From patchwork Sun Sep 17 09:39:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 112827 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp2503510qgf; Sun, 17 Sep 2017 02:39:34 -0700 (PDT) X-Received: by 10.99.177.74 with SMTP id g10mr29420572pgp.326.1505641174433; Sun, 17 Sep 2017 02:39:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505641174; cv=none; d=google.com; s=arc-20160816; b=nytDB791uI229/veYjgBChM71T9XgYmfls2maNNKWSd5rCxzvyw6kh1eL6wl4lI3BR v99rm0rkV5G+HXgZKKdl2xohAjk3jr6IYy6t3p/i32YAEIGrfzSGs8BhLPV1q+Bp9ESB 5RgBVkHtiC4bCtr8IwBl016cnM/Elce5M7UfmWZV0ijG9xfb3Fa/02bFV+FJDtRKbeJk NsoS/ufq115Ppy6baARD3fkJPVAYErIAlOuAFJxTUlXpcYS9+LSWt++H7s5NbqAIP5Fk tqGE/h7gaXwAhn88ATGEpXZ1VgC/EnVoCejVZUiURYpJX9I5PG8eK4XiDxk0Cc/gB+NP zXkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=k9Vob8DYJi4kyczGDuJoNvHeLrUQ0luZju+XmU3lJ2A=; b=ZzhEnfCfdtYRw3JBMc3SUMNtolL9IkeRyToxs8qea2lZVmwzIIxiL0DHfWhr8FKQHF w2A9LPXHQnVYHaGCIN53EA8l8wtVBmMXAsslVxeGuGRUouqoOsa4z91qaykS9gbVi8ts uOMLamKhHeDZB4K244cpkt831Su4xEL/o0836I6VFMkRfTjQ9YQJ1CuWlLUVo3R4pscM Nozw2z081TApIFXj60KTi5/IJfTXJAZvBa/etoDK13FL2uO9xqt61BLf6Shwz5TIMXO+ gYbNP/vtEGPH8YtEVJqbvQzcQ92pdAbI5o653U99Hwp4azM2MHcsGW5hi/f/TEHEhpMR heUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ByXEK4sZ; spf=pass (google.com: best guess record for domain of linux-i2c-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-i2c-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t8si3374838plz.730.2017.09.17.02.39.34; Sun, 17 Sep 2017 02:39:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-i2c-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ByXEK4sZ; spf=pass (google.com: best guess record for domain of linux-i2c-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-i2c-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751295AbdIQJjd (ORCPT + 3 others); Sun, 17 Sep 2017 05:39:33 -0400 Received: from mail-lf0-f45.google.com ([209.85.215.45]:56542 "EHLO mail-lf0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750995AbdIQJjc (ORCPT ); Sun, 17 Sep 2017 05:39:32 -0400 Received: by mail-lf0-f45.google.com with SMTP id a18so5562682lfl.13 for ; Sun, 17 Sep 2017 02:39:32 -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=k9Vob8DYJi4kyczGDuJoNvHeLrUQ0luZju+XmU3lJ2A=; b=ByXEK4sZwjERuOS4GecH6NQisOG0/0cMeE/ZCdR7k6clxbasEjLhfIKcim/JAQyfdb 6k5Wpo04Raeb/I+Ab22NCi7ADGTX+mf2ZVGSl7TjKkQl5yYa5z6PYKtfci2yi/QLAMMb ISkV3PDbr6gTdDok6xH/rRUXbaKZkZ8G+echE= 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=k9Vob8DYJi4kyczGDuJoNvHeLrUQ0luZju+XmU3lJ2A=; b=TqdA5MrViXW50A4KgevOFrN91fQLNgu7VhKEITyZ/fk8y+yJlDvTCSQLyEPq077AFO vLxRKzgDWIG7zPe5A2dCUWnUNDWywMGFjutsZI0zje8Y3ZoGiXWvSp9vFWBIXSl3rqXp hxmz5wxigEqS2WrDhzsTvw34qyBEKqAm3+7oxUHkdGHyFRRzZfj17bJmM25KBcezGA60 n+mKJ9EQ72uZpDWWNXO0ljT3bdsNMpoGtK3fZmWQetHrR6YBPuw6xkk/K1TZcjzqgY8n CQf16ze/8Udl+S9EKMf/5vvJJccH60EY6Y5rxgUI8yovNkGnRbxiIWx24KI5ywd5e5kj mgTg== X-Gm-Message-State: AHPjjUjMWwQpl+XUKMmOpjO/cGpeS8ON0NS9VEeeyUl6XZDJcLCKPtwK mhbji3MzoJ735Fq9 X-Google-Smtp-Source: AOwi7QAhujHlkyg3HrDPPY7p3HUgGExvhaf/62cPMT48V3sqO6jiQLq18cQ/RnAR4Uo7IKE1Mzctgg== X-Received: by 10.25.181.26 with SMTP id e26mr2481381lff.91.1505641171276; Sun, 17 Sep 2017 02:39:31 -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 t84sm974559lfi.21.2017.09.17.02.39.29 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 17 Sep 2017 02:39:30 -0700 (PDT) From: Linus Walleij To: Wolfram Sang , linux-i2c@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, linux-mips@linux-mips.org, adi-buildroot-devel@lists.sourceforge.net, Geert Uytterhoeven , Linus Walleij Subject: [PATCH 5/7] i2c: gpio: Local vars in probe Date: Sun, 17 Sep 2017 11:39:04 +0200 Message-Id: <20170917093906.16325-6-linus.walleij@linaro.org> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170917093906.16325-1-linus.walleij@linaro.org> References: <20170917093906.16325-1-linus.walleij@linaro.org> Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org 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(-) -- 2.13.5 diff --git a/drivers/i2c/busses/i2c-gpio.c b/drivers/i2c/busses/i2c-gpio.c index 97b9c29e9429..beb5ce523684 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->scl); /* 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" : "");