From patchwork Sun Sep 10 21:44:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 9946383 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 8D6EE6035D for ; Sun, 10 Sep 2017 21:46:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8003828A0B for ; Sun, 10 Sep 2017 21:46:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 74E7728A66; Sun, 10 Sep 2017 21:46: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=-1.7 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_MED, SUSPICIOUS_RECIPS autolearn=no 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 F409328A0B for ; Sun, 10 Sep 2017 21:46: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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=amQ1tQcsV5lzOruj5gmlClUAxKPb7/HN4+WvTe+tosM=; b=nOJC+xuxrY4UwTCN/N6f0Naki5 0nc1OJF+zGvICBxa8oSmLH8K43YPueYY5LBbHz0Og5b7VOkPsKQ/+JhKsD9NUNSpGQj7HeBV0W1FR oPcHOn57yo8NEWqD8ASFIJwsOqGXxqnUTXmx4H9a3IkBgNnkFpGHbJu5ZEO4zoPoQNTWso0xK2VO8 uEqpznExExelsfdyiwZ1gm65+6SdZE1QjeIqrL0NdfRZYWqgSs0BNdC2ZxZAohdV7NV0QGLkBuTKx jy1a0VF1ifRjN3REQzfywKE2z2UlJqk5VZaqwGnQr72K9xD0wVACoUR5tPYTLSfsnoArhbT8ZO/gm VoEOGZ0Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1drA3S-0000z9-8V; Sun, 10 Sep 2017 21:46:14 +0000 Received: from mail-lf0-x230.google.com ([2a00:1450:4010:c07::230]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1drA2O-0007Fe-Qu for linux-arm-kernel@lists.infradead.org; Sun, 10 Sep 2017 21:45:22 +0000 Received: by mail-lf0-x230.google.com with SMTP id m199so14415804lfe.3 for ; Sun, 10 Sep 2017 14:44:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=erzgjhU0ezSIivaubwnwB+XCJNNifZqiUpJZ7kylSg0=; b=CbcTVlfm6t23WEwprTHtw710tIDAdxGwWka0o+xOgBycTzqXNZKDNR5fbiA3oHkE2G 2lebTDU8LviJoEVLCafNaOFpcUGMEKmmvD9AXbjh8ULStwz7WlBx+YRW37ziK1WafTgo zuCFJgUV1oPd89LhIqPQDZUX3BbJy1K5kSOOE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=erzgjhU0ezSIivaubwnwB+XCJNNifZqiUpJZ7kylSg0=; b=bNKipeH1hKXSefTKnmZPDES1efMU6iBecee8sooOEAkXP6Jwo9WqPnmqITFn+GE7w4 CFvsiQ25dsGo9ix40djmQusYEgoaPd0LpPWAyB4b6lYCjXbN37bfxkmxMcymGKweZI0p q3+o0C+vUfQRhawpLQyc1y7WAUFQE8Cw87NBhW31bcfB3Iqi63nBOpLEBHUx2KYlnQiR ZNM15bntymJ+TUv05Z/sxKOv1Tsj1uA5pocCBGAimdxfGhFsGnl4j/7Eibr1lyHCoxTG 4RBC13+bJPi3ejl4rP3xfpkH+qLSySUPN6TuwNLZUqbpimdCMBv9iLH/9kbmDzTJbDqc v+RA== X-Gm-Message-State: AHPjjUippgbpBzAA6hllHjtxlAq16Wgihgft3HCV97dBQ/pn5OmLKHOs 612NrLeT0PluxDkm X-Google-Smtp-Source: ADKCNb773bhIteqT6T7lwK2r6V3lBceeQP/MPy84KM/y3ABleZhZdlj59GSA5uxCX1qJ3spg9lGxKg== X-Received: by 10.46.6.18 with SMTP id 18mr3081395ljg.117.1505079890970; Sun, 10 Sep 2017 14:44:50 -0700 (PDT) Received: from fabina.bredbandsbolaget.se (c-2209e055.014-348-6c756e10.cust.bredbandsbolaget.se. [85.224.9.34]) by smtp.gmail.com with ESMTPSA id c69sm1461546ljd.42.2017.09.10.14.44.49 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 10 Sep 2017 14:44:50 -0700 (PDT) From: Linus Walleij To: Wolfram Sang , linux-i2c@vger.kernel.org Subject: [PATCH 5/5] i2c: gpio: Local vars in probe Date: Sun, 10 Sep 2017 23:44:24 +0200 Message-Id: <20170910214424.14945-6-linus.walleij@linaro.org> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170910214424.14945-1-linus.walleij@linaro.org> References: <20170910214424.14945-1-linus.walleij@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170910_144509_558716_26EBB26A X-CRM114-Status: GOOD ( 15.75 ) 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: linux-mips@linux-mips.org, Linus Walleij , adi-buildroot-devel@lists.sourceforge.net, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 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 By creating local variables for *dev and *np, the code become much easier to read, in my opinion. Signed-off-by: Linus Walleij --- I put this at the end of the series because compared to the rest of the patches it is completely unimportant. --- drivers/i2c/busses/i2c-gpio.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/drivers/i2c/busses/i2c-gpio.c b/drivers/i2c/busses/i2c-gpio.c index 18ac4cf2ee75..7fe599f4fdb0 100644 --- a/drivers/i2c/busses/i2c-gpio.c +++ b/drivers/i2c/busses/i2c-gpio.c @@ -88,10 +88,12 @@ static int i2c_gpio_probe(struct platform_device *pdev) struct i2c_gpio_platform_data *pdata; struct i2c_algo_bit_data *bit_data; struct i2c_adapter *adap; + struct device *dev = &pdev->dev; + struct device_node *np = dev->of_node; enum gpiod_flags gflags; int ret; - priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); if (!priv) return -ENOMEM; @@ -99,15 +101,15 @@ static int i2c_gpio_probe(struct platform_device *pdev) bit_data = &priv->bit_data; pdata = &priv->pdata; - if (pdev->dev.of_node) { - of_i2c_gpio_get_props(pdev->dev.of_node, pdata); + if (np) { + of_i2c_gpio_get_props(np, pdata); } else { /* * If all platform data settings are zero it is OK * to not provide any platform data from the board. */ - if (dev_get_platdata(&pdev->dev)) - memcpy(pdata, dev_get_platdata(&pdev->dev), + if (dev_get_platdata(dev)) + memcpy(pdata, dev_get_platdata(dev), sizeof(*pdata)); } @@ -123,7 +125,7 @@ static int i2c_gpio_probe(struct platform_device *pdev) gflags = GPIOD_OUT_HIGH; else gflags = GPIOD_OUT_HIGH_OPEN_DRAIN; - priv->sda = devm_gpiod_get_index(&pdev->dev, NULL, 0, gflags); + priv->sda = devm_gpiod_get_index(dev, NULL, 0, gflags); if (IS_ERR(priv->sda)) { ret = PTR_ERR(priv->sda); /* FIXME: hack in the old code, is this really necessary? */ @@ -142,7 +144,7 @@ static int i2c_gpio_probe(struct platform_device *pdev) gflags = GPIOD_OUT_LOW; else gflags = GPIOD_OUT_LOW_OPEN_DRAIN; - priv->scl = devm_gpiod_get_index(&pdev->dev, NULL, 1, gflags); + priv->scl = devm_gpiod_get_index(dev, NULL, 1, gflags); if (IS_ERR(priv->scl)) { ret = PTR_ERR(priv->sda); /* FIXME: hack in the old code, is this really necessary? */ @@ -173,15 +175,15 @@ static int i2c_gpio_probe(struct platform_device *pdev) bit_data->data = priv; adap->owner = THIS_MODULE; - if (pdev->dev.of_node) - strlcpy(adap->name, dev_name(&pdev->dev), sizeof(adap->name)); + if (np) + strlcpy(adap->name, dev_name(dev), sizeof(adap->name)); else snprintf(adap->name, sizeof(adap->name), "i2c-gpio%d", pdev->id); adap->algo_data = bit_data; adap->class = I2C_CLASS_HWMON | I2C_CLASS_SPD; - adap->dev.parent = &pdev->dev; - adap->dev.of_node = pdev->dev.of_node; + adap->dev.parent = dev; + adap->dev.of_node = np; adap->nr = pdev->id; ret = i2c_bit_add_numbered_bus(adap); @@ -195,7 +197,7 @@ static int i2c_gpio_probe(struct platform_device *pdev) * get accessors to get the actual name of the GPIO line, * from the descriptor, then provide that instead. */ - dev_info(&pdev->dev, "using lines %u (SDA) and %u (SCL%s)\n", + dev_info(dev, "using lines %u (SDA) and %u (SCL%s)\n", desc_to_gpio(priv->sda), desc_to_gpio(priv->scl), pdata->scl_is_output_only ? ", no clock stretching" : "");