Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1027419pxb; Tue, 8 Feb 2022 07:45:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJwJGVLLKYopMrqDExKo//WXSSG5XA7Cpusco3w024QAiBmdKtz6dZmy6Jv1Ox5prSgFAL8V X-Received: by 2002:a17:902:6844:: with SMTP id f4mr5031870pln.160.1644335131442; Tue, 08 Feb 2022 07:45:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644335131; cv=none; d=google.com; s=arc-20160816; b=dkEiI8BZAxCarxuHsaqgbfhvYzgF2GqdezqAsF+SKoaCxKUjHuviYsORXMrQjl388X t00wx1bdr9Fa7W0y4dAX0Wwqi4uYZcAMZ6rtySJKvQ916DK+A5yD4KWd+9YkwVjsqAuh olI1hjUJr6G25NloWQ9I5lSX+PFw4//Xz4pqMiMSpKqpglIPU7ceHCjIGTCS4pdFnD/2 mSAkL+1xVneTVwB+bJhYI/L71Sb6g5ORnuqmBHNlfOi7aMlMqUl7eMHQqE8qgtYnC2Uu mfmSCEgp5/sN+Ofaw3wRRayQZ9TwHbQnyvm2o4uxYBQreTGgN+ga/AZWNi+hXJ1zYNyI y0/A== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=divf7bdZ2w3aj6AzQrbOPEVYJoXmOeRN9tS3ctAaiOs=; b=jeZrRwF0q0gzPm+8ZThX1L97umeTBvTsZ/+Q/QtUoZ/c6C6qRa3BwJLjoweDD3Tp4x XoDQkeODXUwritJV8IM02W/nk9aeWtgr2H+AAXOuQbFUA0XJuRl0mGxz+sKR1qFvMlx4 sLhrFguUhLdFtK8l2pH/1DzAr7skg5PQ1nPnYkfIqvac8RaDV32Ue6reyAW8UhbwjZt1 eWrhILlZg+ARNPT3vsMWEgXaZHuyKXXCPTTVb8V4iha/Mfh0WXfWH6J1KofouNXytWmx r50b25onl4COunKJzIO/BCoaA1Po1iDeA+OHWTNrYSM57fMOcTg/URrTCG6kXh3ACyD/ 3P5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jiP1EPaq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u190si627527pgd.391.2022.02.08.07.45.18; Tue, 08 Feb 2022 07:45:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jiP1EPaq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1358169AbiBHLZL (ORCPT + 99 others); Tue, 8 Feb 2022 06:25:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50724 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356063AbiBHKHK (ORCPT ); Tue, 8 Feb 2022 05:07:10 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8FC26C03FEC0; Tue, 8 Feb 2022 02:07:09 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 51E25B81802; Tue, 8 Feb 2022 10:07:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 55214C340EF; Tue, 8 Feb 2022 10:07:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644314827; bh=OikrdX8FMNiMLuMVEJTQbFg4yac0GkRiulyJsMntNGY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=jiP1EPaq3l/aJLJwYUcK5NMYqW2KzAtVaLuE9HOb9vDiTt92PUE12lcvGYU6E6zqt XcPHv5v36KfoKOmKMk4R3I/1iVdMxdBG53W5NftkumO7AlhhmCtBDucZk4S+gPHloK ss7Xe7jZpLAI2h8sTcfxDRByeIUNzXrPHSohN2ps= Date: Tue, 8 Feb 2022 11:07:04 +0100 From: Greg Kroah-Hartman To: Erwan LE RAY Cc: Andy Shevchenko , Jiri Slaby , Maxime Coquelin , Alexandre Torgue , Gerald Baeza , Valentin Caron , "linux-serial@vger.kernel.org" , "linux-stm32@st-md-mailman.stormreply.com" , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH 1/2] serial: mctrl_gpio: add a new API to enable / disable wake_irq Message-ID: References: <20220203171644.12231-1-erwan.leray@foss.st.com> <20220203171644.12231-2-erwan.leray@foss.st.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 On Fri, Feb 04, 2022 at 04:41:58PM +0100, Erwan LE RAY wrote: > Hi Andy, > > On 2/4/22 10:07 AM, Andy Shevchenko wrote: > > > > > > On Thursday, February 3, 2022, Erwan Le Ray > > wrote: > > > > Add a new API to enable / disable wake_irq in order to enable gpio > > irqs as > > wakeup irqs for the uart port. > > > > Signed-off-by: Erwan Le Ray > > > > > > diff --git a/drivers/tty/serial/serial_mctrl_gpio.c > > b/drivers/tty/serial/serial_mctrl_gpio.c > > index c41d8911ce95..1663b3afc3a0 100644 > > --- a/drivers/tty/serial/serial_mctrl_gpio.c > > +++ b/drivers/tty/serial/serial_mctrl_gpio.c > > @@ -299,4 +299,42 @@ void mctrl_gpio_disable_ms(struct mctrl_gpios > > *gpios) > > ?} > > ?EXPORT_SYMBOL_GPL(mctrl_gpio_disable_ms); > > > > +void mctrl_gpio_enable_irq_wake(struct mctrl_gpios *gpios) > > +{ > > +? ? ? ?enum mctrl_gpio_idx i; > > + > > +? ? ? ?if (!gpios) > > +? ? ? ? ? ? ? ?return; > > + > > +? ? ? ?if (!gpios->mctrl_on) > > +? ? ? ? ? ? ? ?return; > > + > > +? ? ? ?for (i = 0; i < UART_GPIO_MAX; ++i) { > > +? ? ? ? ? ? ? ?if (!gpios->irq[i]) > > +? ? ? ? ? ? ? ? ? ? ? ?continue; > > > > > > > > Why not simply > > > > ? if (gpios[]) > > ? ? enable_irq_... > > > > ? > > > > And same for disabling. > > > > + > > +? ? ? ? ? ? ? ?enable_irq_wake(gpios->irq[i]); > > +? ? ? ?} > > +} > > +EXPORT_SYMBOL_GPL(mctrl_gpio_enable_irq_wake); > > + > > +void mctrl_gpio_disable_irq_wake(struct mctrl_gpios *gpios) > > +{ > > +? ? ? ?enum mctrl_gpio_idx i; > > + > > +? ? ? ?if (!gpios) > > +? ? ? ? ? ? ? ?return; > > + > > +? ? ? ?if (!gpios->mctrl_on) > > +? ? ? ? ? ? ? ?return; > > + > > +? ? ? ?for (i = 0; i < UART_GPIO_MAX; ++i) { > > +? ? ? ? ? ? ? ?if (!gpios->irq[i]) > > +? ? ? ? ? ? ? ? ? ? ? ?continue; > > + > > +? ? ? ? ? ? ? ?disable_irq_wake(gpios->irq[i]); > > +? ? ? ?} > > +} > > +EXPORT_SYMBOL_GPL(mctrl_gpio_disable_irq_wake); > > + > > ?MODULE_LICENSE("GPL"); > > diff --git a/drivers/tty/serial/serial_mctrl_gpio.h > > b/drivers/tty/serial/serial_mctrl_gpio.h > > index b134a0ffc894..fc76910fb105 100644 > > --- a/drivers/tty/serial/serial_mctrl_gpio.h > > +++ b/drivers/tty/serial/serial_mctrl_gpio.h > > @@ -91,6 +91,16 @@ void mctrl_gpio_enable_ms(struct mctrl_gpios *gpios); > > ? */ > > ?void mctrl_gpio_disable_ms(struct mctrl_gpios *gpios); > > > > +/* > > + * Enable gpio wakeup interrupts to enable wake up source. > > + */ > > +void mctrl_gpio_enable_irq_wake(struct mctrl_gpios *gpios); > > + > > +/* > > + * Disable gpio wakeup interrupts to enable wake up source. > > + */ > > +void mctrl_gpio_disable_irq_wake(struct mctrl_gpios *gpios); > > + > > ?#else /* GPIOLIB */ > > > > ?static inline > > @@ -142,6 +152,14 @@ static inline void mctrl_gpio_disable_ms(struct > > mctrl_gpios *gpios) > > ?{ > > ?} > > > > +static inline void mctrl_gpio_enable_irq_wake(struct mctrl_gpios > > *gpios) > > +{ > > +} > > + > > +static inline void mctrl_gpio_disable_irq_wake(struct mctrl_gpios > > *gpios) > > +{ > > +} > > + > > ?#endif /* GPIOLIB */ > > > > ?#endif > > -- 2.17.1 > > > > > > > > -- > > With Best Regards, > > Andy Shevchenko > > > > > > Thanks for your review. > I fully agree with your comment, but I wrote this code like it is to keep > the same structure than all the other ops of serial_mcrtrl_gpio driver. I > preferred keeping an homogeneous code in the driver rather than breaking the > driver homogeneity with the addition of an optimized code. > > Greg, can you please indicate which solution you recommend ? Sadly, this is the format in this file, so I'll take this as-is. thanks, greg k-h