Received: by 10.213.65.68 with SMTP id h4csp36285imn; Mon, 19 Mar 2018 18:43:26 -0700 (PDT) X-Google-Smtp-Source: AG47ELtSKHd8racUbXeFYdBWTawWcn/H8M7e01PNizfR/pTd6ikEFI2QYRv3iIWGWQhFr8a/ut/4 X-Received: by 2002:a17:902:768b:: with SMTP id m11-v6mr14842639pll.185.1521510206444; Mon, 19 Mar 2018 18:43:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521510206; cv=none; d=google.com; s=arc-20160816; b=ucgvlZIX7n2SKgTLNHZEejZD9is0Qi+M8TuOsB1STou16w/hg/YcY7+zDMO/AJ6qxx tNIc6kbo/LGRk+nj3V9td0a3I7CJgDCDU7eUWglW5H0XEmSGTwVrSMugKYftiZjdEP10 Kx8mGv5FdbMdeEYGA+2zKFppnViz25NwstSfILqi+NjW9PsJGBLDtxzUbPYsVQiBLHQX klBcEaBYayYgW8QzkMwh+EMMRkQ6i4cUTVWoy/GucEA7B6MKIc1cI1BNK4ug1EazkZiO 3M1AWzf7W8XGbhIZDuFolrmSbjOpxDZmwtyWcPY0M9DW5kVyHXQhqz7EJHae0bL9Dq8y v1kg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=hkJYD2E4w5zlVabyK7i+c8iMDN0PqprK7d+5CsorcIM=; b=bTo50TcmFqxTd4DCmmik4U872xNzO0Qdl1lT+tyxOwD+C+4/8BdxZ0/TxH2i135M3w DnN6ZRNGiMuy+ZIT67M7n4sREQGji+GoY4a8v+RDmN+36+yajoXJAbX2dufq+8HG/gZR eaIR0Sf8o2ThkROR4w60Zhyofv553gztKLIvtnft2Vkb/jwsh6CACFruKsK4tlKQy0Q7 9eMHmjHt7A3ViX/76w76/FOZkAPVhTxDH+nVgeoa/x/jKy6RkI49ICJkgQaFBdPCKLDK vSc6/0ER/MY/VGmyMcJHnPTPabYk5kevJIRKt8HHjPoAABMbpPQkGsb60BFtaMpcNat7 MI0A== 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 y20-v6si514486pll.287.2018.03.19.18.43.12; Mon, 19 Mar 2018 18:43:26 -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 S1031130AbeCSSVa (ORCPT + 99 others); Mon, 19 Mar 2018 14:21:30 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:48076 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1031100AbeCSSVZ (ORCPT ); Mon, 19 Mar 2018 14:21:25 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id D29F91258; Mon, 19 Mar 2018 18:21:24 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Matthias Kaehlcke , Javier Martinez Canillas , Mark Brown , Sasha Levin Subject: [PATCH 4.9 080/241] regulator: core: Limit propagation of parent voltage count and list Date: Mon, 19 Mar 2018 19:05:45 +0100 Message-Id: <20180319180754.520172717@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180319180751.172155436@linuxfoundation.org> References: <20180319180751.172155436@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ 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 Signed-off-by: Greg Kroah-Hartman --- drivers/regulator/core.c | 9 +++++++-- include/linux/regulator/driver.h | 2 ++ 2 files changed, 9 insertions(+), 2 deletions(-) --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -2465,7 +2465,7 @@ static int _regulator_list_voltage(struc ret = ops->list_voltage(rdev, selector); if (lock) mutex_unlock(&rdev->mutex); - } else if (rdev->supply) { + } else if (rdev->is_switch && rdev->supply) { ret = _regulator_list_voltage(rdev->supply, selector, lock); } else { return -EINVAL; @@ -2523,7 +2523,7 @@ int regulator_count_voltages(struct regu if (rdev->desc->n_voltages) return rdev->desc->n_voltages; - if (!rdev->supply) + if (!rdev->is_switch || !rdev->supply) return -EINVAL; return regulator_count_voltages(rdev->supply); @@ -4049,6 +4049,11 @@ regulator_register(const struct regulato mutex_unlock(®ulator_list_mutex); } + if (!rdev->desc->ops->get_voltage && + !rdev->desc->ops->list_voltage && + !rdev->desc->fixed_uV) + rdev->is_switch = true; + ret = device_register(&rdev->dev); if (ret != 0) { put_device(&rdev->dev); --- 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; + unsigned int is_switch:1; + /* time when this regulator was disabled last time */ unsigned long last_off_jiffy; };