From patchwork Fri Oct 12 09:16:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Dooks X-Patchwork-Id: 10638149 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 72A6513AD for ; Fri, 12 Oct 2018 09:17:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 56A812BB73 for ; Fri, 12 Oct 2018 09:17:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4AFD62BB79; Fri, 12 Oct 2018 09:17:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 278392BB73 for ; Fri, 12 Oct 2018 09:17:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728327AbeJLQtC (ORCPT ); Fri, 12 Oct 2018 12:49:02 -0400 Received: from imap1.codethink.co.uk ([176.9.8.82]:49435 "EHLO imap1.codethink.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728102AbeJLQsZ (ORCPT ); Fri, 12 Oct 2018 12:48:25 -0400 Received: from [148.252.241.226] (helo=rainbowdash) by imap1.codethink.co.uk with esmtpsa (Exim 4.84_2 #1 (Debian)) id 1gAtYz-0006u5-En; Fri, 12 Oct 2018 10:16:53 +0100 Received: from ben by rainbowdash with local (Exim 4.91) (envelope-from ) id 1gAtYy-0005Yb-Jr; Fri, 12 Oct 2018 10:16:52 +0100 From: Ben Dooks To: davem@davemloft.net, netdev@vger.kernel.org Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kernel@lists.codethink.co.uk, gregkh@linuxfoundation.org, bjorn@mork.no, steve.glendinning@shawell.net, Ben Dooks Subject: [PATCH 6/7] net: huawei_cdc_ncm: add usbnet -> priv function Date: Fri, 12 Oct 2018 10:16:41 +0100 Message-Id: <20181012091642.21294-7-ben.dooks@codethink.co.uk> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181012091642.21294-1-ben.dooks@codethink.co.uk> References: <20181012091642.21294-1-ben.dooks@codethink.co.uk> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Reviewed-by: Greg Kroah-Hartman --- --- 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;