* [6/7] net: huawei_cdc_ncm: add usbnet -> priv function
@ 2018-10-12 9:16 Ben Dooks
0 siblings, 0 replies; 2+ messages in thread
From: Ben Dooks @ 2018-10-12 9:16 UTC (permalink / raw)
To: davem, netdev
Cc: linux-usb, linux-kernel, linux-kernel, gregkh, bjorn,
steve.glendinning, Ben Dooks
There are a number of places in the huawei driver where it gets the
private-data from the usbnet passed in. It would be sensible to have
one inline function to convert it and change all points in the driver
to use that.
Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
---
---
drivers/net/usb/huawei_cdc_ncm.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/drivers/net/usb/huawei_cdc_ncm.c b/drivers/net/usb/huawei_cdc_ncm.c
index 63f28908afda..d290b8c318be 100644
--- a/drivers/net/usb/huawei_cdc_ncm.c
+++ b/drivers/net/usb/huawei_cdc_ncm.c
@@ -38,9 +38,14 @@ struct huawei_cdc_ncm_state {
struct usb_interface *data;
};
+static inline struct huawei_cdc_ncm_state *usbnet_to_state(struct usbnet *usb)
+{
+ return (struct huawei_cdc_ncm_state *)&usb->data;
+}
+
static int huawei_cdc_ncm_manage_power(struct usbnet *usbnet_dev, int on)
{
- struct huawei_cdc_ncm_state *drvstate = (void *)&usbnet_dev->data;
+ struct huawei_cdc_ncm_state *drvstate = usbnet_to_state(usbnet_dev);
int rv;
if ((on && atomic_add_return(1, &drvstate->pmcount) == 1) ||
@@ -72,7 +77,7 @@ static int huawei_cdc_ncm_bind(struct usbnet *usbnet_dev,
struct cdc_ncm_ctx *ctx;
struct usb_driver *subdriver = ERR_PTR(-ENODEV);
int ret = -ENODEV;
- struct huawei_cdc_ncm_state *drvstate = (void *)&usbnet_dev->data;
+ struct huawei_cdc_ncm_state *drvstate = usbnet_to_state(usbnet_dev);
int drvflags = 0;
/* altsetting should always be 1 for NCM devices - so we hard-coded
@@ -119,7 +124,7 @@ static int huawei_cdc_ncm_bind(struct usbnet *usbnet_dev,
static void huawei_cdc_ncm_unbind(struct usbnet *usbnet_dev,
struct usb_interface *intf)
{
- struct huawei_cdc_ncm_state *drvstate = (void *)&usbnet_dev->data;
+ struct huawei_cdc_ncm_state *drvstate = usbnet_to_state(usbnet_dev);
struct cdc_ncm_ctx *ctx = drvstate->ctx;
if (drvstate->subdriver && drvstate->subdriver->disconnect)
@@ -134,7 +139,7 @@ static int huawei_cdc_ncm_suspend(struct usb_interface *intf,
{
int ret = 0;
struct usbnet *usbnet_dev = usb_get_intfdata(intf);
- struct huawei_cdc_ncm_state *drvstate = (void *)&usbnet_dev->data;
+ struct huawei_cdc_ncm_state *drvstate = usbnet_to_state(usbnet_dev);
struct cdc_ncm_ctx *ctx = drvstate->ctx;
if (ctx == NULL) {
@@ -161,7 +166,7 @@ static int huawei_cdc_ncm_resume(struct usb_interface *intf)
{
int ret = 0;
struct usbnet *usbnet_dev = usb_get_intfdata(intf);
- struct huawei_cdc_ncm_state *drvstate = (void *)&usbnet_dev->data;
+ struct huawei_cdc_ncm_state *drvstate = usbnet_to_state(usbnet_dev);
bool callsub;
struct cdc_ncm_ctx *ctx = drvstate->ctx;
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [6/7] net: huawei_cdc_ncm: add usbnet -> priv function
@ 2018-10-12 10:20 Greg Kroah-Hartman
0 siblings, 0 replies; 2+ messages in thread
From: Greg Kroah-Hartman @ 2018-10-12 10:20 UTC (permalink / raw)
To: Ben Dooks
Cc: davem, netdev, linux-usb, linux-kernel, linux-kernel, bjorn,
steve.glendinning
On Fri, Oct 12, 2018 at 10:16:41AM +0100, Ben Dooks wrote:
> There are a number of places in the huawei driver where it gets the
> private-data from the usbnet passed in. It would be sensible to have
> one inline function to convert it and change all points in the driver
> to use that.
>
> Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-10-12 10:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-10-12 10:20 [6/7] net: huawei_cdc_ncm: add usbnet -> priv function Greg Kroah-Hartman
-- strict thread matches above, loose matches on Subject: below --
2018-10-12 9:16 Ben Dooks
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).