Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3621610ybi; Mon, 29 Jul 2019 09:37:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqwoa/pFsg7MGfiHg5pAM8SaE0agh56Cpw5MnUUbQq4Wcv8gyS4UuIpMqJqs3utj9DRFy+R3 X-Received: by 2002:a17:902:8d97:: with SMTP id v23mr108220668plo.157.1564418271502; Mon, 29 Jul 2019 09:37:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564418271; cv=none; d=google.com; s=arc-20160816; b=beOX58A18FBXzWcAJXKKjhGO6E4lQd4AajCxEh6AdoVLTB3tjBQpXT2DfEfJEbxzSG VzP3MrZ+y2NY2alfKT5pWVEZwAuop6J/26GoHIf6WC5/jSNrQZqdzCdnVfp95EdHEnro 0zradjcwvDmsok9JgLZuFrl5qhOgAXMsbIomXaaBfhjcd97N01nwaso+p710BVInfU3a 61pXklmgew/s3paHyH6pkQQMWGwaHd+aJkfGwbj0qCcfP+iKVJ0oMsigU3MZIZCOJAsK NIj8RJsCkBgR5b2B5SCgEHOWbcbHqWFJtub712S1fm+PuGnPAgLPrTwPan9dkFRwMFdJ zqQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:to:subject; bh=yQAt39gVIx/12+cMOBRXnhsWR+PllWWi+W8+K2ks0aA=; b=b76li9y3bc+UOVVb9CtqSVSmIXmg1Qo5MwiB5PYquUMOXYoyQ5XoEm73Adu5x5hA+K ynKT8aoM6xfJ1C+dZLXQRJngi67o6DyYrFKE26+DcKc3PsOEABTMlD772W3HIMGYm5o/ o5a2WwUDb7ZIiEs+dOF9bpaRc926x0m//kl/y1/e79hiOC13wDCBMe/kTZMQcWMUvRoi dnyfGqEsezIrfcH5vypFDrriX9fbCWMOfVdCV7ENOIEtUk0gcackSbh3SUqgrKHF8JEv vcWARS+coYtMhQmdvu7/HlSUg5ohuRttklsXRgn3eIOQb2ZFKqStcGo6iaKQlt7Mb5+n 2m7Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u189si26958734pgc.385.2019.07.29.09.37.36; Mon, 29 Jul 2019 09:37:51 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387593AbfG2P4Q (ORCPT + 99 others); Mon, 29 Jul 2019 11:56:16 -0400 Received: from mail-wm1-f67.google.com ([209.85.128.67]:51745 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387583AbfG2P4P (ORCPT ); Mon, 29 Jul 2019 11:56:15 -0400 Received: by mail-wm1-f67.google.com with SMTP id 207so54354308wma.1 for ; Mon, 29 Jul 2019 08:56:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=yQAt39gVIx/12+cMOBRXnhsWR+PllWWi+W8+K2ks0aA=; b=TZ8uIRipSeXfPI/Hn77pn4k6Y3GZcKEGNz+EgZEb1BagOPVzEMtaHnxx5YOm7/K4Y2 ZF3gciMDo6RTGC1xrJNr3E/xe60SYQQxIqSeagaNPNHY3gZPJXx4tOqJ1yt7nqGUXfTi ymzMQZIftwPgnzd4tvGCR3BYEyKZGRfTD63pO/rC2avcY55oWxqClRuDx7DiUG3SgWVF 4wvdfPAL2KfeheNIXNEed/RalmDUjChTNqW38j7voIz/jgYsrC4ZeVI/0vwqJsNIVA3U O1W5LU6P7mzamqa9aO+rS/EYdKStVy1FFFuh4D5vDkRmS+64WE3dQOvOJ1SIC17jZE72 ZsxQ== X-Gm-Message-State: APjAAAXABMr51cpV+8nvegHXzeuKNDXm3hYoi2PrLUo6EoCxCLBio28E AdQfP5xq1qMjI1zJ0NgbdBpqhw== X-Received: by 2002:a1c:18a:: with SMTP id 132mr101242272wmb.15.1564415772230; Mon, 29 Jul 2019 08:56:12 -0700 (PDT) Received: from shalem.localdomain (84-106-84-65.cable.dynamic.v4.ziggo.nl. [84.106.84.65]) by smtp.gmail.com with ESMTPSA id b186sm45845832wmb.3.2019.07.29.08.56.11 (version=TLS1_3 cipher=AEAD-AES128-GCM-SHA256 bits=128/128); Mon, 29 Jul 2019 08:56:11 -0700 (PDT) Subject: Re: [PATCH] staging: rtl8723bs: os_dep: Move common code to func To: Hariprasad Kelam , Greg Kroah-Hartman , Shobhit Kukreti , Madhumitha Prabakaran , devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, Larry.Finger@lwfinger.net References: <20190725183147.GA15303@hari-Inspiron-1545> From: Hans de Goede Message-ID: Date: Mon, 29 Jul 2019 17:56:10 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20190725183147.GA15303@hari-Inspiron-1545> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 25-07-19 20:31, Hariprasad Kelam wrote: > Inthis file all functions has below common functionality > 1.Check flag padapter->bSurpriseRemoved > 2.Get sdio_func structure from intf_hdl. > > This patch introduces two new APIs > rtw_isadapter_removed,rtw_sdio_get_func which helps to do above common > functionality. > > Signed-off-by: Hariprasad Kelam Looks good to me: Reviewed-by: Hans de Goede Regards, Hans > --- > drivers/staging/rtl8723bs/os_dep/sdio_ops_linux.c | 149 ++++++---------------- > 1 file changed, 41 insertions(+), 108 deletions(-) > > diff --git a/drivers/staging/rtl8723bs/os_dep/sdio_ops_linux.c b/drivers/staging/rtl8723bs/os_dep/sdio_ops_linux.c > index 50b8934..126429e 100644 > --- a/drivers/staging/rtl8723bs/os_dep/sdio_ops_linux.c > +++ b/drivers/staging/rtl8723bs/os_dep/sdio_ops_linux.c > @@ -26,26 +26,38 @@ inline void rtw_sdio_set_irq_thd(struct dvobj_priv *dvobj, void *thd_hdl) > sdio_data->sys_sdio_irq_thd = thd_hdl; > } > > -u8 sd_f0_read8(struct intf_hdl *pintfhdl, u32 addr, s32 *err) > +static s32 rtw_isadapter_removed(struct intf_hdl *pintfhdl) > { > struct adapter *padapter; > + > + padapter = pintfhdl->padapter; > + return padapter->bSurpriseRemoved; > +} > + > +static struct sdio_func *rtw_sdio_get_func(struct intf_hdl *pintfhdl) > +{ > struct dvobj_priv *psdiodev; > struct sdio_data *psdio; > > + psdiodev = pintfhdl->pintf_dev; > + psdio = &psdiodev->intf_data; > + > + return psdio->func; > +} > + > +u8 sd_f0_read8(struct intf_hdl *pintfhdl, u32 addr, s32 *err) > +{ > u8 v = 0; > struct sdio_func *func; > bool claim_needed; > > - padapter = pintfhdl->padapter; > - psdiodev = pintfhdl->pintf_dev; > - psdio = &psdiodev->intf_data; > > - if (padapter->bSurpriseRemoved) { > + if (rtw_isadapter_removed(pintfhdl)) { > /* DBG_871X(" %s (padapter->bSurpriseRemoved ||adapter->pwrctrlpriv.pnp_bstop_trx)!!!\n", __func__); */ > return v; > } > > - func = psdio->func; > + func = rtw_sdio_get_func(pintfhdl); > claim_needed = rtw_sdio_claim_host_needed(func); > > if (claim_needed) > @@ -65,23 +77,15 @@ u8 sd_f0_read8(struct intf_hdl *pintfhdl, u32 addr, s32 *err) > */ > s32 _sd_cmd52_read(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pdata) > { > - struct adapter *padapter; > - struct dvobj_priv *psdiodev; > - struct sdio_data *psdio; > - > int err = 0, i; > struct sdio_func *func; > > - padapter = pintfhdl->padapter; > - psdiodev = pintfhdl->pintf_dev; > - psdio = &psdiodev->intf_data; > - > - if (padapter->bSurpriseRemoved) { > + if (rtw_isadapter_removed(pintfhdl)) { > /* DBG_871X(" %s (padapter->bSurpriseRemoved ||adapter->pwrctrlpriv.pnp_bstop_trx)!!!\n", __func__); */ > return err; > } > > - func = psdio->func; > + func = rtw_sdio_get_func(pintfhdl); > > for (i = 0; i < cnt; i++) { > pdata[i] = sdio_readb(func, addr+i, &err); > @@ -100,24 +104,16 @@ s32 _sd_cmd52_read(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pdata) > */ > s32 sd_cmd52_read(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pdata) > { > - struct adapter *padapter; > - struct dvobj_priv *psdiodev; > - struct sdio_data *psdio; > - > int err = 0; > struct sdio_func *func; > bool claim_needed; > > - padapter = pintfhdl->padapter; > - psdiodev = pintfhdl->pintf_dev; > - psdio = &psdiodev->intf_data; > - > - if (padapter->bSurpriseRemoved) { > + if (rtw_isadapter_removed(pintfhdl)) { > /* DBG_871X(" %s (padapter->bSurpriseRemoved ||adapter->pwrctrlpriv.pnp_bstop_trx)!!!\n", __func__); */ > return err; > } > > - func = psdio->func; > + func = rtw_sdio_get_func(pintfhdl); > claim_needed = rtw_sdio_claim_host_needed(func); > > if (claim_needed) > @@ -135,23 +131,15 @@ s32 sd_cmd52_read(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pdata) > */ > s32 _sd_cmd52_write(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pdata) > { > - struct adapter *padapter; > - struct dvobj_priv *psdiodev; > - struct sdio_data *psdio; > - > int err = 0, i; > struct sdio_func *func; > > - padapter = pintfhdl->padapter; > - psdiodev = pintfhdl->pintf_dev; > - psdio = &psdiodev->intf_data; > - > - if (padapter->bSurpriseRemoved) { > + if (rtw_isadapter_removed(pintfhdl)) { > /* DBG_871X(" %s (padapter->bSurpriseRemoved ||adapter->pwrctrlpriv.pnp_bstop_trx)!!!\n", __func__); */ > return err; > } > > - func = psdio->func; > + func = rtw_sdio_get_func(pintfhdl); > > for (i = 0; i < cnt; i++) { > sdio_writeb(func, pdata[i], addr+i, &err); > @@ -170,24 +158,16 @@ s32 _sd_cmd52_write(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pdata) > */ > s32 sd_cmd52_write(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pdata) > { > - struct adapter *padapter; > - struct dvobj_priv *psdiodev; > - struct sdio_data *psdio; > - > int err = 0; > struct sdio_func *func; > bool claim_needed; > > - padapter = pintfhdl->padapter; > - psdiodev = pintfhdl->pintf_dev; > - psdio = &psdiodev->intf_data; > - > - if (padapter->bSurpriseRemoved) { > + if (rtw_isadapter_removed(pintfhdl)) { > /* DBG_871X(" %s (padapter->bSurpriseRemoved ||adapter->pwrctrlpriv.pnp_bstop_trx)!!!\n", __func__); */ > return err; > } > > - func = psdio->func; > + func = rtw_sdio_get_func(pintfhdl); > claim_needed = rtw_sdio_claim_host_needed(func); > > if (claim_needed) > @@ -200,24 +180,16 @@ s32 sd_cmd52_write(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pdata) > > u8 sd_read8(struct intf_hdl *pintfhdl, u32 addr, s32 *err) > { > - struct adapter *padapter; > - struct dvobj_priv *psdiodev; > - struct sdio_data *psdio; > - > u8 v = 0; > struct sdio_func *func; > bool claim_needed; > > - padapter = pintfhdl->padapter; > - psdiodev = pintfhdl->pintf_dev; > - psdio = &psdiodev->intf_data; > - > - if (padapter->bSurpriseRemoved) { > + if (rtw_isadapter_removed(pintfhdl)) { > /* DBG_871X(" %s (padapter->bSurpriseRemoved ||adapter->pwrctrlpriv.pnp_bstop_trx)!!!\n", __func__); */ > return v; > } > > - func = psdio->func; > + func = rtw_sdio_get_func(pintfhdl); > claim_needed = rtw_sdio_claim_host_needed(func); > > if (claim_needed) > @@ -234,21 +206,19 @@ u32 sd_read32(struct intf_hdl *pintfhdl, u32 addr, s32 *err) > { > struct adapter *padapter; > struct dvobj_priv *psdiodev; > - struct sdio_data *psdio; > u32 v = 0; > struct sdio_func *func; > bool claim_needed; > > padapter = pintfhdl->padapter; > psdiodev = pintfhdl->pintf_dev; > - psdio = &psdiodev->intf_data; > > if (padapter->bSurpriseRemoved) { > /* DBG_871X(" %s (padapter->bSurpriseRemoved ||adapter->pwrctrlpriv.pnp_bstop_trx)!!!\n", __func__); */ > return v; > } > > - func = psdio->func; > + func = rtw_sdio_get_func(pintfhdl); > claim_needed = rtw_sdio_claim_host_needed(func); > > if (claim_needed) > @@ -295,22 +265,15 @@ u32 sd_read32(struct intf_hdl *pintfhdl, u32 addr, s32 *err) > > void sd_write8(struct intf_hdl *pintfhdl, u32 addr, u8 v, s32 *err) > { > - struct adapter *padapter; > - struct dvobj_priv *psdiodev; > - struct sdio_data *psdio; > struct sdio_func *func; > bool claim_needed; > > - padapter = pintfhdl->padapter; > - psdiodev = pintfhdl->pintf_dev; > - psdio = &psdiodev->intf_data; > - > - if (padapter->bSurpriseRemoved) { > + if (rtw_isadapter_removed(pintfhdl)) { > /* DBG_871X(" %s (padapter->bSurpriseRemoved ||adapter->pwrctrlpriv.pnp_bstop_trx)!!!\n", __func__); */ > return; > } > > - func = psdio->func; > + func = rtw_sdio_get_func(pintfhdl); > claim_needed = rtw_sdio_claim_host_needed(func); > > if (claim_needed) > @@ -326,20 +289,18 @@ void sd_write32(struct intf_hdl *pintfhdl, u32 addr, u32 v, s32 *err) > { > struct adapter *padapter; > struct dvobj_priv *psdiodev; > - struct sdio_data *psdio; > struct sdio_func *func; > bool claim_needed; > > padapter = pintfhdl->padapter; > psdiodev = pintfhdl->pintf_dev; > - psdio = &psdiodev->intf_data; > > if (padapter->bSurpriseRemoved) { > /* DBG_871X(" %s (padapter->bSurpriseRemoved ||adapter->pwrctrlpriv.pnp_bstop_trx)!!!\n", __func__); */ > return; > } > > - func = psdio->func; > + func = rtw_sdio_get_func(pintfhdl); > claim_needed = rtw_sdio_claim_host_needed(func); > > if (claim_needed) > @@ -398,23 +359,15 @@ void sd_write32(struct intf_hdl *pintfhdl, u32 addr, u32 v, s32 *err) > */ > s32 _sd_read(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, void *pdata) > { > - struct adapter *padapter; > - struct dvobj_priv *psdiodev; > - struct sdio_data *psdio; > - > int err = -EPERM; > struct sdio_func *func; > > - padapter = pintfhdl->padapter; > - psdiodev = pintfhdl->pintf_dev; > - psdio = &psdiodev->intf_data; > - > - if (padapter->bSurpriseRemoved) { > + if (rtw_isadapter_removed(pintfhdl)) { > /* DBG_871X(" %s (padapter->bSurpriseRemoved ||adapter->pwrctrlpriv.pnp_bstop_trx)!!!\n", __func__); */ > return err; > } > > - func = psdio->func; > + func = rtw_sdio_get_func(pintfhdl); > > if (unlikely((cnt == 1) || (cnt == 2))) { > int i; > @@ -453,23 +406,18 @@ s32 _sd_read(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, void *pdata) > */ > s32 sd_read(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, void *pdata) > { > - struct adapter *padapter; > - struct dvobj_priv *psdiodev; > - struct sdio_data *psdio; > > struct sdio_func *func; > bool claim_needed; > s32 err = -EPERM; > > - padapter = pintfhdl->padapter; > - psdiodev = pintfhdl->pintf_dev; > - psdio = &psdiodev->intf_data; > > - if (padapter->bSurpriseRemoved) { > + if (rtw_isadapter_removed(pintfhdl)) { > /* DBG_871X(" %s (padapter->bSurpriseRemoved ||adapter->pwrctrlpriv.pnp_bstop_trx)!!!\n", __func__); */ > return err; > } > - func = psdio->func; > + > + func = rtw_sdio_get_func(pintfhdl); > claim_needed = rtw_sdio_claim_host_needed(func); > > if (claim_needed) > @@ -497,24 +445,16 @@ s32 sd_read(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, void *pdata) > */ > s32 _sd_write(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, void *pdata) > { > - struct adapter *padapter; > - struct dvobj_priv *psdiodev; > - struct sdio_data *psdio; > - > struct sdio_func *func; > u32 size; > s32 err = -EPERM; > > - padapter = pintfhdl->padapter; > - psdiodev = pintfhdl->pintf_dev; > - psdio = &psdiodev->intf_data; > - > - if (padapter->bSurpriseRemoved) { > + if (rtw_isadapter_removed(pintfhdl)) { > /* DBG_871X(" %s (padapter->bSurpriseRemoved ||adapter->pwrctrlpriv.pnp_bstop_trx)!!!\n", __func__); */ > return err; > } > > - func = psdio->func; > + func = rtw_sdio_get_func(pintfhdl); > /* size = sdio_align_size(func, cnt); */ > > if (unlikely((cnt == 1) || (cnt == 2))) { > @@ -555,23 +495,16 @@ s32 _sd_write(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, void *pdata) > */ > s32 sd_write(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, void *pdata) > { > - struct adapter *padapter; > - struct dvobj_priv *psdiodev; > - struct sdio_data *psdio; > struct sdio_func *func; > bool claim_needed; > s32 err = -EPERM; > > - padapter = pintfhdl->padapter; > - psdiodev = pintfhdl->pintf_dev; > - psdio = &psdiodev->intf_data; > - > - if (padapter->bSurpriseRemoved) { > + if (rtw_isadapter_removed(pintfhdl)) { > /* DBG_871X(" %s (padapter->bSurpriseRemoved ||adapter->pwrctrlpriv.pnp_bstop_trx)!!!\n", __func__); */ > return err; > } > > - func = psdio->func; > + func = rtw_sdio_get_func(pintfhdl); > claim_needed = rtw_sdio_claim_host_needed(func); > > if (claim_needed) >