Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp3354163imj; Tue, 19 Feb 2019 01:55:23 -0800 (PST) X-Google-Smtp-Source: AHgI3Ib0r/p+Koql+ErcH4Kfr+dl+XBIWqaw9bWhek9UED1pfPko2BwBcdLmQgwc86xi5+I8XF9y X-Received: by 2002:aa7:85cc:: with SMTP id z12mr28847367pfn.196.1550570123138; Tue, 19 Feb 2019 01:55:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550570123; cv=none; d=google.com; s=arc-20160816; b=BXe7dSAunXwryN7dUSa29qhUK1o3ydc0jM4JMLYHG1E1TxW8pH7ISVYQfbFSpf3gHX pN4YNajk6NgMrU7lJhc/7WO3P7U432DPd7wYFu73eNhO1lu6FOSbl3ZYlJv6+d9qIcqK iL1EwaJGXcwQkB1i5JHhogTVjyBwYejmIl9Xe3aq4BMFZjTNyDuK4XwRqZxKuXbumjHH J8UIkfkEnlKP5UDpFJ9aoZ/kAmsYMTYoVSabVSccL8ISQXk0ria3g+y06v+hUIV4z7/1 CNr+ELsgQNO0/3VUzsSh0qXW8gBkV4n2SQhbcYFBNeDgV1JIvBoGQxbUP1+7AyWztbNJ n5Zw== 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=mI+zwZQoGzq+IUSq7/5UnqlQGyNGHnKt+ODATQCunNU=; b=rkU492C90DRZ9w6XHcTy0Im+PwKOmzq06fp7bHF05BpUpolXM3l4rOUr/sFAvwuhlW 1asXC6IrgOqG0p4sOUzIwrdEinHV+UnqbW10FOF7nZhqQg5EB2QFy4Q/7nD3e6qnv+2B yvOvGMlSuScTZMzfN03JInd08S1yyaLYFSvD8+mP9qGjJL4SBTtbFmCIw9DpXLP70OHz Eo19mmNYDwWMX9QcpLTng+qyrVSD6yYDKWk8vqrvtVSpNUutoWucfcZ9cvVCBSCKtz1z GUBk6A38B1EXjl93C/WGaO0e4jyaz1602P+cstCyQU48VN6bEulRIxZ910T96eI4Kv3Q BqCg== 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 n1si4928240pgv.545.2019.02.19.01.55.07; Tue, 19 Feb 2019 01:55:23 -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 S1727023AbfBSJyj (ORCPT + 99 others); Tue, 19 Feb 2019 04:54:39 -0500 Received: from mx07-00178001.pphosted.com ([62.209.51.94]:17718 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725763AbfBSJyj (ORCPT ); Tue, 19 Feb 2019 04:54:39 -0500 Received: from pps.filterd (m0046668.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x1J9pPpe027674; Tue, 19 Feb 2019 10:54:22 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 2qr6x5jjsk-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Tue, 19 Feb 2019 10:54:22 +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 B2EAA34; Tue, 19 Feb 2019 09:54:21 +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 6AF822750; Tue, 19 Feb 2019 09:54:21 +0000 (GMT) Received: from [10.48.0.167] (10.75.127.51) by SFHDAG5NODE3.st.com (10.75.127.15) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Tue, 19 Feb 2019 10:54:20 +0100 Subject: Re: [PATCH v4 3/3] pwm: core: add consumer device link To: =?UTF-8?Q?Uwe_Kleine-K=c3=b6nig?= CC: , , , , , , , , , , References: <1550139951-25788-1-git-send-email-fabrice.gasnier@st.com> <1550139951-25788-4-git-send-email-fabrice.gasnier@st.com> <20190218172223.lw3e5tn5hzsow6tg@pengutronix.de> <53bc3d80-8732-46be-caef-015998c9ad0e@st.com> <20190219085516.dz5ux37kdszqkisy@pengutronix.de> From: Fabrice Gasnier Message-ID: Date: Tue, 19 Feb 2019 10:54:20 +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: <20190219085516.dz5ux37kdszqkisy@pengutronix.de> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 8bit X-Originating-IP: [10.75.127.51] X-ClientProxiedBy: SFHDAG7NODE2.st.com (10.75.127.20) To SFHDAG5NODE3.st.com (10.75.127.15) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-02-19_06:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2/19/19 9:55 AM, Uwe Kleine-König wrote: > On Tue, Feb 19, 2019 at 09:46:32AM +0100, Fabrice Gasnier wrote: >> On 2/18/19 6:22 PM, Uwe Kleine-König wrote: >>> Hello, >>> >>> On Thu, Feb 14, 2019 at 11:25:51AM +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: >>>> - of_pwm_get() >>>> - pwm_get() >>>> - devm_*pwm_get() variants >>>> 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 >>>> --- >>>> Changes in v4: >>>> - rework error handling following Thierry's comments >>>> - turn/split pr_debug() into dev_err()/pr_warn(). >>>> >>>> Changes in v3: >>>> - add struct device to of_get_pwm() arguments to handle device link from >>>> there as discussed with Uwe. >>>> --- >>>> drivers/pwm/core.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++--- >>>> include/linux/pwm.h | 6 ++++-- >>>> 2 files changed, 51 insertions(+), 5 deletions(-) >>>> >>>> diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c >>>> index 1581f6a..64e10a6 100644 >>>> --- a/drivers/pwm/core.c >>>> +++ b/drivers/pwm/core.c >>>> @@ -636,8 +636,35 @@ static struct pwm_chip *of_node_to_pwmchip(struct device_node *np) >>>> return ERR_PTR(-EPROBE_DEFER); >>>> } >>>> >>>> +static struct device_link *pwm_device_link_add(struct device *dev, >>>> + struct pwm_device *pwm) >>>> +{ >>>> + struct device_link *dl; >>>> + >>>> + if (!dev) { >>>> + /* >>>> + * No device for the PWM consumer has been provided. It may >>>> + * impact the PM sequence ordering: the PWM supplier may get >>>> + * suspended before the consumer. >>>> + */ >>>> + pr_warn("no consumer dev, can't create device link to %s\n", >>>> + dev_name(pwm->chip->dev)); >>> >>> Maybe use dev_warn(pwm->chip->dev, ...) ? >> >> Hi Uwe, >> >> I'm wondering a bit about this: In this case, the caller that doesn't >> provide a struct device *, PWM provider isn't responsible for that. So I >> just hope this wouldn't be miss-leading ? > > IMHO it's more the wording that might make the message misleading. If > you use > > dev_warn(pwm->chip->dev, "No consumer device specified to create a device link to\n"); > > that's completely fine in my eyes. Thanks for the suggestion, I'll update this as well in v5. Best regards, Fabrice > > Best regards > Uwe >