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: 784504 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 3x2cFg0MTMz9s9Y for ; Wed, 5 Jul 2017 20:15:35 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=alliedtelesis.co.nz header.i=@alliedtelesis.co.nz header.b="GTmaP5ap"; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752613AbdGEKOP (ORCPT ); Wed, 5 Jul 2017 06:14:15 -0400 Received: from gate2.alliedtelesis.co.nz ([202.36.163.20]:56635 "EHLO gate2.alliedtelesis.co.nz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751811AbdGEKON (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-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org 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;