From patchwork Tue Aug 14 07:09:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lothar Felten X-Patchwork-Id: 10565133 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 610C31390 for ; Tue, 14 Aug 2018 07:09:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 51E3229625 for ; Tue, 14 Aug 2018 07:09:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4449E29630; Tue, 14 Aug 2018 07:09: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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 8EE9C29631 for ; Tue, 14 Aug 2018 07:09:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730788AbeHNJzj (ORCPT ); Tue, 14 Aug 2018 05:55:39 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:37389 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727670AbeHNJzj (ORCPT ); Tue, 14 Aug 2018 05:55:39 -0400 Received: by mail-wm0-f66.google.com with SMTP id n11-v6so11094083wmc.2 for ; Tue, 14 Aug 2018 00:09:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=GAFCK+uoB3eMoh9I2DtVZ6QmdLy8XTZzKC2gqXKob9k=; b=t27bxgb0+QheEkI/exZDuo2g0XIJjPLnM2S5IxHBSwRR6lqy0UjEVneZzVXEdoRfTI +PxIIIoqEewk/nFSqM9RjWgsEOmaCmB9Qrxf3ToiC3hWrmCXAjA+VQ4LpGY7TkkJySoa rbWa3EAx032N06xWx1Gbjx6G6cq96RebP0Ga4uANoIJ+lX5nIKgUVhpAWrR9QDVNjEQJ 3Byr9AUifNruHVPeJTTs4rITN6vkNvsPnXQJBRlLMbCW3v6LOivw2zWo/UTwbcCgTlpu rh+s2lY6sqD60HWfgc1dv2anLaYZtxFlL9rosRWmAB3zSN+p0CZObn9aie3q0GINJmlR gsHQ== 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; bh=GAFCK+uoB3eMoh9I2DtVZ6QmdLy8XTZzKC2gqXKob9k=; b=qPt2w82bkl7PYrIM7V/5UkizvW3C5GmX0j4/qaUcCKh6cSNtn3zvltZ1BnBUOmVO74 QKqpiVXpUZjXtQKaas7APMpQ2tg40CdHmZ++7OTJ6Rms6fWq2vTOlUuUF18sCz/cRLf5 wIRnPvj4kVSggLYpAE45OStdl7IimoiJf5z9PVrmQBjUemfKULfZ5t6qDYjWqCnZqSoB w5sltnu1O+ftl4mtHw3+1x84lwZ0rrKC+gVeRz4P0raM8nMi5E531uVaxkmAvvrIPkDj 74+TMFC1LtTEOCnnPqjrP/s7z14xP0O6wvMAaaRdybS9bn0EkpXlAuWtnQUd4IqkUUpS bi+Q== X-Gm-Message-State: AOUpUlEaml5g2SLXkBLpMKdkGVAcdG2H0Atuv2cCqGWx0LipeR3ohSF/ pC0UOsAgJJhrvZcuiBqop6U/FJkSltg= X-Google-Smtp-Source: AA+uWPznoxCFNovXEljOIxUg9AH6VdjgskCH9eLHfgOCtIpXjrxzqXnsX2yC88z4slVTQJrhI5oDzw== X-Received: by 2002:a1c:63d4:: with SMTP id x203-v6mr9902800wmb.9.1534230585337; Tue, 14 Aug 2018 00:09:45 -0700 (PDT) Received: from xeon.fritz.box (p508DB08D.dip0.t-ipconnect.de. [80.141.176.141]) by smtp.gmail.com with ESMTPSA id j133-v6sm26136921wmd.12.2018.08.14.00.09.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 Aug 2018 00:09:44 -0700 (PDT) From: Lothar Felten To: linux-hwmon@vger.kernel.org Cc: Lothar Felten Subject: [PATCH 1/1] hwmon: (ina2xx) fix sysfs shunt resistor read access Date: Tue, 14 Aug 2018 09:09:37 +0200 Message-Id: <20180814070937.3794-1-lothar.felten@gmail.com> X-Mailer: git-send-email 2.11.0 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 fix the sysfs shunt resistor read access: return the shunt resistor value, not the calibration register contents. update email address Signed-off-by: Lothar Felten --- Documentation/hwmon/ina2xx | 2 +- drivers/hwmon/ina2xx.c | 13 +++++++++++-- include/linux/platform_data/ina2xx.h | 2 +- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Documentation/hwmon/ina2xx b/Documentation/hwmon/ina2xx index 72d16f08e431..b8df81f6d6bc 100644 --- a/Documentation/hwmon/ina2xx +++ b/Documentation/hwmon/ina2xx @@ -32,7 +32,7 @@ Supported chips: Datasheet: Publicly available at the Texas Instruments website http://www.ti.com/ -Author: Lothar Felten +Author: Lothar Felten Description ----------- diff --git a/drivers/hwmon/ina2xx.c b/drivers/hwmon/ina2xx.c index e9e6aeabbf84..71d3445ba869 100644 --- a/drivers/hwmon/ina2xx.c +++ b/drivers/hwmon/ina2xx.c @@ -17,7 +17,7 @@ * Bi-directional Current/Power Monitor with I2C Interface * Datasheet: http://www.ti.com/product/ina230 * - * Copyright (C) 2012 Lothar Felten + * Copyright (C) 2012 Lothar Felten * Thanks to Jan Volkering * * This program is free software; you can redistribute it and/or modify @@ -329,6 +329,15 @@ static int ina2xx_set_shunt(struct ina2xx_data *data, long val) return 0; } +static ssize_t ina2xx_show_shunt(struct device *dev, + struct device_attribute *da, + char *buf) +{ + struct ina2xx_data *data = dev_get_drvdata(dev); + + return snprintf(buf, PAGE_SIZE, "%li\n", data->rshunt); +} + static ssize_t ina2xx_store_shunt(struct device *dev, struct device_attribute *da, const char *buf, size_t count) @@ -403,7 +412,7 @@ static SENSOR_DEVICE_ATTR(power1_input, S_IRUGO, ina2xx_show_value, NULL, /* shunt resistance */ static SENSOR_DEVICE_ATTR(shunt_resistor, S_IRUGO | S_IWUSR, - ina2xx_show_value, ina2xx_store_shunt, + ina2xx_show_shunt, ina2xx_store_shunt, INA2XX_CALIBRATION); /* update interval (ina226 only) */ diff --git a/include/linux/platform_data/ina2xx.h b/include/linux/platform_data/ina2xx.h index 9abc0ca7259b..9f0aa1b48c78 100644 --- a/include/linux/platform_data/ina2xx.h +++ b/include/linux/platform_data/ina2xx.h @@ -1,7 +1,7 @@ /* * Driver for Texas Instruments INA219, INA226 power monitor chips * - * Copyright (C) 2012 Lothar Felten + * Copyright (C) 2012 Lothar Felten * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as