Received: by 2002:ac0:a591:0:0:0:0:0 with SMTP id m17-v6csp697622imm; Thu, 5 Jul 2018 07:27:48 -0700 (PDT) X-Google-Smtp-Source: AAOMgpd34bvszMEREr39LrImT531Kceujbon2WV6GaRyQK1vU73F4tUqxyVwKUQTJJZ+Lu0C4TP+ X-Received: by 2002:a65:53cb:: with SMTP id z11-v6mr5807992pgr.218.1530800868845; Thu, 05 Jul 2018 07:27:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530800868; cv=none; d=google.com; s=arc-20160816; b=wY8J0bedDdpB4rhG9KxtufO+KpV4gYgq1fXmaK87zWG0qmY+xhfNuDwAewdsSYtFXv l4Zg1hXfP7wn2efJgA0wDr8Vt3OvSDFTkCDmvD72LrAMijoHXH7oL25I6fEekEGDBAQp sSJOItl2rPneN3GvcuuRB7ycGD2O4i4Ln1P+DOV/f5vSBRRqJ4IDi90Hpf69uiHV6H8+ fuKP6e8nKzthmolJ1jkutPHVfeKOprS7VNXCs6JUFtpSP6/imKdKgQoxrhY6MfnEKm4E DpCGjXNv6b7KODkmy9l1H0Kbtpw1p08zZDToZpU14WCLBLViyCFlgOl3sV1U9nHXIF6g MffA== 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 :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from :arc-authentication-results; bh=rpe3SAVTE2W5Z9enVpbX5nbm7qXXGw+TWZTnqiyLgtI=; b=PQsJfTimZtYAttSIvyINc1BQbgJNTkA1p1GE/mdH8k9+F1WmPoNm/oreyX5/Mc9pY9 EM1EeX+r+5VCFaERkRX2hrc/Y64Lu76kJFbzk925hssIYNPWu5T7SKi+XhpQF6mN42F2 d3hozG8a2ZwSUOlNdJ9MDwHJo7Hn+mRftdhQkrOZMJJw83jkM10dbrdUFhU7zO26gIAX YNfADBadAyjerJHvNNdfVYlGBiT8z7DfzkLvdyu3gz8Fk9Sj1KKXDav1GqPm73Nin7Xv HEHtzNYGRmZV8yLdJRu7imX3fW5idNhJMOTinG9hNf7U5UxQ8xvlpt3YkYtoGXBmoI1I cKYw== 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 s14-v6si5789038pgn.76.2018.07.05.07.27.34; Thu, 05 Jul 2018 07:27:48 -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 S1754221AbeGEO0M convert rfc822-to-8bit (ORCPT + 99 others); Thu, 5 Jul 2018 10:26:12 -0400 Received: from mx07-00178001.pphosted.com ([62.209.51.94]:9242 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753911AbeGEO0G (ORCPT ); Thu, 5 Jul 2018 10:26:06 -0400 Received: from pps.filterd (m0046668.ppops.net [127.0.0.1]) by mx07-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id w65EOMtV020108; Thu, 5 Jul 2018 16:25:57 +0200 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 2k1k1j0mf2-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 05 Jul 2018 16:25:57 +0200 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 41CB731; Thu, 5 Jul 2018 14:25:57 +0000 (GMT) Received: from Webmail-eu.st.com (sfhdag6node1.st.com [10.75.127.16]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id F3F752064; Thu, 5 Jul 2018 14:25:56 +0000 (GMT) Received: from SFHDAG6NODE2.st.com (10.75.127.17) by SFHDAG6NODE1.st.com (10.75.127.16) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Thu, 5 Jul 2018 16:25:56 +0200 Received: from SFHDAG6NODE2.st.com ([fe80::a56f:c186:bab7:13d6]) by SFHDAG6NODE2.st.com ([fe80::a56f:c186:bab7:13d6%20]) with mapi id 15.00.1347.000; Thu, 5 Jul 2018 16:25:56 +0200 From: Pascal PAILLET-LME To: "gregkh@linuxfoundation.org" , "lgirdwood@gmail.com" , "broonie@kernel.org" , "linux-kernel@vger.kernel.org" , "benjamin.gaignard@linaro.org" CC: Pascal PAILLET-LME Subject: [PATCH 2/3] regulator: core: Link consumer with regulator driver Thread-Topic: [PATCH 2/3] regulator: core: Link consumer with regulator driver Thread-Index: AQHUFGwWwlUWfYmgkkeEISLF07NUuw== Date: Thu, 5 Jul 2018 14:25:56 +0000 Message-ID: <1530800748-7300-3-git-send-email-p.paillet@st.com> References: <1530800748-7300-1-git-send-email-p.paillet@st.com> In-Reply-To: <1530800748-7300-1-git-send-email-p.paillet@st.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-messagesentrepresentingtype: 1 x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.75.127.51] Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-07-05_04:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: pascal paillet Add a device link between the consumer and the driver so that the consumer is not suspended before the driver. The goal is to avoid implementing suspend_late ops in regulator drivers. Signed-off-by: pascal paillet --- drivers/regulator/core.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 6ed568b..607ec47 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -1740,6 +1740,8 @@ struct regulator *_regulator_get(struct device *dev, const char *id, rdev->use_count = 0; } + device_link_add(dev, &rdev->dev, DL_FLAG_STATELESS); + return regulator; } @@ -1829,9 +1831,21 @@ static void _regulator_put(struct regulator *regulator) debugfs_remove_recursive(regulator->debugfs); - /* remove any sysfs entries */ - if (regulator->dev) + if (regulator->dev) { + int count = 0; + struct regulator *r; + + list_for_each_entry(r, &rdev->consumer_list, list) + if (r->dev == regulator->dev) + count++; + + if (count == 1) + device_link_remove(regulator->dev, &rdev->dev); + + /* remove any sysfs entries */ sysfs_remove_link(&rdev->dev.kobj, regulator->supply_name); + } + regulator_lock(rdev); list_del(®ulator->list); -- 1.9.1