Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp1167078pxb; Fri, 21 Jan 2022 11:16:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJy5i+pXB2XAU323pmDZc4kdI4F7d7i8gx4dSKz26BMpl2Pktv6yPV6CtQNkyyl6DvWn4giK X-Received: by 2002:a17:90a:4482:: with SMTP id t2mr2081899pjg.133.1642792597349; Fri, 21 Jan 2022 11:16:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642792597; cv=none; d=google.com; s=arc-20160816; b=agyrUsINlZnc0HtlAs9Fz0Rrwuj5smBXaom5GliaJXlxHBKy8QxKgULXf8xK+C7MLX rAw/dBH1EFinVVGx2lroKAI+Erbe1V82eudd+3wxQD+0ZO1T59Dwois5cXwJL0CsU1gu sRX1hjNizAxKOgKvmna4pOr3S1oUSCOsyDgfS6TbBzfF5sWE4VqmAAe+7ES1pGSxoTWK Y2y+diySK9wEbQnIoeVeMSe9T6UPZv2c1S+R8FiwgeotXk+R1sNIclzC8x8cEAsibw5h epIozKFXujmFAuYIhF+GzdVNcdGzFORqYbm/r3gUf4SnvE8U8BrZP0Wiq/r9Ey+o4/Bs IFqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date:dkim-signature; bh=KP1WmBvFt/ydySvNiZBaS10V7WsEz3GmTyE++68R/zM=; b=I6As2cSWOZUYTdZagLQ3lG3JDUWt1PgEvigEsWTkxE2nba/+j4R1XL/DWU48DZRpvl 68v/8R7rsY8yPbsoW0lkWyFBcTFLDvKmvE2PHAhjayW8h7o0SF5QNZxs8OZ44t2SjeWP zHUcJPBNf7qRXZ5IVKDZM0Cs/lKdNNSt51Tjlf9BON/tv6xfSLkHgE0gajYjH5ehwiRy uJFv+O6tC+zRNOKBGz92y3yc4KsTrnk4T+Cpm0MD7BCbq3eFJMwVytpSMZbDa3IJFNLT rSb5nVI3/16L8MlymRLKhI76sGs0H8bCSfgS94GW/zgGu+Rgm4Al4/INeObsE8yJ04xT 3Ddw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FBqlGY9w; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id mq16si7611385pjb.12.2022.01.21.11.16.25; Fri, 21 Jan 2022 11:16:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FBqlGY9w; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354827AbiASNcG (ORCPT + 99 others); Wed, 19 Jan 2022 08:32:06 -0500 Received: from sin.source.kernel.org ([145.40.73.55]:39674 "EHLO sin.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354805AbiASNcE (ORCPT ); Wed, 19 Jan 2022 08:32:04 -0500 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 sin.source.kernel.org (Postfix) with ESMTPS id DDF67CE1BF9 for ; Wed, 19 Jan 2022 13:32:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4FAE4C340E1; Wed, 19 Jan 2022 13:32:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1642599121; bh=Dcxwe8xPAg1I+NdtM7U5krnqKyrJ5JxBLM/2WAGYiUY=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=FBqlGY9wI3HWc3PoOe7kvrDD/InvFPUklZO2SfxvjE0YVt8z/zTt5fqOczDQNEAet 2mAjOE+w5+MFMirdLFjioIKYutuk37Ta4QWRGf6Rj+9VGYJNSTJ5Z3la0sobvjZQbB UiWyH84rCNHV9AZC8zJokwZckIzPAAPpQEP7lltZvrYwTzxPim60r0pKZdyRhf+rnz +zXmtib7uMPegRszvngd+Mdgu3+T9VLOBFPHsnsU+O9lIvnQlok6CJ4gpqZgTxJOdh 50yMp4zwRtq21Ixkqx7WYOKUSDuyuVsttCb/RYX8QsB9DLqivzRkDlfIXrwg3qe8a0 Dys3WDW5TovXw== 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 1nAB4A-001U2A-Vp; Wed, 19 Jan 2022 13:31:59 +0000 Date: Wed, 19 Jan 2022 13:31:58 +0000 Message-ID: <87czkn97ht.wl-maz@kernel.org> From: Marc Zyngier To: Qianggui Song Cc: Thomas Gleixner , Kevin Hilman , Neil Armstrong , Jerome Brunet , Martin Blumenstingl , , , Subject: Re: [PATCH v2 2/4] irqchip/meson-gpio: support more than 8 channels gpio irq line In-Reply-To: <20220119070809.15563-3-qianggui.song@amlogic.com> References: <20220119070809.15563-1-qianggui.song@amlogic.com> <20220119070809.15563-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") 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 Wed, 19 Jan 2022 07:08:07 +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..eefe15e1b3a6 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 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, \ > + .nr_channels = 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, \ > + .nr_channels = 8, \ > > static const struct meson_gpio_irq_params meson8_params = { > INIT_MESON8_COMMON_DATA(134) > @@ -136,8 +138,8 @@ 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; This really is over-engineering at its best. With your new fancy HW, you have at most 12 bits being used in this bitmap. So why not have a single unsigned long, no dynamic allocation, and simply an assertion somewhere that checks that nr_channel is never bigger than BITS_PER_LONG? Less code, less memory wasted, less problems. M. -- Without deviation from the norm, progress is not possible.