From nobody Thu Nov 28 10:59:39 2024 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BEE35155A5D; Thu, 3 Oct 2024 11:15:07 +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=1727954110; cv=none; b=S7Yqk2bZcoi2OkHvUdQBDfLySQaypsttyMwqfRK12v/5zAeZj8ykAFU8gaKld4JJ1s3w36N5dyHRf3R/ajgF/d/51x+eSeKe2vPXdcucs37RWze+5IV1ZuvqCrAYbESk1TX7JWAYHaUTZV9PZBbZ230C6pTgN++2nrTWLsF9E/A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727954110; c=relaxed/simple; bh=iuJIo5xHSieU5ZzP0xX3qWpAQCVTSyqz/s/+XbJTuNg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=W8nO4o2OPDvoYE60MJY5ZM4xPCmbMwksDA1URQQ8wynRkpY2bvynO4VCed+1ls69p0A3ByUgZMGzBFiBgErHK21ikdj4ATg08esq8i5kV7hr4OY024GaPWzMJuHI+Fsv4O/NP9x1h4ZpsCGc6YjAAxpBpHlxrnfjO2hnwBJACe8= 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 B53A3339; Thu, 3 Oct 2024 04:15:36 -0700 (PDT) Received: from e110479.arm.com (unknown [10.57.55.26]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 4F8043F640; Thu, 3 Oct 2024 04:15:04 -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 2/5] mfd: axp20x: ensure relationship between IDs and model names Date: Thu, 3 Oct 2024 12:14:41 +0100 Message-Id: <20241003111444.543964-3-andre.przywara@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241003111444.543964-1-andre.przywara@arm.com> References: <20241003111444.543964-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 4051551757f2..5ceea359289f 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 a8e91d9d028b..3ba76dbd0fb9 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 f4dfc1871a95..79ecaaaa2070 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.25.1