From patchwork Tue Nov 15 04:00:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mahoda Ratnayaka X-Patchwork-Id: 9428891 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 D55C360469 for ; Tue, 15 Nov 2016 04:00:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B1197289B3 for ; Tue, 15 Nov 2016 04:00:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A501228B56; Tue, 15 Nov 2016 04:00:34 +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 A0E51289B3 for ; Tue, 15 Nov 2016 04:00:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S938799AbcKOEAd (ORCPT ); Mon, 14 Nov 2016 23:00:33 -0500 Received: from gate2.alliedtelesis.co.nz ([202.36.163.20]:49757 "EHLO gate2.alliedtelesis.co.nz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933542AbcKOEAc (ORCPT ); Mon, 14 Nov 2016 23:00:32 -0500 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 7EE508605D; Tue, 15 Nov 2016 17:00:28 +1300 (NZDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alliedtelesis.co.nz; s=mail; t=1479182428; bh=L5kzBcC8FuOzezZQZrSmwCIOSZsX/n9eOq7L8p8221Q=; h=From:To:Cc:Subject:Date; b=nu7O58mgufoiX/3ZQ539b/x/ZsE4LY84CQMQOkbE/EwF9LvZKYacb9/otkxz8R71J //9MWWNDX+nK2YQHI8//EwkIyXawDvucYx04hH6LariydmxExxNUV72LdUDpdS1P4h mbaDV/x4uqsQyIZpgknRfgqqgj0lRsQiezcIkLwM= Received: from smtp (Not Verified[10.32.16.33]) by mmarshal3.atlnz.lc with Trustwave SEG (v7, 5, 6, 8438) id ; Tue, 15 Nov 2016 17:00:27 +1300 Received: from mahodar-dl.ws.atlnz.lc (mahodar-dl.ws.atlnz.lc [10.33.22.12]) by smtp (Postfix) with ESMTP id 41DBC13EF0F; Tue, 15 Nov 2016 17:00:26 +1300 (NZDT) Received: by mahodar-dl.ws.atlnz.lc (Postfix, from userid 1609) id 94E6FE0C07; Tue, 15 Nov 2016 17:00:26 +1300 (NZDT) From: Mahoda Ratnayaka To: Jean Delvare , Guenter Roeck , linux-hwmon@vger.kernel.org Cc: Chris Packham , Mahoda Ratnayaka , Jason Gunthorpe Subject: [PATCH v3] lm87: Allow channel data to be set from dts file. Date: Tue, 15 Nov 2016 17:00:06 +1300 Message-Id: <20161115040006.7435-1-mahoda.ratnayaka@alliedtelesis.co.nz> X-Mailer: git-send-email 2.10.2 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 implements the schema agreed with the device tree binding document. Signed-off-by: Mahoda Ratnayaka --- Notes: changes since v1: Removed unncessary variables channel and np. Update the code as per review comments. changes since v2: Update the implementation to reflect the newly added lm87 binding document. https://patchwork.kernel.org/patch/9408433/ drivers/hwmon/lm87.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/drivers/hwmon/lm87.c b/drivers/hwmon/lm87.c index a5e2958..64ea57d4 100644 --- a/drivers/hwmon/lm87.c +++ b/drivers/hwmon/lm87.c @@ -858,8 +858,22 @@ 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); - - if (dev_get_platdata(&client->dev)) { + struct device_node *of_node = client->dev.of_node; + u8 val = 0; + + if (of_node) { + if (of_property_read_bool(of_node, "has-temp3")) + val |= CHAN_TEMP3; + if (of_property_read_bool(of_node, "has-in6")) + val |= CHAN_NO_FAN(0); + if (of_property_read_bool(of_node, "has-in7")) + val |= CHAN_NO_FAN(1); + if (of_property_read_bool(of_node, "vcc-supply")) + val |= CHAN_VCC_5V; + 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);