From patchwork Fri Feb 10 16:12:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Lamparter X-Patchwork-Id: 9567039 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 50BBF601C3 for ; Fri, 10 Feb 2017 16:15:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3E8082858D for ; Fri, 10 Feb 2017 16:15:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3354D285AA; Fri, 10 Feb 2017 16:15:30 +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.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, 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 8413A2858D for ; Fri, 10 Feb 2017 16:15:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752963AbdBJQP1 (ORCPT ); Fri, 10 Feb 2017 11:15:27 -0500 Received: from mail-wm0-f67.google.com ([74.125.82.67]:35030 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752523AbdBJQPE (ORCPT ); Fri, 10 Feb 2017 11:15:04 -0500 Received: by mail-wm0-f67.google.com with SMTP id u63so8054085wmu.2; Fri, 10 Feb 2017 08:14:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=1WkopNGScpHS4eEhGQar6noV2XOITcIgiKoDckDPQ38=; b=CrJ3RIszdB5cyrgAMpdUGO00a6IiU2DkgpFizTI1HYpw6CLl1OKUa6cWc9CYIzGt2X x6w5sxIAAPIgZrJ4Ut5UALWW/Po0eKukgog9e65XZfR2XocFlIkIKv7fJH4uUsrs2M+i Z0RgNo19Fa83dLJbhbNkPoBsR6w7rS9Sx1Vo2r44hN1OsymOR5rzZt4fosGtsvWx2vbN iymTVJQ3g+2t+yhDqqkNB5CIfsC1yCekbhVNTmMaRkcWMGco6ytop/0DQBQsdf4bRm7b SqvOZj1MluzhCGmEHxbwF24MQB8w0NwFy+9UbSlCo6CwkR29XPuFyxkfCYEizAjGIcM+ Z55w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=1WkopNGScpHS4eEhGQar6noV2XOITcIgiKoDckDPQ38=; b=MvDZm/bMQArI13oPcrQnmXUoqowxFMi1kKOzDGKObQba0vCCYQJb0I1FYhfGSUpqOx pIYRLsh+6fpb69LyGvp9U/KRr7P1EiBxaM2Bzs1KHWSnBu1hSGBDwv0AnQeZNdnH+vbn CLLQlAVrRlfxYQUpm2aH2fB7/TLRwg49CUeGYeLb41BRr9ZF0I9erE6fGC13f0SjXPfV miW/RibnqDjxGJPZTp3s8W0wUrWHHEVziUJFGA0v9ubG71IpPitnRxA9cMagVBfuD/DR f1Dx54V0ZCjpDkptJWcKJi17h6/9iAMdLikIS1MNJKq7quiiUTL93Y/ufDK81Nfuu0hE sUBw== X-Gm-Message-State: AMke39mly3ElwIkioShsyWxpiUHLxvf2562GqVbQYg0+6KWqj1Hk7SxvSC524JybKFeTbw== X-Received: by 10.28.57.131 with SMTP id g125mr8005266wma.33.1486743281895; Fri, 10 Feb 2017 08:14:41 -0800 (PST) Received: from debian64.daheim (p5B0D7F2F.dip0.t-ipconnect.de. [91.13.127.47]) by smtp.gmail.com with ESMTPSA id e14sm2166854wmd.14.2017.02.10.08.14.40 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 10 Feb 2017 08:14:40 -0800 (PST) Received: from chuck by debian64.daheim with local (Exim 4.89) (envelope-from ) id 1ccDoE-0004ig-7W; Fri, 10 Feb 2017 17:12:30 +0100 From: Christian Lamparter To: linux-hwmon@vger.kernel.org, devicetree@vger.kernel.org Cc: Rob Herring , Jean Delvare , Wei Ni , Guenter Roeck Subject: [PATCH 2/2] hwmon: lm90: integration of channel map in dt-bindings Date: Fri, 10 Feb 2017 17:12:30 +0100 Message-Id: X-Mailer: git-send-email 2.11.0 In-Reply-To: <0d274e32ad09daa2f6f7f27f1c36d39da526b66d.1486741517.git.chunkeey@googlemail.com> References: <0d274e32ad09daa2f6f7f27f1c36d39da526b66d.1486741517.git.chunkeey@googlemail.com> In-Reply-To: <0d274e32ad09daa2f6f7f27f1c36d39da526b66d.1486741517.git.chunkeey@googlemail.com> References: <2979642.2YCYMDeKdL@debian64> <0d274e32ad09daa2f6f7f27f1c36d39da526b66d.1486741517.git.chunkeey@googlemail.com> 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 This patch integrates the LOCAL, REMOTE and REMOTE2 channel definitions into the lm90.c driver. Signed-off-by: Christian Lamparter --- This is an optional patch to showcase how the channel definition in the dt-bindings are mapped into the driver. In theory, this makes it possible to easily remap the channel indices. However, it does make the driver harder to read. --- drivers/hwmon/lm90.c | 61 ++++++++++++++++++++++++++++++++++------------------ 1 file changed, 40 insertions(+), 21 deletions(-) diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c index 841f2428e84a..aa67810000f9 100644 --- a/drivers/hwmon/lm90.c +++ b/drivers/hwmon/lm90.c @@ -95,6 +95,7 @@ #include #include #include +#include /* * Addresses to scan @@ -1016,23 +1017,33 @@ static int lm90_set_temphyst(struct lm90_data *data, long val) } static const u8 lm90_temp_index[3] = { - LOCAL_TEMP, REMOTE_TEMP, REMOTE2_TEMP + [LM90_LOCAL_TEMPERATURE] = LOCAL_TEMP, + [LM90_REMOTE_TEMPERATURE] = REMOTE_TEMP, + [LM90_REMOTE2_TEMPERATURE] = REMOTE2_TEMP }; static const u8 lm90_temp_min_index[3] = { - LOCAL_LOW, REMOTE_LOW, REMOTE2_LOW + [LM90_LOCAL_TEMPERATURE] = LOCAL_LOW, + [LM90_REMOTE_TEMPERATURE] = REMOTE_LOW, + [LM90_REMOTE2_TEMPERATURE] = REMOTE2_LOW }; static const u8 lm90_temp_max_index[3] = { - LOCAL_HIGH, REMOTE_HIGH, REMOTE2_HIGH + [LM90_LOCAL_TEMPERATURE] = LOCAL_HIGH, + [LM90_REMOTE_TEMPERATURE] = REMOTE_HIGH, + [LM90_REMOTE2_TEMPERATURE] = REMOTE2_HIGH }; static const u8 lm90_temp_crit_index[3] = { - LOCAL_CRIT, REMOTE_CRIT, REMOTE2_CRIT + [LM90_LOCAL_TEMPERATURE] = LOCAL_CRIT, + [LM90_REMOTE_TEMPERATURE] = REMOTE_CRIT, + [LM90_REMOTE2_TEMPERATURE] = REMOTE2_CRIT }; static const u8 lm90_temp_emerg_index[3] = { - LOCAL_EMERG, REMOTE_EMERG, REMOTE2_EMERG + [LM90_LOCAL_TEMPERATURE] = LOCAL_EMERG, + [LM90_REMOTE_TEMPERATURE] = REMOTE_EMERG, + [LM90_REMOTE2_TEMPERATURE] = REMOTE2_EMERG }; static const u8 lm90_min_alarm_bits[3] = { 5, 3, 11 }; @@ -1654,6 +1665,10 @@ static int lm90_probe(struct i2c_client *client, struct lm90_data *data; int err; + BUILD_BUG_ON(LM90_LOCAL_TEMPERATURE == LM90_REMOTE_TEMPERATURE || + LM90_REMOTE_TEMPERATURE == LM90_REMOTE2_TEMPERATURE || + LM90_REMOTE2_TEMPERATURE == LM90_LOCAL_TEMPERATURE); + regulator = devm_regulator_get(dev, "vcc"); if (IS_ERR(regulator)) return PTR_ERR(regulator); @@ -1695,37 +1710,41 @@ static int lm90_probe(struct i2c_client *client, data->chip.ops = &lm90_ops; data->chip.info = data->info; - data->info[0] = &lm90_chip_info; - data->info[1] = &data->temp_info; + data->info[LM90_LOCAL_TEMPERATURE] = &lm90_chip_info; + data->info[LM90_REMOTE_TEMPERATURE] = &data->temp_info; info = &data->temp_info; info->type = hwmon_temp; info->config = data->channel_config; - data->channel_config[0] = HWMON_T_INPUT | HWMON_T_MIN | HWMON_T_MAX | - HWMON_T_CRIT | HWMON_T_CRIT_HYST | HWMON_T_MIN_ALARM | - HWMON_T_MAX_ALARM | HWMON_T_CRIT_ALARM; - data->channel_config[1] = HWMON_T_INPUT | HWMON_T_MIN | HWMON_T_MAX | - HWMON_T_CRIT | HWMON_T_CRIT_HYST | HWMON_T_MIN_ALARM | - HWMON_T_MAX_ALARM | HWMON_T_CRIT_ALARM | HWMON_T_FAULT; + data->channel_config[LM90_LOCAL_TEMPERATURE] = HWMON_T_INPUT | + HWMON_T_MIN | HWMON_T_MAX | HWMON_T_CRIT | HWMON_T_CRIT_HYST | + HWMON_T_MIN_ALARM | HWMON_T_MAX_ALARM | HWMON_T_CRIT_ALARM; + data->channel_config[LM90_REMOTE_TEMPERATURE] = HWMON_T_INPUT | + HWMON_T_MIN | HWMON_T_MAX | HWMON_T_CRIT | HWMON_T_CRIT_HYST | + HWMON_T_MIN_ALARM | HWMON_T_MAX_ALARM | HWMON_T_CRIT_ALARM | + HWMON_T_FAULT; if (data->flags & LM90_HAVE_OFFSET) - data->channel_config[1] |= HWMON_T_OFFSET; + data->channel_config[LM90_REMOTE_TEMPERATURE] |= HWMON_T_OFFSET; if (data->flags & LM90_HAVE_EMERGENCY) { - data->channel_config[0] |= HWMON_T_EMERGENCY | - HWMON_T_EMERGENCY_HYST; - data->channel_config[1] |= HWMON_T_EMERGENCY | - HWMON_T_EMERGENCY_HYST; + data->channel_config[LM90_LOCAL_TEMPERATURE] |= + HWMON_T_EMERGENCY | HWMON_T_EMERGENCY_HYST; + data->channel_config[LM90_REMOTE_TEMPERATURE] |= + HWMON_T_EMERGENCY | HWMON_T_EMERGENCY_HYST; } if (data->flags & LM90_HAVE_EMERGENCY_ALARM) { - data->channel_config[0] |= HWMON_T_EMERGENCY_ALARM; - data->channel_config[1] |= HWMON_T_EMERGENCY_ALARM; + data->channel_config[LM90_LOCAL_TEMPERATURE] |= + HWMON_T_EMERGENCY_ALARM; + data->channel_config[LM90_REMOTE_TEMPERATURE] |= + HWMON_T_EMERGENCY_ALARM; } if (data->flags & LM90_HAVE_TEMP3) { - data->channel_config[2] = HWMON_T_INPUT | + data->channel_config[LM90_REMOTE2_TEMPERATURE] = + HWMON_T_INPUT | HWMON_T_MIN | HWMON_T_MAX | HWMON_T_CRIT | HWMON_T_CRIT_HYST | HWMON_T_EMERGENCY | HWMON_T_EMERGENCY_HYST |