leds-lp55xx: support device specific attributes
authorMilo(Woogyom) Kim <milo.kim@ti.com>
Tue, 5 Feb 2013 10:20:01 +0000 (19:20 +0900)
committerBryan Wu <cooloney@gmail.com>
Wed, 6 Feb 2013 23:59:29 +0000 (15:59 -0800)
 To support device specific attributes, new common driver function is added.
 Eventually those are created on registering the sysfs with common dev attrs.
 Furthermore, this patch makes adding device attributes simple in each driver.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
drivers/leds/leds-lp55xx-common.c
drivers/leds/leds-lp55xx-common.h

index 578902a..9638ad4 100644 (file)
@@ -493,8 +493,19 @@ EXPORT_SYMBOL_GPL(lp55xx_unregister_leds);
 int lp55xx_register_sysfs(struct lp55xx_chip *chip)
 {
        struct device *dev = &chip->cl->dev;
+       struct lp55xx_device_config *cfg = chip->cfg;
+       int ret;
+
+       if (!cfg->run_engine || !cfg->firmware_cb)
+               goto dev_specific_attrs;
+
+       ret = sysfs_create_group(&dev->kobj, &lp55xx_engine_attr_group);
+       if (ret)
+               return ret;
 
-       return sysfs_create_group(&dev->kobj, &lp55xx_engine_attr_group);
+dev_specific_attrs:
+       return cfg->dev_attr_group ?
+               sysfs_create_group(&dev->kobj, cfg->dev_attr_group) : 0;
 }
 EXPORT_SYMBOL_GPL(lp55xx_register_sysfs);
 
index 8473abf..64eb78d 100644 (file)
@@ -45,6 +45,7 @@ struct lp55xx_reg {
  * @set_led_current    : LED current set function
  * @firmware_cb        : Call function when the firmware is loaded
  * @run_engine         : Run internal engine for pattern
+ * @dev_attr_group     : Device specific attributes
  */
 struct lp55xx_device_config {
        const struct lp55xx_reg reset;
@@ -65,6 +66,9 @@ struct lp55xx_device_config {
 
        /* used for running firmware LED patterns */
        void (*run_engine) (struct lp55xx_chip *chip, bool start);
+
+       /* additional device specific attributes */
+       const struct attribute_group *dev_attr_group;
 };
 
 /*