* [PATCH v2] regulator: max597x: Align for simple_mfd_i2c driver
@ 2023-02-16 7:53 Naresh Solanki
2023-02-17 1:54 ` Mark Brown
0 siblings, 1 reply; 2+ messages in thread
From: Naresh Solanki @ 2023-02-16 7:53 UTC (permalink / raw)
To: Mark Brown, Liam Girdwood; +Cc: Naresh Solanki, linux-kernel
Use regmap provided by simple_mfd_i2c driver and remove unused variable.
Identify device variant by checking compatible property in DT.
Signed-off-by: Naresh Solanki <Naresh.Solanki@9elements.com>
---
drivers/regulator/max597x-regulator.c | 46 +++++++++++++++++++--------
1 file changed, 32 insertions(+), 14 deletions(-)
diff --git a/drivers/regulator/max597x-regulator.c b/drivers/regulator/max597x-regulator.c
index ab9dc18f98e3..f0fb0f56e420 100644
--- a/drivers/regulator/max597x-regulator.c
+++ b/drivers/regulator/max597x-regulator.c
@@ -425,41 +425,59 @@ static int max597x_setup_irq(struct device *dev,
static int max597x_regulator_probe(struct platform_device *pdev)
{
-
-
- struct max597x_data *max597x = dev_get_drvdata(pdev->dev.parent);
+ struct max597x_data *max597x;
+ struct regmap *regmap = dev_get_regmap(pdev->dev.parent, NULL);
struct max597x_regulator *data;
-
+ struct i2c_client *i2c = to_i2c_client(pdev->dev.parent);
struct regulator_config config = { };
struct regulator_dev *rdev;
struct regulator_dev *rdevs[MAX5970_NUM_SWITCHES];
- int num_switches = max597x->num_switches;
+ int num_switches;
int ret, i;
+ if (!regmap)
+ return -EPROBE_DEFER;
+
+ max597x = devm_kzalloc(&i2c->dev, sizeof(struct max597x_data), GFP_KERNEL);
+ if (!max597x)
+ return -ENOMEM;
+
+ i2c_set_clientdata(i2c, max597x);
+
+ if (of_device_is_compatible(i2c->dev.of_node, "maxim,max5978"))
+ max597x->num_switches = MAX597x_TYPE_MAX5978;
+ else if (of_device_is_compatible(i2c->dev.of_node, "maxim,max5970"))
+ max597x->num_switches = MAX597x_TYPE_MAX5970;
+ else
+ return -ENODEV;
+
+ i2c_set_clientdata(i2c, max597x);
+ num_switches = max597x->num_switches;
+
for (i = 0; i < num_switches; i++) {
data =
- devm_kzalloc(max597x->dev, sizeof(struct max597x_regulator),
+ devm_kzalloc(&i2c->dev, sizeof(struct max597x_regulator),
GFP_KERNEL);
if (!data)
return -ENOMEM;
data->num_switches = num_switches;
- data->regmap = max597x->regmap;
+ data->regmap = regmap;
- ret = max597x_adc_range(data->regmap, i, &max597x->irng[i], &max597x->mon_rng[i]);
+ ret = max597x_adc_range(regmap, i, &max597x->irng[i], &max597x->mon_rng[i]);
if (ret < 0)
return ret;
data->irng = max597x->irng[i];
data->mon_rng = max597x->mon_rng[i];
- config.dev = max597x->dev;
+ config.dev = &i2c->dev;
config.driver_data = (void *)data;
config.regmap = data->regmap;
- rdev = devm_regulator_register(max597x->dev,
+ rdev = devm_regulator_register(&i2c->dev,
®ulators[i], &config);
if (IS_ERR(rdev)) {
- dev_err(max597x->dev, "failed to register regulator %s\n",
+ dev_err(&i2c->dev, "failed to register regulator %s\n",
regulators[i].name);
return PTR_ERR(rdev);
}
@@ -467,12 +485,12 @@ static int max597x_regulator_probe(struct platform_device *pdev)
max597x->shunt_micro_ohms[i] = data->shunt_micro_ohms;
}
- if (max597x->irq) {
+ if (i2c->irq) {
ret =
- max597x_setup_irq(max597x->dev, max597x->irq, rdevs, num_switches,
+ max597x_setup_irq(&i2c->dev, i2c->irq, rdevs, num_switches,
data);
if (ret) {
- dev_err(max597x->dev, "IRQ setup failed");
+ dev_err(&i2c->dev, "IRQ setup failed");
return ret;
}
}
base-commit: ea3efd52e96287ce8d93563b1084429686b6e824
--
2.39.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] regulator: max597x: Align for simple_mfd_i2c driver
2023-02-16 7:53 [PATCH v2] regulator: max597x: Align for simple_mfd_i2c driver Naresh Solanki
@ 2023-02-17 1:54 ` Mark Brown
0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2023-02-17 1:54 UTC (permalink / raw)
To: Liam Girdwood, Naresh Solanki; +Cc: Naresh Solanki, linux-kernel
On Thu, 16 Feb 2023 08:53:01 +0100, Naresh Solanki wrote:
> Use regmap provided by simple_mfd_i2c driver and remove unused variable.
> Identify device variant by checking compatible property in DT.
>
>
Applied to
broonie/regulator.git for-next
Thanks!
[1/1] regulator: max597x: Align for simple_mfd_i2c driver
commit: 7f62cb8861190e7cc1018ff37597fc49b2eaafa8
All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying
to this mail.
Thanks,
Mark
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-02-17 1:54 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-16 7:53 [PATCH v2] regulator: max597x: Align for simple_mfd_i2c driver Naresh Solanki
2023-02-17 1:54 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox