{"id":814623,"url":"http://patchwork.ozlabs.org/api/patches/814623/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-i2c/patch/20170917093906.16325-6-linus.walleij@linaro.org/","project":{"id":35,"url":"http://patchwork.ozlabs.org/api/projects/35/?format=json","name":"Linux I2C development","link_name":"linux-i2c","list_id":"linux-i2c.vger.kernel.org","list_email":"linux-i2c@vger.kernel.org","web_url":"","scm_url":"","webscm_url":"","list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20170917093906.16325-6-linus.walleij@linaro.org>","list_archive_url":null,"date":"2017-09-17T09:39:04","name":"[5/7] i2c: gpio: Local vars in probe","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"b02670e55e8ccfc406c041220abf5620f1eb3d96","submitter":{"id":7055,"url":"http://patchwork.ozlabs.org/api/people/7055/?format=json","name":"Linus Walleij","email":"linus.walleij@linaro.org"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/linux-i2c/patch/20170917093906.16325-6-linus.walleij@linaro.org/mbox/","series":[{"id":3497,"url":"http://patchwork.ozlabs.org/api/series/3497/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-i2c/list/?series=3497","date":"2017-09-17T09:38:59","name":"I2C GPIO to use gpiolibs open drain","version":1,"mbox":"http://patchwork.ozlabs.org/series/3497/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/814623/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/814623/checks/","tags":{},"related":[],"headers":{"Return-Path":"<linux-i2c-owner@vger.kernel.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=vger.kernel.org\n\t(client-ip=209.132.180.67; helo=vger.kernel.org;\n\tenvelope-from=linux-i2c-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (1024-bit key;\n\tunprotected) header.d=linaro.org header.i=@linaro.org\n\theader.b=\"ByXEK4sZ\"; dkim-atps=neutral"],"Received":["from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xw3xy2Jn0z9s72\n\tfor <incoming@patchwork.ozlabs.org>;\n\tSun, 17 Sep 2017 19:39:34 +1000 (AEST)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1751295AbdIQJjd (ORCPT <rfc822;incoming@patchwork.ozlabs.org>);\n\tSun, 17 Sep 2017 05:39:33 -0400","from mail-lf0-f45.google.com ([209.85.215.45]:56542 \"EHLO\n\tmail-lf0-f45.google.com\" rhost-flags-OK-OK-OK-OK) by vger.kernel.org\n\twith ESMTP id S1750995AbdIQJjc (ORCPT\n\t<rfc822; linux-i2c@vger.kernel.org>); Sun, 17 Sep 2017 05:39:32 -0400","by mail-lf0-f45.google.com with SMTP id a18so5562682lfl.13\n\tfor <linux-i2c@vger.kernel.org>; Sun, 17 Sep 2017 02:39:32 -0700 (PDT)","from fabina.bredbandsbolaget.se\n\t(c-2209e055.014-348-6c756e10.cust.bredbandsbolaget.se.\n\t[85.224.9.34]) by smtp.gmail.com with ESMTPSA id\n\tt84sm974559lfi.21.2017.09.17.02.39.29\n\t(version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256);\n\tSun, 17 Sep 2017 02:39:30 -0700 (PDT)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references;\n\tbh=k9Vob8DYJi4kyczGDuJoNvHeLrUQ0luZju+XmU3lJ2A=;\n\tb=ByXEK4sZwjERuOS4GecH6NQisOG0/0cMeE/ZCdR7k6clxbasEjLhfIKcim/JAQyfdb\n\t6k5Wpo04Raeb/I+Ab22NCi7ADGTX+mf2ZVGSl7TjKkQl5yYa5z6PYKtfci2yi/QLAMMb\n\tISkV3PDbr6gTdDok6xH/rRUXbaKZkZ8G+echE=","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references;\n\tbh=k9Vob8DYJi4kyczGDuJoNvHeLrUQ0luZju+XmU3lJ2A=;\n\tb=TqdA5MrViXW50A4KgevOFrN91fQLNgu7VhKEITyZ/fk8y+yJlDvTCSQLyEPq077AFO\n\tvLxRKzgDWIG7zPe5A2dCUWnUNDWywMGFjutsZI0zje8Y3ZoGiXWvSp9vFWBIXSl3rqXp\n\thxmz5wxigEqS2WrDhzsTvw34qyBEKqAm3+7oxUHkdGHyFRRzZfj17bJmM25KBcezGA60\n\tn+mKJ9EQ72uZpDWWNXO0ljT3bdsNMpoGtK3fZmWQetHrR6YBPuw6xkk/K1TZcjzqgY8n\n\tCQf16ze/8Udl+S9EKMf/5vvJJccH60EY6Y5rxgUI8yovNkGnRbxiIWx24KI5ywd5e5kj\n\tmgTg==","X-Gm-Message-State":"AHPjjUjMWwQpl+XUKMmOpjO/cGpeS8ON0NS9VEeeyUl6XZDJcLCKPtwK\n\tmhbji3MzoJ735Fq9","X-Google-Smtp-Source":"AOwi7QAhujHlkyg3HrDPPY7p3HUgGExvhaf/62cPMT48V3sqO6jiQLq18cQ/RnAR4Uo7IKE1Mzctgg==","X-Received":"by 10.25.181.26 with SMTP id e26mr2481381lff.91.1505641171276;\n\tSun, 17 Sep 2017 02:39:31 -0700 (PDT)","From":"Linus Walleij <linus.walleij@linaro.org>","To":"Wolfram Sang <wsa@the-dreams.de>, linux-i2c@vger.kernel.org","Cc":"linux-arm-kernel@lists.infradead.org, linux-mips@linux-mips.org,\n\tadi-buildroot-devel@lists.sourceforge.net,\n\tGeert Uytterhoeven <geert@linux-m68k.org>,\n\tLinus Walleij <linus.walleij@linaro.org>","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":"<linux-i2c.vger.kernel.org>","X-Mailing-List":"linux-i2c@vger.kernel.org"},"content":"By creating local variables for *dev and *np, the code become\nmuch easier to read, in my opinion.\n\nSigned-off-by: Linus Walleij <linus.walleij@linaro.org>\n---\nI put this at the end of the series because compared to the\nrest of the patches it is completely unimportant.\n---\n drivers/i2c/busses/i2c-gpio.c | 26 ++++++++++++++------------\n 1 file changed, 14 insertions(+), 12 deletions(-)","diff":"diff --git a/drivers/i2c/busses/i2c-gpio.c b/drivers/i2c/busses/i2c-gpio.c\nindex 97b9c29e9429..beb5ce523684 100644\n--- a/drivers/i2c/busses/i2c-gpio.c\n+++ b/drivers/i2c/busses/i2c-gpio.c\n@@ -88,10 +88,12 @@ static int i2c_gpio_probe(struct platform_device *pdev)\n \tstruct i2c_gpio_platform_data *pdata;\n \tstruct i2c_algo_bit_data *bit_data;\n \tstruct i2c_adapter *adap;\n+\tstruct device *dev = &pdev->dev;\n+\tstruct device_node *np = dev->of_node;\n \tenum gpiod_flags gflags;\n \tint ret;\n \n-\tpriv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);\n+\tpriv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);\n \tif (!priv)\n \t\treturn -ENOMEM;\n \n@@ -99,15 +101,15 @@ static int i2c_gpio_probe(struct platform_device *pdev)\n \tbit_data = &priv->bit_data;\n \tpdata = &priv->pdata;\n \n-\tif (pdev->dev.of_node) {\n-\t\tof_i2c_gpio_get_props(pdev->dev.of_node, pdata);\n+\tif (np) {\n+\t\tof_i2c_gpio_get_props(np, pdata);\n \t} else {\n \t\t/*\n \t\t * If all platform data settings are zero it is OK\n \t\t * to not provide any platform data from the board.\n \t\t */\n-\t\tif (dev_get_platdata(&pdev->dev))\n-\t\t\tmemcpy(pdata, dev_get_platdata(&pdev->dev),\n+\t\tif (dev_get_platdata(dev))\n+\t\t\tmemcpy(pdata, dev_get_platdata(dev),\n \t\t\t       sizeof(*pdata));\n \t}\n \n@@ -123,7 +125,7 @@ static int i2c_gpio_probe(struct platform_device *pdev)\n \t\tgflags = GPIOD_OUT_HIGH;\n \telse\n \t\tgflags = GPIOD_OUT_HIGH_OPEN_DRAIN;\n-\tpriv->sda = devm_gpiod_get_index(&pdev->dev, NULL, 0, gflags);\n+\tpriv->sda = devm_gpiod_get_index(dev, NULL, 0, gflags);\n \tif (IS_ERR(priv->sda)) {\n \t\tret = PTR_ERR(priv->sda);\n \t\t/* FIXME: hack in the old code, is this really necessary? */\n@@ -142,7 +144,7 @@ static int i2c_gpio_probe(struct platform_device *pdev)\n \t\tgflags = GPIOD_OUT_LOW;\n \telse\n \t\tgflags = GPIOD_OUT_LOW_OPEN_DRAIN;\n-\tpriv->scl = devm_gpiod_get_index(&pdev->dev, NULL, 1, gflags);\n+\tpriv->scl = devm_gpiod_get_index(dev, NULL, 1, gflags);\n \tif (IS_ERR(priv->scl)) {\n \t\tret = PTR_ERR(priv->scl);\n \t\t/* FIXME: hack in the old code, is this really necessary? */\n@@ -173,15 +175,15 @@ static int i2c_gpio_probe(struct platform_device *pdev)\n \tbit_data->data = priv;\n \n \tadap->owner = THIS_MODULE;\n-\tif (pdev->dev.of_node)\n-\t\tstrlcpy(adap->name, dev_name(&pdev->dev), sizeof(adap->name));\n+\tif (np)\n+\t\tstrlcpy(adap->name, dev_name(dev), sizeof(adap->name));\n \telse\n \t\tsnprintf(adap->name, sizeof(adap->name), \"i2c-gpio%d\", pdev->id);\n \n \tadap->algo_data = bit_data;\n \tadap->class = I2C_CLASS_HWMON | I2C_CLASS_SPD;\n-\tadap->dev.parent = &pdev->dev;\n-\tadap->dev.of_node = pdev->dev.of_node;\n+\tadap->dev.parent = dev;\n+\tadap->dev.of_node = np;\n \n \tadap->nr = pdev->id;\n \tret = i2c_bit_add_numbered_bus(adap);\n@@ -195,7 +197,7 @@ static int i2c_gpio_probe(struct platform_device *pdev)\n \t * get accessors to get the actual name of the GPIO line,\n \t * from the descriptor, then provide that instead.\n \t */\n-\tdev_info(&pdev->dev, \"using lines %u (SDA) and %u (SCL%s)\\n\",\n+\tdev_info(dev, \"using lines %u (SDA) and %u (SCL%s)\\n\",\n \t\t desc_to_gpio(priv->sda), desc_to_gpio(priv->scl),\n \t\t pdata->scl_is_output_only\n \t\t ? \", no clock stretching\" : \"\");\n","prefixes":["5/7"]}