Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 50bddb99 authored by Vaishali Thakkar's avatar Vaishali Thakkar Committed by Sebastian Reichel
Browse files

power: max17042_battery: Convert to using managed resources



Use managed resource functions devm_request_threaded_irq and
devm_power_supply_register to simplify error handling.

Also, remove max17042_remove as it is now redundant.

Signed-off-by: default avatarVaishali Thakkar <vthakkar1994@gmail.com>
Signed-off-by: default avatarSebastian Reichel <sre@kernel.org>
parent bc312cbd
Loading
Loading
Loading
Loading
+9 −17
Original line number Diff line number Diff line
@@ -909,7 +909,7 @@ static int max17042_probe(struct i2c_client *client,
		regmap_write(chip->regmap, MAX17042_LearnCFG, 0x0007);
	}

	chip->battery = power_supply_register(&client->dev, max17042_desc,
	chip->battery = devm_power_supply_register(&client->dev, max17042_desc,
						   &psy_cfg);
	if (IS_ERR(chip->battery)) {
		dev_err(&client->dev, "failed: power supply register\n");
@@ -917,10 +917,13 @@ static int max17042_probe(struct i2c_client *client,
	}

	if (client->irq) {
		ret = request_threaded_irq(client->irq, NULL,
		ret = devm_request_threaded_irq(&client->dev, client->irq,
						NULL,
						max17042_thread_handler,
					IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
					chip->battery->desc->name, chip);
						IRQF_TRIGGER_FALLING |
						IRQF_ONESHOT,
						chip->battery->desc->name,
						chip);
		if (!ret) {
			regmap_update_bits(chip->regmap, MAX17042_CONFIG,
					CONFIG_ALRT_BIT_ENBL,
@@ -944,16 +947,6 @@ static int max17042_probe(struct i2c_client *client,
	return 0;
}

static int max17042_remove(struct i2c_client *client)
{
	struct max17042_chip *chip = i2c_get_clientdata(client);

	if (client->irq)
		free_irq(client->irq, chip);
	power_supply_unregister(chip->battery);
	return 0;
}

#ifdef CONFIG_PM_SLEEP
static int max17042_suspend(struct device *dev)
{
@@ -1014,7 +1007,6 @@ static struct i2c_driver max17042_i2c_driver = {
		.pm	= &max17042_pm_ops,
	},
	.probe		= max17042_probe,
	.remove		= max17042_remove,
	.id_table	= max17042_id,
};
module_i2c_driver(max17042_i2c_driver);