From patchwork Wed Jul 5 10:13:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Packham X-Patchwork-Id: 9826261 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9F5D460317 for ; Wed, 5 Jul 2017 10:15:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 91A1F27F7F for ; Wed, 5 Jul 2017 10:15:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 867B72808F; Wed, 5 Jul 2017 10:15:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F26EB27F7F for ; Wed, 5 Jul 2017 10:15:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752618AbdGEKOP (ORCPT ); Wed, 5 Jul 2017 06:14:15 -0400 Received: from gate2.alliedtelesis.co.nz ([202.36.163.20]:56637 "EHLO gate2.alliedtelesis.co.nz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752613AbdGEKON (ORCPT ); Wed, 5 Jul 2017 06:14:13 -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 59A42886BC; 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=Uylsf++RmhFM/CoNY8zbDIIMpmGoY+lgfSSOhfhZcUk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=GTmaP5apGMd4EZLdTT3mLwETXjaKzBphPSAVMWiO1ayCovIeHDQ4Dv05Ov+DsaVFP KhJYlKyP2hFcw3FYtRYjyV3FaQnAwPTKvM8LAvLb3YqNqeTp8kl3ETFUjg8vlxVtdB OByg+DmeDwhp1z8OV+ns5n3l1th4cRcOTzE7A/NQ= 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 1F1F113F009; Wed, 5 Jul 2017 22:14:11 +1200 (NZST) Received: by chrisp-dl.atlnz.lc (Postfix, from userid 1030) id BC2821E2274; 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 3/4] i2c: pca-platform: use device_property_read_u32 Date: Wed, 5 Jul 2017 22:13:57 +1200 Message-Id: <20170705101358.17458-4-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-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use device_property_read_u32 instead of of_property_read_u32_index to lookup the "clock-frequency" property. Signed-off-by: Chris Packham --- Changes in v2: - move call to device_property_read_u32 to above platform_data usage. This allows the device property/device tree to go first and platform_data (if present) can override things. Eventually when all the platforms using this driver are converted to either use device properties or a device tree then the platform_data can simply be deleted. drivers/i2c/busses/i2c-pca-platform.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/i2c/busses/i2c-pca-platform.c b/drivers/i2c/busses/i2c-pca-platform.c index b90193d09d4b..bc2707ffd409 100644 --- a/drivers/i2c/busses/i2c-pca-platform.c +++ b/drivers/i2c/busses/i2c-pca-platform.c @@ -177,16 +177,15 @@ static int i2c_pca_pf_probe(struct platform_device *pdev) if (IS_ERR(i2c->gpio)) return PTR_ERR(i2c->gpio); + i2c->adap.timeout = HZ; + ret = device_property_read_u32(&pdev->dev, "clock-frequency", + &i2c->algo_data.i2c_clock); + if (ret) + i2c->algo_data.i2c_clock = 59000; + if (platform_data) { i2c->adap.timeout = platform_data->timeout; i2c->algo_data.i2c_clock = platform_data->i2c_clock_speed; - } else if (np) { - i2c->adap.timeout = HZ; - 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->algo_data.data = i2c;