Merge branch 'torvalds/master'
[firefly-linux-kernel-4.4.55.git] / drivers / input / keyboard / lm8323.c
index 0de23f41b2d316364b8a0f50b8b1b72ca5c9555b..21bea52d4365797a602f27e2f2f7c514540c0120 100644 (file)
@@ -558,6 +558,12 @@ static ssize_t lm8323_pwm_store_time(struct device *dev,
 }
 static DEVICE_ATTR(time, 0644, lm8323_pwm_show_time, lm8323_pwm_store_time);
 
+static struct attribute *lm8323_pwm_attrs[] = {
+       &dev_attr_time.attr,
+       NULL
+};
+ATTRIBUTE_GROUPS(lm8323_pwm);
+
 static int init_pwm(struct lm8323_chip *lm, int id, struct device *dev,
                    const char *name)
 {
@@ -580,16 +586,11 @@ static int init_pwm(struct lm8323_chip *lm, int id, struct device *dev,
        if (name) {
                pwm->cdev.name = name;
                pwm->cdev.brightness_set = lm8323_pwm_set_brightness;
+               pwm->cdev.groups = lm8323_pwm_groups;
                if (led_classdev_register(dev, &pwm->cdev) < 0) {
                        dev_err(dev, "couldn't register PWM %d\n", id);
                        return -1;
                }
-               if (device_create_file(pwm->cdev.dev,
-                                       &dev_attr_time) < 0) {
-                       dev_err(dev, "couldn't register time attribute\n");
-                       led_classdev_unregister(&pwm->cdev);
-                       return -1;
-               }
                pwm->enabled = true;
        }
 
@@ -615,6 +616,8 @@ static ssize_t lm8323_set_disable(struct device *dev,
        unsigned int i;
 
        ret = kstrtouint(buf, 10, &i);
+       if (ret)
+               return ret;
 
        mutex_lock(&lm->lock);
        lm->kp_enabled = !i;
@@ -627,7 +630,7 @@ static DEVICE_ATTR(disable_kp, 0644, lm8323_show_disable, lm8323_set_disable);
 static int lm8323_probe(struct i2c_client *client,
                                  const struct i2c_device_id *id)
 {
-       struct lm8323_platform_data *pdata = client->dev.platform_data;
+       struct lm8323_platform_data *pdata = dev_get_platdata(&client->dev);
        struct input_dev *idev;
        struct lm8323_chip *lm;
        int pwm;
@@ -753,11 +756,8 @@ fail3:
        device_remove_file(&client->dev, &dev_attr_disable_kp);
 fail2:
        while (--pwm >= 0)
-               if (lm->pwm[pwm].enabled) {
-                       device_remove_file(lm->pwm[pwm].cdev.dev,
-                                          &dev_attr_time);
+               if (lm->pwm[pwm].enabled)
                        led_classdev_unregister(&lm->pwm[pwm].cdev);
-               }
 fail1:
        input_free_device(idev);
        kfree(lm);
@@ -777,10 +777,8 @@ static int lm8323_remove(struct i2c_client *client)
        device_remove_file(&lm->client->dev, &dev_attr_disable_kp);
 
        for (i = 0; i < 3; i++)
-               if (lm->pwm[i].enabled) {
-                       device_remove_file(lm->pwm[i].cdev.dev, &dev_attr_time);
+               if (lm->pwm[i].enabled)
                        led_classdev_unregister(&lm->pwm[i].cdev);
-               }
 
        kfree(lm);