From patchwork Fri Nov 16 09:47:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Slawomir Stepien X-Patchwork-Id: 10685757 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 6D5EB14D6 for ; Fri, 16 Nov 2018 09:47:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 58754294F6 for ; Fri, 16 Nov 2018 09:47:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4C86A2C428; Fri, 16 Nov 2018 09:47:10 +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,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FROM,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 EDAD62D3A4 for ; Fri, 16 Nov 2018 09:47:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727398AbeKPT6m (ORCPT ); Fri, 16 Nov 2018 14:58:42 -0500 Received: from smtpo.poczta.interia.pl ([217.74.65.153]:57072 "EHLO smtpo.poczta.interia.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727567AbeKPT6m (ORCPT ); Fri, 16 Nov 2018 14:58:42 -0500 X-Interia-R: Interia X-Interia-R-IP: 188.121.17.172 X-Interia-R-Helo: Received: from localhost (ipv4-188-121-17-172.net.internetunion.pl [188.121.17.172]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by www.poczta.fm (INTERIA.PL) with ESMTPSA; Fri, 16 Nov 2018 10:47:06 +0100 (CET) From: Slawomir Stepien To: lars@metafoo.de, jic23@kernel.org, knaack.h@gmx.de, pmeerw@pmeerw.net Cc: linux-iio@vger.kernel.org Subject: [PATCH 2/2] iio: potentiometer mcp4131: use spi_get_device_id() only when needed Date: Fri, 16 Nov 2018 10:47:22 +0100 Message-Id: <20181116094722.1070-3-sst@poczta.fm> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181116094722.1070-1-sst@poczta.fm> References: <20181116094722.1070-1-sst@poczta.fm> MIME-Version: 1.0 X-Interia-Antivirus: OK DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=interia.pl; s=biztos; t=1542361627; bh=nrDT1JLHy/XZfCoytDbgiycDFFa0WHJZPwNcLiawBEE=; h=X-Interia-R:X-Interia-R-IP:X-Interia-R-Helo:From:To:Cc:Subject: Date:Message-Id:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:X-Interia-Antivirus; b=TDTfGrLL0/B3Kff9x7aZOCo5NWcPa69fsbRkrplwVpgMDOOd9DM9f7wvJTXiF4ly/ wvKO+NxQ1adwf80wllTVfQrey20lPupvqlfMtxIlNLMjI+BJyVxqEci5FIF60LLBFP MgFKjKnFresmrpDy46cQY7qITFvTfjrMMwzIpziQ= Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP There is no need to find the device id up front, since the of_device_get_match_data() might return the correct data. Signed-off-by: Slawomir Stepien --- drivers/iio/potentiometer/mcp4131.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/iio/potentiometer/mcp4131.c b/drivers/iio/potentiometer/mcp4131.c index 55f526a59215..efe035ce010d 100644 --- a/drivers/iio/potentiometer/mcp4131.c +++ b/drivers/iio/potentiometer/mcp4131.c @@ -244,7 +244,7 @@ static int mcp4131_probe(struct spi_device *spi) { int err; struct device *dev = &spi->dev; - unsigned long devid = spi_get_device_id(spi)->driver_data; + unsigned long devid; struct mcp4131_data *data; struct iio_dev *indio_dev; @@ -256,8 +256,10 @@ static int mcp4131_probe(struct spi_device *spi) spi_set_drvdata(spi, indio_dev); data->spi = spi; data->cfg = of_device_get_match_data(&spi->dev); - if (!data->cfg) + if (!data->cfg) { + devid = spi_get_device_id(spi)->driver_data; data->cfg = &mcp4131_cfg[devid]; + } mutex_init(&data->lock);