Received: by 10.223.185.116 with SMTP id b49csp1065933wrg; Sat, 3 Mar 2018 14:34:23 -0800 (PST) X-Google-Smtp-Source: AG47ELvQZqU+HTaR/hjTacpNwI4jIarPnaBdEnDo8zLxqk9ZjKsPAFbSYu1WuoJ/1cvSRKNG+hb8 X-Received: by 10.101.66.136 with SMTP id j8mr8296955pgp.409.1520116462967; Sat, 03 Mar 2018 14:34:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520116462; cv=none; d=google.com; s=arc-20160816; b=roJxpGO2oRzcOpLoYne2CrHzn27bFiG0f2a5ZG6i4+d97k9Qkkxa6IdrvoE/951bQo Ypdk+eALCGXxBaaMPQNNyJ+AgBoVwzk9mjMsNctvDv0gnIsLMTPb9sU8JBbly7DvJxh/ U6aYuUBKMsRiawPSNzYSagbyt7EqkZFtlPkhOLBLO9eaGMhXglLUaLDym+5jkkXDXHDs ssob8hVORKvMToxMVnMnChcHPkdfbibRGnAxvI52OjWcvqEIwx41SQO8DU1r6X6R8ALf wzoFSIQ+CV8ThfbhnJrs+2RMpReTkNX5nNUx/8zlYK4QsVUInpjMbf9roTqP6PRMlfjU 8hWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=2w1vf+vpl+MPSugWYY+wezKtUSCMugAvBA1QqC1DYL4=; b=QDUGs728fSJu77VSsAPwag4u5vlZeLLgjwXpUaOiQV9S0Dw7TBQ/nxCWNDm+DWMDFR yV+fJMkWtugJQfX4T+Ah8YEdkzgQGIYyzc9aImMu8rW8Oyz2o+IqqICvnxZboT4lVCgZ spreiiZFUwdObr31uGZvj850nOj52RhQvwYmoEUujXplfSZVjJUZRyAxEJYlbPYQzb2P qtw023L+T5c4d1HKSQnCH1NhWOc2dXlfjuIY09dBOrAp8uw+Tlnhm0U9VqixYGfIDe0K 7wzOK4TJlBzkUzNEt6dkfG0doui6mRVBG/MKsR550zC80PBrFsnqnTp0ygrOr6QaJPY3 QU1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=bMbIm61j; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b189si6070792pgc.798.2018.03.03.14.34.08; Sat, 03 Mar 2018 14:34:22 -0800 (PST) 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; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=bMbIm61j; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934009AbeCCWdP (ORCPT + 99 others); Sat, 3 Mar 2018 17:33:15 -0500 Received: from mail-by2nam01on0133.outbound.protection.outlook.com ([104.47.34.133]:49841 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933993AbeCCWdM (ORCPT ); Sat, 3 Mar 2018 17:33:12 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=2w1vf+vpl+MPSugWYY+wezKtUSCMugAvBA1QqC1DYL4=; b=bMbIm61j3DCRfHRSLpNtfjegYRVfo4ktA0RCOos/xvqXqOxAkkhunUJSBJkcE/lXJswp+eV0K1kPz9di69YDX5GeIhI5ce5O41TNsrVmLKjQuVKkD8E1/PJJV0rdkrQ2rX7/UtrlZt9SEd37ZmkUmjwogaHtudxCisrDC/mQJTs= Received: from MW2PR2101MB1034.namprd21.prod.outlook.com (52.132.149.10) by MW2PR2101MB1097.namprd21.prod.outlook.com (52.132.149.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.567.2; Sat, 3 Mar 2018 22:33:09 +0000 Received: from MW2PR2101MB1034.namprd21.prod.outlook.com ([fe80::1d56:338f:e2b:cec0]) by MW2PR2101MB1034.namprd21.prod.outlook.com ([fe80::1d56:338f:e2b:cec0%3]) with mapi id 15.20.0567.006; Sat, 3 Mar 2018 22:33:09 +0000 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: Matthias Kaehlcke , Mark Brown , Sasha Levin Subject: [PATCH AUTOSEL for 4.9 083/219] regulator: core: Limit propagation of parent voltage count and list Thread-Topic: [PATCH AUTOSEL for 4.9 083/219] regulator: core: Limit propagation of parent voltage count and list Thread-Index: AQHTsz79jFdFr0unw02mjbKZXcseNA== Date: Sat, 3 Mar 2018 22:28:44 +0000 Message-ID: <20180303222716.26640-83-alexander.levin@microsoft.com> References: <20180303222716.26640-1-alexander.levin@microsoft.com> In-Reply-To: <20180303222716.26640-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;MW2PR2101MB1097;7:l1M3OteA5IXFs06TtwEVvx90DG4bgjwTmDK+zd7hj4nqif7qFLGnuA5CjNGGtZZ7EYrCqqy6CQWDWitv8CRKO4E+cT2npKZvPZnfPLikQ4W8WsF01sFT7zgdMn1pRup9BAV6Y4/2MYT/N4BYD4N+t2r1vm3iskH/nDDW+1Y/wDBXPP5IcRXdURnGVKxfy8J7M1wk7FrqCUNMdTR+AbA6BeJSNdZu/zhULrKhZkyNIs2cMmAkaz6Yg0jhZ13WjyUb x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: d8714566-4405-4a85-612d-08d58156bdd7 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(48565401081)(5600026)(4604075)(3008032)(2017052603307)(7193020);SRVR:MW2PR2101MB1097; x-ms-traffictypediagnostic: MW2PR2101MB1097: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171)(7411616537696); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040501)(2401047)(5005006)(8121501046)(10201501046)(3002001)(3231220)(944501244)(52105095)(93006095)(93001095)(6055026)(61426038)(61427038)(6041288)(20161123560045)(20161123558120)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(6072148)(201708071742011);SRVR:MW2PR2101MB1097;BCL:0;PCL:0;RULEID:;SRVR:MW2PR2101MB1097; x-forefront-prvs: 0600F93FE1 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(376002)(366004)(39380400002)(396003)(39860400002)(346002)(189003)(199004)(305945005)(105586002)(36756003)(3660700001)(86362001)(6666003)(66066001)(2900100001)(5660300001)(8676002)(10090500001)(81166006)(81156014)(8936002)(22452003)(10290500003)(2950100002)(4326008)(25786009)(5250100002)(2501003)(68736007)(7736002)(72206003)(14454004)(478600001)(186003)(110136005)(26005)(316002)(2906002)(97736004)(6512007)(99286004)(107886003)(54906003)(1076002)(6506007)(106356001)(53936002)(59450400001)(6116002)(3846002)(102836004)(6486002)(86612001)(3280700002)(6436002)(76176011)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:MW2PR2101MB1097;H:MW2PR2101MB1034.namprd21.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: Ah8OWmNJkf1fu1UEdhHZi7rz465tejMBqRKLdmgc7qnBpLcdgkbkKUX6idodXGtqhDIBR2UhsslvW+qj7jj0O/MT8B90LDcKoCcVU++33grzz8tspLRcF1v7wGp+z3ARwh8smcS8hFf+R43cICLZjREo7POvtlWvNuSbnQoXeHc= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: d8714566-4405-4a85-612d-08d58156bdd7 X-MS-Exchange-CrossTenant-originalarrivaltime: 03 Mar 2018 22:28:44.0569 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW2PR2101MB1097 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Matthias Kaehlcke [ Upstream commit fd086045559d90cd7854818b4c60a7119eda6231 ] Commit 26988efe11b1 ("regulator: core: Allow to get voltage count and list from parent") introduces the propagation of the parent voltage count and list for regulators that don't provide this information themselves. The goal is to support simple switch regulators, however as a side effect normal continuous regulators can leak details of their supplies and provide consumers with inconsistent information. Limit the propagation of the voltage count and list to switch regulators. Fixes: 26988efe11b1 ("regulator: core: Allow to get voltage count and list from parent") Signed-off-by: Matthias Kaehlcke Reviewed-by: Javier Martinez Canillas Tested-by: Javier Martinez Canillas Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- drivers/regulator/core.c | 9 +++++++-- include/linux/regulator/driver.h | 2 ++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 9403245503de..178fcda12cec 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -2465,7 +2465,7 @@ static int _regulator_list_voltage(struct regulator *= regulator, ret =3D ops->list_voltage(rdev, selector); if (lock) mutex_unlock(&rdev->mutex); - } else if (rdev->supply) { + } else if (rdev->is_switch && rdev->supply) { ret =3D _regulator_list_voltage(rdev->supply, selector, lock); } else { return -EINVAL; @@ -2523,7 +2523,7 @@ int regulator_count_voltages(struct regulator *regula= tor) if (rdev->desc->n_voltages) return rdev->desc->n_voltages; =20 - if (!rdev->supply) + if (!rdev->is_switch || !rdev->supply) return -EINVAL; =20 return regulator_count_voltages(rdev->supply); @@ -4049,6 +4049,11 @@ regulator_register(const struct regulator_desc *regu= lator_desc, mutex_unlock(®ulator_list_mutex); } =20 + if (!rdev->desc->ops->get_voltage && + !rdev->desc->ops->list_voltage && + !rdev->desc->fixed_uV) + rdev->is_switch =3D true; + ret =3D device_register(&rdev->dev); if (ret !=3D 0) { put_device(&rdev->dev); diff --git a/include/linux/regulator/driver.h b/include/linux/regulator/dri= ver.h index 37b532410528..3c3786df044c 100644 --- a/include/linux/regulator/driver.h +++ b/include/linux/regulator/driver.h @@ -425,6 +425,8 @@ struct regulator_dev { struct regulator_enable_gpio *ena_pin; unsigned int ena_gpio_state:1; =20 + unsigned int is_switch:1; + /* time when this regulator was disabled last time */ unsigned long last_off_jiffy; }; --=20 2.14.1