From mboxrd@z Thu Jan 1 00:00:00 1970 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7668AC433F5 for ; Sat, 8 Jan 2022 10:39:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Subject:Cc:To:From:Message-ID:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Fkt18z5wmmd61cQnJS1zcBlznUdCN9fSLP5kUXvSYtM=; b=llQTCgMeYMpCZ3 AiWclXJ2RQFBuezcB4dP1sA4Fd2OQx3YQwjH5J826apnxH9w309uLaJaQpgJnwZ43I1dlKqZaVFSo 01rvoZZEwrpFLe+gJm22+vXWgklQH4EOt0Lwmid8WV5613PeQITHIhQxzpCOTDepwltnmKjZV2pBp 5PnSn75+d3oTpSSuwf6mbasCI00/2n5Y14pd7aCxD7N4KllJxSGstDMbCYM/WU3PzInUjdlqQ2KhE ou52IxOlpZDlnbyYPT1OBvfzxlsLgQk79dVoKwLrIZpFB4n3n0vIjAIlQJCqTr1aXm441h0tiPEu5 aGoUF1OPMgEQfZ2glAYg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n696p-006IAK-0M; Sat, 08 Jan 2022 10:38:03 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n696k-006I9W-M2; Sat, 08 Jan 2022 10:38:00 +0000 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 A2CA360C98; Sat, 8 Jan 2022 10:37:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 03C30C36AE5; Sat, 8 Jan 2022 10:37:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1641638275; bh=TgiExzQYT7E5hlkoyGhgsfsCKWKWd3FY1bDyb5egQbE=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=tfw63Vy5Hgr12/12qbOm7haq7wb/mj9b1LVwjXV6B7gxKuKWh7AaAebVM/DPVxTVj yPE98SMXVijtTRUQkBVePvT5wXeeX0Vg2EPMn2mn5QuwUMAz/kJlLSMy5iWLIllhF6 rvSoX1UOcTfOWShiw4IviWnt7Byo3PJOfFe6oOYO73iar+M3Udjov28zszvJx+vcxi kflCYt5I+1s5903dogyRw7nLf2jOOrZt/Y06Yoy63VswbvOlCESPNrwWEioG2T+pKw ZowSweFiOk4viVQnRf8qV7BiQk87ux/5nNLTNN4kX/1RfICTWcerkDzkbWLij6+xRy r/91nDVdtDneA== 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 1n696e-00Gk3l-Nl; Sat, 08 Jan 2022 10:37:52 +0000 Date: Sat, 08 Jan 2022 10:37:52 +0000 Message-ID: <87tueetsvz.wl-maz@kernel.org> From: Marc Zyngier To: Qianggui Song Cc: Thomas Gleixner , Kevin Hilman , Neil Armstrong , Jerome Brunet , Martin Blumenstingl , , , Subject: Re: [PATCH 2/4] irqchip/meson-gpio: support more than 8 channels gpio irq line In-Reply-To: <20220108084218.31877-3-qianggui.song@amlogic.com> References: <20220108084218.31877-1-qianggui.song@amlogic.com> <20220108084218.31877-3-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") 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220108_023758_850552_58CE1C6A X-CRM114-Status: GOOD ( 26.32 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Sat, 08 Jan 2022 08:42:16 +0000, Qianggui Song wrote: > > Current meson gpio irqchip driver only support 8 channels for gpio irq > line, later chips may have more then 8 channels, so need to modify code > to support more. > > Signed-off-by: Qianggui Song > --- > drivers/irqchip/irq-meson-gpio.c | 33 +++++++++++++++++++++++--------- > 1 file changed, 24 insertions(+), 9 deletions(-) > > diff --git a/drivers/irqchip/irq-meson-gpio.c b/drivers/irqchip/irq-meson-gpio.c > index d90ff0b92480..6a7b4fb13452 100644 > --- a/drivers/irqchip/irq-meson-gpio.c > +++ b/drivers/irqchip/irq-meson-gpio.c > @@ -16,7 +16,6 @@ > #include > #include > > -#define NUM_CHANNEL 8 > #define MAX_INPUT_MUX 256 > > #define REG_EDGE_POL 0x00 > @@ -60,6 +59,7 @@ struct irq_ctl_ops { > > struct meson_gpio_irq_params { > unsigned int nr_hwirq; > + unsigned int channel_num; For consistency, please name this nr_channels. > bool support_edge_both; > unsigned int edge_both_offset; > unsigned int edge_single_offset; > @@ -81,6 +81,7 @@ struct meson_gpio_irq_params { > .edge_single_offset = 0, \ > .pol_low_offset = 16, \ > .pin_sel_mask = 0xff, \ > + .channel_num = 8, \ > > #define INIT_MESON_A1_COMMON_DATA(irqs) \ > INIT_MESON_COMMON(irqs, meson_a1_gpio_irq_init, \ > @@ -90,6 +91,7 @@ struct meson_gpio_irq_params { > .edge_single_offset = 8, \ > .pol_low_offset = 0, \ > .pin_sel_mask = 0x7f, \ > + .channel_num = 8, \ > > static const struct meson_gpio_irq_params meson8_params = { > INIT_MESON8_COMMON_DATA(134) > @@ -136,8 +138,9 @@ static const struct of_device_id meson_irq_gpio_matches[] = { > struct meson_gpio_irq_controller { > const struct meson_gpio_irq_params *params; > void __iomem *base; > - u32 channel_irqs[NUM_CHANNEL]; > - DECLARE_BITMAP(channel_map, NUM_CHANNEL); > + u32 *channel_irqs; > + unsigned long *channel_map; > + u8 channel_num; Same thing. Though this is completely superfluous, see below. > spinlock_t lock; > }; > > @@ -207,8 +210,8 @@ meson_gpio_irq_request_channel(struct meson_gpio_irq_controller *ctl, > spin_lock_irqsave(&ctl->lock, flags); > > /* Find a free channel */ > - idx = find_first_zero_bit(ctl->channel_map, NUM_CHANNEL); > - if (idx >= NUM_CHANNEL) { > + idx = find_first_zero_bit(ctl->channel_map, ctl->channel_num); > + if (idx >= ctl->channel_num) { > spin_unlock_irqrestore(&ctl->lock, flags); > pr_err("No channel available\n"); > return -ENOSPC; > @@ -447,13 +450,25 @@ static int meson_gpio_irq_parse_dt(struct device_node *node, struct meson_gpio_i > > ctl->params = match->data; > > + ctl->channel_num = ctl->params->channel_num; Since you already have a pointer to params, why do you need to duplicate this information? > + ctl->channel_irqs = kcalloc(ctl->channel_num, > + sizeof(*ctl->channel_irqs), GFP_KERNEL); > + if (!ctl->channel_irqs) > + return -ENOMEM; > + > + ctl->channel_map = bitmap_zalloc(ctl->params->channel_num, GFP_KERNEL); > + if (!ctl->channel_map) { > + kfree(ctl->channel_irqs); > + return -ENOMEM; > + } > + > ret = of_property_read_variable_u32_array(node, > "amlogic,channel-interrupts", > ctl->channel_irqs, > - NUM_CHANNEL, > - NUM_CHANNEL); > + ctl->channel_num, > + ctl->channel_num); > if (ret < 0) { > - pr_err("can't get %d channel interrupts\n", NUM_CHANNEL); > + pr_err("can't get %d channel interrupts\n", ctl->channel_num); > return ret; You are now leaking the bitmap and channel_map allocations. M. -- Without deviation from the norm, progress is not possible. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel