2017-08-12 06:10:11

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 0/6] constify pci_error_handlers structures

These pci_error_handlers structures are only stored in the err_handler
field of a pci_driver structure, and this field is declared as const. Thus
the pci_error_handlers structures can be const too.

Done with the help of Coccinelle.

---

drivers/misc/genwqe/card_base.c | 2 +-
drivers/scsi/aacraid/linit.c | 2 +-
drivers/scsi/be2iscsi/be_main.c | 2 +-
drivers/scsi/bfa/bfad.c | 2 +-
drivers/scsi/csiostor/csio_init.c | 2 +-
drivers/scsi/mpt3sas/mpt3sas_scsih.c | 2 +-
6 files changed, 6 insertions(+), 6 deletions(-)


2017-08-12 06:10:15

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 2/6] GenWQE: constify pci_error_handlers structures

These pci_error_handlers structures are only stored in the err_handler
field of a pci_driver structure, and this field is declared as const. Thus
the pci_error_handlers structures can be const too.

Done with the help of Coccinelle.

Signed-off-by: Julia Lawall <[email protected]>

---
drivers/misc/genwqe/card_base.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/misc/genwqe/card_base.c b/drivers/misc/genwqe/card_base.c
index 4fd21e8..8650046 100644
--- a/drivers/misc/genwqe/card_base.c
+++ b/drivers/misc/genwqe/card_base.c
@@ -1333,7 +1333,7 @@ static int genwqe_sriov_configure(struct pci_dev *dev, int numvfs)
return 0;
}

-static struct pci_error_handlers genwqe_err_handler = {
+static const struct pci_error_handlers genwqe_err_handler = {
.error_detected = genwqe_err_error_detected,
.mmio_enabled = genwqe_err_result_none,
.slot_reset = genwqe_err_slot_reset,

2017-08-12 06:10:13

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 1/6] scsi: mpt3sas: constify pci_error_handlers structures

These pci_error_handlers structures are only stored in the err_handler
field of a pci_driver structure, and this field is declared as const. Thus
the pci_error_handlers structures can be const too.

Done with the help of Coccinelle.

Signed-off-by: Julia Lawall <[email protected]>

---
drivers/scsi/mpt3sas/mpt3sas_scsih.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
index 22998cb..52c163f 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
@@ -9277,7 +9277,7 @@ bool scsih_ncq_prio_supp(struct scsi_device *sdev)
};
MODULE_DEVICE_TABLE(pci, mpt3sas_pci_table);

-static struct pci_error_handlers _mpt3sas_err_handler = {
+static const struct pci_error_handlers _mpt3sas_err_handler = {
.error_detected = scsih_pci_error_detected,
.mmio_enabled = scsih_pci_mmio_enabled,
.slot_reset = scsih_pci_slot_reset,

2017-08-12 06:10:35

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 6/6] bfa: constify pci_error_handlers structures

These pci_error_handlers structures are only stored in the err_handler
field of a pci_driver structure, and this field is declared as const. Thus
the pci_error_handlers structures can be const too.

Done with the help of Coccinelle.

Signed-off-by: Julia Lawall <[email protected]>

---
drivers/scsi/bfa/bfad.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/bfa/bfad.c b/drivers/scsi/bfa/bfad.c
index 5caf5f3..2861694 100644
--- a/drivers/scsi/bfa/bfad.c
+++ b/drivers/scsi/bfa/bfad.c
@@ -1683,7 +1683,7 @@ struct pci_device_id bfad_id_table[] = {
/*
* PCI error recovery handlers.
*/
-static struct pci_error_handlers bfad_err_handler = {
+static const struct pci_error_handlers bfad_err_handler = {
.error_detected = bfad_pci_error_detected,
.slot_reset = bfad_pci_slot_reset,
.mmio_enabled = bfad_pci_mmio_enabled,

2017-08-12 06:10:56

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 5/6] [SCSI] csiostor: constify pci_error_handlers structures

These pci_error_handlers structures are only stored in the err_handler
field of a pci_driver structure, and this field is declared as const. Thus
the pci_error_handlers structures can be const too.

Done with the help of Coccinelle.

Signed-off-by: Julia Lawall <[email protected]>

---
drivers/scsi/csiostor/csio_init.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/csiostor/csio_init.c b/drivers/scsi/csiostor/csio_init.c
index 28a9c7d..ab4fbcf 100644
--- a/drivers/scsi/csiostor/csio_init.c
+++ b/drivers/scsi/csiostor/csio_init.c
@@ -1168,7 +1168,7 @@ static void csio_remove_one(struct pci_dev *pdev)
dev_err(&pdev->dev, "resume of device failed: %d\n", rv);
}

-static struct pci_error_handlers csio_err_handler = {
+static const struct pci_error_handlers csio_err_handler = {
.error_detected = csio_pci_error_detected,
.slot_reset = csio_pci_slot_reset,
.resume = csio_pci_resume,

2017-08-12 06:11:32

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 4/6] scsi: be2iscsi: constify pci_error_handlers structures

These pci_error_handlers structures are only stored in the err_handler
field of a pci_driver structure, and this field is declared as const. Thus
the pci_error_handlers structures can be const too.

Done with the help of Coccinelle.

Signed-off-by: Julia Lawall <[email protected]>

---
drivers/scsi/be2iscsi/be_main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index b4542e7..511732a 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -5786,7 +5786,7 @@ static void beiscsi_remove(struct pci_dev *pcidev)
}


-static struct pci_error_handlers beiscsi_eeh_handlers = {
+static const struct pci_error_handlers beiscsi_eeh_handlers = {
.error_detected = beiscsi_eeh_err_detected,
.slot_reset = beiscsi_eeh_reset,
.resume = beiscsi_eeh_resume,

2017-08-12 06:11:50

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 3/6] scsi: aacraid: constify pci_error_handlers structures

These pci_error_handlers structures are only stored in the err_handler
field of a pci_driver structure, and this field is declared as const. Thus
the pci_error_handlers structures can be const too.

Done with the help of Coccinelle.

Signed-off-by: Julia Lawall <[email protected]>

---
drivers/scsi/aacraid/linit.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c
index a8dedc3..2b978d8 100644
--- a/drivers/scsi/aacraid/linit.c
+++ b/drivers/scsi/aacraid/linit.c
@@ -2070,7 +2070,7 @@ static void aac_pci_resume(struct pci_dev *pdev)
dev_err(&pdev->dev, "aacraid: PCI error - resume\n");
}

-static struct pci_error_handlers aac_pci_err_handler = {
+static const struct pci_error_handlers aac_pci_err_handler = {
.error_detected = aac_pci_error_detected,
.mmio_enabled = aac_pci_mmio_enabled,
.slot_reset = aac_pci_slot_reset,

2017-08-12 07:44:54

by Christoph Hellwig

[permalink] [raw]
Subject: Re: [PATCH 0/6] constify pci_error_handlers structures

On Sat, Aug 12, 2017 at 07:44:28AM +0200, Julia Lawall wrote:
> These pci_error_handlers structures are only stored in the err_handler
> field of a pci_driver structure, and this field is declared as const. Thus
> the pci_error_handlers structures can be const too.
>
> Done with the help of Coccinelle.

If you're doing a scripted conversion of the pci_error_handlers
structured I'd much rather see that structure killed off and folded
into the pci_driver one.

2017-08-12 07:52:31

by Julia Lawall

[permalink] [raw]
Subject: Re: [PATCH 0/6] constify pci_error_handlers structures



On Sat, 12 Aug 2017, Christoph Hellwig wrote:

> On Sat, Aug 12, 2017 at 07:44:28AM +0200, Julia Lawall wrote:
> > These pci_error_handlers structures are only stored in the err_handler
> > field of a pci_driver structure, and this field is declared as const. Thus
> > the pci_error_handlers structures can be const too.
> >
> > Done with the help of Coccinelle.
>
> If you're doing a scripted conversion of the pci_error_handlers
> structured I'd much rather see that structure killed off and folded
> into the pci_driver one.

OK, sure. So to be precise, you want the fields error_detected,
mmio_enabled, etc to be added as new fields to the pci_driver structure?

They both have a resume field, though. What should the pci_error_handlers
resume function be renamed to? Would resume_after_error be too much?

julia

2017-08-12 07:56:19

by Christoph Hellwig

[permalink] [raw]
Subject: Re: [PATCH 0/6] constify pci_error_handlers structures

On Sat, Aug 12, 2017 at 09:52:28AM +0200, Julia Lawall wrote:
> OK, sure. So to be precise, you want the fields error_detected,
> mmio_enabled, etc to be added as new fields to the pci_driver structure?

Yes.

> They both have a resume field, though. What should the pci_error_handlers
> resume function be renamed to? Would resume_after_error be too much?

error_resume maybe?

FYI, I already killed it for the PCIe port drivers a while ago:

https://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git/commit/?h=pci/aer&id=c5dc3c69f17a7e77359f10c342d1816390bc8846

2017-08-12 08:00:35

by Julia Lawall

[permalink] [raw]
Subject: Re: [PATCH 0/6] constify pci_error_handlers structures



On Sat, 12 Aug 2017, Christoph Hellwig wrote:

> On Sat, Aug 12, 2017 at 09:52:28AM +0200, Julia Lawall wrote:
> > OK, sure. So to be precise, you want the fields error_detected,
> > mmio_enabled, etc to be added as new fields to the pci_driver structure?
>
> Yes.
>
> > They both have a resume field, though. What should the pci_error_handlers
> > resume function be renamed to? Would resume_after_error be too much?
>
> error_resume maybe?

OK

>
> FYI, I already killed it for the PCIe port drivers a while ago:
>
> https://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git/commit/?h=pci/aer&id=c5dc3c69f17a7e77359f10c342d1816390bc8846

Thanks for the pointer.

julia

2017-08-12 11:51:27

by Julia Lawall

[permalink] [raw]
Subject: Re: [PATCH 0/6] constify pci_error_handlers structures

Another issue arises in the files drivers/infiniband/hw/hfi1/pcie.c and
drivers/infiniband/hw/qib/qib_pcie.c, where the pci_error_handlers
structure is defined in one file and used in another file. The structure
definition references various functions that are static in the same file.
Should I try to move those functions to the file containing the pci_driver
structure? Or leave the functions where they are and remove the static
annotation?

thanks,
julia

2017-08-13 02:32:58

by Dave Carroll

[permalink] [raw]
Subject: RE: [PATCH 3/6] scsi: aacraid: constify pci_error_handlers structures

>
> These pci_error_handlers structures are only stored in the err_handler field of a
> pci_driver structure, and this field is declared as const. Thus the
> pci_error_handlers structures can be const too.
>
> Done with the help of Coccinelle.
>
> Signed-off-by: Julia Lawall <[email protected]>
>
> ---
> drivers/scsi/aacraid/linit.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c index
> a8dedc3..2b978d8 100644
> --- a/drivers/scsi/aacraid/linit.c
> +++ b/drivers/scsi/aacraid/linit.c
> @@ -2070,7 +2070,7 @@ static void aac_pci_resume(struct pci_dev *pdev)
> dev_err(&pdev->dev, "aacraid: PCI error - resume\n"); }
>
> -static struct pci_error_handlers aac_pci_err_handler = {
> +static const struct pci_error_handlers aac_pci_err_handler = {
> .error_detected = aac_pci_error_detected,
> .mmio_enabled = aac_pci_mmio_enabled,
> .slot_reset = aac_pci_slot_reset,

Acked-by: Dave Carroll <[email protected]>


2017-08-13 14:37:53

by Christoph Hellwig

[permalink] [raw]
Subject: Re: [PATCH 0/6] constify pci_error_handlers structures

On Sat, Aug 12, 2017 at 01:51:21PM +0200, Julia Lawall wrote:
> Another issue arises in the files drivers/infiniband/hw/hfi1/pcie.c and
> drivers/infiniband/hw/qib/qib_pcie.c, where the pci_error_handlers
> structure is defined in one file and used in another file. The structure
> definition references various functions that are static in the same file.
> Should I try to move those functions to the file containing the pci_driver
> structure? Or leave the functions where they are and remove the static
> annotation?

I'd just leave them as-is and remove the static for now.