From: Shree Ramamoorthy <s-ramamoorthy@ti.com>
To: <lgirdwood@gmail.com>, <broonie@kernel.org>, <robh@kernel.org>,
<krzk+dt@kernel.org>, <conor+dt@kernel.org>,
<aaro.koskinen@iki.fi>, <andreas@kemnade.info>,
<khilman@baylibre.com>, <rogerq@kernel.org>, <tony@atomide.com>,
<jerome.neanne@baylibre.com>, <linux-omap@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <devicetree@vger.kernel.org>
Cc: <m-leonard@ti.com>, <praneeth@ti.com>, <christophe.jaillet@wanadoo.fr>
Subject: [PATCH v2 7/7] regulator: tps65215: Restructure probe() for multi-PMIC support
Date: Fri, 3 Jan 2025 17:04:46 -0600 [thread overview]
Message-ID: <20250103230446.197597-8-s-ramamoorthy@ti.com> (raw)
In-Reply-To: <20250103230446.197597-1-s-ramamoorthy@ti.com>
The probe() function will now utilize the register_regulators() and
request_irqs() helper functions defined in the previous patch. Probe() will
cycle through common (overlapping) regulators and irqs first, and then
handle device-specific resources identified using the chip_data struct.
Signed-off-by: Shree Ramamoorthy <s-ramamoorthy@ti.com>
---
drivers/regulator/tps65219-regulator.c | 63 ++++++++++++--------------
1 file changed, 28 insertions(+), 35 deletions(-)
diff --git a/drivers/regulator/tps65219-regulator.c b/drivers/regulator/tps65219-regulator.c
index 31d76706bfc0..56415f1fd60d 100644
--- a/drivers/regulator/tps65219-regulator.c
+++ b/drivers/regulator/tps65219-regulator.c
@@ -409,54 +409,47 @@ static int tps65219_request_irqs(struct tps65219_regulator_irq_type *irq_types,
static int tps65219_regulator_probe(struct platform_device *pdev)
{
struct tps65219 *tps = dev_get_drvdata(pdev->dev.parent);
- struct regulator_dev *rdev;
struct regulator_config config = { };
- int i;
int error;
- int irq;
struct tps65219_regulator_irq_data *irq_data;
- struct tps65219_regulator_irq_type *irq_type;
+ struct tps65219_chip_data *pmic;
+
+
+ enum pmic_id chip = platform_get_device_id(pdev)->driver_data;
+
+ pmic = &chip_info_table[chip];
config.dev = tps->dev;
config.driver_data = tps;
config.regmap = tps->regmap;
- for (i = 0; i < ARRAY_SIZE(regulators); i++) {
- rdev = devm_regulator_register(&pdev->dev, ®ulators[i],
- &config);
- if (IS_ERR(rdev))
- return dev_err_probe(tps->dev, PTR_ERR(rdev),
- "Failed to register %s regulator\n",
- regulators[i].name);
- }
+ error = tps65219_register_regulators(pmic->common_rdesc, tps,
+ &pdev->dev, config, pmic->common_rdesc_size);
+ if (error)
+ return error;
- irq_data = devm_kmalloc(tps->dev,
- ARRAY_SIZE(tps65219_regulator_irq_types) *
- sizeof(struct tps65219_regulator_irq_data),
- GFP_KERNEL);
+ error = tps65219_register_regulators(pmic->rdesc, tps, &pdev->dev,
+ config, pmic->rdesc_size);
+ if (error)
+ return error;
+
+ irq_data = devm_kmalloc(tps->dev, pmic->common_irq_size, GFP_KERNEL);
if (!irq_data)
return -ENOMEM;
- for (i = 0; i < ARRAY_SIZE(tps65219_regulator_irq_types); ++i) {
- irq_type = &tps65219_regulator_irq_types[i];
-
- irq = platform_get_irq_byname(pdev, irq_type->irq_name);
- if (irq < 0)
- return -EINVAL;
-
- irq_data[i].dev = tps->dev;
- irq_data[i].type = irq_type;
-
- error = devm_request_threaded_irq(tps->dev, irq, NULL,
- tps65219_regulator_irq_handler,
- IRQF_ONESHOT,
- irq_type->irq_name,
- &irq_data[i]);
- if (error) {
- dev_err(tps->dev, "failed to request %s IRQ %d: %d\n",
- irq_type->irq_name, irq, error);
+ error = tps65219_request_irqs(pmic->common_irq_types, tps, pdev,
+ irq_data, pmic->common_irq_size);
+ if (error)
+ return error;
+
+ if (chip == TPS65219) {
+ irq_data = devm_kmalloc(tps->dev, pmic->dev_irq_size, GFP_KERNEL);
+ if (!irq_data)
+ return -ENOMEM;
+ error = tps65219_request_irqs(pmic->irq_types, tps, pdev,
+ irq_data, pmic->dev_irq_size);
+ if (error)
return error;
- }
}
return 0;
--
2.34.1
prev parent reply other threads:[~2025-01-03 23:05 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-03 23:04 [PATCH v2 0/7] Add TI TPS65215 PMIC Regulator Support Shree Ramamoorthy
2025-01-03 23:04 ` [PATCH v2 1/7] regulator: dt-bindings: Add TI TPS65215 PMIC bindings Shree Ramamoorthy
2025-01-04 10:13 ` Krzysztof Kozlowski
2025-01-06 19:50 ` Shree Ramamoorthy
2025-01-03 23:04 ` [PATCH v2 2/7] regulator: tps65215: Update function & struct names Shree Ramamoorthy
2025-01-04 8:38 ` kernel test robot
2025-01-04 10:37 ` kernel test robot
2025-01-03 23:04 ` [PATCH v2 3/7] regulator: tps65215: Update IRQ structs to include TPS65215 Shree Ramamoorthy
2025-01-03 23:04 ` [PATCH v2 4/7] regulator: tps65215: Add chip_data struct for multi-PMIC support Shree Ramamoorthy
2025-01-04 9:53 ` kernel test robot
2025-01-03 23:04 ` [PATCH v2 5/7] regulator: tps65215: Update platform_device_id table Shree Ramamoorthy
2025-01-04 10:14 ` Krzysztof Kozlowski
2025-01-07 22:15 ` Shree Ramamoorthy
2025-01-03 23:04 ` [PATCH v2 6/7] regulator: tps65215: Define probe() helper functions Shree Ramamoorthy
2025-01-03 23:04 ` Shree Ramamoorthy [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250103230446.197597-8-s-ramamoorthy@ti.com \
--to=s-ramamoorthy@ti.com \
--cc=aaro.koskinen@iki.fi \
--cc=andreas@kemnade.info \
--cc=broonie@kernel.org \
--cc=christophe.jaillet@wanadoo.fr \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=jerome.neanne@baylibre.com \
--cc=khilman@baylibre.com \
--cc=krzk+dt@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=m-leonard@ti.com \
--cc=praneeth@ti.com \
--cc=robh@kernel.org \
--cc=rogerq@kernel.org \
--cc=tony@atomide.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®