Skip to content

Commit 489d695

Browse files
AxelLinbroonie
authored andcommitted
regulator: mpq7920: Remove unneeded fields from struct mpq7920_regulator_info
Both *dev and *rdev are only used in .probe, so use local variable instead. Also remove mpq7920_regulator_register() because it is so trivial and there is only one caller. Signed-off-by: Axel Lin <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent f72c583 commit 489d695

File tree

1 file changed

+13
-28
lines changed

1 file changed

+13
-28
lines changed

drivers/regulator/mpq7920.c

Lines changed: 13 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,7 @@ enum mpq7920_regulators {
9292
};
9393

9494
struct mpq7920_regulator_info {
95-
struct device *dev;
9695
struct regmap *regmap;
97-
struct regulator_dev *rdev[MPQ7920_MAX_REGULATORS];
9896
struct regulator_desc *rdesc;
9997
};
10098

@@ -262,40 +260,21 @@ static void mpq7920_parse_dt(struct device *dev,
262260
of_node_put(np);
263261
}
264262

265-
static inline int mpq7920_regulator_register(
266-
struct mpq7920_regulator_info *info,
267-
struct regulator_config *config)
268-
{
269-
int i;
270-
struct regulator_desc *rdesc;
271-
272-
for (i = 0; i < MPQ7920_MAX_REGULATORS; i++) {
273-
rdesc = &info->rdesc[i];
274-
275-
info->rdev[i] = devm_regulator_register(info->dev, rdesc,
276-
config);
277-
if (IS_ERR(info->rdev[i]))
278-
return PTR_ERR(info->rdev[i]);
279-
}
280-
281-
return 0;
282-
}
283-
284263
static int mpq7920_i2c_probe(struct i2c_client *client,
285264
const struct i2c_device_id *id)
286265
{
287266
struct device *dev = &client->dev;
288267
struct mpq7920_regulator_info *info;
289268
struct regulator_config config = { NULL, };
269+
struct regulator_dev *rdev;
290270
struct regmap *regmap;
291-
int ret;
271+
int i;
292272

293273
info = devm_kzalloc(dev, sizeof(struct mpq7920_regulator_info),
294274
GFP_KERNEL);
295275
if (!info)
296276
return -ENOMEM;
297277

298-
info->dev = dev;
299278
info->rdesc = mpq7920_regulators_desc;
300279
regmap = devm_regmap_init_i2c(client, &mpq7920_regmap_config);
301280
if (IS_ERR(regmap)) {
@@ -308,15 +287,21 @@ static int mpq7920_i2c_probe(struct i2c_client *client,
308287
if (client->dev.of_node)
309288
mpq7920_parse_dt(&client->dev, info);
310289

311-
config.dev = info->dev;
290+
config.dev = dev;
312291
config.regmap = regmap;
313292
config.driver_data = info;
314293

315-
ret = mpq7920_regulator_register(info, &config);
316-
if (ret < 0)
317-
dev_err(dev, "Failed to register regulator!\n");
294+
for (i = 0; i < MPQ7920_MAX_REGULATORS; i++) {
295+
rdev = devm_regulator_register(dev,
296+
&mpq7920_regulators_desc[i],
297+
&config);
298+
if (IS_ERR(rdev)) {
299+
dev_err(dev, "Failed to register regulator!\n");
300+
return PTR_ERR(rdev);
301+
}
302+
}
318303

319-
return ret;
304+
return 0;
320305
}
321306

322307
static const struct of_device_id mpq7920_of_match[] = {

0 commit comments

Comments
 (0)