2017-07-28 21:07:18

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 00/11] constify hc_driver structures

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(-)


2017-07-28 21:07:24

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 10/11] greybus: usb: constify hc_driver structures

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 <[email protected]>

---
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),

2017-07-28 21:07:22

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 09/11] USB: whci-hcd: constify hc_driver structures

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 <[email protected]>

---
drivers/usb/host/whci/hcd.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/host/whci/hcd.c b/drivers/usb/host/whci/hcd.c
index 5b3603c..cf84269 100644
--- a/drivers/usb/host/whci/hcd.c
+++ b/drivers/usb/host/whci/hcd.c
@@ -213,7 +213,7 @@ static void whc_endpoint_reset(struct usb_hcd *usb_hcd,
}


-static struct hc_driver whc_hc_driver = {
+static const struct hc_driver whc_hc_driver = {
.description = "whci-hcd",
.product_desc = "Wireless host controller",
.hcd_priv_size = sizeof(struct whc) - sizeof(struct usb_hcd),

2017-07-28 21:07:54

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 08/11] USB: HWA: constify hc_driver structures

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 <[email protected]>

---
drivers/usb/host/hwa-hc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/host/hwa-hc.c b/drivers/usb/host/hwa-hc.c
index 1db0626..8658619 100644
--- a/drivers/usb/host/hwa-hc.c
+++ b/drivers/usb/host/hwa-hc.c
@@ -614,7 +614,7 @@ static int wa_fill_descr(struct wahc *wa)
return result;
}

-static struct hc_driver hwahc_hc_driver = {
+static const struct hc_driver hwahc_hc_driver = {
.description = "hwa-hcd",
.product_desc = "Wireless USB HWA host controller",
.hcd_priv_size = sizeof(struct hwahc) - sizeof(struct usb_hcd),

2017-07-28 21:07:53

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 11/11] c67x00-hcd: constify hc_driver structures

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 <[email protected]>

---
drivers/usb/c67x00/c67x00-hcd.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/c67x00/c67x00-hcd.c b/drivers/usb/c67x00/c67x00-hcd.c
index c2d1396..30d3f34 100644
--- a/drivers/usb/c67x00/c67x00-hcd.c
+++ b/drivers/usb/c67x00/c67x00-hcd.c
@@ -305,7 +305,7 @@ static int c67x00_hcd_get_frame(struct usb_hcd *hcd)
return temp_val ? (temp_val - 1) : HOST_FRAME_MASK;
}

-static struct hc_driver c67x00_hc_driver = {
+static const struct hc_driver c67x00_hc_driver = {
.description = "c67x00-hcd",
.product_desc = "Cypress C67X00 Host Controller",
.hcd_priv_size = sizeof(struct c67x00_hcd),

2017-07-28 21:08:32

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 06/11] usb: renesas_usbhs: constify hc_driver structures

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 <[email protected]>

---
drivers/usb/renesas_usbhs/mod_host.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/renesas_usbhs/mod_host.c b/drivers/usb/renesas_usbhs/mod_host.c
index dfb346e..e256351 100644
--- a/drivers/usb/renesas_usbhs/mod_host.c
+++ b/drivers/usb/renesas_usbhs/mod_host.c
@@ -1285,7 +1285,7 @@ static int usbhsh_bus_nop(struct usb_hcd *hcd)
return 0;
}

-static struct hc_driver usbhsh_driver = {
+static const struct hc_driver usbhsh_driver = {
.description = usbhsh_hcd_name,
.hcd_priv_size = sizeof(struct usbhsh_hpriv),


2017-07-28 21:08:31

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 07/11] isp116x-hcd: constify hc_driver structures

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 <[email protected]>

---
drivers/usb/host/isp116x-hcd.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/host/isp116x-hcd.c b/drivers/usb/host/isp116x-hcd.c
index d089b3f..73fec38 100644
--- a/drivers/usb/host/isp116x-hcd.c
+++ b/drivers/usb/host/isp116x-hcd.c
@@ -1511,7 +1511,7 @@ static int isp116x_bus_resume(struct usb_hcd *hcd)

#endif

-static struct hc_driver isp116x_hc_driver = {
+static const struct hc_driver isp116x_hc_driver = {
.description = hcd_name,
.product_desc = "ISP116x Host Controller",
.hcd_priv_size = sizeof(struct isp116x),

2017-07-28 21:09:06

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 05/11] usb: host: u132-hcd: constify hc_driver structures

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 <[email protected]>

---
drivers/usb/host/u132-hcd.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/host/u132-hcd.c b/drivers/usb/host/u132-hcd.c
index 43d5293..c38855a 100644
--- a/drivers/usb/host/u132-hcd.c
+++ b/drivers/usb/host/u132-hcd.c
@@ -2941,7 +2941,7 @@ static int u132_bus_resume(struct usb_hcd *hcd)
#define u132_bus_suspend NULL
#define u132_bus_resume NULL
#endif
-static struct hc_driver u132_hc_driver = {
+static const struct hc_driver u132_hc_driver = {
.description = hcd_name,
.hcd_priv_size = sizeof(struct u132),
.irq = NULL,

2017-07-28 21:07:17

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 01/11] isp1362-hcd: constify hc_driver structures

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 <[email protected]>

---
drivers/usb/host/isp1362-hcd.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/host/isp1362-hcd.c b/drivers/usb/host/isp1362-hcd.c
index 0f2b4b3..9b7e307 100644
--- a/drivers/usb/host/isp1362-hcd.c
+++ b/drivers/usb/host/isp1362-hcd.c
@@ -2591,7 +2591,7 @@ static int isp1362_hc_start(struct usb_hcd *hcd)

/*-------------------------------------------------------------------------*/

-static struct hc_driver isp1362_hc_driver = {
+static const struct hc_driver isp1362_hc_driver = {
.description = hcd_name,
.product_desc = "ISP1362 Host Controller",
.hcd_priv_size = sizeof(struct isp1362_hcd),

2017-07-28 21:09:40

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 03/11] usb: r8a66597-hcd: constify hc_driver structures

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 <[email protected]>

---
drivers/usb/host/r8a66597-hcd.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/host/r8a66597-hcd.c b/drivers/usb/host/r8a66597-hcd.c
index 7bf78be..5e5fc9d 100644
--- a/drivers/usb/host/r8a66597-hcd.c
+++ b/drivers/usb/host/r8a66597-hcd.c
@@ -2312,7 +2312,7 @@ static int r8a66597_bus_resume(struct usb_hcd *hcd)
#define r8a66597_bus_resume NULL
#endif

-static struct hc_driver r8a66597_hc_driver = {
+static const struct hc_driver r8a66597_hc_driver = {
.description = hcd_name,
.hcd_priv_size = sizeof(struct r8a66597),
.irq = r8a66597_irq,

2017-07-28 21:09:39

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 04/11] usb: host/sl811-hcd: constify hc_driver structures

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 <[email protected]>

---
drivers/usb/host/sl811-hcd.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/host/sl811-hcd.c b/drivers/usb/host/sl811-hcd.c
index fd2a114..24ad1d6 100644
--- a/drivers/usb/host/sl811-hcd.c
+++ b/drivers/usb/host/sl811-hcd.c
@@ -1554,7 +1554,7 @@ static void remove_debug_file(struct sl811 *sl811)

/*-------------------------------------------------------------------------*/

-static struct hc_driver sl811h_hc_driver = {
+static const struct hc_driver sl811h_hc_driver = {
.description = hcd_name,
.hcd_priv_size = sizeof(struct sl811),


2017-07-28 21:10:15

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 02/11] usb: host: max3421-hcd: constify hc_driver structures

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 <[email protected]>

---
drivers/usb/host/max3421-hcd.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/host/max3421-hcd.c b/drivers/usb/host/max3421-hcd.c
index 369869a..0ece9a9 100644
--- a/drivers/usb/host/max3421-hcd.c
+++ b/drivers/usb/host/max3421-hcd.c
@@ -1811,7 +1811,7 @@ enum {
{
}

-static struct hc_driver max3421_hcd_desc = {
+static const struct hc_driver max3421_hcd_desc = {
.description = "max3421",
.product_desc = DRIVER_DESC,
.hcd_priv_size = sizeof(struct max3421_hcd),

2017-07-31 04:25:57

by Viresh Kumar

[permalink] [raw]
Subject: Re: [greybus-dev] [PATCH 10/11] greybus: usb: constify hc_driver structures

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 <[email protected]>
>
> ---
> 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 <[email protected]>

--
viresh

2017-07-31 07:07:24

by Yoshihiro Shimoda

[permalink] [raw]
Subject: RE: [PATCH 06/11] usb: renesas_usbhs: constify hc_driver structures

Hi,

> From: Julia Lawall
> Sent: Saturday, July 29, 2017 5:42 AM
>
> 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 <[email protected]>

Thank you for the patch!

Acked-by: Yoshihiro Shimoda <[email protected]>

Best regards,
Yoshihiro Shimoda


2017-07-31 07:14:18

by Johan Hovold

[permalink] [raw]
Subject: Re: [PATCH 10/11] greybus: usb: constify hc_driver structures

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 <[email protected]>

Acked-by: Johan Hovold <[email protected]>

Thanks,
Johan