Commit 0f14480b authored by Jean Delvare's avatar Jean Delvare
Browse files

hwmon: (adt7475) Move sysfs files removal to a separate function



Move sysfs files removal to a separate function. The code is common to
the device probing error path and the standard device removal path. As
it will grow with future driver development, this avoids code
duplication.

Signed-off-by: default avatarJean Delvare <khali@linux-fr.org>
Cc: Hans de Goede <hdegoede@redhat.com>
Cc: Jordan Crouse <jordan@cosmicpenguin.net>
Cc: "Darrick J. Wong" <djwong@us.ibm.com>
parent 3d849981
Loading
Loading
Loading
Loading
+10 −6
Original line number Original line Diff line number Diff line
@@ -1109,6 +1109,14 @@ static int adt7475_detect(struct i2c_client *client, int kind,
	return 0;
	return 0;
}
}


static void adt7475_remove_files(struct i2c_client *client,
				 struct adt7475_data *data)
{
	sysfs_remove_group(&client->dev.kobj, &adt7475_attr_group);
	if (data->has_voltage & 0x39)
		sysfs_remove_group(&client->dev.kobj, &adt7490_attr_group);
}

static int adt7475_probe(struct i2c_client *client,
static int adt7475_probe(struct i2c_client *client,
			 const struct i2c_device_id *id)
			 const struct i2c_device_id *id)
{
{
@@ -1156,9 +1164,7 @@ static int adt7475_probe(struct i2c_client *client,
	return 0;
	return 0;


eremove:
eremove:
	sysfs_remove_group(&client->dev.kobj, &adt7475_attr_group);
	adt7475_remove_files(client, data);
	if (data->has_voltage & 0x39)
		sysfs_remove_group(&client->dev.kobj, &adt7490_attr_group);
efree:
efree:
	kfree(data);
	kfree(data);
	return ret;
	return ret;
@@ -1169,9 +1175,7 @@ static int adt7475_remove(struct i2c_client *client)
	struct adt7475_data *data = i2c_get_clientdata(client);
	struct adt7475_data *data = i2c_get_clientdata(client);


	hwmon_device_unregister(data->hwmon_dev);
	hwmon_device_unregister(data->hwmon_dev);
	sysfs_remove_group(&client->dev.kobj, &adt7475_attr_group);
	adt7475_remove_files(client, data);
	if (data->has_voltage & 0x39)
		sysfs_remove_group(&client->dev.kobj, &adt7490_attr_group);
	kfree(data);
	kfree(data);


	return 0;
	return 0;