diff options
Diffstat (limited to 'drivers/leds')
-rw-r--r-- | drivers/leds/Kconfig | 20 | ||||
-rw-r--r-- | drivers/leds/leds-gpio.c | 6 | ||||
-rw-r--r-- | drivers/leds/leds-lm3530.c | 67 | ||||
-rw-r--r-- | drivers/leds/leds-lp5521.c | 4 | ||||
-rw-r--r-- | drivers/leds/leds-sunfire.c | 12 |
5 files changed, 67 insertions, 42 deletions
diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig index 713d43b4e563..b591e726a6fa 100644 --- a/drivers/leds/Kconfig +++ b/drivers/leds/Kconfig @@ -92,7 +92,7 @@ config LEDS_NET48XX config LEDS_NET5501 tristate "LED Support for Soekris net5501 series Error LED" depends on LEDS_TRIGGERS - depends on X86 && LEDS_GPIO_PLATFORM && GPIO_CS5535 + depends on X86 && GPIO_CS5535 select LEDS_TRIGGER_DEFAULT_ON default n help @@ -182,23 +182,6 @@ config LEDS_GPIO defined as platform devices and/or OpenFirmware platform devices. The code to use these bindings can be selected below. -config LEDS_GPIO_PLATFORM - bool "Platform device bindings for GPIO LEDs" - depends on LEDS_GPIO - default y - help - Let the leds-gpio driver drive LEDs which have been defined as - platform devices. If you don't know what this means, say yes. - -config LEDS_GPIO_OF - bool "OpenFirmware platform device bindings for GPIO LEDs" - depends on LEDS_GPIO && OF_DEVICE - default y - help - Let the leds-gpio driver drive LEDs which have been defined as - of_platform devices. For instance, LEDs which are listed in a "dts" - file. - config LEDS_LP3944 tristate "LED Support for N.S. LP3944 (Fun Light) I2C chip" depends on LEDS_CLASS @@ -382,6 +365,7 @@ config LEDS_NS2 config LEDS_NETXBIG tristate "LED support for Big Network series LEDs" depends on MACH_NET2BIG_V2 || MACH_NET5BIG_V2 + depends on LEDS_CLASS default y help This option enable support for LEDs found on the LaCie 2Big diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c index b0480c8fbcbf..3d8bc327a68d 100644 --- a/drivers/leds/leds-gpio.c +++ b/drivers/leds/leds-gpio.c @@ -165,7 +165,7 @@ static inline int sizeof_gpio_leds_priv(int num_leds) } /* Code to create from OpenFirmware platform devices */ -#ifdef CONFIG_LEDS_GPIO_OF +#ifdef CONFIG_OF_GPIO static struct gpio_leds_priv * __devinit gpio_leds_create_of(struct platform_device *pdev) { struct device_node *np = pdev->dev.of_node, *child; @@ -223,13 +223,13 @@ static const struct of_device_id of_gpio_leds_match[] = { { .compatible = "gpio-leds", }, {}, }; -#else +#else /* CONFIG_OF_GPIO */ static struct gpio_leds_priv * __devinit gpio_leds_create_of(struct platform_device *pdev) { return NULL; } #define of_gpio_leds_match NULL -#endif +#endif /* CONFIG_OF_GPIO */ static int __devinit gpio_led_probe(struct platform_device *pdev) diff --git a/drivers/leds/leds-lm3530.c b/drivers/leds/leds-lm3530.c index 4d7ce7631acf..3dd7090a9a9b 100644 --- a/drivers/leds/leds-lm3530.c +++ b/drivers/leds/leds-lm3530.c @@ -68,17 +68,16 @@ #define LM3530_ALS2_IMP_SHIFT (4) /* Zone Boundary Register defaults */ -#define LM3530_DEF_ZB_0 (0x33) -#define LM3530_DEF_ZB_1 (0x66) -#define LM3530_DEF_ZB_2 (0x99) -#define LM3530_DEF_ZB_3 (0xCC) +#define LM3530_ALS_ZB_MAX (4) +#define LM3530_ALS_WINDOW_mV (1000) +#define LM3530_ALS_OFFSET_mV (4) /* Zone Target Register defaults */ -#define LM3530_DEF_ZT_0 (0x19) -#define LM3530_DEF_ZT_1 (0x33) +#define LM3530_DEF_ZT_0 (0x7F) +#define LM3530_DEF_ZT_1 (0x66) #define LM3530_DEF_ZT_2 (0x4C) -#define LM3530_DEF_ZT_3 (0x66) -#define LM3530_DEF_ZT_4 (0x7F) +#define LM3530_DEF_ZT_3 (0x33) +#define LM3530_DEF_ZT_4 (0x19) struct lm3530_mode_map { const char *mode; @@ -150,6 +149,8 @@ static int lm3530_init_registers(struct lm3530_data *drvdata) u8 als_imp_sel = 0; u8 brightness; u8 reg_val[LM3530_REG_MAX]; + u8 zones[LM3530_ALS_ZB_MAX]; + u32 als_vmin, als_vmax, als_vstep; struct lm3530_platform_data *pltfm = drvdata->pdata; struct i2c_client *client = drvdata->client; @@ -161,6 +162,26 @@ static int lm3530_init_registers(struct lm3530_data *drvdata) gen_config |= (LM3530_ENABLE_I2C); if (drvdata->mode == LM3530_BL_MODE_ALS) { + if (pltfm->als_vmax == 0) { + pltfm->als_vmin = als_vmin = 0; + pltfm->als_vmin = als_vmax = LM3530_ALS_WINDOW_mV; + } + + als_vmin = pltfm->als_vmin; + als_vmax = pltfm->als_vmax; + + if ((als_vmax - als_vmin) > LM3530_ALS_WINDOW_mV) + pltfm->als_vmax = als_vmax = + als_vmin + LM3530_ALS_WINDOW_mV; + + /* n zone boundary makes n+1 zones */ + als_vstep = (als_vmax - als_vmin) / (LM3530_ALS_ZB_MAX + 1); + + for (i = 0; i < LM3530_ALS_ZB_MAX; i++) + zones[i] = (((als_vmin + LM3530_ALS_OFFSET_mV) + + als_vstep + (i * als_vstep)) * LED_FULL) + / 1000; + als_config = (pltfm->als_avrg_time << LM3530_ALS_AVG_TIME_SHIFT) | (LM3530_ENABLE_ALS) | @@ -169,6 +190,7 @@ static int lm3530_init_registers(struct lm3530_data *drvdata) als_imp_sel = (pltfm->als1_resistor_sel << LM3530_ALS1_IMP_SHIFT) | (pltfm->als2_resistor_sel << LM3530_ALS2_IMP_SHIFT); + } if (drvdata->mode == LM3530_BL_MODE_PWM) @@ -190,10 +212,10 @@ static int lm3530_init_registers(struct lm3530_data *drvdata) reg_val[3] = 0x00; /* LM3530_ALS_ZONE_REG */ reg_val[4] = als_imp_sel; /* LM3530_ALS_IMP_SELECT */ reg_val[5] = brightness; /* LM3530_BRT_CTRL_REG */ - reg_val[6] = LM3530_DEF_ZB_0; /* LM3530_ALS_ZB0_REG */ - reg_val[7] = LM3530_DEF_ZB_1; /* LM3530_ALS_ZB1_REG */ - reg_val[8] = LM3530_DEF_ZB_2; /* LM3530_ALS_ZB2_REG */ - reg_val[9] = LM3530_DEF_ZB_3; /* LM3530_ALS_ZB3_REG */ + reg_val[6] = zones[0]; /* LM3530_ALS_ZB0_REG */ + reg_val[7] = zones[1]; /* LM3530_ALS_ZB1_REG */ + reg_val[8] = zones[2]; /* LM3530_ALS_ZB2_REG */ + reg_val[9] = zones[3]; /* LM3530_ALS_ZB3_REG */ reg_val[10] = LM3530_DEF_ZT_0; /* LM3530_ALS_Z0T_REG */ reg_val[11] = LM3530_DEF_ZT_1; /* LM3530_ALS_Z1T_REG */ reg_val[12] = LM3530_DEF_ZT_2; /* LM3530_ALS_Z2T_REG */ @@ -265,6 +287,24 @@ static void lm3530_brightness_set(struct led_classdev *led_cdev, } } +static ssize_t lm3530_mode_get(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct i2c_client *client = container_of( + dev->parent, struct i2c_client, dev); + struct lm3530_data *drvdata = i2c_get_clientdata(client); + int i, len = 0; + + for (i = 0; i < ARRAY_SIZE(mode_map); i++) + if (drvdata->mode == mode_map[i].mode_val) + len += sprintf(buf + len, "[%s] ", mode_map[i].mode); + else + len += sprintf(buf + len, "%s ", mode_map[i].mode); + + len += sprintf(buf + len, "\n"); + + return len; +} static ssize_t lm3530_mode_set(struct device *dev, struct device_attribute *attr, const char *buf, size_t size) @@ -298,8 +338,7 @@ static ssize_t lm3530_mode_set(struct device *dev, struct device_attribute return sizeof(drvdata->mode); } - -static DEVICE_ATTR(mode, 0644, NULL, lm3530_mode_set); +static DEVICE_ATTR(mode, 0644, lm3530_mode_get, lm3530_mode_set); static int __devinit lm3530_probe(struct i2c_client *client, const struct i2c_device_id *id) diff --git a/drivers/leds/leds-lp5521.c b/drivers/leds/leds-lp5521.c index cc1dc4817fac..9fc122c81f06 100644 --- a/drivers/leds/leds-lp5521.c +++ b/drivers/leds/leds-lp5521.c @@ -744,7 +744,7 @@ fail1: return ret; } -static int lp5521_remove(struct i2c_client *client) +static int __devexit lp5521_remove(struct i2c_client *client) { struct lp5521_chip *chip = i2c_get_clientdata(client); int i; @@ -775,7 +775,7 @@ static struct i2c_driver lp5521_driver = { .name = "lp5521", }, .probe = lp5521_probe, - .remove = lp5521_remove, + .remove = __devexit_p(lp5521_remove), .id_table = lp5521_id, }; diff --git a/drivers/leds/leds-sunfire.c b/drivers/leds/leds-sunfire.c index ab6d18f5c39f..1757396b20b3 100644 --- a/drivers/leds/leds-sunfire.c +++ b/drivers/leds/leds-sunfire.c @@ -127,17 +127,19 @@ static int __devinit sunfire_led_generic_probe(struct platform_device *pdev, struct led_type *types) { struct sunfire_drvdata *p; - int i, err = -EINVAL; + int i, err; if (pdev->num_resources != 1) { printk(KERN_ERR PFX "Wrong number of resources %d, should be 1\n", pdev->num_resources); + err = -EINVAL; goto out; } p = kzalloc(sizeof(*p), GFP_KERNEL); if (!p) { printk(KERN_ERR PFX "Could not allocate struct sunfire_drvdata\n"); + err = -ENOMEM; goto out; } @@ -160,14 +162,14 @@ static int __devinit sunfire_led_generic_probe(struct platform_device *pdev, dev_set_drvdata(&pdev->dev, p); - err = 0; -out: - return err; + return 0; out_unregister_led_cdevs: for (i--; i >= 0; i--) led_classdev_unregister(&p->leds[i].led_cdev); - goto out; + kfree(p); +out: + return err; } static int __devexit sunfire_led_generic_remove(struct platform_device *pdev) |