Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 27390C433F5 for ; Sat, 8 Jan 2022 10:45:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234130AbiAHKpE (ORCPT ); Sat, 8 Jan 2022 05:45:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231232AbiAHKpD (ORCPT ); Sat, 8 Jan 2022 05:45:03 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 31995C061574 for ; Sat, 8 Jan 2022 02:45:03 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 872E860DDF for ; Sat, 8 Jan 2022 10:45:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E6A13C36AE5; Sat, 8 Jan 2022 10:45:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1641638701; bh=jzhOp8C6hTySN8VYbW0FS606ZaRRUE4qLQu1l9rI4rU=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=sgG8ObE6KEsr0n2V5Ld+QHlse5DPN1sFDdn+pwKli1a7E6P/toO+VQjgDc2Gt9rxK k2qFdOO4xTM34DhHtKSVlNp0EwNiOpm+YZq03HVyMP4GJpV54g3UaiXwrlIDYz9fTW F4xbALj2e/8ir9RetHxF5pA4r1gbVevW7HTHQ/18bJafoWjznrfZYOzBQorMveSa5k K+hDJspZWCKW0G4QVmeH1uZ2pQF+IRTPxxQNZRvfG8YuiBjgeUdzIpL4fY4LWeovJ9 uuOQPGsBXuIe4rebsvIfX3M+GJdZJ93A2aa+da+oKTbBeuXyjVEOfGX+2KkXIhNT2C zmwbwvBQKeFHw== Received: from sofa.misterjones.org ([185.219.108.64] helo=why.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1n69DY-00Gk7U-11; Sat, 08 Jan 2022 10:45:00 +0000 Date: Sat, 08 Jan 2022 10:44:59 +0000 Message-ID: <87sftytsk4.wl-maz@kernel.org> From: Marc Zyngier To: Qianggui Song Cc: Thomas Gleixner , Kevin Hilman , Neil Armstrong , Jerome Brunet , Martin Blumenstingl , , , Subject: Re: [PATCH 3/4] irqchip/meson-gpio: add select trigger type callback In-Reply-To: <20220108084218.31877-4-qianggui.song@amlogic.com> References: <20220108084218.31877-1-qianggui.song@amlogic.com> <20220108084218.31877-4-qianggui.song@amlogic.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: qianggui.song@amlogic.com, tglx@linutronix.de, khilman@baylibre.com, narmstrong@baylibre.com, jbrunet@baylibre.com, martin.blumenstingl@googlemail.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-amlogic@lists.infradead.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 08 Jan 2022 08:42:17 +0000, Qianggui Song wrote: > > Due to some chips may use different registers and offset, provide > a set trigger type call back. > > Signed-off-by: Qianggui Song > --- > drivers/irqchip/irq-meson-gpio.c | 13 ++++++++++--- > 1 file changed, 10 insertions(+), 3 deletions(-) > > diff --git a/drivers/irqchip/irq-meson-gpio.c b/drivers/irqchip/irq-meson-gpio.c > index 6a7b4fb13452..98419428fcbd 100644 > --- a/drivers/irqchip/irq-meson-gpio.c > +++ b/drivers/irqchip/irq-meson-gpio.c > @@ -55,6 +55,8 @@ struct irq_ctl_ops { > void (*gpio_irq_sel_pin)(struct meson_gpio_irq_controller *ctl, > unsigned int channel, unsigned long hwirq); > void (*gpio_irq_init)(struct meson_gpio_irq_controller *ctl); > + unsigned int (*gpio_irq_sel_type)(struct meson_gpio_irq_controller *ctl, > + unsigned int idx, u32 val); > }; > > struct meson_gpio_irq_params { > @@ -68,16 +70,17 @@ struct meson_gpio_irq_params { > struct irq_ctl_ops ops; > }; > > -#define INIT_MESON_COMMON(irqs, init, sel) \ > +#define INIT_MESON_COMMON(irqs, init, sel, type) \ > .nr_hwirq = irqs, \ > .ops = { \ > .gpio_irq_init = init, \ > .gpio_irq_sel_pin = sel, \ > + .gpio_irq_sel_type = type, \ > }, > > #define INIT_MESON8_COMMON_DATA(irqs) \ > INIT_MESON_COMMON(irqs, meson_gpio_irq_init_dummy, \ > - meson8_gpio_irq_sel_pin) \ > + meson8_gpio_irq_sel_pin, NULL) \ > .edge_single_offset = 0, \ > .pol_low_offset = 16, \ > .pin_sel_mask = 0xff, \ > @@ -85,7 +88,7 @@ struct meson_gpio_irq_params { > > #define INIT_MESON_A1_COMMON_DATA(irqs) \ > INIT_MESON_COMMON(irqs, meson_a1_gpio_irq_init, \ > - meson_a1_gpio_irq_sel_pin) \ > + meson_a1_gpio_irq_sel_pin, NULL) \ > .support_edge_both = true, \ > .edge_both_offset = 16, \ > .edge_single_offset = 8, \ > @@ -279,6 +282,10 @@ static int meson_gpio_irq_type_setup(struct meson_gpio_irq_controller *ctl, > */ > type &= IRQ_TYPE_SENSE_MASK; > > + /* Some controllers may have different calculation method*/ > + if (params->ops.gpio_irq_sel_type) > + return params->ops.gpio_irq_sel_type(ctl, idx, type); > + No. If you are going to indirect these things, indirect them for all implementations and keep the code clean. M. -- Without deviation from the norm, progress is not possible.