diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-05-29 21:05:31 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-05-29 21:05:31 -0400 |
commit | 7d36014b972a3833b883a7ef41e6bd3b0d187850 (patch) | |
tree | 5c828b0de1cd357288135cc04461d31386b89c26 /drivers | |
parent | 442a9ffabb21f175027e93e72ea05159818271a6 (diff) | |
parent | ecb41a77411358d385e3fde5b4e98a5f3d9cfdd5 (diff) |
Merge branch 'akpm' (Andrew's patch-bomb)
Merge patches through Andrew Morton:
"180 patches - err 181 - listed below:
- most of MM. I held back the (large) "memcg: add hugetlb extension"
series because a bunfight has recently broken out.
- leds. After this, Bryan Wu will be handling drivers/leds/
- backlight
- lib/
- rtc"
* emailed from Andrew Morton <akpm@linux-foundation.org>: (181 patches)
drivers/rtc/rtc-s3c.c: fix compiler warning
drivers/rtc/rtc-tegra.c: clean up probe/remove routines
drivers/rtc/rtc-pl031.c: remove RTC timer interrupt handling
drivers/rtc/rtc-lpc32xx.c: add device tree support
drivers/rtc/rtc-m41t93.c: don't let get_time() reset M41T93_FLAG_OF
rtc: ds1307: add trickle charger support
rtc: ds1307: remove superfluous initialization
rtc: rename CONFIG_RTC_MXC to CONFIG_RTC_DRV_MXC
drivers/rtc/Kconfig: place RTC_DRV_IMXDI and RTC_MXC under "on-CPU RTC drivers"
drivers/rtc/rtc-pcf8563.c: add RTC_VL_READ/RTC_VL_CLR ioctl feature
rtc: add ioctl to get/clear battery low voltage status
drivers/rtc/rtc-ep93xx.c: convert to use module_platform_driver()
rtc/spear: add Device Tree probing capability
lib/vsprintf.c: "%#o",0 becomes '0' instead of '00'
radix-tree: fix preload vector size
spinlock_debug: print kallsyms name for lock
vsprintf: fix %ps on non symbols when using kallsyms
lib/bitmap.c: fix documentation for scnprintf() functions
lib/string_helpers.c: make arrays static
lib/test-kstrtox.c: mark const init data with __initconst instead of __initdata
...
Diffstat (limited to 'drivers')
59 files changed, 2218 insertions, 445 deletions
diff --git a/drivers/base/node.c b/drivers/base/node.c index 90aa2a11a933..af1a177216f1 100644 --- a/drivers/base/node.c +++ b/drivers/base/node.c | |||
@@ -592,11 +592,9 @@ static ssize_t print_nodes_state(enum node_states state, char *buf) | |||
592 | { | 592 | { |
593 | int n; | 593 | int n; |
594 | 594 | ||
595 | n = nodelist_scnprintf(buf, PAGE_SIZE, node_states[state]); | 595 | n = nodelist_scnprintf(buf, PAGE_SIZE-2, node_states[state]); |
596 | if (n > 0 && PAGE_SIZE > n + 1) { | 596 | buf[n++] = '\n'; |
597 | *(buf + n++) = '\n'; | 597 | buf[n] = '\0'; |
598 | *(buf + n++) = '\0'; | ||
599 | } | ||
600 | return n; | 598 | return n; |
601 | } | 599 | } |
602 | 600 | ||
diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig index ff4b8cfda585..04cb8c88d74b 100644 --- a/drivers/leds/Kconfig +++ b/drivers/leds/Kconfig | |||
@@ -50,6 +50,19 @@ config LEDS_LM3530 | |||
50 | controlled manually or using PWM input or using ambient | 50 | controlled manually or using PWM input or using ambient |
51 | light automatically. | 51 | light automatically. |
52 | 52 | ||
53 | config LEDS_LM3533 | ||
54 | tristate "LED support for LM3533" | ||
55 | depends on LEDS_CLASS | ||
56 | depends on MFD_LM3533 | ||
57 | help | ||
58 | This option enables support for the LEDs on National Semiconductor / | ||
59 | TI LM3533 Lighting Power chips. | ||
60 | |||
61 | The LEDs can be controlled directly, through PWM input, or by the | ||
62 | ambient-light-sensor interface. The chip supports | ||
63 | hardware-accelerated blinking with maximum on and off periods of 9.8 | ||
64 | and 77 seconds respectively. | ||
65 | |||
53 | config LEDS_LOCOMO | 66 | config LEDS_LOCOMO |
54 | tristate "LED Support for Locomo device" | 67 | tristate "LED Support for Locomo device" |
55 | depends on LEDS_CLASS | 68 | depends on LEDS_CLASS |
@@ -259,6 +272,14 @@ config LEDS_DA903X | |||
259 | This option enables support for on-chip LED drivers found | 272 | This option enables support for on-chip LED drivers found |
260 | on Dialog Semiconductor DA9030/DA9034 PMICs. | 273 | on Dialog Semiconductor DA9030/DA9034 PMICs. |
261 | 274 | ||
275 | config LEDS_DA9052 | ||
276 | tristate "Dialog DA9052/DA9053 LEDS" | ||
277 | depends on LEDS_CLASS | ||
278 | depends on PMIC_DA9052 | ||
279 | help | ||
280 | This option enables support for on-chip LED drivers found | ||
281 | on Dialog Semiconductor DA9052-BC and DA9053-AA/Bx PMICs. | ||
282 | |||
262 | config LEDS_DAC124S085 | 283 | config LEDS_DAC124S085 |
263 | tristate "LED Support for DAC124S085 SPI DAC" | 284 | tristate "LED Support for DAC124S085 SPI DAC" |
264 | depends on LEDS_CLASS | 285 | depends on LEDS_CLASS |
@@ -471,4 +492,12 @@ config LEDS_TRIGGER_DEFAULT_ON | |||
471 | comment "iptables trigger is under Netfilter config (LED target)" | 492 | comment "iptables trigger is under Netfilter config (LED target)" |
472 | depends on LEDS_TRIGGERS | 493 | depends on LEDS_TRIGGERS |
473 | 494 | ||
495 | config LEDS_TRIGGER_TRANSIENT | ||
496 | tristate "LED Transient Trigger" | ||
497 | depends on LEDS_TRIGGERS | ||
498 | help | ||
499 | This allows one time activation of a transient state on | ||
500 | GPIO/PWM based hadrware. | ||
501 | If unsure, say Y. | ||
502 | |||
474 | endif # NEW_LEDS | 503 | endif # NEW_LEDS |
diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile index 890481cb09f6..f8958cd6cf6e 100644 --- a/drivers/leds/Makefile +++ b/drivers/leds/Makefile | |||
@@ -10,6 +10,7 @@ obj-$(CONFIG_LEDS_ATMEL_PWM) += leds-atmel-pwm.o | |||
10 | obj-$(CONFIG_LEDS_BD2802) += leds-bd2802.o | 10 | obj-$(CONFIG_LEDS_BD2802) += leds-bd2802.o |
11 | obj-$(CONFIG_LEDS_LOCOMO) += leds-locomo.o | 11 | obj-$(CONFIG_LEDS_LOCOMO) += leds-locomo.o |
12 | obj-$(CONFIG_LEDS_LM3530) += leds-lm3530.o | 12 | obj-$(CONFIG_LEDS_LM3530) += leds-lm3530.o |
13 | obj-$(CONFIG_LEDS_LM3533) += leds-lm3533.o | ||
13 | obj-$(CONFIG_LEDS_MIKROTIK_RB532) += leds-rb532.o | 14 | obj-$(CONFIG_LEDS_MIKROTIK_RB532) += leds-rb532.o |
14 | obj-$(CONFIG_LEDS_S3C24XX) += leds-s3c24xx.o | 15 | obj-$(CONFIG_LEDS_S3C24XX) += leds-s3c24xx.o |
15 | obj-$(CONFIG_LEDS_NET48XX) += leds-net48xx.o | 16 | obj-$(CONFIG_LEDS_NET48XX) += leds-net48xx.o |
@@ -31,6 +32,7 @@ obj-$(CONFIG_LEDS_FSG) += leds-fsg.o | |||
31 | obj-$(CONFIG_LEDS_PCA955X) += leds-pca955x.o | 32 | obj-$(CONFIG_LEDS_PCA955X) += leds-pca955x.o |
32 | obj-$(CONFIG_LEDS_PCA9633) += leds-pca9633.o | 33 | obj-$(CONFIG_LEDS_PCA9633) += leds-pca9633.o |
33 | obj-$(CONFIG_LEDS_DA903X) += leds-da903x.o | 34 | obj-$(CONFIG_LEDS_DA903X) += leds-da903x.o |
35 | obj-$(CONFIG_LEDS_DA9052) += leds-da9052.o | ||
34 | obj-$(CONFIG_LEDS_WM831X_STATUS) += leds-wm831x-status.o | 36 | obj-$(CONFIG_LEDS_WM831X_STATUS) += leds-wm831x-status.o |
35 | obj-$(CONFIG_LEDS_WM8350) += leds-wm8350.o | 37 | obj-$(CONFIG_LEDS_WM8350) += leds-wm8350.o |
36 | obj-$(CONFIG_LEDS_PWM) += leds-pwm.o | 38 | obj-$(CONFIG_LEDS_PWM) += leds-pwm.o |
@@ -56,3 +58,4 @@ obj-$(CONFIG_LEDS_TRIGGER_HEARTBEAT) += ledtrig-heartbeat.o | |||
56 | obj-$(CONFIG_LEDS_TRIGGER_BACKLIGHT) += ledtrig-backlight.o | 58 | obj-$(CONFIG_LEDS_TRIGGER_BACKLIGHT) += ledtrig-backlight.o |
57 | obj-$(CONFIG_LEDS_TRIGGER_GPIO) += ledtrig-gpio.o | 59 | obj-$(CONFIG_LEDS_TRIGGER_GPIO) += ledtrig-gpio.o |
58 | obj-$(CONFIG_LEDS_TRIGGER_DEFAULT_ON) += ledtrig-default-on.o | 60 | obj-$(CONFIG_LEDS_TRIGGER_DEFAULT_ON) += ledtrig-default-on.o |
61 | obj-$(CONFIG_LEDS_TRIGGER_TRANSIENT) += ledtrig-transient.o | ||
diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c index 5bff8439dc68..8ee92c81aec2 100644 --- a/drivers/leds/led-class.c +++ b/drivers/leds/led-class.c | |||
@@ -44,23 +44,18 @@ static ssize_t led_brightness_store(struct device *dev, | |||
44 | struct device_attribute *attr, const char *buf, size_t size) | 44 | struct device_attribute *attr, const char *buf, size_t size) |
45 | { | 45 | { |
46 | struct led_classdev *led_cdev = dev_get_drvdata(dev); | 46 | struct led_classdev *led_cdev = dev_get_drvdata(dev); |
47 | unsigned long state; | ||
47 | ssize_t ret = -EINVAL; | 48 | ssize_t ret = -EINVAL; |
48 | char *after; | ||
49 | unsigned long state = simple_strtoul(buf, &after, 10); | ||
50 | size_t count = after - buf; | ||
51 | 49 | ||
52 | if (isspace(*after)) | 50 | ret = kstrtoul(buf, 10, &state); |
53 | count++; | 51 | if (ret) |
52 | return ret; | ||
54 | 53 | ||
55 | if (count == size) { | 54 | if (state == LED_OFF) |
56 | ret = count; | 55 | led_trigger_remove(led_cdev); |
56 | led_set_brightness(led_cdev, state); | ||
57 | 57 | ||
58 | if (state == LED_OFF) | 58 | return size; |
59 | led_trigger_remove(led_cdev); | ||
60 | led_set_brightness(led_cdev, state); | ||
61 | } | ||
62 | |||
63 | return ret; | ||
64 | } | 59 | } |
65 | 60 | ||
66 | static ssize_t led_max_brightness_show(struct device *dev, | 61 | static ssize_t led_max_brightness_show(struct device *dev, |
diff --git a/drivers/leds/leds-da9052.c b/drivers/leds/leds-da9052.c new file mode 100644 index 000000000000..58a5244c437e --- /dev/null +++ b/drivers/leds/leds-da9052.c | |||
@@ -0,0 +1,214 @@ | |||
1 | /* | ||
2 | * LED Driver for Dialog DA9052 PMICs. | ||
3 | * | ||
4 | * Copyright(c) 2012 Dialog Semiconductor Ltd. | ||
5 | * | ||
6 | * Author: David Dajun Chen <dchen@diasemi.com> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify it | ||
9 | * under the terms of the GNU General Public License as published by the | ||
10 | * Free Software Foundation; either version 2 of the License, or (at your | ||
11 | * option) any later version. | ||
12 | * | ||
13 | */ | ||
14 | |||
15 | #include <linux/module.h> | ||
16 | #include <linux/kernel.h> | ||
17 | #include <linux/init.h> | ||
18 | #include <linux/platform_device.h> | ||
19 | #include <linux/leds.h> | ||
20 | #include <linux/workqueue.h> | ||
21 | #include <linux/slab.h> | ||
22 | |||
23 | #include <linux/mfd/da9052/reg.h> | ||
24 | #include <linux/mfd/da9052/da9052.h> | ||
25 | #include <linux/mfd/da9052/pdata.h> | ||
26 | |||
27 | #define DA9052_OPENDRAIN_OUTPUT 2 | ||
28 | #define DA9052_SET_HIGH_LVL_OUTPUT (1 << 3) | ||
29 | #define DA9052_MASK_UPPER_NIBBLE 0xF0 | ||
30 | #define DA9052_MASK_LOWER_NIBBLE 0x0F | ||
31 | #define DA9052_NIBBLE_SHIFT 4 | ||
32 | #define DA9052_MAX_BRIGHTNESS 0x5f | ||
33 | |||
34 | struct da9052_led { | ||
35 | struct led_classdev cdev; | ||
36 | struct work_struct work; | ||
37 | struct da9052 *da9052; | ||
38 | unsigned char led_index; | ||
39 | unsigned char id; | ||
40 | int brightness; | ||
41 | }; | ||
42 | |||
43 | static unsigned char led_reg[] = { | ||
44 | DA9052_LED_CONT_4_REG, | ||
45 | DA9052_LED_CONT_5_REG, | ||
46 | }; | ||
47 | |||
48 | static int da9052_set_led_brightness(struct da9052_led *led) | ||
49 | { | ||
50 | u8 val; | ||
51 | int error; | ||
52 | |||
53 | val = (led->brightness & 0x7f) | DA9052_LED_CONT_DIM; | ||
54 | |||
55 | error = da9052_reg_write(led->da9052, led_reg[led->led_index], val); | ||
56 | if (error < 0) | ||
57 | dev_err(led->da9052->dev, "Failed to set led brightness, %d\n", | ||
58 | error); | ||
59 | return error; | ||
60 | } | ||
61 | |||
62 | static void da9052_led_work(struct work_struct *work) | ||
63 | { | ||
64 | struct da9052_led *led = container_of(work, struct da9052_led, work); | ||
65 | |||
66 | da9052_set_led_brightness(led); | ||
67 | } | ||
68 | |||
69 | static void da9052_led_set(struct led_classdev *led_cdev, | ||
70 | enum led_brightness value) | ||
71 | { | ||
72 | struct da9052_led *led; | ||
73 | |||
74 | led = container_of(led_cdev, struct da9052_led, cdev); | ||
75 | led->brightness = value; | ||
76 | schedule_work(&led->work); | ||
77 | } | ||
78 | |||
79 | static int da9052_configure_leds(struct da9052 *da9052) | ||
80 | { | ||
81 | int error; | ||
82 | unsigned char register_value = DA9052_OPENDRAIN_OUTPUT | ||
83 | | DA9052_SET_HIGH_LVL_OUTPUT; | ||
84 | |||
85 | error = da9052_reg_update(da9052, DA9052_GPIO_14_15_REG, | ||
86 | DA9052_MASK_LOWER_NIBBLE, | ||
87 | register_value); | ||
88 | |||
89 | if (error < 0) { | ||
90 | dev_err(da9052->dev, "Failed to write GPIO 14-15 reg, %d\n", | ||
91 | error); | ||
92 | return error; | ||
93 | } | ||
94 | |||
95 | error = da9052_reg_update(da9052, DA9052_GPIO_14_15_REG, | ||
96 | DA9052_MASK_UPPER_NIBBLE, | ||
97 | register_value << DA9052_NIBBLE_SHIFT); | ||
98 | if (error < 0) | ||
99 | dev_err(da9052->dev, "Failed to write GPIO 14-15 reg, %d\n", | ||
100 | error); | ||
101 | |||
102 | return error; | ||
103 | } | ||
104 | |||
105 | static int __devinit da9052_led_probe(struct platform_device *pdev) | ||
106 | { | ||
107 | struct da9052_pdata *pdata; | ||
108 | struct da9052 *da9052; | ||
109 | struct led_platform_data *pled; | ||
110 | struct da9052_led *led = NULL; | ||
111 | int error = -ENODEV; | ||
112 | int i; | ||
113 | |||
114 | da9052 = dev_get_drvdata(pdev->dev.parent); | ||
115 | pdata = da9052->dev->platform_data; | ||
116 | if (pdata == NULL) { | ||
117 | dev_err(&pdev->dev, "No platform data\n"); | ||
118 | goto err; | ||
119 | } | ||
120 | |||
121 | pled = pdata->pled; | ||
122 | if (pled == NULL) { | ||
123 | dev_err(&pdev->dev, "No platform data for LED\n"); | ||
124 | goto err; | ||
125 | } | ||
126 | |||
127 | led = devm_kzalloc(&pdev->dev, | ||
128 | sizeof(struct da9052_led) * pled->num_leds, | ||
129 | GFP_KERNEL); | ||
130 | if (led == NULL) { | ||
131 | dev_err(&pdev->dev, "Failed to alloc memory\n"); | ||
132 | error = -ENOMEM; | ||
133 | goto err; | ||
134 | } | ||
135 | |||
136 | for (i = 0; i < pled->num_leds; i++) { | ||
137 | led[i].cdev.name = pled->leds[i].name; | ||
138 | led[i].cdev.brightness_set = da9052_led_set; | ||
139 | led[i].cdev.brightness = LED_OFF; | ||
140 | led[i].cdev.max_brightness = DA9052_MAX_BRIGHTNESS; | ||
141 | led[i].brightness = LED_OFF; | ||
142 | led[i].led_index = pled->leds[i].flags; | ||
143 | led[i].da9052 = dev_get_drvdata(pdev->dev.parent); | ||
144 | INIT_WORK(&led[i].work, da9052_led_work); | ||
145 | |||
146 | error = led_classdev_register(pdev->dev.parent, &led[i].cdev); | ||
147 | if (error) { | ||
148 | dev_err(&pdev->dev, "Failed to register led %d\n", | ||
149 | led[i].led_index); | ||
150 | goto err_register; | ||
151 | } | ||
152 | |||
153 | error = da9052_set_led_brightness(&led[i]); | ||
154 | if (error) { | ||
155 | dev_err(&pdev->dev, "Unable to init led %d\n", | ||
156 | led[i].led_index); | ||
157 | continue; | ||
158 | } | ||
159 | } | ||
160 | error = da9052_configure_leds(led->da9052); | ||
161 | if (error) { | ||
162 | dev_err(&pdev->dev, "Failed to configure GPIO LED%d\n", error); | ||
163 | goto err_register; | ||
164 | } | ||
165 | |||
166 | platform_set_drvdata(pdev, led); | ||
167 | |||
168 | return 0; | ||
169 | |||
170 | err_register: | ||
171 | for (i = i - 1; i >= 0; i--) { | ||
172 | led_classdev_unregister(&led[i].cdev); | ||
173 | cancel_work_sync(&led[i].work); | ||
174 | } | ||
175 | err: | ||
176 | return error; | ||
177 | } | ||
178 | |||
179 | static int __devexit da9052_led_remove(struct platform_device *pdev) | ||
180 | { | ||
181 | struct da9052_led *led = platform_get_drvdata(pdev); | ||
182 | struct da9052_pdata *pdata; | ||
183 | struct da9052 *da9052; | ||
184 | struct led_platform_data *pled; | ||
185 | int i; | ||
186 | |||
187 | da9052 = dev_get_drvdata(pdev->dev.parent); | ||
188 | pdata = da9052->dev->platform_data; | ||
189 | pled = pdata->pled; | ||
190 | |||
191 | for (i = 0; i < pled->num_leds; i++) { | ||
192 | led[i].brightness = 0; | ||
193 | da9052_set_led_brightness(&led[i]); | ||
194 | led_classdev_unregister(&led[i].cdev); | ||
195 | cancel_work_sync(&led[i].work); | ||
196 | } | ||
197 | |||
198 | return 0; | ||
199 | } | ||
200 | |||
201 | static struct platform_driver da9052_led_driver = { | ||
202 | .driver = { | ||
203 | .name = "da9052-leds", | ||
204 | .owner = THIS_MODULE, | ||
205 | }, | ||
206 | .probe = da9052_led_probe, | ||
207 | .remove = __devexit_p(da9052_led_remove), | ||
208 | }; | ||
209 | |||
210 | module_platform_driver(da9052_led_driver); | ||
211 | |||
212 | MODULE_AUTHOR("Dialog Semiconductor Ltd <dchen@diasemi.com>"); | ||
213 | MODULE_DESCRIPTION("LED driver for Dialog DA9052 PMIC"); | ||
214 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/leds/leds-lm3530.c b/drivers/leds/leds-lm3530.c index 968fd5fef4fc..84ba6de8039c 100644 --- a/drivers/leds/leds-lm3530.c +++ b/drivers/leds/leds-lm3530.c | |||
@@ -113,6 +113,18 @@ struct lm3530_data { | |||
113 | bool enable; | 113 | bool enable; |
114 | }; | 114 | }; |
115 | 115 | ||
116 | /* | ||
117 | * struct lm3530_als_data | ||
118 | * @config : value of ALS configuration register | ||
119 | * @imp_sel : value of ALS resistor select register | ||
120 | * @zone : values of ALS ZB(Zone Boundary) registers | ||
121 | */ | ||
122 | struct lm3530_als_data { | ||
123 | u8 config; | ||
124 | u8 imp_sel; | ||
125 | u8 zones[LM3530_ALS_ZB_MAX]; | ||
126 | }; | ||
127 | |||
116 | static const u8 lm3530_reg[LM3530_REG_MAX] = { | 128 | static const u8 lm3530_reg[LM3530_REG_MAX] = { |
117 | LM3530_GEN_CONFIG, | 129 | LM3530_GEN_CONFIG, |
118 | LM3530_ALS_CONFIG, | 130 | LM3530_ALS_CONFIG, |
@@ -141,29 +153,65 @@ static int lm3530_get_mode_from_str(const char *str) | |||
141 | return -1; | 153 | return -1; |
142 | } | 154 | } |
143 | 155 | ||
156 | static void lm3530_als_configure(struct lm3530_platform_data *pdata, | ||
157 | struct lm3530_als_data *als) | ||
158 | { | ||
159 | int i; | ||
160 | u32 als_vmin, als_vmax, als_vstep; | ||
161 | |||
162 | if (pdata->als_vmax == 0) { | ||
163 | pdata->als_vmin = 0; | ||
164 | pdata->als_vmax = LM3530_ALS_WINDOW_mV; | ||
165 | } | ||
166 | |||
167 | als_vmin = pdata->als_vmin; | ||
168 | als_vmax = pdata->als_vmax; | ||
169 | |||
170 | if ((als_vmax - als_vmin) > LM3530_ALS_WINDOW_mV) | ||
171 | pdata->als_vmax = als_vmax = als_vmin + LM3530_ALS_WINDOW_mV; | ||
172 | |||
173 | /* n zone boundary makes n+1 zones */ | ||
174 | als_vstep = (als_vmax - als_vmin) / (LM3530_ALS_ZB_MAX + 1); | ||
175 | |||
176 | for (i = 0; i < LM3530_ALS_ZB_MAX; i++) | ||
177 | als->zones[i] = (((als_vmin + LM3530_ALS_OFFSET_mV) + | ||
178 | als_vstep + (i * als_vstep)) * LED_FULL) / 1000; | ||
179 | |||
180 | als->config = | ||
181 | (pdata->als_avrg_time << LM3530_ALS_AVG_TIME_SHIFT) | | ||
182 | (LM3530_ENABLE_ALS) | | ||
183 | (pdata->als_input_mode << LM3530_ALS_SEL_SHIFT); | ||
184 | |||
185 | als->imp_sel = | ||
186 | (pdata->als1_resistor_sel << LM3530_ALS1_IMP_SHIFT) | | ||
187 | (pdata->als2_resistor_sel << LM3530_ALS2_IMP_SHIFT); | ||
188 | } | ||
189 | |||
144 | static int lm3530_init_registers(struct lm3530_data *drvdata) | 190 | static int lm3530_init_registers(struct lm3530_data *drvdata) |
145 | { | 191 | { |
146 | int ret = 0; | 192 | int ret = 0; |
147 | int i; | 193 | int i; |
148 | u8 gen_config; | 194 | u8 gen_config; |
149 | u8 als_config = 0; | ||
150 | u8 brt_ramp; | 195 | u8 brt_ramp; |
151 | u8 als_imp_sel = 0; | ||
152 | u8 brightness; | 196 | u8 brightness; |
153 | u8 reg_val[LM3530_REG_MAX]; | 197 | u8 reg_val[LM3530_REG_MAX]; |
154 | u8 zones[LM3530_ALS_ZB_MAX]; | ||
155 | u32 als_vmin, als_vmax, als_vstep; | ||
156 | struct lm3530_platform_data *pdata = drvdata->pdata; | 198 | struct lm3530_platform_data *pdata = drvdata->pdata; |
157 | struct i2c_client *client = drvdata->client; | 199 | struct i2c_client *client = drvdata->client; |
158 | struct lm3530_pwm_data *pwm = &pdata->pwm_data; | 200 | struct lm3530_pwm_data *pwm = &pdata->pwm_data; |
201 | struct lm3530_als_data als; | ||
202 | |||
203 | memset(&als, 0, sizeof(struct lm3530_als_data)); | ||
159 | 204 | ||
160 | gen_config = (pdata->brt_ramp_law << LM3530_RAMP_LAW_SHIFT) | | 205 | gen_config = (pdata->brt_ramp_law << LM3530_RAMP_LAW_SHIFT) | |
161 | ((pdata->max_current & 7) << LM3530_MAX_CURR_SHIFT); | 206 | ((pdata->max_current & 7) << LM3530_MAX_CURR_SHIFT); |
162 | 207 | ||
163 | switch (drvdata->mode) { | 208 | switch (drvdata->mode) { |
164 | case LM3530_BL_MODE_MANUAL: | 209 | case LM3530_BL_MODE_MANUAL: |
210 | gen_config |= LM3530_ENABLE_I2C; | ||
211 | break; | ||
165 | case LM3530_BL_MODE_ALS: | 212 | case LM3530_BL_MODE_ALS: |
166 | gen_config |= LM3530_ENABLE_I2C; | 213 | gen_config |= LM3530_ENABLE_I2C; |
214 | lm3530_als_configure(pdata, &als); | ||
167 | break; | 215 | break; |
168 | case LM3530_BL_MODE_PWM: | 216 | case LM3530_BL_MODE_PWM: |
169 | gen_config |= LM3530_ENABLE_PWM | LM3530_ENABLE_PWM_SIMPLE | | 217 | gen_config |= LM3530_ENABLE_PWM | LM3530_ENABLE_PWM_SIMPLE | |
@@ -171,38 +219,6 @@ static int lm3530_init_registers(struct lm3530_data *drvdata) | |||
171 | break; | 219 | break; |
172 | } | 220 | } |
173 | 221 | ||
174 | if (drvdata->mode == LM3530_BL_MODE_ALS) { | ||
175 | if (pdata->als_vmax == 0) { | ||
176 | pdata->als_vmin = 0; | ||
177 | pdata->als_vmax = LM3530_ALS_WINDOW_mV; | ||
178 | } | ||
179 | |||
180 | als_vmin = pdata->als_vmin; | ||
181 | als_vmax = pdata->als_vmax; | ||
182 | |||
183 | if ((als_vmax - als_vmin) > LM3530_ALS_WINDOW_mV) | ||
184 | pdata->als_vmax = als_vmax = | ||
185 | als_vmin + LM3530_ALS_WINDOW_mV; | ||
186 | |||
187 | /* n zone boundary makes n+1 zones */ | ||
188 | als_vstep = (als_vmax - als_vmin) / (LM3530_ALS_ZB_MAX + 1); | ||
189 | |||
190 | for (i = 0; i < LM3530_ALS_ZB_MAX; i++) | ||
191 | zones[i] = (((als_vmin + LM3530_ALS_OFFSET_mV) + | ||
192 | als_vstep + (i * als_vstep)) * LED_FULL) | ||
193 | / 1000; | ||
194 | |||
195 | als_config = | ||
196 | (pdata->als_avrg_time << LM3530_ALS_AVG_TIME_SHIFT) | | ||
197 | (LM3530_ENABLE_ALS) | | ||
198 | (pdata->als_input_mode << LM3530_ALS_SEL_SHIFT); | ||
199 | |||
200 | als_imp_sel = | ||
201 | (pdata->als1_resistor_sel << LM3530_ALS1_IMP_SHIFT) | | ||
202 | (pdata->als2_resistor_sel << LM3530_ALS2_IMP_SHIFT); | ||
203 | |||
204 | } | ||
205 | |||
206 | brt_ramp = (pdata->brt_ramp_fall << LM3530_BRT_RAMP_FALL_SHIFT) | | 222 | brt_ramp = (pdata->brt_ramp_fall << LM3530_BRT_RAMP_FALL_SHIFT) | |
207 | (pdata->brt_ramp_rise << LM3530_BRT_RAMP_RISE_SHIFT); | 223 | (pdata->brt_ramp_rise << LM3530_BRT_RAMP_RISE_SHIFT); |
208 | 224 | ||
@@ -215,14 +231,14 @@ static int lm3530_init_registers(struct lm3530_data *drvdata) | |||
215 | brightness = drvdata->led_dev.max_brightness; | 231 | brightness = drvdata->led_dev.max_brightness; |
216 | 232 | ||
217 | reg_val[0] = gen_config; /* LM3530_GEN_CONFIG */ | 233 | reg_val[0] = gen_config; /* LM3530_GEN_CONFIG */ |
218 | reg_val[1] = als_config; /* LM3530_ALS_CONFIG */ | 234 | reg_val[1] = als.config; /* LM3530_ALS_CONFIG */ |
219 | reg_val[2] = brt_ramp; /* LM3530_BRT_RAMP_RATE */ | 235 | reg_val[2] = brt_ramp; /* LM3530_BRT_RAMP_RATE */ |
220 | reg_val[3] = als_imp_sel; /* LM3530_ALS_IMP_SELECT */ | 236 | reg_val[3] = als.imp_sel; /* LM3530_ALS_IMP_SELECT */ |
221 | reg_val[4] = brightness; /* LM3530_BRT_CTRL_REG */ | 237 | reg_val[4] = brightness; /* LM3530_BRT_CTRL_REG */ |
222 | reg_val[5] = zones[0]; /* LM3530_ALS_ZB0_REG */ | 238 | reg_val[5] = als.zones[0]; /* LM3530_ALS_ZB0_REG */ |
223 | reg_val[6] = zones[1]; /* LM3530_ALS_ZB1_REG */ | 239 | reg_val[6] = als.zones[1]; /* LM3530_ALS_ZB1_REG */ |
224 | reg_val[7] = zones[2]; /* LM3530_ALS_ZB2_REG */ | 240 | reg_val[7] = als.zones[2]; /* LM3530_ALS_ZB2_REG */ |
225 | reg_val[8] = zones[3]; /* LM3530_ALS_ZB3_REG */ | 241 | reg_val[8] = als.zones[3]; /* LM3530_ALS_ZB3_REG */ |
226 | reg_val[9] = LM3530_DEF_ZT_0; /* LM3530_ALS_Z0T_REG */ | 242 | reg_val[9] = LM3530_DEF_ZT_0; /* LM3530_ALS_Z0T_REG */ |
227 | reg_val[10] = LM3530_DEF_ZT_1; /* LM3530_ALS_Z1T_REG */ | 243 | reg_val[10] = LM3530_DEF_ZT_1; /* LM3530_ALS_Z1T_REG */ |
228 | reg_val[11] = LM3530_DEF_ZT_2; /* LM3530_ALS_Z2T_REG */ | 244 | reg_val[11] = LM3530_DEF_ZT_2; /* LM3530_ALS_Z2T_REG */ |
diff --git a/drivers/leds/leds-lm3533.c b/drivers/leds/leds-lm3533.c new file mode 100644 index 000000000000..f56b6e7ffdac --- /dev/null +++ b/drivers/leds/leds-lm3533.c | |||
@@ -0,0 +1,785 @@ | |||
1 | /* | ||
2 | * leds-lm3533.c -- LM3533 LED driver | ||
3 | * | ||
4 | * Copyright (C) 2011-2012 Texas Instruments | ||
5 | * | ||
6 | * Author: Johan Hovold <jhovold@gmail.com> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify it | ||
9 | * under the terms of the GNU General Public License as published by the | ||
10 | * Free Software Foundation; either version 2 of the License, or (at your | ||
11 | * option) any later version. | ||
12 | */ | ||
13 | |||
14 | #include <linux/module.h> | ||
15 | #include <linux/init.h> | ||
16 | #include <linux/leds.h> | ||
17 | #include <linux/mfd/core.h> | ||
18 | #include <linux/mutex.h> | ||
19 | #include <linux/platform_device.h> | ||
20 | #include <linux/slab.h> | ||
21 | #include <linux/workqueue.h> | ||
22 | |||
23 | #include <linux/mfd/lm3533.h> | ||
24 | |||
25 | |||
26 | #define LM3533_LVCTRLBANK_MIN 2 | ||
27 | #define LM3533_LVCTRLBANK_MAX 5 | ||
28 | #define LM3533_LVCTRLBANK_COUNT 4 | ||
29 | #define LM3533_RISEFALLTIME_MAX 7 | ||
30 | #define LM3533_ALS_CHANNEL_LV_MIN 1 | ||
31 | #define LM3533_ALS_CHANNEL_LV_MAX 2 | ||
32 | |||
33 | #define LM3533_REG_CTRLBANK_BCONF_BASE 0x1b | ||
34 | #define LM3533_REG_PATTERN_ENABLE 0x28 | ||
35 | #define LM3533_REG_PATTERN_LOW_TIME_BASE 0x71 | ||
36 | #define LM3533_REG_PATTERN_HIGH_TIME_BASE 0x72 | ||
37 | #define LM3533_REG_PATTERN_RISETIME_BASE 0x74 | ||
38 | #define LM3533_REG_PATTERN_FALLTIME_BASE 0x75 | ||
39 | |||
40 | #define LM3533_REG_PATTERN_STEP 0x10 | ||
41 | |||
42 | #define LM3533_REG_CTRLBANK_BCONF_MAPPING_MASK 0x04 | ||
43 | #define LM3533_REG_CTRLBANK_BCONF_ALS_EN_MASK 0x02 | ||
44 | #define LM3533_REG_CTRLBANK_BCONF_ALS_CHANNEL_MASK 0x01 | ||
45 | |||
46 | #define LM3533_LED_FLAG_PATTERN_ENABLE 1 | ||
47 | |||
48 | |||
49 | struct lm3533_led { | ||
50 | struct lm3533 *lm3533; | ||
51 | struct lm3533_ctrlbank cb; | ||
52 | struct led_classdev cdev; | ||
53 | int id; | ||
54 | |||
55 | struct mutex mutex; | ||
56 | unsigned long flags; | ||
57 | |||
58 | struct work_struct work; | ||
59 | u8 new_brightness; | ||
60 | }; | ||
61 | |||
62 | |||
63 | static inline struct lm3533_led *to_lm3533_led(struct led_classdev *cdev) | ||
64 | { | ||
65 | return container_of(cdev, struct lm3533_led, cdev); | ||
66 | } | ||
67 | |||
68 | static inline int lm3533_led_get_ctrlbank_id(struct lm3533_led *led) | ||
69 | { | ||
70 | return led->id + 2; | ||
71 | } | ||
72 | |||
73 | static inline u8 lm3533_led_get_lv_reg(struct lm3533_led *led, u8 base) | ||
74 | { | ||
75 | return base + led->id; | ||
76 | } | ||
77 | |||
78 | static inline u8 lm3533_led_get_pattern(struct lm3533_led *led) | ||
79 | { | ||
80 | return led->id; | ||
81 | } | ||
82 | |||
83 | static inline u8 lm3533_led_get_pattern_reg(struct lm3533_led *led, | ||
84 | u8 base) | ||
85 | { | ||
86 | return base + lm3533_led_get_pattern(led) * LM3533_REG_PATTERN_STEP; | ||
87 | } | ||
88 | |||
89 | static int lm3533_led_pattern_enable(struct lm3533_led *led, int enable) | ||
90 | { | ||
91 | u8 mask; | ||
92 | u8 val; | ||
93 | int pattern; | ||
94 | int state; | ||
95 | int ret = 0; | ||
96 | |||
97 | dev_dbg(led->cdev.dev, "%s - %d\n", __func__, enable); | ||
98 | |||
99 | mutex_lock(&led->mutex); | ||
100 | |||
101 | state = test_bit(LM3533_LED_FLAG_PATTERN_ENABLE, &led->flags); | ||
102 | if ((enable && state) || (!enable && !state)) | ||
103 | goto out; | ||
104 | |||
105 | pattern = lm3533_led_get_pattern(led); | ||
106 | mask = 1 << (2 * pattern); | ||
107 | |||
108 | if (enable) | ||
109 | val = mask; | ||
110 | else | ||
111 | val = 0; | ||
112 | |||
113 | ret = lm3533_update(led->lm3533, LM3533_REG_PATTERN_ENABLE, val, mask); | ||
114 | if (ret) { | ||
115 | dev_err(led->cdev.dev, "failed to enable pattern %d (%d)\n", | ||
116 | pattern, enable); | ||
117 | goto out; | ||
118 | } | ||
119 | |||
120 | __change_bit(LM3533_LED_FLAG_PATTERN_ENABLE, &led->flags); | ||
121 | out: | ||
122 | mutex_unlock(&led->mutex); | ||
123 | |||
124 | return ret; | ||
125 | } | ||
126 | |||
127 | static void lm3533_led_work(struct work_struct *work) | ||
128 | { | ||
129 | struct lm3533_led *led = container_of(work, struct lm3533_led, work); | ||
130 | |||
131 | dev_dbg(led->cdev.dev, "%s - %u\n", __func__, led->new_brightness); | ||
132 | |||
133 | if (led->new_brightness == 0) | ||
134 | lm3533_led_pattern_enable(led, 0); /* disable blink */ | ||
135 | |||
136 | lm3533_ctrlbank_set_brightness(&led->cb, led->new_brightness); | ||
137 | } | ||
138 | |||
139 | static void lm3533_led_set(struct led_classdev *cdev, | ||
140 | enum led_brightness value) | ||
141 | { | ||
142 | struct lm3533_led *led = to_lm3533_led(cdev); | ||
143 | |||
144 | dev_dbg(led->cdev.dev, "%s - %d\n", __func__, value); | ||
145 | |||
146 | led->new_brightness = value; | ||
147 | schedule_work(&led->work); | ||
148 | } | ||
149 | |||
150 | static enum led_brightness lm3533_led_get(struct led_classdev *cdev) | ||
151 | { | ||
152 | struct lm3533_led *led = to_lm3533_led(cdev); | ||
153 | u8 val; | ||
154 | int ret; | ||
155 | |||
156 | ret = lm3533_ctrlbank_get_brightness(&led->cb, &val); | ||
157 | if (ret) | ||
158 | return ret; | ||
159 | |||
160 | dev_dbg(led->cdev.dev, "%s - %u\n", __func__, val); | ||
161 | |||
162 | return val; | ||
163 | } | ||
164 | |||
165 | /* Pattern generator defines (delays in us). */ | ||
166 | #define LM3533_LED_DELAY1_VMIN 0x00 | ||
167 | #define LM3533_LED_DELAY2_VMIN 0x3d | ||
168 | #define LM3533_LED_DELAY3_VMIN 0x80 | ||
169 | |||
170 | #define LM3533_LED_DELAY1_VMAX (LM3533_LED_DELAY2_VMIN - 1) | ||
171 | #define LM3533_LED_DELAY2_VMAX (LM3533_LED_DELAY3_VMIN - 1) | ||
172 | #define LM3533_LED_DELAY3_VMAX 0xff | ||
173 | |||
174 | #define LM3533_LED_DELAY1_TMIN 16384U | ||
175 | #define LM3533_LED_DELAY2_TMIN 1130496U | ||
176 | #define LM3533_LED_DELAY3_TMIN 10305536U | ||
177 | |||
178 | #define LM3533_LED_DELAY1_TMAX 999424U | ||
179 | #define LM3533_LED_DELAY2_TMAX 9781248U | ||
180 | #define LM3533_LED_DELAY3_TMAX 76890112U | ||
181 | |||
182 | /* t_step = (t_max - t_min) / (v_max - v_min) */ | ||
183 | #define LM3533_LED_DELAY1_TSTEP 16384 | ||
184 | #define LM3533_LED_DELAY2_TSTEP 131072 | ||
185 | #define LM3533_LED_DELAY3_TSTEP 524288 | ||
186 | |||
187 | /* Delay limits for hardware accelerated blinking (in ms). */ | ||
188 | #define LM3533_LED_DELAY_ON_MAX \ | ||
189 | ((LM3533_LED_DELAY2_TMAX + LM3533_LED_DELAY2_TSTEP / 2) / 1000) | ||
190 | #define LM3533_LED_DELAY_OFF_MAX \ | ||
191 | ((LM3533_LED_DELAY3_TMAX + LM3533_LED_DELAY3_TSTEP / 2) / 1000) | ||
192 | |||
193 | /* | ||
194 | * Returns linear map of *t from [t_min,t_max] to [v_min,v_max] with a step | ||
195 | * size of t_step, where | ||
196 | * | ||
197 | * t_step = (t_max - t_min) / (v_max - v_min) | ||
198 | * | ||
199 | * and updates *t to reflect the mapped value. | ||
200 | */ | ||
201 | static u8 time_to_val(unsigned *t, unsigned t_min, unsigned t_step, | ||
202 | u8 v_min, u8 v_max) | ||
203 | { | ||
204 | unsigned val; | ||
205 | |||
206 | val = (*t + t_step / 2 - t_min) / t_step + v_min; | ||
207 | |||
208 | *t = t_step * (val - v_min) + t_min; | ||
209 | |||
210 | return (u8)val; | ||
211 | } | ||
212 | |||
213 | /* | ||
214 | * Returns time code corresponding to *delay (in ms) and updates *delay to | ||
215 | * reflect actual hardware delay. | ||
216 | * | ||
217 | * Hardware supports 256 discrete delay times, divided into three groups with | ||
218 | * the following ranges and step-sizes: | ||
219 | * | ||
220 | * [ 16, 999] [0x00, 0x3e] step 16 ms | ||
221 | * [ 1130, 9781] [0x3d, 0x7f] step 131 ms | ||
222 | * [10306, 76890] [0x80, 0xff] step 524 ms | ||
223 | * | ||
224 | * Note that delay group 3 is only available for delay_off. | ||
225 | */ | ||
226 | static u8 lm3533_led_get_hw_delay(unsigned *delay) | ||
227 | { | ||
228 | unsigned t; | ||
229 | u8 val; | ||
230 | |||
231 | t = *delay * 1000; | ||
232 | |||
233 | if (t >= (LM3533_LED_DELAY2_TMAX + LM3533_LED_DELAY3_TMIN) / 2) { | ||
234 | t = clamp(t, LM3533_LED_DELAY3_TMIN, LM3533_LED_DELAY3_TMAX); | ||
235 | val = time_to_val(&t, LM3533_LED_DELAY3_TMIN, | ||
236 | LM3533_LED_DELAY3_TSTEP, | ||
237 | LM3533_LED_DELAY3_VMIN, | ||
238 | LM3533_LED_DELAY3_VMAX); | ||
239 | } else if (t >= (LM3533_LED_DELAY1_TMAX + LM3533_LED_DELAY2_TMIN) / 2) { | ||
240 | t = clamp(t, LM3533_LED_DELAY2_TMIN, LM3533_LED_DELAY2_TMAX); | ||
241 | val = time_to_val(&t, LM3533_LED_DELAY2_TMIN, | ||
242 | LM3533_LED_DELAY2_TSTEP, | ||
243 | LM3533_LED_DELAY2_VMIN, | ||
244 | LM3533_LED_DELAY2_VMAX); | ||
245 | } else { | ||
246 | t = clamp(t, LM3533_LED_DELAY1_TMIN, LM3533_LED_DELAY1_TMAX); | ||
247 | val = time_to_val(&t, LM3533_LED_DELAY1_TMIN, | ||
248 | LM3533_LED_DELAY1_TSTEP, | ||
249 | LM3533_LED_DELAY1_VMIN, | ||
250 | LM3533_LED_DELAY1_VMAX); | ||
251 | } | ||
252 | |||
253 | *delay = (t + 500) / 1000; | ||
254 | |||
255 | return val; | ||
256 | } | ||
257 | |||
258 | /* | ||
259 | * Set delay register base to *delay (in ms) and update *delay to reflect | ||
260 | * actual hardware delay used. | ||
261 | */ | ||
262 | static u8 lm3533_led_delay_set(struct lm3533_led *led, u8 base, | ||
263 | unsigned long *delay) | ||
264 | { | ||
265 | unsigned t; | ||
266 | u8 val; | ||
267 | u8 reg; | ||
268 | int ret; | ||
269 | |||
270 | t = (unsigned)*delay; | ||
271 | |||
272 | /* Delay group 3 is only available for low time (delay off). */ | ||
273 | if (base != LM3533_REG_PATTERN_LOW_TIME_BASE) | ||
274 | t = min(t, LM3533_LED_DELAY2_TMAX / 1000); | ||
275 | |||
276 | val = lm3533_led_get_hw_delay(&t); | ||
277 | |||
278 | dev_dbg(led->cdev.dev, "%s - %lu: %u (0x%02x)\n", __func__, | ||
279 | *delay, t, val); | ||
280 | reg = lm3533_led_get_pattern_reg(led, base); | ||
281 | ret = lm3533_write(led->lm3533, reg, val); | ||
282 | if (ret) | ||
283 | dev_err(led->cdev.dev, "failed to set delay (%02x)\n", reg); | ||
284 | |||
285 | *delay = t; | ||
286 | |||
287 | return ret; | ||
288 | } | ||
289 | |||
290 | static int lm3533_led_delay_on_set(struct lm3533_led *led, unsigned long *t) | ||
291 | { | ||
292 | return lm3533_led_delay_set(led, LM3533_REG_PATTERN_HIGH_TIME_BASE, t); | ||
293 | } | ||
294 | |||
295 | static int lm3533_led_delay_off_set(struct lm3533_led *led, unsigned long *t) | ||
296 | { | ||
297 | return lm3533_led_delay_set(led, LM3533_REG_PATTERN_LOW_TIME_BASE, t); | ||
298 | } | ||
299 | |||
300 | static int lm3533_led_blink_set(struct led_classdev *cdev, | ||
301 | unsigned long *delay_on, | ||
302 | unsigned long *delay_off) | ||
303 | { | ||
304 | struct lm3533_led *led = to_lm3533_led(cdev); | ||
305 | int ret; | ||
306 | |||
307 | dev_dbg(led->cdev.dev, "%s - on = %lu, off = %lu\n", __func__, | ||
308 | *delay_on, *delay_off); | ||
309 | |||
310 | if (*delay_on > LM3533_LED_DELAY_ON_MAX || | ||
311 | *delay_off > LM3533_LED_DELAY_OFF_MAX) | ||
312 | return -EINVAL; | ||
313 | |||
314 | if (*delay_on == 0 && *delay_off == 0) { | ||
315 | *delay_on = 500; | ||
316 | *delay_off = 500; | ||
317 | } | ||
318 | |||
319 | ret = lm3533_led_delay_on_set(led, delay_on); | ||
320 | if (ret) | ||
321 | return ret; | ||
322 | |||
323 | ret = lm3533_led_delay_off_set(led, delay_off); | ||
324 | if (ret) | ||
325 | return ret; | ||
326 | |||
327 | return lm3533_led_pattern_enable(led, 1); | ||
328 | } | ||
329 | |||
330 | static ssize_t show_id(struct device *dev, | ||
331 | struct device_attribute *attr, char *buf) | ||
332 | { | ||
333 | struct led_classdev *led_cdev = dev_get_drvdata(dev); | ||
334 | struct lm3533_led *led = to_lm3533_led(led_cdev); | ||
335 | |||
336 | return scnprintf(buf, PAGE_SIZE, "%d\n", led->id); | ||
337 | } | ||
338 | |||
339 | /* | ||
340 | * Pattern generator rise/fall times: | ||
341 | * | ||
342 | * 0 - 2048 us (default) | ||
343 | * 1 - 262 ms | ||
344 | * 2 - 524 ms | ||
345 | * 3 - 1.049 s | ||
346 | * 4 - 2.097 s | ||
347 | * 5 - 4.194 s | ||
348 | * 6 - 8.389 s | ||
349 | * 7 - 16.78 s | ||
350 | */ | ||
351 | static ssize_t show_risefalltime(struct device *dev, | ||
352 | struct device_attribute *attr, | ||
353 | char *buf, u8 base) | ||
354 | { | ||
355 | struct led_classdev *led_cdev = dev_get_drvdata(dev); | ||
356 | struct lm3533_led *led = to_lm3533_led(led_cdev); | ||
357 | ssize_t ret; | ||
358 | u8 reg; | ||
359 | u8 val; | ||
360 | |||
361 | reg = lm3533_led_get_pattern_reg(led, base); | ||
362 | ret = lm3533_read(led->lm3533, reg, &val); | ||
363 | if (ret) | ||
364 | return ret; | ||
365 | |||
366 | return scnprintf(buf, PAGE_SIZE, "%x\n", val); | ||
367 | } | ||
368 | |||
369 | static ssize_t show_risetime(struct device *dev, | ||
370 | struct device_attribute *attr, char *buf) | ||
371 | { | ||
372 | return show_risefalltime(dev, attr, buf, | ||
373 | LM3533_REG_PATTERN_RISETIME_BASE); | ||
374 | } | ||
375 | |||
376 | static ssize_t show_falltime(struct device *dev, | ||
377 | struct device_attribute *attr, char *buf) | ||
378 | { | ||
379 | return show_risefalltime(dev, attr, buf, | ||
380 | LM3533_REG_PATTERN_FALLTIME_BASE); | ||
381 | } | ||
382 | |||
383 | static ssize_t store_risefalltime(struct device *dev, | ||
384 | struct device_attribute *attr, | ||
385 | const char *buf, size_t len, u8 base) | ||
386 | { | ||
387 | struct led_classdev *led_cdev = dev_get_drvdata(dev); | ||
388 | struct lm3533_led *led = to_lm3533_led(led_cdev); | ||
389 | u8 val; | ||
390 | u8 reg; | ||
391 | int ret; | ||
392 | |||
393 | if (kstrtou8(buf, 0, &val) || val > LM3533_RISEFALLTIME_MAX) | ||
394 | return -EINVAL; | ||
395 | |||
396 | reg = lm3533_led_get_pattern_reg(led, base); | ||
397 | ret = lm3533_write(led->lm3533, reg, val); | ||
398 | if (ret) | ||
399 | return ret; | ||
400 | |||
401 | return len; | ||
402 | } | ||
403 | |||
404 | static ssize_t store_risetime(struct device *dev, | ||
405 | struct device_attribute *attr, | ||
406 | const char *buf, size_t len) | ||
407 | { | ||
408 | return store_risefalltime(dev, attr, buf, len, | ||
409 | LM3533_REG_PATTERN_RISETIME_BASE); | ||
410 | } | ||
411 | |||
412 | static ssize_t store_falltime(struct device *dev, | ||
413 | struct device_attribute *attr, | ||
414 | const char *buf, size_t len) | ||
415 | { | ||
416 | return store_risefalltime(dev, attr, buf, len, | ||
417 | LM3533_REG_PATTERN_FALLTIME_BASE); | ||
418 | } | ||
419 | |||
420 | static ssize_t show_als_channel(struct device *dev, | ||
421 | struct device_attribute *attr, char *buf) | ||
422 | { | ||
423 | struct led_classdev *led_cdev = dev_get_drvdata(dev); | ||
424 | struct lm3533_led *led = to_lm3533_led(led_cdev); | ||
425 | unsigned channel; | ||
426 | u8 reg; | ||
427 | u8 val; | ||
428 | int ret; | ||
429 | |||
430 | reg = lm3533_led_get_lv_reg(led, LM3533_REG_CTRLBANK_BCONF_BASE); | ||
431 | ret = lm3533_read(led->lm3533, reg, &val); | ||
432 | if (ret) | ||
433 | return ret; | ||
434 | |||
435 | channel = (val & LM3533_REG_CTRLBANK_BCONF_ALS_CHANNEL_MASK) + 1; | ||
436 | |||
437 | return scnprintf(buf, PAGE_SIZE, "%u\n", channel); | ||
438 | } | ||
439 | |||
440 | static ssize_t store_als_channel(struct device *dev, | ||
441 | struct device_attribute *attr, | ||
442 | const char *buf, size_t len) | ||
443 | { | ||
444 | struct led_classdev *led_cdev = dev_get_drvdata(dev); | ||
445 | struct lm3533_led *led = to_lm3533_led(led_cdev); | ||
446 | unsigned channel; | ||
447 | u8 reg; | ||
448 | u8 val; | ||
449 | u8 mask; | ||
450 | int ret; | ||
451 | |||
452 | if (kstrtouint(buf, 0, &channel)) | ||
453 | return -EINVAL; | ||
454 | |||
455 | if (channel < LM3533_ALS_CHANNEL_LV_MIN || | ||
456 | channel > LM3533_ALS_CHANNEL_LV_MAX) | ||
457 | return -EINVAL; | ||
458 | |||
459 | reg = lm3533_led_get_lv_reg(led, LM3533_REG_CTRLBANK_BCONF_BASE); | ||
460 | mask = LM3533_REG_CTRLBANK_BCONF_ALS_CHANNEL_MASK; | ||
461 | val = channel - 1; | ||
462 | |||
463 | ret = lm3533_update(led->lm3533, reg, val, mask); | ||
464 | if (ret) | ||
465 | return ret; | ||
466 | |||
467 | return len; | ||
468 | } | ||
469 | |||
470 | static ssize_t show_als_en(struct device *dev, | ||
471 | struct device_attribute *attr, char *buf) | ||
472 | { | ||
473 | struct led_classdev *led_cdev = dev_get_drvdata(dev); | ||
474 | struct lm3533_led *led = to_lm3533_led(led_cdev); | ||
475 | bool enable; | ||
476 | u8 reg; | ||
477 | u8 val; | ||
478 | int ret; | ||
479 | |||
480 | reg = lm3533_led_get_lv_reg(led, LM3533_REG_CTRLBANK_BCONF_BASE); | ||
481 | ret = lm3533_read(led->lm3533, reg, &val); | ||
482 | if (ret) | ||
483 | return ret; | ||
484 | |||
485 | enable = val & LM3533_REG_CTRLBANK_BCONF_ALS_EN_MASK; | ||
486 | |||
487 | return scnprintf(buf, PAGE_SIZE, "%d\n", enable); | ||
488 | } | ||
489 | |||
490 | static ssize_t store_als_en(struct device *dev, | ||
491 | struct device_attribute *attr, | ||
492 | const char *buf, size_t len) | ||
493 | { | ||
494 | struct led_classdev *led_cdev = dev_get_drvdata(dev); | ||
495 | struct lm3533_led *led = to_lm3533_led(led_cdev); | ||
496 | unsigned enable; | ||
497 | u8 reg; | ||
498 | u8 mask; | ||
499 | u8 val; | ||
500 | int ret; | ||
501 | |||
502 | if (kstrtouint(buf, 0, &enable)) | ||
503 | return -EINVAL; | ||
504 | |||
505 | reg = lm3533_led_get_lv_reg(led, LM3533_REG_CTRLBANK_BCONF_BASE); | ||
506 | mask = LM3533_REG_CTRLBANK_BCONF_ALS_EN_MASK; | ||
507 | |||
508 | if (enable) | ||
509 | val = mask; | ||
510 | else | ||
511 | val = 0; | ||
512 | |||
513 | ret = lm3533_update(led->lm3533, reg, val, mask); | ||
514 | if (ret) | ||
515 | return ret; | ||
516 | |||
517 | return len; | ||
518 | } | ||
519 | |||
520 | static ssize_t show_linear(struct device *dev, | ||
521 | struct device_attribute *attr, char *buf) | ||
522 | { | ||
523 | struct led_classdev *led_cdev = dev_get_drvdata(dev); | ||
524 | struct lm3533_led *led = to_lm3533_led(led_cdev); | ||
525 | u8 reg; | ||
526 | u8 val; | ||
527 | int linear; | ||
528 | int ret; | ||
529 | |||
530 | reg = lm3533_led_get_lv_reg(led, LM3533_REG_CTRLBANK_BCONF_BASE); | ||
531 | ret = lm3533_read(led->lm3533, reg, &val); | ||
532 | if (ret) | ||
533 | return ret; | ||
534 | |||
535 | if (val & LM3533_REG_CTRLBANK_BCONF_MAPPING_MASK) | ||
536 | linear = 1; | ||
537 | else | ||
538 | linear = 0; | ||
539 | |||
540 | return scnprintf(buf, PAGE_SIZE, "%x\n", linear); | ||
541 | } | ||
542 | |||
543 | static ssize_t store_linear(struct device *dev, | ||
544 | struct device_attribute *attr, | ||
545 | const char *buf, size_t len) | ||
546 | { | ||
547 | struct led_classdev *led_cdev = dev_get_drvdata(dev); | ||
548 | struct lm3533_led *led = to_lm3533_led(led_cdev); | ||
549 | unsigned long linear; | ||
550 | u8 reg; | ||
551 | u8 mask; | ||
552 | u8 val; | ||
553 | int ret; | ||
554 | |||
555 | if (kstrtoul(buf, 0, &linear)) | ||
556 | return -EINVAL; | ||
557 | |||
558 | reg = lm3533_led_get_lv_reg(led, LM3533_REG_CTRLBANK_BCONF_BASE); | ||
559 | mask = LM3533_REG_CTRLBANK_BCONF_MAPPING_MASK; | ||
560 | |||
561 | if (linear) | ||
562 | val = mask; | ||
563 | else | ||
564 | val = 0; | ||
565 | |||
566 | ret = lm3533_update(led->lm3533, reg, val, mask); | ||
567 | if (ret) | ||
568 | return ret; | ||
569 | |||
570 | return len; | ||
571 | } | ||
572 | |||
573 | static ssize_t show_pwm(struct device *dev, | ||
574 | struct device_attribute *attr, | ||
575 | char *buf) | ||
576 | { | ||
577 | struct led_classdev *led_cdev = dev_get_drvdata(dev); | ||
578 | struct lm3533_led *led = to_lm3533_led(led_cdev); | ||
579 | u8 val; | ||
580 | int ret; | ||
581 | |||
582 | ret = lm3533_ctrlbank_get_pwm(&led->cb, &val); | ||
583 | if (ret) | ||
584 | return ret; | ||
585 | |||
586 | return scnprintf(buf, PAGE_SIZE, "%u\n", val); | ||
587 | } | ||
588 | |||
589 | static ssize_t store_pwm(struct device *dev, | ||
590 | struct device_attribute *attr, | ||
591 | const char *buf, size_t len) | ||
592 | { | ||
593 | struct led_classdev *led_cdev = dev_get_drvdata(dev); | ||
594 | struct lm3533_led *led = to_lm3533_led(led_cdev); | ||
595 | u8 val; | ||
596 | int ret; | ||
597 | |||
598 | if (kstrtou8(buf, 0, &val)) | ||
599 | return -EINVAL; | ||
600 | |||
601 | ret = lm3533_ctrlbank_set_pwm(&led->cb, val); | ||
602 | if (ret) | ||
603 | return ret; | ||
604 | |||
605 | return len; | ||
606 | } | ||
607 | |||
608 | static LM3533_ATTR_RW(als_channel); | ||
609 | static LM3533_ATTR_RW(als_en); | ||
610 | static LM3533_ATTR_RW(falltime); | ||
611 | static LM3533_ATTR_RO(id); | ||
612 | static LM3533_ATTR_RW(linear); | ||
613 | static LM3533_ATTR_RW(pwm); | ||
614 | static LM3533_ATTR_RW(risetime); | ||
615 | |||
616 | static struct attribute *lm3533_led_attributes[] = { | ||
617 | &dev_attr_als_channel.attr, | ||
618 | &dev_attr_als_en.attr, | ||
619 | &dev_attr_falltime.attr, | ||
620 | &dev_attr_id.attr, | ||
621 | &dev_attr_linear.attr, | ||
622 | &dev_attr_pwm.attr, | ||
623 | &dev_attr_risetime.attr, | ||
624 | NULL, | ||
625 | }; | ||
626 | |||
627 | static umode_t lm3533_led_attr_is_visible(struct kobject *kobj, | ||
628 | struct attribute *attr, int n) | ||
629 | { | ||
630 | struct device *dev = container_of(kobj, struct device, kobj); | ||
631 | struct led_classdev *led_cdev = dev_get_drvdata(dev); | ||
632 | struct lm3533_led *led = to_lm3533_led(led_cdev); | ||
633 | umode_t mode = attr->mode; | ||
634 | |||
635 | if (attr == &dev_attr_als_channel.attr || | ||
636 | attr == &dev_attr_als_en.attr) { | ||
637 | if (!led->lm3533->have_als) | ||
638 | mode = 0; | ||
639 | } | ||
640 | |||
641 | return mode; | ||
642 | }; | ||
643 | |||
644 | static struct attribute_group lm3533_led_attribute_group = { | ||
645 | .is_visible = lm3533_led_attr_is_visible, | ||
646 | .attrs = lm3533_led_attributes | ||
647 | }; | ||
648 | |||
649 | static int __devinit lm3533_led_setup(struct lm3533_led *led, | ||
650 | struct lm3533_led_platform_data *pdata) | ||
651 | { | ||
652 | int ret; | ||
653 | |||
654 | ret = lm3533_ctrlbank_set_max_current(&led->cb, pdata->max_current); | ||
655 | if (ret) | ||
656 | return ret; | ||
657 | |||
658 | return lm3533_ctrlbank_set_pwm(&led->cb, pdata->pwm); | ||
659 | } | ||
660 | |||
661 | static int __devinit lm3533_led_probe(struct platform_device *pdev) | ||
662 | { | ||
663 | struct lm3533 *lm3533; | ||
664 | struct lm3533_led_platform_data *pdata; | ||
665 | struct lm3533_led *led; | ||
666 | int ret; | ||
667 | |||
668 | dev_dbg(&pdev->dev, "%s\n", __func__); | ||
669 | |||
670 | lm3533 = dev_get_drvdata(pdev->dev.parent); | ||
671 | if (!lm3533) | ||
672 | return -EINVAL; | ||
673 | |||
674 | pdata = pdev->dev.platform_data; | ||
675 | if (!pdata) { | ||
676 | dev_err(&pdev->dev, "no platform data\n"); | ||
677 | return -EINVAL; | ||
678 | } | ||
679 | |||
680 | if (pdev->id < 0 || pdev->id >= LM3533_LVCTRLBANK_COUNT) { | ||
681 | dev_err(&pdev->dev, "illegal LED id %d\n", pdev->id); | ||
682 | return -EINVAL; | ||
683 | } | ||
684 | |||
685 | led = devm_kzalloc(&pdev->dev, sizeof(*led), GFP_KERNEL); | ||
686 | if (!led) | ||
687 | return -ENOMEM; | ||
688 | |||
689 | led->lm3533 = lm3533; | ||
690 | led->cdev.name = pdata->name; | ||
691 | led->cdev.default_trigger = pdata->default_trigger; | ||
692 | led->cdev.brightness_set = lm3533_led_set; | ||
693 | led->cdev.brightness_get = lm3533_led_get; | ||
694 | led->cdev.blink_set = lm3533_led_blink_set; | ||
695 | led->cdev.brightness = LED_OFF; | ||
696 | led->id = pdev->id; | ||
697 | |||
698 | mutex_init(&led->mutex); | ||
699 | INIT_WORK(&led->work, lm3533_led_work); | ||
700 | |||
701 | /* The class framework makes a callback to get brightness during | ||
702 | * registration so use parent device (for error reporting) until | ||
703 | * registered. | ||
704 | */ | ||
705 | led->cb.lm3533 = lm3533; | ||
706 | led->cb.id = lm3533_led_get_ctrlbank_id(led); | ||
707 | led->cb.dev = lm3533->dev; | ||
708 | |||
709 | platform_set_drvdata(pdev, led); | ||
710 | |||
711 | ret = led_classdev_register(pdev->dev.parent, &led->cdev); | ||
712 | if (ret) { | ||
713 | dev_err(&pdev->dev, "failed to register LED %d\n", pdev->id); | ||
714 | return ret; | ||
715 | } | ||
716 | |||
717 | led->cb.dev = led->cdev.dev; | ||
718 | |||
719 | ret = sysfs_create_group(&led->cdev.dev->kobj, | ||
720 | &lm3533_led_attribute_group); | ||
721 | if (ret < 0) { | ||
722 | dev_err(&pdev->dev, "failed to create sysfs attributes\n"); | ||
723 | goto err_unregister; | ||
724 | } | ||
725 | |||
726 | ret = lm3533_led_setup(led, pdata); | ||
727 | if (ret) | ||
728 | goto err_sysfs_remove; | ||
729 | |||
730 | ret = lm3533_ctrlbank_enable(&led->cb); | ||
731 | if (ret) | ||
732 | goto err_sysfs_remove; | ||
733 | |||
734 | return 0; | ||
735 | |||
736 | err_sysfs_remove: | ||
737 | sysfs_remove_group(&led->cdev.dev->kobj, &lm3533_led_attribute_group); | ||
738 | err_unregister: | ||
739 | led_classdev_unregister(&led->cdev); | ||
740 | flush_work_sync(&led->work); | ||
741 | |||
742 | return ret; | ||
743 | } | ||
744 | |||
745 | static int __devexit lm3533_led_remove(struct platform_device *pdev) | ||
746 | { | ||
747 | struct lm3533_led *led = platform_get_drvdata(pdev); | ||
748 | |||
749 | dev_dbg(&pdev->dev, "%s\n", __func__); | ||
750 | |||
751 | lm3533_ctrlbank_disable(&led->cb); | ||
752 | sysfs_remove_group(&led->cdev.dev->kobj, &lm3533_led_attribute_group); | ||
753 | led_classdev_unregister(&led->cdev); | ||
754 | flush_work_sync(&led->work); | ||
755 | |||
756 | return 0; | ||
757 | } | ||
758 | |||
759 | static void lm3533_led_shutdown(struct platform_device *pdev) | ||
760 | { | ||
761 | |||
762 | struct lm3533_led *led = platform_get_drvdata(pdev); | ||
763 | |||
764 | dev_dbg(&pdev->dev, "%s\n", __func__); | ||
765 | |||
766 | lm3533_ctrlbank_disable(&led->cb); | ||
767 | lm3533_led_set(&led->cdev, LED_OFF); /* disable blink */ | ||
768 | flush_work_sync(&led->work); | ||
769 | } | ||
770 | |||
771 | static struct platform_driver lm3533_led_driver = { | ||
772 | .driver = { | ||
773 | .name = "lm3533-leds", | ||
774 | .owner = THIS_MODULE, | ||
775 | }, | ||
776 | .probe = lm3533_led_probe, | ||
777 | .remove = __devexit_p(lm3533_led_remove), | ||
778 | .shutdown = lm3533_led_shutdown, | ||
779 | }; | ||
780 | module_platform_driver(lm3533_led_driver); | ||
781 | |||
782 | MODULE_AUTHOR("Johan Hovold <jhovold@gmail.com>"); | ||
783 | MODULE_DESCRIPTION("LM3533 LED driver"); | ||
784 | MODULE_LICENSE("GPL"); | ||
785 | MODULE_ALIAS("platform:lm3533-leds"); | ||
diff --git a/drivers/leds/leds-lp5521.c b/drivers/leds/leds-lp5521.c index 410a723b8691..23815624f35e 100644 --- a/drivers/leds/leds-lp5521.c +++ b/drivers/leds/leds-lp5521.c | |||
@@ -193,9 +193,14 @@ static int lp5521_load_program(struct lp5521_engine *eng, const u8 *pattern) | |||
193 | 193 | ||
194 | /* move current engine to direct mode and remember the state */ | 194 | /* move current engine to direct mode and remember the state */ |
195 | ret = lp5521_set_engine_mode(eng, LP5521_CMD_DIRECT); | 195 | ret = lp5521_set_engine_mode(eng, LP5521_CMD_DIRECT); |
196 | if (ret) | ||
197 | return ret; | ||
198 | |||
196 | /* Mode change requires min 500 us delay. 1 - 2 ms with margin */ | 199 | /* Mode change requires min 500 us delay. 1 - 2 ms with margin */ |
197 | usleep_range(1000, 2000); | 200 | usleep_range(1000, 2000); |
198 | ret |= lp5521_read(client, LP5521_REG_OP_MODE, &mode); | 201 | ret = lp5521_read(client, LP5521_REG_OP_MODE, &mode); |
202 | if (ret) | ||
203 | return ret; | ||
199 | 204 | ||
200 | /* For loading, all the engines to load mode */ | 205 | /* For loading, all the engines to load mode */ |
201 | lp5521_write(client, LP5521_REG_OP_MODE, LP5521_CMD_DIRECT); | 206 | lp5521_write(client, LP5521_REG_OP_MODE, LP5521_CMD_DIRECT); |
@@ -211,8 +216,7 @@ static int lp5521_load_program(struct lp5521_engine *eng, const u8 *pattern) | |||
211 | LP5521_PROG_MEM_SIZE, | 216 | LP5521_PROG_MEM_SIZE, |
212 | pattern); | 217 | pattern); |
213 | 218 | ||
214 | ret |= lp5521_write(client, LP5521_REG_OP_MODE, mode); | 219 | return lp5521_write(client, LP5521_REG_OP_MODE, mode); |
215 | return ret; | ||
216 | } | 220 | } |
217 | 221 | ||
218 | static int lp5521_set_led_current(struct lp5521_chip *chip, int led, u8 curr) | 222 | static int lp5521_set_led_current(struct lp5521_chip *chip, int led, u8 curr) |
@@ -785,7 +789,7 @@ static int __devinit lp5521_probe(struct i2c_client *client, | |||
785 | * LP5521_REG_ENABLE register will not have any effect - strange! | 789 | * LP5521_REG_ENABLE register will not have any effect - strange! |
786 | */ | 790 | */ |
787 | ret = lp5521_read(client, LP5521_REG_R_CURRENT, &buf); | 791 | ret = lp5521_read(client, LP5521_REG_R_CURRENT, &buf); |
788 | if (buf != LP5521_REG_R_CURR_DEFAULT) { | 792 | if (ret || buf != LP5521_REG_R_CURR_DEFAULT) { |
789 | dev_err(&client->dev, "error in resetting chip\n"); | 793 | dev_err(&client->dev, "error in resetting chip\n"); |
790 | goto fail2; | 794 | goto fail2; |
791 | } | 795 | } |
diff --git a/drivers/leds/leds-mc13783.c b/drivers/leds/leds-mc13783.c index 8bc491541550..4cc6a2e3df34 100644 --- a/drivers/leds/leds-mc13783.c +++ b/drivers/leds/leds-mc13783.c | |||
@@ -280,7 +280,7 @@ static int __devinit mc13783_led_probe(struct platform_device *pdev) | |||
280 | return -EINVAL; | 280 | return -EINVAL; |
281 | } | 281 | } |
282 | 282 | ||
283 | led = kzalloc(sizeof(*led) * pdata->num_leds, GFP_KERNEL); | 283 | led = kcalloc(pdata->num_leds, sizeof(*led), GFP_KERNEL); |
284 | if (led == NULL) { | 284 | if (led == NULL) { |
285 | dev_err(&pdev->dev, "failed to alloc memory\n"); | 285 | dev_err(&pdev->dev, "failed to alloc memory\n"); |
286 | return -ENOMEM; | 286 | return -ENOMEM; |
diff --git a/drivers/leds/leds-pca955x.c b/drivers/leds/leds-pca955x.c index dcc3bc3d38db..5f462dbf0dbb 100644 --- a/drivers/leds/leds-pca955x.c +++ b/drivers/leds/leds-pca955x.c | |||
@@ -101,11 +101,16 @@ static const struct i2c_device_id pca955x_id[] = { | |||
101 | }; | 101 | }; |
102 | MODULE_DEVICE_TABLE(i2c, pca955x_id); | 102 | MODULE_DEVICE_TABLE(i2c, pca955x_id); |
103 | 103 | ||
104 | struct pca955x_led { | 104 | struct pca955x { |
105 | struct mutex lock; | ||
106 | struct pca955x_led *leds; | ||
105 | struct pca955x_chipdef *chipdef; | 107 | struct pca955x_chipdef *chipdef; |
106 | struct i2c_client *client; | 108 | struct i2c_client *client; |
109 | }; | ||
110 | |||
111 | struct pca955x_led { | ||
112 | struct pca955x *pca955x; | ||
107 | struct work_struct work; | 113 | struct work_struct work; |
108 | spinlock_t lock; | ||
109 | enum led_brightness brightness; | 114 | enum led_brightness brightness; |
110 | struct led_classdev led_cdev; | 115 | struct led_classdev led_cdev; |
111 | int led_num; /* 0 .. 15 potentially */ | 116 | int led_num; /* 0 .. 15 potentially */ |
@@ -140,7 +145,7 @@ static inline u8 pca955x_ledsel(u8 oldval, int led_num, int state) | |||
140 | */ | 145 | */ |
141 | static void pca955x_write_psc(struct i2c_client *client, int n, u8 val) | 146 | static void pca955x_write_psc(struct i2c_client *client, int n, u8 val) |
142 | { | 147 | { |
143 | struct pca955x_led *pca955x = i2c_get_clientdata(client); | 148 | struct pca955x *pca955x = i2c_get_clientdata(client); |
144 | 149 | ||
145 | i2c_smbus_write_byte_data(client, | 150 | i2c_smbus_write_byte_data(client, |
146 | pca95xx_num_input_regs(pca955x->chipdef->bits) + 2*n, | 151 | pca95xx_num_input_regs(pca955x->chipdef->bits) + 2*n, |
@@ -156,7 +161,7 @@ static void pca955x_write_psc(struct i2c_client *client, int n, u8 val) | |||
156 | */ | 161 | */ |
157 | static void pca955x_write_pwm(struct i2c_client *client, int n, u8 val) | 162 | static void pca955x_write_pwm(struct i2c_client *client, int n, u8 val) |
158 | { | 163 | { |
159 | struct pca955x_led *pca955x = i2c_get_clientdata(client); | 164 | struct pca955x *pca955x = i2c_get_clientdata(client); |
160 | 165 | ||
161 | i2c_smbus_write_byte_data(client, | 166 | i2c_smbus_write_byte_data(client, |
162 | pca95xx_num_input_regs(pca955x->chipdef->bits) + 1 + 2*n, | 167 | pca95xx_num_input_regs(pca955x->chipdef->bits) + 1 + 2*n, |
@@ -169,7 +174,7 @@ static void pca955x_write_pwm(struct i2c_client *client, int n, u8 val) | |||
169 | */ | 174 | */ |
170 | static void pca955x_write_ls(struct i2c_client *client, int n, u8 val) | 175 | static void pca955x_write_ls(struct i2c_client *client, int n, u8 val) |
171 | { | 176 | { |
172 | struct pca955x_led *pca955x = i2c_get_clientdata(client); | 177 | struct pca955x *pca955x = i2c_get_clientdata(client); |
173 | 178 | ||
174 | i2c_smbus_write_byte_data(client, | 179 | i2c_smbus_write_byte_data(client, |
175 | pca95xx_num_input_regs(pca955x->chipdef->bits) + 4 + n, | 180 | pca95xx_num_input_regs(pca955x->chipdef->bits) + 4 + n, |
@@ -182,7 +187,7 @@ static void pca955x_write_ls(struct i2c_client *client, int n, u8 val) | |||
182 | */ | 187 | */ |
183 | static u8 pca955x_read_ls(struct i2c_client *client, int n) | 188 | static u8 pca955x_read_ls(struct i2c_client *client, int n) |
184 | { | 189 | { |
185 | struct pca955x_led *pca955x = i2c_get_clientdata(client); | 190 | struct pca955x *pca955x = i2c_get_clientdata(client); |
186 | 191 | ||
187 | return (u8) i2c_smbus_read_byte_data(client, | 192 | return (u8) i2c_smbus_read_byte_data(client, |
188 | pca95xx_num_input_regs(pca955x->chipdef->bits) + 4 + n); | 193 | pca95xx_num_input_regs(pca955x->chipdef->bits) + 4 + n); |
@@ -190,18 +195,23 @@ static u8 pca955x_read_ls(struct i2c_client *client, int n) | |||
190 | 195 | ||
191 | static void pca955x_led_work(struct work_struct *work) | 196 | static void pca955x_led_work(struct work_struct *work) |
192 | { | 197 | { |
193 | struct pca955x_led *pca955x; | 198 | struct pca955x_led *pca955x_led; |
199 | struct pca955x *pca955x; | ||
194 | u8 ls; | 200 | u8 ls; |
195 | int chip_ls; /* which LSx to use (0-3 potentially) */ | 201 | int chip_ls; /* which LSx to use (0-3 potentially) */ |
196 | int ls_led; /* which set of bits within LSx to use (0-3) */ | 202 | int ls_led; /* which set of bits within LSx to use (0-3) */ |
197 | 203 | ||
198 | pca955x = container_of(work, struct pca955x_led, work); | 204 | pca955x_led = container_of(work, struct pca955x_led, work); |
199 | chip_ls = pca955x->led_num / 4; | 205 | pca955x = pca955x_led->pca955x; |
200 | ls_led = pca955x->led_num % 4; | 206 | |
207 | chip_ls = pca955x_led->led_num / 4; | ||
208 | ls_led = pca955x_led->led_num % 4; | ||
209 | |||
210 | mutex_lock(&pca955x->lock); | ||
201 | 211 | ||
202 | ls = pca955x_read_ls(pca955x->client, chip_ls); | 212 | ls = pca955x_read_ls(pca955x->client, chip_ls); |
203 | 213 | ||
204 | switch (pca955x->brightness) { | 214 | switch (pca955x_led->brightness) { |
205 | case LED_FULL: | 215 | case LED_FULL: |
206 | ls = pca955x_ledsel(ls, ls_led, PCA955X_LS_LED_ON); | 216 | ls = pca955x_ledsel(ls, ls_led, PCA955X_LS_LED_ON); |
207 | break; | 217 | break; |
@@ -219,12 +229,15 @@ static void pca955x_led_work(struct work_struct *work) | |||
219 | * OFF, HALF, or FULL. But, this is probably better than | 229 | * OFF, HALF, or FULL. But, this is probably better than |
220 | * just turning off for all other values. | 230 | * just turning off for all other values. |
221 | */ | 231 | */ |
222 | pca955x_write_pwm(pca955x->client, 1, 255-pca955x->brightness); | 232 | pca955x_write_pwm(pca955x->client, 1, |
233 | 255 - pca955x_led->brightness); | ||
223 | ls = pca955x_ledsel(ls, ls_led, PCA955X_LS_BLINK1); | 234 | ls = pca955x_ledsel(ls, ls_led, PCA955X_LS_BLINK1); |
224 | break; | 235 | break; |
225 | } | 236 | } |
226 | 237 | ||
227 | pca955x_write_ls(pca955x->client, chip_ls, ls); | 238 | pca955x_write_ls(pca955x->client, chip_ls, ls); |
239 | |||
240 | mutex_unlock(&pca955x->lock); | ||
228 | } | 241 | } |
229 | 242 | ||
230 | static void pca955x_led_set(struct led_classdev *led_cdev, enum led_brightness value) | 243 | static void pca955x_led_set(struct led_classdev *led_cdev, enum led_brightness value) |
@@ -233,7 +246,6 @@ static void pca955x_led_set(struct led_classdev *led_cdev, enum led_brightness v | |||
233 | 246 | ||
234 | pca955x = container_of(led_cdev, struct pca955x_led, led_cdev); | 247 | pca955x = container_of(led_cdev, struct pca955x_led, led_cdev); |
235 | 248 | ||
236 | spin_lock(&pca955x->lock); | ||
237 | pca955x->brightness = value; | 249 | pca955x->brightness = value; |
238 | 250 | ||
239 | /* | 251 | /* |
@@ -241,14 +253,13 @@ static void pca955x_led_set(struct led_classdev *led_cdev, enum led_brightness v | |||
241 | * can sleep. | 253 | * can sleep. |
242 | */ | 254 | */ |
243 | schedule_work(&pca955x->work); | 255 | schedule_work(&pca955x->work); |
244 | |||
245 | spin_unlock(&pca955x->lock); | ||
246 | } | 256 | } |
247 | 257 | ||
248 | static int __devinit pca955x_probe(struct i2c_client *client, | 258 | static int __devinit pca955x_probe(struct i2c_client *client, |
249 | const struct i2c_device_id *id) | 259 | const struct i2c_device_id *id) |
250 | { | 260 | { |
251 | struct pca955x_led *pca955x; | 261 | struct pca955x *pca955x; |
262 | struct pca955x_led *pca955x_led; | ||
252 | struct pca955x_chipdef *chip; | 263 | struct pca955x_chipdef *chip; |
253 | struct i2c_adapter *adapter; | 264 | struct i2c_adapter *adapter; |
254 | struct led_platform_data *pdata; | 265 | struct led_platform_data *pdata; |
@@ -282,39 +293,48 @@ static int __devinit pca955x_probe(struct i2c_client *client, | |||
282 | } | 293 | } |
283 | } | 294 | } |
284 | 295 | ||
285 | pca955x = kzalloc(sizeof(*pca955x) * chip->bits, GFP_KERNEL); | 296 | pca955x = kzalloc(sizeof(*pca955x), GFP_KERNEL); |
286 | if (!pca955x) | 297 | if (!pca955x) |
287 | return -ENOMEM; | 298 | return -ENOMEM; |
288 | 299 | ||
300 | pca955x->leds = kzalloc(sizeof(*pca955x_led) * chip->bits, GFP_KERNEL); | ||
301 | if (!pca955x->leds) { | ||
302 | err = -ENOMEM; | ||
303 | goto exit_nomem; | ||
304 | } | ||
305 | |||
289 | i2c_set_clientdata(client, pca955x); | 306 | i2c_set_clientdata(client, pca955x); |
290 | 307 | ||
308 | mutex_init(&pca955x->lock); | ||
309 | pca955x->client = client; | ||
310 | pca955x->chipdef = chip; | ||
311 | |||
291 | for (i = 0; i < chip->bits; i++) { | 312 | for (i = 0; i < chip->bits; i++) { |
292 | pca955x[i].chipdef = chip; | 313 | pca955x_led = &pca955x->leds[i]; |
293 | pca955x[i].client = client; | 314 | pca955x_led->led_num = i; |
294 | pca955x[i].led_num = i; | 315 | pca955x_led->pca955x = pca955x; |
295 | 316 | ||
296 | /* Platform data can specify LED names and default triggers */ | 317 | /* Platform data can specify LED names and default triggers */ |
297 | if (pdata) { | 318 | if (pdata) { |
298 | if (pdata->leds[i].name) | 319 | if (pdata->leds[i].name) |
299 | snprintf(pca955x[i].name, | 320 | snprintf(pca955x_led->name, |
300 | sizeof(pca955x[i].name), "pca955x:%s", | 321 | sizeof(pca955x_led->name), "pca955x:%s", |
301 | pdata->leds[i].name); | 322 | pdata->leds[i].name); |
302 | if (pdata->leds[i].default_trigger) | 323 | if (pdata->leds[i].default_trigger) |
303 | pca955x[i].led_cdev.default_trigger = | 324 | pca955x_led->led_cdev.default_trigger = |
304 | pdata->leds[i].default_trigger; | 325 | pdata->leds[i].default_trigger; |
305 | } else { | 326 | } else { |
306 | snprintf(pca955x[i].name, sizeof(pca955x[i].name), | 327 | snprintf(pca955x_led->name, sizeof(pca955x_led->name), |
307 | "pca955x:%d", i); | 328 | "pca955x:%d", i); |
308 | } | 329 | } |
309 | 330 | ||
310 | spin_lock_init(&pca955x[i].lock); | 331 | pca955x_led->led_cdev.name = pca955x_led->name; |
311 | 332 | pca955x_led->led_cdev.brightness_set = pca955x_led_set; | |
312 | pca955x[i].led_cdev.name = pca955x[i].name; | ||
313 | pca955x[i].led_cdev.brightness_set = pca955x_led_set; | ||
314 | 333 | ||
315 | INIT_WORK(&pca955x[i].work, pca955x_led_work); | 334 | INIT_WORK(&pca955x_led->work, pca955x_led_work); |
316 | 335 | ||
317 | err = led_classdev_register(&client->dev, &pca955x[i].led_cdev); | 336 | err = led_classdev_register(&client->dev, |
337 | &pca955x_led->led_cdev); | ||
318 | if (err < 0) | 338 | if (err < 0) |
319 | goto exit; | 339 | goto exit; |
320 | } | 340 | } |
@@ -337,10 +357,12 @@ static int __devinit pca955x_probe(struct i2c_client *client, | |||
337 | 357 | ||
338 | exit: | 358 | exit: |
339 | while (i--) { | 359 | while (i--) { |
340 | led_classdev_unregister(&pca955x[i].led_cdev); | 360 | led_classdev_unregister(&pca955x->leds[i].led_cdev); |
341 | cancel_work_sync(&pca955x[i].work); | 361 | cancel_work_sync(&pca955x->leds[i].work); |
342 | } | 362 | } |
343 | 363 | ||
364 | kfree(pca955x->leds); | ||
365 | exit_nomem: | ||
344 | kfree(pca955x); | 366 | kfree(pca955x); |
345 | 367 | ||
346 | return err; | 368 | return err; |
@@ -348,14 +370,15 @@ exit: | |||
348 | 370 | ||
349 | static int __devexit pca955x_remove(struct i2c_client *client) | 371 | static int __devexit pca955x_remove(struct i2c_client *client) |
350 | { | 372 | { |
351 | struct pca955x_led *pca955x = i2c_get_clientdata(client); | 373 | struct pca955x *pca955x = i2c_get_clientdata(client); |
352 | int i; | 374 | int i; |
353 | 375 | ||
354 | for (i = 0; i < pca955x->chipdef->bits; i++) { | 376 | for (i = 0; i < pca955x->chipdef->bits; i++) { |
355 | led_classdev_unregister(&pca955x[i].led_cdev); | 377 | led_classdev_unregister(&pca955x->leds[i].led_cdev); |
356 | cancel_work_sync(&pca955x[i].work); | 378 | cancel_work_sync(&pca955x->leds[i].work); |
357 | } | 379 | } |
358 | 380 | ||
381 | kfree(pca955x->leds); | ||
359 | kfree(pca955x); | 382 | kfree(pca955x); |
360 | 383 | ||
361 | return 0; | 384 | return 0; |
diff --git a/drivers/leds/ledtrig-backlight.c b/drivers/leds/ledtrig-backlight.c index 2b513a2ad7de..e2726867c5d4 100644 --- a/drivers/leds/ledtrig-backlight.c +++ b/drivers/leds/ledtrig-backlight.c | |||
@@ -120,6 +120,7 @@ static void bl_trig_activate(struct led_classdev *led) | |||
120 | ret = fb_register_client(&n->notifier); | 120 | ret = fb_register_client(&n->notifier); |
121 | if (ret) | 121 | if (ret) |
122 | dev_err(led->dev, "unable to register backlight trigger\n"); | 122 | dev_err(led->dev, "unable to register backlight trigger\n"); |
123 | led->activated = true; | ||
123 | 124 | ||
124 | return; | 125 | return; |
125 | 126 | ||
@@ -133,10 +134,11 @@ static void bl_trig_deactivate(struct led_classdev *led) | |||
133 | struct bl_trig_notifier *n = | 134 | struct bl_trig_notifier *n = |
134 | (struct bl_trig_notifier *) led->trigger_data; | 135 | (struct bl_trig_notifier *) led->trigger_data; |
135 | 136 | ||
136 | if (n) { | 137 | if (led->activated) { |
137 | device_remove_file(led->dev, &dev_attr_inverted); | 138 | device_remove_file(led->dev, &dev_attr_inverted); |
138 | fb_unregister_client(&n->notifier); | 139 | fb_unregister_client(&n->notifier); |
139 | kfree(n); | 140 | kfree(n); |
141 | led->activated = false; | ||
140 | } | 142 | } |
141 | } | 143 | } |
142 | 144 | ||
diff --git a/drivers/leds/ledtrig-gpio.c b/drivers/leds/ledtrig-gpio.c index ecc4bf3f37a9..f057c101b896 100644 --- a/drivers/leds/ledtrig-gpio.c +++ b/drivers/leds/ledtrig-gpio.c | |||
@@ -200,6 +200,7 @@ static void gpio_trig_activate(struct led_classdev *led) | |||
200 | gpio_data->led = led; | 200 | gpio_data->led = led; |
201 | led->trigger_data = gpio_data; | 201 | led->trigger_data = gpio_data; |
202 | INIT_WORK(&gpio_data->work, gpio_trig_work); | 202 | INIT_WORK(&gpio_data->work, gpio_trig_work); |
203 | led->activated = true; | ||
203 | 204 | ||
204 | return; | 205 | return; |
205 | 206 | ||
@@ -217,7 +218,7 @@ static void gpio_trig_deactivate(struct led_classdev *led) | |||
217 | { | 218 | { |
218 | struct gpio_trig_data *gpio_data = led->trigger_data; | 219 | struct gpio_trig_data *gpio_data = led->trigger_data; |
219 | 220 | ||
220 | if (gpio_data) { | 221 | if (led->activated) { |
221 | device_remove_file(led->dev, &dev_attr_gpio); | 222 | device_remove_file(led->dev, &dev_attr_gpio); |
222 | device_remove_file(led->dev, &dev_attr_inverted); | 223 | device_remove_file(led->dev, &dev_attr_inverted); |
223 | device_remove_file(led->dev, &dev_attr_desired_brightness); | 224 | device_remove_file(led->dev, &dev_attr_desired_brightness); |
@@ -225,6 +226,7 @@ static void gpio_trig_deactivate(struct led_classdev *led) | |||
225 | if (gpio_data->gpio != 0) | 226 | if (gpio_data->gpio != 0) |
226 | free_irq(gpio_to_irq(gpio_data->gpio), led); | 227 | free_irq(gpio_to_irq(gpio_data->gpio), led); |
227 | kfree(gpio_data); | 228 | kfree(gpio_data); |
229 | led->activated = false; | ||
228 | } | 230 | } |
229 | } | 231 | } |
230 | 232 | ||
diff --git a/drivers/leds/ledtrig-heartbeat.c b/drivers/leds/ledtrig-heartbeat.c index 759c0bba4a8f..41dc76db4311 100644 --- a/drivers/leds/ledtrig-heartbeat.c +++ b/drivers/leds/ledtrig-heartbeat.c | |||
@@ -18,6 +18,7 @@ | |||
18 | #include <linux/timer.h> | 18 | #include <linux/timer.h> |
19 | #include <linux/sched.h> | 19 | #include <linux/sched.h> |
20 | #include <linux/leds.h> | 20 | #include <linux/leds.h> |
21 | #include <linux/reboot.h> | ||
21 | #include "leds.h" | 22 | #include "leds.h" |
22 | 23 | ||
23 | struct heartbeat_trig_data { | 24 | struct heartbeat_trig_data { |
@@ -83,15 +84,17 @@ static void heartbeat_trig_activate(struct led_classdev *led_cdev) | |||
83 | led_heartbeat_function, (unsigned long) led_cdev); | 84 | led_heartbeat_function, (unsigned long) led_cdev); |
84 | heartbeat_data->phase = 0; | 85 | heartbeat_data->phase = 0; |
85 | led_heartbeat_function(heartbeat_data->timer.data); | 86 | led_heartbeat_function(heartbeat_data->timer.data); |
87 | led_cdev->activated = true; | ||
86 | } | 88 | } |
87 | 89 | ||
88 | static void heartbeat_trig_deactivate(struct led_classdev *led_cdev) | 90 | static void heartbeat_trig_deactivate(struct led_classdev *led_cdev) |
89 | { | 91 | { |
90 | struct heartbeat_trig_data *heartbeat_data = led_cdev->trigger_data; | 92 | struct heartbeat_trig_data *heartbeat_data = led_cdev->trigger_data; |
91 | 93 | ||
92 | if (heartbeat_data) { | 94 | if (led_cdev->activated) { |
93 | del_timer_sync(&heartbeat_data->timer); | 95 | del_timer_sync(&heartbeat_data->timer); |
94 | kfree(heartbeat_data); | 96 | kfree(heartbeat_data); |
97 | led_cdev->activated = false; | ||
95 | } | 98 | } |
96 | } | 99 | } |
97 | 100 | ||
@@ -101,13 +104,38 @@ static struct led_trigger heartbeat_led_trigger = { | |||
101 | .deactivate = heartbeat_trig_deactivate, | 104 | .deactivate = heartbeat_trig_deactivate, |
102 | }; | 105 | }; |
103 | 106 | ||
107 | static int heartbeat_reboot_notifier(struct notifier_block *nb, | ||
108 | unsigned long code, void *unused) | ||
109 | { | ||
110 | led_trigger_unregister(&heartbeat_led_trigger); | ||
111 | return NOTIFY_DONE; | ||
112 | } | ||
113 | |||
114 | static struct notifier_block heartbeat_reboot_nb = { | ||
115 | .notifier_call = heartbeat_reboot_notifier, | ||
116 | }; | ||
117 | |||
118 | static struct notifier_block heartbeat_panic_nb = { | ||
119 | .notifier_call = heartbeat_reboot_notifier, | ||
120 | }; | ||
121 | |||
104 | static int __init heartbeat_trig_init(void) | 122 | static int __init heartbeat_trig_init(void) |
105 | { | 123 | { |
106 | return led_trigger_register(&heartbeat_led_trigger); | 124 | int rc = led_trigger_register(&heartbeat_led_trigger); |
125 | |||
126 | if (!rc) { | ||
127 | atomic_notifier_chain_register(&panic_notifier_list, | ||
128 | &heartbeat_panic_nb); | ||
129 | register_reboot_notifier(&heartbeat_reboot_nb); | ||
130 | } | ||
131 | return rc; | ||
107 | } | 132 | } |
108 | 133 | ||
109 | static void __exit heartbeat_trig_exit(void) | 134 | static void __exit heartbeat_trig_exit(void) |
110 | { | 135 | { |
136 | unregister_reboot_notifier(&heartbeat_reboot_nb); | ||
137 | atomic_notifier_chain_unregister(&panic_notifier_list, | ||
138 | &heartbeat_panic_nb); | ||
111 | led_trigger_unregister(&heartbeat_led_trigger); | 139 | led_trigger_unregister(&heartbeat_led_trigger); |
112 | } | 140 | } |
113 | 141 | ||
diff --git a/drivers/leds/ledtrig-timer.c b/drivers/leds/ledtrig-timer.c index 328c64c0841c..9010f7abaf2c 100644 --- a/drivers/leds/ledtrig-timer.c +++ b/drivers/leds/ledtrig-timer.c | |||
@@ -31,21 +31,17 @@ static ssize_t led_delay_on_store(struct device *dev, | |||
31 | struct device_attribute *attr, const char *buf, size_t size) | 31 | struct device_attribute *attr, const char *buf, size_t size) |
32 | { | 32 | { |
33 | struct led_classdev *led_cdev = dev_get_drvdata(dev); | 33 | struct led_classdev *led_cdev = dev_get_drvdata(dev); |
34 | int ret = -EINVAL; | 34 | unsigned long state; |
35 | char *after; | 35 | ssize_t ret = -EINVAL; |
36 | unsigned long state = simple_strtoul(buf, &after, 10); | 36 | |
37 | size_t count = after - buf; | 37 | ret = kstrtoul(buf, 10, &state); |
38 | 38 | if (ret) | |
39 | if (isspace(*after)) | 39 | return ret; |
40 | count++; | ||
41 | |||
42 | if (count == size) { | ||
43 | led_blink_set(led_cdev, &state, &led_cdev->blink_delay_off); | ||
44 | led_cdev->blink_delay_on = state; | ||
45 | ret = count; | ||
46 | } | ||
47 | 40 | ||
48 | return ret; | 41 | led_blink_set(led_cdev, &state, &led_cdev->blink_delay_off); |
42 | led_cdev->blink_delay_on = state; | ||
43 | |||
44 | return size; | ||
49 | } | 45 | } |
50 | 46 | ||
51 | static ssize_t led_delay_off_show(struct device *dev, | 47 | static ssize_t led_delay_off_show(struct device *dev, |
@@ -60,21 +56,17 @@ static ssize_t led_delay_off_store(struct device *dev, | |||
60 | struct device_attribute *attr, const char *buf, size_t size) | 56 | struct device_attribute *attr, const char *buf, size_t size) |
61 | { | 57 | { |
62 | struct led_classdev *led_cdev = dev_get_drvdata(dev); | 58 | struct led_classdev *led_cdev = dev_get_drvdata(dev); |
63 | int ret = -EINVAL; | 59 | unsigned long state; |
64 | char *after; | 60 | ssize_t ret = -EINVAL; |
65 | unsigned long state = simple_strtoul(buf, &after, 10); | ||
66 | size_t count = after - buf; | ||
67 | |||
68 | if (isspace(*after)) | ||
69 | count++; | ||
70 | |||
71 | if (count == size) { | ||
72 | led_blink_set(led_cdev, &led_cdev->blink_delay_on, &state); | ||
73 | led_cdev->blink_delay_off = state; | ||
74 | ret = count; | ||
75 | } | ||
76 | 61 | ||
77 | return ret; | 62 | ret = kstrtoul(buf, 10, &state); |
63 | if (ret) | ||
64 | return ret; | ||
65 | |||
66 | led_blink_set(led_cdev, &led_cdev->blink_delay_on, &state); | ||
67 | led_cdev->blink_delay_off = state; | ||
68 | |||
69 | return size; | ||
78 | } | 70 | } |
79 | 71 | ||
80 | static DEVICE_ATTR(delay_on, 0644, led_delay_on_show, led_delay_on_store); | 72 | static DEVICE_ATTR(delay_on, 0644, led_delay_on_show, led_delay_on_store); |
@@ -95,8 +87,7 @@ static void timer_trig_activate(struct led_classdev *led_cdev) | |||
95 | 87 | ||
96 | led_blink_set(led_cdev, &led_cdev->blink_delay_on, | 88 | led_blink_set(led_cdev, &led_cdev->blink_delay_on, |
97 | &led_cdev->blink_delay_off); | 89 | &led_cdev->blink_delay_off); |
98 | 90 | led_cdev->activated = true; | |
99 | led_cdev->trigger_data = (void *)1; | ||
100 | 91 | ||
101 | return; | 92 | return; |
102 | 93 | ||
@@ -106,9 +97,10 @@ err_out_delayon: | |||
106 | 97 | ||
107 | static void timer_trig_deactivate(struct led_classdev *led_cdev) | 98 | static void timer_trig_deactivate(struct led_classdev *led_cdev) |
108 | { | 99 | { |
109 | if (led_cdev->trigger_data) { | 100 | if (led_cdev->activated) { |
110 | device_remove_file(led_cdev->dev, &dev_attr_delay_on); | 101 | device_remove_file(led_cdev->dev, &dev_attr_delay_on); |
111 | device_remove_file(led_cdev->dev, &dev_attr_delay_off); | 102 | device_remove_file(led_cdev->dev, &dev_attr_delay_off); |
103 | led_cdev->activated = false; | ||
112 | } | 104 | } |
113 | 105 | ||
114 | /* Stop blinking */ | 106 | /* Stop blinking */ |
diff --git a/drivers/leds/ledtrig-transient.c b/drivers/leds/ledtrig-transient.c new file mode 100644 index 000000000000..83179f435e1e --- /dev/null +++ b/drivers/leds/ledtrig-transient.c | |||
@@ -0,0 +1,237 @@ | |||
1 | /* | ||
2 | * LED Kernel Transient Trigger | ||
3 | * | ||
4 | * Copyright (C) 2012 Shuah Khan <shuahkhan@gmail.com> | ||
5 | * | ||
6 | * Based on Richard Purdie's ledtrig-timer.c and Atsushi Nemoto's | ||
7 | * ledtrig-heartbeat.c | ||
8 | * Design and use-case input from Jonas Bonn <jonas@southpole.se> and | ||
9 | * Neil Brown <neilb@suse.de> | ||
10 | * | ||
11 | * This program is free software; you can redistribute it and/or modify | ||
12 | * it under the terms of the GNU General Public License version 2 as | ||
13 | * published by the Free Software Foundation. | ||
14 | * | ||
15 | */ | ||
16 | /* | ||
17 | * Transient trigger allows one shot timer activation. Please refer to | ||
18 | * Documentation/leds/ledtrig-transient.txt for details | ||
19 | */ | ||
20 | |||
21 | #include <linux/module.h> | ||
22 | #include <linux/kernel.h> | ||
23 | #include <linux/init.h> | ||
24 | #include <linux/device.h> | ||
25 | #include <linux/slab.h> | ||
26 | #include <linux/timer.h> | ||
27 | #include <linux/leds.h> | ||
28 | #include "leds.h" | ||
29 | |||
30 | struct transient_trig_data { | ||
31 | int activate; | ||
32 | int state; | ||
33 | int restore_state; | ||
34 | unsigned long duration; | ||
35 | struct timer_list timer; | ||
36 | }; | ||
37 | |||
38 | static void transient_timer_function(unsigned long data) | ||
39 | { | ||
40 | struct led_classdev *led_cdev = (struct led_classdev *) data; | ||
41 | struct transient_trig_data *transient_data = led_cdev->trigger_data; | ||
42 | |||
43 | transient_data->activate = 0; | ||
44 | led_set_brightness(led_cdev, transient_data->restore_state); | ||
45 | } | ||
46 | |||
47 | static ssize_t transient_activate_show(struct device *dev, | ||
48 | struct device_attribute *attr, char *buf) | ||
49 | { | ||
50 | struct led_classdev *led_cdev = dev_get_drvdata(dev); | ||
51 | struct transient_trig_data *transient_data = led_cdev->trigger_data; | ||
52 | |||
53 | return sprintf(buf, "%d\n", transient_data->activate); | ||
54 | } | ||
55 | |||
56 | static ssize_t transient_activate_store(struct device *dev, | ||
57 | struct device_attribute *attr, const char *buf, size_t size) | ||
58 | { | ||
59 | struct led_classdev *led_cdev = dev_get_drvdata(dev); | ||
60 | struct transient_trig_data *transient_data = led_cdev->trigger_data; | ||
61 | unsigned long state; | ||
62 | ssize_t ret; | ||
63 | |||
64 | ret = kstrtoul(buf, 10, &state); | ||
65 | if (ret) | ||
66 | return ret; | ||
67 | |||
68 | if (state != 1 && state != 0) | ||
69 | return -EINVAL; | ||
70 | |||
71 | /* cancel the running timer */ | ||
72 | if (state == 0 && transient_data->activate == 1) { | ||
73 | del_timer(&transient_data->timer); | ||
74 | transient_data->activate = state; | ||
75 | led_set_brightness(led_cdev, transient_data->restore_state); | ||
76 | return size; | ||
77 | } | ||
78 | |||
79 | /* start timer if there is no active timer */ | ||
80 | if (state == 1 && transient_data->activate == 0 && | ||
81 | transient_data->duration != 0) { | ||
82 | transient_data->activate = state; | ||
83 | led_set_brightness(led_cdev, transient_data->state); | ||
84 | transient_data->restore_state = | ||
85 | (transient_data->state == LED_FULL) ? LED_OFF : LED_FULL; | ||
86 | mod_timer(&transient_data->timer, | ||
87 | jiffies + transient_data->duration); | ||
88 | } | ||
89 | |||
90 | /* state == 0 && transient_data->activate == 0 | ||
91 | timer is not active - just return */ | ||
92 | /* state == 1 && transient_data->activate == 1 | ||
93 | timer is already active - just return */ | ||
94 | |||
95 | return size; | ||
96 | } | ||
97 | |||
98 | static ssize_t transient_duration_show(struct device *dev, | ||
99 | struct device_attribute *attr, char *buf) | ||
100 | { | ||
101 | struct led_classdev *led_cdev = dev_get_drvdata(dev); | ||
102 | struct transient_trig_data *transient_data = led_cdev->trigger_data; | ||
103 | |||
104 | return sprintf(buf, "%lu\n", transient_data->duration); | ||
105 | } | ||
106 | |||
107 | static ssize_t transient_duration_store(struct device *dev, | ||
108 | struct device_attribute *attr, const char *buf, size_t size) | ||
109 | { | ||
110 | struct led_classdev *led_cdev = dev_get_drvdata(dev); | ||
111 | struct transient_trig_data *transient_data = led_cdev->trigger_data; | ||
112 | unsigned long state; | ||
113 | ssize_t ret; | ||
114 | |||
115 | ret = kstrtoul(buf, 10, &state); | ||
116 | if (ret) | ||
117 | return ret; | ||
118 | |||
119 | transient_data->duration = state; | ||
120 | return size; | ||
121 | } | ||
122 | |||
123 | static ssize_t transient_state_show(struct device *dev, | ||
124 | struct device_attribute *attr, char *buf) | ||
125 | { | ||
126 | struct led_classdev *led_cdev = dev_get_drvdata(dev); | ||
127 | struct transient_trig_data *transient_data = led_cdev->trigger_data; | ||
128 | int state; | ||
129 | |||
130 | state = (transient_data->state == LED_FULL) ? 1 : 0; | ||
131 | return sprintf(buf, "%d\n", state); | ||
132 | } | ||
133 | |||
134 | static ssize_t transient_state_store(struct device *dev, | ||
135 | struct device_attribute *attr, const char *buf, size_t size) | ||
136 | { | ||
137 | struct led_classdev *led_cdev = dev_get_drvdata(dev); | ||
138 | struct transient_trig_data *transient_data = led_cdev->trigger_data; | ||
139 | unsigned long state; | ||
140 | ssize_t ret; | ||
141 | |||
142 | ret = kstrtoul(buf, 10, &state); | ||
143 | if (ret) | ||
144 | return ret; | ||
145 | |||
146 | if (state != 1 && state != 0) | ||
147 | return -EINVAL; | ||
148 | |||
149 | transient_data->state = (state == 1) ? LED_FULL : LED_OFF; | ||
150 | return size; | ||
151 | } | ||
152 | |||
153 | static DEVICE_ATTR(activate, 0644, transient_activate_show, | ||
154 | transient_activate_store); | ||
155 | static DEVICE_ATTR(duration, 0644, transient_duration_show, | ||
156 | transient_duration_store); | ||
157 | static DEVICE_ATTR(state, 0644, transient_state_show, transient_state_store); | ||
158 | |||
159 | static void transient_trig_activate(struct led_classdev *led_cdev) | ||
160 | { | ||
161 | int rc; | ||
162 | struct transient_trig_data *tdata; | ||
163 | |||
164 | tdata = kzalloc(sizeof(struct transient_trig_data), GFP_KERNEL); | ||
165 | if (!tdata) { | ||
166 | dev_err(led_cdev->dev, | ||
167 | "unable to allocate transient trigger\n"); | ||
168 | return; | ||
169 | } | ||
170 | led_cdev->trigger_data = tdata; | ||
171 | |||
172 | rc = device_create_file(led_cdev->dev, &dev_attr_activate); | ||
173 | if (rc) | ||
174 | goto err_out; | ||
175 | |||
176 | rc = device_create_file(led_cdev->dev, &dev_attr_duration); | ||
177 | if (rc) | ||
178 | goto err_out_duration; | ||
179 | |||
180 | rc = device_create_file(led_cdev->dev, &dev_attr_state); | ||
181 | if (rc) | ||
182 | goto err_out_state; | ||
183 | |||
184 | setup_timer(&tdata->timer, transient_timer_function, | ||
185 | (unsigned long) led_cdev); | ||
186 | led_cdev->activated = true; | ||
187 | |||
188 | return; | ||
189 | |||
190 | err_out_state: | ||
191 | device_remove_file(led_cdev->dev, &dev_attr_duration); | ||
192 | err_out_duration: | ||
193 | device_remove_file(led_cdev->dev, &dev_attr_activate); | ||
194 | err_out: | ||
195 | dev_err(led_cdev->dev, "unable to register transient trigger\n"); | ||
196 | led_cdev->trigger_data = NULL; | ||
197 | kfree(tdata); | ||
198 | } | ||
199 | |||
200 | static void transient_trig_deactivate(struct led_classdev *led_cdev) | ||
201 | { | ||
202 | struct transient_trig_data *transient_data = led_cdev->trigger_data; | ||
203 | |||
204 | if (led_cdev->activated) { | ||
205 | del_timer_sync(&transient_data->timer); | ||
206 | led_set_brightness(led_cdev, transient_data->restore_state); | ||
207 | device_remove_file(led_cdev->dev, &dev_attr_activate); | ||
208 | device_remove_file(led_cdev->dev, &dev_attr_duration); | ||
209 | device_remove_file(led_cdev->dev, &dev_attr_state); | ||
210 | led_cdev->trigger_data = NULL; | ||
211 | led_cdev->activated = false; | ||
212 | kfree(transient_data); | ||
213 | } | ||
214 | } | ||
215 | |||
216 | static struct led_trigger transient_trigger = { | ||
217 | .name = "transient", | ||
218 | .activate = transient_trig_activate, | ||
219 | .deactivate = transient_trig_deactivate, | ||
220 | }; | ||
221 | |||
222 | static int __init transient_trig_init(void) | ||
223 | { | ||
224 | return led_trigger_register(&transient_trigger); | ||
225 | } | ||
226 | |||
227 | static void __exit transient_trig_exit(void) | ||
228 | { | ||
229 | led_trigger_unregister(&transient_trigger); | ||
230 | } | ||
231 | |||
232 | module_init(transient_trig_init); | ||
233 | module_exit(transient_trig_exit); | ||
234 | |||
235 | MODULE_AUTHOR("Shuah Khan <shuahkhan@gmail.com>"); | ||
236 | MODULE_DESCRIPTION("Transient LED trigger"); | ||
237 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/platform/x86/toshiba_acpi.c b/drivers/platform/x86/toshiba_acpi.c index ee79ce64d9df..57787d87d9a4 100644 --- a/drivers/platform/x86/toshiba_acpi.c +++ b/drivers/platform/x86/toshiba_acpi.c | |||
@@ -1104,6 +1104,7 @@ static int __devinit toshiba_acpi_add(struct acpi_device *acpi_dev) | |||
1104 | 1104 | ||
1105 | mutex_init(&dev->mutex); | 1105 | mutex_init(&dev->mutex); |
1106 | 1106 | ||
1107 | memset(&props, 0, sizeof(props)); | ||
1107 | props.type = BACKLIGHT_PLATFORM; | 1108 | props.type = BACKLIGHT_PLATFORM; |
1108 | props.max_brightness = HCI_LCD_BRIGHTNESS_LEVELS - 1; | 1109 | props.max_brightness = HCI_LCD_BRIGHTNESS_LEVELS - 1; |
1109 | dev->backlight_dev = backlight_device_register("toshiba", | 1110 | dev->backlight_dev = backlight_device_register("toshiba", |
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig index 4161bfe462cd..08cbdb900a18 100644 --- a/drivers/rtc/Kconfig +++ b/drivers/rtc/Kconfig | |||
@@ -620,27 +620,6 @@ config RTC_DRV_MSM6242 | |||
620 | This driver can also be built as a module. If so, the module | 620 | This driver can also be built as a module. If so, the module |
621 | will be called rtc-msm6242. | 621 | will be called rtc-msm6242. |
622 | 622 | ||
623 | config RTC_DRV_IMXDI | ||
624 | tristate "Freescale IMX DryIce Real Time Clock" | ||
625 | depends on ARCH_MX25 | ||
626 | depends on RTC_CLASS | ||
627 | help | ||
628 | Support for Freescale IMX DryIce RTC | ||
629 | |||
630 | This driver can also be built as a module, if so, the module | ||
631 | will be called "rtc-imxdi". | ||
632 | |||
633 | config RTC_MXC | ||
634 | tristate "Freescale MXC Real Time Clock" | ||
635 | depends on ARCH_MXC | ||
636 | depends on RTC_CLASS | ||
637 | help | ||
638 | If you say yes here you get support for the Freescale MXC | ||
639 | RTC module. | ||
640 | |||
641 | This driver can also be built as a module, if so, the module | ||
642 | will be called "rtc-mxc". | ||
643 | |||
644 | config RTC_DRV_BQ4802 | 623 | config RTC_DRV_BQ4802 |
645 | tristate "TI BQ4802" | 624 | tristate "TI BQ4802" |
646 | help | 625 | help |
@@ -738,6 +717,16 @@ config RTC_DRV_DAVINCI | |||
738 | This driver can also be built as a module. If so, the module | 717 | This driver can also be built as a module. If so, the module |
739 | will be called rtc-davinci. | 718 | will be called rtc-davinci. |
740 | 719 | ||
720 | config RTC_DRV_IMXDI | ||
721 | tristate "Freescale IMX DryIce Real Time Clock" | ||
722 | depends on SOC_IMX25 | ||
723 | depends on RTC_CLASS | ||
724 | help | ||
725 | Support for Freescale IMX DryIce RTC | ||
726 | |||
727 | This driver can also be built as a module, if so, the module | ||
728 | will be called "rtc-imxdi". | ||
729 | |||
741 | config RTC_DRV_OMAP | 730 | config RTC_DRV_OMAP |
742 | tristate "TI OMAP1" | 731 | tristate "TI OMAP1" |
743 | depends on ARCH_OMAP15XX || ARCH_OMAP16XX || ARCH_OMAP730 || ARCH_DAVINCI_DA8XX | 732 | depends on ARCH_OMAP15XX || ARCH_OMAP16XX || ARCH_OMAP730 || ARCH_DAVINCI_DA8XX |
@@ -1087,4 +1076,15 @@ config RTC_DRV_LOONGSON1 | |||
1087 | This driver can also be built as a module. If so, the module | 1076 | This driver can also be built as a module. If so, the module |
1088 | will be called rtc-ls1x. | 1077 | will be called rtc-ls1x. |
1089 | 1078 | ||
1079 | config RTC_DRV_MXC | ||
1080 | tristate "Freescale MXC Real Time Clock" | ||
1081 | depends on ARCH_MXC | ||
1082 | depends on RTC_CLASS | ||
1083 | help | ||
1084 | If you say yes here you get support for the Freescale MXC | ||
1085 | RTC module. | ||
1086 | |||
1087 | This driver can also be built as a module, if so, the module | ||
1088 | will be called "rtc-mxc". | ||
1089 | |||
1090 | endif # RTC_CLASS | 1090 | endif # RTC_CLASS |
diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile index 727ae7786e6c..2973921c30d8 100644 --- a/drivers/rtc/Makefile +++ b/drivers/rtc/Makefile | |||
@@ -61,7 +61,7 @@ obj-$(CONFIG_RTC_DRV_M41T94) += rtc-m41t94.o | |||
61 | obj-$(CONFIG_RTC_DRV_M48T35) += rtc-m48t35.o | 61 | obj-$(CONFIG_RTC_DRV_M48T35) += rtc-m48t35.o |
62 | obj-$(CONFIG_RTC_DRV_M48T59) += rtc-m48t59.o | 62 | obj-$(CONFIG_RTC_DRV_M48T59) += rtc-m48t59.o |
63 | obj-$(CONFIG_RTC_DRV_M48T86) += rtc-m48t86.o | 63 | obj-$(CONFIG_RTC_DRV_M48T86) += rtc-m48t86.o |
64 | obj-$(CONFIG_RTC_MXC) += rtc-mxc.o | 64 | obj-$(CONFIG_RTC_DRV_MXC) += rtc-mxc.o |
65 | obj-$(CONFIG_RTC_DRV_MAX6900) += rtc-max6900.o | 65 | obj-$(CONFIG_RTC_DRV_MAX6900) += rtc-max6900.o |
66 | obj-$(CONFIG_RTC_DRV_MAX8925) += rtc-max8925.o | 66 | obj-$(CONFIG_RTC_DRV_MAX8925) += rtc-max8925.o |
67 | obj-$(CONFIG_RTC_DRV_MAX8998) += rtc-max8998.o | 67 | obj-$(CONFIG_RTC_DRV_MAX8998) += rtc-max8998.o |
diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c index c293d0cdb104..836710ce750e 100644 --- a/drivers/rtc/rtc-ds1307.c +++ b/drivers/rtc/rtc-ds1307.c | |||
@@ -17,8 +17,7 @@ | |||
17 | #include <linux/string.h> | 17 | #include <linux/string.h> |
18 | #include <linux/rtc.h> | 18 | #include <linux/rtc.h> |
19 | #include <linux/bcd.h> | 19 | #include <linux/bcd.h> |
20 | 20 | #include <linux/rtc/ds1307.h> | |
21 | |||
22 | 21 | ||
23 | /* | 22 | /* |
24 | * We can't determine type by probing, but if we expect pre-Linux code | 23 | * We can't determine type by probing, but if we expect pre-Linux code |
@@ -92,7 +91,8 @@ enum ds_type { | |||
92 | # define DS1337_BIT_A2I 0x02 | 91 | # define DS1337_BIT_A2I 0x02 |
93 | # define DS1337_BIT_A1I 0x01 | 92 | # define DS1337_BIT_A1I 0x01 |
94 | #define DS1339_REG_ALARM1_SECS 0x07 | 93 | #define DS1339_REG_ALARM1_SECS 0x07 |
95 | #define DS1339_REG_TRICKLE 0x10 | 94 | |
95 | #define DS13XX_TRICKLE_CHARGER_MAGIC 0xa0 | ||
96 | 96 | ||
97 | #define RX8025_REG_CTRL1 0x0e | 97 | #define RX8025_REG_CTRL1 0x0e |
98 | # define RX8025_BIT_2412 0x20 | 98 | # define RX8025_BIT_2412 0x20 |
@@ -124,6 +124,7 @@ struct chip_desc { | |||
124 | unsigned alarm:1; | 124 | unsigned alarm:1; |
125 | u16 nvram_offset; | 125 | u16 nvram_offset; |
126 | u16 nvram_size; | 126 | u16 nvram_size; |
127 | u16 trickle_charger_reg; | ||
127 | }; | 128 | }; |
128 | 129 | ||
129 | static const struct chip_desc chips[last_ds_type] = { | 130 | static const struct chip_desc chips[last_ds_type] = { |
@@ -140,6 +141,13 @@ static const struct chip_desc chips[last_ds_type] = { | |||
140 | }, | 141 | }, |
141 | [ds_1339] = { | 142 | [ds_1339] = { |
142 | .alarm = 1, | 143 | .alarm = 1, |
144 | .trickle_charger_reg = 0x10, | ||
145 | }, | ||
146 | [ds_1340] = { | ||
147 | .trickle_charger_reg = 0x08, | ||
148 | }, | ||
149 | [ds_1388] = { | ||
150 | .trickle_charger_reg = 0x0a, | ||
143 | }, | 151 | }, |
144 | [ds_3231] = { | 152 | [ds_3231] = { |
145 | .alarm = 1, | 153 | .alarm = 1, |
@@ -619,6 +627,7 @@ static int __devinit ds1307_probe(struct i2c_client *client, | |||
619 | struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent); | 627 | struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent); |
620 | int want_irq = false; | 628 | int want_irq = false; |
621 | unsigned char *buf; | 629 | unsigned char *buf; |
630 | struct ds1307_platform_data *pdata = client->dev.platform_data; | ||
622 | static const int bbsqi_bitpos[] = { | 631 | static const int bbsqi_bitpos[] = { |
623 | [ds_1337] = 0, | 632 | [ds_1337] = 0, |
624 | [ds_1339] = DS1339_BIT_BBSQI, | 633 | [ds_1339] = DS1339_BIT_BBSQI, |
@@ -637,7 +646,10 @@ static int __devinit ds1307_probe(struct i2c_client *client, | |||
637 | 646 | ||
638 | ds1307->client = client; | 647 | ds1307->client = client; |
639 | ds1307->type = id->driver_data; | 648 | ds1307->type = id->driver_data; |
640 | ds1307->offset = 0; | 649 | |
650 | if (pdata && pdata->trickle_charger_setup && chip->trickle_charger_reg) | ||
651 | i2c_smbus_write_byte_data(client, chip->trickle_charger_reg, | ||
652 | DS13XX_TRICKLE_CHARGER_MAGIC | pdata->trickle_charger_setup); | ||
641 | 653 | ||
642 | buf = ds1307->regs; | 654 | buf = ds1307->regs; |
643 | if (i2c_check_functionality(adapter, I2C_FUNC_SMBUS_I2C_BLOCK)) { | 655 | if (i2c_check_functionality(adapter, I2C_FUNC_SMBUS_I2C_BLOCK)) { |
diff --git a/drivers/rtc/rtc-ep93xx.c b/drivers/rtc/rtc-ep93xx.c index 14a42a1edc66..9602278ff988 100644 --- a/drivers/rtc/rtc-ep93xx.c +++ b/drivers/rtc/rtc-ep93xx.c | |||
@@ -127,7 +127,7 @@ static const struct attribute_group ep93xx_rtc_sysfs_files = { | |||
127 | .attrs = ep93xx_rtc_attrs, | 127 | .attrs = ep93xx_rtc_attrs, |
128 | }; | 128 | }; |
129 | 129 | ||
130 | static int __init ep93xx_rtc_probe(struct platform_device *pdev) | 130 | static int __devinit ep93xx_rtc_probe(struct platform_device *pdev) |
131 | { | 131 | { |
132 | struct ep93xx_rtc *ep93xx_rtc; | 132 | struct ep93xx_rtc *ep93xx_rtc; |
133 | struct resource *res; | 133 | struct resource *res; |
@@ -174,7 +174,7 @@ exit: | |||
174 | return err; | 174 | return err; |
175 | } | 175 | } |
176 | 176 | ||
177 | static int __exit ep93xx_rtc_remove(struct platform_device *pdev) | 177 | static int __devexit ep93xx_rtc_remove(struct platform_device *pdev) |
178 | { | 178 | { |
179 | struct ep93xx_rtc *ep93xx_rtc = platform_get_drvdata(pdev); | 179 | struct ep93xx_rtc *ep93xx_rtc = platform_get_drvdata(pdev); |
180 | 180 | ||
@@ -186,31 +186,19 @@ static int __exit ep93xx_rtc_remove(struct platform_device *pdev) | |||
186 | return 0; | 186 | return 0; |
187 | } | 187 | } |
188 | 188 | ||
189 | /* work with hotplug and coldplug */ | ||
190 | MODULE_ALIAS("platform:ep93xx-rtc"); | ||
191 | |||
192 | static struct platform_driver ep93xx_rtc_driver = { | 189 | static struct platform_driver ep93xx_rtc_driver = { |
193 | .driver = { | 190 | .driver = { |
194 | .name = "ep93xx-rtc", | 191 | .name = "ep93xx-rtc", |
195 | .owner = THIS_MODULE, | 192 | .owner = THIS_MODULE, |
196 | }, | 193 | }, |
197 | .remove = __exit_p(ep93xx_rtc_remove), | 194 | .probe = ep93xx_rtc_probe, |
195 | .remove = __devexit_p(ep93xx_rtc_remove), | ||
198 | }; | 196 | }; |
199 | 197 | ||
200 | static int __init ep93xx_rtc_init(void) | 198 | module_platform_driver(ep93xx_rtc_driver); |
201 | { | ||
202 | return platform_driver_probe(&ep93xx_rtc_driver, ep93xx_rtc_probe); | ||
203 | } | ||
204 | |||
205 | static void __exit ep93xx_rtc_exit(void) | ||
206 | { | ||
207 | platform_driver_unregister(&ep93xx_rtc_driver); | ||
208 | } | ||
209 | 199 | ||
210 | MODULE_AUTHOR("Alessandro Zummo <a.zummo@towertech.it>"); | 200 | MODULE_AUTHOR("Alessandro Zummo <a.zummo@towertech.it>"); |
211 | MODULE_DESCRIPTION("EP93XX RTC driver"); | 201 | MODULE_DESCRIPTION("EP93XX RTC driver"); |
212 | MODULE_LICENSE("GPL"); | 202 | MODULE_LICENSE("GPL"); |
213 | MODULE_VERSION(DRV_VERSION); | 203 | MODULE_VERSION(DRV_VERSION); |
214 | 204 | MODULE_ALIAS("platform:ep93xx-rtc"); | |
215 | module_init(ep93xx_rtc_init); | ||
216 | module_exit(ep93xx_rtc_exit); | ||
diff --git a/drivers/rtc/rtc-lpc32xx.c b/drivers/rtc/rtc-lpc32xx.c index 63c72189c64b..d5218553741f 100644 --- a/drivers/rtc/rtc-lpc32xx.c +++ b/drivers/rtc/rtc-lpc32xx.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include <linux/rtc.h> | 19 | #include <linux/rtc.h> |
20 | #include <linux/slab.h> | 20 | #include <linux/slab.h> |
21 | #include <linux/io.h> | 21 | #include <linux/io.h> |
22 | #include <linux/of.h> | ||
22 | 23 | ||
23 | /* | 24 | /* |
24 | * Clock and Power control register offsets | 25 | * Clock and Power control register offsets |
@@ -386,13 +387,22 @@ static const struct dev_pm_ops lpc32xx_rtc_pm_ops = { | |||
386 | #define LPC32XX_RTC_PM_OPS NULL | 387 | #define LPC32XX_RTC_PM_OPS NULL |
387 | #endif | 388 | #endif |
388 | 389 | ||
390 | #ifdef CONFIG_OF | ||
391 | static const struct of_device_id lpc32xx_rtc_match[] = { | ||
392 | { .compatible = "nxp,lpc3220-rtc" }, | ||
393 | { } | ||
394 | }; | ||
395 | MODULE_DEVICE_TABLE(of, lpc32xx_rtc_match); | ||
396 | #endif | ||
397 | |||
389 | static struct platform_driver lpc32xx_rtc_driver = { | 398 | static struct platform_driver lpc32xx_rtc_driver = { |
390 | .probe = lpc32xx_rtc_probe, | 399 | .probe = lpc32xx_rtc_probe, |
391 | .remove = __devexit_p(lpc32xx_rtc_remove), | 400 | .remove = __devexit_p(lpc32xx_rtc_remove), |
392 | .driver = { | 401 | .driver = { |
393 | .name = RTC_NAME, | 402 | .name = RTC_NAME, |
394 | .owner = THIS_MODULE, | 403 | .owner = THIS_MODULE, |
395 | .pm = LPC32XX_RTC_PM_OPS | 404 | .pm = LPC32XX_RTC_PM_OPS, |
405 | .of_match_table = of_match_ptr(lpc32xx_rtc_match), | ||
396 | }, | 406 | }, |
397 | }; | 407 | }; |
398 | 408 | ||
diff --git a/drivers/rtc/rtc-m41t93.c b/drivers/rtc/rtc-m41t93.c index 10f1c29436ec..efab3d48cb15 100644 --- a/drivers/rtc/rtc-m41t93.c +++ b/drivers/rtc/rtc-m41t93.c | |||
@@ -48,6 +48,7 @@ static inline int m41t93_set_reg(struct spi_device *spi, u8 addr, u8 data) | |||
48 | static int m41t93_set_time(struct device *dev, struct rtc_time *tm) | 48 | static int m41t93_set_time(struct device *dev, struct rtc_time *tm) |
49 | { | 49 | { |
50 | struct spi_device *spi = to_spi_device(dev); | 50 | struct spi_device *spi = to_spi_device(dev); |
51 | int tmp; | ||
51 | u8 buf[9] = {0x80}; /* write cmd + 8 data bytes */ | 52 | u8 buf[9] = {0x80}; /* write cmd + 8 data bytes */ |
52 | u8 * const data = &buf[1]; /* ptr to first data byte */ | 53 | u8 * const data = &buf[1]; /* ptr to first data byte */ |
53 | 54 | ||
@@ -62,6 +63,30 @@ static int m41t93_set_time(struct device *dev, struct rtc_time *tm) | |||
62 | return -EINVAL; | 63 | return -EINVAL; |
63 | } | 64 | } |
64 | 65 | ||
66 | tmp = spi_w8r8(spi, M41T93_REG_FLAGS); | ||
67 | if (tmp < 0) | ||
68 | return tmp; | ||
69 | |||
70 | if (tmp & M41T93_FLAG_OF) { | ||
71 | dev_warn(&spi->dev, "OF bit is set, resetting.\n"); | ||
72 | m41t93_set_reg(spi, M41T93_REG_FLAGS, tmp & ~M41T93_FLAG_OF); | ||
73 | |||
74 | tmp = spi_w8r8(spi, M41T93_REG_FLAGS); | ||
75 | if (tmp < 0) { | ||
76 | return tmp; | ||
77 | } else if (tmp & M41T93_FLAG_OF) { | ||
78 | /* OF cannot be immediately reset: oscillator has to be | ||
79 | * restarted. */ | ||
80 | u8 reset_osc = buf[M41T93_REG_ST_SEC] | M41T93_FLAG_ST; | ||
81 | |||
82 | dev_warn(&spi->dev, | ||
83 | "OF bit is still set, kickstarting clock.\n"); | ||
84 | m41t93_set_reg(spi, M41T93_REG_ST_SEC, reset_osc); | ||
85 | reset_osc &= ~M41T93_FLAG_ST; | ||
86 | m41t93_set_reg(spi, M41T93_REG_ST_SEC, reset_osc); | ||
87 | } | ||
88 | } | ||
89 | |||
65 | data[M41T93_REG_SSEC] = 0; | 90 | data[M41T93_REG_SSEC] = 0; |
66 | data[M41T93_REG_ST_SEC] = bin2bcd(tm->tm_sec); | 91 | data[M41T93_REG_ST_SEC] = bin2bcd(tm->tm_sec); |
67 | data[M41T93_REG_MIN] = bin2bcd(tm->tm_min); | 92 | data[M41T93_REG_MIN] = bin2bcd(tm->tm_min); |
@@ -89,10 +114,7 @@ static int m41t93_get_time(struct device *dev, struct rtc_time *tm) | |||
89 | 1. halt bit (HT) is set: the clock is running but update of readout | 114 | 1. halt bit (HT) is set: the clock is running but update of readout |
90 | registers has been disabled due to power failure. This is normal | 115 | registers has been disabled due to power failure. This is normal |
91 | case after poweron. Time is valid after resetting HT bit. | 116 | case after poweron. Time is valid after resetting HT bit. |
92 | 2. oscillator fail bit (OF) is set. Oscillator has be stopped and | 117 | 2. oscillator fail bit (OF) is set: time is invalid. |
93 | time is invalid: | ||
94 | a) OF can be immeditely reset. | ||
95 | b) OF cannot be immediately reset: oscillator has to be restarted. | ||
96 | */ | 118 | */ |
97 | tmp = spi_w8r8(spi, M41T93_REG_ALM_HOUR_HT); | 119 | tmp = spi_w8r8(spi, M41T93_REG_ALM_HOUR_HT); |
98 | if (tmp < 0) | 120 | if (tmp < 0) |
@@ -110,21 +132,7 @@ static int m41t93_get_time(struct device *dev, struct rtc_time *tm) | |||
110 | 132 | ||
111 | if (tmp & M41T93_FLAG_OF) { | 133 | if (tmp & M41T93_FLAG_OF) { |
112 | ret = -EINVAL; | 134 | ret = -EINVAL; |
113 | dev_warn(&spi->dev, "OF bit is set, resetting.\n"); | 135 | dev_warn(&spi->dev, "OF bit is set, write time to restart.\n"); |
114 | m41t93_set_reg(spi, M41T93_REG_FLAGS, tmp & ~M41T93_FLAG_OF); | ||
115 | |||
116 | tmp = spi_w8r8(spi, M41T93_REG_FLAGS); | ||
117 | if (tmp < 0) | ||
118 | return tmp; | ||
119 | else if (tmp & M41T93_FLAG_OF) { | ||
120 | u8 reset_osc = buf[M41T93_REG_ST_SEC] | M41T93_FLAG_ST; | ||
121 | |||
122 | dev_warn(&spi->dev, | ||
123 | "OF bit is still set, kickstarting clock.\n"); | ||
124 | m41t93_set_reg(spi, M41T93_REG_ST_SEC, reset_osc); | ||
125 | reset_osc &= ~M41T93_FLAG_ST; | ||
126 | m41t93_set_reg(spi, M41T93_REG_ST_SEC, reset_osc); | ||
127 | } | ||
128 | } | 136 | } |
129 | 137 | ||
130 | if (tmp & M41T93_FLAG_BL) | 138 | if (tmp & M41T93_FLAG_BL) |
diff --git a/drivers/rtc/rtc-pcf8563.c b/drivers/rtc/rtc-pcf8563.c index bc0677de1996..97a3284bb7c6 100644 --- a/drivers/rtc/rtc-pcf8563.c +++ b/drivers/rtc/rtc-pcf8563.c | |||
@@ -64,6 +64,7 @@ struct pcf8563 { | |||
64 | * 1970...2069. | 64 | * 1970...2069. |
65 | */ | 65 | */ |
66 | int c_polarity; /* 0: MO_C=1 means 19xx, otherwise MO_C=1 means 20xx */ | 66 | int c_polarity; /* 0: MO_C=1 means 19xx, otherwise MO_C=1 means 20xx */ |
67 | int voltage_low; /* incicates if a low_voltage was detected */ | ||
67 | }; | 68 | }; |
68 | 69 | ||
69 | /* | 70 | /* |
@@ -86,9 +87,11 @@ static int pcf8563_get_datetime(struct i2c_client *client, struct rtc_time *tm) | |||
86 | return -EIO; | 87 | return -EIO; |
87 | } | 88 | } |
88 | 89 | ||
89 | if (buf[PCF8563_REG_SC] & PCF8563_SC_LV) | 90 | if (buf[PCF8563_REG_SC] & PCF8563_SC_LV) { |
91 | pcf8563->voltage_low = 1; | ||
90 | dev_info(&client->dev, | 92 | dev_info(&client->dev, |
91 | "low voltage detected, date/time is not reliable.\n"); | 93 | "low voltage detected, date/time is not reliable.\n"); |
94 | } | ||
92 | 95 | ||
93 | dev_dbg(&client->dev, | 96 | dev_dbg(&client->dev, |
94 | "%s: raw data is st1=%02x, st2=%02x, sec=%02x, min=%02x, hr=%02x, " | 97 | "%s: raw data is st1=%02x, st2=%02x, sec=%02x, min=%02x, hr=%02x, " |
@@ -173,6 +176,44 @@ static int pcf8563_set_datetime(struct i2c_client *client, struct rtc_time *tm) | |||
173 | return 0; | 176 | return 0; |
174 | } | 177 | } |
175 | 178 | ||
179 | #ifdef CONFIG_RTC_INTF_DEV | ||
180 | static int pcf8563_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg) | ||
181 | { | ||
182 | struct pcf8563 *pcf8563 = i2c_get_clientdata(to_i2c_client(dev)); | ||
183 | struct rtc_time tm; | ||
184 | |||
185 | switch (cmd) { | ||
186 | case RTC_VL_READ: | ||
187 | if (pcf8563->voltage_low) | ||
188 | dev_info(dev, "low voltage detected, date/time is not reliable.\n"); | ||
189 | |||
190 | if (copy_to_user((void __user *)arg, &pcf8563->voltage_low, | ||
191 | sizeof(int))) | ||
192 | return -EFAULT; | ||
193 | return 0; | ||
194 | case RTC_VL_CLR: | ||
195 | /* | ||
196 | * Clear the VL bit in the seconds register in case | ||
197 | * the time has not been set already (which would | ||
198 | * have cleared it). This does not really matter | ||
199 | * because of the cached voltage_low value but do it | ||
200 | * anyway for consistency. | ||
201 | */ | ||
202 | if (pcf8563_get_datetime(to_i2c_client(dev), &tm)) | ||
203 | pcf8563_set_datetime(to_i2c_client(dev), &tm); | ||
204 | |||
205 | /* Clear the cached value. */ | ||
206 | pcf8563->voltage_low = 0; | ||
207 | |||
208 | return 0; | ||
209 | default: | ||
210 | return -ENOIOCTLCMD; | ||
211 | } | ||
212 | } | ||
213 | #else | ||
214 | #define pcf8563_rtc_ioctl NULL | ||
215 | #endif | ||
216 | |||
176 | static int pcf8563_rtc_read_time(struct device *dev, struct rtc_time *tm) | 217 | static int pcf8563_rtc_read_time(struct device *dev, struct rtc_time *tm) |
177 | { | 218 | { |
178 | return pcf8563_get_datetime(to_i2c_client(dev), tm); | 219 | return pcf8563_get_datetime(to_i2c_client(dev), tm); |
@@ -184,6 +225,7 @@ static int pcf8563_rtc_set_time(struct device *dev, struct rtc_time *tm) | |||
184 | } | 225 | } |
185 | 226 | ||
186 | static const struct rtc_class_ops pcf8563_rtc_ops = { | 227 | static const struct rtc_class_ops pcf8563_rtc_ops = { |
228 | .ioctl = pcf8563_rtc_ioctl, | ||
187 | .read_time = pcf8563_rtc_read_time, | 229 | .read_time = pcf8563_rtc_read_time, |
188 | .set_time = pcf8563_rtc_set_time, | 230 | .set_time = pcf8563_rtc_set_time, |
189 | }; | 231 | }; |
diff --git a/drivers/rtc/rtc-pl031.c b/drivers/rtc/rtc-pl031.c index f027c063fb20..cc0533994f6e 100644 --- a/drivers/rtc/rtc-pl031.c +++ b/drivers/rtc/rtc-pl031.c | |||
@@ -220,17 +220,9 @@ static irqreturn_t pl031_interrupt(int irq, void *dev_id) | |||
220 | unsigned long events = 0; | 220 | unsigned long events = 0; |
221 | 221 | ||
222 | rtcmis = readl(ldata->base + RTC_MIS); | 222 | rtcmis = readl(ldata->base + RTC_MIS); |
223 | if (rtcmis) { | 223 | if (rtcmis & RTC_BIT_AI) { |
224 | writel(rtcmis, ldata->base + RTC_ICR); | 224 | writel(RTC_BIT_AI, ldata->base + RTC_ICR); |
225 | 225 | events |= (RTC_AF | RTC_IRQF); | |
226 | if (rtcmis & RTC_BIT_AI) | ||
227 | events |= (RTC_AF | RTC_IRQF); | ||
228 | |||
229 | /* Timer interrupt is only available in ST variants */ | ||
230 | if ((rtcmis & RTC_BIT_PI) && | ||
231 | (ldata->hw_designer == AMBA_VENDOR_ST)) | ||
232 | events |= (RTC_PF | RTC_IRQF); | ||
233 | |||
234 | rtc_update_irq(ldata->rtc, 1, events); | 226 | rtc_update_irq(ldata->rtc, 1, events); |
235 | 227 | ||
236 | return IRQ_HANDLED; | 228 | return IRQ_HANDLED; |
diff --git a/drivers/rtc/rtc-s3c.c b/drivers/rtc/rtc-s3c.c index 3f3a29752369..7e6af0b22f17 100644 --- a/drivers/rtc/rtc-s3c.c +++ b/drivers/rtc/rtc-s3c.c | |||
@@ -670,6 +670,7 @@ static int s3c_rtc_resume(struct platform_device *pdev) | |||
670 | #define s3c_rtc_resume NULL | 670 | #define s3c_rtc_resume NULL |
671 | #endif | 671 | #endif |
672 | 672 | ||
673 | #ifdef CONFIG_OF | ||
673 | static struct s3c_rtc_drv_data s3c_rtc_drv_data_array[] = { | 674 | static struct s3c_rtc_drv_data s3c_rtc_drv_data_array[] = { |
674 | [TYPE_S3C2410] = { TYPE_S3C2410 }, | 675 | [TYPE_S3C2410] = { TYPE_S3C2410 }, |
675 | [TYPE_S3C2416] = { TYPE_S3C2416 }, | 676 | [TYPE_S3C2416] = { TYPE_S3C2416 }, |
@@ -677,7 +678,6 @@ static struct s3c_rtc_drv_data s3c_rtc_drv_data_array[] = { | |||
677 | [TYPE_S3C64XX] = { TYPE_S3C64XX }, | 678 | [TYPE_S3C64XX] = { TYPE_S3C64XX }, |
678 | }; | 679 | }; |
679 | 680 | ||
680 | #ifdef CONFIG_OF | ||
681 | static const struct of_device_id s3c_rtc_dt_match[] = { | 681 | static const struct of_device_id s3c_rtc_dt_match[] = { |
682 | { | 682 | { |
683 | .compatible = "samsung,s3c2410-rtc", | 683 | .compatible = "samsung,s3c2410-rtc", |
diff --git a/drivers/rtc/rtc-spear.c b/drivers/rtc/rtc-spear.c index e38da0dc4187..1f76320e545b 100644 --- a/drivers/rtc/rtc-spear.c +++ b/drivers/rtc/rtc-spear.c | |||
@@ -16,6 +16,7 @@ | |||
16 | #include <linux/io.h> | 16 | #include <linux/io.h> |
17 | #include <linux/irq.h> | 17 | #include <linux/irq.h> |
18 | #include <linux/module.h> | 18 | #include <linux/module.h> |
19 | #include <linux/of.h> | ||
19 | #include <linux/platform_device.h> | 20 | #include <linux/platform_device.h> |
20 | #include <linux/rtc.h> | 21 | #include <linux/rtc.h> |
21 | #include <linux/slab.h> | 22 | #include <linux/slab.h> |
@@ -519,6 +520,14 @@ static void spear_rtc_shutdown(struct platform_device *pdev) | |||
519 | clk_disable(config->clk); | 520 | clk_disable(config->clk); |
520 | } | 521 | } |
521 | 522 | ||
523 | #ifdef CONFIG_OF | ||
524 | static const struct of_device_id spear_rtc_id_table[] = { | ||
525 | { .compatible = "st,spear600-rtc" }, | ||
526 | {} | ||
527 | }; | ||
528 | MODULE_DEVICE_TABLE(of, spear_rtc_id_table); | ||
529 | #endif | ||
530 | |||
522 | static struct platform_driver spear_rtc_driver = { | 531 | static struct platform_driver spear_rtc_driver = { |
523 | .probe = spear_rtc_probe, | 532 | .probe = spear_rtc_probe, |
524 | .remove = __devexit_p(spear_rtc_remove), | 533 | .remove = __devexit_p(spear_rtc_remove), |
@@ -527,6 +536,7 @@ static struct platform_driver spear_rtc_driver = { | |||
527 | .shutdown = spear_rtc_shutdown, | 536 | .shutdown = spear_rtc_shutdown, |
528 | .driver = { | 537 | .driver = { |
529 | .name = "rtc-spear", | 538 | .name = "rtc-spear", |
539 | .of_match_table = of_match_ptr(spear_rtc_id_table), | ||
530 | }, | 540 | }, |
531 | }; | 541 | }; |
532 | 542 | ||
diff --git a/drivers/rtc/rtc-tegra.c b/drivers/rtc/rtc-tegra.c index 75259fe38602..c006025cecc8 100644 --- a/drivers/rtc/rtc-tegra.c +++ b/drivers/rtc/rtc-tegra.c | |||
@@ -309,7 +309,8 @@ static int __devinit tegra_rtc_probe(struct platform_device *pdev) | |||
309 | struct resource *res; | 309 | struct resource *res; |
310 | int ret; | 310 | int ret; |
311 | 311 | ||
312 | info = kzalloc(sizeof(struct tegra_rtc_info), GFP_KERNEL); | 312 | info = devm_kzalloc(&pdev->dev, sizeof(struct tegra_rtc_info), |
313 | GFP_KERNEL); | ||
313 | if (!info) | 314 | if (!info) |
314 | return -ENOMEM; | 315 | return -ENOMEM; |
315 | 316 | ||
@@ -317,29 +318,18 @@ static int __devinit tegra_rtc_probe(struct platform_device *pdev) | |||
317 | if (!res) { | 318 | if (!res) { |
318 | dev_err(&pdev->dev, | 319 | dev_err(&pdev->dev, |
319 | "Unable to allocate resources for device.\n"); | 320 | "Unable to allocate resources for device.\n"); |
320 | ret = -EBUSY; | 321 | return -EBUSY; |
321 | goto err_free_info; | ||
322 | } | 322 | } |
323 | 323 | ||
324 | if (!request_mem_region(res->start, resource_size(res), pdev->name)) { | 324 | info->rtc_base = devm_request_and_ioremap(&pdev->dev, res); |
325 | dev_err(&pdev->dev, | 325 | if (!info->rtc_base) { |
326 | "Unable to request mem region for device.\n"); | 326 | dev_err(&pdev->dev, "Unable to request mem region and grab IOs for device.\n"); |
327 | ret = -EBUSY; | 327 | return -EBUSY; |
328 | goto err_free_info; | ||
329 | } | 328 | } |
330 | 329 | ||
331 | info->tegra_rtc_irq = platform_get_irq(pdev, 0); | 330 | info->tegra_rtc_irq = platform_get_irq(pdev, 0); |
332 | if (info->tegra_rtc_irq <= 0) { | 331 | if (info->tegra_rtc_irq <= 0) |
333 | ret = -EBUSY; | 332 | return -EBUSY; |
334 | goto err_release_mem_region; | ||
335 | } | ||
336 | |||
337 | info->rtc_base = ioremap_nocache(res->start, resource_size(res)); | ||
338 | if (!info->rtc_base) { | ||
339 | dev_err(&pdev->dev, "Unable to grab IOs for device.\n"); | ||
340 | ret = -EBUSY; | ||
341 | goto err_release_mem_region; | ||
342 | } | ||
343 | 333 | ||
344 | /* set context info. */ | 334 | /* set context info. */ |
345 | info->pdev = pdev; | 335 | info->pdev = pdev; |
@@ -362,11 +352,12 @@ static int __devinit tegra_rtc_probe(struct platform_device *pdev) | |||
362 | dev_err(&pdev->dev, | 352 | dev_err(&pdev->dev, |
363 | "Unable to register device (err=%d).\n", | 353 | "Unable to register device (err=%d).\n", |
364 | ret); | 354 | ret); |
365 | goto err_iounmap; | 355 | return ret; |
366 | } | 356 | } |
367 | 357 | ||
368 | ret = request_irq(info->tegra_rtc_irq, tegra_rtc_irq_handler, | 358 | ret = devm_request_irq(&pdev->dev, info->tegra_rtc_irq, |
369 | IRQF_TRIGGER_HIGH, "rtc alarm", &pdev->dev); | 359 | tegra_rtc_irq_handler, IRQF_TRIGGER_HIGH, |
360 | "rtc alarm", &pdev->dev); | ||
370 | if (ret) { | 361 | if (ret) { |
371 | dev_err(&pdev->dev, | 362 | dev_err(&pdev->dev, |
372 | "Unable to request interrupt for device (err=%d).\n", | 363 | "Unable to request interrupt for device (err=%d).\n", |
@@ -380,12 +371,6 @@ static int __devinit tegra_rtc_probe(struct platform_device *pdev) | |||
380 | 371 | ||
381 | err_dev_unreg: | 372 | err_dev_unreg: |
382 | rtc_device_unregister(info->rtc_dev); | 373 | rtc_device_unregister(info->rtc_dev); |
383 | err_iounmap: | ||
384 | iounmap(info->rtc_base); | ||
385 | err_release_mem_region: | ||
386 | release_mem_region(res->start, resource_size(res)); | ||
387 | err_free_info: | ||
388 | kfree(info); | ||
389 | 374 | ||
390 | return ret; | 375 | return ret; |
391 | } | 376 | } |
@@ -393,17 +378,8 @@ err_free_info: | |||
393 | static int __devexit tegra_rtc_remove(struct platform_device *pdev) | 378 | static int __devexit tegra_rtc_remove(struct platform_device *pdev) |
394 | { | 379 | { |
395 | struct tegra_rtc_info *info = platform_get_drvdata(pdev); | 380 | struct tegra_rtc_info *info = platform_get_drvdata(pdev); |
396 | struct resource *res; | ||
397 | |||
398 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
399 | if (!res) | ||
400 | return -EBUSY; | ||
401 | 381 | ||
402 | free_irq(info->tegra_rtc_irq, &pdev->dev); | ||
403 | rtc_device_unregister(info->rtc_dev); | 382 | rtc_device_unregister(info->rtc_dev); |
404 | iounmap(info->rtc_base); | ||
405 | release_mem_region(res->start, resource_size(res)); | ||
406 | kfree(info); | ||
407 | 383 | ||
408 | platform_set_drvdata(pdev, NULL); | 384 | platform_set_drvdata(pdev, NULL); |
409 | 385 | ||
diff --git a/drivers/staging/android/ashmem.c b/drivers/staging/android/ashmem.c index 4511420849bc..e84dbecd0991 100644 --- a/drivers/staging/android/ashmem.c +++ b/drivers/staging/android/ashmem.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include <linux/module.h> | 19 | #include <linux/module.h> |
20 | #include <linux/file.h> | 20 | #include <linux/file.h> |
21 | #include <linux/fs.h> | 21 | #include <linux/fs.h> |
22 | #include <linux/falloc.h> | ||
22 | #include <linux/miscdevice.h> | 23 | #include <linux/miscdevice.h> |
23 | #include <linux/security.h> | 24 | #include <linux/security.h> |
24 | #include <linux/mm.h> | 25 | #include <linux/mm.h> |
@@ -363,11 +364,12 @@ static int ashmem_shrink(struct shrinker *s, struct shrink_control *sc) | |||
363 | 364 | ||
364 | mutex_lock(&ashmem_mutex); | 365 | mutex_lock(&ashmem_mutex); |
365 | list_for_each_entry_safe(range, next, &ashmem_lru_list, lru) { | 366 | list_for_each_entry_safe(range, next, &ashmem_lru_list, lru) { |
366 | struct inode *inode = range->asma->file->f_dentry->d_inode; | ||
367 | loff_t start = range->pgstart * PAGE_SIZE; | 367 | loff_t start = range->pgstart * PAGE_SIZE; |
368 | loff_t end = (range->pgend + 1) * PAGE_SIZE - 1; | 368 | loff_t end = (range->pgend + 1) * PAGE_SIZE; |
369 | 369 | ||
370 | vmtruncate_range(inode, start, end); | 370 | do_fallocate(range->asma->file, |
371 | FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, | ||
372 | start, end - start); | ||
371 | range->purged = ASHMEM_WAS_PURGED; | 373 | range->purged = ASHMEM_WAS_PURGED; |
372 | lru_del(range); | 374 | lru_del(range); |
373 | 375 | ||
diff --git a/drivers/video/backlight/Kconfig b/drivers/video/backlight/Kconfig index af16884491ed..fa2b03750316 100644 --- a/drivers/video/backlight/Kconfig +++ b/drivers/video/backlight/Kconfig | |||
@@ -184,6 +184,18 @@ config BACKLIGHT_GENERIC | |||
184 | known as the Corgi backlight driver. If you have a Sharp Zaurus | 184 | known as the Corgi backlight driver. If you have a Sharp Zaurus |
185 | SL-C7xx, SL-Cxx00 or SL-6000x say y. | 185 | SL-C7xx, SL-Cxx00 or SL-6000x say y. |
186 | 186 | ||
187 | config BACKLIGHT_LM3533 | ||
188 | tristate "Backlight Driver for LM3533" | ||
189 | depends on BACKLIGHT_CLASS_DEVICE | ||
190 | depends on MFD_LM3533 | ||
191 | help | ||
192 | Say Y to enable the backlight driver for National Semiconductor / TI | ||
193 | LM3533 Lighting Power chips. | ||
194 | |||
195 | The backlights can be controlled directly, through PWM input, or by | ||
196 | the ambient-light-sensor interface. The chip supports 256 brightness | ||
197 | levels. | ||
198 | |||
187 | config BACKLIGHT_LOCOMO | 199 | config BACKLIGHT_LOCOMO |
188 | tristate "Sharp LOCOMO LCD/Backlight Driver" | 200 | tristate "Sharp LOCOMO LCD/Backlight Driver" |
189 | depends on SHARP_LOCOMO | 201 | depends on SHARP_LOCOMO |
diff --git a/drivers/video/backlight/Makefile b/drivers/video/backlight/Makefile index 36855ae887d6..a2ac9cfbaf6b 100644 --- a/drivers/video/backlight/Makefile +++ b/drivers/video/backlight/Makefile | |||
@@ -21,6 +21,7 @@ obj-$(CONFIG_BACKLIGHT_EP93XX) += ep93xx_bl.o | |||
21 | obj-$(CONFIG_BACKLIGHT_GENERIC) += generic_bl.o | 21 | obj-$(CONFIG_BACKLIGHT_GENERIC) += generic_bl.o |
22 | obj-$(CONFIG_BACKLIGHT_HP700) += jornada720_bl.o | 22 | obj-$(CONFIG_BACKLIGHT_HP700) += jornada720_bl.o |
23 | obj-$(CONFIG_BACKLIGHT_HP680) += hp680_bl.o | 23 | obj-$(CONFIG_BACKLIGHT_HP680) += hp680_bl.o |
24 | obj-$(CONFIG_BACKLIGHT_LM3533) += lm3533_bl.o | ||
24 | obj-$(CONFIG_BACKLIGHT_LOCOMO) += locomolcd.o | 25 | obj-$(CONFIG_BACKLIGHT_LOCOMO) += locomolcd.o |
25 | obj-$(CONFIG_BACKLIGHT_LP855X) += lp855x_bl.o | 26 | obj-$(CONFIG_BACKLIGHT_LP855X) += lp855x_bl.o |
26 | obj-$(CONFIG_BACKLIGHT_OMAP1) += omap1_bl.o | 27 | obj-$(CONFIG_BACKLIGHT_OMAP1) += omap1_bl.o |
diff --git a/drivers/video/backlight/adp5520_bl.c b/drivers/video/backlight/adp5520_bl.c index 4911ea7989c8..df5db99af23d 100644 --- a/drivers/video/backlight/adp5520_bl.c +++ b/drivers/video/backlight/adp5520_bl.c | |||
@@ -160,7 +160,7 @@ static ssize_t adp5520_store(struct device *dev, const char *buf, | |||
160 | unsigned long val; | 160 | unsigned long val; |
161 | int ret; | 161 | int ret; |
162 | 162 | ||
163 | ret = strict_strtoul(buf, 10, &val); | 163 | ret = kstrtoul(buf, 10, &val); |
164 | if (ret) | 164 | if (ret) |
165 | return ret; | 165 | return ret; |
166 | 166 | ||
@@ -214,7 +214,7 @@ static ssize_t adp5520_bl_daylight_max_store(struct device *dev, | |||
214 | struct adp5520_bl *data = dev_get_drvdata(dev); | 214 | struct adp5520_bl *data = dev_get_drvdata(dev); |
215 | int ret; | 215 | int ret; |
216 | 216 | ||
217 | ret = strict_strtoul(buf, 10, &data->cached_daylight_max); | 217 | ret = kstrtoul(buf, 10, &data->cached_daylight_max); |
218 | if (ret < 0) | 218 | if (ret < 0) |
219 | return ret; | 219 | return ret; |
220 | 220 | ||
diff --git a/drivers/video/backlight/adp8860_bl.c b/drivers/video/backlight/adp8860_bl.c index 550dbf0bb896..77d1fdba597f 100644 --- a/drivers/video/backlight/adp8860_bl.c +++ b/drivers/video/backlight/adp8860_bl.c | |||
@@ -222,7 +222,8 @@ static int __devinit adp8860_led_probe(struct i2c_client *client) | |||
222 | struct led_info *cur_led; | 222 | struct led_info *cur_led; |
223 | int ret, i; | 223 | int ret, i; |
224 | 224 | ||
225 | led = kzalloc(sizeof(*led) * pdata->num_leds, GFP_KERNEL); | 225 | led = devm_kzalloc(&client->dev, sizeof(*led) * pdata->num_leds, |
226 | GFP_KERNEL); | ||
226 | if (led == NULL) { | 227 | if (led == NULL) { |
227 | dev_err(&client->dev, "failed to alloc memory\n"); | 228 | dev_err(&client->dev, "failed to alloc memory\n"); |
228 | return -ENOMEM; | 229 | return -ENOMEM; |
@@ -236,7 +237,7 @@ static int __devinit adp8860_led_probe(struct i2c_client *client) | |||
236 | 237 | ||
237 | if (ret) { | 238 | if (ret) { |
238 | dev_err(&client->dev, "failed to write\n"); | 239 | dev_err(&client->dev, "failed to write\n"); |
239 | goto err_free; | 240 | return ret; |
240 | } | 241 | } |
241 | 242 | ||
242 | for (i = 0; i < pdata->num_leds; ++i) { | 243 | for (i = 0; i < pdata->num_leds; ++i) { |
@@ -291,9 +292,6 @@ static int __devinit adp8860_led_probe(struct i2c_client *client) | |||
291 | cancel_work_sync(&led[i].work); | 292 | cancel_work_sync(&led[i].work); |
292 | } | 293 | } |
293 | 294 | ||
294 | err_free: | ||
295 | kfree(led); | ||
296 | |||
297 | return ret; | 295 | return ret; |
298 | } | 296 | } |
299 | 297 | ||
@@ -309,7 +307,6 @@ static int __devexit adp8860_led_remove(struct i2c_client *client) | |||
309 | cancel_work_sync(&data->led[i].work); | 307 | cancel_work_sync(&data->led[i].work); |
310 | } | 308 | } |
311 | 309 | ||
312 | kfree(data->led); | ||
313 | return 0; | 310 | return 0; |
314 | } | 311 | } |
315 | #else | 312 | #else |
@@ -451,7 +448,7 @@ static ssize_t adp8860_store(struct device *dev, const char *buf, | |||
451 | unsigned long val; | 448 | unsigned long val; |
452 | int ret; | 449 | int ret; |
453 | 450 | ||
454 | ret = strict_strtoul(buf, 10, &val); | 451 | ret = kstrtoul(buf, 10, &val); |
455 | if (ret) | 452 | if (ret) |
456 | return ret; | 453 | return ret; |
457 | 454 | ||
@@ -501,7 +498,7 @@ static ssize_t adp8860_bl_l1_daylight_max_store(struct device *dev, | |||
501 | struct device_attribute *attr, const char *buf, size_t count) | 498 | struct device_attribute *attr, const char *buf, size_t count) |
502 | { | 499 | { |
503 | struct adp8860_bl *data = dev_get_drvdata(dev); | 500 | struct adp8860_bl *data = dev_get_drvdata(dev); |
504 | int ret = strict_strtoul(buf, 10, &data->cached_daylight_max); | 501 | int ret = kstrtoul(buf, 10, &data->cached_daylight_max); |
505 | if (ret) | 502 | if (ret) |
506 | return ret; | 503 | return ret; |
507 | 504 | ||
@@ -608,7 +605,7 @@ static ssize_t adp8860_bl_ambient_light_zone_store(struct device *dev, | |||
608 | uint8_t reg_val; | 605 | uint8_t reg_val; |
609 | int ret; | 606 | int ret; |
610 | 607 | ||
611 | ret = strict_strtoul(buf, 10, &val); | 608 | ret = kstrtoul(buf, 10, &val); |
612 | if (ret) | 609 | if (ret) |
613 | return ret; | 610 | return ret; |
614 | 611 | ||
@@ -675,13 +672,13 @@ static int __devinit adp8860_probe(struct i2c_client *client, | |||
675 | return -EINVAL; | 672 | return -EINVAL; |
676 | } | 673 | } |
677 | 674 | ||
678 | data = kzalloc(sizeof(*data), GFP_KERNEL); | 675 | data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL); |
679 | if (data == NULL) | 676 | if (data == NULL) |
680 | return -ENOMEM; | 677 | return -ENOMEM; |
681 | 678 | ||
682 | ret = adp8860_read(client, ADP8860_MFDVID, ®_val); | 679 | ret = adp8860_read(client, ADP8860_MFDVID, ®_val); |
683 | if (ret < 0) | 680 | if (ret < 0) |
684 | goto out2; | 681 | return ret; |
685 | 682 | ||
686 | switch (ADP8860_MANID(reg_val)) { | 683 | switch (ADP8860_MANID(reg_val)) { |
687 | case ADP8863_MANUFID: | 684 | case ADP8863_MANUFID: |
@@ -694,8 +691,7 @@ static int __devinit adp8860_probe(struct i2c_client *client, | |||
694 | break; | 691 | break; |
695 | default: | 692 | default: |
696 | dev_err(&client->dev, "failed to probe\n"); | 693 | dev_err(&client->dev, "failed to probe\n"); |
697 | ret = -ENODEV; | 694 | return -ENODEV; |
698 | goto out2; | ||
699 | } | 695 | } |
700 | 696 | ||
701 | /* It's confirmed that the DEVID field is actually a REVID */ | 697 | /* It's confirmed that the DEVID field is actually a REVID */ |
@@ -717,8 +713,7 @@ static int __devinit adp8860_probe(struct i2c_client *client, | |||
717 | &client->dev, data, &adp8860_bl_ops, &props); | 713 | &client->dev, data, &adp8860_bl_ops, &props); |
718 | if (IS_ERR(bl)) { | 714 | if (IS_ERR(bl)) { |
719 | dev_err(&client->dev, "failed to register backlight\n"); | 715 | dev_err(&client->dev, "failed to register backlight\n"); |
720 | ret = PTR_ERR(bl); | 716 | return PTR_ERR(bl); |
721 | goto out2; | ||
722 | } | 717 | } |
723 | 718 | ||
724 | bl->props.brightness = ADP8860_MAX_BRIGHTNESS; | 719 | bl->props.brightness = ADP8860_MAX_BRIGHTNESS; |
@@ -756,8 +751,6 @@ out: | |||
756 | &adp8860_bl_attr_group); | 751 | &adp8860_bl_attr_group); |
757 | out1: | 752 | out1: |
758 | backlight_device_unregister(bl); | 753 | backlight_device_unregister(bl); |
759 | out2: | ||
760 | kfree(data); | ||
761 | 754 | ||
762 | return ret; | 755 | return ret; |
763 | } | 756 | } |
@@ -776,7 +769,6 @@ static int __devexit adp8860_remove(struct i2c_client *client) | |||
776 | &adp8860_bl_attr_group); | 769 | &adp8860_bl_attr_group); |
777 | 770 | ||
778 | backlight_device_unregister(data->bl); | 771 | backlight_device_unregister(data->bl); |
779 | kfree(data); | ||
780 | 772 | ||
781 | return 0; | 773 | return 0; |
782 | } | 774 | } |
diff --git a/drivers/video/backlight/adp8870_bl.c b/drivers/video/backlight/adp8870_bl.c index 9be58c6f18f1..edf7f91c8e61 100644 --- a/drivers/video/backlight/adp8870_bl.c +++ b/drivers/video/backlight/adp8870_bl.c | |||
@@ -244,8 +244,8 @@ static int __devinit adp8870_led_probe(struct i2c_client *client) | |||
244 | struct led_info *cur_led; | 244 | struct led_info *cur_led; |
245 | int ret, i; | 245 | int ret, i; |
246 | 246 | ||
247 | 247 | led = devm_kzalloc(&client->dev, pdata->num_leds * sizeof(*led), | |
248 | led = kcalloc(pdata->num_leds, sizeof(*led), GFP_KERNEL); | 248 | GFP_KERNEL); |
249 | if (led == NULL) { | 249 | if (led == NULL) { |
250 | dev_err(&client->dev, "failed to alloc memory\n"); | 250 | dev_err(&client->dev, "failed to alloc memory\n"); |
251 | return -ENOMEM; | 251 | return -ENOMEM; |
@@ -253,17 +253,17 @@ static int __devinit adp8870_led_probe(struct i2c_client *client) | |||
253 | 253 | ||
254 | ret = adp8870_write(client, ADP8870_ISCLAW, pdata->led_fade_law); | 254 | ret = adp8870_write(client, ADP8870_ISCLAW, pdata->led_fade_law); |
255 | if (ret) | 255 | if (ret) |
256 | goto err_free; | 256 | return ret; |
257 | 257 | ||
258 | ret = adp8870_write(client, ADP8870_ISCT1, | 258 | ret = adp8870_write(client, ADP8870_ISCT1, |
259 | (pdata->led_on_time & 0x3) << 6); | 259 | (pdata->led_on_time & 0x3) << 6); |
260 | if (ret) | 260 | if (ret) |
261 | goto err_free; | 261 | return ret; |
262 | 262 | ||
263 | ret = adp8870_write(client, ADP8870_ISCF, | 263 | ret = adp8870_write(client, ADP8870_ISCF, |
264 | FADE_VAL(pdata->led_fade_in, pdata->led_fade_out)); | 264 | FADE_VAL(pdata->led_fade_in, pdata->led_fade_out)); |
265 | if (ret) | 265 | if (ret) |
266 | goto err_free; | 266 | return ret; |
267 | 267 | ||
268 | for (i = 0; i < pdata->num_leds; ++i) { | 268 | for (i = 0; i < pdata->num_leds; ++i) { |
269 | cur_led = &pdata->leds[i]; | 269 | cur_led = &pdata->leds[i]; |
@@ -317,9 +317,6 @@ static int __devinit adp8870_led_probe(struct i2c_client *client) | |||
317 | cancel_work_sync(&led[i].work); | 317 | cancel_work_sync(&led[i].work); |
318 | } | 318 | } |
319 | 319 | ||
320 | err_free: | ||
321 | kfree(led); | ||
322 | |||
323 | return ret; | 320 | return ret; |
324 | } | 321 | } |
325 | 322 | ||
@@ -335,7 +332,6 @@ static int __devexit adp8870_led_remove(struct i2c_client *client) | |||
335 | cancel_work_sync(&data->led[i].work); | 332 | cancel_work_sync(&data->led[i].work); |
336 | } | 333 | } |
337 | 334 | ||
338 | kfree(data->led); | ||
339 | return 0; | 335 | return 0; |
340 | } | 336 | } |
341 | #else | 337 | #else |
@@ -572,7 +568,7 @@ static ssize_t adp8870_store(struct device *dev, const char *buf, | |||
572 | unsigned long val; | 568 | unsigned long val; |
573 | int ret; | 569 | int ret; |
574 | 570 | ||
575 | ret = strict_strtoul(buf, 10, &val); | 571 | ret = kstrtoul(buf, 10, &val); |
576 | if (ret) | 572 | if (ret) |
577 | return ret; | 573 | return ret; |
578 | 574 | ||
@@ -652,7 +648,7 @@ static ssize_t adp8870_bl_l1_daylight_max_store(struct device *dev, | |||
652 | struct device_attribute *attr, const char *buf, size_t count) | 648 | struct device_attribute *attr, const char *buf, size_t count) |
653 | { | 649 | { |
654 | struct adp8870_bl *data = dev_get_drvdata(dev); | 650 | struct adp8870_bl *data = dev_get_drvdata(dev); |
655 | int ret = strict_strtoul(buf, 10, &data->cached_daylight_max); | 651 | int ret = kstrtoul(buf, 10, &data->cached_daylight_max); |
656 | if (ret) | 652 | if (ret) |
657 | return ret; | 653 | return ret; |
658 | 654 | ||
@@ -794,7 +790,7 @@ static ssize_t adp8870_bl_ambient_light_zone_store(struct device *dev, | |||
794 | uint8_t reg_val; | 790 | uint8_t reg_val; |
795 | int ret; | 791 | int ret; |
796 | 792 | ||
797 | ret = strict_strtoul(buf, 10, &val); | 793 | ret = kstrtoul(buf, 10, &val); |
798 | if (ret) | 794 | if (ret) |
799 | return ret; | 795 | return ret; |
800 | 796 | ||
@@ -874,7 +870,7 @@ static int __devinit adp8870_probe(struct i2c_client *client, | |||
874 | return -ENODEV; | 870 | return -ENODEV; |
875 | } | 871 | } |
876 | 872 | ||
877 | data = kzalloc(sizeof(*data), GFP_KERNEL); | 873 | data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL); |
878 | if (data == NULL) | 874 | if (data == NULL) |
879 | return -ENOMEM; | 875 | return -ENOMEM; |
880 | 876 | ||
@@ -894,8 +890,7 @@ static int __devinit adp8870_probe(struct i2c_client *client, | |||
894 | &client->dev, data, &adp8870_bl_ops, &props); | 890 | &client->dev, data, &adp8870_bl_ops, &props); |
895 | if (IS_ERR(bl)) { | 891 | if (IS_ERR(bl)) { |
896 | dev_err(&client->dev, "failed to register backlight\n"); | 892 | dev_err(&client->dev, "failed to register backlight\n"); |
897 | ret = PTR_ERR(bl); | 893 | return PTR_ERR(bl); |
898 | goto out2; | ||
899 | } | 894 | } |
900 | 895 | ||
901 | data->bl = bl; | 896 | data->bl = bl; |
@@ -930,8 +925,6 @@ out: | |||
930 | &adp8870_bl_attr_group); | 925 | &adp8870_bl_attr_group); |
931 | out1: | 926 | out1: |
932 | backlight_device_unregister(bl); | 927 | backlight_device_unregister(bl); |
933 | out2: | ||
934 | kfree(data); | ||
935 | 928 | ||
936 | return ret; | 929 | return ret; |
937 | } | 930 | } |
@@ -950,7 +943,6 @@ static int __devexit adp8870_remove(struct i2c_client *client) | |||
950 | &adp8870_bl_attr_group); | 943 | &adp8870_bl_attr_group); |
951 | 944 | ||
952 | backlight_device_unregister(data->bl); | 945 | backlight_device_unregister(data->bl); |
953 | kfree(data); | ||
954 | 946 | ||
955 | return 0; | 947 | return 0; |
956 | } | 948 | } |
diff --git a/drivers/video/backlight/ams369fg06.c b/drivers/video/backlight/ams369fg06.c index 7bdadc790117..3729238e7096 100644 --- a/drivers/video/backlight/ams369fg06.c +++ b/drivers/video/backlight/ams369fg06.c | |||
@@ -482,7 +482,7 @@ static int __devinit ams369fg06_probe(struct spi_device *spi) | |||
482 | struct backlight_device *bd = NULL; | 482 | struct backlight_device *bd = NULL; |
483 | struct backlight_properties props; | 483 | struct backlight_properties props; |
484 | 484 | ||
485 | lcd = kzalloc(sizeof(struct ams369fg06), GFP_KERNEL); | 485 | lcd = devm_kzalloc(&spi->dev, sizeof(struct ams369fg06), GFP_KERNEL); |
486 | if (!lcd) | 486 | if (!lcd) |
487 | return -ENOMEM; | 487 | return -ENOMEM; |
488 | 488 | ||
@@ -492,7 +492,7 @@ static int __devinit ams369fg06_probe(struct spi_device *spi) | |||
492 | ret = spi_setup(spi); | 492 | ret = spi_setup(spi); |
493 | if (ret < 0) { | 493 | if (ret < 0) { |
494 | dev_err(&spi->dev, "spi setup failed.\n"); | 494 | dev_err(&spi->dev, "spi setup failed.\n"); |
495 | goto out_free_lcd; | 495 | return ret; |
496 | } | 496 | } |
497 | 497 | ||
498 | lcd->spi = spi; | 498 | lcd->spi = spi; |
@@ -501,15 +501,13 @@ static int __devinit ams369fg06_probe(struct spi_device *spi) | |||
501 | lcd->lcd_pd = spi->dev.platform_data; | 501 | lcd->lcd_pd = spi->dev.platform_data; |
502 | if (!lcd->lcd_pd) { | 502 | if (!lcd->lcd_pd) { |
503 | dev_err(&spi->dev, "platform data is NULL\n"); | 503 | dev_err(&spi->dev, "platform data is NULL\n"); |
504 | goto out_free_lcd; | 504 | return -EFAULT; |
505 | } | 505 | } |
506 | 506 | ||
507 | ld = lcd_device_register("ams369fg06", &spi->dev, lcd, | 507 | ld = lcd_device_register("ams369fg06", &spi->dev, lcd, |
508 | &ams369fg06_lcd_ops); | 508 | &ams369fg06_lcd_ops); |
509 | if (IS_ERR(ld)) { | 509 | if (IS_ERR(ld)) |
510 | ret = PTR_ERR(ld); | 510 | return PTR_ERR(ld); |
511 | goto out_free_lcd; | ||
512 | } | ||
513 | 511 | ||
514 | lcd->ld = ld; | 512 | lcd->ld = ld; |
515 | 513 | ||
@@ -547,8 +545,6 @@ static int __devinit ams369fg06_probe(struct spi_device *spi) | |||
547 | 545 | ||
548 | out_lcd_unregister: | 546 | out_lcd_unregister: |
549 | lcd_device_unregister(ld); | 547 | lcd_device_unregister(ld); |
550 | out_free_lcd: | ||
551 | kfree(lcd); | ||
552 | return ret; | 548 | return ret; |
553 | } | 549 | } |
554 | 550 | ||
@@ -559,7 +555,6 @@ static int __devexit ams369fg06_remove(struct spi_device *spi) | |||
559 | ams369fg06_power(lcd, FB_BLANK_POWERDOWN); | 555 | ams369fg06_power(lcd, FB_BLANK_POWERDOWN); |
560 | backlight_device_unregister(lcd->bd); | 556 | backlight_device_unregister(lcd->bd); |
561 | lcd_device_unregister(lcd->ld); | 557 | lcd_device_unregister(lcd->ld); |
562 | kfree(lcd); | ||
563 | 558 | ||
564 | return 0; | 559 | return 0; |
565 | } | 560 | } |
@@ -619,7 +614,6 @@ static void ams369fg06_shutdown(struct spi_device *spi) | |||
619 | static struct spi_driver ams369fg06_driver = { | 614 | static struct spi_driver ams369fg06_driver = { |
620 | .driver = { | 615 | .driver = { |
621 | .name = "ams369fg06", | 616 | .name = "ams369fg06", |
622 | .bus = &spi_bus_type, | ||
623 | .owner = THIS_MODULE, | 617 | .owner = THIS_MODULE, |
624 | }, | 618 | }, |
625 | .probe = ams369fg06_probe, | 619 | .probe = ams369fg06_probe, |
diff --git a/drivers/video/backlight/apple_bl.c b/drivers/video/backlight/apple_bl.c index a523b255e124..9dc73ac3709a 100644 --- a/drivers/video/backlight/apple_bl.c +++ b/drivers/video/backlight/apple_bl.c | |||
@@ -16,6 +16,8 @@ | |||
16 | * get at the firmware code in order to figure out what it's actually doing. | 16 | * get at the firmware code in order to figure out what it's actually doing. |
17 | */ | 17 | */ |
18 | 18 | ||
19 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
20 | |||
19 | #include <linux/module.h> | 21 | #include <linux/module.h> |
20 | #include <linux/kernel.h> | 22 | #include <linux/kernel.h> |
21 | #include <linux/init.h> | 23 | #include <linux/init.h> |
@@ -25,6 +27,7 @@ | |||
25 | #include <linux/pci.h> | 27 | #include <linux/pci.h> |
26 | #include <linux/acpi.h> | 28 | #include <linux/acpi.h> |
27 | #include <linux/atomic.h> | 29 | #include <linux/atomic.h> |
30 | #include <linux/apple_bl.h> | ||
28 | 31 | ||
29 | static struct backlight_device *apple_backlight_device; | 32 | static struct backlight_device *apple_backlight_device; |
30 | 33 | ||
@@ -39,8 +42,6 @@ struct hw_data { | |||
39 | 42 | ||
40 | static const struct hw_data *hw_data; | 43 | static const struct hw_data *hw_data; |
41 | 44 | ||
42 | #define DRIVER "apple_backlight: " | ||
43 | |||
44 | /* Module parameters. */ | 45 | /* Module parameters. */ |
45 | static int debug; | 46 | static int debug; |
46 | module_param_named(debug, debug, int, 0644); | 47 | module_param_named(debug, debug, int, 0644); |
@@ -60,8 +61,7 @@ static int intel_chipset_send_intensity(struct backlight_device *bd) | |||
60 | int intensity = bd->props.brightness; | 61 | int intensity = bd->props.brightness; |
61 | 62 | ||
62 | if (debug) | 63 | if (debug) |
63 | printk(KERN_DEBUG DRIVER "setting brightness to %d\n", | 64 | pr_debug("setting brightness to %d\n", intensity); |
64 | intensity); | ||
65 | 65 | ||
66 | intel_chipset_set_brightness(intensity); | 66 | intel_chipset_set_brightness(intensity); |
67 | return 0; | 67 | return 0; |
@@ -76,8 +76,7 @@ static int intel_chipset_get_intensity(struct backlight_device *bd) | |||
76 | intensity = inb(0xb3) >> 4; | 76 | intensity = inb(0xb3) >> 4; |
77 | 77 | ||
78 | if (debug) | 78 | if (debug) |
79 | printk(KERN_DEBUG DRIVER "read brightness of %d\n", | 79 | pr_debug("read brightness of %d\n", intensity); |
80 | intensity); | ||
81 | 80 | ||
82 | return intensity; | 81 | return intensity; |
83 | } | 82 | } |
@@ -107,8 +106,7 @@ static int nvidia_chipset_send_intensity(struct backlight_device *bd) | |||
107 | int intensity = bd->props.brightness; | 106 | int intensity = bd->props.brightness; |
108 | 107 | ||
109 | if (debug) | 108 | if (debug) |
110 | printk(KERN_DEBUG DRIVER "setting brightness to %d\n", | 109 | pr_debug("setting brightness to %d\n", intensity); |
111 | intensity); | ||
112 | 110 | ||
113 | nvidia_chipset_set_brightness(intensity); | 111 | nvidia_chipset_set_brightness(intensity); |
114 | return 0; | 112 | return 0; |
@@ -123,8 +121,7 @@ static int nvidia_chipset_get_intensity(struct backlight_device *bd) | |||
123 | intensity = inb(0x52f) >> 4; | 121 | intensity = inb(0x52f) >> 4; |
124 | 122 | ||
125 | if (debug) | 123 | if (debug) |
126 | printk(KERN_DEBUG DRIVER "read brightness of %d\n", | 124 | pr_debug("read brightness of %d\n", intensity); |
127 | intensity); | ||
128 | 125 | ||
129 | return intensity; | 126 | return intensity; |
130 | } | 127 | } |
@@ -149,7 +146,7 @@ static int __devinit apple_bl_add(struct acpi_device *dev) | |||
149 | host = pci_get_bus_and_slot(0, 0); | 146 | host = pci_get_bus_and_slot(0, 0); |
150 | 147 | ||
151 | if (!host) { | 148 | if (!host) { |
152 | printk(KERN_ERR DRIVER "unable to find PCI host\n"); | 149 | pr_err("unable to find PCI host\n"); |
153 | return -ENODEV; | 150 | return -ENODEV; |
154 | } | 151 | } |
155 | 152 | ||
@@ -161,7 +158,7 @@ static int __devinit apple_bl_add(struct acpi_device *dev) | |||
161 | pci_dev_put(host); | 158 | pci_dev_put(host); |
162 | 159 | ||
163 | if (!hw_data) { | 160 | if (!hw_data) { |
164 | printk(KERN_ERR DRIVER "unknown hardware\n"); | 161 | pr_err("unknown hardware\n"); |
165 | return -ENODEV; | 162 | return -ENODEV; |
166 | } | 163 | } |
167 | 164 | ||
diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c index bf5b1ece7160..297db2fa91f5 100644 --- a/drivers/video/backlight/backlight.c +++ b/drivers/video/backlight/backlight.c | |||
@@ -5,6 +5,8 @@ | |||
5 | * | 5 | * |
6 | */ | 6 | */ |
7 | 7 | ||
8 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
9 | |||
8 | #include <linux/module.h> | 10 | #include <linux/module.h> |
9 | #include <linux/init.h> | 11 | #include <linux/init.h> |
10 | #include <linux/device.h> | 12 | #include <linux/device.h> |
@@ -123,7 +125,7 @@ static ssize_t backlight_store_power(struct device *dev, | |||
123 | rc = -ENXIO; | 125 | rc = -ENXIO; |
124 | mutex_lock(&bd->ops_lock); | 126 | mutex_lock(&bd->ops_lock); |
125 | if (bd->ops) { | 127 | if (bd->ops) { |
126 | pr_debug("backlight: set power to %lu\n", power); | 128 | pr_debug("set power to %lu\n", power); |
127 | if (bd->props.power != power) { | 129 | if (bd->props.power != power) { |
128 | bd->props.power = power; | 130 | bd->props.power = power; |
129 | backlight_update_status(bd); | 131 | backlight_update_status(bd); |
@@ -161,8 +163,7 @@ static ssize_t backlight_store_brightness(struct device *dev, | |||
161 | if (brightness > bd->props.max_brightness) | 163 | if (brightness > bd->props.max_brightness) |
162 | rc = -EINVAL; | 164 | rc = -EINVAL; |
163 | else { | 165 | else { |
164 | pr_debug("backlight: set brightness to %lu\n", | 166 | pr_debug("set brightness to %lu\n", brightness); |
165 | brightness); | ||
166 | bd->props.brightness = brightness; | 167 | bd->props.brightness = brightness; |
167 | backlight_update_status(bd); | 168 | backlight_update_status(bd); |
168 | rc = count; | 169 | rc = count; |
@@ -378,8 +379,8 @@ static int __init backlight_class_init(void) | |||
378 | { | 379 | { |
379 | backlight_class = class_create(THIS_MODULE, "backlight"); | 380 | backlight_class = class_create(THIS_MODULE, "backlight"); |
380 | if (IS_ERR(backlight_class)) { | 381 | if (IS_ERR(backlight_class)) { |
381 | printk(KERN_WARNING "Unable to create backlight class; errno = %ld\n", | 382 | pr_warn("Unable to create backlight class; errno = %ld\n", |
382 | PTR_ERR(backlight_class)); | 383 | PTR_ERR(backlight_class)); |
383 | return PTR_ERR(backlight_class); | 384 | return PTR_ERR(backlight_class); |
384 | } | 385 | } |
385 | 386 | ||
diff --git a/drivers/video/backlight/corgi_lcd.c b/drivers/video/backlight/corgi_lcd.c index 6dab13fe562e..23d732677ba1 100644 --- a/drivers/video/backlight/corgi_lcd.c +++ b/drivers/video/backlight/corgi_lcd.c | |||
@@ -544,7 +544,7 @@ static int __devinit corgi_lcd_probe(struct spi_device *spi) | |||
544 | return -EINVAL; | 544 | return -EINVAL; |
545 | } | 545 | } |
546 | 546 | ||
547 | lcd = kzalloc(sizeof(struct corgi_lcd), GFP_KERNEL); | 547 | lcd = devm_kzalloc(&spi->dev, sizeof(struct corgi_lcd), GFP_KERNEL); |
548 | if (!lcd) { | 548 | if (!lcd) { |
549 | dev_err(&spi->dev, "failed to allocate memory\n"); | 549 | dev_err(&spi->dev, "failed to allocate memory\n"); |
550 | return -ENOMEM; | 550 | return -ENOMEM; |
@@ -554,10 +554,9 @@ static int __devinit corgi_lcd_probe(struct spi_device *spi) | |||
554 | 554 | ||
555 | lcd->lcd_dev = lcd_device_register("corgi_lcd", &spi->dev, | 555 | lcd->lcd_dev = lcd_device_register("corgi_lcd", &spi->dev, |
556 | lcd, &corgi_lcd_ops); | 556 | lcd, &corgi_lcd_ops); |
557 | if (IS_ERR(lcd->lcd_dev)) { | 557 | if (IS_ERR(lcd->lcd_dev)) |
558 | ret = PTR_ERR(lcd->lcd_dev); | 558 | return PTR_ERR(lcd->lcd_dev); |
559 | goto err_free_lcd; | 559 | |
560 | } | ||
561 | lcd->power = FB_BLANK_POWERDOWN; | 560 | lcd->power = FB_BLANK_POWERDOWN; |
562 | lcd->mode = (pdata) ? pdata->init_mode : CORGI_LCD_MODE_VGA; | 561 | lcd->mode = (pdata) ? pdata->init_mode : CORGI_LCD_MODE_VGA; |
563 | 562 | ||
@@ -591,8 +590,6 @@ err_unregister_bl: | |||
591 | backlight_device_unregister(lcd->bl_dev); | 590 | backlight_device_unregister(lcd->bl_dev); |
592 | err_unregister_lcd: | 591 | err_unregister_lcd: |
593 | lcd_device_unregister(lcd->lcd_dev); | 592 | lcd_device_unregister(lcd->lcd_dev); |
594 | err_free_lcd: | ||
595 | kfree(lcd); | ||
596 | return ret; | 593 | return ret; |
597 | } | 594 | } |
598 | 595 | ||
@@ -613,7 +610,6 @@ static int __devexit corgi_lcd_remove(struct spi_device *spi) | |||
613 | 610 | ||
614 | corgi_lcd_set_power(lcd->lcd_dev, FB_BLANK_POWERDOWN); | 611 | corgi_lcd_set_power(lcd->lcd_dev, FB_BLANK_POWERDOWN); |
615 | lcd_device_unregister(lcd->lcd_dev); | 612 | lcd_device_unregister(lcd->lcd_dev); |
616 | kfree(lcd); | ||
617 | 613 | ||
618 | return 0; | 614 | return 0; |
619 | } | 615 | } |
diff --git a/drivers/video/backlight/cr_bllcd.c b/drivers/video/backlight/cr_bllcd.c index 22489eb5f3e0..37bae801e23b 100644 --- a/drivers/video/backlight/cr_bllcd.c +++ b/drivers/video/backlight/cr_bllcd.c | |||
@@ -27,6 +27,8 @@ | |||
27 | * Alan Hourihane <alanh-at-tungstengraphics-dot-com> | 27 | * Alan Hourihane <alanh-at-tungstengraphics-dot-com> |
28 | */ | 28 | */ |
29 | 29 | ||
30 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
31 | |||
30 | #include <linux/module.h> | 32 | #include <linux/module.h> |
31 | #include <linux/kernel.h> | 33 | #include <linux/kernel.h> |
32 | #include <linux/init.h> | 34 | #include <linux/init.h> |
@@ -180,14 +182,13 @@ static int cr_backlight_probe(struct platform_device *pdev) | |||
180 | lpc_dev = pci_get_device(PCI_VENDOR_ID_INTEL, | 182 | lpc_dev = pci_get_device(PCI_VENDOR_ID_INTEL, |
181 | CRVML_DEVICE_LPC, NULL); | 183 | CRVML_DEVICE_LPC, NULL); |
182 | if (!lpc_dev) { | 184 | if (!lpc_dev) { |
183 | printk("INTEL CARILLO RANCH LPC not found.\n"); | 185 | pr_err("INTEL CARILLO RANCH LPC not found.\n"); |
184 | return -ENODEV; | 186 | return -ENODEV; |
185 | } | 187 | } |
186 | 188 | ||
187 | pci_read_config_byte(lpc_dev, CRVML_REG_GPIOEN, &dev_en); | 189 | pci_read_config_byte(lpc_dev, CRVML_REG_GPIOEN, &dev_en); |
188 | if (!(dev_en & CRVML_GPIOEN_BIT)) { | 190 | if (!(dev_en & CRVML_GPIOEN_BIT)) { |
189 | printk(KERN_ERR | 191 | pr_err("Carillo Ranch GPIO device was not enabled.\n"); |
190 | "Carillo Ranch GPIO device was not enabled.\n"); | ||
191 | pci_dev_put(lpc_dev); | 192 | pci_dev_put(lpc_dev); |
192 | return -ENODEV; | 193 | return -ENODEV; |
193 | } | 194 | } |
@@ -270,7 +271,7 @@ static int __init cr_backlight_init(void) | |||
270 | return PTR_ERR(crp); | 271 | return PTR_ERR(crp); |
271 | } | 272 | } |
272 | 273 | ||
273 | printk("Carillo Ranch Backlight Driver Initialized.\n"); | 274 | pr_info("Carillo Ranch Backlight Driver Initialized.\n"); |
274 | 275 | ||
275 | return 0; | 276 | return 0; |
276 | } | 277 | } |
diff --git a/drivers/video/backlight/da903x_bl.c b/drivers/video/backlight/da903x_bl.c index 30e19681a30b..573c7ece0fde 100644 --- a/drivers/video/backlight/da903x_bl.c +++ b/drivers/video/backlight/da903x_bl.c | |||
@@ -136,6 +136,7 @@ static int da903x_backlight_probe(struct platform_device *pdev) | |||
136 | da903x_write(data->da903x_dev, DA9034_WLED_CONTROL2, | 136 | da903x_write(data->da903x_dev, DA9034_WLED_CONTROL2, |
137 | DA9034_WLED_ISET(pdata->output_current)); | 137 | DA9034_WLED_ISET(pdata->output_current)); |
138 | 138 | ||
139 | memset(&props, 0, sizeof(props)); | ||
139 | props.type = BACKLIGHT_RAW; | 140 | props.type = BACKLIGHT_RAW; |
140 | props.max_brightness = max_brightness; | 141 | props.max_brightness = max_brightness; |
141 | bl = backlight_device_register(pdev->name, data->da903x_dev, data, | 142 | bl = backlight_device_register(pdev->name, data->da903x_dev, data, |
diff --git a/drivers/video/backlight/generic_bl.c b/drivers/video/backlight/generic_bl.c index 9ce6170c1860..8c660fcd250d 100644 --- a/drivers/video/backlight/generic_bl.c +++ b/drivers/video/backlight/generic_bl.c | |||
@@ -9,6 +9,8 @@ | |||
9 | * | 9 | * |
10 | */ | 10 | */ |
11 | 11 | ||
12 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
13 | |||
12 | #include <linux/module.h> | 14 | #include <linux/module.h> |
13 | #include <linux/kernel.h> | 15 | #include <linux/kernel.h> |
14 | #include <linux/init.h> | 16 | #include <linux/init.h> |
@@ -106,7 +108,7 @@ static int genericbl_probe(struct platform_device *pdev) | |||
106 | 108 | ||
107 | generic_backlight_device = bd; | 109 | generic_backlight_device = bd; |
108 | 110 | ||
109 | printk("Generic Backlight Driver Initialized.\n"); | 111 | pr_info("Generic Backlight Driver Initialized.\n"); |
110 | return 0; | 112 | return 0; |
111 | } | 113 | } |
112 | 114 | ||
@@ -120,7 +122,7 @@ static int genericbl_remove(struct platform_device *pdev) | |||
120 | 122 | ||
121 | backlight_device_unregister(bd); | 123 | backlight_device_unregister(bd); |
122 | 124 | ||
123 | printk("Generic Backlight Driver Unloaded\n"); | 125 | pr_info("Generic Backlight Driver Unloaded\n"); |
124 | return 0; | 126 | return 0; |
125 | } | 127 | } |
126 | 128 | ||
diff --git a/drivers/video/backlight/ili9320.c b/drivers/video/backlight/ili9320.c index 5118a9f029ab..6c9399341bcf 100644 --- a/drivers/video/backlight/ili9320.c +++ b/drivers/video/backlight/ili9320.c | |||
@@ -220,7 +220,7 @@ int __devinit ili9320_probe_spi(struct spi_device *spi, | |||
220 | 220 | ||
221 | /* allocate and initialse our state */ | 221 | /* allocate and initialse our state */ |
222 | 222 | ||
223 | ili = kzalloc(sizeof(struct ili9320), GFP_KERNEL); | 223 | ili = devm_kzalloc(&spi->dev, sizeof(struct ili9320), GFP_KERNEL); |
224 | if (ili == NULL) { | 224 | if (ili == NULL) { |
225 | dev_err(dev, "no memory for device\n"); | 225 | dev_err(dev, "no memory for device\n"); |
226 | return -ENOMEM; | 226 | return -ENOMEM; |
@@ -240,8 +240,7 @@ int __devinit ili9320_probe_spi(struct spi_device *spi, | |||
240 | lcd = lcd_device_register("ili9320", dev, ili, &ili9320_ops); | 240 | lcd = lcd_device_register("ili9320", dev, ili, &ili9320_ops); |
241 | if (IS_ERR(lcd)) { | 241 | if (IS_ERR(lcd)) { |
242 | dev_err(dev, "failed to register lcd device\n"); | 242 | dev_err(dev, "failed to register lcd device\n"); |
243 | ret = PTR_ERR(lcd); | 243 | return PTR_ERR(lcd); |
244 | goto err_free; | ||
245 | } | 244 | } |
246 | 245 | ||
247 | ili->lcd = lcd; | 246 | ili->lcd = lcd; |
@@ -259,9 +258,6 @@ int __devinit ili9320_probe_spi(struct spi_device *spi, | |||
259 | err_unregister: | 258 | err_unregister: |
260 | lcd_device_unregister(lcd); | 259 | lcd_device_unregister(lcd); |
261 | 260 | ||
262 | err_free: | ||
263 | kfree(ili); | ||
264 | |||
265 | return ret; | 261 | return ret; |
266 | } | 262 | } |
267 | 263 | ||
@@ -272,7 +268,6 @@ int __devexit ili9320_remove(struct ili9320 *ili) | |||
272 | ili9320_power(ili, FB_BLANK_POWERDOWN); | 268 | ili9320_power(ili, FB_BLANK_POWERDOWN); |
273 | 269 | ||
274 | lcd_device_unregister(ili->lcd); | 270 | lcd_device_unregister(ili->lcd); |
275 | kfree(ili); | ||
276 | 271 | ||
277 | return 0; | 272 | return 0; |
278 | } | 273 | } |
diff --git a/drivers/video/backlight/jornada720_bl.c b/drivers/video/backlight/jornada720_bl.c index 2f8af5d786ab..16f593b64427 100644 --- a/drivers/video/backlight/jornada720_bl.c +++ b/drivers/video/backlight/jornada720_bl.c | |||
@@ -9,6 +9,8 @@ | |||
9 | * | 9 | * |
10 | */ | 10 | */ |
11 | 11 | ||
12 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
13 | |||
12 | #include <linux/backlight.h> | 14 | #include <linux/backlight.h> |
13 | #include <linux/device.h> | 15 | #include <linux/device.h> |
14 | #include <linux/fb.h> | 16 | #include <linux/fb.h> |
@@ -38,7 +40,7 @@ static int jornada_bl_get_brightness(struct backlight_device *bd) | |||
38 | ret = jornada_ssp_byte(GETBRIGHTNESS); | 40 | ret = jornada_ssp_byte(GETBRIGHTNESS); |
39 | 41 | ||
40 | if (jornada_ssp_byte(GETBRIGHTNESS) != TXDUMMY) { | 42 | if (jornada_ssp_byte(GETBRIGHTNESS) != TXDUMMY) { |
41 | printk(KERN_ERR "bl : get brightness timeout\n"); | 43 | pr_err("get brightness timeout\n"); |
42 | jornada_ssp_end(); | 44 | jornada_ssp_end(); |
43 | return -ETIMEDOUT; | 45 | return -ETIMEDOUT; |
44 | } else /* exchange txdummy for value */ | 46 | } else /* exchange txdummy for value */ |
@@ -59,7 +61,7 @@ static int jornada_bl_update_status(struct backlight_device *bd) | |||
59 | if ((bd->props.power != FB_BLANK_UNBLANK) || (bd->props.fb_blank != FB_BLANK_UNBLANK)) { | 61 | if ((bd->props.power != FB_BLANK_UNBLANK) || (bd->props.fb_blank != FB_BLANK_UNBLANK)) { |
60 | ret = jornada_ssp_byte(BRIGHTNESSOFF); | 62 | ret = jornada_ssp_byte(BRIGHTNESSOFF); |
61 | if (ret != TXDUMMY) { | 63 | if (ret != TXDUMMY) { |
62 | printk(KERN_INFO "bl : brightness off timeout\n"); | 64 | pr_info("brightness off timeout\n"); |
63 | /* turn off backlight */ | 65 | /* turn off backlight */ |
64 | PPSR &= ~PPC_LDD1; | 66 | PPSR &= ~PPC_LDD1; |
65 | PPDR |= PPC_LDD1; | 67 | PPDR |= PPC_LDD1; |
@@ -70,7 +72,7 @@ static int jornada_bl_update_status(struct backlight_device *bd) | |||
70 | 72 | ||
71 | /* send command to our mcu */ | 73 | /* send command to our mcu */ |
72 | if (jornada_ssp_byte(SETBRIGHTNESS) != TXDUMMY) { | 74 | if (jornada_ssp_byte(SETBRIGHTNESS) != TXDUMMY) { |
73 | printk(KERN_INFO "bl : failed to set brightness\n"); | 75 | pr_info("failed to set brightness\n"); |
74 | ret = -ETIMEDOUT; | 76 | ret = -ETIMEDOUT; |
75 | goto out; | 77 | goto out; |
76 | } | 78 | } |
@@ -81,7 +83,7 @@ static int jornada_bl_update_status(struct backlight_device *bd) | |||
81 | but due to physical layout it is equal to 0, so we simply | 83 | but due to physical layout it is equal to 0, so we simply |
82 | invert the value (MAX VALUE - NEW VALUE). */ | 84 | invert the value (MAX VALUE - NEW VALUE). */ |
83 | if (jornada_ssp_byte(BL_MAX_BRIGHT - bd->props.brightness) != TXDUMMY) { | 85 | if (jornada_ssp_byte(BL_MAX_BRIGHT - bd->props.brightness) != TXDUMMY) { |
84 | printk(KERN_ERR "bl : set brightness failed\n"); | 86 | pr_err("set brightness failed\n"); |
85 | ret = -ETIMEDOUT; | 87 | ret = -ETIMEDOUT; |
86 | } | 88 | } |
87 | 89 | ||
@@ -113,7 +115,7 @@ static int jornada_bl_probe(struct platform_device *pdev) | |||
113 | 115 | ||
114 | if (IS_ERR(bd)) { | 116 | if (IS_ERR(bd)) { |
115 | ret = PTR_ERR(bd); | 117 | ret = PTR_ERR(bd); |
116 | printk(KERN_ERR "bl : failed to register device, err=%x\n", ret); | 118 | pr_err("failed to register device, err=%x\n", ret); |
117 | return ret; | 119 | return ret; |
118 | } | 120 | } |
119 | 121 | ||
@@ -125,7 +127,7 @@ static int jornada_bl_probe(struct platform_device *pdev) | |||
125 | jornada_bl_update_status(bd); | 127 | jornada_bl_update_status(bd); |
126 | 128 | ||
127 | platform_set_drvdata(pdev, bd); | 129 | platform_set_drvdata(pdev, bd); |
128 | printk(KERN_INFO "HP Jornada 700 series backlight driver\n"); | 130 | pr_info("HP Jornada 700 series backlight driver\n"); |
129 | 131 | ||
130 | return 0; | 132 | return 0; |
131 | } | 133 | } |
diff --git a/drivers/video/backlight/jornada720_lcd.c b/drivers/video/backlight/jornada720_lcd.c index 22d231a17e3c..635b30523fd5 100644 --- a/drivers/video/backlight/jornada720_lcd.c +++ b/drivers/video/backlight/jornada720_lcd.c | |||
@@ -9,6 +9,8 @@ | |||
9 | * | 9 | * |
10 | */ | 10 | */ |
11 | 11 | ||
12 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
13 | |||
12 | #include <linux/device.h> | 14 | #include <linux/device.h> |
13 | #include <linux/fb.h> | 15 | #include <linux/fb.h> |
14 | #include <linux/kernel.h> | 16 | #include <linux/kernel.h> |
@@ -44,7 +46,7 @@ static int jornada_lcd_get_contrast(struct lcd_device *dev) | |||
44 | jornada_ssp_start(); | 46 | jornada_ssp_start(); |
45 | 47 | ||
46 | if (jornada_ssp_byte(GETCONTRAST) != TXDUMMY) { | 48 | if (jornada_ssp_byte(GETCONTRAST) != TXDUMMY) { |
47 | printk(KERN_ERR "lcd: get contrast failed\n"); | 49 | pr_err("get contrast failed\n"); |
48 | jornada_ssp_end(); | 50 | jornada_ssp_end(); |
49 | return -ETIMEDOUT; | 51 | return -ETIMEDOUT; |
50 | } else { | 52 | } else { |
@@ -65,7 +67,7 @@ static int jornada_lcd_set_contrast(struct lcd_device *dev, int value) | |||
65 | 67 | ||
66 | /* push the new value */ | 68 | /* push the new value */ |
67 | if (jornada_ssp_byte(value) != TXDUMMY) { | 69 | if (jornada_ssp_byte(value) != TXDUMMY) { |
68 | printk(KERN_ERR "lcd : set contrast failed\n"); | 70 | pr_err("set contrast failed\n"); |
69 | jornada_ssp_end(); | 71 | jornada_ssp_end(); |
70 | return -ETIMEDOUT; | 72 | return -ETIMEDOUT; |
71 | } | 73 | } |
@@ -103,7 +105,7 @@ static int jornada_lcd_probe(struct platform_device *pdev) | |||
103 | 105 | ||
104 | if (IS_ERR(lcd_device)) { | 106 | if (IS_ERR(lcd_device)) { |
105 | ret = PTR_ERR(lcd_device); | 107 | ret = PTR_ERR(lcd_device); |
106 | printk(KERN_ERR "lcd : failed to register device\n"); | 108 | pr_err("failed to register device\n"); |
107 | return ret; | 109 | return ret; |
108 | } | 110 | } |
109 | 111 | ||
diff --git a/drivers/video/backlight/l4f00242t03.c b/drivers/video/backlight/l4f00242t03.c index 6022b67285ec..40f606a86093 100644 --- a/drivers/video/backlight/l4f00242t03.c +++ b/drivers/video/backlight/l4f00242t03.c | |||
@@ -11,6 +11,8 @@ | |||
11 | * published by the Free Software Foundation. | 11 | * published by the Free Software Foundation. |
12 | */ | 12 | */ |
13 | 13 | ||
14 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
15 | |||
14 | #include <linux/device.h> | 16 | #include <linux/device.h> |
15 | #include <linux/kernel.h> | 17 | #include <linux/kernel.h> |
16 | #include <linux/delay.h> | 18 | #include <linux/delay.h> |
@@ -159,7 +161,8 @@ static int __devinit l4f00242t03_probe(struct spi_device *spi) | |||
159 | return -EINVAL; | 161 | return -EINVAL; |
160 | } | 162 | } |
161 | 163 | ||
162 | priv = kzalloc(sizeof(struct l4f00242t03_priv), GFP_KERNEL); | 164 | priv = devm_kzalloc(&spi->dev, sizeof(struct l4f00242t03_priv), |
165 | GFP_KERNEL); | ||
163 | 166 | ||
164 | if (priv == NULL) { | 167 | if (priv == NULL) { |
165 | dev_err(&spi->dev, "No memory for this device.\n"); | 168 | dev_err(&spi->dev, "No memory for this device.\n"); |
@@ -177,7 +180,7 @@ static int __devinit l4f00242t03_probe(struct spi_device *spi) | |||
177 | if (ret) { | 180 | if (ret) { |
178 | dev_err(&spi->dev, | 181 | dev_err(&spi->dev, |
179 | "Unable to get the lcd l4f00242t03 reset gpio.\n"); | 182 | "Unable to get the lcd l4f00242t03 reset gpio.\n"); |
180 | goto err; | 183 | return ret; |
181 | } | 184 | } |
182 | 185 | ||
183 | ret = gpio_request_one(pdata->data_enable_gpio, GPIOF_OUT_INIT_LOW, | 186 | ret = gpio_request_one(pdata->data_enable_gpio, GPIOF_OUT_INIT_LOW, |
@@ -185,7 +188,7 @@ static int __devinit l4f00242t03_probe(struct spi_device *spi) | |||
185 | if (ret) { | 188 | if (ret) { |
186 | dev_err(&spi->dev, | 189 | dev_err(&spi->dev, |
187 | "Unable to get the lcd l4f00242t03 data en gpio.\n"); | 190 | "Unable to get the lcd l4f00242t03 data en gpio.\n"); |
188 | goto err2; | 191 | goto err; |
189 | } | 192 | } |
190 | 193 | ||
191 | priv->io_reg = regulator_get(&spi->dev, "vdd"); | 194 | priv->io_reg = regulator_get(&spi->dev, "vdd"); |
@@ -193,7 +196,7 @@ static int __devinit l4f00242t03_probe(struct spi_device *spi) | |||
193 | ret = PTR_ERR(priv->io_reg); | 196 | ret = PTR_ERR(priv->io_reg); |
194 | dev_err(&spi->dev, "%s: Unable to get the IO regulator\n", | 197 | dev_err(&spi->dev, "%s: Unable to get the IO regulator\n", |
195 | __func__); | 198 | __func__); |
196 | goto err3; | 199 | goto err2; |
197 | } | 200 | } |
198 | 201 | ||
199 | priv->core_reg = regulator_get(&spi->dev, "vcore"); | 202 | priv->core_reg = regulator_get(&spi->dev, "vcore"); |
@@ -201,14 +204,14 @@ static int __devinit l4f00242t03_probe(struct spi_device *spi) | |||
201 | ret = PTR_ERR(priv->core_reg); | 204 | ret = PTR_ERR(priv->core_reg); |
202 | dev_err(&spi->dev, "%s: Unable to get the core regulator\n", | 205 | dev_err(&spi->dev, "%s: Unable to get the core regulator\n", |
203 | __func__); | 206 | __func__); |
204 | goto err4; | 207 | goto err3; |
205 | } | 208 | } |
206 | 209 | ||
207 | priv->ld = lcd_device_register("l4f00242t03", | 210 | priv->ld = lcd_device_register("l4f00242t03", |
208 | &spi->dev, priv, &l4f_ops); | 211 | &spi->dev, priv, &l4f_ops); |
209 | if (IS_ERR(priv->ld)) { | 212 | if (IS_ERR(priv->ld)) { |
210 | ret = PTR_ERR(priv->ld); | 213 | ret = PTR_ERR(priv->ld); |
211 | goto err5; | 214 | goto err4; |
212 | } | 215 | } |
213 | 216 | ||
214 | /* Init the LCD */ | 217 | /* Init the LCD */ |
@@ -220,16 +223,14 @@ static int __devinit l4f00242t03_probe(struct spi_device *spi) | |||
220 | 223 | ||
221 | return 0; | 224 | return 0; |
222 | 225 | ||
223 | err5: | ||
224 | regulator_put(priv->core_reg); | ||
225 | err4: | 226 | err4: |
226 | regulator_put(priv->io_reg); | 227 | regulator_put(priv->core_reg); |
227 | err3: | 228 | err3: |
228 | gpio_free(pdata->data_enable_gpio); | 229 | regulator_put(priv->io_reg); |
229 | err2: | 230 | err2: |
230 | gpio_free(pdata->reset_gpio); | 231 | gpio_free(pdata->data_enable_gpio); |
231 | err: | 232 | err: |
232 | kfree(priv); | 233 | gpio_free(pdata->reset_gpio); |
233 | 234 | ||
234 | return ret; | 235 | return ret; |
235 | } | 236 | } |
@@ -250,8 +251,6 @@ static int __devexit l4f00242t03_remove(struct spi_device *spi) | |||
250 | regulator_put(priv->io_reg); | 251 | regulator_put(priv->io_reg); |
251 | regulator_put(priv->core_reg); | 252 | regulator_put(priv->core_reg); |
252 | 253 | ||
253 | kfree(priv); | ||
254 | |||
255 | return 0; | 254 | return 0; |
256 | } | 255 | } |
257 | 256 | ||
diff --git a/drivers/video/backlight/lcd.c b/drivers/video/backlight/lcd.c index 79c1b0d609a8..a5d0d024bb92 100644 --- a/drivers/video/backlight/lcd.c +++ b/drivers/video/backlight/lcd.c | |||
@@ -5,6 +5,8 @@ | |||
5 | * | 5 | * |
6 | */ | 6 | */ |
7 | 7 | ||
8 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
9 | |||
8 | #include <linux/module.h> | 10 | #include <linux/module.h> |
9 | #include <linux/init.h> | 11 | #include <linux/init.h> |
10 | #include <linux/device.h> | 12 | #include <linux/device.h> |
@@ -32,6 +34,8 @@ static int fb_notifier_callback(struct notifier_block *self, | |||
32 | case FB_EVENT_BLANK: | 34 | case FB_EVENT_BLANK: |
33 | case FB_EVENT_MODE_CHANGE: | 35 | case FB_EVENT_MODE_CHANGE: |
34 | case FB_EVENT_MODE_CHANGE_ALL: | 36 | case FB_EVENT_MODE_CHANGE_ALL: |
37 | case FB_EARLY_EVENT_BLANK: | ||
38 | case FB_R_EARLY_EVENT_BLANK: | ||
35 | break; | 39 | break; |
36 | default: | 40 | default: |
37 | return 0; | 41 | return 0; |
@@ -46,6 +50,14 @@ static int fb_notifier_callback(struct notifier_block *self, | |||
46 | if (event == FB_EVENT_BLANK) { | 50 | if (event == FB_EVENT_BLANK) { |
47 | if (ld->ops->set_power) | 51 | if (ld->ops->set_power) |
48 | ld->ops->set_power(ld, *(int *)evdata->data); | 52 | ld->ops->set_power(ld, *(int *)evdata->data); |
53 | } else if (event == FB_EARLY_EVENT_BLANK) { | ||
54 | if (ld->ops->early_set_power) | ||
55 | ld->ops->early_set_power(ld, | ||
56 | *(int *)evdata->data); | ||
57 | } else if (event == FB_R_EARLY_EVENT_BLANK) { | ||
58 | if (ld->ops->r_early_set_power) | ||
59 | ld->ops->r_early_set_power(ld, | ||
60 | *(int *)evdata->data); | ||
49 | } else { | 61 | } else { |
50 | if (ld->ops->set_mode) | 62 | if (ld->ops->set_mode) |
51 | ld->ops->set_mode(ld, evdata->data); | 63 | ld->ops->set_mode(ld, evdata->data); |
@@ -106,7 +118,7 @@ static ssize_t lcd_store_power(struct device *dev, | |||
106 | 118 | ||
107 | mutex_lock(&ld->ops_lock); | 119 | mutex_lock(&ld->ops_lock); |
108 | if (ld->ops && ld->ops->set_power) { | 120 | if (ld->ops && ld->ops->set_power) { |
109 | pr_debug("lcd: set power to %lu\n", power); | 121 | pr_debug("set power to %lu\n", power); |
110 | ld->ops->set_power(ld, power); | 122 | ld->ops->set_power(ld, power); |
111 | rc = count; | 123 | rc = count; |
112 | } | 124 | } |
@@ -142,7 +154,7 @@ static ssize_t lcd_store_contrast(struct device *dev, | |||
142 | 154 | ||
143 | mutex_lock(&ld->ops_lock); | 155 | mutex_lock(&ld->ops_lock); |
144 | if (ld->ops && ld->ops->set_contrast) { | 156 | if (ld->ops && ld->ops->set_contrast) { |
145 | pr_debug("lcd: set contrast to %lu\n", contrast); | 157 | pr_debug("set contrast to %lu\n", contrast); |
146 | ld->ops->set_contrast(ld, contrast); | 158 | ld->ops->set_contrast(ld, contrast); |
147 | rc = count; | 159 | rc = count; |
148 | } | 160 | } |
@@ -253,8 +265,8 @@ static int __init lcd_class_init(void) | |||
253 | { | 265 | { |
254 | lcd_class = class_create(THIS_MODULE, "lcd"); | 266 | lcd_class = class_create(THIS_MODULE, "lcd"); |
255 | if (IS_ERR(lcd_class)) { | 267 | if (IS_ERR(lcd_class)) { |
256 | printk(KERN_WARNING "Unable to create backlight class; errno = %ld\n", | 268 | pr_warn("Unable to create backlight class; errno = %ld\n", |
257 | PTR_ERR(lcd_class)); | 269 | PTR_ERR(lcd_class)); |
258 | return PTR_ERR(lcd_class); | 270 | return PTR_ERR(lcd_class); |
259 | } | 271 | } |
260 | 272 | ||
diff --git a/drivers/video/backlight/ld9040.c b/drivers/video/backlight/ld9040.c index efd352be21ae..58f517fb7d40 100644 --- a/drivers/video/backlight/ld9040.c +++ b/drivers/video/backlight/ld9040.c | |||
@@ -707,7 +707,7 @@ static int ld9040_probe(struct spi_device *spi) | |||
707 | struct backlight_device *bd = NULL; | 707 | struct backlight_device *bd = NULL; |
708 | struct backlight_properties props; | 708 | struct backlight_properties props; |
709 | 709 | ||
710 | lcd = kzalloc(sizeof(struct ld9040), GFP_KERNEL); | 710 | lcd = devm_kzalloc(&spi->dev, sizeof(struct ld9040), GFP_KERNEL); |
711 | if (!lcd) | 711 | if (!lcd) |
712 | return -ENOMEM; | 712 | return -ENOMEM; |
713 | 713 | ||
@@ -717,7 +717,7 @@ static int ld9040_probe(struct spi_device *spi) | |||
717 | ret = spi_setup(spi); | 717 | ret = spi_setup(spi); |
718 | if (ret < 0) { | 718 | if (ret < 0) { |
719 | dev_err(&spi->dev, "spi setup failed.\n"); | 719 | dev_err(&spi->dev, "spi setup failed.\n"); |
720 | goto out_free_lcd; | 720 | return ret; |
721 | } | 721 | } |
722 | 722 | ||
723 | lcd->spi = spi; | 723 | lcd->spi = spi; |
@@ -726,7 +726,7 @@ static int ld9040_probe(struct spi_device *spi) | |||
726 | lcd->lcd_pd = spi->dev.platform_data; | 726 | lcd->lcd_pd = spi->dev.platform_data; |
727 | if (!lcd->lcd_pd) { | 727 | if (!lcd->lcd_pd) { |
728 | dev_err(&spi->dev, "platform data is NULL.\n"); | 728 | dev_err(&spi->dev, "platform data is NULL.\n"); |
729 | goto out_free_lcd; | 729 | return -EFAULT; |
730 | } | 730 | } |
731 | 731 | ||
732 | mutex_init(&lcd->lock); | 732 | mutex_init(&lcd->lock); |
@@ -734,13 +734,13 @@ static int ld9040_probe(struct spi_device *spi) | |||
734 | ret = regulator_bulk_get(lcd->dev, ARRAY_SIZE(supplies), supplies); | 734 | ret = regulator_bulk_get(lcd->dev, ARRAY_SIZE(supplies), supplies); |
735 | if (ret) { | 735 | if (ret) { |
736 | dev_err(lcd->dev, "Failed to get regulators: %d\n", ret); | 736 | dev_err(lcd->dev, "Failed to get regulators: %d\n", ret); |
737 | goto out_free_lcd; | 737 | return ret; |
738 | } | 738 | } |
739 | 739 | ||
740 | ld = lcd_device_register("ld9040", &spi->dev, lcd, &ld9040_lcd_ops); | 740 | ld = lcd_device_register("ld9040", &spi->dev, lcd, &ld9040_lcd_ops); |
741 | if (IS_ERR(ld)) { | 741 | if (IS_ERR(ld)) { |
742 | ret = PTR_ERR(ld); | 742 | ret = PTR_ERR(ld); |
743 | goto out_free_lcd; | 743 | goto out_free_regulator; |
744 | } | 744 | } |
745 | 745 | ||
746 | lcd->ld = ld; | 746 | lcd->ld = ld; |
@@ -782,10 +782,9 @@ static int ld9040_probe(struct spi_device *spi) | |||
782 | 782 | ||
783 | out_unregister_lcd: | 783 | out_unregister_lcd: |
784 | lcd_device_unregister(lcd->ld); | 784 | lcd_device_unregister(lcd->ld); |
785 | out_free_lcd: | 785 | out_free_regulator: |
786 | regulator_bulk_free(ARRAY_SIZE(supplies), supplies); | 786 | regulator_bulk_free(ARRAY_SIZE(supplies), supplies); |
787 | 787 | ||
788 | kfree(lcd); | ||
789 | return ret; | 788 | return ret; |
790 | } | 789 | } |
791 | 790 | ||
@@ -797,7 +796,6 @@ static int __devexit ld9040_remove(struct spi_device *spi) | |||
797 | backlight_device_unregister(lcd->bd); | 796 | backlight_device_unregister(lcd->bd); |
798 | lcd_device_unregister(lcd->ld); | 797 | lcd_device_unregister(lcd->ld); |
799 | regulator_bulk_free(ARRAY_SIZE(supplies), supplies); | 798 | regulator_bulk_free(ARRAY_SIZE(supplies), supplies); |
800 | kfree(lcd); | ||
801 | 799 | ||
802 | return 0; | 800 | return 0; |
803 | } | 801 | } |
@@ -846,7 +844,6 @@ static void ld9040_shutdown(struct spi_device *spi) | |||
846 | static struct spi_driver ld9040_driver = { | 844 | static struct spi_driver ld9040_driver = { |
847 | .driver = { | 845 | .driver = { |
848 | .name = "ld9040", | 846 | .name = "ld9040", |
849 | .bus = &spi_bus_type, | ||
850 | .owner = THIS_MODULE, | 847 | .owner = THIS_MODULE, |
851 | }, | 848 | }, |
852 | .probe = ld9040_probe, | 849 | .probe = ld9040_probe, |
diff --git a/drivers/video/backlight/lm3533_bl.c b/drivers/video/backlight/lm3533_bl.c new file mode 100644 index 000000000000..bebeb63607db --- /dev/null +++ b/drivers/video/backlight/lm3533_bl.c | |||
@@ -0,0 +1,423 @@ | |||
1 | /* | ||
2 | * lm3533-bl.c -- LM3533 Backlight driver | ||
3 | * | ||
4 | * Copyright (C) 2011-2012 Texas Instruments | ||
5 | * | ||
6 | * Author: Johan Hovold <jhovold@gmail.com> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify it | ||
9 | * under the terms of the GNU General Public License as published by the | ||
10 | * Free Software Foundation; either version 2 of the License, or (at your | ||
11 | * option) any later version. | ||
12 | */ | ||
13 | |||
14 | #include <linux/module.h> | ||
15 | #include <linux/init.h> | ||
16 | #include <linux/platform_device.h> | ||
17 | #include <linux/backlight.h> | ||
18 | #include <linux/fb.h> | ||
19 | #include <linux/slab.h> | ||
20 | |||
21 | #include <linux/mfd/lm3533.h> | ||
22 | |||
23 | |||
24 | #define LM3533_HVCTRLBANK_COUNT 2 | ||
25 | #define LM3533_BL_MAX_BRIGHTNESS 255 | ||
26 | |||
27 | #define LM3533_REG_CTRLBANK_AB_BCONF 0x1a | ||
28 | |||
29 | |||
30 | struct lm3533_bl { | ||
31 | struct lm3533 *lm3533; | ||
32 | struct lm3533_ctrlbank cb; | ||
33 | struct backlight_device *bd; | ||
34 | int id; | ||
35 | }; | ||
36 | |||
37 | |||
38 | static inline int lm3533_bl_get_ctrlbank_id(struct lm3533_bl *bl) | ||
39 | { | ||
40 | return bl->id; | ||
41 | } | ||
42 | |||
43 | static int lm3533_bl_update_status(struct backlight_device *bd) | ||
44 | { | ||
45 | struct lm3533_bl *bl = bl_get_data(bd); | ||
46 | int brightness = bd->props.brightness; | ||
47 | |||
48 | if (bd->props.power != FB_BLANK_UNBLANK) | ||
49 | brightness = 0; | ||
50 | if (bd->props.fb_blank != FB_BLANK_UNBLANK) | ||
51 | brightness = 0; | ||
52 | |||
53 | return lm3533_ctrlbank_set_brightness(&bl->cb, (u8)brightness); | ||
54 | } | ||
55 | |||
56 | static int lm3533_bl_get_brightness(struct backlight_device *bd) | ||
57 | { | ||
58 | struct lm3533_bl *bl = bl_get_data(bd); | ||
59 | u8 val; | ||
60 | int ret; | ||
61 | |||
62 | ret = lm3533_ctrlbank_get_brightness(&bl->cb, &val); | ||
63 | if (ret) | ||
64 | return ret; | ||
65 | |||
66 | return val; | ||
67 | } | ||
68 | |||
69 | static const struct backlight_ops lm3533_bl_ops = { | ||
70 | .get_brightness = lm3533_bl_get_brightness, | ||
71 | .update_status = lm3533_bl_update_status, | ||
72 | }; | ||
73 | |||
74 | static ssize_t show_id(struct device *dev, | ||
75 | struct device_attribute *attr, char *buf) | ||
76 | { | ||
77 | struct lm3533_bl *bl = dev_get_drvdata(dev); | ||
78 | |||
79 | return scnprintf(buf, PAGE_SIZE, "%d\n", bl->id); | ||
80 | } | ||
81 | |||
82 | static ssize_t show_als_channel(struct device *dev, | ||
83 | struct device_attribute *attr, char *buf) | ||
84 | { | ||
85 | struct lm3533_bl *bl = dev_get_drvdata(dev); | ||
86 | unsigned channel = lm3533_bl_get_ctrlbank_id(bl); | ||
87 | |||
88 | return scnprintf(buf, PAGE_SIZE, "%u\n", channel); | ||
89 | } | ||
90 | |||
91 | static ssize_t show_als_en(struct device *dev, | ||
92 | struct device_attribute *attr, char *buf) | ||
93 | { | ||
94 | struct lm3533_bl *bl = dev_get_drvdata(dev); | ||
95 | int ctrlbank = lm3533_bl_get_ctrlbank_id(bl); | ||
96 | u8 val; | ||
97 | u8 mask; | ||
98 | bool enable; | ||
99 | int ret; | ||
100 | |||
101 | ret = lm3533_read(bl->lm3533, LM3533_REG_CTRLBANK_AB_BCONF, &val); | ||
102 | if (ret) | ||
103 | return ret; | ||
104 | |||
105 | mask = 1 << (2 * ctrlbank); | ||
106 | enable = val & mask; | ||
107 | |||
108 | return scnprintf(buf, PAGE_SIZE, "%d\n", enable); | ||
109 | } | ||
110 | |||
111 | static ssize_t store_als_en(struct device *dev, | ||
112 | struct device_attribute *attr, | ||
113 | const char *buf, size_t len) | ||
114 | { | ||
115 | struct lm3533_bl *bl = dev_get_drvdata(dev); | ||
116 | int ctrlbank = lm3533_bl_get_ctrlbank_id(bl); | ||
117 | int enable; | ||
118 | u8 val; | ||
119 | u8 mask; | ||
120 | int ret; | ||
121 | |||
122 | if (kstrtoint(buf, 0, &enable)) | ||
123 | return -EINVAL; | ||
124 | |||
125 | mask = 1 << (2 * ctrlbank); | ||
126 | |||
127 | if (enable) | ||
128 | val = mask; | ||
129 | else | ||
130 | val = 0; | ||
131 | |||
132 | ret = lm3533_update(bl->lm3533, LM3533_REG_CTRLBANK_AB_BCONF, val, | ||
133 | mask); | ||
134 | if (ret) | ||
135 | return ret; | ||
136 | |||
137 | return len; | ||
138 | } | ||
139 | |||
140 | static ssize_t show_linear(struct device *dev, | ||
141 | struct device_attribute *attr, char *buf) | ||
142 | { | ||
143 | struct lm3533_bl *bl = dev_get_drvdata(dev); | ||
144 | u8 val; | ||
145 | u8 mask; | ||
146 | int linear; | ||
147 | int ret; | ||
148 | |||
149 | ret = lm3533_read(bl->lm3533, LM3533_REG_CTRLBANK_AB_BCONF, &val); | ||
150 | if (ret) | ||
151 | return ret; | ||
152 | |||
153 | mask = 1 << (2 * lm3533_bl_get_ctrlbank_id(bl) + 1); | ||
154 | |||
155 | if (val & mask) | ||
156 | linear = 1; | ||
157 | else | ||
158 | linear = 0; | ||
159 | |||
160 | return scnprintf(buf, PAGE_SIZE, "%x\n", linear); | ||
161 | } | ||
162 | |||
163 | static ssize_t store_linear(struct device *dev, | ||
164 | struct device_attribute *attr, | ||
165 | const char *buf, size_t len) | ||
166 | { | ||
167 | struct lm3533_bl *bl = dev_get_drvdata(dev); | ||
168 | unsigned long linear; | ||
169 | u8 mask; | ||
170 | u8 val; | ||
171 | int ret; | ||
172 | |||
173 | if (kstrtoul(buf, 0, &linear)) | ||
174 | return -EINVAL; | ||
175 | |||
176 | mask = 1 << (2 * lm3533_bl_get_ctrlbank_id(bl) + 1); | ||
177 | |||
178 | if (linear) | ||
179 | val = mask; | ||
180 | else | ||
181 | val = 0; | ||
182 | |||
183 | ret = lm3533_update(bl->lm3533, LM3533_REG_CTRLBANK_AB_BCONF, val, | ||
184 | mask); | ||
185 | if (ret) | ||
186 | return ret; | ||
187 | |||
188 | return len; | ||
189 | } | ||
190 | |||
191 | static ssize_t show_pwm(struct device *dev, | ||
192 | struct device_attribute *attr, | ||
193 | char *buf) | ||
194 | { | ||
195 | struct lm3533_bl *bl = dev_get_drvdata(dev); | ||
196 | u8 val; | ||
197 | int ret; | ||
198 | |||
199 | ret = lm3533_ctrlbank_get_pwm(&bl->cb, &val); | ||
200 | if (ret) | ||
201 | return ret; | ||
202 | |||
203 | return scnprintf(buf, PAGE_SIZE, "%u\n", val); | ||
204 | } | ||
205 | |||
206 | static ssize_t store_pwm(struct device *dev, | ||
207 | struct device_attribute *attr, | ||
208 | const char *buf, size_t len) | ||
209 | { | ||
210 | struct lm3533_bl *bl = dev_get_drvdata(dev); | ||
211 | u8 val; | ||
212 | int ret; | ||
213 | |||
214 | if (kstrtou8(buf, 0, &val)) | ||
215 | return -EINVAL; | ||
216 | |||
217 | ret = lm3533_ctrlbank_set_pwm(&bl->cb, val); | ||
218 | if (ret) | ||
219 | return ret; | ||
220 | |||
221 | return len; | ||
222 | } | ||
223 | |||
224 | static LM3533_ATTR_RO(als_channel); | ||
225 | static LM3533_ATTR_RW(als_en); | ||
226 | static LM3533_ATTR_RO(id); | ||
227 | static LM3533_ATTR_RW(linear); | ||
228 | static LM3533_ATTR_RW(pwm); | ||
229 | |||
230 | static struct attribute *lm3533_bl_attributes[] = { | ||
231 | &dev_attr_als_channel.attr, | ||
232 | &dev_attr_als_en.attr, | ||
233 | &dev_attr_id.attr, | ||
234 | &dev_attr_linear.attr, | ||
235 | &dev_attr_pwm.attr, | ||
236 | NULL, | ||
237 | }; | ||
238 | |||
239 | static umode_t lm3533_bl_attr_is_visible(struct kobject *kobj, | ||
240 | struct attribute *attr, int n) | ||
241 | { | ||
242 | struct device *dev = container_of(kobj, struct device, kobj); | ||
243 | struct lm3533_bl *bl = dev_get_drvdata(dev); | ||
244 | umode_t mode = attr->mode; | ||
245 | |||
246 | if (attr == &dev_attr_als_channel.attr || | ||
247 | attr == &dev_attr_als_en.attr) { | ||
248 | if (!bl->lm3533->have_als) | ||
249 | mode = 0; | ||
250 | } | ||
251 | |||
252 | return mode; | ||
253 | }; | ||
254 | |||
255 | static struct attribute_group lm3533_bl_attribute_group = { | ||
256 | .is_visible = lm3533_bl_attr_is_visible, | ||
257 | .attrs = lm3533_bl_attributes | ||
258 | }; | ||
259 | |||
260 | static int __devinit lm3533_bl_setup(struct lm3533_bl *bl, | ||
261 | struct lm3533_bl_platform_data *pdata) | ||
262 | { | ||
263 | int ret; | ||
264 | |||
265 | ret = lm3533_ctrlbank_set_max_current(&bl->cb, pdata->max_current); | ||
266 | if (ret) | ||
267 | return ret; | ||
268 | |||
269 | return lm3533_ctrlbank_set_pwm(&bl->cb, pdata->pwm); | ||
270 | } | ||
271 | |||
272 | static int __devinit lm3533_bl_probe(struct platform_device *pdev) | ||
273 | { | ||
274 | struct lm3533 *lm3533; | ||
275 | struct lm3533_bl_platform_data *pdata; | ||
276 | struct lm3533_bl *bl; | ||
277 | struct backlight_device *bd; | ||
278 | struct backlight_properties props; | ||
279 | int ret; | ||
280 | |||
281 | dev_dbg(&pdev->dev, "%s\n", __func__); | ||
282 | |||
283 | lm3533 = dev_get_drvdata(pdev->dev.parent); | ||
284 | if (!lm3533) | ||
285 | return -EINVAL; | ||
286 | |||
287 | pdata = pdev->dev.platform_data; | ||
288 | if (!pdata) { | ||
289 | dev_err(&pdev->dev, "no platform data\n"); | ||
290 | return -EINVAL; | ||
291 | } | ||
292 | |||
293 | if (pdev->id < 0 || pdev->id >= LM3533_HVCTRLBANK_COUNT) { | ||
294 | dev_err(&pdev->dev, "illegal backlight id %d\n", pdev->id); | ||
295 | return -EINVAL; | ||
296 | } | ||
297 | |||
298 | bl = kzalloc(sizeof(*bl), GFP_KERNEL); | ||
299 | if (!bl) { | ||
300 | dev_err(&pdev->dev, | ||
301 | "failed to allocate memory for backlight\n"); | ||
302 | return -ENOMEM; | ||
303 | } | ||
304 | |||
305 | bl->lm3533 = lm3533; | ||
306 | bl->id = pdev->id; | ||
307 | |||
308 | bl->cb.lm3533 = lm3533; | ||
309 | bl->cb.id = lm3533_bl_get_ctrlbank_id(bl); | ||
310 | bl->cb.dev = NULL; /* until registered */ | ||
311 | |||
312 | memset(&props, 0, sizeof(props)); | ||
313 | props.type = BACKLIGHT_RAW; | ||
314 | props.max_brightness = LM3533_BL_MAX_BRIGHTNESS; | ||
315 | props.brightness = pdata->default_brightness; | ||
316 | bd = backlight_device_register(pdata->name, pdev->dev.parent, bl, | ||
317 | &lm3533_bl_ops, &props); | ||
318 | if (IS_ERR(bd)) { | ||
319 | dev_err(&pdev->dev, "failed to register backlight device\n"); | ||
320 | ret = PTR_ERR(bd); | ||
321 | goto err_free; | ||
322 | } | ||
323 | |||
324 | bl->bd = bd; | ||
325 | bl->cb.dev = &bl->bd->dev; | ||
326 | |||
327 | platform_set_drvdata(pdev, bl); | ||
328 | |||
329 | ret = sysfs_create_group(&bd->dev.kobj, &lm3533_bl_attribute_group); | ||
330 | if (ret < 0) { | ||
331 | dev_err(&pdev->dev, "failed to create sysfs attributes\n"); | ||
332 | goto err_unregister; | ||
333 | } | ||
334 | |||
335 | backlight_update_status(bd); | ||
336 | |||
337 | ret = lm3533_bl_setup(bl, pdata); | ||
338 | if (ret) | ||
339 | goto err_sysfs_remove; | ||
340 | |||
341 | ret = lm3533_ctrlbank_enable(&bl->cb); | ||
342 | if (ret) | ||
343 | goto err_sysfs_remove; | ||
344 | |||
345 | return 0; | ||
346 | |||
347 | err_sysfs_remove: | ||
348 | sysfs_remove_group(&bd->dev.kobj, &lm3533_bl_attribute_group); | ||
349 | err_unregister: | ||
350 | backlight_device_unregister(bd); | ||
351 | err_free: | ||
352 | kfree(bl); | ||
353 | |||
354 | return ret; | ||
355 | } | ||
356 | |||
357 | static int __devexit lm3533_bl_remove(struct platform_device *pdev) | ||
358 | { | ||
359 | struct lm3533_bl *bl = platform_get_drvdata(pdev); | ||
360 | struct backlight_device *bd = bl->bd; | ||
361 | |||
362 | dev_dbg(&bd->dev, "%s\n", __func__); | ||
363 | |||
364 | bd->props.power = FB_BLANK_POWERDOWN; | ||
365 | bd->props.brightness = 0; | ||
366 | |||
367 | lm3533_ctrlbank_disable(&bl->cb); | ||
368 | sysfs_remove_group(&bd->dev.kobj, &lm3533_bl_attribute_group); | ||
369 | backlight_device_unregister(bd); | ||
370 | kfree(bl); | ||
371 | |||
372 | return 0; | ||
373 | } | ||
374 | |||
375 | #ifdef CONFIG_PM | ||
376 | static int lm3533_bl_suspend(struct platform_device *pdev, pm_message_t state) | ||
377 | { | ||
378 | struct lm3533_bl *bl = platform_get_drvdata(pdev); | ||
379 | |||
380 | dev_dbg(&pdev->dev, "%s\n", __func__); | ||
381 | |||
382 | return lm3533_ctrlbank_disable(&bl->cb); | ||
383 | } | ||
384 | |||
385 | static int lm3533_bl_resume(struct platform_device *pdev) | ||
386 | { | ||
387 | struct lm3533_bl *bl = platform_get_drvdata(pdev); | ||
388 | |||
389 | dev_dbg(&pdev->dev, "%s\n", __func__); | ||
390 | |||
391 | return lm3533_ctrlbank_enable(&bl->cb); | ||
392 | } | ||
393 | #else | ||
394 | #define lm3533_bl_suspend NULL | ||
395 | #define lm3533_bl_resume NULL | ||
396 | #endif | ||
397 | |||
398 | static void lm3533_bl_shutdown(struct platform_device *pdev) | ||
399 | { | ||
400 | struct lm3533_bl *bl = platform_get_drvdata(pdev); | ||
401 | |||
402 | dev_dbg(&pdev->dev, "%s\n", __func__); | ||
403 | |||
404 | lm3533_ctrlbank_disable(&bl->cb); | ||
405 | } | ||
406 | |||
407 | static struct platform_driver lm3533_bl_driver = { | ||
408 | .driver = { | ||
409 | .name = "lm3533-backlight", | ||
410 | .owner = THIS_MODULE, | ||
411 | }, | ||
412 | .probe = lm3533_bl_probe, | ||
413 | .remove = __devexit_p(lm3533_bl_remove), | ||
414 | .shutdown = lm3533_bl_shutdown, | ||
415 | .suspend = lm3533_bl_suspend, | ||
416 | .resume = lm3533_bl_resume, | ||
417 | }; | ||
418 | module_platform_driver(lm3533_bl_driver); | ||
419 | |||
420 | MODULE_AUTHOR("Johan Hovold <jhovold@gmail.com>"); | ||
421 | MODULE_DESCRIPTION("LM3533 Backlight driver"); | ||
422 | MODULE_LICENSE("GPL"); | ||
423 | MODULE_ALIAS("platform:lm3533-backlight"); | ||
diff --git a/drivers/video/backlight/lms283gf05.c b/drivers/video/backlight/lms283gf05.c index 4161f9e3982a..a9f2c36966f1 100644 --- a/drivers/video/backlight/lms283gf05.c +++ b/drivers/video/backlight/lms283gf05.c | |||
@@ -168,7 +168,8 @@ static int __devinit lms283gf05_probe(struct spi_device *spi) | |||
168 | goto err; | 168 | goto err; |
169 | } | 169 | } |
170 | 170 | ||
171 | st = kzalloc(sizeof(struct lms283gf05_state), GFP_KERNEL); | 171 | st = devm_kzalloc(&spi->dev, sizeof(struct lms283gf05_state), |
172 | GFP_KERNEL); | ||
172 | if (st == NULL) { | 173 | if (st == NULL) { |
173 | dev_err(&spi->dev, "No memory for device state\n"); | 174 | dev_err(&spi->dev, "No memory for device state\n"); |
174 | ret = -ENOMEM; | 175 | ret = -ENOMEM; |
@@ -178,7 +179,7 @@ static int __devinit lms283gf05_probe(struct spi_device *spi) | |||
178 | ld = lcd_device_register("lms283gf05", &spi->dev, st, &lms_ops); | 179 | ld = lcd_device_register("lms283gf05", &spi->dev, st, &lms_ops); |
179 | if (IS_ERR(ld)) { | 180 | if (IS_ERR(ld)) { |
180 | ret = PTR_ERR(ld); | 181 | ret = PTR_ERR(ld); |
181 | goto err2; | 182 | goto err; |
182 | } | 183 | } |
183 | 184 | ||
184 | st->spi = spi; | 185 | st->spi = spi; |
@@ -193,8 +194,6 @@ static int __devinit lms283gf05_probe(struct spi_device *spi) | |||
193 | 194 | ||
194 | return 0; | 195 | return 0; |
195 | 196 | ||
196 | err2: | ||
197 | kfree(st); | ||
198 | err: | 197 | err: |
199 | if (pdata != NULL) | 198 | if (pdata != NULL) |
200 | gpio_free(pdata->reset_gpio); | 199 | gpio_free(pdata->reset_gpio); |
@@ -212,8 +211,6 @@ static int __devexit lms283gf05_remove(struct spi_device *spi) | |||
212 | if (pdata != NULL) | 211 | if (pdata != NULL) |
213 | gpio_free(pdata->reset_gpio); | 212 | gpio_free(pdata->reset_gpio); |
214 | 213 | ||
215 | kfree(st); | ||
216 | |||
217 | return 0; | 214 | return 0; |
218 | } | 215 | } |
219 | 216 | ||
diff --git a/drivers/video/backlight/ltv350qv.c b/drivers/video/backlight/ltv350qv.c index 333949ff3265..6c0f1ac0d32a 100644 --- a/drivers/video/backlight/ltv350qv.c +++ b/drivers/video/backlight/ltv350qv.c | |||
@@ -232,23 +232,20 @@ static int __devinit ltv350qv_probe(struct spi_device *spi) | |||
232 | struct lcd_device *ld; | 232 | struct lcd_device *ld; |
233 | int ret; | 233 | int ret; |
234 | 234 | ||
235 | lcd = kzalloc(sizeof(struct ltv350qv), GFP_KERNEL); | 235 | lcd = devm_kzalloc(&spi->dev, sizeof(struct ltv350qv), GFP_KERNEL); |
236 | if (!lcd) | 236 | if (!lcd) |
237 | return -ENOMEM; | 237 | return -ENOMEM; |
238 | 238 | ||
239 | lcd->spi = spi; | 239 | lcd->spi = spi; |
240 | lcd->power = FB_BLANK_POWERDOWN; | 240 | lcd->power = FB_BLANK_POWERDOWN; |
241 | lcd->buffer = kzalloc(8, GFP_KERNEL); | 241 | lcd->buffer = devm_kzalloc(&spi->dev, 8, GFP_KERNEL); |
242 | if (!lcd->buffer) { | 242 | if (!lcd->buffer) |
243 | ret = -ENOMEM; | 243 | return -ENOMEM; |
244 | goto out_free_lcd; | ||
245 | } | ||
246 | 244 | ||
247 | ld = lcd_device_register("ltv350qv", &spi->dev, lcd, <v_ops); | 245 | ld = lcd_device_register("ltv350qv", &spi->dev, lcd, <v_ops); |
248 | if (IS_ERR(ld)) { | 246 | if (IS_ERR(ld)) |
249 | ret = PTR_ERR(ld); | 247 | return PTR_ERR(ld); |
250 | goto out_free_buffer; | 248 | |
251 | } | ||
252 | lcd->ld = ld; | 249 | lcd->ld = ld; |
253 | 250 | ||
254 | ret = ltv350qv_power(lcd, FB_BLANK_UNBLANK); | 251 | ret = ltv350qv_power(lcd, FB_BLANK_UNBLANK); |
@@ -261,10 +258,6 @@ static int __devinit ltv350qv_probe(struct spi_device *spi) | |||
261 | 258 | ||
262 | out_unregister: | 259 | out_unregister: |
263 | lcd_device_unregister(ld); | 260 | lcd_device_unregister(ld); |
264 | out_free_buffer: | ||
265 | kfree(lcd->buffer); | ||
266 | out_free_lcd: | ||
267 | kfree(lcd); | ||
268 | return ret; | 261 | return ret; |
269 | } | 262 | } |
270 | 263 | ||
@@ -274,8 +267,6 @@ static int __devexit ltv350qv_remove(struct spi_device *spi) | |||
274 | 267 | ||
275 | ltv350qv_power(lcd, FB_BLANK_POWERDOWN); | 268 | ltv350qv_power(lcd, FB_BLANK_POWERDOWN); |
276 | lcd_device_unregister(lcd->ld); | 269 | lcd_device_unregister(lcd->ld); |
277 | kfree(lcd->buffer); | ||
278 | kfree(lcd); | ||
279 | 270 | ||
280 | return 0; | 271 | return 0; |
281 | } | 272 | } |
@@ -310,7 +301,6 @@ static void ltv350qv_shutdown(struct spi_device *spi) | |||
310 | static struct spi_driver ltv350qv_driver = { | 301 | static struct spi_driver ltv350qv_driver = { |
311 | .driver = { | 302 | .driver = { |
312 | .name = "ltv350qv", | 303 | .name = "ltv350qv", |
313 | .bus = &spi_bus_type, | ||
314 | .owner = THIS_MODULE, | 304 | .owner = THIS_MODULE, |
315 | }, | 305 | }, |
316 | 306 | ||
diff --git a/drivers/video/backlight/omap1_bl.c b/drivers/video/backlight/omap1_bl.c index 0175bfb08a1c..bfdc5fbeaa11 100644 --- a/drivers/video/backlight/omap1_bl.c +++ b/drivers/video/backlight/omap1_bl.c | |||
@@ -18,6 +18,8 @@ | |||
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
22 | |||
21 | #include <linux/module.h> | 23 | #include <linux/module.h> |
22 | #include <linux/kernel.h> | 24 | #include <linux/kernel.h> |
23 | #include <linux/init.h> | 25 | #include <linux/init.h> |
@@ -168,7 +170,7 @@ static int omapbl_probe(struct platform_device *pdev) | |||
168 | dev->props.brightness = pdata->default_intensity; | 170 | dev->props.brightness = pdata->default_intensity; |
169 | omapbl_update_status(dev); | 171 | omapbl_update_status(dev); |
170 | 172 | ||
171 | printk(KERN_INFO "OMAP LCD backlight initialised\n"); | 173 | pr_info("OMAP LCD backlight initialised\n"); |
172 | 174 | ||
173 | return 0; | 175 | return 0; |
174 | } | 176 | } |
diff --git a/drivers/video/backlight/pcf50633-backlight.c b/drivers/video/backlight/pcf50633-backlight.c index c65853cb9740..c092159f4383 100644 --- a/drivers/video/backlight/pcf50633-backlight.c +++ b/drivers/video/backlight/pcf50633-backlight.c | |||
@@ -111,6 +111,7 @@ static int __devinit pcf50633_bl_probe(struct platform_device *pdev) | |||
111 | if (!pcf_bl) | 111 | if (!pcf_bl) |
112 | return -ENOMEM; | 112 | return -ENOMEM; |
113 | 113 | ||
114 | memset(&bl_props, 0, sizeof(bl_props)); | ||
114 | bl_props.type = BACKLIGHT_RAW; | 115 | bl_props.type = BACKLIGHT_RAW; |
115 | bl_props.max_brightness = 0x3f; | 116 | bl_props.max_brightness = 0x3f; |
116 | bl_props.power = FB_BLANK_UNBLANK; | 117 | bl_props.power = FB_BLANK_UNBLANK; |
diff --git a/drivers/video/backlight/progear_bl.c b/drivers/video/backlight/progear_bl.c index 6af183d6465e..69b35f02929e 100644 --- a/drivers/video/backlight/progear_bl.c +++ b/drivers/video/backlight/progear_bl.c | |||
@@ -15,6 +15,8 @@ | |||
15 | * | 15 | * |
16 | */ | 16 | */ |
17 | 17 | ||
18 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
19 | |||
18 | #include <linux/module.h> | 20 | #include <linux/module.h> |
19 | #include <linux/kernel.h> | 21 | #include <linux/kernel.h> |
20 | #include <linux/init.h> | 22 | #include <linux/init.h> |
@@ -68,13 +70,13 @@ static int progearbl_probe(struct platform_device *pdev) | |||
68 | 70 | ||
69 | pmu_dev = pci_get_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M7101, NULL); | 71 | pmu_dev = pci_get_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M7101, NULL); |
70 | if (!pmu_dev) { | 72 | if (!pmu_dev) { |
71 | printk("ALI M7101 PMU not found.\n"); | 73 | pr_err("ALI M7101 PMU not found.\n"); |
72 | return -ENODEV; | 74 | return -ENODEV; |
73 | } | 75 | } |
74 | 76 | ||
75 | sb_dev = pci_get_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1533, NULL); | 77 | sb_dev = pci_get_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1533, NULL); |
76 | if (!sb_dev) { | 78 | if (!sb_dev) { |
77 | printk("ALI 1533 SB not found.\n"); | 79 | pr_err("ALI 1533 SB not found.\n"); |
78 | ret = -ENODEV; | 80 | ret = -ENODEV; |
79 | goto put_pmu; | 81 | goto put_pmu; |
80 | } | 82 | } |
diff --git a/drivers/video/backlight/s6e63m0.c b/drivers/video/backlight/s6e63m0.c index e264f55b2574..6437ae474cf2 100644 --- a/drivers/video/backlight/s6e63m0.c +++ b/drivers/video/backlight/s6e63m0.c | |||
@@ -741,7 +741,7 @@ static int __devinit s6e63m0_probe(struct spi_device *spi) | |||
741 | struct backlight_device *bd = NULL; | 741 | struct backlight_device *bd = NULL; |
742 | struct backlight_properties props; | 742 | struct backlight_properties props; |
743 | 743 | ||
744 | lcd = kzalloc(sizeof(struct s6e63m0), GFP_KERNEL); | 744 | lcd = devm_kzalloc(&spi->dev, sizeof(struct s6e63m0), GFP_KERNEL); |
745 | if (!lcd) | 745 | if (!lcd) |
746 | return -ENOMEM; | 746 | return -ENOMEM; |
747 | 747 | ||
@@ -751,7 +751,7 @@ static int __devinit s6e63m0_probe(struct spi_device *spi) | |||
751 | ret = spi_setup(spi); | 751 | ret = spi_setup(spi); |
752 | if (ret < 0) { | 752 | if (ret < 0) { |
753 | dev_err(&spi->dev, "spi setup failed.\n"); | 753 | dev_err(&spi->dev, "spi setup failed.\n"); |
754 | goto out_free_lcd; | 754 | return ret; |
755 | } | 755 | } |
756 | 756 | ||
757 | lcd->spi = spi; | 757 | lcd->spi = spi; |
@@ -760,14 +760,12 @@ static int __devinit s6e63m0_probe(struct spi_device *spi) | |||
760 | lcd->lcd_pd = (struct lcd_platform_data *)spi->dev.platform_data; | 760 | lcd->lcd_pd = (struct lcd_platform_data *)spi->dev.platform_data; |
761 | if (!lcd->lcd_pd) { | 761 | if (!lcd->lcd_pd) { |
762 | dev_err(&spi->dev, "platform data is NULL.\n"); | 762 | dev_err(&spi->dev, "platform data is NULL.\n"); |
763 | goto out_free_lcd; | 763 | return -EFAULT; |
764 | } | 764 | } |
765 | 765 | ||
766 | ld = lcd_device_register("s6e63m0", &spi->dev, lcd, &s6e63m0_lcd_ops); | 766 | ld = lcd_device_register("s6e63m0", &spi->dev, lcd, &s6e63m0_lcd_ops); |
767 | if (IS_ERR(ld)) { | 767 | if (IS_ERR(ld)) |
768 | ret = PTR_ERR(ld); | 768 | return PTR_ERR(ld); |
769 | goto out_free_lcd; | ||
770 | } | ||
771 | 769 | ||
772 | lcd->ld = ld; | 770 | lcd->ld = ld; |
773 | 771 | ||
@@ -824,8 +822,6 @@ static int __devinit s6e63m0_probe(struct spi_device *spi) | |||
824 | 822 | ||
825 | out_lcd_unregister: | 823 | out_lcd_unregister: |
826 | lcd_device_unregister(ld); | 824 | lcd_device_unregister(ld); |
827 | out_free_lcd: | ||
828 | kfree(lcd); | ||
829 | return ret; | 825 | return ret; |
830 | } | 826 | } |
831 | 827 | ||
@@ -838,7 +834,6 @@ static int __devexit s6e63m0_remove(struct spi_device *spi) | |||
838 | device_remove_file(&spi->dev, &dev_attr_gamma_mode); | 834 | device_remove_file(&spi->dev, &dev_attr_gamma_mode); |
839 | backlight_device_unregister(lcd->bd); | 835 | backlight_device_unregister(lcd->bd); |
840 | lcd_device_unregister(lcd->ld); | 836 | lcd_device_unregister(lcd->ld); |
841 | kfree(lcd); | ||
842 | 837 | ||
843 | return 0; | 838 | return 0; |
844 | } | 839 | } |
@@ -899,7 +894,6 @@ static void s6e63m0_shutdown(struct spi_device *spi) | |||
899 | static struct spi_driver s6e63m0_driver = { | 894 | static struct spi_driver s6e63m0_driver = { |
900 | .driver = { | 895 | .driver = { |
901 | .name = "s6e63m0", | 896 | .name = "s6e63m0", |
902 | .bus = &spi_bus_type, | ||
903 | .owner = THIS_MODULE, | 897 | .owner = THIS_MODULE, |
904 | }, | 898 | }, |
905 | .probe = s6e63m0_probe, | 899 | .probe = s6e63m0_probe, |
diff --git a/drivers/video/backlight/tdo24m.c b/drivers/video/backlight/tdo24m.c index 2368b8e5f89e..02444d042cd5 100644 --- a/drivers/video/backlight/tdo24m.c +++ b/drivers/video/backlight/tdo24m.c | |||
@@ -349,7 +349,7 @@ static int __devinit tdo24m_probe(struct spi_device *spi) | |||
349 | if (err) | 349 | if (err) |
350 | return err; | 350 | return err; |
351 | 351 | ||
352 | lcd = kzalloc(sizeof(struct tdo24m), GFP_KERNEL); | 352 | lcd = devm_kzalloc(&spi->dev, sizeof(struct tdo24m), GFP_KERNEL); |
353 | if (!lcd) | 353 | if (!lcd) |
354 | return -ENOMEM; | 354 | return -ENOMEM; |
355 | 355 | ||
@@ -357,11 +357,9 @@ static int __devinit tdo24m_probe(struct spi_device *spi) | |||
357 | lcd->power = FB_BLANK_POWERDOWN; | 357 | lcd->power = FB_BLANK_POWERDOWN; |
358 | lcd->mode = MODE_VGA; /* default to VGA */ | 358 | lcd->mode = MODE_VGA; /* default to VGA */ |
359 | 359 | ||
360 | lcd->buf = kmalloc(TDO24M_SPI_BUFF_SIZE, GFP_KERNEL); | 360 | lcd->buf = devm_kzalloc(&spi->dev, TDO24M_SPI_BUFF_SIZE, GFP_KERNEL); |
361 | if (lcd->buf == NULL) { | 361 | if (lcd->buf == NULL) |
362 | kfree(lcd); | ||
363 | return -ENOMEM; | 362 | return -ENOMEM; |
364 | } | ||
365 | 363 | ||
366 | m = &lcd->msg; | 364 | m = &lcd->msg; |
367 | x = &lcd->xfer; | 365 | x = &lcd->xfer; |
@@ -383,15 +381,13 @@ static int __devinit tdo24m_probe(struct spi_device *spi) | |||
383 | break; | 381 | break; |
384 | default: | 382 | default: |
385 | dev_err(&spi->dev, "Unsupported model"); | 383 | dev_err(&spi->dev, "Unsupported model"); |
386 | goto out_free; | 384 | return -EINVAL; |
387 | } | 385 | } |
388 | 386 | ||
389 | lcd->lcd_dev = lcd_device_register("tdo24m", &spi->dev, | 387 | lcd->lcd_dev = lcd_device_register("tdo24m", &spi->dev, |
390 | lcd, &tdo24m_ops); | 388 | lcd, &tdo24m_ops); |
391 | if (IS_ERR(lcd->lcd_dev)) { | 389 | if (IS_ERR(lcd->lcd_dev)) |
392 | err = PTR_ERR(lcd->lcd_dev); | 390 | return PTR_ERR(lcd->lcd_dev); |
393 | goto out_free; | ||
394 | } | ||
395 | 391 | ||
396 | dev_set_drvdata(&spi->dev, lcd); | 392 | dev_set_drvdata(&spi->dev, lcd); |
397 | err = tdo24m_power(lcd, FB_BLANK_UNBLANK); | 393 | err = tdo24m_power(lcd, FB_BLANK_UNBLANK); |
@@ -402,9 +398,6 @@ static int __devinit tdo24m_probe(struct spi_device *spi) | |||
402 | 398 | ||
403 | out_unregister: | 399 | out_unregister: |
404 | lcd_device_unregister(lcd->lcd_dev); | 400 | lcd_device_unregister(lcd->lcd_dev); |
405 | out_free: | ||
406 | kfree(lcd->buf); | ||
407 | kfree(lcd); | ||
408 | return err; | 401 | return err; |
409 | } | 402 | } |
410 | 403 | ||
@@ -414,8 +407,6 @@ static int __devexit tdo24m_remove(struct spi_device *spi) | |||
414 | 407 | ||
415 | tdo24m_power(lcd, FB_BLANK_POWERDOWN); | 408 | tdo24m_power(lcd, FB_BLANK_POWERDOWN); |
416 | lcd_device_unregister(lcd->lcd_dev); | 409 | lcd_device_unregister(lcd->lcd_dev); |
417 | kfree(lcd->buf); | ||
418 | kfree(lcd); | ||
419 | 410 | ||
420 | return 0; | 411 | return 0; |
421 | } | 412 | } |
diff --git a/drivers/video/backlight/tosa_bl.c b/drivers/video/backlight/tosa_bl.c index 2b241abced43..0d54e607e82d 100644 --- a/drivers/video/backlight/tosa_bl.c +++ b/drivers/video/backlight/tosa_bl.c | |||
@@ -82,8 +82,11 @@ static int __devinit tosa_bl_probe(struct i2c_client *client, | |||
82 | const struct i2c_device_id *id) | 82 | const struct i2c_device_id *id) |
83 | { | 83 | { |
84 | struct backlight_properties props; | 84 | struct backlight_properties props; |
85 | struct tosa_bl_data *data = kzalloc(sizeof(struct tosa_bl_data), GFP_KERNEL); | 85 | struct tosa_bl_data *data; |
86 | int ret = 0; | 86 | int ret = 0; |
87 | |||
88 | data = devm_kzalloc(&client->dev, sizeof(struct tosa_bl_data), | ||
89 | GFP_KERNEL); | ||
87 | if (!data) | 90 | if (!data) |
88 | return -ENOMEM; | 91 | return -ENOMEM; |
89 | 92 | ||
@@ -92,7 +95,7 @@ static int __devinit tosa_bl_probe(struct i2c_client *client, | |||
92 | ret = gpio_request(TOSA_GPIO_BL_C20MA, "backlight"); | 95 | ret = gpio_request(TOSA_GPIO_BL_C20MA, "backlight"); |
93 | if (ret) { | 96 | if (ret) { |
94 | dev_dbg(&data->bl->dev, "Unable to request gpio!\n"); | 97 | dev_dbg(&data->bl->dev, "Unable to request gpio!\n"); |
95 | goto err_gpio_bl; | 98 | return ret; |
96 | } | 99 | } |
97 | ret = gpio_direction_output(TOSA_GPIO_BL_C20MA, 0); | 100 | ret = gpio_direction_output(TOSA_GPIO_BL_C20MA, 0); |
98 | if (ret) | 101 | if (ret) |
@@ -122,8 +125,6 @@ err_reg: | |||
122 | data->bl = NULL; | 125 | data->bl = NULL; |
123 | err_gpio_dir: | 126 | err_gpio_dir: |
124 | gpio_free(TOSA_GPIO_BL_C20MA); | 127 | gpio_free(TOSA_GPIO_BL_C20MA); |
125 | err_gpio_bl: | ||
126 | kfree(data); | ||
127 | return ret; | 128 | return ret; |
128 | } | 129 | } |
129 | 130 | ||
@@ -136,8 +137,6 @@ static int __devexit tosa_bl_remove(struct i2c_client *client) | |||
136 | 137 | ||
137 | gpio_free(TOSA_GPIO_BL_C20MA); | 138 | gpio_free(TOSA_GPIO_BL_C20MA); |
138 | 139 | ||
139 | kfree(data); | ||
140 | |||
141 | return 0; | 140 | return 0; |
142 | } | 141 | } |
143 | 142 | ||
diff --git a/drivers/video/backlight/tosa_lcd.c b/drivers/video/backlight/tosa_lcd.c index 2231aec23918..47823b8efff0 100644 --- a/drivers/video/backlight/tosa_lcd.c +++ b/drivers/video/backlight/tosa_lcd.c | |||
@@ -174,7 +174,8 @@ static int __devinit tosa_lcd_probe(struct spi_device *spi) | |||
174 | int ret; | 174 | int ret; |
175 | struct tosa_lcd_data *data; | 175 | struct tosa_lcd_data *data; |
176 | 176 | ||
177 | data = kzalloc(sizeof(struct tosa_lcd_data), GFP_KERNEL); | 177 | data = devm_kzalloc(&spi->dev, sizeof(struct tosa_lcd_data), |
178 | GFP_KERNEL); | ||
178 | if (!data) | 179 | if (!data) |
179 | return -ENOMEM; | 180 | return -ENOMEM; |
180 | 181 | ||
@@ -187,7 +188,7 @@ static int __devinit tosa_lcd_probe(struct spi_device *spi) | |||
187 | 188 | ||
188 | ret = spi_setup(spi); | 189 | ret = spi_setup(spi); |
189 | if (ret < 0) | 190 | if (ret < 0) |
190 | goto err_spi; | 191 | return ret; |
191 | 192 | ||
192 | data->spi = spi; | 193 | data->spi = spi; |
193 | dev_set_drvdata(&spi->dev, data); | 194 | dev_set_drvdata(&spi->dev, data); |
@@ -224,8 +225,6 @@ err_gpio_dir: | |||
224 | gpio_free(TOSA_GPIO_TG_ON); | 225 | gpio_free(TOSA_GPIO_TG_ON); |
225 | err_gpio_tg: | 226 | err_gpio_tg: |
226 | dev_set_drvdata(&spi->dev, NULL); | 227 | dev_set_drvdata(&spi->dev, NULL); |
227 | err_spi: | ||
228 | kfree(data); | ||
229 | return ret; | 228 | return ret; |
230 | } | 229 | } |
231 | 230 | ||
@@ -242,7 +241,6 @@ static int __devexit tosa_lcd_remove(struct spi_device *spi) | |||
242 | 241 | ||
243 | gpio_free(TOSA_GPIO_TG_ON); | 242 | gpio_free(TOSA_GPIO_TG_ON); |
244 | dev_set_drvdata(&spi->dev, NULL); | 243 | dev_set_drvdata(&spi->dev, NULL); |
245 | kfree(data); | ||
246 | 244 | ||
247 | return 0; | 245 | return 0; |
248 | } | 246 | } |
diff --git a/drivers/video/backlight/wm831x_bl.c b/drivers/video/backlight/wm831x_bl.c index 5d365deb5f82..9e5517a3a52b 100644 --- a/drivers/video/backlight/wm831x_bl.c +++ b/drivers/video/backlight/wm831x_bl.c | |||
@@ -194,6 +194,7 @@ static int wm831x_backlight_probe(struct platform_device *pdev) | |||
194 | data->current_brightness = 0; | 194 | data->current_brightness = 0; |
195 | data->isink_reg = isink_reg; | 195 | data->isink_reg = isink_reg; |
196 | 196 | ||
197 | memset(&props, 0, sizeof(props)); | ||
197 | props.type = BACKLIGHT_RAW; | 198 | props.type = BACKLIGHT_RAW; |
198 | props.max_brightness = max_isel; | 199 | props.max_brightness = max_isel; |
199 | bl = backlight_device_register("wm831x", &pdev->dev, data, | 200 | bl = backlight_device_register("wm831x", &pdev->dev, data, |
diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c index c6ce416ab587..0dff12a1daef 100644 --- a/drivers/video/fbmem.c +++ b/drivers/video/fbmem.c | |||
@@ -1046,20 +1046,29 @@ fb_set_var(struct fb_info *info, struct fb_var_screeninfo *var) | |||
1046 | int | 1046 | int |
1047 | fb_blank(struct fb_info *info, int blank) | 1047 | fb_blank(struct fb_info *info, int blank) |
1048 | { | 1048 | { |
1049 | int ret = -EINVAL; | 1049 | struct fb_event event; |
1050 | int ret = -EINVAL, early_ret; | ||
1050 | 1051 | ||
1051 | if (blank > FB_BLANK_POWERDOWN) | 1052 | if (blank > FB_BLANK_POWERDOWN) |
1052 | blank = FB_BLANK_POWERDOWN; | 1053 | blank = FB_BLANK_POWERDOWN; |
1053 | 1054 | ||
1055 | event.info = info; | ||
1056 | event.data = ␣ | ||
1057 | |||
1058 | early_ret = fb_notifier_call_chain(FB_EARLY_EVENT_BLANK, &event); | ||
1059 | |||
1054 | if (info->fbops->fb_blank) | 1060 | if (info->fbops->fb_blank) |
1055 | ret = info->fbops->fb_blank(blank, info); | 1061 | ret = info->fbops->fb_blank(blank, info); |
1056 | 1062 | ||
1057 | if (!ret) { | 1063 | if (!ret) |
1058 | struct fb_event event; | ||
1059 | |||
1060 | event.info = info; | ||
1061 | event.data = ␣ | ||
1062 | fb_notifier_call_chain(FB_EVENT_BLANK, &event); | 1064 | fb_notifier_call_chain(FB_EVENT_BLANK, &event); |
1065 | else { | ||
1066 | /* | ||
1067 | * if fb_blank is failed then revert effects of | ||
1068 | * the early blank event. | ||
1069 | */ | ||
1070 | if (!early_ret) | ||
1071 | fb_notifier_call_chain(FB_R_EARLY_EVENT_BLANK, &event); | ||
1063 | } | 1072 | } |
1064 | 1073 | ||
1065 | return ret; | 1074 | return ret; |
diff --git a/drivers/video/omap2/displays/panel-acx565akm.c b/drivers/video/omap2/displays/panel-acx565akm.c index d26f37ac69d8..74e7cf078505 100644 --- a/drivers/video/omap2/displays/panel-acx565akm.c +++ b/drivers/video/omap2/displays/panel-acx565akm.c | |||
@@ -532,6 +532,7 @@ static int acx_panel_probe(struct omap_dss_device *dssdev) | |||
532 | 532 | ||
533 | /*------- Backlight control --------*/ | 533 | /*------- Backlight control --------*/ |
534 | 534 | ||
535 | memset(&props, 0, sizeof(props)); | ||
535 | props.fb_blank = FB_BLANK_UNBLANK; | 536 | props.fb_blank = FB_BLANK_UNBLANK; |
536 | props.power = FB_BLANK_UNBLANK; | 537 | props.power = FB_BLANK_UNBLANK; |
537 | props.type = BACKLIGHT_RAW; | 538 | props.type = BACKLIGHT_RAW; |