Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp1192604ybn; Wed, 2 Oct 2019 12:13:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqww69RbWsKP2bruAspoUP5JPn8t1i46ASZvvNLaNLKdoIeWmNs2tgbDVwfCh74E3JjcKN+B X-Received: by 2002:a50:eb03:: with SMTP id y3mr5687501edp.194.1570043595298; Wed, 02 Oct 2019 12:13:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570043595; cv=none; d=google.com; s=arc-20160816; b=fRSVwTJyr4wLOPBgS1RmPha3FC6fiaH1W5z/YepiCSRt2dJYZaVnp3mgppyNNebj5b rAFLK9YR2KRhv97jP+5GqFM45U5/iNaXe7ce/jDuoWkOj1HoOKWuXMsXcuR2HU1/bOBD +ombGEABvfg3beiuzEf7RPXPhvw6GIYwycFk6Xg1Eqk1vUPziyzTfdDjJdkKlWfVpJ+X keGYhJcah5gHuSBm6aEOL0+pIfEwSFp8esJCqB+v6p+yx9lR6HFcFnjp4EF92yYSh6+I e0WC/3uh4l7FcaGPcvdg1+qBcthDkxNNCEVV2RjBaLcZEaW/FUCmzeLoESEFDraYce6E v7Hg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=JpezFIcAtsGOAKIVa92DxVCmYxPd7npiPI6NUkdgqvw=; b=nAxtrPwFSmOlu2jimXHxHqPNQreGmm1RCxCdRJw29i4rJ8yobIeSFuqUPJ3Yw0l1O/ VvsHJCHJqOaB9HEHKVwmVe2nrPDLeZL/gq7oLurChV8GN1gX5vlzoftj2tHBMpY0O7gP cv4sjIMqA61Mc3vb8trmyXXhAexcLCr8IkyZMuTUAyqW1iHRKLiCCcjCdg6A9uAueGfl 3upVh3BfumeF1mAeLk1cTK92jBdHcuI3AlVBgIOIN22hOKjHLLUPrwYVK00ch3qL//Cf JYonODytDHxs4mZNMm5WzROjIIExwHHnJKxmqN7x2qjF0neqdssR7ZajmERL1guc5enm uHcQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j52si19161eda.338.2019.10.02.12.12.51; Wed, 02 Oct 2019 12:13:15 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729996AbfJBTLj (ORCPT + 99 others); Wed, 2 Oct 2019 15:11:39 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:35614 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729215AbfJBTIM (ORCPT ); Wed, 2 Oct 2019 15:08:12 -0400 Received: from [192.168.4.242] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1iFjyr-00035n-4r; Wed, 02 Oct 2019 20:08:09 +0100 Received: from ben by deadeye with local (Exim 4.92.1) (envelope-from ) id 1iFjyo-0003dT-BC; Wed, 02 Oct 2019 20:08:06 +0100 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, Denis Kirjanov , "Robert Hancock" , "Guenter Roeck" Date: Wed, 02 Oct 2019 20:06:51 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) X-Patchwork-Hint: ignore Subject: [PATCH 3.16 45/87] hwmon: (pmbus/core) Treat parameters as paged if on multiple pages In-Reply-To: X-SA-Exim-Connect-IP: 192.168.4.242 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.75-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Robert Hancock commit 4a60570dce658e3f8885bbcf852430b99f65aca5 upstream. Some chips have attributes which exist on more than one page but the attribute is not presently marked as paged. This causes the attributes to be generated with the same label, which makes it impossible for userspace to tell them apart. Marking all such attributes as paged would result in the page suffix being added regardless of whether they were present on more than one page or not, which might break existing setups. Therefore, we add a second check which treats the attribute as paged, even if not marked as such, if it is present on multiple pages. Fixes: b4ce237b7f7d ("hwmon: (pmbus) Introduce infrastructure to detect sensors and limit registers") Signed-off-by: Robert Hancock Signed-off-by: Guenter Roeck Signed-off-by: Ben Hutchings --- drivers/hwmon/pmbus/pmbus_core.c | 34 ++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) --- a/drivers/hwmon/pmbus/pmbus_core.c +++ b/drivers/hwmon/pmbus/pmbus_core.c @@ -987,14 +987,15 @@ static int pmbus_add_sensor_attrs_one(st const struct pmbus_driver_info *info, const char *name, int index, int page, - const struct pmbus_sensor_attr *attr) + const struct pmbus_sensor_attr *attr, + bool paged) { struct pmbus_sensor *base; int ret; if (attr->label) { ret = pmbus_add_label(data, name, index, attr->label, - attr->paged ? page + 1 : 0); + paged ? page + 1 : 0); if (ret) return ret; } @@ -1026,6 +1027,30 @@ static int pmbus_add_sensor_attrs_one(st return 0; } +static bool pmbus_sensor_is_paged(const struct pmbus_driver_info *info, + const struct pmbus_sensor_attr *attr) +{ + int p; + + if (attr->paged) + return true; + + /* + * Some attributes may be present on more than one page despite + * not being marked with the paged attribute. If that is the case, + * then treat the sensor as being paged and add the page suffix to the + * attribute name. + * We don't just add the paged attribute to all such attributes, in + * order to maintain the un-suffixed labels in the case where the + * attribute is only on page 0. + */ + for (p = 1; p < info->pages; p++) { + if (info->func[p] & attr->func) + return true; + } + return false; +} + static int pmbus_add_sensor_attrs(struct i2c_client *client, struct pmbus_data *data, const char *name, @@ -1039,14 +1064,15 @@ static int pmbus_add_sensor_attrs(struct index = 1; for (i = 0; i < nattrs; i++) { int page, pages; + bool paged = pmbus_sensor_is_paged(info, attrs); - pages = attrs->paged ? info->pages : 1; + pages = paged ? info->pages : 1; for (page = 0; page < pages; page++) { if (!(info->func[page] & attrs->func)) continue; ret = pmbus_add_sensor_attrs_one(client, data, info, name, index, page, - attrs); + attrs, paged); if (ret) return ret; index++;