Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2724511imj; Mon, 18 Feb 2019 10:59:59 -0800 (PST) X-Google-Smtp-Source: AHgI3IZx3BP+wcNQRlxTPONPdJodZGfhZR4u+YEXwqYk6EQBN/Qn3i6vbCzrk/75yacwzmK3j28J X-Received: by 2002:a65:5c41:: with SMTP id v1mr473033pgr.404.1550516399104; Mon, 18 Feb 2019 10:59:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550516399; cv=none; d=google.com; s=arc-20160816; b=C33NU//qB2rxpA3pXrCHqJdo0194MKncdQbSh332fpKh3ikAdeEJw/3hPS6RUVbqci 4sD3DB08g+15vgZ4ugWwqWJfdCnpAJp8YnJZmv6zVLHT+jJ0BOswrGqCEPuz9RcZ6DLG vwKQ8RtYseJs4hLLEygH3yOqhVc6ynBmYjW6e+Ybu5MXmigvaBRVHGz3yiCeRNwtqvHM YntdXgFzCKdJIliJclcCMe3I5ZgJJpvuGrazsXQ8jdFUpUmenG8kMLZjRfiVH0cYyNLf 0sxvhUYbeIjSVBloiEdKRw8us4ZXt8O+WLc3qqtoOe4R5EjHHvunpo9+aBpvqu8Pvo0W O82A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=m8X2t5FeKTLC364CPMlf/wibV5GCagdcFXG9FSOIrFo=; b=M45nZB+Q44rYGFUiOxn6AppKJd7kBwAVcrpZYsEN5pKykpC8vX4pWUkkAmexdCtyzp leCd0r22nmKl9UURuwivETVnTGhZ226w1FmoJxYIUmdJdZquWjNveOqBgJS+VCa1xIx0 jNiW2CR1NADvqsZDemsg6zWntH2CgrgV9V+NuKTpMVUljzWF4dPXvaHabS0+qisdvlY5 pvW0Vo/4SoD64EVh5OJ5fQRpOmVM8xTH2KMMUaf+sptmp7kf3G0vAbouGYIpqPUAR5bj DNTh9+sWCABsHneU7bVbzRBksm3ni8mVZ9tClhPRSSN8khDx2hnqWHU9qxcP1l2gMQ6n 9qNQ== 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 e40si14846973plb.234.2019.02.18.10.59.43; Mon, 18 Feb 2019 10:59:59 -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 S2388824AbfBRRWe (ORCPT + 99 others); Mon, 18 Feb 2019 12:22:34 -0500 Received: from metis.ext.pengutronix.de ([85.220.165.71]:37557 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728216AbfBRRWd (ORCPT ); Mon, 18 Feb 2019 12:22:33 -0500 Received: from pty.hi.pengutronix.de ([2001:67c:670:100:1d::c5]) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gvmcb-0003be-R1; Mon, 18 Feb 2019 18:22:25 +0100 Received: from ukl by pty.hi.pengutronix.de with local (Exim 4.89) (envelope-from ) id 1gvmcZ-0007Xr-PP; Mon, 18 Feb 2019 18:22:23 +0100 Date: Mon, 18 Feb 2019 18:22:23 +0100 From: Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= To: Fabrice Gasnier Cc: thierry.reding@gmail.com, robh+dt@kernel.org, tduszyns@gmail.com, mark.rutland@arm.com, alexandre.torgue@st.com, mcoquelin.stm32@gmail.com, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-pwm@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com Subject: Re: [PATCH v4 3/3] pwm: core: add consumer device link Message-ID: <20190218172223.lw3e5tn5hzsow6tg@pengutronix.de> References: <1550139951-25788-1-git-send-email-fabrice.gasnier@st.com> <1550139951-25788-4-git-send-email-fabrice.gasnier@st.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1550139951-25788-4-git-send-email-fabrice.gasnier@st.com> User-Agent: NeoMutt/20170113 (1.7.2) X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c5 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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, ...) ? > + return NULL; > + } > + > + dl = device_link_add(dev, pwm->chip->dev, DL_FLAG_AUTOREMOVE_CONSUMER); > + if (!dl) { > + dev_err(dev, "failed to create device link to %s\n", > + dev_name(pwm->chip->dev)); > + return ERR_PTR(-EINVAL); broken indention. > + } > + > + return dl; > +} > + Best regards Uwe -- Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |