From nobody Wed Nov 27 20:37:53 2024 Received: from TWMBX01.aspeed.com (mail.aspeedtech.com [211.20.114.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2A8031F942D; Tue, 8 Oct 2024 08:15:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=211.20.114.72 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728375311; cv=none; b=SuSU7R3K5xtKoTYYupBC5/XjFrBe/6MceNvTOu1D/F54DrI6dtq1biueamn2Ay24sAb2WEyY1JqidSjhJZZw0P4POcUCaZGEBBjmrxyGW7GF+/OzY6RZqP/52+SkgkXoPf1Vojyo0+asW+057kDCka9Rb2kAxcBgMNTjsMA+Z9Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728375311; c=relaxed/simple; bh=Jy3KZF2qtiEUu8zbgg3C+eekQAA4QNf7hgwI4vh/7gU=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ji5KCo2nVrDm78KcBMYeG1EO9qhzz4QQg+QZHigTWHfRd3UncWGfu6w0ERbOR2WXbA7mc4azVztVgRIvwmqcA/waFMjque4Fl5f5c5bHFK9M4oLbDuo0FKhGB58pHG47+cq5Bw2zdE47ZdBDWO07/Oi/KKqLcfNiTSW0f6qvP10= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=aspeedtech.com; spf=pass smtp.mailfrom=aspeedtech.com; arc=none smtp.client-ip=211.20.114.72 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=aspeedtech.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=aspeedtech.com Received: from TWMBX01.aspeed.com (192.168.0.62) by TWMBX01.aspeed.com (192.168.0.62) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.12; Tue, 8 Oct 2024 16:14:51 +0800 Received: from mail.aspeedtech.com (192.168.10.10) by TWMBX01.aspeed.com (192.168.0.62) with Microsoft SMTP Server id 15.2.1258.12 via Frontend Transport; Tue, 8 Oct 2024 16:14:51 +0800 From: Billy Tsai To: , , , , , , , , , , , , , , Subject: [PATCH v7 4/7] gpio: aspeed: Remove the name for bank array Date: Tue, 8 Oct 2024 16:14:47 +0800 Message-ID: <20241008081450.1490955-5-billy_tsai@aspeedtech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241008081450.1490955-1-billy_tsai@aspeedtech.com> References: <20241008081450.1490955-1-billy_tsai@aspeedtech.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The bank array name is only used to determine if the GPIO offset is valid, and this condition can be replaced by checking if the offset exceeds the ngpio property. Reviewed-by: Andrew Jeffery Signed-off-by: Billy Tsai --- drivers/gpio/gpio-aspeed.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/drivers/gpio/gpio-aspeed.c b/drivers/gpio/gpio-aspeed.c index c49c55ae962b..61a531962de3 100644 --- a/drivers/gpio/gpio-aspeed.c +++ b/drivers/gpio/gpio-aspeed.c @@ -77,7 +77,6 @@ struct aspeed_gpio_bank { uint16_t debounce_regs; uint16_t tolerance_regs; uint16_t cmdsrc_regs; - const char names[4][3]; }; =20 /* @@ -104,7 +103,6 @@ static const struct aspeed_gpio_bank aspeed_gpio_banks[= ] =3D { .debounce_regs =3D 0x0040, .tolerance_regs =3D 0x001c, .cmdsrc_regs =3D 0x0060, - .names =3D { "A", "B", "C", "D" }, }, { .val_regs =3D 0x0020, @@ -113,7 +111,6 @@ static const struct aspeed_gpio_bank aspeed_gpio_banks[= ] =3D { .debounce_regs =3D 0x0048, .tolerance_regs =3D 0x003c, .cmdsrc_regs =3D 0x0068, - .names =3D { "E", "F", "G", "H" }, }, { .val_regs =3D 0x0070, @@ -122,7 +119,6 @@ static const struct aspeed_gpio_bank aspeed_gpio_banks[= ] =3D { .debounce_regs =3D 0x00b0, .tolerance_regs =3D 0x00ac, .cmdsrc_regs =3D 0x0090, - .names =3D { "I", "J", "K", "L" }, }, { .val_regs =3D 0x0078, @@ -131,7 +127,6 @@ static const struct aspeed_gpio_bank aspeed_gpio_banks[= ] =3D { .debounce_regs =3D 0x0100, .tolerance_regs =3D 0x00fc, .cmdsrc_regs =3D 0x00e0, - .names =3D { "M", "N", "O", "P" }, }, { .val_regs =3D 0x0080, @@ -140,7 +135,6 @@ static const struct aspeed_gpio_bank aspeed_gpio_banks[= ] =3D { .debounce_regs =3D 0x0130, .tolerance_regs =3D 0x012c, .cmdsrc_regs =3D 0x0110, - .names =3D { "Q", "R", "S", "T" }, }, { .val_regs =3D 0x0088, @@ -149,7 +143,6 @@ static const struct aspeed_gpio_bank aspeed_gpio_banks[= ] =3D { .debounce_regs =3D 0x0160, .tolerance_regs =3D 0x015c, .cmdsrc_regs =3D 0x0140, - .names =3D { "U", "V", "W", "X" }, }, { .val_regs =3D 0x01E0, @@ -158,7 +151,6 @@ static const struct aspeed_gpio_bank aspeed_gpio_banks[= ] =3D { .debounce_regs =3D 0x0190, .tolerance_regs =3D 0x018c, .cmdsrc_regs =3D 0x0170, - .names =3D { "Y", "Z", "AA", "AB" }, }, { .val_regs =3D 0x01e8, @@ -167,7 +159,6 @@ static const struct aspeed_gpio_bank aspeed_gpio_banks[= ] =3D { .debounce_regs =3D 0x01c0, .tolerance_regs =3D 0x01bc, .cmdsrc_regs =3D 0x01a0, - .names =3D { "AC", "", "", "" }, }, }; =20 @@ -280,11 +271,11 @@ static inline const struct aspeed_bank_props *find_ba= nk_props( static inline bool have_gpio(struct aspeed_gpio *gpio, unsigned int offset) { const struct aspeed_bank_props *props =3D find_bank_props(gpio, offset); - const struct aspeed_gpio_bank *bank =3D to_bank(offset); - unsigned int group =3D GPIO_OFFSET(offset) / 8; =20 - return bank->names[group][0] !=3D '\0' && - (!props || ((props->input | props->output) & GPIO_BIT(offset))); + if (offset >=3D gpio->chip.ngpio) + return false; + + return (!props || ((props->input | props->output) & GPIO_BIT(offset))); } =20 static inline bool have_input(struct aspeed_gpio *gpio, unsigned int offse= t) --=20 2.25.1