From patchwork Mon Sep 5 05:36:14 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mahoda Ratnayaka X-Patchwork-Id: 9313071 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 85E0D600CA for ; Mon, 5 Sep 2016 05:36:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 770C028997 for ; Mon, 5 Sep 2016 05:36:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6B26228999; Mon, 5 Sep 2016 05:36:24 +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 3653F28997 for ; Mon, 5 Sep 2016 05:36:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750776AbcIEFgW (ORCPT ); Mon, 5 Sep 2016 01:36:22 -0400 Received: from gate2.alliedtelesis.co.nz ([202.36.163.20]:39468 "EHLO gate2.alliedtelesis.co.nz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754115AbcIEFgW (ORCPT ); Mon, 5 Sep 2016 01:36:22 -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 1B3D3800E6; Mon, 5 Sep 2016 17:36:20 +1200 (NZST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alliedtelesis.co.nz; s=mail; t=1473053780; bh=XFp07EevXN+mDVktJKrcFasgP2rVK8zInhCf0H0nzfo=; h=From:To:Cc:Subject:Date; b=mm8SlnBEEyekZa8jTPjiMnEPlKX+0C+bwmi+rWKpsCXoXB/vuPohFn+sEv3N18Lrq RBc3q/XEB4/IMpFCWMQcnR5nABOPC9lS4WjUVZMYurBiFn5tYsIOfd4IQzWRmNkeSj pNIX6GjRc/8Q1/k1evI/+mO2tPrYnAsi42KtFUe4= Received: from smtp (Not Verified[10.32.16.33]) by mmarshal3.atlnz.lc with Trustwave SEG (v7, 3, 6, 7949) id ; Mon, 05 Sep 2016 17:36:18 +1200 Received: from mahodar-dl.ws.atlnz.lc (mahodar-dl.ws.atlnz.lc [10.33.22.17]) by smtp (Postfix) with ESMTP id 770DB13EC2D; Mon, 5 Sep 2016 17:36:17 +1200 (NZST) Received: by mahodar-dl.ws.atlnz.lc (Postfix, from userid 1609) id 5CB07E0BF2; Mon, 5 Sep 2016 17:36:19 +1200 (NZST) From: Mahoda Ratnayaka To: Jean Delvare , Guenter Roeck , linux-hwmon@vger.kernel.org Cc: Mahoda Ratnayaka , Chris Packham Subject: [PATCH] hwmon: (lm87) Add channel data from the dts file. Date: Mon, 5 Sep 2016 17:36:14 +1200 Message-Id: <20160905053614.7135-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 --- drivers/hwmon/lm87.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/hwmon/lm87.c b/drivers/hwmon/lm87.c index a5e2958..ac0018b 100644 --- a/drivers/hwmon/lm87.c +++ b/drivers/hwmon/lm87.c @@ -858,14 +858,25 @@ 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); + struct device_node *np = NULL; + const char *channel = NULL; + u8 val; - if (dev_get_platdata(&client->dev)) { + np = client->dev.of_node; + + /* Use value read from the dts file to setup channel value. */ + if (np && of_property_read_u8(np, "channels", &val) == 0) { + 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); } else { data->channel = lm87_read_value(client, LM87_REG_CHANNEL_MODE); } + data->config = lm87_read_value(client, LM87_REG_CONFIG) & 0x6F; if (!(data->config & 0x01)) {