Skip to contentSkip to conversation

usb: gadget: make config_item_type structures const

PATCH New Bhumika Goyal 1 participant 1 message Oct 11, 2017

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

PATCH 1/1 usb: gadget: make config_item_type structures const

This is a followup patch for:
https://patchwork.kernel.org/patch/9999649/

Make these structures const as they are only passed to the const argument of the functions config_{group/item}_init_type_name.

Done using Coccinelle:

@rule1 disable optional_qualifier @
identifier x;
@@
static struct config_item_type x={...};

@ref@
position p;
identifier rule1.x;
@@
x@p

@good1@
position ref.p;
identifier rule1.x;
@@
(
config_group_init_type_name(...,&x@p,...)
|
config_item_init_type_name(...,&x@p,...)
|
configfs_register_default_group(...,&x@p,...)
)

@bad depends on !good1@
position ref.p;
identifier rule1.x;
@@
x@p

@depends on forall !bad disable optional_qualifier@ identifier rule1.x;
@@
static
+ const
struct config_item_type x={...};

---
 drivers/usb/gadget/function/f_acm.c          |  2 +-
 drivers/usb/gadget/function/f_ecm.c          |  2 +-
 drivers/usb/gadget/function/f_eem.c          |  2 +-
 drivers/usb/gadget/function/f_fs.c           |  2 +-
 drivers/usb/gadget/function/f_hid.c          |  2 +-
 drivers/usb/gadget/function/f_loopback.c     |  2 +-
 drivers/usb/gadget/function/f_mass_storage.c |  4 +--
 drivers/usb/gadget/function/f_midi.c         |  2 +-
 drivers/usb/gadget/function/f_ncm.c          |  2 +-
 drivers/usb/gadget/function/f_obex.c         |  2 +-
 drivers/usb/gadget/function/f_phonet.c       |  2 +-
 drivers/usb/gadget/function/f_printer.c      |  2 +-
 drivers/usb/gadget/function/f_rndis.c        |  2 +-
 drivers/usb/gadget/function/f_serial.c       |  2 +-
 drivers/usb/gadget/function/f_sourcesink.c   |  2 +-
 drivers/usb/gadget/function/f_subset.c       |  2 +-
 drivers/usb/gadget/function/f_tcm.c          |  2 +-
 drivers/usb/gadget/function/f_uac1.c         |  2 +-
 drivers/usb/gadget/function/f_uac1_legacy.c  |  2 +-
 drivers/usb/gadget/function/f_uac2.c         |  2 +-
 drivers/usb/gadget/function/uvc_configfs.c   | 50 ++++++++++++++--------------
 21 files changed, 46 insertions(+), 46 deletions(-)
drivers/usb/gadget/function/f_acm.c +1 -1
index 5e3828d..8680af4 100644
@@ -786,7 +786,7 @@ static ssize_t f_acm_port_num_show(struct config_item *item, char *page)
 	NULL,
 };
 
-static struct config_item_type acm_func_type = {
+static const struct config_item_type acm_func_type = {
 	.ct_item_ops    = &acm_item_ops,
 	.ct_attrs	= acm_attrs,
 	.ct_owner       = THIS_MODULE,
drivers/usb/gadget/function/f_ecm.c +1 -1
index 4c488d1..9657e19 100644
@@ -845,7 +845,7 @@ static inline struct f_ecm_opts *to_f_ecm_opts(struct config_item *item)
 	NULL,
 };
 
-static struct config_item_type ecm_func_type = {
+static const struct config_item_type ecm_func_type = {
 	.ct_item_ops	= &ecm_item_ops,
 	.ct_attrs	= ecm_attrs,
 	.ct_owner	= THIS_MODULE,
drivers/usb/gadget/function/f_eem.c +1 -1
index 007ec6e..5e5d164 100644
@@ -556,7 +556,7 @@ static inline struct f_eem_opts *to_f_eem_opts(struct config_item *item)
 	NULL,
 };
 
-static struct config_item_type eem_func_type = {
+static const struct config_item_type eem_func_type = {
 	.ct_item_ops	= &eem_item_ops,
 	.ct_attrs	= eem_attrs,
 	.ct_owner	= THIS_MODULE,
drivers/usb/gadget/function/f_fs.c +1 -1
index 8b34258..5362fc4 100644
@@ -3385,7 +3385,7 @@ static void ffs_attr_release(struct config_item *item)
 	.release	= ffs_attr_release,
 };
 
-static struct config_item_type ffs_func_type = {
+static const struct config_item_type ffs_func_type = {
 	.ct_item_ops	= &ffs_item_ops,
 	.ct_owner	= THIS_MODULE,
 };
drivers/usb/gadget/function/f_hid.c +1 -1
index d8e359e..6993cb8 100644
@@ -992,7 +992,7 @@ static ssize_t f_hid_opts_dev_show(struct config_item *item, char *page)
 	NULL,
 };
 
-static struct config_item_type hid_func_type = {
+static const struct config_item_type hid_func_type = {
 	.ct_item_ops	= &hidg_item_ops,
 	.ct_attrs	= hid_attrs,
 	.ct_owner	= THIS_MODULE,
drivers/usb/gadget/function/f_loopback.c +1 -1
index e700938..9311f8c 100644
@@ -556,7 +556,7 @@ static ssize_t f_lb_opts_bulk_buflen_store(struct config_item *item,
 	NULL,
 };
 
-static struct config_item_type lb_func_type = {
+static const struct config_item_type lb_func_type = {
 	.ct_item_ops    = &lb_item_ops,
 	.ct_attrs	= lb_attrs,
 	.ct_owner       = THIS_MODULE,
drivers/usb/gadget/function/f_mass_storage.c +2 -2
index 5153e29..a538be3 100644
@@ -3140,7 +3140,7 @@ static ssize_t fsg_lun_opts_inquiry_string_store(struct config_item *item,
 	NULL,
 };
 
-static struct config_item_type fsg_lun_type = {
+static const struct config_item_type fsg_lun_type = {
 	.ct_item_ops	= &fsg_lun_item_ops,
 	.ct_attrs	= fsg_lun_attrs,
 	.ct_owner	= THIS_MODULE,
@@ -3331,7 +3331,7 @@ static ssize_t fsg_opts_num_buffers_store(struct config_item *item,
 	.drop_item	= fsg_lun_drop,
 };
 
-static struct config_item_type fsg_func_type = {
+static const struct config_item_type fsg_func_type = {
 	.ct_item_ops	= &fsg_item_ops,
 	.ct_group_ops	= &fsg_group_ops,
 	.ct_attrs	= fsg_attrs,
drivers/usb/gadget/function/f_midi.c +1 -1
index 5d3d794..53fa073 100644
@@ -1189,7 +1189,7 @@ static ssize_t f_midi_opts_id_store(struct config_item *item,
 	NULL,
 };
 
-static struct config_item_type midi_func_type = {
+static const struct config_item_type midi_func_type = {
 	.ct_item_ops	= &midi_item_ops,
 	.ct_attrs	= midi_attrs,
 	.ct_owner	= THIS_MODULE,
drivers/usb/gadget/function/f_ncm.c +1 -1
index 45b334c..3599aa4 100644
@@ -1568,7 +1568,7 @@ static inline struct f_ncm_opts *to_f_ncm_opts(struct config_item *item)
 	NULL,
 };
 
-static struct config_item_type ncm_func_type = {
+static const struct config_item_type ncm_func_type = {
 	.ct_item_ops	= &ncm_item_ops,
 	.ct_attrs	= ncm_attrs,
 	.ct_owner	= THIS_MODULE,
drivers/usb/gadget/function/f_obex.c +1 -1
index d43e86c..9fc7988 100644
@@ -411,7 +411,7 @@ static ssize_t f_obex_port_num_show(struct config_item *item, char *page)
 	NULL,
 };
 
-static struct config_item_type obex_func_type = {
+static const struct config_item_type obex_func_type = {
 	.ct_item_ops	= &obex_item_ops,
 	.ct_attrs	= acm_attrs,
 	.ct_owner	= THIS_MODULE,
drivers/usb/gadget/function/f_phonet.c +1 -1
index 9c4c58e..5fe1f2a 100644
@@ -599,7 +599,7 @@ static ssize_t f_phonet_ifname_show(struct config_item *item, char *page)
 	NULL,
 };
 
-static struct config_item_type phonet_func_type = {
+static const struct config_item_type phonet_func_type = {
 	.ct_item_ops	= &phonet_item_ops,
 	.ct_attrs	= phonet_attrs,
 	.ct_owner	= THIS_MODULE,
drivers/usb/gadget/function/f_printer.c +1 -1
index ea0da35a..8072836 100644
@@ -1261,7 +1261,7 @@ static ssize_t f_printer_opts_q_len_store(struct config_item *item,
 	NULL,
 };
 
-static struct config_item_type printer_func_type = {
+static const struct config_item_type printer_func_type = {
 	.ct_item_ops	= &printer_item_ops,
 	.ct_attrs	= printer_attrs,
 	.ct_owner	= THIS_MODULE,
drivers/usb/gadget/function/f_rndis.c +1 -1
index e1d5853..7dc599e 100644
@@ -890,7 +890,7 @@ static inline struct f_rndis_opts *to_f_rndis_opts(struct config_item *item)
 	NULL,
 };
 
-static struct config_item_type rndis_func_type = {
+static const struct config_item_type rndis_func_type = {
 	.ct_item_ops	= &rndis_item_ops,
 	.ct_attrs	= rndis_attrs,
 	.ct_owner	= THIS_MODULE,
drivers/usb/gadget/function/f_serial.c +1 -1
index cb00ada..4ee860b 100644
@@ -281,7 +281,7 @@ static ssize_t f_serial_port_num_show(struct config_item *item, char *page)
 	NULL,
 };
 
-static struct config_item_type serial_func_type = {
+static const struct config_item_type serial_func_type = {
 	.ct_item_ops	= &serial_item_ops,
 	.ct_attrs	= acm_attrs,
 	.ct_owner	= THIS_MODULE,
drivers/usb/gadget/function/f_sourcesink.c +1 -1
index 8784fa1..ed22e18 100644
@@ -1230,7 +1230,7 @@ static ssize_t f_ss_opts_iso_qlen_store(struct config_item *item,
 	NULL,
 };
 
-static struct config_item_type ss_func_type = {
+static const struct config_item_type ss_func_type = {
 	.ct_item_ops    = &ss_item_ops,
 	.ct_attrs	= ss_attrs,
 	.ct_owner       = THIS_MODULE,
drivers/usb/gadget/function/f_subset.c +1 -1
index 434b983..e810d15 100644
@@ -412,7 +412,7 @@ static inline struct f_gether_opts *to_f_gether_opts(struct config_item *item)
 	NULL,
 };
 
-static struct config_item_type gether_func_type = {
+static const struct config_item_type gether_func_type = {
 	.ct_item_ops	= &gether_item_ops,
 	.ct_attrs	= gether_attrs,
 	.ct_owner	= THIS_MODULE,
drivers/usb/gadget/function/f_tcm.c +1 -1
index a82e2bd..e3cec75 100644
@@ -2166,7 +2166,7 @@ static void tcm_attr_release(struct config_item *item)
 	.release		= tcm_attr_release,
 };
 
-static struct config_item_type tcm_func_type = {
+static const struct config_item_type tcm_func_type = {
 	.ct_item_ops	= &tcm_item_ops,
 	.ct_owner	= THIS_MODULE,
 };
drivers/usb/gadget/function/f_uac1.c +1 -1
index 29efbed..4d5487a 100644
@@ -709,7 +709,7 @@ static void f_uac1_attr_release(struct config_item *item)
 	NULL,
 };
 
-static struct config_item_type f_uac1_func_type = {
+static const struct config_item_type f_uac1_func_type = {
 	.ct_item_ops	= &f_uac1_item_ops,
 	.ct_attrs	= f_uac1_attrs,
 	.ct_owner	= THIS_MODULE,
drivers/usb/gadget/function/f_uac1_legacy.c +1 -1
index 5d229e7..178fd12 100644
@@ -921,7 +921,7 @@ static void f_uac1_attr_release(struct config_item *item)
 	NULL,
 };
 
-static struct config_item_type f_uac1_func_type = {
+static const struct config_item_type f_uac1_func_type = {
 	.ct_item_ops	= &f_uac1_item_ops,
 	.ct_attrs	= f_uac1_attrs,
 	.ct_owner	= THIS_MODULE,
drivers/usb/gadget/function/f_uac2.c +1 -1
index f05c3f3..7bb9737 100644
@@ -921,7 +921,7 @@ static void f_uac2_attr_release(struct config_item *item)
 	NULL,
 };
 
-static struct config_item_type f_uac2_func_type = {
+static const struct config_item_type f_uac2_func_type = {
 	.ct_item_ops	= &f_uac2_item_ops,
 	.ct_attrs	= f_uac2_attrs,
 	.ct_owner	= THIS_MODULE,
drivers/usb/gadget/function/uvc_configfs.c +25 -25

200 lines not on this page · raw message

Signature · 1 line
1.9.1