From patchwork Tue Sep 20 05:22:40 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mahoda Ratnayaka X-Patchwork-Id: 9341031 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 8E60D607EE for ; Tue, 20 Sep 2016 05:22:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7EAD727F9E for ; Tue, 20 Sep 2016 05:22:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 72A5E28BEA; Tue, 20 Sep 2016 05:22:50 +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 75F6927F9E for ; Tue, 20 Sep 2016 05:22:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752744AbcITFWt (ORCPT ); Tue, 20 Sep 2016 01:22:49 -0400 Received: from gate2.alliedtelesis.co.nz ([202.36.163.20]:42316 "EHLO gate2.alliedtelesis.co.nz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751765AbcITFWs (ORCPT ); Tue, 20 Sep 2016 01:22:48 -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 4C5068025D; Tue, 20 Sep 2016 17:22:44 +1200 (NZST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alliedtelesis.co.nz; s=mail; t=1474348964; bh=jGKqoHzQhe3rvnGB5peu2vdzsuC6NX/RHL+X2foe8Go=; h=From:To:Cc:Subject:Date; b=HNInV1z6VH7qDHNxekerSf/eOlmFAf23Zu8YfO1BH6yb57K/oNrfFomq8FFp/GiZ+ 7LcyFU0DEPoicIeHHCx++ZWGlyAecpbKNB/J+4BUPIDC5VhwkgpeHJY4FSqt41kSE9 bSgd3ZBYt7IamfovvU5MrpnLBm2MJBXhG2ZllD00= Received: from smtp (Not Verified[10.32.16.33]) by mmarshal3.atlnz.lc with Trustwave SEG (v7, 3, 6, 7949) id ; Tue, 20 Sep 2016 17:22:43 +1200 Received: from mahodar-dl.ws.atlnz.lc (mahodar-dl.ws.atlnz.lc [10.33.22.13]) by smtp (Postfix) with ESMTP id 68BA013EC4C; Tue, 20 Sep 2016 17:22:43 +1200 (NZST) Received: by mahodar-dl.ws.atlnz.lc (Postfix, from userid 1609) id C8B00E0C4C; Tue, 20 Sep 2016 17:22:43 +1200 (NZST) From: Mahoda Ratnayaka To: Jean Delvare , Guenter Roeck , linux-hwmon@vger.kernel.org, devicetree@vger.kernel.org, Rob Herring Cc: Mahoda Ratnayaka , Chris Packham Subject: [PATCH v2] lm87: Allow channel data to be set from dts file. Date: Tue, 20 Sep 2016 17:22:40 +1200 Message-Id: <20160920052240.10242-1-mahoda.ratnayaka@alliedtelesis.co.nz> X-Mailer: git-send-email 2.9.3 Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently there is no method for setting the channel value from the DTS file. When, the driver uses a dts file to initialize the driver platform_data is not set. As a the result channel variable may not be set correctly. Without the channel variable set correctly, some of the sensors will not be initialized correctly. For example temp3 sensor sysfs entries. This adds the required functionality to set the channel variable from the DTS file. This is done via reading the reading a property named "channel" from the lm87 driver. Signed-off-by: Mahoda Ratnayaka --- Notes: changes since v1: Removed unncessary variables channel and np. Update the code as per review comments. Documentation/devicetree/bindings/hwmon/lm87.txt | 9 +++++++++ drivers/hwmon/lm87.c | 7 ++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/hwmon/lm87.txt b/Documentation/devicetree/bindings/hwmon/lm87.txt index fefcb48..1906e08 100644 --- a/Documentation/devicetree/bindings/hwmon/lm87.txt +++ b/Documentation/devicetree/bindings/hwmon/lm87.txt @@ -6,9 +6,18 @@ Required properties: - reg: I2C address +optional properties: +- channels: Value for the channel mode register. + This allows configuration of pins with + selectable uses on the LM87 device (e.g. + choosing between voltage and temperature + inputs). + See hwmon/lm87 for further information + Example: lm87@2e { compatible = "ti,lm87"; reg = <0x2e>; + channels=<0x4>; }; diff --git a/drivers/hwmon/lm87.c b/drivers/hwmon/lm87.c index a5e2958..358c1d4 100644 --- a/drivers/hwmon/lm87.c +++ b/drivers/hwmon/lm87.c @@ -858,8 +858,13 @@ static void lm87_remove_files(struct i2c_client *client) static void lm87_init_client(struct i2c_client *client) { struct lm87_data *data = i2c_get_clientdata(client); + u8 val = 0; - if (dev_get_platdata(&client->dev)) { + if (!of_property_read_u8(client->dev.of_node, "channels", &val)) { + data->channel = val; + lm87_write_value(client, + LM87_REG_CHANNEL_MODE, data->channel); + } else if (dev_get_platdata(&client->dev)) { data->channel = *(u8 *)dev_get_platdata(&client->dev); lm87_write_value(client, LM87_REG_CHANNEL_MODE, data->channel);