The hc_driver structure is only passed as the first argument to usb_create_hcd, which is declared as const. Thus the hc_driver structure itself can be const.
Done with the help of Coccinelle.
// <smpl> @r disable optional_qualifier@ identifier i; position p; @@
static struct hc_driver i@p = { ... };
@ok1@ identifier r.i; expression e1; position p; @@
usb_create_hcd(&i@p,...)
@bad@ position p != {r.p,ok1.p}; identifier r.i; struct hc_driver e; @@
e@i@p
@depends on !bad disable optional_qualifier@ identifier r.i; @@
static +const struct hc_driver i = { ... }; // </smpl>
---
drivers/staging/greybus/usb.c | 2 +- drivers/usb/c67x00/c67x00-hcd.c | 2 +- drivers/usb/host/hwa-hc.c | 2 +- drivers/usb/host/isp116x-hcd.c | 2 +- drivers/usb/host/isp1362-hcd.c | 2 +- drivers/usb/host/max3421-hcd.c | 2 +- drivers/usb/host/r8a66597-hcd.c | 2 +- drivers/usb/host/sl811-hcd.c | 2 +- drivers/usb/host/u132-hcd.c | 2 +- drivers/usb/host/whci/hcd.c | 2 +- drivers/usb/renesas_usbhs/mod_host.c | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-)
The hc_driver structure is only passed as the first argument to usb_create_hcd, which is declared as const. Thus the hc_driver structure itself can be const.
Done with the help of Coccinelle.
Signed-off-by: Julia Lawall Julia.Lawall@lip6.fr
--- drivers/staging/greybus/usb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/staging/greybus/usb.c b/drivers/staging/greybus/usb.c index ccadda0..f93a76d 100644 --- a/drivers/staging/greybus/usb.c +++ b/drivers/staging/greybus/usb.c @@ -139,7 +139,7 @@ static int hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, u16 wIndex, return ret; }
-static struct hc_driver usb_gb_hc_driver = { +static const struct hc_driver usb_gb_hc_driver = { .description = "greybus-hcd", .product_desc = "Greybus USB Host Controller", .hcd_priv_size = sizeof(struct gb_usb_device),
On 28-07-17, 22:41, Julia Lawall wrote:
The hc_driver structure is only passed as the first argument to usb_create_hcd, which is declared as const. Thus the hc_driver structure itself can be const.
Done with the help of Coccinelle.
Signed-off-by: Julia Lawall Julia.Lawall@lip6.fr
drivers/staging/greybus/usb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/staging/greybus/usb.c b/drivers/staging/greybus/usb.c index ccadda0..f93a76d 100644 --- a/drivers/staging/greybus/usb.c +++ b/drivers/staging/greybus/usb.c @@ -139,7 +139,7 @@ static int hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, u16 wIndex, return ret; } -static struct hc_driver usb_gb_hc_driver = { +static const struct hc_driver usb_gb_hc_driver = { .description = "greybus-hcd", .product_desc = "Greybus USB Host Controller", .hcd_priv_size = sizeof(struct gb_usb_device),
Reviewed-by: Viresh Kumar viresh.kumar@linaro.org
On Fri, Jul 28, 2017 at 10:41:57PM +0200, Julia Lawall wrote:
The hc_driver structure is only passed as the first argument to usb_create_hcd, which is declared as const. Thus the hc_driver structure itself can be const.
Done with the help of Coccinelle.
Signed-off-by: Julia Lawall Julia.Lawall@lip6.fr
Acked-by: Johan Hovold johan@kernel.org
Thanks, Johan