qlogic: netxen: constify bin_attribute structures
authorBhumika Goyal <bhumirks@gmail.com>
Tue, 21 Feb 2017 18:47:48 +0000 (00:17 +0530)
committerDavid S. Miller <davem@davemloft.net>
Wed, 22 Feb 2017 20:39:09 +0000 (15:39 -0500)
Declare bin_attribute structures as const as they are only passed as an
arguments to the functions device_remove_bin_file and
device_create_bin_file. These function arguments are of type const, so
bin_attribute structures having this property can be made const too.
Done using Coccinelle:

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

@ok1@
identifier r1.i;
position p,p1;
@@
(
device_remove_bin_file(...,&i@p)
|
device_create_bin_file(..., &i@p1)
)

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

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

Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c

index 3b5d7cf..827de83 100644 (file)
@@ -3005,14 +3005,14 @@ static ssize_t netxen_sysfs_write_mem(struct file *filp, struct kobject *kobj,
 }
 
 
-static struct bin_attribute bin_attr_crb = {
+static const struct bin_attribute bin_attr_crb = {
        .attr = {.name = "crb", .mode = (S_IRUGO | S_IWUSR)},
        .size = 0,
        .read = netxen_sysfs_read_crb,
        .write = netxen_sysfs_write_crb,
 };
 
-static struct bin_attribute bin_attr_mem = {
+static const struct bin_attribute bin_attr_mem = {
        .attr = {.name = "mem", .mode = (S_IRUGO | S_IWUSR)},
        .size = 0,
        .read = netxen_sysfs_read_mem,
@@ -3141,7 +3141,7 @@ out:
 
 }
 
-static struct bin_attribute bin_attr_dimm = {
+static const struct bin_attribute bin_attr_dimm = {
        .attr = { .name = "dimm", .mode = (S_IRUGO | S_IWUSR) },
        .size = sizeof(struct netxen_dimm_cfg),
        .read = netxen_sysfs_read_dimm,