Skip to contentSkip to conversation

scsi: ibmvscsi: constify dev_pm_ops structures

PATCH New Bhumika Goyal 1 participant 1 message Jan 15, 2017

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scsi: ibmvscsi: constify dev_pm_ops structures

Declare dev_pm_ops structures as const as they are only stored in the pm field of a vio_driver structure. This field is of type const, so dev_pm_ops structures having similar properties can be declared const. Done using Coccinelle:

@r1 disable optional_qualifier@
identifier i;
position p;
@@
static struct dev_pm_ops i@p={...};

@ok@
identifier r1.i;
position p;
struct vio_driver x;
@@
x.pm=&i@p;

@bad@
position p!={r1.p,ok.p};
identifier r1.i;
@@
i@p

@depends on !bad disable optional_qualifier@
identifier r1.i;
@@
+const
struct dev_pm_ops i;

File sizes after cross compiling the .o files for powerpc architecture.

File size before:
text data bss dec hex filename
57893 5665 20 63578 f85a drivers/scsi/ibmvscsi/ibmvfc.o

File size after:
text data bss dec hex filename
58077 5481 20 63578 f85a drivers/scsi/ibmvscsi/ibmvfc.o

File size before:
text data bss dec hex filenam
20990 2816 80 23886 5d4e drivers/scsi/ibmvscsi/ibmvscsi.o

File size after:
text data bss dec hex filename
21174 2632 80 23886 5d4e drivers/scsi/ibmvscsi/ibmvscsi.o

---
 drivers/scsi/ibmvscsi/ibmvfc.c   | 2 +-
 drivers/scsi/ibmvscsi/ibmvscsi.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/ibmvscsi/ibmvfc.c +1 -1
index 78b72c2..1e1b343 100644
@@ -4940,7 +4940,7 @@ static unsigned long ibmvfc_get_desired_dma(struct vio_dev *vdev)
 };
 MODULE_DEVICE_TABLE(vio, ibmvfc_device_table);
 
-static struct dev_pm_ops ibmvfc_pm_ops = {
+static const struct dev_pm_ops ibmvfc_pm_ops = {
 	.resume = ibmvfc_resume
 };
 
drivers/scsi/ibmvscsi/ibmvscsi.c +1 -1
index 50cd011..b94e7b1 100644
@@ -2335,7 +2335,7 @@ static int ibmvscsi_resume(struct device *dev)
 };
 MODULE_DEVICE_TABLE(vio, ibmvscsi_device_table);
 
-static struct dev_pm_ops ibmvscsi_pm_ops = {
+static const struct dev_pm_ops ibmvscsi_pm_ops = {
 	.resume = ibmvscsi_resume
 };
 
Signature · 1 line
1.9.1