From patchwork Tue Jun 5 13:42:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 137733 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp978198lji; Tue, 5 Jun 2018 06:42:59 -0700 (PDT) X-Google-Smtp-Source: ADUXVKL5XN9vP9XTnD1TH9Zc+DLA4hS3QD4cBiKCLBbOl7koftUb6Vji4BJ8YFBISCc76Wuy+z66 X-Received: by 2002:a63:7b51:: with SMTP id k17-v6mr20938296pgn.55.1528206179250; Tue, 05 Jun 2018 06:42:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528206179; cv=none; d=google.com; s=arc-20160816; b=WpdICv0Li3bkzcEPDqM18DEYsuVOaDQgyFLVxqwAM5UKhZjt4Q4bX1puaAcDXXjZNm FaFc0a9qa9UQ48J9ImunokLAyoSiwzNeVZdun3PMow+YY9jKzHgzSsA6QDXdpTYJ6PG6 cgMuM/sz7zwfYjL73b3fwz/Ec0SpbREeV+I5Fkz67/xtVTtzeAsTGMMpanue+wZwETx3 d4c9oiFqick+BZTqTsHeXUqTOexLoAzntUemFs8/8OyKG4K2CwCGUxfJeHsNIx/PzuxP chlQqujpfiQ01VndbpQBv3W+uKO0yhAjf02E2IecbAh4kH6jrQ6Zeuupak64iujxJiZC 3rww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=7hc1eWCqSnfxfi8NLNLOAAj32GuiPj44vHg2fcxnm2s=; b=JNZTM9co8tEC8iN8G5zslWu/JUgpFYfu6CHwDBJgwMB21XlETT+dRX2JBgCKxf1fXf tdoeFGSRKCwMHKopOkAQpYiV+/S9H/CTlyfze+r+S1zU+jeeQooX/Rl/nppIKq9632S5 rO9hgZB6UxfM8GZ39d4seUneiIlMutEpmm0lxo8yn93keHOCl63N10klw62cqR6pjHmZ L/Y0NlhsbqCtN3OcmKDy+fHKHOaGZKDdua8X0PPnM2cHjL5bwesW2UJbsv94GMZJBTjd qaTf4mpxi10hEW0pXchnEklnW/GdIx860kjEZllzoHLoSOb5WVCnmSGwP0yuTj7Id0IA UjRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=En0p1/Rl; 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 p1-v6si37876891plo.363.2018.06.05.06.42.59; Tue, 05 Jun 2018 06:42:59 -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=En0p1/Rl; 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 S1752009AbeFENm5 (ORCPT + 2 others); Tue, 5 Jun 2018 09:42:57 -0400 Received: from mail-lf0-f68.google.com ([209.85.215.68]:46928 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751759AbeFENmn (ORCPT ); Tue, 5 Jun 2018 09:42:43 -0400 Received: by mail-lf0-f68.google.com with SMTP id j13-v6so3641172lfb.13 for ; Tue, 05 Jun 2018 06:42:42 -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; bh=7hc1eWCqSnfxfi8NLNLOAAj32GuiPj44vHg2fcxnm2s=; b=En0p1/RlTeIlkdV+qbiwk49kQLpNXCZ+jreGsHa+vTb78Ii4OS5MON08EUnf5pU8jJ vSoE9GQL3YVJmlFXqCU+NzVDrrlWwbjUyhjJ64PaFLmUvmlRa6vd4sJh86ez7n7M5EU7 KY17KeblfFySbE/vFXTDBWwMb8WRAcbck+m0I= 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; bh=7hc1eWCqSnfxfi8NLNLOAAj32GuiPj44vHg2fcxnm2s=; b=T26APJOdlGBQt+bcHEvD8dzZiqU1DndEHrtq8FlqSmuiu9WKytSbjkbMdiEa0J8txe lMM/c249ZqD8zEFQv1/xGM851uY3tcuKjT5qUCMlbQS2ERko/qGnXRSjSYStkJlw+Y71 IgGD8MDEt99ZlPdcDVIP7J2R9Q6CBwa3/Xk63ipQTbj/xbgNPjgUENZ8jBWzUBZDodeT JbMoaX1WHOR3j2ilXSUSjTXUxPLqUWTGLqqtiy+qAckVCEZ214uaKB6c8+TPzU892C3M J8vF0TIuuZG+VdI+Nle7FIC9Pxe47UfxpuRVeDI1olgaE4YXSm6N+eRMa/WuJLKEm3iO 3IHA== X-Gm-Message-State: APt69E16x+UOhwP6N6KLqgrIfmvfCsdLwQfwQPTpVqZXLRH5HpwuLOYi Ej8JAtotDA4adgzIPIeVJirQsaNqjgo= X-Received: by 2002:a2e:6e19:: with SMTP id j25-v6mr9180262ljc.61.1528206162083; Tue, 05 Jun 2018 06:42:42 -0700 (PDT) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id o11-v6sm2613967lji.0.2018.06.05.06.42.40 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Jun 2018 06:42:41 -0700 (PDT) From: Linus Walleij To: Wolfram Sang , linux-i2c@vger.kernel.org Cc: Linus Walleij , Peter Rosin Subject: [PATCH] i2c: mux: pca954x: Use helper variable in probe Date: Tue, 5 Jun 2018 15:42:36 +0200 Message-Id: <20180605134236.5163-1-linus.walleij@linaro.org> X-Mailer: git-send-email 2.17.0 Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org This creates a struct device *dev helper variable in probe() which IMO makes the code less cluttered and easier to read. Also rename the of_node to the common shortform "np" (node pointer). Cc: Peter Rosin Signed-off-by: Linus Walleij --- drivers/i2c/muxes/i2c-mux-pca954x.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) -- 2.17.0 diff --git a/drivers/i2c/muxes/i2c-mux-pca954x.c b/drivers/i2c/muxes/i2c-mux-pca954x.c index fbc748027087..feb91cb2c39e 100644 --- a/drivers/i2c/muxes/i2c-mux-pca954x.c +++ b/drivers/i2c/muxes/i2c-mux-pca954x.c @@ -368,7 +368,8 @@ static int pca954x_probe(struct i2c_client *client, { struct i2c_adapter *adap = to_i2c_adapter(client->dev.parent); struct pca954x_platform_data *pdata = dev_get_platdata(&client->dev); - struct device_node *of_node = client->dev.of_node; + struct device *dev = &client->dev; + struct device_node *np = dev->of_node; bool idle_disconnect_dt; struct gpio_desc *gpio; int num, force, class; @@ -379,7 +380,7 @@ static int pca954x_probe(struct i2c_client *client, if (!i2c_check_functionality(adap, I2C_FUNC_SMBUS_BYTE)) return -ENODEV; - muxc = i2c_mux_alloc(adap, &client->dev, + muxc = i2c_mux_alloc(adap, dev, PCA954X_MAX_NCHANS, sizeof(*data), 0, pca954x_select_chan, pca954x_deselect_mux); if (!muxc) @@ -390,7 +391,7 @@ static int pca954x_probe(struct i2c_client *client, data->client = client; /* Reset the mux if a reset GPIO is specified. */ - gpio = devm_gpiod_get_optional(&client->dev, "reset", GPIOD_OUT_HIGH); + gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH); if (IS_ERR(gpio)) return PTR_ERR(gpio); if (gpio) { @@ -400,7 +401,7 @@ static int pca954x_probe(struct i2c_client *client, udelay(1); } - data->chip = of_device_get_match_data(&client->dev); + data->chip = of_device_get_match_data(dev); if (!data->chip) data->chip = &chips[id->driver_data]; @@ -414,7 +415,7 @@ static int pca954x_probe(struct i2c_client *client, if (!ret && (id.manufacturer_id != data->chip->id.manufacturer_id || id.part_id != data->chip->id.part_id)) { - dev_warn(&client->dev, + dev_warn(dev, "unexpected device id %03x-%03x-%x\n", id.manufacturer_id, id.part_id, id.die_revision); @@ -427,14 +428,14 @@ static int pca954x_probe(struct i2c_client *client, * initializes the mux to disconnected state. */ if (i2c_smbus_write_byte(client, 0) < 0) { - dev_warn(&client->dev, "probe failed\n"); + dev_warn(dev, "probe failed\n"); return -ENODEV; } data->last_chan = 0; /* force the first selection */ - idle_disconnect_dt = of_node && - of_property_read_bool(of_node, "i2c-mux-idle-disconnect"); + idle_disconnect_dt = np && + of_property_read_bool(np, "i2c-mux-idle-disconnect"); ret = pca954x_irq_setup(muxc); if (ret) @@ -465,7 +466,7 @@ static int pca954x_probe(struct i2c_client *client, } if (data->irq) { - ret = devm_request_threaded_irq(&client->dev, data->client->irq, + ret = devm_request_threaded_irq(dev, data->client->irq, NULL, pca954x_irq_handler, IRQF_ONESHOT | IRQF_SHARED, "pca954x", data); @@ -473,7 +474,7 @@ static int pca954x_probe(struct i2c_client *client, goto fail_cleanup; } - dev_info(&client->dev, + dev_info(dev, "registered %d multiplexed busses for I2C %s %s\n", num, data->chip->muxtype == pca954x_ismux ? "mux" : "switch", client->name);