From nobody Thu Nov 28 02:49:41 2024 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DB3C14C98; Mon, 7 Oct 2024 00:14:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728260096; cv=none; b=SJAWlVjTQvgcnOfzJLRg9kdMZyMrYurFJoxggGIW9dE4i8+/71IsIMpslD6ttbiQI4g9F/6lGEQgAQ72IU6HvP3wN5ZqaCcY/8AjYdhHSUA8EaLRy6v/ZAsku2Om9Nw4v1vjn4aboAtNRUY0ayNzqvxGzhHNxWqmuDaSKTERv28= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728260096; c=relaxed/simple; bh=DrkghZ9iCBPij4tMtQpGuKTetzJpES+lEVEwvbnLsWY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kWzNtQvdNEzjrTMeAXjNIi7bEr1hgAYUUe0YNnNd7dANGi972RU9GWNezjq2vpEf5qZxSzs7qmxfJlgTeeTmeshKA2YrBLiabAECxqFOQA5FTGatItiABO3nF51euUZ7dAQJUbMqUKC15Lo8W7HzOtzZu3oLNN4nm+qjHo2D5zY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1EE7CFEC; Sun, 6 Oct 2024 17:15:24 -0700 (PDT) Received: from localhost.localdomain (usa-sjc-mx-foss1.foss.arm.com [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D7C5C3F640; Sun, 6 Oct 2024 17:14:52 -0700 (PDT) From: Andre Przywara To: Lee Jones , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen-Yu Tsai , Liam Girdwood , Mark Brown Cc: devicetree@vger.kernel.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Martin Botka , Chris Morgan Subject: [PATCH v2 2/5] mfd: axp20x: ensure relationship between IDs and model names Date: Mon, 7 Oct 2024 01:14:05 +0100 Message-ID: <20241007001408.27249-3-andre.przywara@arm.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241007001408.27249-1-andre.przywara@arm.com> References: <20241007001408.27249-1-andre.przywara@arm.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" At the moment there is an implicit relationship between the AXP model IDs and the order of the strings in the axp20x_model_names[] array. This is fragile, and makes adding IDs in the middle error prone. Make this relationship official by changing the ID type to the actual enum used, and using indexed initialisers for the string list. Signed-off-by: Andre Przywara Reviewed-by: Chen-Yu Tsai --- drivers/mfd/axp20x.c | 30 ++++++++++++++-------------- drivers/regulator/axp20x-regulator.c | 2 +- include/linux/mfd/axp20x.h | 2 +- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c index 4051551757f2d..5ceea359289f4 100644 --- a/drivers/mfd/axp20x.c +++ b/drivers/mfd/axp20x.c @@ -34,20 +34,20 @@ #define AXP806_REG_ADDR_EXT_ADDR_SLAVE_MODE BIT(4) =20 static const char * const axp20x_model_names[] =3D { - "AXP152", - "AXP192", - "AXP202", - "AXP209", - "AXP221", - "AXP223", - "AXP288", - "AXP313a", - "AXP717", - "AXP803", - "AXP806", - "AXP809", - "AXP813", - "AXP15060", + [AXP152_ID] =3D "AXP152", + [AXP192_ID] =3D "AXP192", + [AXP202_ID] =3D "AXP202", + [AXP209_ID] =3D "AXP209", + [AXP221_ID] =3D "AXP221", + [AXP223_ID] =3D "AXP223", + [AXP288_ID] =3D "AXP288", + [AXP313A_ID] =3D "AXP313a", + [AXP717_ID] =3D "AXP717", + [AXP803_ID] =3D "AXP803", + [AXP806_ID] =3D "AXP806", + [AXP809_ID] =3D "AXP809", + [AXP813_ID] =3D "AXP813", + [AXP15060_ID] =3D "AXP15060", }; =20 static const struct regmap_range axp152_writeable_ranges[] =3D { @@ -1345,7 +1345,7 @@ int axp20x_match_device(struct axp20x_dev *axp20x) axp20x->regmap_irq_chip =3D &axp15060_regmap_irq_chip; break; default: - dev_err(dev, "unsupported AXP20X ID %lu\n", axp20x->variant); + dev_err(dev, "unsupported AXP20X ID %u\n", axp20x->variant); return -EINVAL; } =20 diff --git a/drivers/regulator/axp20x-regulator.c b/drivers/regulator/axp20= x-regulator.c index a8e91d9d028b8..3ba76dbd0fb9e 100644 --- a/drivers/regulator/axp20x-regulator.c +++ b/drivers/regulator/axp20x-regulator.c @@ -1597,7 +1597,7 @@ static int axp20x_regulator_probe(struct platform_dev= ice *pdev) nregulators =3D AXP15060_REG_ID_MAX; break; default: - dev_err(&pdev->dev, "Unsupported AXP variant: %ld\n", + dev_err(&pdev->dev, "Unsupported AXP variant: %d\n", axp20x->variant); return -EINVAL; } diff --git a/include/linux/mfd/axp20x.h b/include/linux/mfd/axp20x.h index f4dfc1871a95b..79ecaaaa20703 100644 --- a/include/linux/mfd/axp20x.h +++ b/include/linux/mfd/axp20x.h @@ -959,7 +959,7 @@ struct axp20x_dev { unsigned long irq_flags; struct regmap *regmap; struct regmap_irq_chip_data *regmap_irqc; - long variant; + enum axp20x_variants variant; int nr_cells; const struct mfd_cell *cells; const struct regmap_config *regmap_cfg; --=20 2.46.2