Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp3567705imj; Tue, 12 Feb 2019 00:32:25 -0800 (PST) X-Google-Smtp-Source: AHgI3IYqStZdrEt4wACcC1bBMg6cNBqjLSC2zuls7OXHl3XPff5y+rACb0jmJFlbvxTgVDidDjc0 X-Received: by 2002:a17:902:8212:: with SMTP id x18mr123040pln.217.1549960345302; Tue, 12 Feb 2019 00:32:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549960345; cv=none; d=google.com; s=arc-20160816; b=qZNma51cSFdoG4XCJypP2CQ1RY17x0FfpLFIXkvcmmmRL7ba669prnMH8IrXAxp33/ ardKYY0Z2dqrZPEL0Lo/o62V2sN6aBSMNTrGtJbwajA5y6SxdM/4tccY18E7RSrkglDF tP8yjhlUd77PgUXfO3QBu4VsqAd5JughOORQ0RT3jBtwEy+iP7+t10KGN1YEfKwFZZdn dRy9+ZKihTABweL3SuNiiheavA91Uhnrrl8y3uCSXRvOUiYvgrqyR72HW+vqyJbDeEkY HL/0bViQBWCHGXS/F/IDHBUEMTYLiMSK2td6vINDytno60hS7ZAB6xMBKGnuVzjJ820K AVxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=5rN7QVtGjs0csZMjEni0I5zlZFjhnfDLoNqsCWiqZgM=; b=KtILpHrc2/MjbxpXXhq84KxKWw3l7qWV3gG5RyaBOmHFadL6h2r5HJkaebXlB6NRAC kmyIZYOZiqmCj+Bsp6V68yOBCRasbe7TkZqEw3ssaMBL4EAMNt7NDDAfqO1FN5S1nGmB ZUIbK9wCNddQ69UGieiUHeQQpQ8LhXxhNo8j/z2abm12aMigeJOp7QtARLs0Hm0aQd5n D0x5+sffsVXPFQe4udSwSN1AcGh9QOU+sYFA+wr/eR2IzyPJryfcb6tBFIgVj24CStsc /R5AyadNma9b9dCL2NZ3gDQlaTKjtExlzPuh164oYV2SZBabYzCTZWPXj2WkpSh6ixpq TDcA== 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 v16si1233764plo.182.2019.02.12.00.32.09; Tue, 12 Feb 2019 00:32:25 -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; 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 S1728497AbfBLIb5 (ORCPT + 99 others); Tue, 12 Feb 2019 03:31:57 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:52277 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728209AbfBLIb5 (ORCPT ); Tue, 12 Feb 2019 03:31:57 -0500 Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx08-00178001.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x1C8VOwd016393; Tue, 12 Feb 2019 09:31:40 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-00178001.pphosted.com with ESMTP id 2qjfy63dwg-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Tue, 12 Feb 2019 09:31:40 +0100 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 CAFFE38; Tue, 12 Feb 2019 08:31:38 +0000 (GMT) Received: from Webmail-eu.st.com (sfhdag5node3.st.com [10.75.127.15]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 8468A2449; Tue, 12 Feb 2019 08:31:38 +0000 (GMT) Received: from [10.48.0.167] (10.75.127.47) by SFHDAG5NODE3.st.com (10.75.127.15) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Tue, 12 Feb 2019 09:31:37 +0100 Subject: Re: [PATCH v2 3/3] pwm: core: add consumer device link To: =?UTF-8?Q?Uwe_Kleine-K=c3=b6nig?= CC: , , , , , , , , , , References: <1549901522-15071-1-git-send-email-fabrice.gasnier@st.com> <1549901522-15071-4-git-send-email-fabrice.gasnier@st.com> <20190211190628.eisyi6wjus4ltrrn@pengutronix.de> From: Fabrice Gasnier Message-ID: Date: Tue, 12 Feb 2019 09:31:37 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: <20190211190628.eisyi6wjus4ltrrn@pengutronix.de> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 8bit X-Originating-IP: [10.75.127.47] X-ClientProxiedBy: SFHDAG7NODE1.st.com (10.75.127.19) To SFHDAG5NODE3.st.com (10.75.127.15) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-02-12_06:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2/11/19 8:06 PM, Uwe Kleine-König wrote: > Hello Fabrice, > > On Mon, Feb 11, 2019 at 05:12:02PM +0100, Fabrice Gasnier wrote: >> Add a device link between the PWM consumer and the PWM provider. This >> enforces the PWM user to get suspended before the PWM provider. It >> allows proper synchronization of suspend/resume sequences: the PWM user >> is responsible for properly stopping PWM, before the provider gets >> suspended: see [1]. Add the device link in: >> - pwm_get() >> - devm_pwm_get() >> - devm_of_pwm_get() >> as it requires a reference to the device for the PWM consumer. >> >> [1] https://lkml.org/lkml/2019/2/5/770 >> >> Suggested-by: Thierry Reding >> Signed-off-by: Fabrice Gasnier >> --- >> drivers/pwm/core.c | 13 +++++++++++-- >> 1 file changed, 11 insertions(+), 2 deletions(-) >> >> diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c >> index 1581f6a..2835e27 100644 >> --- a/drivers/pwm/core.c >> +++ b/drivers/pwm/core.c >> @@ -770,8 +770,13 @@ struct pwm_device *pwm_get(struct device *dev, const char *con_id) >> int err; >> >> /* look up via DT first */ >> - if (IS_ENABLED(CONFIG_OF) && dev && dev->of_node) >> - return of_pwm_get(dev->of_node, con_id); >> + if (IS_ENABLED(CONFIG_OF) && dev && dev->of_node) { >> + pwm = of_pwm_get(dev->of_node, con_id); >> + if (!IS_ERR(pwm)) >> + device_link_add(dev, pwm->chip->dev, >> + DL_FLAG_AUTOREMOVE_CONSUMER); >> + return pwm; >> + } >> >> /* >> * We look up the provider in the static table typically provided by >> @@ -851,6 +856,8 @@ struct pwm_device *pwm_get(struct device *dev, const char *con_id) >> pwm->args.period = chosen->period; >> pwm->args.polarity = chosen->polarity; >> >> + device_link_add(dev, pwm->chip->dev, DL_FLAG_AUTOREMOVE_CONSUMER); >> + >> return pwm; >> } >> EXPORT_SYMBOL_GPL(pwm_get); >> @@ -943,6 +950,8 @@ struct pwm_device *devm_of_pwm_get(struct device *dev, struct device_node *np, >> if (!IS_ERR(pwm)) { >> *ptr = pwm; >> devres_add(dev, ptr); >> + device_link_add(dev, pwm->chip->dev, >> + DL_FLAG_AUTOREMOVE_CONSUMER); > > IMHO it's surprising that devm_of_pwm_get() does more than of_pwm_get() > + devres stuff. I'd put device_link_add() into of_pwm_get(). Hi Uwe, I also agree with this. But I think this implies modifying the API for of_pwm_get(): /** * of_pwm_get() - request a PWM via the PWM framework + * @dev: device for PWM consumer * @np: device node to get the PWM from * @con_id: consumer name It seems there aren't much of_pwm_get() users currently. Does this look sensible ? Best regards, Fabrice > > Best regards > Uwe >