PCI: kirin: Make structure kirin_dw_pcie_ops constant
PATCH 1/1 PCI: kirin: Make structure kirin_dw_pcie_ops constant
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.
--- drivers/pci/controller/dwc/pcie-kirin.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/controller/dwc/pcie-kirin.c +1 -1
@@ -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,
Signature · 1 line
2.19.1
Quoted 16 lines · Nishka Dasgupta
Static variable
kirin_dw_pcie_ops, of typedw_pcie_ops, is used only once, when it is assigned to the constant field ops of variable pci (having typedw_pcie). Hencekirin_dw_pcie_opsis never modified. Therefore, make it constant to protect it from unintended modification. Issue found with Coccinelle.Signed-off-by Nishka Dasgupta <[email protected]>--- drivers/pci/controller/dwc/pcie-kirin.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/pci/controller/dwc/pcie-kirin.c +0
-0
drivers/pci/controller/dwc/pcie-kirin.c static int kirin_pcie_host_init(struct pcie_port *pp) · line 442
Quoted 8 lines
drivers/pci/controller/dwc/pcie-kirin.c +1
-1@@ -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.
Quoted 3 lines
Signature · 1 line
2.19.1
Lorenzo Pieralisi
AppliedQuoted 10 lines · Nishka Dasgupta
Static variable
kirin_dw_pcie_ops, of typedw_pcie_ops, is used only once, when it is assigned to the constant field ops of variable pci (having typedw_pcie). Hencekirin_dw_pcie_opsis never modified. Therefore, make it constant to protect it from unintended modification. Issue found with Coccinelle.Signed-off-by Nishka Dasgupta <[email protected]>--- drivers/pci/controller/dwc/pcie-kirin.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Applied to pci/dwc for v5.4, thanks.
Lorenzo
Quoted 16 lines
drivers/pci/controller/dwc/pcie-kirin.c +1
-1@@ -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,Signature · 1 line
2.19.1