diff options
Diffstat (limited to 'drivers/leds')
-rw-r--r-- | drivers/leds/Kconfig | 1 | ||||
-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 |
4 files changed, 63 insertions, 21 deletions
diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig index 6c21c2986ca1..b591e726a6fa 100644 --- a/drivers/leds/Kconfig +++ b/drivers/leds/Kconfig | |||
@@ -365,6 +365,7 @@ config LEDS_NS2 | |||
365 | config LEDS_NETXBIG | 365 | config LEDS_NETXBIG |
366 | tristate "LED support for Big Network series LEDs" | 366 | tristate "LED support for Big Network series LEDs" |
367 | depends on MACH_NET2BIG_V2 || MACH_NET5BIG_V2 | 367 | depends on MACH_NET2BIG_V2 || MACH_NET5BIG_V2 |
368 | depends on LEDS_CLASS | ||
368 | default y | 369 | default y |
369 | help | 370 | help |
370 | This option enable support for LEDs found on the LaCie 2Big | 371 | This option enable support for LEDs found on the LaCie 2Big |
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 @@ | |||
68 | #define LM3530_ALS2_IMP_SHIFT (4) | 68 | #define LM3530_ALS2_IMP_SHIFT (4) |
69 | 69 | ||
70 | /* Zone Boundary Register defaults */ | 70 | /* Zone Boundary Register defaults */ |
71 | #define LM3530_DEF_ZB_0 (0x33) | 71 | #define LM3530_ALS_ZB_MAX (4) |
72 | #define LM3530_DEF_ZB_1 (0x66) | 72 | #define LM3530_ALS_WINDOW_mV (1000) |
73 | #define LM3530_DEF_ZB_2 (0x99) | 73 | #define LM3530_ALS_OFFSET_mV (4) |
74 | #define LM3530_DEF_ZB_3 (0xCC) | ||
75 | 74 | ||
76 | /* Zone Target Register defaults */ | 75 | /* Zone Target Register defaults */ |
77 | #define LM3530_DEF_ZT_0 (0x19) | 76 | #define LM3530_DEF_ZT_0 (0x7F) |
78 | #define LM3530_DEF_ZT_1 (0x33) | 77 | #define LM3530_DEF_ZT_1 (0x66) |
79 | #define LM3530_DEF_ZT_2 (0x4C) | 78 | #define LM3530_DEF_ZT_2 (0x4C) |
80 | #define LM3530_DEF_ZT_3 (0x66) | 79 | #define LM3530_DEF_ZT_3 (0x33) |
81 | #define LM3530_DEF_ZT_4 (0x7F) | 80 | #define LM3530_DEF_ZT_4 (0x19) |
82 | 81 | ||
83 | struct lm3530_mode_map { | 82 | struct lm3530_mode_map { |
84 | const char *mode; | 83 | const char *mode; |
@@ -150,6 +149,8 @@ static int lm3530_init_registers(struct lm3530_data *drvdata) | |||
150 | u8 als_imp_sel = 0; | 149 | u8 als_imp_sel = 0; |
151 | u8 brightness; | 150 | u8 brightness; |
152 | u8 reg_val[LM3530_REG_MAX]; | 151 | u8 reg_val[LM3530_REG_MAX]; |
152 | u8 zones[LM3530_ALS_ZB_MAX]; | ||
153 | u32 als_vmin, als_vmax, als_vstep; | ||
153 | struct lm3530_platform_data *pltfm = drvdata->pdata; | 154 | struct lm3530_platform_data *pltfm = drvdata->pdata; |
154 | struct i2c_client *client = drvdata->client; | 155 | struct i2c_client *client = drvdata->client; |
155 | 156 | ||
@@ -161,6 +162,26 @@ static int lm3530_init_registers(struct lm3530_data *drvdata) | |||
161 | gen_config |= (LM3530_ENABLE_I2C); | 162 | gen_config |= (LM3530_ENABLE_I2C); |
162 | 163 | ||
163 | if (drvdata->mode == LM3530_BL_MODE_ALS) { | 164 | if (drvdata->mode == LM3530_BL_MODE_ALS) { |
165 | if (pltfm->als_vmax == 0) { | ||
166 | pltfm->als_vmin = als_vmin = 0; | ||
167 | pltfm->als_vmin = als_vmax = LM3530_ALS_WINDOW_mV; | ||
168 | } | ||
169 | |||
170 | als_vmin = pltfm->als_vmin; | ||
171 | als_vmax = pltfm->als_vmax; | ||
172 | |||
173 | if ((als_vmax - als_vmin) > LM3530_ALS_WINDOW_mV) | ||
174 | pltfm->als_vmax = als_vmax = | ||
175 | als_vmin + LM3530_ALS_WINDOW_mV; | ||
176 | |||
177 | /* n zone boundary makes n+1 zones */ | ||
178 | als_vstep = (als_vmax - als_vmin) / (LM3530_ALS_ZB_MAX + 1); | ||
179 | |||
180 | for (i = 0; i < LM3530_ALS_ZB_MAX; i++) | ||
181 | zones[i] = (((als_vmin + LM3530_ALS_OFFSET_mV) + | ||
182 | als_vstep + (i * als_vstep)) * LED_FULL) | ||
183 | / 1000; | ||
184 | |||
164 | als_config = | 185 | als_config = |
165 | (pltfm->als_avrg_time << LM3530_ALS_AVG_TIME_SHIFT) | | 186 | (pltfm->als_avrg_time << LM3530_ALS_AVG_TIME_SHIFT) | |
166 | (LM3530_ENABLE_ALS) | | 187 | (LM3530_ENABLE_ALS) | |
@@ -169,6 +190,7 @@ static int lm3530_init_registers(struct lm3530_data *drvdata) | |||
169 | als_imp_sel = | 190 | als_imp_sel = |
170 | (pltfm->als1_resistor_sel << LM3530_ALS1_IMP_SHIFT) | | 191 | (pltfm->als1_resistor_sel << LM3530_ALS1_IMP_SHIFT) | |
171 | (pltfm->als2_resistor_sel << LM3530_ALS2_IMP_SHIFT); | 192 | (pltfm->als2_resistor_sel << LM3530_ALS2_IMP_SHIFT); |
193 | |||
172 | } | 194 | } |
173 | 195 | ||
174 | if (drvdata->mode == LM3530_BL_MODE_PWM) | 196 | if (drvdata->mode == LM3530_BL_MODE_PWM) |
@@ -190,10 +212,10 @@ static int lm3530_init_registers(struct lm3530_data *drvdata) | |||
190 | reg_val[3] = 0x00; /* LM3530_ALS_ZONE_REG */ | 212 | reg_val[3] = 0x00; /* LM3530_ALS_ZONE_REG */ |
191 | reg_val[4] = als_imp_sel; /* LM3530_ALS_IMP_SELECT */ | 213 | reg_val[4] = als_imp_sel; /* LM3530_ALS_IMP_SELECT */ |
192 | reg_val[5] = brightness; /* LM3530_BRT_CTRL_REG */ | 214 | reg_val[5] = brightness; /* LM3530_BRT_CTRL_REG */ |
193 | reg_val[6] = LM3530_DEF_ZB_0; /* LM3530_ALS_ZB0_REG */ | 215 | reg_val[6] = zones[0]; /* LM3530_ALS_ZB0_REG */ |
194 | reg_val[7] = LM3530_DEF_ZB_1; /* LM3530_ALS_ZB1_REG */ | 216 | reg_val[7] = zones[1]; /* LM3530_ALS_ZB1_REG */ |
195 | reg_val[8] = LM3530_DEF_ZB_2; /* LM3530_ALS_ZB2_REG */ | 217 | reg_val[8] = zones[2]; /* LM3530_ALS_ZB2_REG */ |
196 | reg_val[9] = LM3530_DEF_ZB_3; /* LM3530_ALS_ZB3_REG */ | 218 | reg_val[9] = zones[3]; /* LM3530_ALS_ZB3_REG */ |
197 | reg_val[10] = LM3530_DEF_ZT_0; /* LM3530_ALS_Z0T_REG */ | 219 | reg_val[10] = LM3530_DEF_ZT_0; /* LM3530_ALS_Z0T_REG */ |
198 | reg_val[11] = LM3530_DEF_ZT_1; /* LM3530_ALS_Z1T_REG */ | 220 | reg_val[11] = LM3530_DEF_ZT_1; /* LM3530_ALS_Z1T_REG */ |
199 | reg_val[12] = LM3530_DEF_ZT_2; /* LM3530_ALS_Z2T_REG */ | 221 | 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, | |||
265 | } | 287 | } |
266 | } | 288 | } |
267 | 289 | ||
290 | static ssize_t lm3530_mode_get(struct device *dev, | ||
291 | struct device_attribute *attr, char *buf) | ||
292 | { | ||
293 | struct i2c_client *client = container_of( | ||
294 | dev->parent, struct i2c_client, dev); | ||
295 | struct lm3530_data *drvdata = i2c_get_clientdata(client); | ||
296 | int i, len = 0; | ||
297 | |||
298 | for (i = 0; i < ARRAY_SIZE(mode_map); i++) | ||
299 | if (drvdata->mode == mode_map[i].mode_val) | ||
300 | len += sprintf(buf + len, "[%s] ", mode_map[i].mode); | ||
301 | else | ||
302 | len += sprintf(buf + len, "%s ", mode_map[i].mode); | ||
303 | |||
304 | len += sprintf(buf + len, "\n"); | ||
305 | |||
306 | return len; | ||
307 | } | ||
268 | 308 | ||
269 | static ssize_t lm3530_mode_set(struct device *dev, struct device_attribute | 309 | static ssize_t lm3530_mode_set(struct device *dev, struct device_attribute |
270 | *attr, const char *buf, size_t size) | 310 | *attr, const char *buf, size_t size) |
@@ -298,8 +338,7 @@ static ssize_t lm3530_mode_set(struct device *dev, struct device_attribute | |||
298 | 338 | ||
299 | return sizeof(drvdata->mode); | 339 | return sizeof(drvdata->mode); |
300 | } | 340 | } |
301 | 341 | static DEVICE_ATTR(mode, 0644, lm3530_mode_get, lm3530_mode_set); | |
302 | static DEVICE_ATTR(mode, 0644, NULL, lm3530_mode_set); | ||
303 | 342 | ||
304 | static int __devinit lm3530_probe(struct i2c_client *client, | 343 | static int __devinit lm3530_probe(struct i2c_client *client, |
305 | const struct i2c_device_id *id) | 344 | 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: | |||
744 | return ret; | 744 | return ret; |
745 | } | 745 | } |
746 | 746 | ||
747 | static int lp5521_remove(struct i2c_client *client) | 747 | static int __devexit lp5521_remove(struct i2c_client *client) |
748 | { | 748 | { |
749 | struct lp5521_chip *chip = i2c_get_clientdata(client); | 749 | struct lp5521_chip *chip = i2c_get_clientdata(client); |
750 | int i; | 750 | int i; |
@@ -775,7 +775,7 @@ static struct i2c_driver lp5521_driver = { | |||
775 | .name = "lp5521", | 775 | .name = "lp5521", |
776 | }, | 776 | }, |
777 | .probe = lp5521_probe, | 777 | .probe = lp5521_probe, |
778 | .remove = lp5521_remove, | 778 | .remove = __devexit_p(lp5521_remove), |
779 | .id_table = lp5521_id, | 779 | .id_table = lp5521_id, |
780 | }; | 780 | }; |
781 | 781 | ||
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, | |||
127 | struct led_type *types) | 127 | struct led_type *types) |
128 | { | 128 | { |
129 | struct sunfire_drvdata *p; | 129 | struct sunfire_drvdata *p; |
130 | int i, err = -EINVAL; | 130 | int i, err; |
131 | 131 | ||
132 | if (pdev->num_resources != 1) { | 132 | if (pdev->num_resources != 1) { |
133 | printk(KERN_ERR PFX "Wrong number of resources %d, should be 1\n", | 133 | printk(KERN_ERR PFX "Wrong number of resources %d, should be 1\n", |
134 | pdev->num_resources); | 134 | pdev->num_resources); |
135 | err = -EINVAL; | ||
135 | goto out; | 136 | goto out; |
136 | } | 137 | } |
137 | 138 | ||
138 | p = kzalloc(sizeof(*p), GFP_KERNEL); | 139 | p = kzalloc(sizeof(*p), GFP_KERNEL); |
139 | if (!p) { | 140 | if (!p) { |
140 | printk(KERN_ERR PFX "Could not allocate struct sunfire_drvdata\n"); | 141 | printk(KERN_ERR PFX "Could not allocate struct sunfire_drvdata\n"); |
142 | err = -ENOMEM; | ||
141 | goto out; | 143 | goto out; |
142 | } | 144 | } |
143 | 145 | ||
@@ -160,14 +162,14 @@ static int __devinit sunfire_led_generic_probe(struct platform_device *pdev, | |||
160 | 162 | ||
161 | dev_set_drvdata(&pdev->dev, p); | 163 | dev_set_drvdata(&pdev->dev, p); |
162 | 164 | ||
163 | err = 0; | 165 | return 0; |
164 | out: | ||
165 | return err; | ||
166 | 166 | ||
167 | out_unregister_led_cdevs: | 167 | out_unregister_led_cdevs: |
168 | for (i--; i >= 0; i--) | 168 | for (i--; i >= 0; i--) |
169 | led_classdev_unregister(&p->leds[i].led_cdev); | 169 | led_classdev_unregister(&p->leds[i].led_cdev); |
170 | goto out; | 170 | kfree(p); |
171 | out: | ||
172 | return err; | ||
171 | } | 173 | } |
172 | 174 | ||
173 | static int __devexit sunfire_led_generic_remove(struct platform_device *pdev) | 175 | static int __devexit sunfire_led_generic_remove(struct platform_device *pdev) |