/* Each client has this additional data */
 struct adm1031_data {
-       struct device *hwmon_dev;
+       struct i2c_client *client;
+       const struct attribute_group *groups[3];
        struct mutex update_lock;
        int chip_type;
        char valid;             /* !=0 if following fields are valid */
 
 static struct adm1031_data *adm1031_update_device(struct device *dev)
 {
-       struct i2c_client *client = to_i2c_client(dev);
-       struct adm1031_data *data = i2c_get_clientdata(client);
+       struct adm1031_data *data = dev_get_drvdata(dev);
+       struct i2c_client *client = data->client;
        unsigned long next_update;
        int chan;
 
 set_fan_auto_channel(struct device *dev, struct device_attribute *attr,
                     const char *buf, size_t count)
 {
-       struct i2c_client *client = to_i2c_client(dev);
-       struct adm1031_data *data = i2c_get_clientdata(client);
+       struct adm1031_data *data = dev_get_drvdata(dev);
+       struct i2c_client *client = data->client;
        int nr = to_sensor_dev_attr(attr)->index;
        long val;
        u8 reg;
 set_auto_temp_min(struct device *dev, struct device_attribute *attr,
                  const char *buf, size_t count)
 {
-       struct i2c_client *client = to_i2c_client(dev);
-       struct adm1031_data *data = i2c_get_clientdata(client);
+       struct adm1031_data *data = dev_get_drvdata(dev);
+       struct i2c_client *client = data->client;
        int nr = to_sensor_dev_attr(attr)->index;
        long val;
        int ret;
 set_auto_temp_max(struct device *dev, struct device_attribute *attr,
                  const char *buf, size_t count)
 {
-       struct i2c_client *client = to_i2c_client(dev);
-       struct adm1031_data *data = i2c_get_clientdata(client);
+       struct adm1031_data *data = dev_get_drvdata(dev);
+       struct i2c_client *client = data->client;
        int nr = to_sensor_dev_attr(attr)->index;
        long val;
        int ret;
 static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
                       const char *buf, size_t count)
 {
-       struct i2c_client *client = to_i2c_client(dev);
-       struct adm1031_data *data = i2c_get_clientdata(client);
+       struct adm1031_data *data = dev_get_drvdata(dev);
+       struct i2c_client *client = data->client;
        int nr = to_sensor_dev_attr(attr)->index;
        long val;
        int ret, reg;
 static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr,
                           const char *buf, size_t count)
 {
-       struct i2c_client *client = to_i2c_client(dev);
-       struct adm1031_data *data = i2c_get_clientdata(client);
+       struct adm1031_data *data = dev_get_drvdata(dev);
+       struct i2c_client *client = data->client;
        int nr = to_sensor_dev_attr(attr)->index;
        long val;
        int ret;
 static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr,
                           const char *buf, size_t count)
 {
-       struct i2c_client *client = to_i2c_client(dev);
-       struct adm1031_data *data = i2c_get_clientdata(client);
+       struct adm1031_data *data = dev_get_drvdata(dev);
+       struct i2c_client *client = data->client;
        int nr = to_sensor_dev_attr(attr)->index;
        long val;
        u8 tmp;
                               struct device_attribute *attr, const char *buf,
                               size_t count)
 {
-       struct i2c_client *client = to_i2c_client(dev);
-       struct adm1031_data *data = i2c_get_clientdata(client);
+       struct adm1031_data *data = dev_get_drvdata(dev);
+       struct i2c_client *client = data->client;
        int nr = to_sensor_dev_attr(attr)->index;
        long val;
        int ret;
 static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr,
                            const char *buf, size_t count)
 {
-       struct i2c_client *client = to_i2c_client(dev);
-       struct adm1031_data *data = i2c_get_clientdata(client);
+       struct adm1031_data *data = dev_get_drvdata(dev);
+       struct i2c_client *client = data->client;
        int nr = to_sensor_dev_attr(attr)->index;
        long val;
        int ret;
 static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr,
                            const char *buf, size_t count)
 {
-       struct i2c_client *client = to_i2c_client(dev);
-       struct adm1031_data *data = i2c_get_clientdata(client);
+       struct adm1031_data *data = dev_get_drvdata(dev);
+       struct i2c_client *client = data->client;
        int nr = to_sensor_dev_attr(attr)->index;
        long val;
        int ret;
 static ssize_t set_temp_crit(struct device *dev, struct device_attribute *attr,
                             const char *buf, size_t count)
 {
-       struct i2c_client *client = to_i2c_client(dev);
-       struct adm1031_data *data = i2c_get_clientdata(client);
+       struct adm1031_data *data = dev_get_drvdata(dev);
+       struct i2c_client *client = data->client;
        int nr = to_sensor_dev_attr(attr)->index;
        long val;
        int ret;
 static ssize_t show_update_interval(struct device *dev,
                                    struct device_attribute *attr, char *buf)
 {
-       struct i2c_client *client = to_i2c_client(dev);
-       struct adm1031_data *data = i2c_get_clientdata(client);
+       struct adm1031_data *data = dev_get_drvdata(dev);
 
        return sprintf(buf, "%u\n", data->update_interval);
 }
                                   struct device_attribute *attr,
                                   const char *buf, size_t count)
 {
-       struct i2c_client *client = to_i2c_client(dev);
-       struct adm1031_data *data = i2c_get_clientdata(client);
+       struct adm1031_data *data = dev_get_drvdata(dev);
+       struct i2c_client *client = data->client;
        unsigned long val;
        int i, err;
        u8 reg;
 static int adm1031_probe(struct i2c_client *client,
                         const struct i2c_device_id *id)
 {
+       struct device *dev = &client->dev;
+       struct device *hwmon_dev;
        struct adm1031_data *data;
-       int err;
 
-       data = devm_kzalloc(&client->dev, sizeof(struct adm1031_data),
-                           GFP_KERNEL);
+       data = devm_kzalloc(dev, sizeof(struct adm1031_data), GFP_KERNEL);
        if (!data)
                return -ENOMEM;
 
        i2c_set_clientdata(client, data);
+       data->client = client;
        data->chip_type = id->driver_data;
        mutex_init(&data->update_lock);
 
        /* Initialize the ADM1031 chip */
        adm1031_init_client(client);
 
-       /* Register sysfs hooks */
-       err = sysfs_create_group(&client->dev.kobj, &adm1031_group);
-       if (err)
-               return err;
-
-       if (data->chip_type == adm1031) {
-               err = sysfs_create_group(&client->dev.kobj, &adm1031_group_opt);
-               if (err)
-                       goto exit_remove;
-       }
-
-       data->hwmon_dev = hwmon_device_register(&client->dev);
-       if (IS_ERR(data->hwmon_dev)) {
-               err = PTR_ERR(data->hwmon_dev);
-               goto exit_remove;
-       }
+       /* sysfs hooks */
+       data->groups[0] = &adm1031_group;
+       if (data->chip_type == adm1031)
+               data->groups[1] = &adm1031_group_opt;
 
-       return 0;
-
-exit_remove:
-       sysfs_remove_group(&client->dev.kobj, &adm1031_group);
-       sysfs_remove_group(&client->dev.kobj, &adm1031_group_opt);
-       return err;
-}
-
-static int adm1031_remove(struct i2c_client *client)
-{
-       struct adm1031_data *data = i2c_get_clientdata(client);
-
-       hwmon_device_unregister(data->hwmon_dev);
-       sysfs_remove_group(&client->dev.kobj, &adm1031_group);
-       sysfs_remove_group(&client->dev.kobj, &adm1031_group_opt);
-       return 0;
+       hwmon_dev = devm_hwmon_device_register_with_groups(dev, client->name,
+                                                          data, data->groups);
+       return PTR_ERR_OR_ZERO(hwmon_dev);
 }
 
 static const struct i2c_device_id adm1031_id[] = {
                .name = "adm1031",
        },
        .probe          = adm1031_probe,
-       .remove         = adm1031_remove,
        .id_table       = adm1031_id,
        .detect         = adm1031_detect,
        .address_list   = normal_i2c,