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

Commit 6922ffcf authored by Jingoo Han's avatar Jingoo Han Committed by Lee Jones
Browse files

mfd: max8997: Use devm_*() functions



Use devm_*() functions to make cleanup paths simpler.

Signed-off-by: default avatarJingoo Han <jg1.han@samsung.com>
Signed-off-by: default avatarLee Jones <lee.jones@linaro.org>
parent b2cdcfac
Loading
Loading
Loading
Loading
+5 −9
Original line number Original line Diff line number Diff line
@@ -191,7 +191,8 @@ static int max8997_i2c_probe(struct i2c_client *i2c,
	struct max8997_platform_data *pdata = dev_get_platdata(&i2c->dev);
	struct max8997_platform_data *pdata = dev_get_platdata(&i2c->dev);
	int ret = 0;
	int ret = 0;


	max8997 = kzalloc(sizeof(struct max8997_dev), GFP_KERNEL);
	max8997 = devm_kzalloc(&i2c->dev, sizeof(struct max8997_dev),
				GFP_KERNEL);
	if (max8997 == NULL)
	if (max8997 == NULL)
		return -ENOMEM;
		return -ENOMEM;


@@ -203,14 +204,12 @@ static int max8997_i2c_probe(struct i2c_client *i2c,


	if (max8997->dev->of_node) {
	if (max8997->dev->of_node) {
		pdata = max8997_i2c_parse_dt_pdata(max8997->dev);
		pdata = max8997_i2c_parse_dt_pdata(max8997->dev);
		if (IS_ERR(pdata)) {
		if (IS_ERR(pdata))
			ret = PTR_ERR(pdata);
			return PTR_ERR(pdata);
			goto err;
		}
	}
	}


	if (!pdata)
	if (!pdata)
		goto err;
		return ret;


	max8997->pdata = pdata;
	max8997->pdata = pdata;
	max8997->ono = pdata->ono;
	max8997->ono = pdata->ono;
@@ -250,8 +249,6 @@ static int max8997_i2c_probe(struct i2c_client *i2c,
	i2c_unregister_device(max8997->muic);
	i2c_unregister_device(max8997->muic);
	i2c_unregister_device(max8997->haptic);
	i2c_unregister_device(max8997->haptic);
	i2c_unregister_device(max8997->rtc);
	i2c_unregister_device(max8997->rtc);
err:
	kfree(max8997);
	return ret;
	return ret;
}
}


@@ -263,7 +260,6 @@ static int max8997_i2c_remove(struct i2c_client *i2c)
	i2c_unregister_device(max8997->muic);
	i2c_unregister_device(max8997->muic);
	i2c_unregister_device(max8997->haptic);
	i2c_unregister_device(max8997->haptic);
	i2c_unregister_device(max8997->rtc);
	i2c_unregister_device(max8997->rtc);
	kfree(max8997);


	return 0;
	return 0;
}
}