2021-09-29 14:14:33

by Rikard Falkeborn

[permalink] [raw]
Subject: [PATCH 0/2] usb: cdc-wdm: Fix config and constify

This series fixes an wrong ifdef which caused a chunk of the code to
never be compiled, regardless of config selected.

While at it, constify a static struct full of function pointers.

Rikard Falkeborn (2):
usb: cdc-wdm: Fix check for WWAN
usb: cdc-wdm: Constify static struct wwan_port_ops

drivers/usb/class/cdc-wdm.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

--
2.33.0


2021-09-29 14:15:24

by Rikard Falkeborn

[permalink] [raw]
Subject: [PATCH 2/2] usb: cdc-wdm: Constify static struct wwan_port_ops

The only usage of wdm_wwan_port_ops is to pass its address to
wwan_create_port() which takes a pointer to const wwan_port_ops as
argument. Make it const to allow the compiler to put it in read-only
memory.

Signed-off-by: Rikard Falkeborn <[email protected]>
---
drivers/usb/class/cdc-wdm.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/class/cdc-wdm.c b/drivers/usb/class/cdc-wdm.c
index 03b25aaaa1dd..e5834f1228f9 100644
--- a/drivers/usb/class/cdc-wdm.c
+++ b/drivers/usb/class/cdc-wdm.c
@@ -911,7 +911,7 @@ static int wdm_wwan_port_tx(struct wwan_port *port, struct sk_buff *skb)
return rv;
}

-static struct wwan_port_ops wdm_wwan_port_ops = {
+static const struct wwan_port_ops wdm_wwan_port_ops = {
.start = wdm_wwan_port_start,
.stop = wdm_wwan_port_stop,
.tx = wdm_wwan_port_tx,
--
2.33.0

2021-09-30 12:13:26

by Oliver Neukum

[permalink] [raw]
Subject: Re: [PATCH 2/2] usb: cdc-wdm: Constify static struct wwan_port_ops


On 29.09.21 15:21, Rikard Falkeborn wrote:
> The only usage of wdm_wwan_port_ops is to pass its address to
> wwan_create_port() which takes a pointer to const wwan_port_ops as
> argument. Make it const to allow the compiler to put it in read-only
> memory.
>
> Signed-off-by: Rikard Falkeborn <[email protected]>
Acked-by: Oliver Neukum <[email protected]>