From patchwork Thu Jan 11 17:38:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 10158291 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B048B602D8 for ; Thu, 11 Jan 2018 17:39:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9A25228731 for ; Thu, 11 Jan 2018 17:39:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8EC7A28735; Thu, 11 Jan 2018 17:39:21 +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=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id CD8FF28723 for ; Thu, 11 Jan 2018 17:39:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date: Message-ID:From:References:To:Subject:Reply-To:Content-ID:Content-Description :Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=5TqgXxqZmBlV3wrB8yVs51pHAEEXy/D6dAysqLsziaY=; b=VEhqjFAU7emjgc eY1NXbw499vDMeu3bGVX1tvDEqJSwLRuO86uqZTKhG7ad8jq0CnfR3hArwrI12fTV3dQuTWAGxe+n d5IgFLhUxyYFWPtR51YgPJERJx4BACLPayGT0axv6oDKk/V+/VNGPgi/N3cZmSpB8f6iHsZ3dKLwP vD5JdgtuuUmi9liSx4lVwuzgLBHXcDD/LW29FVNOBbFoMT9FSJIpzCkoNrNZg2PYLJ8djuTjcOGVq Av+HrTlZPQbwBp/NJdILBDbYIrbjYDdoUzVVmkyDtLvYzIM9MungmRGMRzD9+Bl+9HbyYvCRcpHgz Ksst7oeACtSFfM0mP+QA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1eZgow-0004Jb-4L; Thu, 11 Jan 2018 17:39:18 +0000 Received: from mx07-00178001.pphosted.com ([62.209.51.94]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eZgos-00044m-HI for linux-arm-kernel@lists.infradead.org; Thu, 11 Jan 2018 17:39:16 +0000 Received: from pps.filterd (m0046668.ppops.net [127.0.0.1]) by mx07-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id w0BHYUUa007902; Thu, 11 Jan 2018 18:38:52 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 2fe7399jq0-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 11 Jan 2018 18:38:52 +0100 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 1561E31; Thu, 11 Jan 2018 17:38:51 +0000 (GMT) Received: from Webmail-eu.st.com (sfhdag3node1.st.com [10.75.127.7]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id DDA502A60; Thu, 11 Jan 2018 17:38:50 +0000 (GMT) Received: from [10.201.23.162] (10.75.127.47) by SFHDAG3NODE1.st.com (10.75.127.7) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Thu, 11 Jan 2018 18:38:50 +0100 Subject: Re: [PATCH] IIO: ADC: stm32-dfsdm: avoid unused-variable warning To: Robin Murphy , Arnd Bergmann , Mark Brown References: <20180111103510.1408292-1-arnd@arndb.de> <866335ff-d9a8-99c0-0946-82b3f207f266@arm.com> From: Arnaud Pouliquen Message-ID: <838ace12-2722-33aa-0ed8-2e8e7494b2ae@st.com> Date: Thu, 11 Jan 2018 18:38:49 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: <866335ff-d9a8-99c0-0946-82b3f207f266@arm.com> Content-Language: en-US X-Originating-IP: [10.75.127.47] X-ClientProxiedBy: SFHDAG8NODE2.st.com (10.75.127.23) To SFHDAG3NODE1.st.com (10.75.127.7) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-01-11_06:, , signatures=0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180111_093914_898096_055E5929 X-CRM114-Status: GOOD ( 16.97 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lars-Peter Clausen , Peter Meerwald-Stadler , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Jonathan Cameron , Maxime Coquelin , Hartmut Knaack , linux-arm-kernel@lists.infradead.org, Alexandre Torgue Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP On 01/11/2018 03:27 PM, Robin Murphy wrote: > On 11/01/18 10:34, Arnd Bergmann wrote: >> Building with CONFIG_OF disabled produces a compiler warning: >> >> drivers/iio/adc/stm32-dfsdm-core.c: In function 'stm32_dfsdm_probe': >> drivers/iio/adc/stm32-dfsdm-core.c:245:22: error: unused variable >> 'pnode' [-Werror=unused-variable] >> >> This removes the variable and open-codes it in the only place >> it gets used to avoid that warning. >> >> Fixes: bed73904e76f ("IIO: ADC: add stm32 DFSDM core support") >> Signed-off-by: Arnd Bergmann >> --- >>   drivers/iio/adc/stm32-dfsdm-core.c | 3 +-- >>   1 file changed, 1 insertion(+), 2 deletions(-) >> >> diff --git a/drivers/iio/adc/stm32-dfsdm-core.c >> b/drivers/iio/adc/stm32-dfsdm-core.c >> index 72427414db7f..6cd655f8239b 100644 >> --- a/drivers/iio/adc/stm32-dfsdm-core.c >> +++ b/drivers/iio/adc/stm32-dfsdm-core.c >> @@ -242,7 +242,6 @@ MODULE_DEVICE_TABLE(of, stm32_dfsdm_of_match); >>   static int stm32_dfsdm_probe(struct platform_device *pdev) >>   { >>       struct dfsdm_priv *priv; >> -    struct device_node *pnode = pdev->dev.of_node; >>       const struct of_device_id *of_id; >>       const struct stm32_dfsdm_dev_data *dev_data; >>       struct stm32_dfsdm *dfsdm; >> @@ -254,7 +253,7 @@ static int stm32_dfsdm_probe(struct >> platform_device *pdev) >>         priv->pdev = pdev; >>   -    of_id = of_match_node(stm32_dfsdm_of_match, pnode); >> +    of_id = of_match_node(stm32_dfsdm_of_match, pdev->dev.of_node); >>       if (!of_id->data) { >>           dev_err(&pdev->dev, "Data associated to device is missing\n"); >>           return -EINVAL; > > FWIW, it looks like this whole lot could be cleaned up by using > of_device_get_match_data(). > Right, and test of the return now seems to me an overprotection as data structure is defined in the driver... Same optimization could be applied to stm32_dfsdm_adc_probe function. Here is the patch I tested: Acked-by: Jonathan Cameron --- drivers/iio/adc/stm32-dfsdm-adc.c | 9 +-------- drivers/iio/adc/stm32-dfsdm-core.c | 9 +-------- 2 files changed, 2 insertions(+), 16 deletions(-) sizeof(*dfsdm->fl_list), GFP_KERNEL); diff --git a/drivers/iio/adc/stm32-dfsdm-adc.c b/drivers/iio/adc/stm32-dfsdm-adc.c index b03ca3f..01836c9 100644 --- a/drivers/iio/adc/stm32-dfsdm-adc.c +++ b/drivers/iio/adc/stm32-dfsdm-adc.c @@ -1087,18 +1087,11 @@ static int stm32_dfsdm_adc_probe(struct platform_device *pdev) struct device_node *np = dev->of_node; const struct stm32_dfsdm_dev_data *dev_data; struct iio_dev *iio; - const struct of_device_id *of_id; char *name; int ret, irq, val; - of_id = of_match_node(stm32_dfsdm_adc_match, np); - if (!of_id->data) { - dev_err(&pdev->dev, "Data associated to device is missing\n"); - return -EINVAL; - } - - dev_data = (const struct stm32_dfsdm_dev_data *)of_id->data; + dev_data = of_device_get_match_data(dev); iio = devm_iio_device_alloc(dev, sizeof(*adc)); if (IS_ERR(iio)) { dev_err(dev, "%s: Failed to allocate IIO\n", __func__); diff --git a/drivers/iio/adc/stm32-dfsdm-core.c b/drivers/iio/adc/stm32-dfsdm-core.c index 7242741..6290332 100644 --- a/drivers/iio/adc/stm32-dfsdm-core.c +++ b/drivers/iio/adc/stm32-dfsdm-core.c @@ -242,8 +242,6 @@ MODULE_DEVICE_TABLE(of, stm32_dfsdm_of_match); static int stm32_dfsdm_probe(struct platform_device *pdev) { struct dfsdm_priv *priv; - struct device_node *pnode = pdev->dev.of_node; - const struct of_device_id *of_id; const struct stm32_dfsdm_dev_data *dev_data; struct stm32_dfsdm *dfsdm; int ret; @@ -254,13 +252,8 @@ static int stm32_dfsdm_probe(struct platform_device *pdev) priv->pdev = pdev; - of_id = of_match_node(stm32_dfsdm_of_match, pnode); - if (!of_id->data) { - dev_err(&pdev->dev, "Data associated to device is missing\n"); - return -EINVAL; - } + dev_data = of_device_get_match_data(&pdev->dev); - dev_data = (const struct stm32_dfsdm_dev_data *)of_id->data; dfsdm = &priv->dfsdm; dfsdm->fl_list = devm_kcalloc(&pdev->dev, dev_data->num_filters,