From patchwork Wed Jul 5 10:13:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Packham X-Patchwork-Id: 784503 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3x2cFV3YMXz9s72 for ; Wed, 5 Jul 2017 20:15:26 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=alliedtelesis.co.nz header.i=@alliedtelesis.co.nz header.b="Zp4RfiXk"; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751931AbdGEKPS (ORCPT ); Wed, 5 Jul 2017 06:15:18 -0400 Received: from gate2.alliedtelesis.co.nz ([202.36.163.20]:56632 "EHLO gate2.alliedtelesis.co.nz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752616AbdGEKOR (ORCPT ); Wed, 5 Jul 2017 06:14:17 -0400 Received: from mmarshal3.atlnz.lc (mmarshal3.atlnz.lc [10.32.18.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by gate2.alliedtelesis.co.nz (Postfix) with ESMTPS id 54288886B5; Wed, 5 Jul 2017 22:14:10 +1200 (NZST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alliedtelesis.co.nz; s=mail; t=1499249650; bh=DZbCzxmfzP/3/Ytvvqm3FozmF+P0kRSarCpfDeYqsFk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Zp4RfiXk1uQ2dM06mTK7ihkb0P3sSKJwK9fAP8TW/SSmg5YYhTrAq1OFg69rk954q iim0/nuDvMAeYcElLbhyjp8d68HMir4Fki53RF4FRzob2Dp95Sv7W9DK8nKqm0J+hI CYU01g5FbteDdJsQ8kkBiz3eWELWfQzbl9JRA7lA= Received: from smtp (Not Verified[10.32.16.33]) by mmarshal3.atlnz.lc with Trustwave SEG (v7, 5, 7, 9061) id ; Wed, 05 Jul 2017 22:14:11 +1200 Received: from chrisp-dl.atlnz.lc (chrisp-dl.ws.atlnz.lc [10.33.22.30]) by smtp (Postfix) with ESMTP id 0559F13EFF0; Wed, 5 Jul 2017 22:14:11 +1200 (NZST) Received: by chrisp-dl.atlnz.lc (Postfix, from userid 1030) id A3F7E1E2274; Wed, 5 Jul 2017 22:14:05 +1200 (NZST) From: Chris Packham To: wsa@the-dreams.de, ysato@users.sourceforge.jp, linux-i2c@vger.kernel.org, linux-sh@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Chris Packham Subject: [PATCH v2 2/4] i2c: pca-platform: unconditionally use devm_gpiod_get_optional Date: Wed, 5 Jul 2017 22:13:56 +1200 Message-Id: <20170705101358.17458-3-chris.packham@alliedtelesis.co.nz> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170705101358.17458-1-chris.packham@alliedtelesis.co.nz> References: <20170705101358.17458-1-chris.packham@alliedtelesis.co.nz> Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Allow for the reset-gpios property to be defined in the device tree or via a GPIO lookup table. Signed-off-by: Chris Packham --- Changes in v2: - move call up above platform_data usage drivers/i2c/busses/i2c-pca-platform.c | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/drivers/i2c/busses/i2c-pca-platform.c b/drivers/i2c/busses/i2c-pca-platform.c index 853a2abedb05..b90193d09d4b 100644 --- a/drivers/i2c/busses/i2c-pca-platform.c +++ b/drivers/i2c/busses/i2c-pca-platform.c @@ -173,33 +173,20 @@ static int i2c_pca_pf_probe(struct platform_device *pdev) i2c->adap.dev.parent = &pdev->dev; i2c->adap.dev.of_node = np; + i2c->gpio = devm_gpiod_get_optional(&pdev->dev, "reset-gpios", GPIOD_OUT_LOW); + if (IS_ERR(i2c->gpio)) + return PTR_ERR(i2c->gpio); + if (platform_data) { i2c->adap.timeout = platform_data->timeout; i2c->algo_data.i2c_clock = platform_data->i2c_clock_speed; - if (gpio_is_valid(platform_data->gpio)) { - ret = devm_gpio_request_one(&pdev->dev, - platform_data->gpio, - GPIOF_ACTIVE_LOW, - i2c->adap.name); - if (ret == 0) { - i2c->gpio = gpio_to_desc(platform_data->gpio); - gpiod_direction_output(i2c->gpio, 0); - } else { - dev_warn(&pdev->dev, "Registering gpio failed!\n"); - i2c->gpio = NULL; - } - } } else if (np) { i2c->adap.timeout = HZ; - i2c->gpio = devm_gpiod_get_optional(&pdev->dev, "reset-gpios", GPIOD_OUT_LOW); - if (IS_ERR(i2c->gpio)) - return PTR_ERR(i2c->gpio); of_property_read_u32_index(np, "clock-frequency", 0, &i2c->algo_data.i2c_clock); } else { i2c->adap.timeout = HZ; i2c->algo_data.i2c_clock = 59000; - i2c->gpio = NULL; } i2c->algo_data.data = i2c;