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: 112159 Delivered-To: patch@linaro.org Received: by 10.100.153.131 with SMTP id 3csp4844467pji; Sun, 10 Sep 2017 14:44:53 -0700 (PDT) X-Received: by 10.99.0.75 with SMTP id 72mr9857316pga.209.1505079893926; Sun, 10 Sep 2017 14:44:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505079893; cv=none; d=google.com; s=arc-20160816; b=H/VobP654SfImMCfU1my5OWkqhIr73hVGdN5e0PK46zTRBE7/CnDKd0lCwaiX61q3Q i2AN284OPxNvmHIPh1Yl63105Tcf5blyevcygtwvmmhwNGekKKmArnsuyUF+ZgEagnUp RQTQakzOIFLZ0HAma32CBnuuDj3D8rVPJR5XwllrVPw6uJL/sU9Cl6gae3xgvyYZB1hO jDur/WCWCcjB0iTKYLWRhFf4RUYkCdHjhFhSaqb4vfWaQezmNrRmA6K/nxSPuaPfH2yN ArozlkDgs4kQbh3nhthrYKJB/0yBD7zV34LL9d61AZXJGNWp3DRsFQmfXwzVWDHjYAIf kPUA== 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=erzgjhU0ezSIivaubwnwB+XCJNNifZqiUpJZ7kylSg0=; b=A4gSa2qRJ9wgy3j/bTIz38eevygoOb4C1nwRcSSQklEIeTxhKAyhJ6fIsaS20g2Yyh lIrQ8fDTofRhdIfeukDWHel8Jeh58RK+mt0wWB2JK/5NcjBBTb1b6/Q9x3OEpMFYYfgi B9eOKLklM8mwuEUcWX/4i0y2FZxgttP0EjfYdpR4BZS1B5CAVzJiEM2PxrXiwgnEgdtG bIHKXQbCehqr0PehWAHri907ijNEc68NYmdkyF+2Y4sl4dRgVpuZYQaSNHkIgJb0K6V2 WNUf6XKGEcF0VFjDWKui8xILiVcXUsL1RwGG/9xsFc37n6FOATJjE01gftCNvxICoyoz N0ag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CbcTVlfm; 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 p9si5925819plk.558.2017.09.10.14.44.53; Sun, 10 Sep 2017 14:44:53 -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=CbcTVlfm; 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 S1751918AbdIJVox (ORCPT + 2 others); Sun, 10 Sep 2017 17:44:53 -0400 Received: from mail-lf0-f41.google.com ([209.85.215.41]:33400 "EHLO mail-lf0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751827AbdIJVow (ORCPT ); Sun, 10 Sep 2017 17:44:52 -0400 Received: by mail-lf0-f41.google.com with SMTP id c80so14448725lfh.0 for ; Sun, 10 Sep 2017 14:44:51 -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=n/4bBf4C/O/il4K0Rm7nYvvAZRTQM5+2SulfQF/NZ/6k0aQOR2xrFCEsGx3bZIg0Pm LaMIDf/iqTMcLOzGXGhwcMRHyO3bpdlhQhOyJj5yVKkNDAmGK0RkBMH5Ye3t9NwCWS5g s0MjNwEuT/HK5CsSdws1T4k7Tc83Vw4lM76BZY8AwlNH33hWafz/PMW2qZ39jFOLV1Sc tq95+8gAgSOaZD1OqqGyZL+QZWi5l79fWsnMoO+sgSivjYtI5/Gn1MoqrcbEwugnunzT IWhYmCkuArtaGHQN/869c7fjqJO16m2qR6GasMQ8Z4/Kb9X0RnObIHdI701IpJvT783l kLaQ== X-Gm-Message-State: AHPjjUhdjDxDS+cvsLWqKjv4UJFmupNWcsPwOrfkp64S/+CnpYEGW+Y3 8ggIsmQ+Z7AtUpNaAenMCw== 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 Cc: linux-arm-kernel@lists.infradead.org, linux-mips@linux-mips.org, adi-buildroot-devel@lists.sourceforge.net, Linus Walleij 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> 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 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" : "");