diff mbox series

PCI: kirin: Make structure kirin_dw_pcie_ops constant

Message ID 20190819073946.32458-1-nishkadg.linux@gmail.com (mailing list archive)
State Mainlined, archived
Commit 5ae6393e6d41c7cc38c1ce679bc91c475412c624
Headers show
Series PCI: kirin: Make structure kirin_dw_pcie_ops constant | expand

Commit Message

Nishka Dasgupta Aug. 19, 2019, 7:39 a.m. UTC
Static variable kirin_dw_pcie_ops, of type dw_pcie_ops, is used only
once, when it is assigned to the constant field ops of variable pci
(having type dw_pcie). Hence kirin_dw_pcie_ops is never modified.
Therefore, make it constant to protect it from unintended modification.
Issue found with Coccinelle.

Signed-off-by: Nishka Dasgupta <nishkadg.linux@gmail.com>
---
 drivers/pci/controller/dwc/pcie-kirin.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Andrew Murray Aug. 19, 2019, 5:30 p.m. UTC | #1
On Mon, Aug 19, 2019 at 01:09:46PM +0530, Nishka Dasgupta wrote:
> Static variable kirin_dw_pcie_ops, of type dw_pcie_ops, is used only
> once, when it is assigned to the constant field ops of variable pci
> (having type dw_pcie). Hence kirin_dw_pcie_ops is never modified.
> Therefore, make it constant to protect it from unintended modification.
> Issue found with Coccinelle.
> 
> Signed-off-by: Nishka Dasgupta <nishkadg.linux@gmail.com>
> ---
>  drivers/pci/controller/dwc/pcie-kirin.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/pci/controller/dwc/pcie-kirin.c b/drivers/pci/controller/dwc/pcie-kirin.c
> index 8df1914226be..c19617a912bd 100644
> --- a/drivers/pci/controller/dwc/pcie-kirin.c
> +++ b/drivers/pci/controller/dwc/pcie-kirin.c
> @@ -436,7 +436,7 @@ static int kirin_pcie_host_init(struct pcie_port *pp)
>  	return 0;
>  }
>  
> -static struct dw_pcie_ops kirin_dw_pcie_ops = {
> +static const struct dw_pcie_ops kirin_dw_pcie_ops = {
>  	.read_dbi = kirin_pcie_read_dbi,
>  	.write_dbi = kirin_pcie_write_dbi,
>  	.link_up = kirin_pcie_link_up,

This makes sense, and const is applied to the same structure in many of
the other controller drivers.

Reviewed-by: Andrew Murray <andrew.murray@arm.com>

> -- 
> 2.19.1
>
Lorenzo Pieralisi Aug. 21, 2019, 11:12 a.m. UTC | #2
On Mon, Aug 19, 2019 at 01:09:46PM +0530, Nishka Dasgupta wrote:
> Static variable kirin_dw_pcie_ops, of type dw_pcie_ops, is used only
> once, when it is assigned to the constant field ops of variable pci
> (having type dw_pcie). Hence kirin_dw_pcie_ops is never modified.
> Therefore, make it constant to protect it from unintended modification.
> Issue found with Coccinelle.
> 
> Signed-off-by: Nishka Dasgupta <nishkadg.linux@gmail.com>
> ---
>  drivers/pci/controller/dwc/pcie-kirin.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Applied to pci/dwc for v5.4, thanks.

Lorenzo

> diff --git a/drivers/pci/controller/dwc/pcie-kirin.c b/drivers/pci/controller/dwc/pcie-kirin.c
> index 8df1914226be..c19617a912bd 100644
> --- a/drivers/pci/controller/dwc/pcie-kirin.c
> +++ b/drivers/pci/controller/dwc/pcie-kirin.c
> @@ -436,7 +436,7 @@ static int kirin_pcie_host_init(struct pcie_port *pp)
>  	return 0;
>  }
>  
> -static struct dw_pcie_ops kirin_dw_pcie_ops = {
> +static const struct dw_pcie_ops kirin_dw_pcie_ops = {
>  	.read_dbi = kirin_pcie_read_dbi,
>  	.write_dbi = kirin_pcie_write_dbi,
>  	.link_up = kirin_pcie_link_up,
> -- 
> 2.19.1
>
diff mbox series

Patch

diff --git a/drivers/pci/controller/dwc/pcie-kirin.c b/drivers/pci/controller/dwc/pcie-kirin.c
index 8df1914226be..c19617a912bd 100644
--- a/drivers/pci/controller/dwc/pcie-kirin.c
+++ b/drivers/pci/controller/dwc/pcie-kirin.c
@@ -436,7 +436,7 @@  static int kirin_pcie_host_init(struct pcie_port *pp)
 	return 0;
 }
 
-static struct dw_pcie_ops kirin_dw_pcie_ops = {
+static const struct dw_pcie_ops kirin_dw_pcie_ops = {
 	.read_dbi = kirin_pcie_read_dbi,
 	.write_dbi = kirin_pcie_write_dbi,
 	.link_up = kirin_pcie_link_up,