Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp2858378rdb; Sat, 9 Dec 2023 01:50:00 -0800 (PST) X-Google-Smtp-Source: AGHT+IGZqw/JXlRjwfHLANQvxdUt09AJwCNhW5fbtKFYxKDpeIvCzj123HCy40uhKOA7hB6+/oCo X-Received: by 2002:a05:6358:9986:b0:170:b02a:d38d with SMTP id j6-20020a056358998600b00170b02ad38dmr1465646rwb.0.1702115400205; Sat, 09 Dec 2023 01:50:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702115400; cv=none; d=google.com; s=arc-20160816; b=eKD+ywWM7a6YWxGGwTrlEeBlj3BwDAGY2sq8ytU778btUMtVv3M7qlwfEK2xwI7eS5 YI6aeapKCzDBI5x4lswWE9IxtugugF8O2GQTzn6Ie3EWSOTYzgm90UWq990y18k0SWPD LYq0AsuGzy2+HtO9b5pqQnyjkE3kKhZVouQAMJuPGdYE88ndINjvlIXHX0hZdzMa5a7G TbOlifaJaLEEbiP+w2kO2mXHjLaAxzPjeQOOB/hOW+HylBr+hw1yS6YibN6duEGeM6N7 JOR0nHKwEPJuZrsBpO4DKo2jIFrKw8+a1ebtI79DWuWPJ8N4QFNXkTDuJOdmjbuXrBrr jsTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=/nCs/ybWwnv1qC7cS76lqV61trjmJwjLOlcyvG7SAdk=; fh=XPSD4wa3WwOkmKsyr/hOy3ZmgtVel6vJDLo1J46PyDQ=; b=0T38Se/d6cNXBEkquHxO9LPc8w1KYRsEzkND4XcK/AYL/8DpIGfZ6uWcmtjxEGIxCd YbbfKBlkoXHMqCu9z2/isF8n46L1jiM66Bi1SAYjM33Q9C7XlkPnu7rr05k97WtE/raB 2cB7y2icgvWsfYF/T1tMEksgI3MXBoQy7SLKYPkkuc5M2TpeZFJtU5o5ksvnduVhGOSs aAxDlbAUMdOLTeCDc5pN8CJKxRagmxbF/R3ez8+f1GhTm5cpbqqfREA6EQO9v/t4UL1c 2oQJMrPilXJ3r5xhTak0xrEeHE8RQF13PM76B17LqseaxwDO/x4rKqOJIqSRHZeB0Lyy l5fw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mess.org header.s=2020 header.b=I1ET6nwY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mess.org Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id h16-20020a170902ac9000b001cfc419e609si2921292plr.67.2023.12.09.01.49.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Dec 2023 01:50:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@mess.org header.s=2020 header.b=I1ET6nwY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mess.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id BCB1E80658D9; Sat, 9 Dec 2023 01:49:58 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229487AbjLIJts (ORCPT + 99 others); Sat, 9 Dec 2023 04:49:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229446AbjLIJtr (ORCPT ); Sat, 9 Dec 2023 04:49:47 -0500 Received: from gofer.mess.org (gofer.mess.org [88.97.38.141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E38B810C4; Sat, 9 Dec 2023 01:49:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mess.org; s=2020; t=1702115391; bh=K4v35Dp8Lp3NPnkhtZ9R6FJpo7oiN2Hzlx29IfU2Lq0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=I1ET6nwYmIPj1dDOlJ36cuv6adMCSee+/l3bvMCLtEZVJ3gsKIvTkgWpvUyf4/ydw CGstHQFag5r1HK6Ftg6STvHYYVV2iTxngtTBcs5UDam5c9d53JE4Z5TzmbLJ5pyyA3 mariSQplhWY+wSwgFCLalvfeRztZooSqtT2s5r0altoeoNl8tTgXkQ09atOVR7mLsm nZYM0UNi0mHCJ4iNfZBqMg0bpb67Qn22K0ZJJ4W09VbwU3fDZid9ynlvX2K6rPGB8A 5yqzXwpbcGepDvmlvCc/F1FCV6G/xfzG8oGHxmesi7f6GKT4sekIMzJjC2kufb4kXw dCEcayhOICYsg== Received: by gofer.mess.org (Postfix, from userid 1000) id 9697B100091; Sat, 9 Dec 2023 09:49:51 +0000 (GMT) Date: Sat, 9 Dec 2023 09:49:51 +0000 From: Sean Young To: Thierry Reding Cc: linux-media@vger.kernel.org, linux-pwm@vger.kernel.org, Ivaylo Dimitrov , Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= , Jonathan Corbet , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v6 2/4] pwm: make it possible to apply pwm changes in atomic context Message-ID: References: <734c9985a6f54d34d9ef20203ba7f962b572cb45.1701248996.git.sean@mess.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Sat, 09 Dec 2023 01:49:59 -0800 (PST) Hi Thierry, On Fri, Dec 08, 2023 at 05:19:52PM +0100, Thierry Reding wrote: > On Wed, Nov 29, 2023 at 09:13:35AM +0000, Sean Young wrote: > > Some pwm devices require sleeping, for example if the pwm device is > > connected over i2c. However, many pwm devices could be used from atomic > > context, e.g. memmory mapped pwm. This is useful for, for example, the > > pwm-ir-tx driver which requires precise timing. Sleeping causes havoc > > with the generated IR signal. > > > > Since not all pmw devices can support atomic context, we also add a > > pwm_is_atomic() function to check if it is supported. > > s/i2c/I2C/ and s/pwm/PWM/ in the above. Also, s/memmory/memory/ Thanks for your detailed review. I agree with all your points, they are all nice improvements. Just a question at the bottom: > > > > > Signed-off-by: Sean Young > > --- > > Documentation/driver-api/pwm.rst | 9 +++++ > > drivers/pwm/core.c | 63 ++++++++++++++++++++++++++------ > > drivers/pwm/pwm-renesas-tpu.c | 1 - > > include/linux/pwm.h | 29 ++++++++++++++- > > 4 files changed, 87 insertions(+), 15 deletions(-) > > > > diff --git a/Documentation/driver-api/pwm.rst b/Documentation/driver-api/pwm.rst > > index f1d8197c8c43..1d4536fdf47c 100644 > > --- a/Documentation/driver-api/pwm.rst > > +++ b/Documentation/driver-api/pwm.rst > > @@ -43,6 +43,15 @@ After being requested, a PWM has to be configured using:: > > > > int pwm_apply_might_sleep(struct pwm_device *pwm, struct pwm_state *state); > > > > +Some PWM devices can be used from atomic context. You can check if this is > > +supported with:: > > + > > + bool pwm_is_atomic(struct pwm_device *pwm); > > This is now going to look a bit odd. I think it'd be best to change this > to pwm_might_sleep() for consistency with the pwm_apply_might_sleep() > function. Fine to keep the actual member variable as atomic, though, so > we don't have to change the default for all drivers. Agreed, I was struggling with finding good name and yours is much better, thanks. > +{ > > + return pwm->chip->atomic; > > +} > > + > > /* PWM provider APIs */ > > int pwm_capture(struct pwm_device *pwm, struct pwm_capture *result, > > unsigned long timeout); > > @@ -406,16 +420,27 @@ struct pwm_device *devm_fwnode_pwm_get(struct device *dev, > > struct fwnode_handle *fwnode, > > const char *con_id); > > #else > > +static inline bool pwm_is_atomic(struct pwm_device *pwm) > > +{ > > + return false; > > +} > > + > > static inline int pwm_apply_might_sleep(struct pwm_device *pwm, > > const struct pwm_state *state) > > { > > might_sleep(); > > - return -ENOTSUPP; > > + return -EOPNOTSUPP; > > +} > > + > > +static inline int pwm_apply_atomic(struct pwm_device *pwm, > > + const struct pwm_state *state) > > +{ > > + return -EOPNOTSUPP; > > } > > > > static inline int pwm_adjust_config(struct pwm_device *pwm) > > { > > - return -ENOTSUPP; > > + return -EOPNOTSUPP; > > } > > What's wrong with ENOTSUPP? This was found by checkpatch, see https://github.com/torvalds/linux/blob/master/scripts/checkpatch.pl#L4891-L4892 # ENOTSUPP is not a standard error code and should be avoided in new patches. # Folks usually mean EOPNOTSUPP (also called ENOTSUP), when they type ENOTSUPP. ENOTSUPP is not really widely used in the tree. So it was really done to keep checkpatch happy, please let me know what you would like me to do here. Thanks, Sean