- /* Register sysfs hooks */
- err = sysfs_create_group(&client->dev.kobj, &ad7414_group);
- if (err)
- return err;
-
- data->hwmon_dev = hwmon_device_register(&client->dev);
- if (IS_ERR(data->hwmon_dev)) {
- err = PTR_ERR(data->hwmon_dev);
- goto exit_remove;
- }
-
- return 0;
-
-exit_remove:
- sysfs_remove_group(&client->dev.kobj, &ad7414_group);
- return err;
-}
-
-static int ad7414_remove(struct i2c_client *client)
-{
- struct ad7414_data *data = i2c_get_clientdata(client);
-
- hwmon_device_unregister(data->hwmon_dev);
- sysfs_remove_group(&client->dev.kobj, &ad7414_group);
- return 0;
+ hwmon_dev = devm_hwmon_device_register_with_groups(dev,
+ client->name,
+ data, ad7414_groups);
+ return PTR_ERR_OR_ZERO(hwmon_dev);