aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/base/regmap/regcache-lzo.c2
-rw-r--r--drivers/block/drbd/drbd_nl.c2
-rw-r--r--drivers/leds/Kconfig10
-rw-r--r--drivers/leds/Makefile1
-rw-r--r--drivers/leds/led-class.c70
-rw-r--r--drivers/leds/led-core.c70
-rw-r--r--drivers/leds/leds-gpio.c3
-rw-r--r--drivers/leds/leds-lm3530.c135
-rw-r--r--drivers/leds/leds-lp5521.c147
-rw-r--r--drivers/leds/leds-lp5523.c6
-rw-r--r--drivers/leds/leds-pca9633.c193
-rw-r--r--drivers/leds/leds-tca6507.c9
-rw-r--r--drivers/mtd/chips/cfi_cmdset_0001.c6
-rw-r--r--drivers/mtd/mtdchar.c2
-rw-r--r--drivers/rtc/Kconfig17
-rw-r--r--drivers/rtc/Makefile2
-rw-r--r--drivers/rtc/rtc-at91sam9.c2
-rw-r--r--drivers/rtc/rtc-bq32k.c12
-rw-r--r--drivers/rtc/rtc-cmos.c2
-rw-r--r--drivers/rtc/rtc-coh901331.c2
-rw-r--r--drivers/rtc/rtc-da9052.c293
-rw-r--r--drivers/rtc/rtc-davinci.c2
-rw-r--r--drivers/rtc/rtc-ds1305.c12
-rw-r--r--drivers/rtc/rtc-ds1307.c182
-rw-r--r--drivers/rtc/rtc-ds1374.c13
-rw-r--r--drivers/rtc/rtc-ds1390.c12
-rw-r--r--drivers/rtc/rtc-ds1511.c2
-rw-r--r--drivers/rtc/rtc-ds1553.c2
-rw-r--r--drivers/rtc/rtc-ds1672.c13
-rw-r--r--drivers/rtc/rtc-ds3232.c13
-rw-r--r--drivers/rtc/rtc-ds3234.c12
-rw-r--r--drivers/rtc/rtc-em3027.c13
-rw-r--r--drivers/rtc/rtc-fm3130.c12
-rw-r--r--drivers/rtc/rtc-isl12022.c13
-rw-r--r--drivers/rtc/rtc-isl1208.c15
-rw-r--r--drivers/rtc/rtc-lpc32xx.c2
-rw-r--r--drivers/rtc/rtc-ls1x.c210
-rw-r--r--drivers/rtc/rtc-m41t80.c13
-rw-r--r--drivers/rtc/rtc-m41t93.c12
-rw-r--r--drivers/rtc/rtc-m41t94.c14
-rw-r--r--drivers/rtc/rtc-max6900.c13
-rw-r--r--drivers/rtc/rtc-max6902.c12
-rw-r--r--drivers/rtc/rtc-max8925.c21
-rw-r--r--drivers/rtc/rtc-mpc5121.c4
-rw-r--r--drivers/rtc/rtc-mrst.c2
-rw-r--r--drivers/rtc/rtc-mv.c2
-rw-r--r--drivers/rtc/rtc-nuc900.c2
-rw-r--r--drivers/rtc/rtc-omap.c4
-rw-r--r--drivers/rtc/rtc-pcf2123.c13
-rw-r--r--drivers/rtc/rtc-pcf8563.c13
-rw-r--r--drivers/rtc/rtc-pcf8583.c13
-rw-r--r--drivers/rtc/rtc-pl030.c2
-rw-r--r--drivers/rtc/rtc-pl031.c2
-rw-r--r--drivers/rtc/rtc-pm8xxx.c2
-rw-r--r--drivers/rtc/rtc-pxa.c4
-rw-r--r--drivers/rtc/rtc-r9701.c12
-rw-r--r--drivers/rtc/rtc-rs5c348.c13
-rw-r--r--drivers/rtc/rtc-rs5c372.c13
-rw-r--r--drivers/rtc/rtc-rv3029c2.c13
-rw-r--r--drivers/rtc/rtc-rx8025.c13
-rw-r--r--drivers/rtc/rtc-rx8581.c13
-rw-r--r--drivers/rtc/rtc-s35390a.c13
-rw-r--r--drivers/rtc/rtc-s3c.c4
-rw-r--r--drivers/rtc/rtc-sa1100.c7
-rw-r--r--drivers/rtc/rtc-sh.c8
-rw-r--r--drivers/rtc/rtc-spear.c100
-rw-r--r--drivers/rtc/rtc-stk17ta8.c2
-rw-r--r--drivers/rtc/rtc-twl.c28
-rw-r--r--drivers/rtc/rtc-tx4939.c2
-rw-r--r--drivers/rtc/rtc-vr41xx.c4
-rw-r--r--drivers/rtc/rtc-x1205.c13
-rw-r--r--drivers/s390/char/sclp_cmd.c5
-rw-r--r--drivers/staging/rtl8187se/r8180_core.c2
-rw-r--r--drivers/staging/rtl8192e/rtl8192e/rtl_dm.c4
-rw-r--r--drivers/staging/telephony/ixj.c57
-rw-r--r--drivers/uwb/allocator.c6
-rw-r--r--drivers/video/backlight/88pm860x_bl.c8
-rw-r--r--drivers/video/backlight/Kconfig21
-rw-r--r--drivers/video/backlight/Makefile4
-rw-r--r--drivers/video/backlight/aat2870_bl.c9
-rw-r--r--drivers/video/backlight/adp5520_bl.c6
-rw-r--r--drivers/video/backlight/adp8860_bl.c12
-rw-r--r--drivers/video/backlight/adp8870_bl.c12
-rw-r--r--drivers/video/backlight/ams369fg06.c13
-rw-r--r--drivers/video/backlight/corgi_lcd.c12
-rw-r--r--drivers/video/backlight/cr_bllcd.c3
-rw-r--r--drivers/video/backlight/da903x_bl.c6
-rw-r--r--drivers/video/backlight/l4f00242t03.c13
-rw-r--r--drivers/video/backlight/ld9040.c13
-rw-r--r--drivers/video/backlight/lms283gf05.c13
-rw-r--r--drivers/video/backlight/lp855x_bl.c331
-rw-r--r--drivers/video/backlight/ltv350qv.c12
-rw-r--r--drivers/video/backlight/max8925_bl.c7
-rw-r--r--drivers/video/backlight/omap1_bl.c9
-rw-r--r--drivers/video/backlight/ot200_bl.c175
-rw-r--r--drivers/video/backlight/pandora_bl.c171
-rw-r--r--drivers/video/backlight/pcf50633-backlight.c16
-rw-r--r--drivers/video/backlight/platform_lcd.c19
-rw-r--r--drivers/video/backlight/pwm_bl.c7
-rw-r--r--drivers/video/backlight/s6e63m0.c13
-rw-r--r--drivers/video/backlight/tdo24m.c12
-rw-r--r--drivers/video/backlight/tosa_bl.c13
-rw-r--r--drivers/video/backlight/tosa_lcd.c13
-rw-r--r--drivers/video/backlight/vgg2432a4.c15
-rw-r--r--drivers/video/backlight/wm831x_bl.c6
-rw-r--r--drivers/video/uvesafb.c2
106 files changed, 2035 insertions, 925 deletions
diff --git a/drivers/base/regmap/regcache-lzo.c b/drivers/base/regmap/regcache-lzo.c
index 8d0061569326..77dc53272289 100644
--- a/drivers/base/regmap/regcache-lzo.c
+++ b/drivers/base/regmap/regcache-lzo.c
@@ -341,7 +341,7 @@ static int regcache_lzo_sync(struct regmap *map, unsigned int min,
341 341
342 lzo_blocks = map->cache; 342 lzo_blocks = map->cache;
343 i = min; 343 i = min;
344 for_each_set_bit_cont(i, lzo_blocks[0]->sync_bmp, 344 for_each_set_bit_from(i, lzo_blocks[0]->sync_bmp,
345 lzo_blocks[0]->sync_bmp_nbits) { 345 lzo_blocks[0]->sync_bmp_nbits) {
346 if (i > max) 346 if (i > max)
347 continue; 347 continue;
diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c
index e09f9cebbb20..abfaacaaf346 100644
--- a/drivers/block/drbd/drbd_nl.c
+++ b/drivers/block/drbd/drbd_nl.c
@@ -179,7 +179,7 @@ int drbd_khelper(struct drbd_conf *mdev, char *cmd)
179 dev_info(DEV, "helper command: %s %s %s\n", usermode_helper, cmd, mb); 179 dev_info(DEV, "helper command: %s %s %s\n", usermode_helper, cmd, mb);
180 180
181 drbd_bcast_ev_helper(mdev, cmd); 181 drbd_bcast_ev_helper(mdev, cmd);
182 ret = call_usermodehelper(usermode_helper, argv, envp, 1); 182 ret = call_usermodehelper(usermode_helper, argv, envp, UMH_WAIT_PROC);
183 if (ret) 183 if (ret)
184 dev_warn(DEV, "helper command: %s %s %s exit code %u (0x%x)\n", 184 dev_warn(DEV, "helper command: %s %s %s exit code %u (0x%x)\n",
185 usermode_helper, cmd, mb, 185 usermode_helper, cmd, mb,
diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
index 8c7a75d53101..589ba02d65a2 100644
--- a/drivers/leds/Kconfig
+++ b/drivers/leds/Kconfig
@@ -17,7 +17,7 @@ menuconfig NEW_LEDS
17if NEW_LEDS 17if NEW_LEDS
18 18
19config LEDS_CLASS 19config LEDS_CLASS
20 bool "LED Class Support" 20 tristate "LED Class Support"
21 help 21 help
22 This option enables the led sysfs class in /sys/class/leds. You'll 22 This option enables the led sysfs class in /sys/class/leds. You'll
23 need this to do anything useful with LEDs. If unsure, say N. 23 need this to do anything useful with LEDs. If unsure, say N.
@@ -234,6 +234,14 @@ config LEDS_PCA955X
234 LED driver chips accessed via the I2C bus. Supported 234 LED driver chips accessed via the I2C bus. Supported
235 devices include PCA9550, PCA9551, PCA9552, and PCA9553. 235 devices include PCA9550, PCA9551, PCA9552, and PCA9553.
236 236
237config LEDS_PCA9633
238 tristate "LED support for PCA9633 I2C chip"
239 depends on LEDS_CLASS
240 depends on I2C
241 help
242 This option enables support for LEDs connected to the PCA9633
243 LED driver chip accessed via the I2C bus.
244
237config LEDS_WM831X_STATUS 245config LEDS_WM831X_STATUS
238 tristate "LED support for status LEDs on WM831x PMICs" 246 tristate "LED support for status LEDs on WM831x PMICs"
239 depends on LEDS_CLASS 247 depends on LEDS_CLASS
diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile
index 6bcf4f695515..fa0f428b32fe 100644
--- a/drivers/leds/Makefile
+++ b/drivers/leds/Makefile
@@ -30,6 +30,7 @@ obj-$(CONFIG_LEDS_HP6XX) += leds-hp6xx.o
30obj-$(CONFIG_LEDS_OT200) += leds-ot200.o 30obj-$(CONFIG_LEDS_OT200) += leds-ot200.o
31obj-$(CONFIG_LEDS_FSG) += leds-fsg.o 31obj-$(CONFIG_LEDS_FSG) += leds-fsg.o
32obj-$(CONFIG_LEDS_PCA955X) += leds-pca955x.o 32obj-$(CONFIG_LEDS_PCA955X) += leds-pca955x.o
33obj-$(CONFIG_LEDS_PCA9633) += leds-pca9633.o
33obj-$(CONFIG_LEDS_DA903X) += leds-da903x.o 34obj-$(CONFIG_LEDS_DA903X) += leds-da903x.o
34obj-$(CONFIG_LEDS_WM831X_STATUS) += leds-wm831x-status.o 35obj-$(CONFIG_LEDS_WM831X_STATUS) += leds-wm831x-status.o
35obj-$(CONFIG_LEDS_WM8350) += leds-wm8350.o 36obj-$(CONFIG_LEDS_WM8350) += leds-wm8350.o
diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c
index 0c8739c448b1..5bff8439dc68 100644
--- a/drivers/leds/led-class.c
+++ b/drivers/leds/led-class.c
@@ -110,50 +110,6 @@ static void led_timer_function(unsigned long data)
110 mod_timer(&led_cdev->blink_timer, jiffies + msecs_to_jiffies(delay)); 110 mod_timer(&led_cdev->blink_timer, jiffies + msecs_to_jiffies(delay));
111} 111}
112 112
113static void led_stop_software_blink(struct led_classdev *led_cdev)
114{
115 /* deactivate previous settings */
116 del_timer_sync(&led_cdev->blink_timer);
117 led_cdev->blink_delay_on = 0;
118 led_cdev->blink_delay_off = 0;
119}
120
121static void led_set_software_blink(struct led_classdev *led_cdev,
122 unsigned long delay_on,
123 unsigned long delay_off)
124{
125 int current_brightness;
126
127 current_brightness = led_get_brightness(led_cdev);
128 if (current_brightness)
129 led_cdev->blink_brightness = current_brightness;
130 if (!led_cdev->blink_brightness)
131 led_cdev->blink_brightness = led_cdev->max_brightness;
132
133 if (led_get_trigger_data(led_cdev) &&
134 delay_on == led_cdev->blink_delay_on &&
135 delay_off == led_cdev->blink_delay_off)
136 return;
137
138 led_stop_software_blink(led_cdev);
139
140 led_cdev->blink_delay_on = delay_on;
141 led_cdev->blink_delay_off = delay_off;
142
143 /* never on - don't blink */
144 if (!delay_on)
145 return;
146
147 /* never off - just set to brightness */
148 if (!delay_off) {
149 led_set_brightness(led_cdev, led_cdev->blink_brightness);
150 return;
151 }
152
153 mod_timer(&led_cdev->blink_timer, jiffies + 1);
154}
155
156
157/** 113/**
158 * led_classdev_suspend - suspend an led_classdev. 114 * led_classdev_suspend - suspend an led_classdev.
159 * @led_cdev: the led_classdev to suspend. 115 * @led_cdev: the led_classdev to suspend.
@@ -262,32 +218,6 @@ void led_classdev_unregister(struct led_classdev *led_cdev)
262} 218}
263EXPORT_SYMBOL_GPL(led_classdev_unregister); 219EXPORT_SYMBOL_GPL(led_classdev_unregister);
264 220
265void led_blink_set(struct led_classdev *led_cdev,
266 unsigned long *delay_on,
267 unsigned long *delay_off)
268{
269 del_timer_sync(&led_cdev->blink_timer);
270
271 if (led_cdev->blink_set &&
272 !led_cdev->blink_set(led_cdev, delay_on, delay_off))
273 return;
274
275 /* blink with 1 Hz as default if nothing specified */
276 if (!*delay_on && !*delay_off)
277 *delay_on = *delay_off = 500;
278
279 led_set_software_blink(led_cdev, *delay_on, *delay_off);
280}
281EXPORT_SYMBOL(led_blink_set);
282
283void led_brightness_set(struct led_classdev *led_cdev,
284 enum led_brightness brightness)
285{
286 led_stop_software_blink(led_cdev);
287 led_cdev->brightness_set(led_cdev, brightness);
288}
289EXPORT_SYMBOL(led_brightness_set);
290
291static int __init leds_init(void) 221static int __init leds_init(void)
292{ 222{
293 leds_class = class_create(THIS_MODULE, "leds"); 223 leds_class = class_create(THIS_MODULE, "leds");
diff --git a/drivers/leds/led-core.c b/drivers/leds/led-core.c
index 016d19f5486f..d6860043f6f9 100644
--- a/drivers/leds/led-core.c
+++ b/drivers/leds/led-core.c
@@ -23,3 +23,73 @@ EXPORT_SYMBOL_GPL(leds_list_lock);
23 23
24LIST_HEAD(leds_list); 24LIST_HEAD(leds_list);
25EXPORT_SYMBOL_GPL(leds_list); 25EXPORT_SYMBOL_GPL(leds_list);
26
27static void led_stop_software_blink(struct led_classdev *led_cdev)
28{
29 /* deactivate previous settings */
30 del_timer_sync(&led_cdev->blink_timer);
31 led_cdev->blink_delay_on = 0;
32 led_cdev->blink_delay_off = 0;
33}
34
35static void led_set_software_blink(struct led_classdev *led_cdev,
36 unsigned long delay_on,
37 unsigned long delay_off)
38{
39 int current_brightness;
40
41 current_brightness = led_get_brightness(led_cdev);
42 if (current_brightness)
43 led_cdev->blink_brightness = current_brightness;
44 if (!led_cdev->blink_brightness)
45 led_cdev->blink_brightness = led_cdev->max_brightness;
46
47 if (led_get_trigger_data(led_cdev) &&
48 delay_on == led_cdev->blink_delay_on &&
49 delay_off == led_cdev->blink_delay_off)
50 return;
51
52 led_stop_software_blink(led_cdev);
53
54 led_cdev->blink_delay_on = delay_on;
55 led_cdev->blink_delay_off = delay_off;
56
57 /* never on - don't blink */
58 if (!delay_on)
59 return;
60
61 /* never off - just set to brightness */
62 if (!delay_off) {
63 led_set_brightness(led_cdev, led_cdev->blink_brightness);
64 return;
65 }
66
67 mod_timer(&led_cdev->blink_timer, jiffies + 1);
68}
69
70
71void led_blink_set(struct led_classdev *led_cdev,
72 unsigned long *delay_on,
73 unsigned long *delay_off)
74{
75 del_timer_sync(&led_cdev->blink_timer);
76
77 if (led_cdev->blink_set &&
78 !led_cdev->blink_set(led_cdev, delay_on, delay_off))
79 return;
80
81 /* blink with 1 Hz as default if nothing specified */
82 if (!*delay_on && !*delay_off)
83 *delay_on = *delay_off = 500;
84
85 led_set_software_blink(led_cdev, *delay_on, *delay_off);
86}
87EXPORT_SYMBOL(led_blink_set);
88
89void led_brightness_set(struct led_classdev *led_cdev,
90 enum led_brightness brightness)
91{
92 led_stop_software_blink(led_cdev);
93 led_cdev->brightness_set(led_cdev, brightness);
94}
95EXPORT_SYMBOL(led_brightness_set);
diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c
index 7df74cb97e70..f4c470a3bc8d 100644
--- a/drivers/leds/leds-gpio.c
+++ b/drivers/leds/leds-gpio.c
@@ -13,6 +13,7 @@
13#include <linux/kernel.h> 13#include <linux/kernel.h>
14#include <linux/init.h> 14#include <linux/init.h>
15#include <linux/platform_device.h> 15#include <linux/platform_device.h>
16#include <linux/gpio.h>
16#include <linux/leds.h> 17#include <linux/leds.h>
17#include <linux/of_platform.h> 18#include <linux/of_platform.h>
18#include <linux/of_gpio.h> 19#include <linux/of_gpio.h>
@@ -20,8 +21,6 @@
20#include <linux/workqueue.h> 21#include <linux/workqueue.h>
21#include <linux/module.h> 22#include <linux/module.h>
22 23
23#include <asm/gpio.h>
24
25struct gpio_led_data { 24struct gpio_led_data {
26 struct led_classdev cdev; 25 struct led_classdev cdev;
27 unsigned gpio; 26 unsigned gpio;
diff --git a/drivers/leds/leds-lm3530.c b/drivers/leds/leds-lm3530.c
index e59c166a0ce2..968fd5fef4fc 100644
--- a/drivers/leds/leds-lm3530.c
+++ b/drivers/leds/leds-lm3530.c
@@ -26,7 +26,6 @@
26#define LM3530_GEN_CONFIG 0x10 26#define LM3530_GEN_CONFIG 0x10
27#define LM3530_ALS_CONFIG 0x20 27#define LM3530_ALS_CONFIG 0x20
28#define LM3530_BRT_RAMP_RATE 0x30 28#define LM3530_BRT_RAMP_RATE 0x30
29#define LM3530_ALS_ZONE_REG 0x40
30#define LM3530_ALS_IMP_SELECT 0x41 29#define LM3530_ALS_IMP_SELECT 0x41
31#define LM3530_BRT_CTRL_REG 0xA0 30#define LM3530_BRT_CTRL_REG 0xA0
32#define LM3530_ALS_ZB0_REG 0x60 31#define LM3530_ALS_ZB0_REG 0x60
@@ -38,7 +37,7 @@
38#define LM3530_ALS_Z2T_REG 0x72 37#define LM3530_ALS_Z2T_REG 0x72
39#define LM3530_ALS_Z3T_REG 0x73 38#define LM3530_ALS_Z3T_REG 0x73
40#define LM3530_ALS_Z4T_REG 0x74 39#define LM3530_ALS_Z4T_REG 0x74
41#define LM3530_REG_MAX 15 40#define LM3530_REG_MAX 14
42 41
43/* General Control Register */ 42/* General Control Register */
44#define LM3530_EN_I2C_SHIFT (0) 43#define LM3530_EN_I2C_SHIFT (0)
@@ -80,6 +79,9 @@
80#define LM3530_DEF_ZT_3 (0x33) 79#define LM3530_DEF_ZT_3 (0x33)
81#define LM3530_DEF_ZT_4 (0x19) 80#define LM3530_DEF_ZT_4 (0x19)
82 81
82/* 7 bits are used for the brightness : LM3530_BRT_CTRL_REG */
83#define MAX_BRIGHTNESS (127)
84
83struct lm3530_mode_map { 85struct lm3530_mode_map {
84 const char *mode; 86 const char *mode;
85 enum lm3530_mode mode_val; 87 enum lm3530_mode mode_val;
@@ -115,7 +117,6 @@ static const u8 lm3530_reg[LM3530_REG_MAX] = {
115 LM3530_GEN_CONFIG, 117 LM3530_GEN_CONFIG,
116 LM3530_ALS_CONFIG, 118 LM3530_ALS_CONFIG,
117 LM3530_BRT_RAMP_RATE, 119 LM3530_BRT_RAMP_RATE,
118 LM3530_ALS_ZONE_REG,
119 LM3530_ALS_IMP_SELECT, 120 LM3530_ALS_IMP_SELECT,
120 LM3530_BRT_CTRL_REG, 121 LM3530_BRT_CTRL_REG,
121 LM3530_ALS_ZB0_REG, 122 LM3530_ALS_ZB0_REG,
@@ -152,27 +153,35 @@ static int lm3530_init_registers(struct lm3530_data *drvdata)
152 u8 reg_val[LM3530_REG_MAX]; 153 u8 reg_val[LM3530_REG_MAX];
153 u8 zones[LM3530_ALS_ZB_MAX]; 154 u8 zones[LM3530_ALS_ZB_MAX];
154 u32 als_vmin, als_vmax, als_vstep; 155 u32 als_vmin, als_vmax, als_vstep;
155 struct lm3530_platform_data *pltfm = drvdata->pdata; 156 struct lm3530_platform_data *pdata = drvdata->pdata;
156 struct i2c_client *client = drvdata->client; 157 struct i2c_client *client = drvdata->client;
158 struct lm3530_pwm_data *pwm = &pdata->pwm_data;
157 159
158 gen_config = (pltfm->brt_ramp_law << LM3530_RAMP_LAW_SHIFT) | 160 gen_config = (pdata->brt_ramp_law << LM3530_RAMP_LAW_SHIFT) |
159 ((pltfm->max_current & 7) << LM3530_MAX_CURR_SHIFT); 161 ((pdata->max_current & 7) << LM3530_MAX_CURR_SHIFT);
160 162
161 if (drvdata->mode == LM3530_BL_MODE_MANUAL || 163 switch (drvdata->mode) {
162 drvdata->mode == LM3530_BL_MODE_ALS) 164 case LM3530_BL_MODE_MANUAL:
163 gen_config |= (LM3530_ENABLE_I2C); 165 case LM3530_BL_MODE_ALS:
166 gen_config |= LM3530_ENABLE_I2C;
167 break;
168 case LM3530_BL_MODE_PWM:
169 gen_config |= LM3530_ENABLE_PWM | LM3530_ENABLE_PWM_SIMPLE |
170 (pdata->pwm_pol_hi << LM3530_PWM_POL_SHIFT);
171 break;
172 }
164 173
165 if (drvdata->mode == LM3530_BL_MODE_ALS) { 174 if (drvdata->mode == LM3530_BL_MODE_ALS) {
166 if (pltfm->als_vmax == 0) { 175 if (pdata->als_vmax == 0) {
167 pltfm->als_vmin = 0; 176 pdata->als_vmin = 0;
168 pltfm->als_vmax = LM3530_ALS_WINDOW_mV; 177 pdata->als_vmax = LM3530_ALS_WINDOW_mV;
169 } 178 }
170 179
171 als_vmin = pltfm->als_vmin; 180 als_vmin = pdata->als_vmin;
172 als_vmax = pltfm->als_vmax; 181 als_vmax = pdata->als_vmax;
173 182
174 if ((als_vmax - als_vmin) > LM3530_ALS_WINDOW_mV) 183 if ((als_vmax - als_vmin) > LM3530_ALS_WINDOW_mV)
175 pltfm->als_vmax = als_vmax = 184 pdata->als_vmax = als_vmax =
176 als_vmin + LM3530_ALS_WINDOW_mV; 185 als_vmin + LM3530_ALS_WINDOW_mV;
177 186
178 /* n zone boundary makes n+1 zones */ 187 /* n zone boundary makes n+1 zones */
@@ -184,44 +193,41 @@ static int lm3530_init_registers(struct lm3530_data *drvdata)
184 / 1000; 193 / 1000;
185 194
186 als_config = 195 als_config =
187 (pltfm->als_avrg_time << LM3530_ALS_AVG_TIME_SHIFT) | 196 (pdata->als_avrg_time << LM3530_ALS_AVG_TIME_SHIFT) |
188 (LM3530_ENABLE_ALS) | 197 (LM3530_ENABLE_ALS) |
189 (pltfm->als_input_mode << LM3530_ALS_SEL_SHIFT); 198 (pdata->als_input_mode << LM3530_ALS_SEL_SHIFT);
190 199
191 als_imp_sel = 200 als_imp_sel =
192 (pltfm->als1_resistor_sel << LM3530_ALS1_IMP_SHIFT) | 201 (pdata->als1_resistor_sel << LM3530_ALS1_IMP_SHIFT) |
193 (pltfm->als2_resistor_sel << LM3530_ALS2_IMP_SHIFT); 202 (pdata->als2_resistor_sel << LM3530_ALS2_IMP_SHIFT);
194 203
195 } 204 }
196 205
197 if (drvdata->mode == LM3530_BL_MODE_PWM) 206 brt_ramp = (pdata->brt_ramp_fall << LM3530_BRT_RAMP_FALL_SHIFT) |
198 gen_config |= (LM3530_ENABLE_PWM) | 207 (pdata->brt_ramp_rise << LM3530_BRT_RAMP_RISE_SHIFT);
199 (pltfm->pwm_pol_hi << LM3530_PWM_POL_SHIFT) |
200 (LM3530_ENABLE_PWM_SIMPLE);
201
202 brt_ramp = (pltfm->brt_ramp_fall << LM3530_BRT_RAMP_FALL_SHIFT) |
203 (pltfm->brt_ramp_rise << LM3530_BRT_RAMP_RISE_SHIFT);
204 208
205 if (drvdata->brightness) 209 if (drvdata->brightness)
206 brightness = drvdata->brightness; 210 brightness = drvdata->brightness;
207 else 211 else
208 brightness = drvdata->brightness = pltfm->brt_val; 212 brightness = drvdata->brightness = pdata->brt_val;
213
214 if (brightness > drvdata->led_dev.max_brightness)
215 brightness = drvdata->led_dev.max_brightness;
209 216
210 reg_val[0] = gen_config; /* LM3530_GEN_CONFIG */ 217 reg_val[0] = gen_config; /* LM3530_GEN_CONFIG */
211 reg_val[1] = als_config; /* LM3530_ALS_CONFIG */ 218 reg_val[1] = als_config; /* LM3530_ALS_CONFIG */
212 reg_val[2] = brt_ramp; /* LM3530_BRT_RAMP_RATE */ 219 reg_val[2] = brt_ramp; /* LM3530_BRT_RAMP_RATE */
213 reg_val[3] = 0x00; /* LM3530_ALS_ZONE_REG */ 220 reg_val[3] = als_imp_sel; /* LM3530_ALS_IMP_SELECT */
214 reg_val[4] = als_imp_sel; /* LM3530_ALS_IMP_SELECT */ 221 reg_val[4] = brightness; /* LM3530_BRT_CTRL_REG */
215 reg_val[5] = brightness; /* LM3530_BRT_CTRL_REG */ 222 reg_val[5] = zones[0]; /* LM3530_ALS_ZB0_REG */
216 reg_val[6] = zones[0]; /* LM3530_ALS_ZB0_REG */ 223 reg_val[6] = zones[1]; /* LM3530_ALS_ZB1_REG */
217 reg_val[7] = zones[1]; /* LM3530_ALS_ZB1_REG */ 224 reg_val[7] = zones[2]; /* LM3530_ALS_ZB2_REG */
218 reg_val[8] = zones[2]; /* LM3530_ALS_ZB2_REG */ 225 reg_val[8] = zones[3]; /* LM3530_ALS_ZB3_REG */
219 reg_val[9] = zones[3]; /* LM3530_ALS_ZB3_REG */ 226 reg_val[9] = LM3530_DEF_ZT_0; /* LM3530_ALS_Z0T_REG */
220 reg_val[10] = LM3530_DEF_ZT_0; /* LM3530_ALS_Z0T_REG */ 227 reg_val[10] = LM3530_DEF_ZT_1; /* LM3530_ALS_Z1T_REG */
221 reg_val[11] = LM3530_DEF_ZT_1; /* LM3530_ALS_Z1T_REG */ 228 reg_val[11] = LM3530_DEF_ZT_2; /* LM3530_ALS_Z2T_REG */
222 reg_val[12] = LM3530_DEF_ZT_2; /* LM3530_ALS_Z2T_REG */ 229 reg_val[12] = LM3530_DEF_ZT_3; /* LM3530_ALS_Z3T_REG */
223 reg_val[13] = LM3530_DEF_ZT_3; /* LM3530_ALS_Z3T_REG */ 230 reg_val[13] = LM3530_DEF_ZT_4; /* LM3530_ALS_Z4T_REG */
224 reg_val[14] = LM3530_DEF_ZT_4; /* LM3530_ALS_Z4T_REG */
225 231
226 if (!drvdata->enable) { 232 if (!drvdata->enable) {
227 ret = regulator_enable(drvdata->regulator); 233 ret = regulator_enable(drvdata->regulator);
@@ -234,6 +240,15 @@ static int lm3530_init_registers(struct lm3530_data *drvdata)
234 } 240 }
235 241
236 for (i = 0; i < LM3530_REG_MAX; i++) { 242 for (i = 0; i < LM3530_REG_MAX; i++) {
243 /* do not update brightness register when pwm mode */
244 if (lm3530_reg[i] == LM3530_BRT_CTRL_REG &&
245 drvdata->mode == LM3530_BL_MODE_PWM) {
246 if (pwm->pwm_set_intensity)
247 pwm->pwm_set_intensity(reg_val[i],
248 drvdata->led_dev.max_brightness);
249 continue;
250 }
251
237 ret = i2c_smbus_write_byte_data(client, 252 ret = i2c_smbus_write_byte_data(client,
238 lm3530_reg[i], reg_val[i]); 253 lm3530_reg[i], reg_val[i]);
239 if (ret) 254 if (ret)
@@ -249,6 +264,9 @@ static void lm3530_brightness_set(struct led_classdev *led_cdev,
249 int err; 264 int err;
250 struct lm3530_data *drvdata = 265 struct lm3530_data *drvdata =
251 container_of(led_cdev, struct lm3530_data, led_dev); 266 container_of(led_cdev, struct lm3530_data, led_dev);
267 struct lm3530_platform_data *pdata = drvdata->pdata;
268 struct lm3530_pwm_data *pwm = &pdata->pwm_data;
269 u8 max_brightness = led_cdev->max_brightness;
252 270
253 switch (drvdata->mode) { 271 switch (drvdata->mode) {
254 case LM3530_BL_MODE_MANUAL: 272 case LM3530_BL_MODE_MANUAL:
@@ -264,12 +282,12 @@ static void lm3530_brightness_set(struct led_classdev *led_cdev,
264 282
265 /* set the brightness in brightness control register*/ 283 /* set the brightness in brightness control register*/
266 err = i2c_smbus_write_byte_data(drvdata->client, 284 err = i2c_smbus_write_byte_data(drvdata->client,
267 LM3530_BRT_CTRL_REG, brt_val / 2); 285 LM3530_BRT_CTRL_REG, brt_val);
268 if (err) 286 if (err)
269 dev_err(&drvdata->client->dev, 287 dev_err(&drvdata->client->dev,
270 "Unable to set brightness: %d\n", err); 288 "Unable to set brightness: %d\n", err);
271 else 289 else
272 drvdata->brightness = brt_val / 2; 290 drvdata->brightness = brt_val;
273 291
274 if (brt_val == 0) { 292 if (brt_val == 0) {
275 err = regulator_disable(drvdata->regulator); 293 err = regulator_disable(drvdata->regulator);
@@ -282,6 +300,8 @@ static void lm3530_brightness_set(struct led_classdev *led_cdev,
282 case LM3530_BL_MODE_ALS: 300 case LM3530_BL_MODE_ALS:
283 break; 301 break;
284 case LM3530_BL_MODE_PWM: 302 case LM3530_BL_MODE_PWM:
303 if (pwm->pwm_set_intensity)
304 pwm->pwm_set_intensity(brt_val, max_brightness);
285 break; 305 break;
286 default: 306 default:
287 break; 307 break;
@@ -291,11 +311,11 @@ static void lm3530_brightness_set(struct led_classdev *led_cdev,
291static ssize_t lm3530_mode_get(struct device *dev, 311static ssize_t lm3530_mode_get(struct device *dev,
292 struct device_attribute *attr, char *buf) 312 struct device_attribute *attr, char *buf)
293{ 313{
294 struct i2c_client *client = container_of( 314 struct led_classdev *led_cdev = dev_get_drvdata(dev);
295 dev->parent, struct i2c_client, dev); 315 struct lm3530_data *drvdata;
296 struct lm3530_data *drvdata = i2c_get_clientdata(client);
297 int i, len = 0; 316 int i, len = 0;
298 317
318 drvdata = container_of(led_cdev, struct lm3530_data, led_dev);
299 for (i = 0; i < ARRAY_SIZE(mode_map); i++) 319 for (i = 0; i < ARRAY_SIZE(mode_map); i++)
300 if (drvdata->mode == mode_map[i].mode_val) 320 if (drvdata->mode == mode_map[i].mode_val)
301 len += sprintf(buf + len, "[%s] ", mode_map[i].mode); 321 len += sprintf(buf + len, "[%s] ", mode_map[i].mode);
@@ -310,26 +330,26 @@ static ssize_t lm3530_mode_get(struct device *dev,
310static ssize_t lm3530_mode_set(struct device *dev, struct device_attribute 330static ssize_t lm3530_mode_set(struct device *dev, struct device_attribute
311 *attr, const char *buf, size_t size) 331 *attr, const char *buf, size_t size)
312{ 332{
313 int err; 333 struct led_classdev *led_cdev = dev_get_drvdata(dev);
314 struct i2c_client *client = container_of( 334 struct lm3530_data *drvdata;
315 dev->parent, struct i2c_client, dev); 335 struct lm3530_pwm_data *pwm;
316 struct lm3530_data *drvdata = i2c_get_clientdata(client); 336 u8 max_brightness;
317 int mode; 337 int mode, err;
318 338
339 drvdata = container_of(led_cdev, struct lm3530_data, led_dev);
340 pwm = &drvdata->pdata->pwm_data;
341 max_brightness = led_cdev->max_brightness;
319 mode = lm3530_get_mode_from_str(buf); 342 mode = lm3530_get_mode_from_str(buf);
320 if (mode < 0) { 343 if (mode < 0) {
321 dev_err(dev, "Invalid mode\n"); 344 dev_err(dev, "Invalid mode\n");
322 return -EINVAL; 345 return -EINVAL;
323 } 346 }
324 347
325 if (mode == LM3530_BL_MODE_MANUAL) 348 drvdata->mode = mode;
326 drvdata->mode = LM3530_BL_MODE_MANUAL; 349
327 else if (mode == LM3530_BL_MODE_ALS) 350 /* set pwm to low if unnecessary */
328 drvdata->mode = LM3530_BL_MODE_ALS; 351 if (mode != LM3530_BL_MODE_PWM && pwm->pwm_set_intensity)
329 else if (mode == LM3530_BL_MODE_PWM) { 352 pwm->pwm_set_intensity(0, max_brightness);
330 dev_err(dev, "PWM mode not supported\n");
331 return -EINVAL;
332 }
333 353
334 err = lm3530_init_registers(drvdata); 354 err = lm3530_init_registers(drvdata);
335 if (err) { 355 if (err) {
@@ -380,6 +400,7 @@ static int __devinit lm3530_probe(struct i2c_client *client,
380 drvdata->enable = false; 400 drvdata->enable = false;
381 drvdata->led_dev.name = LM3530_LED_DEV; 401 drvdata->led_dev.name = LM3530_LED_DEV;
382 drvdata->led_dev.brightness_set = lm3530_brightness_set; 402 drvdata->led_dev.brightness_set = lm3530_brightness_set;
403 drvdata->led_dev.max_brightness = MAX_BRIGHTNESS;
383 404
384 i2c_set_clientdata(client, drvdata); 405 i2c_set_clientdata(client, drvdata);
385 406
diff --git a/drivers/leds/leds-lp5521.c b/drivers/leds/leds-lp5521.c
index d62a7982a5e6..410a723b8691 100644
--- a/drivers/leds/leds-lp5521.c
+++ b/drivers/leds/leds-lp5521.c
@@ -81,18 +81,10 @@
81#define LP5521_MASTER_ENABLE 0x40 /* Chip master enable */ 81#define LP5521_MASTER_ENABLE 0x40 /* Chip master enable */
82#define LP5521_LOGARITHMIC_PWM 0x80 /* Logarithmic PWM adjustment */ 82#define LP5521_LOGARITHMIC_PWM 0x80 /* Logarithmic PWM adjustment */
83#define LP5521_EXEC_RUN 0x2A 83#define LP5521_EXEC_RUN 0x2A
84 84#define LP5521_ENABLE_DEFAULT \
85/* Bits in CONFIG register */ 85 (LP5521_MASTER_ENABLE | LP5521_LOGARITHMIC_PWM)
86#define LP5521_PWM_HF 0x40 /* PWM: 0 = 256Hz, 1 = 558Hz */ 86#define LP5521_ENABLE_RUN_PROGRAM \
87#define LP5521_PWRSAVE_EN 0x20 /* 1 = Power save mode */ 87 (LP5521_ENABLE_DEFAULT | LP5521_EXEC_RUN)
88#define LP5521_CP_MODE_OFF 0 /* Charge pump (CP) off */
89#define LP5521_CP_MODE_BYPASS 8 /* CP forced to bypass mode */
90#define LP5521_CP_MODE_1X5 0x10 /* CP forced to 1.5x mode */
91#define LP5521_CP_MODE_AUTO 0x18 /* Automatic mode selection */
92#define LP5521_R_TO_BATT 4 /* R out: 0 = CP, 1 = Vbat */
93#define LP5521_CLK_SRC_EXT 0 /* Ext-clk source (CLK_32K) */
94#define LP5521_CLK_INT 1 /* Internal clock */
95#define LP5521_CLK_AUTO 2 /* Automatic clock selection */
96 88
97/* Status */ 89/* Status */
98#define LP5521_EXT_CLK_USED 0x08 90#define LP5521_EXT_CLK_USED 0x08
@@ -100,6 +92,9 @@
100/* default R channel current register value */ 92/* default R channel current register value */
101#define LP5521_REG_R_CURR_DEFAULT 0xAF 93#define LP5521_REG_R_CURR_DEFAULT 0xAF
102 94
95/* Pattern Mode */
96#define PATTERN_OFF 0
97
103struct lp5521_engine { 98struct lp5521_engine {
104 int id; 99 int id;
105 u8 mode; 100 u8 mode;
@@ -241,15 +236,16 @@ static int lp5521_configure(struct i2c_client *client)
241{ 236{
242 struct lp5521_chip *chip = i2c_get_clientdata(client); 237 struct lp5521_chip *chip = i2c_get_clientdata(client);
243 int ret; 238 int ret;
239 u8 cfg;
244 240
245 lp5521_init_engine(chip); 241 lp5521_init_engine(chip);
246 242
247 /* Set all PWMs to direct control mode */ 243 /* Set all PWMs to direct control mode */
248 ret = lp5521_write(client, LP5521_REG_OP_MODE, 0x3F); 244 ret = lp5521_write(client, LP5521_REG_OP_MODE, LP5521_CMD_DIRECT);
249 245
250 /* Enable auto-powersave, set charge pump to auto, red to battery */ 246 cfg = chip->pdata->update_config ?
251 ret |= lp5521_write(client, LP5521_REG_CONFIG, 247 : (LP5521_PWRSAVE_EN | LP5521_CP_MODE_AUTO | LP5521_R_TO_BATT);
252 LP5521_PWRSAVE_EN | LP5521_CP_MODE_AUTO | LP5521_R_TO_BATT); 248 ret |= lp5521_write(client, LP5521_REG_CONFIG, cfg);
253 249
254 /* Initialize all channels PWM to zero -> leds off */ 250 /* Initialize all channels PWM to zero -> leds off */
255 ret |= lp5521_write(client, LP5521_REG_R_PWM, 0); 251 ret |= lp5521_write(client, LP5521_REG_R_PWM, 0);
@@ -258,8 +254,7 @@ static int lp5521_configure(struct i2c_client *client)
258 254
259 /* Set engines are set to run state when OP_MODE enables engines */ 255 /* Set engines are set to run state when OP_MODE enables engines */
260 ret |= lp5521_write(client, LP5521_REG_ENABLE, 256 ret |= lp5521_write(client, LP5521_REG_ENABLE,
261 LP5521_MASTER_ENABLE | LP5521_LOGARITHMIC_PWM | 257 LP5521_ENABLE_RUN_PROGRAM);
262 LP5521_EXEC_RUN);
263 /* enable takes 500us. 1 - 2 ms leaves some margin */ 258 /* enable takes 500us. 1 - 2 ms leaves some margin */
264 usleep_range(1000, 2000); 259 usleep_range(1000, 2000);
265 260
@@ -310,8 +305,7 @@ static int lp5521_detect(struct i2c_client *client)
310 int ret; 305 int ret;
311 u8 buf; 306 u8 buf;
312 307
313 ret = lp5521_write(client, LP5521_REG_ENABLE, 308 ret = lp5521_write(client, LP5521_REG_ENABLE, LP5521_ENABLE_DEFAULT);
314 LP5521_MASTER_ENABLE | LP5521_LOGARITHMIC_PWM);
315 if (ret) 309 if (ret)
316 return ret; 310 return ret;
317 /* enable takes 500us. 1 - 2 ms leaves some margin */ 311 /* enable takes 500us. 1 - 2 ms leaves some margin */
@@ -319,7 +313,7 @@ static int lp5521_detect(struct i2c_client *client)
319 ret = lp5521_read(client, LP5521_REG_ENABLE, &buf); 313 ret = lp5521_read(client, LP5521_REG_ENABLE, &buf);
320 if (ret) 314 if (ret)
321 return ret; 315 return ret;
322 if (buf != (LP5521_MASTER_ENABLE | LP5521_LOGARITHMIC_PWM)) 316 if (buf != LP5521_ENABLE_DEFAULT)
323 return -ENODEV; 317 return -ENODEV;
324 318
325 return 0; 319 return 0;
@@ -504,7 +498,7 @@ static ssize_t store_current(struct device *dev,
504 ssize_t ret; 498 ssize_t ret;
505 unsigned long curr; 499 unsigned long curr;
506 500
507 if (strict_strtoul(buf, 0, &curr)) 501 if (kstrtoul(buf, 0, &curr))
508 return -EINVAL; 502 return -EINVAL;
509 503
510 if (curr > led->max_current) 504 if (curr > led->max_current)
@@ -536,6 +530,97 @@ static ssize_t lp5521_selftest(struct device *dev,
536 return sprintf(buf, "%s\n", ret ? "FAIL" : "OK"); 530 return sprintf(buf, "%s\n", ret ? "FAIL" : "OK");
537} 531}
538 532
533static void lp5521_clear_program_memory(struct i2c_client *cl)
534{
535 int i;
536 u8 rgb_mem[] = {
537 LP5521_REG_R_PROG_MEM,
538 LP5521_REG_G_PROG_MEM,
539 LP5521_REG_B_PROG_MEM,
540 };
541
542 for (i = 0; i < ARRAY_SIZE(rgb_mem); i++) {
543 lp5521_write(cl, rgb_mem[i], 0);
544 lp5521_write(cl, rgb_mem[i] + 1, 0);
545 }
546}
547
548static void lp5521_write_program_memory(struct i2c_client *cl,
549 u8 base, u8 *rgb, int size)
550{
551 int i;
552
553 if (!rgb || size <= 0)
554 return;
555
556 for (i = 0; i < size; i++)
557 lp5521_write(cl, base + i, *(rgb + i));
558
559 lp5521_write(cl, base + i, 0);
560 lp5521_write(cl, base + i + 1, 0);
561}
562
563static inline struct lp5521_led_pattern *lp5521_get_pattern
564 (struct lp5521_chip *chip, u8 offset)
565{
566 struct lp5521_led_pattern *ptn;
567 ptn = chip->pdata->patterns + (offset - 1);
568 return ptn;
569}
570
571static void lp5521_run_led_pattern(int mode, struct lp5521_chip *chip)
572{
573 struct lp5521_led_pattern *ptn;
574 struct i2c_client *cl = chip->client;
575 int num_patterns = chip->pdata->num_patterns;
576
577 if (mode > num_patterns || !(chip->pdata->patterns))
578 return;
579
580 if (mode == PATTERN_OFF) {
581 lp5521_write(cl, LP5521_REG_ENABLE, LP5521_ENABLE_DEFAULT);
582 usleep_range(1000, 2000);
583 lp5521_write(cl, LP5521_REG_OP_MODE, LP5521_CMD_DIRECT);
584 } else {
585 ptn = lp5521_get_pattern(chip, mode);
586 if (!ptn)
587 return;
588
589 lp5521_write(cl, LP5521_REG_OP_MODE, LP5521_CMD_LOAD);
590 usleep_range(1000, 2000);
591
592 lp5521_clear_program_memory(cl);
593
594 lp5521_write_program_memory(cl, LP5521_REG_R_PROG_MEM,
595 ptn->r, ptn->size_r);
596 lp5521_write_program_memory(cl, LP5521_REG_G_PROG_MEM,
597 ptn->g, ptn->size_g);
598 lp5521_write_program_memory(cl, LP5521_REG_B_PROG_MEM,
599 ptn->b, ptn->size_b);
600
601 lp5521_write(cl, LP5521_REG_OP_MODE, LP5521_CMD_RUN);
602 usleep_range(1000, 2000);
603 lp5521_write(cl, LP5521_REG_ENABLE, LP5521_ENABLE_RUN_PROGRAM);
604 }
605}
606
607static ssize_t store_led_pattern(struct device *dev,
608 struct device_attribute *attr,
609 const char *buf, size_t len)
610{
611 struct lp5521_chip *chip = i2c_get_clientdata(to_i2c_client(dev));
612 unsigned long val;
613 int ret;
614
615 ret = strict_strtoul(buf, 16, &val);
616 if (ret)
617 return ret;
618
619 lp5521_run_led_pattern(val, chip);
620
621 return len;
622}
623
539/* led class device attributes */ 624/* led class device attributes */
540static DEVICE_ATTR(led_current, S_IRUGO | S_IWUSR, show_current, store_current); 625static DEVICE_ATTR(led_current, S_IRUGO | S_IWUSR, show_current, store_current);
541static DEVICE_ATTR(max_current, S_IRUGO , show_max_current, NULL); 626static DEVICE_ATTR(max_current, S_IRUGO , show_max_current, NULL);
@@ -561,6 +646,7 @@ static DEVICE_ATTR(engine1_load, S_IWUSR, NULL, store_engine1_load);
561static DEVICE_ATTR(engine2_load, S_IWUSR, NULL, store_engine2_load); 646static DEVICE_ATTR(engine2_load, S_IWUSR, NULL, store_engine2_load);
562static DEVICE_ATTR(engine3_load, S_IWUSR, NULL, store_engine3_load); 647static DEVICE_ATTR(engine3_load, S_IWUSR, NULL, store_engine3_load);
563static DEVICE_ATTR(selftest, S_IRUGO, lp5521_selftest, NULL); 648static DEVICE_ATTR(selftest, S_IRUGO, lp5521_selftest, NULL);
649static DEVICE_ATTR(led_pattern, S_IWUSR, NULL, store_led_pattern);
564 650
565static struct attribute *lp5521_attributes[] = { 651static struct attribute *lp5521_attributes[] = {
566 &dev_attr_engine1_mode.attr, 652 &dev_attr_engine1_mode.attr,
@@ -570,6 +656,7 @@ static struct attribute *lp5521_attributes[] = {
570 &dev_attr_engine1_load.attr, 656 &dev_attr_engine1_load.attr,
571 &dev_attr_engine2_load.attr, 657 &dev_attr_engine2_load.attr,
572 &dev_attr_engine3_load.attr, 658 &dev_attr_engine3_load.attr,
659 &dev_attr_led_pattern.attr,
573 NULL 660 NULL
574}; 661};
575 662
@@ -620,10 +707,15 @@ static int __devinit lp5521_init_led(struct lp5521_led *led,
620 return -EINVAL; 707 return -EINVAL;
621 } 708 }
622 709
623 snprintf(name, sizeof(name), "%s:channel%d",
624 pdata->label ?: client->name, chan);
625 led->cdev.brightness_set = lp5521_set_brightness; 710 led->cdev.brightness_set = lp5521_set_brightness;
626 led->cdev.name = name; 711 if (pdata->led_config[chan].name) {
712 led->cdev.name = pdata->led_config[chan].name;
713 } else {
714 snprintf(name, sizeof(name), "%s:channel%d",
715 pdata->label ?: client->name, chan);
716 led->cdev.name = name;
717 }
718
627 res = led_classdev_register(dev, &led->cdev); 719 res = led_classdev_register(dev, &led->cdev);
628 if (res < 0) { 720 if (res < 0) {
629 dev_err(dev, "couldn't register led on channel %d\n", chan); 721 dev_err(dev, "couldn't register led on channel %d\n", chan);
@@ -692,9 +784,9 @@ static int __devinit lp5521_probe(struct i2c_client *client,
692 * otherwise further access to the R G B channels in the 784 * otherwise further access to the R G B channels in the
693 * LP5521_REG_ENABLE register will not have any effect - strange! 785 * LP5521_REG_ENABLE register will not have any effect - strange!
694 */ 786 */
695 lp5521_read(client, LP5521_REG_R_CURRENT, &buf); 787 ret = lp5521_read(client, LP5521_REG_R_CURRENT, &buf);
696 if (buf != LP5521_REG_R_CURR_DEFAULT) { 788 if (buf != LP5521_REG_R_CURR_DEFAULT) {
697 dev_err(&client->dev, "error in reseting chip\n"); 789 dev_err(&client->dev, "error in resetting chip\n");
698 goto fail2; 790 goto fail2;
699 } 791 }
700 usleep_range(10000, 20000); 792 usleep_range(10000, 20000);
@@ -767,6 +859,7 @@ static int __devexit lp5521_remove(struct i2c_client *client)
767 struct lp5521_chip *chip = i2c_get_clientdata(client); 859 struct lp5521_chip *chip = i2c_get_clientdata(client);
768 int i; 860 int i;
769 861
862 lp5521_run_led_pattern(PATTERN_OFF, chip);
770 lp5521_unregister_sysfs(client); 863 lp5521_unregister_sysfs(client);
771 864
772 for (i = 0; i < chip->num_leds; i++) { 865 for (i = 0; i < chip->num_leds; i++) {
diff --git a/drivers/leds/leds-lp5523.c b/drivers/leds/leds-lp5523.c
index 73e791ae7259..857a3e15f2dd 100644
--- a/drivers/leds/leds-lp5523.c
+++ b/drivers/leds/leds-lp5523.c
@@ -152,7 +152,7 @@ static inline struct lp5523_chip *led_to_lp5523(struct lp5523_led *led)
152 152
153static int lp5523_set_mode(struct lp5523_engine *engine, u8 mode); 153static int lp5523_set_mode(struct lp5523_engine *engine, u8 mode);
154static int lp5523_set_engine_mode(struct lp5523_engine *engine, u8 mode); 154static int lp5523_set_engine_mode(struct lp5523_engine *engine, u8 mode);
155static int lp5523_load_program(struct lp5523_engine *engine, u8 *pattern); 155static int lp5523_load_program(struct lp5523_engine *engine, const u8 *pattern);
156 156
157static void lp5523_led_brightness_work(struct work_struct *work); 157static void lp5523_led_brightness_work(struct work_struct *work);
158 158
@@ -196,7 +196,7 @@ static int lp5523_configure(struct i2c_client *client)
196 u8 status; 196 u8 status;
197 197
198 /* one pattern per engine setting led mux start and stop addresses */ 198 /* one pattern per engine setting led mux start and stop addresses */
199 u8 pattern[][LP5523_PROGRAM_LENGTH] = { 199 static const u8 pattern[][LP5523_PROGRAM_LENGTH] = {
200 { 0x9c, 0x30, 0x9c, 0xb0, 0x9d, 0x80, 0xd8, 0x00, 0}, 200 { 0x9c, 0x30, 0x9c, 0xb0, 0x9d, 0x80, 0xd8, 0x00, 0},
201 { 0x9c, 0x40, 0x9c, 0xc0, 0x9d, 0x80, 0xd8, 0x00, 0}, 201 { 0x9c, 0x40, 0x9c, 0xc0, 0x9d, 0x80, 0xd8, 0x00, 0},
202 { 0x9c, 0x50, 0x9c, 0xd0, 0x9d, 0x80, 0xd8, 0x00, 0}, 202 { 0x9c, 0x50, 0x9c, 0xd0, 0x9d, 0x80, 0xd8, 0x00, 0},
@@ -301,7 +301,7 @@ static int lp5523_load_mux(struct lp5523_engine *engine, u16 mux)
301 return ret; 301 return ret;
302} 302}
303 303
304static int lp5523_load_program(struct lp5523_engine *engine, u8 *pattern) 304static int lp5523_load_program(struct lp5523_engine *engine, const u8 *pattern)
305{ 305{
306 struct lp5523_chip *chip = engine_to_lp5523(engine); 306 struct lp5523_chip *chip = engine_to_lp5523(engine);
307 struct i2c_client *client = chip->client; 307 struct i2c_client *client = chip->client;
diff --git a/drivers/leds/leds-pca9633.c b/drivers/leds/leds-pca9633.c
new file mode 100644
index 000000000000..d8926fd031aa
--- /dev/null
+++ b/drivers/leds/leds-pca9633.c
@@ -0,0 +1,193 @@
1/*
2 * Copyright 2011 bct electronic GmbH
3 *
4 * Author: Peter Meerwald <p.meerwald@bct-electronic.com>
5 *
6 * Based on leds-pca955x.c
7 *
8 * This file is subject to the terms and conditions of version 2 of
9 * the GNU General Public License. See the file COPYING in the main
10 * directory of this archive for more details.
11 *
12 * LED driver for the PCA9633 I2C LED driver (7-bit slave address 0x62)
13 *
14 */
15
16#include <linux/module.h>
17#include <linux/delay.h>
18#include <linux/string.h>
19#include <linux/ctype.h>
20#include <linux/leds.h>
21#include <linux/err.h>
22#include <linux/i2c.h>
23#include <linux/workqueue.h>
24#include <linux/slab.h>
25
26/* LED select registers determine the source that drives LED outputs */
27#define PCA9633_LED_OFF 0x0 /* LED driver off */
28#define PCA9633_LED_ON 0x1 /* LED driver on */
29#define PCA9633_LED_PWM 0x2 /* Controlled through PWM */
30#define PCA9633_LED_GRP_PWM 0x3 /* Controlled through PWM/GRPPWM */
31
32#define PCA9633_MODE1 0x00
33#define PCA9633_MODE2 0x01
34#define PCA9633_PWM_BASE 0x02
35#define PCA9633_LEDOUT 0x08
36
37static const struct i2c_device_id pca9633_id[] = {
38 { "pca9633", 0 },
39 { }
40};
41MODULE_DEVICE_TABLE(i2c, pca9633_id);
42
43struct pca9633_led {
44 struct i2c_client *client;
45 struct work_struct work;
46 enum led_brightness brightness;
47 struct led_classdev led_cdev;
48 int led_num; /* 0 .. 3 potentially */
49 char name[32];
50};
51
52static void pca9633_led_work(struct work_struct *work)
53{
54 struct pca9633_led *pca9633 = container_of(work,
55 struct pca9633_led, work);
56 u8 ledout = i2c_smbus_read_byte_data(pca9633->client, PCA9633_LEDOUT);
57 int shift = 2 * pca9633->led_num;
58 u8 mask = 0x3 << shift;
59
60 switch (pca9633->brightness) {
61 case LED_FULL:
62 i2c_smbus_write_byte_data(pca9633->client, PCA9633_LEDOUT,
63 (ledout & ~mask) | (PCA9633_LED_ON << shift));
64 break;
65 case LED_OFF:
66 i2c_smbus_write_byte_data(pca9633->client, PCA9633_LEDOUT,
67 ledout & ~mask);
68 break;
69 default:
70 i2c_smbus_write_byte_data(pca9633->client,
71 PCA9633_PWM_BASE + pca9633->led_num,
72 pca9633->brightness);
73 i2c_smbus_write_byte_data(pca9633->client, PCA9633_LEDOUT,
74 (ledout & ~mask) | (PCA9633_LED_PWM << shift));
75 break;
76 }
77}
78
79static void pca9633_led_set(struct led_classdev *led_cdev,
80 enum led_brightness value)
81{
82 struct pca9633_led *pca9633;
83
84 pca9633 = container_of(led_cdev, struct pca9633_led, led_cdev);
85
86 pca9633->brightness = value;
87
88 /*
89 * Must use workqueue for the actual I/O since I2C operations
90 * can sleep.
91 */
92 schedule_work(&pca9633->work);
93}
94
95static int __devinit pca9633_probe(struct i2c_client *client,
96 const struct i2c_device_id *id)
97{
98 struct pca9633_led *pca9633;
99 struct led_platform_data *pdata;
100 int i, err;
101
102 pdata = client->dev.platform_data;
103
104 if (pdata) {
105 if (pdata->num_leds <= 0 || pdata->num_leds > 4) {
106 dev_err(&client->dev, "board info must claim at most 4 LEDs");
107 return -EINVAL;
108 }
109 }
110
111 pca9633 = kcalloc(4, sizeof(*pca9633), GFP_KERNEL);
112 if (!pca9633)
113 return -ENOMEM;
114
115 i2c_set_clientdata(client, pca9633);
116
117 for (i = 0; i < 4; i++) {
118 pca9633[i].client = client;
119 pca9633[i].led_num = i;
120
121 /* Platform data can specify LED names and default triggers */
122 if (pdata && i < pdata->num_leds) {
123 if (pdata->leds[i].name)
124 snprintf(pca9633[i].name,
125 sizeof(pca9633[i].name), "pca9633:%s",
126 pdata->leds[i].name);
127 if (pdata->leds[i].default_trigger)
128 pca9633[i].led_cdev.default_trigger =
129 pdata->leds[i].default_trigger;
130 } else {
131 snprintf(pca9633[i].name, sizeof(pca9633[i].name),
132 "pca9633:%d", i);
133 }
134
135 pca9633[i].led_cdev.name = pca9633[i].name;
136 pca9633[i].led_cdev.brightness_set = pca9633_led_set;
137
138 INIT_WORK(&pca9633[i].work, pca9633_led_work);
139
140 err = led_classdev_register(&client->dev, &pca9633[i].led_cdev);
141 if (err < 0)
142 goto exit;
143 }
144
145 /* Disable LED all-call address and set normal mode */
146 i2c_smbus_write_byte_data(client, PCA9633_MODE1, 0x00);
147
148 /* Turn off LEDs */
149 i2c_smbus_write_byte_data(client, PCA9633_LEDOUT, 0x00);
150
151 return 0;
152
153exit:
154 while (i--) {
155 led_classdev_unregister(&pca9633[i].led_cdev);
156 cancel_work_sync(&pca9633[i].work);
157 }
158
159 kfree(pca9633);
160
161 return err;
162}
163
164static int __devexit pca9633_remove(struct i2c_client *client)
165{
166 struct pca9633_led *pca9633 = i2c_get_clientdata(client);
167 int i;
168
169 for (i = 0; i < 4; i++) {
170 led_classdev_unregister(&pca9633[i].led_cdev);
171 cancel_work_sync(&pca9633[i].work);
172 }
173
174 kfree(pca9633);
175
176 return 0;
177}
178
179static struct i2c_driver pca9633_driver = {
180 .driver = {
181 .name = "leds-pca9633",
182 .owner = THIS_MODULE,
183 },
184 .probe = pca9633_probe,
185 .remove = __devexit_p(pca9633_remove),
186 .id_table = pca9633_id,
187};
188
189module_i2c_driver(pca9633_driver);
190
191MODULE_AUTHOR("Peter Meerwald <p.meerwald@bct-electronic.com>");
192MODULE_DESCRIPTION("PCA9633 LED driver");
193MODULE_LICENSE("GPL v2");
diff --git a/drivers/leds/leds-tca6507.c b/drivers/leds/leds-tca6507.c
index 133f89fb7071..6c1c14f31635 100644
--- a/drivers/leds/leds-tca6507.c
+++ b/drivers/leds/leds-tca6507.c
@@ -687,10 +687,9 @@ static int __devinit tca6507_probe(struct i2c_client *client,
687 NUM_LEDS); 687 NUM_LEDS);
688 return -ENODEV; 688 return -ENODEV;
689 } 689 }
690 err = -ENOMEM;
691 tca = kzalloc(sizeof(*tca), GFP_KERNEL); 690 tca = kzalloc(sizeof(*tca), GFP_KERNEL);
692 if (!tca) 691 if (!tca)
693 goto exit; 692 return -ENOMEM;
694 693
695 tca->client = client; 694 tca->client = client;
696 INIT_WORK(&tca->work, tca6507_work); 695 INIT_WORK(&tca->work, tca6507_work);
@@ -724,11 +723,10 @@ static int __devinit tca6507_probe(struct i2c_client *client,
724 723
725 return 0; 724 return 0;
726exit: 725exit:
727 while (i--) 726 while (i--) {
728 if (tca->leds[i].led_cdev.name) 727 if (tca->leds[i].led_cdev.name)
729 led_classdev_unregister(&tca->leds[i].led_cdev); 728 led_classdev_unregister(&tca->leds[i].led_cdev);
730 cancel_work_sync(&tca->work); 729 }
731 i2c_set_clientdata(client, NULL);
732 kfree(tca); 730 kfree(tca);
733 return err; 731 return err;
734} 732}
@@ -745,7 +743,6 @@ static int __devexit tca6507_remove(struct i2c_client *client)
745 } 743 }
746 tca6507_remove_gpio(tca); 744 tca6507_remove_gpio(tca);
747 cancel_work_sync(&tca->work); 745 cancel_work_sync(&tca->work);
748 i2c_set_clientdata(client, NULL);
749 kfree(tca); 746 kfree(tca);
750 747
751 return 0; 748 return 0;
diff --git a/drivers/mtd/chips/cfi_cmdset_0001.c b/drivers/mtd/chips/cfi_cmdset_0001.c
index e1e122f2f929..9bcd1f415f43 100644
--- a/drivers/mtd/chips/cfi_cmdset_0001.c
+++ b/drivers/mtd/chips/cfi_cmdset_0001.c
@@ -2526,12 +2526,10 @@ static void cfi_intelext_restore_locks(struct mtd_info *mtd)
2526 if (!region->lockmap) 2526 if (!region->lockmap)
2527 continue; 2527 continue;
2528 2528
2529 for (block = 0; block < region->numblocks; block++) { 2529 for_each_clear_bit(block, region->lockmap, region->numblocks) {
2530 len = region->erasesize; 2530 len = region->erasesize;
2531 adr = region->offset + block * len; 2531 adr = region->offset + block * len;
2532 2532 cfi_intelext_unlock(mtd, adr, len);
2533 if (!test_bit(block, region->lockmap))
2534 cfi_intelext_unlock(mtd, adr, len);
2535 } 2533 }
2536 } 2534 }
2537} 2535}
diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c
index 50c6a1e7f675..c57ae92ebda4 100644
--- a/drivers/mtd/mtdchar.c
+++ b/drivers/mtd/mtdchar.c
@@ -31,13 +31,13 @@
31#include <linux/compat.h> 31#include <linux/compat.h>
32#include <linux/mount.h> 32#include <linux/mount.h>
33#include <linux/blkpg.h> 33#include <linux/blkpg.h>
34#include <linux/magic.h>
34#include <linux/mtd/mtd.h> 35#include <linux/mtd/mtd.h>
35#include <linux/mtd/partitions.h> 36#include <linux/mtd/partitions.h>
36#include <linux/mtd/map.h> 37#include <linux/mtd/map.h>
37 38
38#include <asm/uaccess.h> 39#include <asm/uaccess.h>
39 40
40#define MTD_INODE_FS_MAGIC 0x11307854
41static DEFINE_MUTEX(mtd_mutex); 41static DEFINE_MUTEX(mtd_mutex);
42static struct vfsmount *mtd_inode_mnt __read_mostly; 42static struct vfsmount *mtd_inode_mnt __read_mostly;
43 43
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index 3a125b835546..4f9fb25f945b 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -554,6 +554,13 @@ config RTC_DRV_DS1742
554 This driver can also be built as a module. If so, the module 554 This driver can also be built as a module. If so, the module
555 will be called rtc-ds1742. 555 will be called rtc-ds1742.
556 556
557config RTC_DRV_DA9052
558 tristate "Dialog DA9052/DA9053 RTC"
559 depends on PMIC_DA9052
560 help
561 Say y here to support the RTC driver for Dialog Semiconductor
562 DA9052-BC and DA9053-AA/Bx PMICs.
563
557config RTC_DRV_EFI 564config RTC_DRV_EFI
558 tristate "EFI RTC" 565 tristate "EFI RTC"
559 depends on IA64 566 depends on IA64
@@ -1070,4 +1077,14 @@ config RTC_DRV_PUV3
1070 This drive can also be built as a module. If so, the module 1077 This drive can also be built as a module. If so, the module
1071 will be called rtc-puv3. 1078 will be called rtc-puv3.
1072 1079
1080config RTC_DRV_LOONGSON1
1081 tristate "loongson1 RTC support"
1082 depends on MACH_LOONGSON1
1083 help
1084 This is a driver for the loongson1 on-chip Counter0 (Time-Of-Year
1085 counter) to be used as a RTC.
1086
1087 This driver can also be built as a module. If so, the module
1088 will be called rtc-ls1x.
1089
1073endif # RTC_CLASS 1090endif # RTC_CLASS
diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile
index 6e6982335c10..727ae7786e6c 100644
--- a/drivers/rtc/Makefile
+++ b/drivers/rtc/Makefile
@@ -27,6 +27,7 @@ obj-$(CONFIG_RTC_DRV_BQ32K) += rtc-bq32k.o
27obj-$(CONFIG_RTC_DRV_BQ4802) += rtc-bq4802.o 27obj-$(CONFIG_RTC_DRV_BQ4802) += rtc-bq4802.o
28obj-$(CONFIG_RTC_DRV_CMOS) += rtc-cmos.o 28obj-$(CONFIG_RTC_DRV_CMOS) += rtc-cmos.o
29obj-$(CONFIG_RTC_DRV_COH901331) += rtc-coh901331.o 29obj-$(CONFIG_RTC_DRV_COH901331) += rtc-coh901331.o
30obj-$(CONFIG_RTC_DRV_DA9052) += rtc-da9052.o
30obj-$(CONFIG_RTC_DRV_DAVINCI) += rtc-davinci.o 31obj-$(CONFIG_RTC_DRV_DAVINCI) += rtc-davinci.o
31obj-$(CONFIG_RTC_DRV_DM355EVM) += rtc-dm355evm.o 32obj-$(CONFIG_RTC_DRV_DM355EVM) += rtc-dm355evm.o
32obj-$(CONFIG_RTC_DRV_VRTC) += rtc-mrst.o 33obj-$(CONFIG_RTC_DRV_VRTC) += rtc-mrst.o
@@ -53,6 +54,7 @@ obj-$(CONFIG_RTC_DRV_ISL1208) += rtc-isl1208.o
53obj-$(CONFIG_RTC_DRV_ISL12022) += rtc-isl12022.o 54obj-$(CONFIG_RTC_DRV_ISL12022) += rtc-isl12022.o
54obj-$(CONFIG_RTC_DRV_JZ4740) += rtc-jz4740.o 55obj-$(CONFIG_RTC_DRV_JZ4740) += rtc-jz4740.o
55obj-$(CONFIG_RTC_DRV_LPC32XX) += rtc-lpc32xx.o 56obj-$(CONFIG_RTC_DRV_LPC32XX) += rtc-lpc32xx.o
57obj-$(CONFIG_RTC_DRV_LOONGSON1) += rtc-ls1x.o
56obj-$(CONFIG_RTC_DRV_M41T80) += rtc-m41t80.o 58obj-$(CONFIG_RTC_DRV_M41T80) += rtc-m41t80.o
57obj-$(CONFIG_RTC_DRV_M41T93) += rtc-m41t93.o 59obj-$(CONFIG_RTC_DRV_M41T93) += rtc-m41t93.o
58obj-$(CONFIG_RTC_DRV_M41T94) += rtc-m41t94.o 60obj-$(CONFIG_RTC_DRV_M41T94) += rtc-m41t94.o
diff --git a/drivers/rtc/rtc-at91sam9.c b/drivers/rtc/rtc-at91sam9.c
index ee3c122c0599..274a0aafe42b 100644
--- a/drivers/rtc/rtc-at91sam9.c
+++ b/drivers/rtc/rtc-at91sam9.c
@@ -335,7 +335,7 @@ static int __init at91_rtc_probe(struct platform_device *pdev)
335 335
336 /* register irq handler after we know what name we'll use */ 336 /* register irq handler after we know what name we'll use */
337 ret = request_irq(AT91_ID_SYS, at91_rtc_interrupt, 337 ret = request_irq(AT91_ID_SYS, at91_rtc_interrupt,
338 IRQF_DISABLED | IRQF_SHARED, 338 IRQF_SHARED,
339 dev_name(&rtc->rtcdev->dev), rtc); 339 dev_name(&rtc->rtcdev->dev), rtc);
340 if (ret) { 340 if (ret) {
341 dev_dbg(&pdev->dev, "can't share IRQ %d?\n", AT91_ID_SYS); 341 dev_dbg(&pdev->dev, "can't share IRQ %d?\n", AT91_ID_SYS);
diff --git a/drivers/rtc/rtc-bq32k.c b/drivers/rtc/rtc-bq32k.c
index 408cc8f735be..f090159dce4a 100644
--- a/drivers/rtc/rtc-bq32k.c
+++ b/drivers/rtc/rtc-bq32k.c
@@ -187,17 +187,7 @@ static struct i2c_driver bq32k_driver = {
187 .id_table = bq32k_id, 187 .id_table = bq32k_id,
188}; 188};
189 189
190static __init int bq32k_init(void) 190module_i2c_driver(bq32k_driver);
191{
192 return i2c_add_driver(&bq32k_driver);
193}
194module_init(bq32k_init);
195
196static __exit void bq32k_exit(void)
197{
198 i2c_del_driver(&bq32k_driver);
199}
200module_exit(bq32k_exit);
201 191
202MODULE_AUTHOR("Semihalf, Piotr Ziecik <kosmo@semihalf.com>"); 192MODULE_AUTHOR("Semihalf, Piotr Ziecik <kosmo@semihalf.com>");
203MODULE_DESCRIPTION("TI BQ32000 I2C RTC driver"); 193MODULE_DESCRIPTION("TI BQ32000 I2C RTC driver");
diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
index d7782aa09943..7d5f56edb8ef 100644
--- a/drivers/rtc/rtc-cmos.c
+++ b/drivers/rtc/rtc-cmos.c
@@ -714,7 +714,7 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
714 rtc_cmos_int_handler = cmos_interrupt; 714 rtc_cmos_int_handler = cmos_interrupt;
715 715
716 retval = request_irq(rtc_irq, rtc_cmos_int_handler, 716 retval = request_irq(rtc_irq, rtc_cmos_int_handler,
717 IRQF_DISABLED, dev_name(&cmos_rtc.rtc->dev), 717 0, dev_name(&cmos_rtc.rtc->dev),
718 cmos_rtc.rtc); 718 cmos_rtc.rtc);
719 if (retval < 0) { 719 if (retval < 0) {
720 dev_dbg(dev, "IRQ %d is already in use\n", rtc_irq); 720 dev_dbg(dev, "IRQ %d is already in use\n", rtc_irq);
diff --git a/drivers/rtc/rtc-coh901331.c b/drivers/rtc/rtc-coh901331.c
index 80f9c88214c5..a5b8a0c4ea84 100644
--- a/drivers/rtc/rtc-coh901331.c
+++ b/drivers/rtc/rtc-coh901331.c
@@ -199,7 +199,7 @@ static int __init coh901331_probe(struct platform_device *pdev)
199 } 199 }
200 200
201 rtap->irq = platform_get_irq(pdev, 0); 201 rtap->irq = platform_get_irq(pdev, 0);
202 if (request_irq(rtap->irq, coh901331_interrupt, IRQF_DISABLED, 202 if (request_irq(rtap->irq, coh901331_interrupt, 0,
203 "RTC COH 901 331 Alarm", rtap)) { 203 "RTC COH 901 331 Alarm", rtap)) {
204 ret = -EIO; 204 ret = -EIO;
205 goto out_no_irq; 205 goto out_no_irq;
diff --git a/drivers/rtc/rtc-da9052.c b/drivers/rtc/rtc-da9052.c
new file mode 100644
index 000000000000..da6ab5291a41
--- /dev/null
+++ b/drivers/rtc/rtc-da9052.c
@@ -0,0 +1,293 @@
1/*
2 * Real time clock driver for DA9052
3 *
4 * Copyright(c) 2012 Dialog Semiconductor Ltd.
5 *
6 * Author: Dajun Dajun Chen <dajun.chen@diasemi.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 */
14
15#include <linux/module.h>
16#include <linux/platform_device.h>
17#include <linux/rtc.h>
18
19#include <linux/mfd/da9052/da9052.h>
20#include <linux/mfd/da9052/reg.h>
21
22#define rtc_err(da9052, fmt, ...) \
23 dev_err(da9052->dev, "%s: " fmt, __func__, ##__VA_ARGS__)
24
25struct da9052_rtc {
26 struct rtc_device *rtc;
27 struct da9052 *da9052;
28 int irq;
29};
30
31static int da9052_rtc_enable_alarm(struct da9052 *da9052, bool enable)
32{
33 int ret;
34 if (enable) {
35 ret = da9052_reg_update(da9052, DA9052_ALARM_Y_REG,
36 DA9052_ALARM_Y_ALARM_ON,
37 DA9052_ALARM_Y_ALARM_ON);
38 if (ret != 0)
39 rtc_err(da9052, "Failed to enable ALM: %d\n", ret);
40 } else {
41 ret = da9052_reg_update(da9052, DA9052_ALARM_Y_REG,
42 DA9052_ALARM_Y_ALARM_ON, 0);
43 if (ret != 0)
44 rtc_err(da9052, "Write error: %d\n", ret);
45 }
46 return ret;
47}
48
49static irqreturn_t da9052_rtc_irq(int irq, void *data)
50{
51 struct da9052_rtc *rtc = data;
52 int ret;
53
54 ret = da9052_reg_read(rtc->da9052, DA9052_ALARM_MI_REG);
55 if (ret < 0) {
56 rtc_err(rtc->da9052, "Read error: %d\n", ret);
57 return IRQ_NONE;
58 }
59
60 if (ret & DA9052_ALARMMI_ALARMTYPE) {
61 da9052_rtc_enable_alarm(rtc->da9052, 0);
62 rtc_update_irq(rtc->rtc, 1, RTC_IRQF | RTC_AF);
63 } else
64 rtc_update_irq(rtc->rtc, 1, RTC_IRQF | RTC_PF);
65
66 return IRQ_HANDLED;
67}
68
69static int da9052_read_alarm(struct da9052 *da9052, struct rtc_time *rtc_tm)
70{
71 int ret;
72 uint8_t v[5];
73
74 ret = da9052_group_read(da9052, DA9052_ALARM_MI_REG, 5, v);
75 if (ret != 0) {
76 rtc_err(da9052, "Failed to group read ALM: %d\n", ret);
77 return ret;
78 }
79
80 rtc_tm->tm_year = (v[4] & DA9052_RTC_YEAR) + 100;
81 rtc_tm->tm_mon = (v[3] & DA9052_RTC_MONTH) - 1;
82 rtc_tm->tm_mday = v[2] & DA9052_RTC_DAY;
83 rtc_tm->tm_hour = v[1] & DA9052_RTC_HOUR;
84 rtc_tm->tm_min = v[0] & DA9052_RTC_MIN;
85
86 ret = rtc_valid_tm(rtc_tm);
87 if (ret != 0)
88 return ret;
89 return ret;
90}
91
92static int da9052_set_alarm(struct da9052 *da9052, struct rtc_time *rtc_tm)
93{
94 int ret;
95 uint8_t v[3];
96
97 rtc_tm->tm_year -= 100;
98 rtc_tm->tm_mon += 1;
99
100 ret = da9052_reg_update(da9052, DA9052_ALARM_MI_REG,
101 DA9052_RTC_MIN, rtc_tm->tm_min);
102 if (ret != 0) {
103 rtc_err(da9052, "Failed to write ALRM MIN: %d\n", ret);
104 return ret;
105 }
106
107 v[0] = rtc_tm->tm_hour;
108 v[1] = rtc_tm->tm_mday;
109 v[2] = rtc_tm->tm_mon;
110
111 ret = da9052_group_write(da9052, DA9052_ALARM_H_REG, 3, v);
112 if (ret < 0)
113 return ret;
114
115 ret = da9052_reg_update(da9052, DA9052_ALARM_Y_REG,
116 DA9052_RTC_YEAR, rtc_tm->tm_year);
117 if (ret != 0)
118 rtc_err(da9052, "Failed to write ALRM YEAR: %d\n", ret);
119
120 return ret;
121}
122
123static int da9052_rtc_get_alarm_status(struct da9052 *da9052)
124{
125 int ret;
126
127 ret = da9052_reg_read(da9052, DA9052_ALARM_Y_REG);
128 if (ret < 0) {
129 rtc_err(da9052, "Failed to read ALM: %d\n", ret);
130 return ret;
131 }
132 ret &= DA9052_ALARM_Y_ALARM_ON;
133 return (ret > 0) ? 1 : 0;
134}
135
136static int da9052_rtc_read_time(struct device *dev, struct rtc_time *rtc_tm)
137{
138 struct da9052_rtc *rtc = dev_get_drvdata(dev);
139 uint8_t v[6];
140 int ret;
141
142 ret = da9052_group_read(rtc->da9052, DA9052_COUNT_S_REG, 6, v);
143 if (ret < 0) {
144 rtc_err(rtc->da9052, "Failed to read RTC time : %d\n", ret);
145 return ret;
146 }
147
148 rtc_tm->tm_year = (v[5] & DA9052_RTC_YEAR) + 100;
149 rtc_tm->tm_mon = (v[4] & DA9052_RTC_MONTH) - 1;
150 rtc_tm->tm_mday = v[3] & DA9052_RTC_DAY;
151 rtc_tm->tm_hour = v[2] & DA9052_RTC_HOUR;
152 rtc_tm->tm_min = v[1] & DA9052_RTC_MIN;
153 rtc_tm->tm_sec = v[0] & DA9052_RTC_SEC;
154
155 ret = rtc_valid_tm(rtc_tm);
156 if (ret != 0) {
157 rtc_err(rtc->da9052, "rtc_valid_tm failed: %d\n", ret);
158 return ret;
159 }
160
161 return 0;
162}
163
164static int da9052_rtc_set_time(struct device *dev, struct rtc_time *tm)
165{
166 struct da9052_rtc *rtc;
167 uint8_t v[6];
168
169 rtc = dev_get_drvdata(dev);
170
171 v[0] = tm->tm_sec;
172 v[1] = tm->tm_min;
173 v[2] = tm->tm_hour;
174 v[3] = tm->tm_mday;
175 v[4] = tm->tm_mon + 1;
176 v[5] = tm->tm_year - 100;
177
178 return da9052_group_write(rtc->da9052, DA9052_COUNT_S_REG, 6, v);
179}
180
181static int da9052_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
182{
183 int ret;
184 struct rtc_time *tm = &alrm->time;
185 struct da9052_rtc *rtc = dev_get_drvdata(dev);
186
187 ret = da9052_read_alarm(rtc->da9052, tm);
188
189 if (ret)
190 return ret;
191
192 alrm->enabled = da9052_rtc_get_alarm_status(rtc->da9052);
193
194 return 0;
195}
196
197static int da9052_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
198{
199 int ret;
200 struct rtc_time *tm = &alrm->time;
201 struct da9052_rtc *rtc = dev_get_drvdata(dev);
202
203 ret = da9052_rtc_enable_alarm(rtc->da9052, 0);
204 if (ret < 0)
205 return ret;
206
207 ret = da9052_set_alarm(rtc->da9052, tm);
208 if (ret)
209 return ret;
210
211 ret = da9052_rtc_enable_alarm(rtc->da9052, 1);
212
213 return ret;
214}
215
216static int da9052_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled)
217{
218 struct da9052_rtc *rtc = dev_get_drvdata(dev);
219
220 return da9052_rtc_enable_alarm(rtc->da9052, enabled);
221}
222
223static const struct rtc_class_ops da9052_rtc_ops = {
224 .read_time = da9052_rtc_read_time,
225 .set_time = da9052_rtc_set_time,
226 .read_alarm = da9052_rtc_read_alarm,
227 .set_alarm = da9052_rtc_set_alarm,
228 .alarm_irq_enable = da9052_rtc_alarm_irq_enable,
229};
230
231static int __devinit da9052_rtc_probe(struct platform_device *pdev)
232{
233 struct da9052_rtc *rtc;
234 int ret;
235
236 rtc = devm_kzalloc(&pdev->dev, sizeof(struct da9052_rtc), GFP_KERNEL);
237 if (!rtc)
238 return -ENOMEM;
239
240 rtc->da9052 = dev_get_drvdata(pdev->dev.parent);
241 platform_set_drvdata(pdev, rtc);
242 rtc->irq = platform_get_irq_byname(pdev, "ALM");
243 ret = request_threaded_irq(rtc->irq, NULL, da9052_rtc_irq,
244 IRQF_TRIGGER_LOW | IRQF_ONESHOT,
245 "ALM", rtc);
246 if (ret != 0) {
247 rtc_err(rtc->da9052, "irq registration failed: %d\n", ret);
248 goto err_mem;
249 }
250
251 rtc->rtc = rtc_device_register(pdev->name, &pdev->dev,
252 &da9052_rtc_ops, THIS_MODULE);
253 if (IS_ERR(rtc->rtc)) {
254 ret = PTR_ERR(rtc->rtc);
255 goto err_free_irq;
256 }
257
258 return 0;
259
260err_free_irq:
261 free_irq(rtc->irq, rtc);
262err_mem:
263 devm_kfree(&pdev->dev, rtc);
264 return ret;
265}
266
267static int __devexit da9052_rtc_remove(struct platform_device *pdev)
268{
269 struct da9052_rtc *rtc = pdev->dev.platform_data;
270
271 rtc_device_unregister(rtc->rtc);
272 free_irq(rtc->irq, rtc);
273 platform_set_drvdata(pdev, NULL);
274 devm_kfree(&pdev->dev, rtc);
275
276 return 0;
277}
278
279static struct platform_driver da9052_rtc_driver = {
280 .probe = da9052_rtc_probe,
281 .remove = __devexit_p(da9052_rtc_remove),
282 .driver = {
283 .name = "da9052-rtc",
284 .owner = THIS_MODULE,
285 },
286};
287
288module_platform_driver(da9052_rtc_driver);
289
290MODULE_AUTHOR("David Dajun Chen <dchen@diasemi.com>");
291MODULE_DESCRIPTION("RTC driver for Dialog DA9052 PMIC");
292MODULE_LICENSE("GPL");
293MODULE_ALIAS("platform:da9052-rtc");
diff --git a/drivers/rtc/rtc-davinci.c b/drivers/rtc/rtc-davinci.c
index 755e1fe914af..14c2109dbaa3 100644
--- a/drivers/rtc/rtc-davinci.c
+++ b/drivers/rtc/rtc-davinci.c
@@ -542,7 +542,7 @@ static int __init davinci_rtc_probe(struct platform_device *pdev)
542 rtcss_write(davinci_rtc, 0, PRTCSS_RTC_CCTRL); 542 rtcss_write(davinci_rtc, 0, PRTCSS_RTC_CCTRL);
543 543
544 ret = request_irq(davinci_rtc->irq, davinci_rtc_interrupt, 544 ret = request_irq(davinci_rtc->irq, davinci_rtc_interrupt,
545 IRQF_DISABLED, "davinci_rtc", davinci_rtc); 545 0, "davinci_rtc", davinci_rtc);
546 if (ret < 0) { 546 if (ret < 0) {
547 dev_err(dev, "unable to register davinci RTC interrupt\n"); 547 dev_err(dev, "unable to register davinci RTC interrupt\n");
548 goto fail4; 548 goto fail4;
diff --git a/drivers/rtc/rtc-ds1305.c b/drivers/rtc/rtc-ds1305.c
index 3a33b1fdbe0f..686a865913e1 100644
--- a/drivers/rtc/rtc-ds1305.c
+++ b/drivers/rtc/rtc-ds1305.c
@@ -814,17 +814,7 @@ static struct spi_driver ds1305_driver = {
814 /* REVISIT add suspend/resume */ 814 /* REVISIT add suspend/resume */
815}; 815};
816 816
817static int __init ds1305_init(void) 817module_spi_driver(ds1305_driver);
818{
819 return spi_register_driver(&ds1305_driver);
820}
821module_init(ds1305_init);
822
823static void __exit ds1305_exit(void)
824{
825 spi_unregister_driver(&ds1305_driver);
826}
827module_exit(ds1305_exit);
828 818
829MODULE_DESCRIPTION("RTC driver for DS1305 and DS1306 chips"); 819MODULE_DESCRIPTION("RTC driver for DS1305 and DS1306 chips");
830MODULE_LICENSE("GPL"); 820MODULE_LICENSE("GPL");
diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
index 62b0763b7b9a..cd188ab72f79 100644
--- a/drivers/rtc/rtc-ds1307.c
+++ b/drivers/rtc/rtc-ds1307.c
@@ -20,7 +20,8 @@
20 20
21 21
22 22
23/* We can't determine type by probing, but if we expect pre-Linux code 23/*
24 * We can't determine type by probing, but if we expect pre-Linux code
24 * to have set the chip up as a clock (turning on the oscillator and 25 * to have set the chip up as a clock (turning on the oscillator and
25 * setting the date and time), Linux can ignore the non-clock features. 26 * setting the date and time), Linux can ignore the non-clock features.
26 * That's a natural job for a factory or repair bench. 27 * That's a natural job for a factory or repair bench.
@@ -36,7 +37,8 @@ enum ds_type {
36 m41t00, 37 m41t00,
37 mcp7941x, 38 mcp7941x,
38 rx_8025, 39 rx_8025,
39 // rs5c372 too? different address... 40 last_ds_type /* always last */
41 /* rs5c372 too? different address... */
40}; 42};
41 43
42 44
@@ -58,7 +60,8 @@ enum ds_type {
58# define DS1337_BIT_CENTURY 0x80 /* in REG_MONTH */ 60# define DS1337_BIT_CENTURY 0x80 /* in REG_MONTH */
59#define DS1307_REG_YEAR 0x06 /* 00-99 */ 61#define DS1307_REG_YEAR 0x06 /* 00-99 */
60 62
61/* Other registers (control, status, alarms, trickle charge, NVRAM, etc) 63/*
64 * Other registers (control, status, alarms, trickle charge, NVRAM, etc)
62 * start at 7, and they differ a LOT. Only control and status matter for 65 * start at 7, and they differ a LOT. Only control and status matter for
63 * basic RTC date and time functionality; be careful using them. 66 * basic RTC date and time functionality; be careful using them.
64 */ 67 */
@@ -102,6 +105,8 @@ enum ds_type {
102struct ds1307 { 105struct ds1307 {
103 u8 offset; /* register's offset */ 106 u8 offset; /* register's offset */
104 u8 regs[11]; 107 u8 regs[11];
108 u16 nvram_offset;
109 struct bin_attribute *nvram;
105 enum ds_type type; 110 enum ds_type type;
106 unsigned long flags; 111 unsigned long flags;
107#define HAS_NVRAM 0 /* bit 0 == sysfs file active */ 112#define HAS_NVRAM 0 /* bit 0 == sysfs file active */
@@ -116,34 +121,35 @@ struct ds1307 {
116}; 121};
117 122
118struct chip_desc { 123struct chip_desc {
119 unsigned nvram56:1;
120 unsigned alarm:1; 124 unsigned alarm:1;
125 u16 nvram_offset;
126 u16 nvram_size;
121}; 127};
122 128
123static const struct chip_desc chips[] = { 129static const struct chip_desc chips[last_ds_type] = {
124[ds_1307] = { 130 [ds_1307] = {
125 .nvram56 = 1, 131 .nvram_offset = 8,
126}, 132 .nvram_size = 56,
127[ds_1337] = { 133 },
128 .alarm = 1, 134 [ds_1337] = {
129}, 135 .alarm = 1,
130[ds_1338] = { 136 },
131 .nvram56 = 1, 137 [ds_1338] = {
132}, 138 .nvram_offset = 8,
133[ds_1339] = { 139 .nvram_size = 56,
134 .alarm = 1, 140 },
135}, 141 [ds_1339] = {
136[ds_1340] = { 142 .alarm = 1,
137}, 143 },
138[ds_3231] = { 144 [ds_3231] = {
139 .alarm = 1, 145 .alarm = 1,
140}, 146 },
141[m41t00] = { 147 [mcp7941x] = {
142}, 148 /* this is battery backed SRAM */
143[mcp7941x] = { 149 .nvram_offset = 0x20,
144}, 150 .nvram_size = 0x40,
145[rx_8025] = { 151 },
146}, }; 152};
147 153
148static const struct i2c_device_id ds1307_id[] = { 154static const struct i2c_device_id ds1307_id[] = {
149 { "ds1307", ds_1307 }, 155 { "ds1307", ds_1307 },
@@ -372,6 +378,11 @@ static int ds1307_set_time(struct device *dev, struct rtc_time *t)
372 | DS1340_BIT_CENTURY; 378 | DS1340_BIT_CENTURY;
373 break; 379 break;
374 case mcp7941x: 380 case mcp7941x:
381 /*
382 * these bits were cleared when preparing the date/time
383 * values and need to be set again before writing the
384 * buffer out to the device.
385 */
375 buf[DS1307_REG_SECS] |= MCP7941X_BIT_ST; 386 buf[DS1307_REG_SECS] |= MCP7941X_BIT_ST;
376 buf[DS1307_REG_WDAY] |= MCP7941X_BIT_VBATEN; 387 buf[DS1307_REG_WDAY] |= MCP7941X_BIT_VBATEN;
377 break; 388 break;
@@ -417,7 +428,8 @@ static int ds1337_read_alarm(struct device *dev, struct rtc_wkalrm *t)
417 ds1307->regs[6], ds1307->regs[7], 428 ds1307->regs[6], ds1307->regs[7],
418 ds1307->regs[8]); 429 ds1307->regs[8]);
419 430
420 /* report alarm time (ALARM1); assume 24 hour and day-of-month modes, 431 /*
432 * report alarm time (ALARM1); assume 24 hour and day-of-month modes,
421 * and that all four fields are checked matches 433 * and that all four fields are checked matches
422 */ 434 */
423 t->time.tm_sec = bcd2bin(ds1307->regs[0] & 0x7f); 435 t->time.tm_sec = bcd2bin(ds1307->regs[0] & 0x7f);
@@ -445,7 +457,7 @@ static int ds1337_read_alarm(struct device *dev, struct rtc_wkalrm *t)
445 457
446static int ds1337_set_alarm(struct device *dev, struct rtc_wkalrm *t) 458static int ds1337_set_alarm(struct device *dev, struct rtc_wkalrm *t)
447{ 459{
448 struct i2c_client *client = to_i2c_client(dev); 460 struct i2c_client *client = to_i2c_client(dev);
449 struct ds1307 *ds1307 = i2c_get_clientdata(client); 461 struct ds1307 *ds1307 = i2c_get_clientdata(client);
450 unsigned char *buf = ds1307->regs; 462 unsigned char *buf = ds1307->regs;
451 u8 control, status; 463 u8 control, status;
@@ -541,8 +553,6 @@ static const struct rtc_class_ops ds13xx_rtc_ops = {
541 553
542/*----------------------------------------------------------------------*/ 554/*----------------------------------------------------------------------*/
543 555
544#define NVRAM_SIZE 56
545
546static ssize_t 556static ssize_t
547ds1307_nvram_read(struct file *filp, struct kobject *kobj, 557ds1307_nvram_read(struct file *filp, struct kobject *kobj,
548 struct bin_attribute *attr, 558 struct bin_attribute *attr,
@@ -555,14 +565,15 @@ ds1307_nvram_read(struct file *filp, struct kobject *kobj,
555 client = kobj_to_i2c_client(kobj); 565 client = kobj_to_i2c_client(kobj);
556 ds1307 = i2c_get_clientdata(client); 566 ds1307 = i2c_get_clientdata(client);
557 567
558 if (unlikely(off >= NVRAM_SIZE)) 568 if (unlikely(off >= ds1307->nvram->size))
559 return 0; 569 return 0;
560 if ((off + count) > NVRAM_SIZE) 570 if ((off + count) > ds1307->nvram->size)
561 count = NVRAM_SIZE - off; 571 count = ds1307->nvram->size - off;
562 if (unlikely(!count)) 572 if (unlikely(!count))
563 return count; 573 return count;
564 574
565 result = ds1307->read_block_data(client, 8 + off, count, buf); 575 result = ds1307->read_block_data(client, ds1307->nvram_offset + off,
576 count, buf);
566 if (result < 0) 577 if (result < 0)
567 dev_err(&client->dev, "%s error %d\n", "nvram read", result); 578 dev_err(&client->dev, "%s error %d\n", "nvram read", result);
568 return result; 579 return result;
@@ -580,14 +591,15 @@ ds1307_nvram_write(struct file *filp, struct kobject *kobj,
580 client = kobj_to_i2c_client(kobj); 591 client = kobj_to_i2c_client(kobj);
581 ds1307 = i2c_get_clientdata(client); 592 ds1307 = i2c_get_clientdata(client);
582 593
583 if (unlikely(off >= NVRAM_SIZE)) 594 if (unlikely(off >= ds1307->nvram->size))
584 return -EFBIG; 595 return -EFBIG;
585 if ((off + count) > NVRAM_SIZE) 596 if ((off + count) > ds1307->nvram->size)
586 count = NVRAM_SIZE - off; 597 count = ds1307->nvram->size - off;
587 if (unlikely(!count)) 598 if (unlikely(!count))
588 return count; 599 return count;
589 600
590 result = ds1307->write_block_data(client, 8 + off, count, buf); 601 result = ds1307->write_block_data(client, ds1307->nvram_offset + off,
602 count, buf);
591 if (result < 0) { 603 if (result < 0) {
592 dev_err(&client->dev, "%s error %d\n", "nvram write", result); 604 dev_err(&client->dev, "%s error %d\n", "nvram write", result);
593 return result; 605 return result;
@@ -595,21 +607,8 @@ ds1307_nvram_write(struct file *filp, struct kobject *kobj,
595 return count; 607 return count;
596} 608}
597 609
598static struct bin_attribute nvram = {
599 .attr = {
600 .name = "nvram",
601 .mode = S_IRUGO | S_IWUSR,
602 },
603
604 .read = ds1307_nvram_read,
605 .write = ds1307_nvram_write,
606 .size = NVRAM_SIZE,
607};
608
609/*----------------------------------------------------------------------*/ 610/*----------------------------------------------------------------------*/
610 611
611static struct i2c_driver ds1307_driver;
612
613static int __devinit ds1307_probe(struct i2c_client *client, 612static int __devinit ds1307_probe(struct i2c_client *client,
614 const struct i2c_device_id *id) 613 const struct i2c_device_id *id)
615{ 614{
@@ -630,7 +629,8 @@ static int __devinit ds1307_probe(struct i2c_client *client,
630 && !i2c_check_functionality(adapter, I2C_FUNC_SMBUS_I2C_BLOCK)) 629 && !i2c_check_functionality(adapter, I2C_FUNC_SMBUS_I2C_BLOCK))
631 return -EIO; 630 return -EIO;
632 631
633 if (!(ds1307 = kzalloc(sizeof(struct ds1307), GFP_KERNEL))) 632 ds1307 = kzalloc(sizeof(struct ds1307), GFP_KERNEL);
633 if (!ds1307)
634 return -ENOMEM; 634 return -ENOMEM;
635 635
636 i2c_set_clientdata(client, ds1307); 636 i2c_set_clientdata(client, ds1307);
@@ -652,11 +652,6 @@ static int __devinit ds1307_probe(struct i2c_client *client,
652 case ds_1337: 652 case ds_1337:
653 case ds_1339: 653 case ds_1339:
654 case ds_3231: 654 case ds_3231:
655 /* has IRQ? */
656 if (ds1307->client->irq > 0 && chip->alarm) {
657 INIT_WORK(&ds1307->work, ds1307_work);
658 want_irq = true;
659 }
660 /* get registers that the "rtc" read below won't read... */ 655 /* get registers that the "rtc" read below won't read... */
661 tmp = ds1307->read_block_data(ds1307->client, 656 tmp = ds1307->read_block_data(ds1307->client,
662 DS1337_REG_CONTROL, 2, buf); 657 DS1337_REG_CONTROL, 2, buf);
@@ -670,14 +665,19 @@ static int __devinit ds1307_probe(struct i2c_client *client,
670 if (ds1307->regs[0] & DS1337_BIT_nEOSC) 665 if (ds1307->regs[0] & DS1337_BIT_nEOSC)
671 ds1307->regs[0] &= ~DS1337_BIT_nEOSC; 666 ds1307->regs[0] &= ~DS1337_BIT_nEOSC;
672 667
673 /* Using IRQ? Disable the square wave and both alarms. 668 /*
669 * Using IRQ? Disable the square wave and both alarms.
674 * For some variants, be sure alarms can trigger when we're 670 * For some variants, be sure alarms can trigger when we're
675 * running on Vbackup (BBSQI/BBSQW) 671 * running on Vbackup (BBSQI/BBSQW)
676 */ 672 */
677 if (want_irq) { 673 if (ds1307->client->irq > 0 && chip->alarm) {
674 INIT_WORK(&ds1307->work, ds1307_work);
675
678 ds1307->regs[0] |= DS1337_BIT_INTCN 676 ds1307->regs[0] |= DS1337_BIT_INTCN
679 | bbsqi_bitpos[ds1307->type]; 677 | bbsqi_bitpos[ds1307->type];
680 ds1307->regs[0] &= ~(DS1337_BIT_A2IE | DS1337_BIT_A1IE); 678 ds1307->regs[0] &= ~(DS1337_BIT_A2IE | DS1337_BIT_A1IE);
679
680 want_irq = true;
681 } 681 }
682 682
683 i2c_smbus_write_byte_data(client, DS1337_REG_CONTROL, 683 i2c_smbus_write_byte_data(client, DS1337_REG_CONTROL,
@@ -772,7 +772,8 @@ read_rtc:
772 goto exit_free; 772 goto exit_free;
773 } 773 }
774 774
775 /* minimal sanity checking; some chips (like DS1340) don't 775 /*
776 * minimal sanity checking; some chips (like DS1340) don't
776 * specify the extra bits as must-be-zero, but there are 777 * specify the extra bits as must-be-zero, but there are
777 * still a few values that are clearly out-of-range. 778 * still a few values that are clearly out-of-range.
778 */ 779 */
@@ -836,11 +837,7 @@ read_rtc:
836 } 837 }
837 838
838 break; 839 break;
839 case rx_8025: 840 default:
840 case ds_1337:
841 case ds_1339:
842 case ds_1388:
843 case ds_3231:
844 break; 841 break;
845 } 842 }
846 843
@@ -848,7 +845,8 @@ read_rtc:
848 switch (ds1307->type) { 845 switch (ds1307->type) {
849 case ds_1340: 846 case ds_1340:
850 case m41t00: 847 case m41t00:
851 /* NOTE: ignores century bits; fix before deploying 848 /*
849 * NOTE: ignores century bits; fix before deploying
852 * systems that will run through year 2100. 850 * systems that will run through year 2100.
853 */ 851 */
854 break; 852 break;
@@ -858,7 +856,8 @@ read_rtc:
858 if (!(tmp & DS1307_BIT_12HR)) 856 if (!(tmp & DS1307_BIT_12HR))
859 break; 857 break;
860 858
861 /* Be sure we're in 24 hour mode. Multi-master systems 859 /*
860 * Be sure we're in 24 hour mode. Multi-master systems
862 * take note... 861 * take note...
863 */ 862 */
864 tmp = bcd2bin(tmp & 0x1f); 863 tmp = bcd2bin(tmp & 0x1f);
@@ -894,16 +893,31 @@ read_rtc:
894 dev_dbg(&client->dev, "got IRQ %d\n", client->irq); 893 dev_dbg(&client->dev, "got IRQ %d\n", client->irq);
895 } 894 }
896 895
897 if (chip->nvram56) { 896 if (chip->nvram_size) {
898 err = sysfs_create_bin_file(&client->dev.kobj, &nvram); 897 ds1307->nvram = kzalloc(sizeof(struct bin_attribute),
899 if (err == 0) { 898 GFP_KERNEL);
900 set_bit(HAS_NVRAM, &ds1307->flags); 899 if (!ds1307->nvram) {
901 dev_info(&client->dev, "56 bytes nvram\n"); 900 err = -ENOMEM;
901 goto exit_nvram;
902 }
903 ds1307->nvram->attr.name = "nvram";
904 ds1307->nvram->attr.mode = S_IRUGO | S_IWUSR;
905 ds1307->nvram->read = ds1307_nvram_read,
906 ds1307->nvram->write = ds1307_nvram_write,
907 ds1307->nvram->size = chip->nvram_size;
908 ds1307->nvram_offset = chip->nvram_offset;
909 err = sysfs_create_bin_file(&client->dev.kobj, ds1307->nvram);
910 if (err) {
911 kfree(ds1307->nvram);
912 goto exit_nvram;
902 } 913 }
914 set_bit(HAS_NVRAM, &ds1307->flags);
915 dev_info(&client->dev, "%zu bytes nvram\n", ds1307->nvram->size);
903 } 916 }
904 917
905 return 0; 918 return 0;
906 919
920exit_nvram:
907exit_irq: 921exit_irq:
908 rtc_device_unregister(ds1307->rtc); 922 rtc_device_unregister(ds1307->rtc);
909exit_free: 923exit_free:
@@ -913,15 +927,17 @@ exit_free:
913 927
914static int __devexit ds1307_remove(struct i2c_client *client) 928static int __devexit ds1307_remove(struct i2c_client *client)
915{ 929{
916 struct ds1307 *ds1307 = i2c_get_clientdata(client); 930 struct ds1307 *ds1307 = i2c_get_clientdata(client);
917 931
918 if (test_and_clear_bit(HAS_ALARM, &ds1307->flags)) { 932 if (test_and_clear_bit(HAS_ALARM, &ds1307->flags)) {
919 free_irq(client->irq, client); 933 free_irq(client->irq, client);
920 cancel_work_sync(&ds1307->work); 934 cancel_work_sync(&ds1307->work);
921 } 935 }
922 936
923 if (test_and_clear_bit(HAS_NVRAM, &ds1307->flags)) 937 if (test_and_clear_bit(HAS_NVRAM, &ds1307->flags)) {
924 sysfs_remove_bin_file(&client->dev.kobj, &nvram); 938 sysfs_remove_bin_file(&client->dev.kobj, ds1307->nvram);
939 kfree(ds1307->nvram);
940 }
925 941
926 rtc_device_unregister(ds1307->rtc); 942 rtc_device_unregister(ds1307->rtc);
927 kfree(ds1307); 943 kfree(ds1307);
@@ -938,17 +954,7 @@ static struct i2c_driver ds1307_driver = {
938 .id_table = ds1307_id, 954 .id_table = ds1307_id,
939}; 955};
940 956
941static int __init ds1307_init(void) 957module_i2c_driver(ds1307_driver);
942{
943 return i2c_add_driver(&ds1307_driver);
944}
945module_init(ds1307_init);
946
947static void __exit ds1307_exit(void)
948{
949 i2c_del_driver(&ds1307_driver);
950}
951module_exit(ds1307_exit);
952 958
953MODULE_DESCRIPTION("RTC driver for DS1307 and similar chips"); 959MODULE_DESCRIPTION("RTC driver for DS1307 and similar chips");
954MODULE_LICENSE("GPL"); 960MODULE_LICENSE("GPL");
diff --git a/drivers/rtc/rtc-ds1374.c b/drivers/rtc/rtc-ds1374.c
index e6e71deb188f..966316088b7f 100644
--- a/drivers/rtc/rtc-ds1374.c
+++ b/drivers/rtc/rtc-ds1374.c
@@ -446,18 +446,7 @@ static struct i2c_driver ds1374_driver = {
446 .id_table = ds1374_id, 446 .id_table = ds1374_id,
447}; 447};
448 448
449static int __init ds1374_init(void) 449module_i2c_driver(ds1374_driver);
450{
451 return i2c_add_driver(&ds1374_driver);
452}
453
454static void __exit ds1374_exit(void)
455{
456 i2c_del_driver(&ds1374_driver);
457}
458
459module_init(ds1374_init);
460module_exit(ds1374_exit);
461 450
462MODULE_AUTHOR("Scott Wood <scottwood@freescale.com>"); 451MODULE_AUTHOR("Scott Wood <scottwood@freescale.com>");
463MODULE_DESCRIPTION("Maxim/Dallas DS1374 RTC Driver"); 452MODULE_DESCRIPTION("Maxim/Dallas DS1374 RTC Driver");
diff --git a/drivers/rtc/rtc-ds1390.c b/drivers/rtc/rtc-ds1390.c
index b038d2cfef26..b0a99e1b25be 100644
--- a/drivers/rtc/rtc-ds1390.c
+++ b/drivers/rtc/rtc-ds1390.c
@@ -175,17 +175,7 @@ static struct spi_driver ds1390_driver = {
175 .remove = __devexit_p(ds1390_remove), 175 .remove = __devexit_p(ds1390_remove),
176}; 176};
177 177
178static __init int ds1390_init(void) 178module_spi_driver(ds1390_driver);
179{
180 return spi_register_driver(&ds1390_driver);
181}
182module_init(ds1390_init);
183
184static __exit void ds1390_exit(void)
185{
186 spi_unregister_driver(&ds1390_driver);
187}
188module_exit(ds1390_exit);
189 179
190MODULE_DESCRIPTION("Dallas/Maxim DS1390/93/94 SPI RTC driver"); 180MODULE_DESCRIPTION("Dallas/Maxim DS1390/93/94 SPI RTC driver");
191MODULE_AUTHOR("Mark Jackson <mpfj@mimc.co.uk>"); 181MODULE_AUTHOR("Mark Jackson <mpfj@mimc.co.uk>");
diff --git a/drivers/rtc/rtc-ds1511.c b/drivers/rtc/rtc-ds1511.c
index 761f36bc83a9..1f675f5294f5 100644
--- a/drivers/rtc/rtc-ds1511.c
+++ b/drivers/rtc/rtc-ds1511.c
@@ -532,7 +532,7 @@ ds1511_rtc_probe(struct platform_device *pdev)
532 if (pdata->irq > 0) { 532 if (pdata->irq > 0) {
533 rtc_read(RTC_CMD1); 533 rtc_read(RTC_CMD1);
534 if (devm_request_irq(&pdev->dev, pdata->irq, ds1511_interrupt, 534 if (devm_request_irq(&pdev->dev, pdata->irq, ds1511_interrupt,
535 IRQF_DISABLED | IRQF_SHARED, pdev->name, pdev) < 0) { 535 IRQF_SHARED, pdev->name, pdev) < 0) {
536 536
537 dev_warn(&pdev->dev, "interrupt not available.\n"); 537 dev_warn(&pdev->dev, "interrupt not available.\n");
538 pdata->irq = 0; 538 pdata->irq = 0;
diff --git a/drivers/rtc/rtc-ds1553.c b/drivers/rtc/rtc-ds1553.c
index 6f0a1b530f2e..6ccedbbf923c 100644
--- a/drivers/rtc/rtc-ds1553.c
+++ b/drivers/rtc/rtc-ds1553.c
@@ -320,7 +320,7 @@ static int __devinit ds1553_rtc_probe(struct platform_device *pdev)
320 writeb(0, ioaddr + RTC_INTERRUPTS); 320 writeb(0, ioaddr + RTC_INTERRUPTS);
321 if (devm_request_irq(&pdev->dev, pdata->irq, 321 if (devm_request_irq(&pdev->dev, pdata->irq,
322 ds1553_rtc_interrupt, 322 ds1553_rtc_interrupt,
323 IRQF_DISABLED, pdev->name, pdev) < 0) { 323 0, pdev->name, pdev) < 0) {
324 dev_warn(&pdev->dev, "interrupt not available.\n"); 324 dev_warn(&pdev->dev, "interrupt not available.\n");
325 pdata->irq = 0; 325 pdata->irq = 0;
326 } 326 }
diff --git a/drivers/rtc/rtc-ds1672.c b/drivers/rtc/rtc-ds1672.c
index a319402a5447..7fa67d0df172 100644
--- a/drivers/rtc/rtc-ds1672.c
+++ b/drivers/rtc/rtc-ds1672.c
@@ -202,20 +202,9 @@ static struct i2c_driver ds1672_driver = {
202 .id_table = ds1672_id, 202 .id_table = ds1672_id,
203}; 203};
204 204
205static int __init ds1672_init(void) 205module_i2c_driver(ds1672_driver);
206{
207 return i2c_add_driver(&ds1672_driver);
208}
209
210static void __exit ds1672_exit(void)
211{
212 i2c_del_driver(&ds1672_driver);
213}
214 206
215MODULE_AUTHOR("Alessandro Zummo <a.zummo@towertech.it>"); 207MODULE_AUTHOR("Alessandro Zummo <a.zummo@towertech.it>");
216MODULE_DESCRIPTION("Dallas/Maxim DS1672 timekeeper driver"); 208MODULE_DESCRIPTION("Dallas/Maxim DS1672 timekeeper driver");
217MODULE_LICENSE("GPL"); 209MODULE_LICENSE("GPL");
218MODULE_VERSION(DRV_VERSION); 210MODULE_VERSION(DRV_VERSION);
219
220module_init(ds1672_init);
221module_exit(ds1672_exit);
diff --git a/drivers/rtc/rtc-ds3232.c b/drivers/rtc/rtc-ds3232.c
index 27b7bf672ac6..e1945095814e 100644
--- a/drivers/rtc/rtc-ds3232.c
+++ b/drivers/rtc/rtc-ds3232.c
@@ -473,18 +473,7 @@ static struct i2c_driver ds3232_driver = {
473 .id_table = ds3232_id, 473 .id_table = ds3232_id,
474}; 474};
475 475
476static int __init ds3232_init(void) 476module_i2c_driver(ds3232_driver);
477{
478 return i2c_add_driver(&ds3232_driver);
479}
480
481static void __exit ds3232_exit(void)
482{
483 i2c_del_driver(&ds3232_driver);
484}
485
486module_init(ds3232_init);
487module_exit(ds3232_exit);
488 477
489MODULE_AUTHOR("Srikanth Srinivasan <srikanth.srinivasan@freescale.com>"); 478MODULE_AUTHOR("Srikanth Srinivasan <srikanth.srinivasan@freescale.com>");
490MODULE_DESCRIPTION("Maxim/Dallas DS3232 RTC Driver"); 479MODULE_DESCRIPTION("Maxim/Dallas DS3232 RTC Driver");
diff --git a/drivers/rtc/rtc-ds3234.c b/drivers/rtc/rtc-ds3234.c
index bbd26228f532..fda707926f02 100644
--- a/drivers/rtc/rtc-ds3234.c
+++ b/drivers/rtc/rtc-ds3234.c
@@ -173,17 +173,7 @@ static struct spi_driver ds3234_driver = {
173 .remove = __devexit_p(ds3234_remove), 173 .remove = __devexit_p(ds3234_remove),
174}; 174};
175 175
176static __init int ds3234_init(void) 176module_spi_driver(ds3234_driver);
177{
178 return spi_register_driver(&ds3234_driver);
179}
180module_init(ds3234_init);
181
182static __exit void ds3234_exit(void)
183{
184 spi_unregister_driver(&ds3234_driver);
185}
186module_exit(ds3234_exit);
187 177
188MODULE_DESCRIPTION("DS3234 SPI RTC driver"); 178MODULE_DESCRIPTION("DS3234 SPI RTC driver");
189MODULE_AUTHOR("Dennis Aberilla <denzzzhome@yahoo.com>"); 179MODULE_AUTHOR("Dennis Aberilla <denzzzhome@yahoo.com>");
diff --git a/drivers/rtc/rtc-em3027.c b/drivers/rtc/rtc-em3027.c
index 8414dea5fb14..0104ea7ebe50 100644
--- a/drivers/rtc/rtc-em3027.c
+++ b/drivers/rtc/rtc-em3027.c
@@ -144,19 +144,8 @@ static struct i2c_driver em3027_driver = {
144 .id_table = em3027_id, 144 .id_table = em3027_id,
145}; 145};
146 146
147static int __init em3027_init(void) 147module_i2c_driver(em3027_driver);
148{
149 return i2c_add_driver(&em3027_driver);
150}
151
152static void __exit em3027_exit(void)
153{
154 i2c_del_driver(&em3027_driver);
155}
156 148
157MODULE_AUTHOR("Mike Rapoport <mike@compulab.co.il>"); 149MODULE_AUTHOR("Mike Rapoport <mike@compulab.co.il>");
158MODULE_DESCRIPTION("EM Microelectronic EM3027 RTC driver"); 150MODULE_DESCRIPTION("EM Microelectronic EM3027 RTC driver");
159MODULE_LICENSE("GPL"); 151MODULE_LICENSE("GPL");
160
161module_init(em3027_init);
162module_exit(em3027_exit);
diff --git a/drivers/rtc/rtc-fm3130.c b/drivers/rtc/rtc-fm3130.c
index 4cf2e70c5078..86b6ecce99f0 100644
--- a/drivers/rtc/rtc-fm3130.c
+++ b/drivers/rtc/rtc-fm3130.c
@@ -565,17 +565,7 @@ static struct i2c_driver fm3130_driver = {
565 .id_table = fm3130_id, 565 .id_table = fm3130_id,
566}; 566};
567 567
568static int __init fm3130_init(void) 568module_i2c_driver(fm3130_driver);
569{
570 return i2c_add_driver(&fm3130_driver);
571}
572module_init(fm3130_init);
573
574static void __exit fm3130_exit(void)
575{
576 i2c_del_driver(&fm3130_driver);
577}
578module_exit(fm3130_exit);
579 569
580MODULE_DESCRIPTION("RTC driver for FM3130"); 570MODULE_DESCRIPTION("RTC driver for FM3130");
581MODULE_AUTHOR("Sergey Lapin <slapin@ossfans.org>"); 571MODULE_AUTHOR("Sergey Lapin <slapin@ossfans.org>");
diff --git a/drivers/rtc/rtc-isl12022.c b/drivers/rtc/rtc-isl12022.c
index 6186833973ee..1850104705c0 100644
--- a/drivers/rtc/rtc-isl12022.c
+++ b/drivers/rtc/rtc-isl12022.c
@@ -309,18 +309,7 @@ static struct i2c_driver isl12022_driver = {
309 .id_table = isl12022_id, 309 .id_table = isl12022_id,
310}; 310};
311 311
312static int __init isl12022_init(void) 312module_i2c_driver(isl12022_driver);
313{
314 return i2c_add_driver(&isl12022_driver);
315}
316
317static void __exit isl12022_exit(void)
318{
319 i2c_del_driver(&isl12022_driver);
320}
321
322module_init(isl12022_init);
323module_exit(isl12022_exit);
324 313
325MODULE_AUTHOR("roman.fietze@telemotive.de"); 314MODULE_AUTHOR("roman.fietze@telemotive.de");
326MODULE_DESCRIPTION("ISL 12022 RTC driver"); 315MODULE_DESCRIPTION("ISL 12022 RTC driver");
diff --git a/drivers/rtc/rtc-isl1208.c b/drivers/rtc/rtc-isl1208.c
index da8beb8cae51..dd2aeee6c66a 100644
--- a/drivers/rtc/rtc-isl1208.c
+++ b/drivers/rtc/rtc-isl1208.c
@@ -710,22 +710,9 @@ static struct i2c_driver isl1208_driver = {
710 .id_table = isl1208_id, 710 .id_table = isl1208_id,
711}; 711};
712 712
713static int __init 713module_i2c_driver(isl1208_driver);
714isl1208_init(void)
715{
716 return i2c_add_driver(&isl1208_driver);
717}
718
719static void __exit
720isl1208_exit(void)
721{
722 i2c_del_driver(&isl1208_driver);
723}
724 714
725MODULE_AUTHOR("Herbert Valerio Riedel <hvr@gnu.org>"); 715MODULE_AUTHOR("Herbert Valerio Riedel <hvr@gnu.org>");
726MODULE_DESCRIPTION("Intersil ISL1208 RTC driver"); 716MODULE_DESCRIPTION("Intersil ISL1208 RTC driver");
727MODULE_LICENSE("GPL"); 717MODULE_LICENSE("GPL");
728MODULE_VERSION(DRV_VERSION); 718MODULE_VERSION(DRV_VERSION);
729
730module_init(isl1208_init);
731module_exit(isl1208_exit);
diff --git a/drivers/rtc/rtc-lpc32xx.c b/drivers/rtc/rtc-lpc32xx.c
index ecc1713b2b4f..63c72189c64b 100644
--- a/drivers/rtc/rtc-lpc32xx.c
+++ b/drivers/rtc/rtc-lpc32xx.c
@@ -287,7 +287,7 @@ static int __devinit lpc32xx_rtc_probe(struct platform_device *pdev)
287 if (rtc->irq >= 0) { 287 if (rtc->irq >= 0) {
288 if (devm_request_irq(&pdev->dev, rtc->irq, 288 if (devm_request_irq(&pdev->dev, rtc->irq,
289 lpc32xx_rtc_alarm_interrupt, 289 lpc32xx_rtc_alarm_interrupt,
290 IRQF_DISABLED, pdev->name, rtc) < 0) { 290 0, pdev->name, rtc) < 0) {
291 dev_warn(&pdev->dev, "Can't request interrupt.\n"); 291 dev_warn(&pdev->dev, "Can't request interrupt.\n");
292 rtc->irq = -1; 292 rtc->irq = -1;
293 } else { 293 } else {
diff --git a/drivers/rtc/rtc-ls1x.c b/drivers/rtc/rtc-ls1x.c
new file mode 100644
index 000000000000..07e81c5f8247
--- /dev/null
+++ b/drivers/rtc/rtc-ls1x.c
@@ -0,0 +1,210 @@
1/*
2 * Copyright (c) 2011 Zhao Zhang <zhzhl555@gmail.com>
3 *
4 * Derived from driver/rtc/rtc-au1xxx.c
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version.
10 */
11
12#include <linux/module.h>
13#include <linux/kernel.h>
14#include <linux/rtc.h>
15#include <linux/init.h>
16#include <linux/platform_device.h>
17#include <linux/delay.h>
18#include <linux/types.h>
19#include <linux/io.h>
20#include <asm/mach-loongson1/loongson1.h>
21
22#define LS1X_RTC_REG_OFFSET (LS1X_RTC_BASE + 0x20)
23#define LS1X_RTC_REGS(x) \
24 ((void __iomem *)KSEG1ADDR(LS1X_RTC_REG_OFFSET + (x)))
25
26/*RTC programmable counters 0 and 1*/
27#define SYS_COUNTER_CNTRL (LS1X_RTC_REGS(0x20))
28#define SYS_CNTRL_ERS (1 << 23)
29#define SYS_CNTRL_RTS (1 << 20)
30#define SYS_CNTRL_RM2 (1 << 19)
31#define SYS_CNTRL_RM1 (1 << 18)
32#define SYS_CNTRL_RM0 (1 << 17)
33#define SYS_CNTRL_RS (1 << 16)
34#define SYS_CNTRL_BP (1 << 14)
35#define SYS_CNTRL_REN (1 << 13)
36#define SYS_CNTRL_BRT (1 << 12)
37#define SYS_CNTRL_TEN (1 << 11)
38#define SYS_CNTRL_BTT (1 << 10)
39#define SYS_CNTRL_E0 (1 << 8)
40#define SYS_CNTRL_ETS (1 << 7)
41#define SYS_CNTRL_32S (1 << 5)
42#define SYS_CNTRL_TTS (1 << 4)
43#define SYS_CNTRL_TM2 (1 << 3)
44#define SYS_CNTRL_TM1 (1 << 2)
45#define SYS_CNTRL_TM0 (1 << 1)
46#define SYS_CNTRL_TS (1 << 0)
47
48/* Programmable Counter 0 Registers */
49#define SYS_TOYTRIM (LS1X_RTC_REGS(0))
50#define SYS_TOYWRITE0 (LS1X_RTC_REGS(4))
51#define SYS_TOYWRITE1 (LS1X_RTC_REGS(8))
52#define SYS_TOYREAD0 (LS1X_RTC_REGS(0xC))
53#define SYS_TOYREAD1 (LS1X_RTC_REGS(0x10))
54#define SYS_TOYMATCH0 (LS1X_RTC_REGS(0x14))
55#define SYS_TOYMATCH1 (LS1X_RTC_REGS(0x18))
56#define SYS_TOYMATCH2 (LS1X_RTC_REGS(0x1C))
57
58/* Programmable Counter 1 Registers */
59#define SYS_RTCTRIM (LS1X_RTC_REGS(0x40))
60#define SYS_RTCWRITE0 (LS1X_RTC_REGS(0x44))
61#define SYS_RTCREAD0 (LS1X_RTC_REGS(0x48))
62#define SYS_RTCMATCH0 (LS1X_RTC_REGS(0x4C))
63#define SYS_RTCMATCH1 (LS1X_RTC_REGS(0x50))
64#define SYS_RTCMATCH2 (LS1X_RTC_REGS(0x54))
65
66#define LS1X_SEC_OFFSET (4)
67#define LS1X_MIN_OFFSET (10)
68#define LS1X_HOUR_OFFSET (16)
69#define LS1X_DAY_OFFSET (21)
70#define LS1X_MONTH_OFFSET (26)
71
72
73#define LS1X_SEC_MASK (0x3f)
74#define LS1X_MIN_MASK (0x3f)
75#define LS1X_HOUR_MASK (0x1f)
76#define LS1X_DAY_MASK (0x1f)
77#define LS1X_MONTH_MASK (0x3f)
78#define LS1X_YEAR_MASK (0xffffffff)
79
80#define ls1x_get_sec(t) (((t) >> LS1X_SEC_OFFSET) & LS1X_SEC_MASK)
81#define ls1x_get_min(t) (((t) >> LS1X_MIN_OFFSET) & LS1X_MIN_MASK)
82#define ls1x_get_hour(t) (((t) >> LS1X_HOUR_OFFSET) & LS1X_HOUR_MASK)
83#define ls1x_get_day(t) (((t) >> LS1X_DAY_OFFSET) & LS1X_DAY_MASK)
84#define ls1x_get_month(t) (((t) >> LS1X_MONTH_OFFSET) & LS1X_MONTH_MASK)
85
86#define RTC_CNTR_OK (SYS_CNTRL_E0 | SYS_CNTRL_32S)
87
88static int ls1x_rtc_read_time(struct device *dev, struct rtc_time *rtm)
89{
90 unsigned long v, t;
91
92 v = readl(SYS_TOYREAD0);
93 t = readl(SYS_TOYREAD1);
94
95 memset(rtm, 0, sizeof(struct rtc_time));
96 t = mktime((t & LS1X_YEAR_MASK), ls1x_get_month(v),
97 ls1x_get_day(v), ls1x_get_hour(v),
98 ls1x_get_min(v), ls1x_get_sec(v));
99 rtc_time_to_tm(t, rtm);
100
101 return rtc_valid_tm(rtm);
102}
103
104static int ls1x_rtc_set_time(struct device *dev, struct rtc_time *rtm)
105{
106 unsigned long v, t, c;
107 int ret = -ETIMEDOUT;
108
109 v = ((rtm->tm_mon + 1) << LS1X_MONTH_OFFSET)
110 | (rtm->tm_mday << LS1X_DAY_OFFSET)
111 | (rtm->tm_hour << LS1X_HOUR_OFFSET)
112 | (rtm->tm_min << LS1X_MIN_OFFSET)
113 | (rtm->tm_sec << LS1X_SEC_OFFSET);
114
115 writel(v, SYS_TOYWRITE0);
116 c = 0x10000;
117 /* add timeout check counter, for more safe */
118 while ((readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_TS) && --c)
119 usleep_range(1000, 3000);
120
121 if (!c) {
122 dev_err(dev, "set time timeout!\n");
123 goto err;
124 }
125
126 t = rtm->tm_year + 1900;
127 writel(t, SYS_TOYWRITE1);
128 c = 0x10000;
129 while ((readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_TS) && --c)
130 usleep_range(1000, 3000);
131
132 if (!c) {
133 dev_err(dev, "set time timeout!\n");
134 goto err;
135 }
136 return 0;
137err:
138 return ret;
139}
140
141static struct rtc_class_ops ls1x_rtc_ops = {
142 .read_time = ls1x_rtc_read_time,
143 .set_time = ls1x_rtc_set_time,
144};
145
146static int __devinit ls1x_rtc_probe(struct platform_device *pdev)
147{
148 struct rtc_device *rtcdev;
149 unsigned long v;
150 int ret;
151
152 v = readl(SYS_COUNTER_CNTRL);
153 if (!(v & RTC_CNTR_OK)) {
154 dev_err(&pdev->dev, "rtc counters not working\n");
155 ret = -ENODEV;
156 goto err;
157 }
158 ret = -ETIMEDOUT;
159 /* set to 1 HZ if needed */
160 if (readl(SYS_TOYTRIM) != 32767) {
161 v = 0x100000;
162 while ((readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_TTS) && --v)
163 usleep_range(1000, 3000);
164
165 if (!v) {
166 dev_err(&pdev->dev, "time out\n");
167 goto err;
168 }
169 writel(32767, SYS_TOYTRIM);
170 }
171 /* this loop coundn't be endless */
172 while (readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_TTS)
173 usleep_range(1000, 3000);
174
175 rtcdev = rtc_device_register("ls1x-rtc", &pdev->dev,
176 &ls1x_rtc_ops , THIS_MODULE);
177 if (IS_ERR(rtcdev)) {
178 ret = PTR_ERR(rtcdev);
179 goto err;
180 }
181
182 platform_set_drvdata(pdev, rtcdev);
183 return 0;
184err:
185 return ret;
186}
187
188static int __devexit ls1x_rtc_remove(struct platform_device *pdev)
189{
190 struct rtc_device *rtcdev = platform_get_drvdata(pdev);
191
192 rtc_device_unregister(rtcdev);
193 platform_set_drvdata(pdev, NULL);
194
195 return 0;
196}
197
198static struct platform_driver ls1x_rtc_driver = {
199 .driver = {
200 .name = "ls1x-rtc",
201 .owner = THIS_MODULE,
202 },
203 .remove = __devexit_p(ls1x_rtc_remove),
204 .probe = ls1x_rtc_probe,
205};
206
207module_platform_driver(ls1x_rtc_driver);
208
209MODULE_AUTHOR("zhao zhang <zhzhl555@gmail.com>");
210MODULE_LICENSE("GPL");
diff --git a/drivers/rtc/rtc-m41t80.c b/drivers/rtc/rtc-m41t80.c
index 64aedd8cc095..4e0f84af99a7 100644
--- a/drivers/rtc/rtc-m41t80.c
+++ b/drivers/rtc/rtc-m41t80.c
@@ -900,20 +900,9 @@ static struct i2c_driver m41t80_driver = {
900 .id_table = m41t80_id, 900 .id_table = m41t80_id,
901}; 901};
902 902
903static int __init m41t80_rtc_init(void) 903module_i2c_driver(m41t80_driver);
904{
905 return i2c_add_driver(&m41t80_driver);
906}
907
908static void __exit m41t80_rtc_exit(void)
909{
910 i2c_del_driver(&m41t80_driver);
911}
912 904
913MODULE_AUTHOR("Alexander Bigga <ab@mycable.de>"); 905MODULE_AUTHOR("Alexander Bigga <ab@mycable.de>");
914MODULE_DESCRIPTION("ST Microelectronics M41T80 series RTC I2C Client Driver"); 906MODULE_DESCRIPTION("ST Microelectronics M41T80 series RTC I2C Client Driver");
915MODULE_LICENSE("GPL"); 907MODULE_LICENSE("GPL");
916MODULE_VERSION(DRV_VERSION); 908MODULE_VERSION(DRV_VERSION);
917
918module_init(m41t80_rtc_init);
919module_exit(m41t80_rtc_exit);
diff --git a/drivers/rtc/rtc-m41t93.c b/drivers/rtc/rtc-m41t93.c
index ef71132ff205..10f1c29436ec 100644
--- a/drivers/rtc/rtc-m41t93.c
+++ b/drivers/rtc/rtc-m41t93.c
@@ -206,17 +206,7 @@ static struct spi_driver m41t93_driver = {
206 .remove = __devexit_p(m41t93_remove), 206 .remove = __devexit_p(m41t93_remove),
207}; 207};
208 208
209static __init int m41t93_init(void) 209module_spi_driver(m41t93_driver);
210{
211 return spi_register_driver(&m41t93_driver);
212}
213module_init(m41t93_init);
214
215static __exit void m41t93_exit(void)
216{
217 spi_unregister_driver(&m41t93_driver);
218}
219module_exit(m41t93_exit);
220 210
221MODULE_AUTHOR("Nikolaus Voss <n.voss@weinmann.de>"); 211MODULE_AUTHOR("Nikolaus Voss <n.voss@weinmann.de>");
222MODULE_DESCRIPTION("Driver for ST M41T93 SPI RTC"); 212MODULE_DESCRIPTION("Driver for ST M41T93 SPI RTC");
diff --git a/drivers/rtc/rtc-m41t94.c b/drivers/rtc/rtc-m41t94.c
index 2a4721f61797..6e78193e026b 100644
--- a/drivers/rtc/rtc-m41t94.c
+++ b/drivers/rtc/rtc-m41t94.c
@@ -153,19 +153,7 @@ static struct spi_driver m41t94_driver = {
153 .remove = __devexit_p(m41t94_remove), 153 .remove = __devexit_p(m41t94_remove),
154}; 154};
155 155
156static __init int m41t94_init(void) 156module_spi_driver(m41t94_driver);
157{
158 return spi_register_driver(&m41t94_driver);
159}
160
161module_init(m41t94_init);
162
163static __exit void m41t94_exit(void)
164{
165 spi_unregister_driver(&m41t94_driver);
166}
167
168module_exit(m41t94_exit);
169 157
170MODULE_AUTHOR("Kim B. Heino <Kim.Heino@bluegiga.com>"); 158MODULE_AUTHOR("Kim B. Heino <Kim.Heino@bluegiga.com>");
171MODULE_DESCRIPTION("Driver for ST M41T94 SPI RTC"); 159MODULE_DESCRIPTION("Driver for ST M41T94 SPI RTC");
diff --git a/drivers/rtc/rtc-max6900.c b/drivers/rtc/rtc-max6900.c
index 486142c2637a..a00e33204b91 100644
--- a/drivers/rtc/rtc-max6900.c
+++ b/drivers/rtc/rtc-max6900.c
@@ -261,20 +261,9 @@ static struct i2c_driver max6900_driver = {
261 .id_table = max6900_id, 261 .id_table = max6900_id,
262}; 262};
263 263
264static int __init max6900_init(void) 264module_i2c_driver(max6900_driver);
265{
266 return i2c_add_driver(&max6900_driver);
267}
268
269static void __exit max6900_exit(void)
270{
271 i2c_del_driver(&max6900_driver);
272}
273 265
274MODULE_DESCRIPTION("Maxim MAX6900 RTC driver"); 266MODULE_DESCRIPTION("Maxim MAX6900 RTC driver");
275MODULE_AUTHOR("Dale Farnsworth <dale@farnsworth.org>"); 267MODULE_AUTHOR("Dale Farnsworth <dale@farnsworth.org>");
276MODULE_LICENSE("GPL"); 268MODULE_LICENSE("GPL");
277MODULE_VERSION(DRV_VERSION); 269MODULE_VERSION(DRV_VERSION);
278
279module_init(max6900_init);
280module_exit(max6900_exit);
diff --git a/drivers/rtc/rtc-max6902.c b/drivers/rtc/rtc-max6902.c
index 1f6b3cc58e8a..36c74d22e8b5 100644
--- a/drivers/rtc/rtc-max6902.c
+++ b/drivers/rtc/rtc-max6902.c
@@ -160,17 +160,7 @@ static struct spi_driver max6902_driver = {
160 .remove = __devexit_p(max6902_remove), 160 .remove = __devexit_p(max6902_remove),
161}; 161};
162 162
163static __init int max6902_init(void) 163module_spi_driver(max6902_driver);
164{
165 return spi_register_driver(&max6902_driver);
166}
167module_init(max6902_init);
168
169static __exit void max6902_exit(void)
170{
171 spi_unregister_driver(&max6902_driver);
172}
173module_exit(max6902_exit);
174 164
175MODULE_DESCRIPTION ("max6902 spi RTC driver"); 165MODULE_DESCRIPTION ("max6902 spi RTC driver");
176MODULE_AUTHOR ("Raphael Assenat"); 166MODULE_AUTHOR ("Raphael Assenat");
diff --git a/drivers/rtc/rtc-max8925.c b/drivers/rtc/rtc-max8925.c
index 2d71943bc436..1459055a83aa 100644
--- a/drivers/rtc/rtc-max8925.c
+++ b/drivers/rtc/rtc-max8925.c
@@ -193,10 +193,17 @@ static int max8925_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
193 ret = max8925_reg_read(info->rtc, MAX8925_RTC_IRQ_MASK); 193 ret = max8925_reg_read(info->rtc, MAX8925_RTC_IRQ_MASK);
194 if (ret < 0) 194 if (ret < 0)
195 goto out; 195 goto out;
196 if ((ret & ALARM0_IRQ) == 0) 196 if (ret & ALARM0_IRQ) {
197 alrm->enabled = 1;
198 else
199 alrm->enabled = 0; 197 alrm->enabled = 0;
198 } else {
199 ret = max8925_reg_read(info->rtc, MAX8925_ALARM0_CNTL);
200 if (ret < 0)
201 goto out;
202 if (!ret)
203 alrm->enabled = 0;
204 else
205 alrm->enabled = 1;
206 }
200 ret = max8925_reg_read(info->rtc, MAX8925_RTC_STATUS); 207 ret = max8925_reg_read(info->rtc, MAX8925_RTC_STATUS);
201 if (ret < 0) 208 if (ret < 0)
202 goto out; 209 goto out;
@@ -204,6 +211,7 @@ static int max8925_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
204 alrm->pending = 1; 211 alrm->pending = 1;
205 else 212 else
206 alrm->pending = 0; 213 alrm->pending = 0;
214 return 0;
207out: 215out:
208 return ret; 216 return ret;
209} 217}
@@ -220,8 +228,11 @@ static int max8925_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
220 ret = max8925_bulk_write(info->rtc, MAX8925_ALARM0_SEC, TIME_NUM, buf); 228 ret = max8925_bulk_write(info->rtc, MAX8925_ALARM0_SEC, TIME_NUM, buf);
221 if (ret < 0) 229 if (ret < 0)
222 goto out; 230 goto out;
223 /* only enable alarm on year/month/day/hour/min/sec */ 231 if (alrm->enabled)
224 ret = max8925_reg_write(info->rtc, MAX8925_ALARM0_CNTL, 0x77); 232 /* only enable alarm on year/month/day/hour/min/sec */
233 ret = max8925_reg_write(info->rtc, MAX8925_ALARM0_CNTL, 0x77);
234 else
235 ret = max8925_reg_write(info->rtc, MAX8925_ALARM0_CNTL, 0x0);
225 if (ret < 0) 236 if (ret < 0)
226 goto out; 237 goto out;
227out: 238out:
diff --git a/drivers/rtc/rtc-mpc5121.c b/drivers/rtc/rtc-mpc5121.c
index 9d3caccfc250..e954a759ba85 100644
--- a/drivers/rtc/rtc-mpc5121.c
+++ b/drivers/rtc/rtc-mpc5121.c
@@ -327,7 +327,7 @@ static int __devinit mpc5121_rtc_probe(struct platform_device *op)
327 dev_set_drvdata(&op->dev, rtc); 327 dev_set_drvdata(&op->dev, rtc);
328 328
329 rtc->irq = irq_of_parse_and_map(op->dev.of_node, 1); 329 rtc->irq = irq_of_parse_and_map(op->dev.of_node, 1);
330 err = request_irq(rtc->irq, mpc5121_rtc_handler, IRQF_DISABLED, 330 err = request_irq(rtc->irq, mpc5121_rtc_handler, 0,
331 "mpc5121-rtc", &op->dev); 331 "mpc5121-rtc", &op->dev);
332 if (err) { 332 if (err) {
333 dev_err(&op->dev, "%s: could not request irq: %i\n", 333 dev_err(&op->dev, "%s: could not request irq: %i\n",
@@ -337,7 +337,7 @@ static int __devinit mpc5121_rtc_probe(struct platform_device *op)
337 337
338 rtc->irq_periodic = irq_of_parse_and_map(op->dev.of_node, 0); 338 rtc->irq_periodic = irq_of_parse_and_map(op->dev.of_node, 0);
339 err = request_irq(rtc->irq_periodic, mpc5121_rtc_handler_upd, 339 err = request_irq(rtc->irq_periodic, mpc5121_rtc_handler_upd,
340 IRQF_DISABLED, "mpc5121-rtc_upd", &op->dev); 340 0, "mpc5121-rtc_upd", &op->dev);
341 if (err) { 341 if (err) {
342 dev_err(&op->dev, "%s: could not request irq: %i\n", 342 dev_err(&op->dev, "%s: could not request irq: %i\n",
343 __func__, rtc->irq_periodic); 343 __func__, rtc->irq_periodic);
diff --git a/drivers/rtc/rtc-mrst.c b/drivers/rtc/rtc-mrst.c
index 6cd6c7235344..f51719bf4a75 100644
--- a/drivers/rtc/rtc-mrst.c
+++ b/drivers/rtc/rtc-mrst.c
@@ -366,7 +366,7 @@ vrtc_mrst_do_probe(struct device *dev, struct resource *iomem, int rtc_irq)
366 366
367 if (rtc_irq) { 367 if (rtc_irq) {
368 retval = request_irq(rtc_irq, mrst_rtc_irq, 368 retval = request_irq(rtc_irq, mrst_rtc_irq,
369 IRQF_DISABLED, dev_name(&mrst_rtc.rtc->dev), 369 0, dev_name(&mrst_rtc.rtc->dev),
370 mrst_rtc.rtc); 370 mrst_rtc.rtc);
371 if (retval < 0) { 371 if (retval < 0) {
372 dev_dbg(dev, "IRQ %d is already in use, err %d\n", 372 dev_dbg(dev, "IRQ %d is already in use, err %d\n",
diff --git a/drivers/rtc/rtc-mv.c b/drivers/rtc/rtc-mv.c
index 768e2edb9678..1300962486d1 100644
--- a/drivers/rtc/rtc-mv.c
+++ b/drivers/rtc/rtc-mv.c
@@ -273,7 +273,7 @@ static int __devinit mv_rtc_probe(struct platform_device *pdev)
273 if (pdata->irq >= 0) { 273 if (pdata->irq >= 0) {
274 writel(0, pdata->ioaddr + RTC_ALARM_INTERRUPT_MASK_REG_OFFS); 274 writel(0, pdata->ioaddr + RTC_ALARM_INTERRUPT_MASK_REG_OFFS);
275 if (devm_request_irq(&pdev->dev, pdata->irq, mv_rtc_interrupt, 275 if (devm_request_irq(&pdev->dev, pdata->irq, mv_rtc_interrupt,
276 IRQF_DISABLED | IRQF_SHARED, 276 IRQF_SHARED,
277 pdev->name, pdata) < 0) { 277 pdev->name, pdata) < 0) {
278 dev_warn(&pdev->dev, "interrupt not available.\n"); 278 dev_warn(&pdev->dev, "interrupt not available.\n");
279 pdata->irq = -1; 279 pdata->irq = -1;
diff --git a/drivers/rtc/rtc-nuc900.c b/drivers/rtc/rtc-nuc900.c
index 781068d62f23..b79010987d1e 100644
--- a/drivers/rtc/rtc-nuc900.c
+++ b/drivers/rtc/rtc-nuc900.c
@@ -269,7 +269,7 @@ static int __devinit nuc900_rtc_probe(struct platform_device *pdev)
269 269
270 nuc900_rtc->irq_num = platform_get_irq(pdev, 0); 270 nuc900_rtc->irq_num = platform_get_irq(pdev, 0);
271 if (request_irq(nuc900_rtc->irq_num, nuc900_rtc_interrupt, 271 if (request_irq(nuc900_rtc->irq_num, nuc900_rtc_interrupt,
272 IRQF_DISABLED, "nuc900rtc", nuc900_rtc)) { 272 0, "nuc900rtc", nuc900_rtc)) {
273 dev_err(&pdev->dev, "NUC900 RTC request irq failed\n"); 273 dev_err(&pdev->dev, "NUC900 RTC request irq failed\n");
274 err = -EBUSY; 274 err = -EBUSY;
275 goto fail4; 275 goto fail4;
diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c
index 7789002bdd5c..0b614e32653d 100644
--- a/drivers/rtc/rtc-omap.c
+++ b/drivers/rtc/rtc-omap.c
@@ -348,14 +348,14 @@ static int __init omap_rtc_probe(struct platform_device *pdev)
348 rtc_write(OMAP_RTC_STATUS_ALARM, OMAP_RTC_STATUS_REG); 348 rtc_write(OMAP_RTC_STATUS_ALARM, OMAP_RTC_STATUS_REG);
349 349
350 /* handle periodic and alarm irqs */ 350 /* handle periodic and alarm irqs */
351 if (request_irq(omap_rtc_timer, rtc_irq, IRQF_DISABLED, 351 if (request_irq(omap_rtc_timer, rtc_irq, 0,
352 dev_name(&rtc->dev), rtc)) { 352 dev_name(&rtc->dev), rtc)) {
353 pr_debug("%s: RTC timer interrupt IRQ%d already claimed\n", 353 pr_debug("%s: RTC timer interrupt IRQ%d already claimed\n",
354 pdev->name, omap_rtc_timer); 354 pdev->name, omap_rtc_timer);
355 goto fail1; 355 goto fail1;
356 } 356 }
357 if ((omap_rtc_timer != omap_rtc_alarm) && 357 if ((omap_rtc_timer != omap_rtc_alarm) &&
358 (request_irq(omap_rtc_alarm, rtc_irq, IRQF_DISABLED, 358 (request_irq(omap_rtc_alarm, rtc_irq, 0,
359 dev_name(&rtc->dev), rtc))) { 359 dev_name(&rtc->dev), rtc))) {
360 pr_debug("%s: RTC alarm interrupt IRQ%d already claimed\n", 360 pr_debug("%s: RTC alarm interrupt IRQ%d already claimed\n",
361 pdev->name, omap_rtc_alarm); 361 pdev->name, omap_rtc_alarm);
diff --git a/drivers/rtc/rtc-pcf2123.c b/drivers/rtc/rtc-pcf2123.c
index b46c4004d8fe..836118795c0b 100644
--- a/drivers/rtc/rtc-pcf2123.c
+++ b/drivers/rtc/rtc-pcf2123.c
@@ -346,20 +346,9 @@ static struct spi_driver pcf2123_driver = {
346 .remove = __devexit_p(pcf2123_remove), 346 .remove = __devexit_p(pcf2123_remove),
347}; 347};
348 348
349static int __init pcf2123_init(void) 349module_spi_driver(pcf2123_driver);
350{
351 return spi_register_driver(&pcf2123_driver);
352}
353
354static void __exit pcf2123_exit(void)
355{
356 spi_unregister_driver(&pcf2123_driver);
357}
358 350
359MODULE_AUTHOR("Chris Verges <chrisv@cyberswitching.com>"); 351MODULE_AUTHOR("Chris Verges <chrisv@cyberswitching.com>");
360MODULE_DESCRIPTION("NXP PCF2123 RTC driver"); 352MODULE_DESCRIPTION("NXP PCF2123 RTC driver");
361MODULE_LICENSE("GPL"); 353MODULE_LICENSE("GPL");
362MODULE_VERSION(DRV_VERSION); 354MODULE_VERSION(DRV_VERSION);
363
364module_init(pcf2123_init);
365module_exit(pcf2123_exit);
diff --git a/drivers/rtc/rtc-pcf8563.c b/drivers/rtc/rtc-pcf8563.c
index 606fdfab34e2..bc0677de1996 100644
--- a/drivers/rtc/rtc-pcf8563.c
+++ b/drivers/rtc/rtc-pcf8563.c
@@ -252,20 +252,9 @@ static struct i2c_driver pcf8563_driver = {
252 .id_table = pcf8563_id, 252 .id_table = pcf8563_id,
253}; 253};
254 254
255static int __init pcf8563_init(void) 255module_i2c_driver(pcf8563_driver);
256{
257 return i2c_add_driver(&pcf8563_driver);
258}
259
260static void __exit pcf8563_exit(void)
261{
262 i2c_del_driver(&pcf8563_driver);
263}
264 256
265MODULE_AUTHOR("Alessandro Zummo <a.zummo@towertech.it>"); 257MODULE_AUTHOR("Alessandro Zummo <a.zummo@towertech.it>");
266MODULE_DESCRIPTION("Philips PCF8563/Epson RTC8564 RTC driver"); 258MODULE_DESCRIPTION("Philips PCF8563/Epson RTC8564 RTC driver");
267MODULE_LICENSE("GPL"); 259MODULE_LICENSE("GPL");
268MODULE_VERSION(DRV_VERSION); 260MODULE_VERSION(DRV_VERSION);
269
270module_init(pcf8563_init);
271module_exit(pcf8563_exit);
diff --git a/drivers/rtc/rtc-pcf8583.c b/drivers/rtc/rtc-pcf8583.c
index 2d201afead3b..019ff3571168 100644
--- a/drivers/rtc/rtc-pcf8583.c
+++ b/drivers/rtc/rtc-pcf8583.c
@@ -320,18 +320,7 @@ static struct i2c_driver pcf8583_driver = {
320 .id_table = pcf8583_id, 320 .id_table = pcf8583_id,
321}; 321};
322 322
323static __init int pcf8583_init(void) 323module_i2c_driver(pcf8583_driver);
324{
325 return i2c_add_driver(&pcf8583_driver);
326}
327
328static __exit void pcf8583_exit(void)
329{
330 i2c_del_driver(&pcf8583_driver);
331}
332
333module_init(pcf8583_init);
334module_exit(pcf8583_exit);
335 324
336MODULE_AUTHOR("Russell King"); 325MODULE_AUTHOR("Russell King");
337MODULE_DESCRIPTION("PCF8583 I2C RTC driver"); 326MODULE_DESCRIPTION("PCF8583 I2C RTC driver");
diff --git a/drivers/rtc/rtc-pl030.c b/drivers/rtc/rtc-pl030.c
index 02111fee077e..a4a1e534ed42 100644
--- a/drivers/rtc/rtc-pl030.c
+++ b/drivers/rtc/rtc-pl030.c
@@ -123,7 +123,7 @@ static int pl030_probe(struct amba_device *dev, const struct amba_id *id)
123 123
124 amba_set_drvdata(dev, rtc); 124 amba_set_drvdata(dev, rtc);
125 125
126 ret = request_irq(dev->irq[0], pl030_interrupt, IRQF_DISABLED, 126 ret = request_irq(dev->irq[0], pl030_interrupt, 0,
127 "rtc-pl030", rtc); 127 "rtc-pl030", rtc);
128 if (ret) 128 if (ret)
129 goto err_irq; 129 goto err_irq;
diff --git a/drivers/rtc/rtc-pl031.c b/drivers/rtc/rtc-pl031.c
index a952c8de1dd7..3a470e291282 100644
--- a/drivers/rtc/rtc-pl031.c
+++ b/drivers/rtc/rtc-pl031.c
@@ -352,7 +352,7 @@ static int pl031_probe(struct amba_device *adev, const struct amba_id *id)
352 } 352 }
353 353
354 if (request_irq(adev->irq[0], pl031_interrupt, 354 if (request_irq(adev->irq[0], pl031_interrupt,
355 IRQF_DISABLED, "rtc-pl031", ldata)) { 355 0, "rtc-pl031", ldata)) {
356 ret = -EIO; 356 ret = -EIO;
357 goto out_no_irq; 357 goto out_no_irq;
358 } 358 }
diff --git a/drivers/rtc/rtc-pm8xxx.c b/drivers/rtc/rtc-pm8xxx.c
index 9f1d6bcbdf6c..d00bd24342a3 100644
--- a/drivers/rtc/rtc-pm8xxx.c
+++ b/drivers/rtc/rtc-pm8xxx.c
@@ -520,7 +520,7 @@ static int pm8xxx_rtc_suspend(struct device *dev)
520} 520}
521#endif 521#endif
522 522
523SIMPLE_DEV_PM_OPS(pm8xxx_rtc_pm_ops, pm8xxx_rtc_suspend, pm8xxx_rtc_resume); 523static SIMPLE_DEV_PM_OPS(pm8xxx_rtc_pm_ops, pm8xxx_rtc_suspend, pm8xxx_rtc_resume);
524 524
525static struct platform_driver pm8xxx_rtc_driver = { 525static struct platform_driver pm8xxx_rtc_driver = {
526 .probe = pm8xxx_rtc_probe, 526 .probe = pm8xxx_rtc_probe,
diff --git a/drivers/rtc/rtc-pxa.c b/drivers/rtc/rtc-pxa.c
index fc9f4991574b..0075c8fd93d8 100644
--- a/drivers/rtc/rtc-pxa.c
+++ b/drivers/rtc/rtc-pxa.c
@@ -174,14 +174,14 @@ static int pxa_rtc_open(struct device *dev)
174 struct pxa_rtc *pxa_rtc = dev_get_drvdata(dev); 174 struct pxa_rtc *pxa_rtc = dev_get_drvdata(dev);
175 int ret; 175 int ret;
176 176
177 ret = request_irq(pxa_rtc->irq_1Hz, pxa_rtc_irq, IRQF_DISABLED, 177 ret = request_irq(pxa_rtc->irq_1Hz, pxa_rtc_irq, 0,
178 "rtc 1Hz", dev); 178 "rtc 1Hz", dev);
179 if (ret < 0) { 179 if (ret < 0) {
180 dev_err(dev, "can't get irq %i, err %d\n", pxa_rtc->irq_1Hz, 180 dev_err(dev, "can't get irq %i, err %d\n", pxa_rtc->irq_1Hz,
181 ret); 181 ret);
182 goto err_irq_1Hz; 182 goto err_irq_1Hz;
183 } 183 }
184 ret = request_irq(pxa_rtc->irq_Alrm, pxa_rtc_irq, IRQF_DISABLED, 184 ret = request_irq(pxa_rtc->irq_Alrm, pxa_rtc_irq, 0,
185 "rtc Alrm", dev); 185 "rtc Alrm", dev);
186 if (ret < 0) { 186 if (ret < 0) {
187 dev_err(dev, "can't get irq %i, err %d\n", pxa_rtc->irq_Alrm, 187 dev_err(dev, "can't get irq %i, err %d\n", pxa_rtc->irq_Alrm,
diff --git a/drivers/rtc/rtc-r9701.c b/drivers/rtc/rtc-r9701.c
index 2853c2a6f10f..7f8e6c247935 100644
--- a/drivers/rtc/rtc-r9701.c
+++ b/drivers/rtc/rtc-r9701.c
@@ -159,17 +159,7 @@ static struct spi_driver r9701_driver = {
159 .remove = __devexit_p(r9701_remove), 159 .remove = __devexit_p(r9701_remove),
160}; 160};
161 161
162static __init int r9701_init(void) 162module_spi_driver(r9701_driver);
163{
164 return spi_register_driver(&r9701_driver);
165}
166module_init(r9701_init);
167
168static __exit void r9701_exit(void)
169{
170 spi_unregister_driver(&r9701_driver);
171}
172module_exit(r9701_exit);
173 163
174MODULE_DESCRIPTION("r9701 spi RTC driver"); 164MODULE_DESCRIPTION("r9701 spi RTC driver");
175MODULE_AUTHOR("Magnus Damm <damm@opensource.se>"); 165MODULE_AUTHOR("Magnus Damm <damm@opensource.se>");
diff --git a/drivers/rtc/rtc-rs5c348.c b/drivers/rtc/rtc-rs5c348.c
index ce2ca8523ddd..77074ccd2850 100644
--- a/drivers/rtc/rtc-rs5c348.c
+++ b/drivers/rtc/rtc-rs5c348.c
@@ -235,18 +235,7 @@ static struct spi_driver rs5c348_driver = {
235 .remove = __devexit_p(rs5c348_remove), 235 .remove = __devexit_p(rs5c348_remove),
236}; 236};
237 237
238static __init int rs5c348_init(void) 238module_spi_driver(rs5c348_driver);
239{
240 return spi_register_driver(&rs5c348_driver);
241}
242
243static __exit void rs5c348_exit(void)
244{
245 spi_unregister_driver(&rs5c348_driver);
246}
247
248module_init(rs5c348_init);
249module_exit(rs5c348_exit);
250 239
251MODULE_AUTHOR("Atsushi Nemoto <anemo@mba.ocn.ne.jp>"); 240MODULE_AUTHOR("Atsushi Nemoto <anemo@mba.ocn.ne.jp>");
252MODULE_DESCRIPTION("Ricoh RS5C348 RTC driver"); 241MODULE_DESCRIPTION("Ricoh RS5C348 RTC driver");
diff --git a/drivers/rtc/rtc-rs5c372.c b/drivers/rtc/rtc-rs5c372.c
index d29f5432c6e8..fb4842c3544e 100644
--- a/drivers/rtc/rtc-rs5c372.c
+++ b/drivers/rtc/rtc-rs5c372.c
@@ -689,18 +689,7 @@ static struct i2c_driver rs5c372_driver = {
689 .id_table = rs5c372_id, 689 .id_table = rs5c372_id,
690}; 690};
691 691
692static __init int rs5c372_init(void) 692module_i2c_driver(rs5c372_driver);
693{
694 return i2c_add_driver(&rs5c372_driver);
695}
696
697static __exit void rs5c372_exit(void)
698{
699 i2c_del_driver(&rs5c372_driver);
700}
701
702module_init(rs5c372_init);
703module_exit(rs5c372_exit);
704 693
705MODULE_AUTHOR( 694MODULE_AUTHOR(
706 "Pavel Mironchik <pmironchik@optifacio.net>, " 695 "Pavel Mironchik <pmironchik@optifacio.net>, "
diff --git a/drivers/rtc/rtc-rv3029c2.c b/drivers/rtc/rtc-rv3029c2.c
index ea09ff211dc6..0fbe57b2f6d2 100644
--- a/drivers/rtc/rtc-rv3029c2.c
+++ b/drivers/rtc/rtc-rv3029c2.c
@@ -436,18 +436,7 @@ static struct i2c_driver rv3029c2_driver = {
436 .id_table = rv3029c2_id, 436 .id_table = rv3029c2_id,
437}; 437};
438 438
439static int __init rv3029c2_init(void) 439module_i2c_driver(rv3029c2_driver);
440{
441 return i2c_add_driver(&rv3029c2_driver);
442}
443
444static void __exit rv3029c2_exit(void)
445{
446 i2c_del_driver(&rv3029c2_driver);
447}
448
449module_init(rv3029c2_init);
450module_exit(rv3029c2_exit);
451 440
452MODULE_AUTHOR("Gregory Hermant <gregory.hermant@calao-systems.com>"); 441MODULE_AUTHOR("Gregory Hermant <gregory.hermant@calao-systems.com>");
453MODULE_DESCRIPTION("Micro Crystal RV3029C2 RTC driver"); 442MODULE_DESCRIPTION("Micro Crystal RV3029C2 RTC driver");
diff --git a/drivers/rtc/rtc-rx8025.c b/drivers/rtc/rtc-rx8025.c
index fde172fb2abe..0de902dc1cd5 100644
--- a/drivers/rtc/rtc-rx8025.c
+++ b/drivers/rtc/rtc-rx8025.c
@@ -644,19 +644,8 @@ static struct i2c_driver rx8025_driver = {
644 .id_table = rx8025_id, 644 .id_table = rx8025_id,
645}; 645};
646 646
647static int __init rx8025_init(void) 647module_i2c_driver(rx8025_driver);
648{
649 return i2c_add_driver(&rx8025_driver);
650}
651
652static void __exit rx8025_exit(void)
653{
654 i2c_del_driver(&rx8025_driver);
655}
656 648
657MODULE_AUTHOR("Wolfgang Grandegger <wg@grandegger.com>"); 649MODULE_AUTHOR("Wolfgang Grandegger <wg@grandegger.com>");
658MODULE_DESCRIPTION("RX-8025 SA/NB RTC driver"); 650MODULE_DESCRIPTION("RX-8025 SA/NB RTC driver");
659MODULE_LICENSE("GPL"); 651MODULE_LICENSE("GPL");
660
661module_init(rx8025_init);
662module_exit(rx8025_exit);
diff --git a/drivers/rtc/rtc-rx8581.c b/drivers/rtc/rtc-rx8581.c
index 600b890a3c15..d84825124a7a 100644
--- a/drivers/rtc/rtc-rx8581.c
+++ b/drivers/rtc/rtc-rx8581.c
@@ -276,20 +276,9 @@ static struct i2c_driver rx8581_driver = {
276 .id_table = rx8581_id, 276 .id_table = rx8581_id,
277}; 277};
278 278
279static int __init rx8581_init(void) 279module_i2c_driver(rx8581_driver);
280{
281 return i2c_add_driver(&rx8581_driver);
282}
283
284static void __exit rx8581_exit(void)
285{
286 i2c_del_driver(&rx8581_driver);
287}
288 280
289MODULE_AUTHOR("Martyn Welch <martyn.welch@ge.com>"); 281MODULE_AUTHOR("Martyn Welch <martyn.welch@ge.com>");
290MODULE_DESCRIPTION("Epson RX-8581 RTC driver"); 282MODULE_DESCRIPTION("Epson RX-8581 RTC driver");
291MODULE_LICENSE("GPL"); 283MODULE_LICENSE("GPL");
292MODULE_VERSION(DRV_VERSION); 284MODULE_VERSION(DRV_VERSION);
293
294module_init(rx8581_init);
295module_exit(rx8581_exit);
diff --git a/drivers/rtc/rtc-s35390a.c b/drivers/rtc/rtc-s35390a.c
index f789e002c9b0..c9562ceedef3 100644
--- a/drivers/rtc/rtc-s35390a.c
+++ b/drivers/rtc/rtc-s35390a.c
@@ -304,19 +304,8 @@ static struct i2c_driver s35390a_driver = {
304 .id_table = s35390a_id, 304 .id_table = s35390a_id,
305}; 305};
306 306
307static int __init s35390a_rtc_init(void) 307module_i2c_driver(s35390a_driver);
308{
309 return i2c_add_driver(&s35390a_driver);
310}
311
312static void __exit s35390a_rtc_exit(void)
313{
314 i2c_del_driver(&s35390a_driver);
315}
316 308
317MODULE_AUTHOR("Byron Bradley <byron.bbradley@gmail.com>"); 309MODULE_AUTHOR("Byron Bradley <byron.bbradley@gmail.com>");
318MODULE_DESCRIPTION("S35390A RTC driver"); 310MODULE_DESCRIPTION("S35390A RTC driver");
319MODULE_LICENSE("GPL"); 311MODULE_LICENSE("GPL");
320
321module_init(s35390a_rtc_init);
322module_exit(s35390a_rtc_exit);
diff --git a/drivers/rtc/rtc-s3c.c b/drivers/rtc/rtc-s3c.c
index aef40bd2957b..c543f6f1eec2 100644
--- a/drivers/rtc/rtc-s3c.c
+++ b/drivers/rtc/rtc-s3c.c
@@ -543,14 +543,14 @@ static int __devinit s3c_rtc_probe(struct platform_device *pdev)
543 s3c_rtc_setfreq(&pdev->dev, 1); 543 s3c_rtc_setfreq(&pdev->dev, 1);
544 544
545 ret = request_irq(s3c_rtc_alarmno, s3c_rtc_alarmirq, 545 ret = request_irq(s3c_rtc_alarmno, s3c_rtc_alarmirq,
546 IRQF_DISABLED, "s3c2410-rtc alarm", rtc); 546 0, "s3c2410-rtc alarm", rtc);
547 if (ret) { 547 if (ret) {
548 dev_err(&pdev->dev, "IRQ%d error %d\n", s3c_rtc_alarmno, ret); 548 dev_err(&pdev->dev, "IRQ%d error %d\n", s3c_rtc_alarmno, ret);
549 goto err_alarm_irq; 549 goto err_alarm_irq;
550 } 550 }
551 551
552 ret = request_irq(s3c_rtc_tickno, s3c_rtc_tickirq, 552 ret = request_irq(s3c_rtc_tickno, s3c_rtc_tickirq,
553 IRQF_DISABLED, "s3c2410-rtc tick", rtc); 553 0, "s3c2410-rtc tick", rtc);
554 if (ret) { 554 if (ret) {
555 dev_err(&pdev->dev, "IRQ%d error %d\n", s3c_rtc_tickno, ret); 555 dev_err(&pdev->dev, "IRQ%d error %d\n", s3c_rtc_tickno, ret);
556 free_irq(s3c_rtc_alarmno, rtc); 556 free_irq(s3c_rtc_alarmno, rtc);
diff --git a/drivers/rtc/rtc-sa1100.c b/drivers/rtc/rtc-sa1100.c
index cb9a585312cc..fb758db9d0f4 100644
--- a/drivers/rtc/rtc-sa1100.c
+++ b/drivers/rtc/rtc-sa1100.c
@@ -160,14 +160,13 @@ static int sa1100_rtc_open(struct device *dev)
160 struct platform_device *plat_dev = to_platform_device(dev); 160 struct platform_device *plat_dev = to_platform_device(dev);
161 struct rtc_device *rtc = platform_get_drvdata(plat_dev); 161 struct rtc_device *rtc = platform_get_drvdata(plat_dev);
162 162
163 ret = request_irq(IRQ_RTC1Hz, sa1100_rtc_interrupt, IRQF_DISABLED, 163 ret = request_irq(IRQ_RTC1Hz, sa1100_rtc_interrupt, 0, "rtc 1Hz", dev);
164 "rtc 1Hz", dev);
165 if (ret) { 164 if (ret) {
166 dev_err(dev, "IRQ %d already in use.\n", IRQ_RTC1Hz); 165 dev_err(dev, "IRQ %d already in use.\n", IRQ_RTC1Hz);
167 goto fail_ui; 166 goto fail_ui;
168 } 167 }
169 ret = request_irq(IRQ_RTCAlrm, sa1100_rtc_interrupt, IRQF_DISABLED, 168 ret = request_irq(IRQ_RTCAlrm, sa1100_rtc_interrupt, 0,
170 "rtc Alrm", dev); 169 "rtc Alrm", dev);
171 if (ret) { 170 if (ret) {
172 dev_err(dev, "IRQ %d already in use.\n", IRQ_RTCAlrm); 171 dev_err(dev, "IRQ %d already in use.\n", IRQ_RTCAlrm);
173 goto fail_ai; 172 goto fail_ai;
diff --git a/drivers/rtc/rtc-sh.c b/drivers/rtc/rtc-sh.c
index 6ac55fd48413..e55a7635ae5f 100644
--- a/drivers/rtc/rtc-sh.c
+++ b/drivers/rtc/rtc-sh.c
@@ -666,7 +666,7 @@ static int __init sh_rtc_probe(struct platform_device *pdev)
666 if (rtc->carry_irq <= 0) { 666 if (rtc->carry_irq <= 0) {
667 /* register shared periodic/carry/alarm irq */ 667 /* register shared periodic/carry/alarm irq */
668 ret = request_irq(rtc->periodic_irq, sh_rtc_shared, 668 ret = request_irq(rtc->periodic_irq, sh_rtc_shared,
669 IRQF_DISABLED, "sh-rtc", rtc); 669 0, "sh-rtc", rtc);
670 if (unlikely(ret)) { 670 if (unlikely(ret)) {
671 dev_err(&pdev->dev, 671 dev_err(&pdev->dev,
672 "request IRQ failed with %d, IRQ %d\n", ret, 672 "request IRQ failed with %d, IRQ %d\n", ret,
@@ -676,7 +676,7 @@ static int __init sh_rtc_probe(struct platform_device *pdev)
676 } else { 676 } else {
677 /* register periodic/carry/alarm irqs */ 677 /* register periodic/carry/alarm irqs */
678 ret = request_irq(rtc->periodic_irq, sh_rtc_periodic, 678 ret = request_irq(rtc->periodic_irq, sh_rtc_periodic,
679 IRQF_DISABLED, "sh-rtc period", rtc); 679 0, "sh-rtc period", rtc);
680 if (unlikely(ret)) { 680 if (unlikely(ret)) {
681 dev_err(&pdev->dev, 681 dev_err(&pdev->dev,
682 "request period IRQ failed with %d, IRQ %d\n", 682 "request period IRQ failed with %d, IRQ %d\n",
@@ -685,7 +685,7 @@ static int __init sh_rtc_probe(struct platform_device *pdev)
685 } 685 }
686 686
687 ret = request_irq(rtc->carry_irq, sh_rtc_interrupt, 687 ret = request_irq(rtc->carry_irq, sh_rtc_interrupt,
688 IRQF_DISABLED, "sh-rtc carry", rtc); 688 0, "sh-rtc carry", rtc);
689 if (unlikely(ret)) { 689 if (unlikely(ret)) {
690 dev_err(&pdev->dev, 690 dev_err(&pdev->dev,
691 "request carry IRQ failed with %d, IRQ %d\n", 691 "request carry IRQ failed with %d, IRQ %d\n",
@@ -695,7 +695,7 @@ static int __init sh_rtc_probe(struct platform_device *pdev)
695 } 695 }
696 696
697 ret = request_irq(rtc->alarm_irq, sh_rtc_alarm, 697 ret = request_irq(rtc->alarm_irq, sh_rtc_alarm,
698 IRQF_DISABLED, "sh-rtc alarm", rtc); 698 0, "sh-rtc alarm", rtc);
699 if (unlikely(ret)) { 699 if (unlikely(ret)) {
700 dev_err(&pdev->dev, 700 dev_err(&pdev->dev,
701 "request alarm IRQ failed with %d, IRQ %d\n", 701 "request alarm IRQ failed with %d, IRQ %d\n",
diff --git a/drivers/rtc/rtc-spear.c b/drivers/rtc/rtc-spear.c
index 19a28a671a8e..e38da0dc4187 100644
--- a/drivers/rtc/rtc-spear.c
+++ b/drivers/rtc/rtc-spear.c
@@ -77,9 +77,11 @@
77#define STATUS_FAIL (LOST_WR_TIME | LOST_WR_DATE) 77#define STATUS_FAIL (LOST_WR_TIME | LOST_WR_DATE)
78 78
79struct spear_rtc_config { 79struct spear_rtc_config {
80 struct rtc_device *rtc;
80 struct clk *clk; 81 struct clk *clk;
81 spinlock_t lock; 82 spinlock_t lock;
82 void __iomem *ioaddr; 83 void __iomem *ioaddr;
84 unsigned int irq_wake;
83}; 85};
84 86
85static inline void spear_rtc_clear_interrupt(struct spear_rtc_config *config) 87static inline void spear_rtc_clear_interrupt(struct spear_rtc_config *config)
@@ -149,8 +151,7 @@ static void rtc_wait_not_busy(struct spear_rtc_config *config)
149 151
150static irqreturn_t spear_rtc_irq(int irq, void *dev_id) 152static irqreturn_t spear_rtc_irq(int irq, void *dev_id)
151{ 153{
152 struct rtc_device *rtc = (struct rtc_device *)dev_id; 154 struct spear_rtc_config *config = dev_id;
153 struct spear_rtc_config *config = dev_get_drvdata(&rtc->dev);
154 unsigned long flags, events = 0; 155 unsigned long flags, events = 0;
155 unsigned int irq_data; 156 unsigned int irq_data;
156 157
@@ -161,7 +162,7 @@ static irqreturn_t spear_rtc_irq(int irq, void *dev_id)
161 if ((irq_data & RTC_INT_MASK)) { 162 if ((irq_data & RTC_INT_MASK)) {
162 spear_rtc_clear_interrupt(config); 163 spear_rtc_clear_interrupt(config);
163 events = RTC_IRQF | RTC_AF; 164 events = RTC_IRQF | RTC_AF;
164 rtc_update_irq(rtc, 1, events); 165 rtc_update_irq(config->rtc, 1, events);
165 return IRQ_HANDLED; 166 return IRQ_HANDLED;
166 } else 167 } else
167 return IRQ_NONE; 168 return IRQ_NONE;
@@ -203,9 +204,7 @@ static void bcd2tm(struct rtc_time *tm)
203 */ 204 */
204static int spear_rtc_read_time(struct device *dev, struct rtc_time *tm) 205static int spear_rtc_read_time(struct device *dev, struct rtc_time *tm)
205{ 206{
206 struct platform_device *pdev = to_platform_device(dev); 207 struct spear_rtc_config *config = dev_get_drvdata(dev);
207 struct rtc_device *rtc = platform_get_drvdata(pdev);
208 struct spear_rtc_config *config = dev_get_drvdata(&rtc->dev);
209 unsigned int time, date; 208 unsigned int time, date;
210 209
211 /* we don't report wday/yday/isdst ... */ 210 /* we don't report wday/yday/isdst ... */
@@ -234,9 +233,7 @@ static int spear_rtc_read_time(struct device *dev, struct rtc_time *tm)
234 */ 233 */
235static int spear_rtc_set_time(struct device *dev, struct rtc_time *tm) 234static int spear_rtc_set_time(struct device *dev, struct rtc_time *tm)
236{ 235{
237 struct platform_device *pdev = to_platform_device(dev); 236 struct spear_rtc_config *config = dev_get_drvdata(dev);
238 struct rtc_device *rtc = platform_get_drvdata(pdev);
239 struct spear_rtc_config *config = dev_get_drvdata(&rtc->dev);
240 unsigned int time, date, err = 0; 237 unsigned int time, date, err = 0;
241 238
242 if (tm2bcd(tm) < 0) 239 if (tm2bcd(tm) < 0)
@@ -266,9 +263,7 @@ static int spear_rtc_set_time(struct device *dev, struct rtc_time *tm)
266 */ 263 */
267static int spear_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alm) 264static int spear_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alm)
268{ 265{
269 struct platform_device *pdev = to_platform_device(dev); 266 struct spear_rtc_config *config = dev_get_drvdata(dev);
270 struct rtc_device *rtc = platform_get_drvdata(pdev);
271 struct spear_rtc_config *config = dev_get_drvdata(&rtc->dev);
272 unsigned int time, date; 267 unsigned int time, date;
273 268
274 rtc_wait_not_busy(config); 269 rtc_wait_not_busy(config);
@@ -298,9 +293,7 @@ static int spear_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alm)
298 */ 293 */
299static int spear_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alm) 294static int spear_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alm)
300{ 295{
301 struct platform_device *pdev = to_platform_device(dev); 296 struct spear_rtc_config *config = dev_get_drvdata(dev);
302 struct rtc_device *rtc = platform_get_drvdata(pdev);
303 struct spear_rtc_config *config = dev_get_drvdata(&rtc->dev);
304 unsigned int time, date, err = 0; 297 unsigned int time, date, err = 0;
305 298
306 if (tm2bcd(&alm->time) < 0) 299 if (tm2bcd(&alm->time) < 0)
@@ -326,17 +319,42 @@ static int spear_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alm)
326 319
327 return 0; 320 return 0;
328} 321}
322
323static int spear_alarm_irq_enable(struct device *dev, unsigned int enabled)
324{
325 struct spear_rtc_config *config = dev_get_drvdata(dev);
326 int ret = 0;
327
328 spear_rtc_clear_interrupt(config);
329
330 switch (enabled) {
331 case 0:
332 /* alarm off */
333 spear_rtc_disable_interrupt(config);
334 break;
335 case 1:
336 /* alarm on */
337 spear_rtc_enable_interrupt(config);
338 break;
339 default:
340 ret = -EINVAL;
341 break;
342 }
343
344 return ret;
345}
346
329static struct rtc_class_ops spear_rtc_ops = { 347static struct rtc_class_ops spear_rtc_ops = {
330 .read_time = spear_rtc_read_time, 348 .read_time = spear_rtc_read_time,
331 .set_time = spear_rtc_set_time, 349 .set_time = spear_rtc_set_time,
332 .read_alarm = spear_rtc_read_alarm, 350 .read_alarm = spear_rtc_read_alarm,
333 .set_alarm = spear_rtc_set_alarm, 351 .set_alarm = spear_rtc_set_alarm,
352 .alarm_irq_enable = spear_alarm_irq_enable,
334}; 353};
335 354
336static int __devinit spear_rtc_probe(struct platform_device *pdev) 355static int __devinit spear_rtc_probe(struct platform_device *pdev)
337{ 356{
338 struct resource *res; 357 struct resource *res;
339 struct rtc_device *rtc;
340 struct spear_rtc_config *config; 358 struct spear_rtc_config *config;
341 unsigned int status = 0; 359 unsigned int status = 0;
342 int irq; 360 int irq;
@@ -376,19 +394,17 @@ static int __devinit spear_rtc_probe(struct platform_device *pdev)
376 } 394 }
377 395
378 spin_lock_init(&config->lock); 396 spin_lock_init(&config->lock);
397 platform_set_drvdata(pdev, config);
379 398
380 rtc = rtc_device_register(pdev->name, &pdev->dev, &spear_rtc_ops, 399 config->rtc = rtc_device_register(pdev->name, &pdev->dev,
381 THIS_MODULE); 400 &spear_rtc_ops, THIS_MODULE);
382 if (IS_ERR(rtc)) { 401 if (IS_ERR(config->rtc)) {
383 dev_err(&pdev->dev, "can't register RTC device, err %ld\n", 402 dev_err(&pdev->dev, "can't register RTC device, err %ld\n",
384 PTR_ERR(rtc)); 403 PTR_ERR(config->rtc));
385 status = PTR_ERR(rtc); 404 status = PTR_ERR(config->rtc);
386 goto err_iounmap; 405 goto err_iounmap;
387 } 406 }
388 407
389 platform_set_drvdata(pdev, rtc);
390 dev_set_drvdata(&rtc->dev, config);
391
392 /* alarm irqs */ 408 /* alarm irqs */
393 irq = platform_get_irq(pdev, 0); 409 irq = platform_get_irq(pdev, 0);
394 if (irq < 0) { 410 if (irq < 0) {
@@ -397,7 +413,7 @@ static int __devinit spear_rtc_probe(struct platform_device *pdev)
397 goto err_clear_platdata; 413 goto err_clear_platdata;
398 } 414 }
399 415
400 status = request_irq(irq, spear_rtc_irq, 0, pdev->name, rtc); 416 status = request_irq(irq, spear_rtc_irq, 0, pdev->name, config);
401 if (status) { 417 if (status) {
402 dev_err(&pdev->dev, "Alarm interrupt IRQ%d already \ 418 dev_err(&pdev->dev, "Alarm interrupt IRQ%d already \
403 claimed\n", irq); 419 claimed\n", irq);
@@ -411,8 +427,7 @@ static int __devinit spear_rtc_probe(struct platform_device *pdev)
411 427
412err_clear_platdata: 428err_clear_platdata:
413 platform_set_drvdata(pdev, NULL); 429 platform_set_drvdata(pdev, NULL);
414 dev_set_drvdata(&rtc->dev, NULL); 430 rtc_device_unregister(config->rtc);
415 rtc_device_unregister(rtc);
416err_iounmap: 431err_iounmap:
417 iounmap(config->ioaddr); 432 iounmap(config->ioaddr);
418err_disable_clock: 433err_disable_clock:
@@ -429,8 +444,7 @@ err_release_region:
429 444
430static int __devexit spear_rtc_remove(struct platform_device *pdev) 445static int __devexit spear_rtc_remove(struct platform_device *pdev)
431{ 446{
432 struct rtc_device *rtc = platform_get_drvdata(pdev); 447 struct spear_rtc_config *config = platform_get_drvdata(pdev);
433 struct spear_rtc_config *config = dev_get_drvdata(&rtc->dev);
434 int irq; 448 int irq;
435 struct resource *res; 449 struct resource *res;
436 450
@@ -448,8 +462,7 @@ static int __devexit spear_rtc_remove(struct platform_device *pdev)
448 if (res) 462 if (res)
449 release_mem_region(res->start, resource_size(res)); 463 release_mem_region(res->start, resource_size(res));
450 platform_set_drvdata(pdev, NULL); 464 platform_set_drvdata(pdev, NULL);
451 dev_set_drvdata(&rtc->dev, NULL); 465 rtc_device_unregister(config->rtc);
452 rtc_device_unregister(rtc);
453 466
454 return 0; 467 return 0;
455} 468}
@@ -458,14 +471,14 @@ static int __devexit spear_rtc_remove(struct platform_device *pdev)
458 471
459static int spear_rtc_suspend(struct platform_device *pdev, pm_message_t state) 472static int spear_rtc_suspend(struct platform_device *pdev, pm_message_t state)
460{ 473{
461 struct rtc_device *rtc = platform_get_drvdata(pdev); 474 struct spear_rtc_config *config = platform_get_drvdata(pdev);
462 struct spear_rtc_config *config = dev_get_drvdata(&rtc->dev);
463 int irq; 475 int irq;
464 476
465 irq = platform_get_irq(pdev, 0); 477 irq = platform_get_irq(pdev, 0);
466 if (device_may_wakeup(&pdev->dev)) 478 if (device_may_wakeup(&pdev->dev)) {
467 enable_irq_wake(irq); 479 if (!enable_irq_wake(irq))
468 else { 480 config->irq_wake = 1;
481 } else {
469 spear_rtc_disable_interrupt(config); 482 spear_rtc_disable_interrupt(config);
470 clk_disable(config->clk); 483 clk_disable(config->clk);
471 } 484 }
@@ -475,15 +488,17 @@ static int spear_rtc_suspend(struct platform_device *pdev, pm_message_t state)
475 488
476static int spear_rtc_resume(struct platform_device *pdev) 489static int spear_rtc_resume(struct platform_device *pdev)
477{ 490{
478 struct rtc_device *rtc = platform_get_drvdata(pdev); 491 struct spear_rtc_config *config = platform_get_drvdata(pdev);
479 struct spear_rtc_config *config = dev_get_drvdata(&rtc->dev);
480 int irq; 492 int irq;
481 493
482 irq = platform_get_irq(pdev, 0); 494 irq = platform_get_irq(pdev, 0);
483 495
484 if (device_may_wakeup(&pdev->dev)) 496 if (device_may_wakeup(&pdev->dev)) {
485 disable_irq_wake(irq); 497 if (config->irq_wake) {
486 else { 498 disable_irq_wake(irq);
499 config->irq_wake = 0;
500 }
501 } else {
487 clk_enable(config->clk); 502 clk_enable(config->clk);
488 spear_rtc_enable_interrupt(config); 503 spear_rtc_enable_interrupt(config);
489 } 504 }
@@ -498,8 +513,7 @@ static int spear_rtc_resume(struct platform_device *pdev)
498 513
499static void spear_rtc_shutdown(struct platform_device *pdev) 514static void spear_rtc_shutdown(struct platform_device *pdev)
500{ 515{
501 struct rtc_device *rtc = platform_get_drvdata(pdev); 516 struct spear_rtc_config *config = platform_get_drvdata(pdev);
502 struct spear_rtc_config *config = dev_get_drvdata(&rtc->dev);
503 517
504 spear_rtc_disable_interrupt(config); 518 spear_rtc_disable_interrupt(config);
505 clk_disable(config->clk); 519 clk_disable(config->clk);
diff --git a/drivers/rtc/rtc-stk17ta8.c b/drivers/rtc/rtc-stk17ta8.c
index 7621116bd20d..279f5cfa691a 100644
--- a/drivers/rtc/rtc-stk17ta8.c
+++ b/drivers/rtc/rtc-stk17ta8.c
@@ -329,7 +329,7 @@ static int __devinit stk17ta8_rtc_probe(struct platform_device *pdev)
329 writeb(0, ioaddr + RTC_INTERRUPTS); 329 writeb(0, ioaddr + RTC_INTERRUPTS);
330 if (devm_request_irq(&pdev->dev, pdata->irq, 330 if (devm_request_irq(&pdev->dev, pdata->irq,
331 stk17ta8_rtc_interrupt, 331 stk17ta8_rtc_interrupt,
332 IRQF_DISABLED | IRQF_SHARED, 332 IRQF_SHARED,
333 pdev->name, pdev) < 0) { 333 pdev->name, pdev) < 0) {
334 dev_warn(&pdev->dev, "interrupt not available.\n"); 334 dev_warn(&pdev->dev, "interrupt not available.\n");
335 pdata->irq = 0; 335 pdata->irq = 0;
diff --git a/drivers/rtc/rtc-twl.c b/drivers/rtc/rtc-twl.c
index d43b4f6eb4e4..4c2c6df2a9ef 100644
--- a/drivers/rtc/rtc-twl.c
+++ b/drivers/rtc/rtc-twl.c
@@ -176,6 +176,10 @@ static int set_rtc_irq_bit(unsigned char bit)
176 unsigned char val; 176 unsigned char val;
177 int ret; 177 int ret;
178 178
179 /* if the bit is set, return from here */
180 if (rtc_irq_bits & bit)
181 return 0;
182
179 val = rtc_irq_bits | bit; 183 val = rtc_irq_bits | bit;
180 val &= ~BIT_RTC_INTERRUPTS_REG_EVERY_M; 184 val &= ~BIT_RTC_INTERRUPTS_REG_EVERY_M;
181 ret = twl_rtc_write_u8(val, REG_RTC_INTERRUPTS_REG); 185 ret = twl_rtc_write_u8(val, REG_RTC_INTERRUPTS_REG);
@@ -193,6 +197,10 @@ static int mask_rtc_irq_bit(unsigned char bit)
193 unsigned char val; 197 unsigned char val;
194 int ret; 198 int ret;
195 199
200 /* if the bit is clear, return from here */
201 if (!(rtc_irq_bits & bit))
202 return 0;
203
196 val = rtc_irq_bits & ~bit; 204 val = rtc_irq_bits & ~bit;
197 ret = twl_rtc_write_u8(val, REG_RTC_INTERRUPTS_REG); 205 ret = twl_rtc_write_u8(val, REG_RTC_INTERRUPTS_REG);
198 if (ret == 0) 206 if (ret == 0)
@@ -357,7 +365,7 @@ out:
357 365
358static irqreturn_t twl_rtc_interrupt(int irq, void *rtc) 366static irqreturn_t twl_rtc_interrupt(int irq, void *rtc)
359{ 367{
360 unsigned long events = 0; 368 unsigned long events;
361 int ret = IRQ_NONE; 369 int ret = IRQ_NONE;
362 int res; 370 int res;
363 u8 rd_reg; 371 u8 rd_reg;
@@ -372,11 +380,11 @@ static irqreturn_t twl_rtc_interrupt(int irq, void *rtc)
372 * by reading RTS_INTERRUPTS_REGISTER[IT_TIMER,IT_ALARM] 380 * by reading RTS_INTERRUPTS_REGISTER[IT_TIMER,IT_ALARM]
373 */ 381 */
374 if (rd_reg & BIT_RTC_STATUS_REG_ALARM_M) 382 if (rd_reg & BIT_RTC_STATUS_REG_ALARM_M)
375 events |= RTC_IRQF | RTC_AF; 383 events = RTC_IRQF | RTC_AF;
376 else 384 else
377 events |= RTC_IRQF | RTC_UF; 385 events = RTC_IRQF | RTC_PF;
378 386
379 res = twl_rtc_write_u8(rd_reg | BIT_RTC_STATUS_REG_ALARM_M, 387 res = twl_rtc_write_u8(BIT_RTC_STATUS_REG_ALARM_M,
380 REG_RTC_STATUS_REG); 388 REG_RTC_STATUS_REG);
381 if (res) 389 if (res)
382 goto out; 390 goto out;
@@ -449,19 +457,11 @@ static int __devinit twl_rtc_probe(struct platform_device *pdev)
449 REG_INT_MSK_STS_A); 457 REG_INT_MSK_STS_A);
450 } 458 }
451 459
452 /* Check RTC module status, Enable if it is off */ 460 dev_info(&pdev->dev, "Enabling TWL-RTC\n");
453 ret = twl_rtc_read_u8(&rd_reg, REG_RTC_CTRL_REG); 461 ret = twl_rtc_write_u8(BIT_RTC_CTRL_REG_STOP_RTC_M, REG_RTC_CTRL_REG);
454 if (ret < 0) 462 if (ret < 0)
455 goto out1; 463 goto out1;
456 464
457 if (!(rd_reg & BIT_RTC_CTRL_REG_STOP_RTC_M)) {
458 dev_info(&pdev->dev, "Enabling TWL-RTC.\n");
459 rd_reg = BIT_RTC_CTRL_REG_STOP_RTC_M;
460 ret = twl_rtc_write_u8(rd_reg, REG_RTC_CTRL_REG);
461 if (ret < 0)
462 goto out1;
463 }
464
465 /* init cached IRQ enable bits */ 465 /* init cached IRQ enable bits */
466 ret = twl_rtc_read_u8(&rtc_irq_bits, REG_RTC_INTERRUPTS_REG); 466 ret = twl_rtc_read_u8(&rtc_irq_bits, REG_RTC_INTERRUPTS_REG);
467 if (ret < 0) 467 if (ret < 0)
diff --git a/drivers/rtc/rtc-tx4939.c b/drivers/rtc/rtc-tx4939.c
index aac0ffed4345..a12bfac49d36 100644
--- a/drivers/rtc/rtc-tx4939.c
+++ b/drivers/rtc/rtc-tx4939.c
@@ -266,7 +266,7 @@ static int __init tx4939_rtc_probe(struct platform_device *pdev)
266 spin_lock_init(&pdata->lock); 266 spin_lock_init(&pdata->lock);
267 tx4939_rtc_cmd(pdata->rtcreg, TX4939_RTCCTL_COMMAND_NOP); 267 tx4939_rtc_cmd(pdata->rtcreg, TX4939_RTCCTL_COMMAND_NOP);
268 if (devm_request_irq(&pdev->dev, irq, tx4939_rtc_interrupt, 268 if (devm_request_irq(&pdev->dev, irq, tx4939_rtc_interrupt,
269 IRQF_DISABLED, pdev->name, &pdev->dev) < 0) 269 0, pdev->name, &pdev->dev) < 0)
270 return -EBUSY; 270 return -EBUSY;
271 rtc = rtc_device_register(pdev->name, &pdev->dev, 271 rtc = rtc_device_register(pdev->name, &pdev->dev,
272 &tx4939_rtc_ops, THIS_MODULE); 272 &tx4939_rtc_ops, THIS_MODULE);
diff --git a/drivers/rtc/rtc-vr41xx.c b/drivers/rtc/rtc-vr41xx.c
index fcbfdda2993b..5f60a7c6a155 100644
--- a/drivers/rtc/rtc-vr41xx.c
+++ b/drivers/rtc/rtc-vr41xx.c
@@ -333,7 +333,7 @@ static int __devinit rtc_probe(struct platform_device *pdev)
333 goto err_device_unregister; 333 goto err_device_unregister;
334 } 334 }
335 335
336 retval = request_irq(aie_irq, elapsedtime_interrupt, IRQF_DISABLED, 336 retval = request_irq(aie_irq, elapsedtime_interrupt, 0,
337 "elapsed_time", pdev); 337 "elapsed_time", pdev);
338 if (retval < 0) 338 if (retval < 0)
339 goto err_device_unregister; 339 goto err_device_unregister;
@@ -342,7 +342,7 @@ static int __devinit rtc_probe(struct platform_device *pdev)
342 if (pie_irq <= 0) 342 if (pie_irq <= 0)
343 goto err_free_irq; 343 goto err_free_irq;
344 344
345 retval = request_irq(pie_irq, rtclong1_interrupt, IRQF_DISABLED, 345 retval = request_irq(pie_irq, rtclong1_interrupt, 0,
346 "rtclong1", pdev); 346 "rtclong1", pdev);
347 if (retval < 0) 347 if (retval < 0)
348 goto err_free_irq; 348 goto err_free_irq;
diff --git a/drivers/rtc/rtc-x1205.c b/drivers/rtc/rtc-x1205.c
index 8c051d3179db..403b3d41d101 100644
--- a/drivers/rtc/rtc-x1205.c
+++ b/drivers/rtc/rtc-x1205.c
@@ -623,15 +623,7 @@ static struct i2c_driver x1205_driver = {
623 .id_table = x1205_id, 623 .id_table = x1205_id,
624}; 624};
625 625
626static int __init x1205_init(void) 626module_i2c_driver(x1205_driver);
627{
628 return i2c_add_driver(&x1205_driver);
629}
630
631static void __exit x1205_exit(void)
632{
633 i2c_del_driver(&x1205_driver);
634}
635 627
636MODULE_AUTHOR( 628MODULE_AUTHOR(
637 "Karen Spearel <kas111 at gmail dot com>, " 629 "Karen Spearel <kas111 at gmail dot com>, "
@@ -639,6 +631,3 @@ MODULE_AUTHOR(
639MODULE_DESCRIPTION("Xicor/Intersil X1205 RTC driver"); 631MODULE_DESCRIPTION("Xicor/Intersil X1205 RTC driver");
640MODULE_LICENSE("GPL"); 632MODULE_LICENSE("GPL");
641MODULE_VERSION(DRV_VERSION); 633MODULE_VERSION(DRV_VERSION);
642
643module_init(x1205_init);
644module_exit(x1205_exit);
diff --git a/drivers/s390/char/sclp_cmd.c b/drivers/s390/char/sclp_cmd.c
index 0b54a91f8dcd..168525a9c292 100644
--- a/drivers/s390/char/sclp_cmd.c
+++ b/drivers/s390/char/sclp_cmd.c
@@ -441,9 +441,8 @@ static int sclp_mem_notifier(struct notifier_block *nb,
441 start = arg->start_pfn << PAGE_SHIFT; 441 start = arg->start_pfn << PAGE_SHIFT;
442 size = arg->nr_pages << PAGE_SHIFT; 442 size = arg->nr_pages << PAGE_SHIFT;
443 mutex_lock(&sclp_mem_mutex); 443 mutex_lock(&sclp_mem_mutex);
444 for (id = 0; id <= sclp_max_storage_id; id++) 444 for_each_clear_bit(id, sclp_storage_ids, sclp_max_storage_id + 1)
445 if (!test_bit(id, sclp_storage_ids)) 445 sclp_attach_storage(id);
446 sclp_attach_storage(id);
447 switch (action) { 446 switch (action) {
448 case MEM_ONLINE: 447 case MEM_ONLINE:
449 case MEM_GOING_OFFLINE: 448 case MEM_GOING_OFFLINE:
diff --git a/drivers/staging/rtl8187se/r8180_core.c b/drivers/staging/rtl8187se/r8180_core.c
index e4ade550cfe5..4fe52f6b0034 100644
--- a/drivers/staging/rtl8187se/r8180_core.c
+++ b/drivers/staging/rtl8187se/r8180_core.c
@@ -4159,7 +4159,7 @@ void GPIOChangeRFWorkItemCallBack(struct work_struct *work)
4159 argv[0] = RadioPowerPath; 4159 argv[0] = RadioPowerPath;
4160 argv[2] = NULL; 4160 argv[2] = NULL;
4161 4161
4162 call_usermodehelper(RadioPowerPath, argv, envp, 1); 4162 call_usermodehelper(RadioPowerPath, argv, envp, UMH_WAIT_PROC);
4163 } 4163 }
4164} 4164}
4165 4165
diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c b/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c
index a7fa9aad6f2d..f026b7171f62 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c
@@ -208,7 +208,7 @@ static void dm_check_ac_dc_power(struct net_device *dev)
208 208
209 if (priv->rtllib->state != RTLLIB_LINKED) 209 if (priv->rtllib->state != RTLLIB_LINKED)
210 return; 210 return;
211 call_usermodehelper(ac_dc_check_script_path, argv, envp, 1); 211 call_usermodehelper(ac_dc_check_script_path, argv, envp, UMH_WAIT_PROC);
212 212
213 return; 213 return;
214}; 214};
@@ -2296,7 +2296,7 @@ void dm_CheckRfCtrlGPIO(void *data)
2296 2296
2297 argv[0] = RadioPowerPath; 2297 argv[0] = RadioPowerPath;
2298 argv[2] = NULL; 2298 argv[2] = NULL;
2299 call_usermodehelper(RadioPowerPath, argv, envp, 1); 2299 call_usermodehelper(RadioPowerPath, argv, envp, UMH_WAIT_PROC);
2300 } 2300 }
2301} 2301}
2302 2302
diff --git a/drivers/staging/telephony/ixj.c b/drivers/staging/telephony/ixj.c
index d5f923bcdffe..f96027921f60 100644
--- a/drivers/staging/telephony/ixj.c
+++ b/drivers/staging/telephony/ixj.c
@@ -5927,7 +5927,8 @@ static void add_caps(IXJ *j)
5927 j->caplist[j->caps].cap = PHONE_VENDOR_QUICKNET; 5927 j->caplist[j->caps].cap = PHONE_VENDOR_QUICKNET;
5928 strcpy(j->caplist[j->caps].desc, "Quicknet Technologies, Inc. (www.quicknet.net)"); 5928 strcpy(j->caplist[j->caps].desc, "Quicknet Technologies, Inc. (www.quicknet.net)");
5929 j->caplist[j->caps].captype = vendor; 5929 j->caplist[j->caps].captype = vendor;
5930 j->caplist[j->caps].handle = j->caps++; 5930 j->caplist[j->caps].handle = j->caps;
5931 j->caps++;
5931 j->caplist[j->caps].captype = device; 5932 j->caplist[j->caps].captype = device;
5932 switch (j->cardtype) { 5933 switch (j->cardtype) {
5933 case QTI_PHONEJACK: 5934 case QTI_PHONEJACK:
@@ -5947,11 +5948,13 @@ static void add_caps(IXJ *j)
5947 break; 5948 break;
5948 } 5949 }
5949 j->caplist[j->caps].cap = j->cardtype; 5950 j->caplist[j->caps].cap = j->cardtype;
5950 j->caplist[j->caps].handle = j->caps++; 5951 j->caplist[j->caps].handle = j->caps;
5952 j->caps++;
5951 strcpy(j->caplist[j->caps].desc, "POTS"); 5953 strcpy(j->caplist[j->caps].desc, "POTS");
5952 j->caplist[j->caps].captype = port; 5954 j->caplist[j->caps].captype = port;
5953 j->caplist[j->caps].cap = pots; 5955 j->caplist[j->caps].cap = pots;
5954 j->caplist[j->caps].handle = j->caps++; 5956 j->caplist[j->caps].handle = j->caps;
5957 j->caps++;
5955 5958
5956 /* add devices that can do speaker/mic */ 5959 /* add devices that can do speaker/mic */
5957 switch (j->cardtype) { 5960 switch (j->cardtype) {
@@ -5962,7 +5965,8 @@ static void add_caps(IXJ *j)
5962 strcpy(j->caplist[j->caps].desc, "SPEAKER"); 5965 strcpy(j->caplist[j->caps].desc, "SPEAKER");
5963 j->caplist[j->caps].captype = port; 5966 j->caplist[j->caps].captype = port;
5964 j->caplist[j->caps].cap = speaker; 5967 j->caplist[j->caps].cap = speaker;
5965 j->caplist[j->caps].handle = j->caps++; 5968 j->caplist[j->caps].handle = j->caps;
5969 j->caps++;
5966 default: 5970 default:
5967 break; 5971 break;
5968 } 5972 }
@@ -5973,7 +5977,8 @@ static void add_caps(IXJ *j)
5973 strcpy(j->caplist[j->caps].desc, "HANDSET"); 5977 strcpy(j->caplist[j->caps].desc, "HANDSET");
5974 j->caplist[j->caps].captype = port; 5978 j->caplist[j->caps].captype = port;
5975 j->caplist[j->caps].cap = handset; 5979 j->caplist[j->caps].cap = handset;
5976 j->caplist[j->caps].handle = j->caps++; 5980 j->caplist[j->caps].handle = j->caps;
5981 j->caps++;
5977 break; 5982 break;
5978 default: 5983 default:
5979 break; 5984 break;
@@ -5985,7 +5990,8 @@ static void add_caps(IXJ *j)
5985 strcpy(j->caplist[j->caps].desc, "PSTN"); 5990 strcpy(j->caplist[j->caps].desc, "PSTN");
5986 j->caplist[j->caps].captype = port; 5991 j->caplist[j->caps].captype = port;
5987 j->caplist[j->caps].cap = pstn; 5992 j->caplist[j->caps].cap = pstn;
5988 j->caplist[j->caps].handle = j->caps++; 5993 j->caplist[j->caps].handle = j->caps;
5994 j->caps++;
5989 break; 5995 break;
5990 default: 5996 default:
5991 break; 5997 break;
@@ -5995,50 +6001,59 @@ static void add_caps(IXJ *j)
5995 strcpy(j->caplist[j->caps].desc, "ULAW"); 6001 strcpy(j->caplist[j->caps].desc, "ULAW");
5996 j->caplist[j->caps].captype = codec; 6002 j->caplist[j->caps].captype = codec;
5997 j->caplist[j->caps].cap = ULAW; 6003 j->caplist[j->caps].cap = ULAW;
5998 j->caplist[j->caps].handle = j->caps++; 6004 j->caplist[j->caps].handle = j->caps;
6005 j->caps++;
5999 6006
6000 strcpy(j->caplist[j->caps].desc, "LINEAR 16 bit"); 6007 strcpy(j->caplist[j->caps].desc, "LINEAR 16 bit");
6001 j->caplist[j->caps].captype = codec; 6008 j->caplist[j->caps].captype = codec;
6002 j->caplist[j->caps].cap = LINEAR16; 6009 j->caplist[j->caps].cap = LINEAR16;
6003 j->caplist[j->caps].handle = j->caps++; 6010 j->caplist[j->caps].handle = j->caps;
6011 j->caps++;
6004 6012
6005 strcpy(j->caplist[j->caps].desc, "LINEAR 8 bit"); 6013 strcpy(j->caplist[j->caps].desc, "LINEAR 8 bit");
6006 j->caplist[j->caps].captype = codec; 6014 j->caplist[j->caps].captype = codec;
6007 j->caplist[j->caps].cap = LINEAR8; 6015 j->caplist[j->caps].cap = LINEAR8;
6008 j->caplist[j->caps].handle = j->caps++; 6016 j->caplist[j->caps].handle = j->caps;
6017 j->caps++;
6009 6018
6010 strcpy(j->caplist[j->caps].desc, "Windows Sound System"); 6019 strcpy(j->caplist[j->caps].desc, "Windows Sound System");
6011 j->caplist[j->caps].captype = codec; 6020 j->caplist[j->caps].captype = codec;
6012 j->caplist[j->caps].cap = WSS; 6021 j->caplist[j->caps].cap = WSS;
6013 j->caplist[j->caps].handle = j->caps++; 6022 j->caplist[j->caps].handle = j->caps;
6023 j->caps++;
6014 6024
6015 /* software ALAW codec, made from ULAW */ 6025 /* software ALAW codec, made from ULAW */
6016 strcpy(j->caplist[j->caps].desc, "ALAW"); 6026 strcpy(j->caplist[j->caps].desc, "ALAW");
6017 j->caplist[j->caps].captype = codec; 6027 j->caplist[j->caps].captype = codec;
6018 j->caplist[j->caps].cap = ALAW; 6028 j->caplist[j->caps].cap = ALAW;
6019 j->caplist[j->caps].handle = j->caps++; 6029 j->caplist[j->caps].handle = j->caps;
6030 j->caps++;
6020 6031
6021 /* version 12 of the 8020 does the following codecs in a broken way */ 6032 /* version 12 of the 8020 does the following codecs in a broken way */
6022 if (j->dsp.low != 0x20 || j->ver.low != 0x12) { 6033 if (j->dsp.low != 0x20 || j->ver.low != 0x12) {
6023 strcpy(j->caplist[j->caps].desc, "G.723.1 6.3kbps"); 6034 strcpy(j->caplist[j->caps].desc, "G.723.1 6.3kbps");
6024 j->caplist[j->caps].captype = codec; 6035 j->caplist[j->caps].captype = codec;
6025 j->caplist[j->caps].cap = G723_63; 6036 j->caplist[j->caps].cap = G723_63;
6026 j->caplist[j->caps].handle = j->caps++; 6037 j->caplist[j->caps].handle = j->caps;
6038 j->caps++;
6027 6039
6028 strcpy(j->caplist[j->caps].desc, "G.723.1 5.3kbps"); 6040 strcpy(j->caplist[j->caps].desc, "G.723.1 5.3kbps");
6029 j->caplist[j->caps].captype = codec; 6041 j->caplist[j->caps].captype = codec;
6030 j->caplist[j->caps].cap = G723_53; 6042 j->caplist[j->caps].cap = G723_53;
6031 j->caplist[j->caps].handle = j->caps++; 6043 j->caplist[j->caps].handle = j->caps;
6044 j->caps++;
6032 6045
6033 strcpy(j->caplist[j->caps].desc, "TrueSpeech 4.8kbps"); 6046 strcpy(j->caplist[j->caps].desc, "TrueSpeech 4.8kbps");
6034 j->caplist[j->caps].captype = codec; 6047 j->caplist[j->caps].captype = codec;
6035 j->caplist[j->caps].cap = TS48; 6048 j->caplist[j->caps].cap = TS48;
6036 j->caplist[j->caps].handle = j->caps++; 6049 j->caplist[j->caps].handle = j->caps;
6050 j->caps++;
6037 6051
6038 strcpy(j->caplist[j->caps].desc, "TrueSpeech 4.1kbps"); 6052 strcpy(j->caplist[j->caps].desc, "TrueSpeech 4.1kbps");
6039 j->caplist[j->caps].captype = codec; 6053 j->caplist[j->caps].captype = codec;
6040 j->caplist[j->caps].cap = TS41; 6054 j->caplist[j->caps].cap = TS41;
6041 j->caplist[j->caps].handle = j->caps++; 6055 j->caplist[j->caps].handle = j->caps;
6056 j->caps++;
6042 } 6057 }
6043 6058
6044 /* 8020 chips can do TS8.5 native, and 8021/8022 can load it */ 6059 /* 8020 chips can do TS8.5 native, and 8021/8022 can load it */
@@ -6046,7 +6061,8 @@ static void add_caps(IXJ *j)
6046 strcpy(j->caplist[j->caps].desc, "TrueSpeech 8.5kbps"); 6061 strcpy(j->caplist[j->caps].desc, "TrueSpeech 8.5kbps");
6047 j->caplist[j->caps].captype = codec; 6062 j->caplist[j->caps].captype = codec;
6048 j->caplist[j->caps].cap = TS85; 6063 j->caplist[j->caps].cap = TS85;
6049 j->caplist[j->caps].handle = j->caps++; 6064 j->caplist[j->caps].handle = j->caps;
6065 j->caps++;
6050 } 6066 }
6051 6067
6052 /* 8021 chips can do G728 */ 6068 /* 8021 chips can do G728 */
@@ -6054,7 +6070,8 @@ static void add_caps(IXJ *j)
6054 strcpy(j->caplist[j->caps].desc, "G.728 16kbps"); 6070 strcpy(j->caplist[j->caps].desc, "G.728 16kbps");
6055 j->caplist[j->caps].captype = codec; 6071 j->caplist[j->caps].captype = codec;
6056 j->caplist[j->caps].cap = G728; 6072 j->caplist[j->caps].cap = G728;
6057 j->caplist[j->caps].handle = j->caps++; 6073 j->caplist[j->caps].handle = j->caps;
6074 j->caps++;
6058 } 6075 }
6059 6076
6060 /* 8021/8022 chips can do G729 if loaded */ 6077 /* 8021/8022 chips can do G729 if loaded */
@@ -6062,13 +6079,15 @@ static void add_caps(IXJ *j)
6062 strcpy(j->caplist[j->caps].desc, "G.729A 8kbps"); 6079 strcpy(j->caplist[j->caps].desc, "G.729A 8kbps");
6063 j->caplist[j->caps].captype = codec; 6080 j->caplist[j->caps].captype = codec;
6064 j->caplist[j->caps].cap = G729; 6081 j->caplist[j->caps].cap = G729;
6065 j->caplist[j->caps].handle = j->caps++; 6082 j->caplist[j->caps].handle = j->caps;
6083 j->caps++;
6066 } 6084 }
6067 if (j->dsp.low != 0x20 && j->flags.g729_loaded) { 6085 if (j->dsp.low != 0x20 && j->flags.g729_loaded) {
6068 strcpy(j->caplist[j->caps].desc, "G.729B 8kbps"); 6086 strcpy(j->caplist[j->caps].desc, "G.729B 8kbps");
6069 j->caplist[j->caps].captype = codec; 6087 j->caplist[j->caps].captype = codec;
6070 j->caplist[j->caps].cap = G729B; 6088 j->caplist[j->caps].cap = G729B;
6071 j->caplist[j->caps].handle = j->caps++; 6089 j->caplist[j->caps].handle = j->caps;
6090 j->caps++;
6072 } 6091 }
6073} 6092}
6074 6093
diff --git a/drivers/uwb/allocator.c b/drivers/uwb/allocator.c
index e45e673b8770..6e3e713f0ef7 100644
--- a/drivers/uwb/allocator.c
+++ b/drivers/uwb/allocator.c
@@ -334,10 +334,8 @@ int uwb_rsv_find_best_allocation(struct uwb_rsv *rsv, struct uwb_mas_bm *availab
334 334
335 335
336 /* fill the not available vector from the available bm */ 336 /* fill the not available vector from the available bm */
337 for (bit_index = 0; bit_index < UWB_NUM_MAS; bit_index++) { 337 for_each_clear_bit(bit_index, available->bm, UWB_NUM_MAS)
338 if (!test_bit(bit_index, available->bm)) 338 ai->bm[bit_index] = UWB_RSV_MAS_NOT_AVAIL;
339 ai->bm[bit_index] = UWB_RSV_MAS_NOT_AVAIL;
340 }
341 339
342 if (ai->max_interval == 1) { 340 if (ai->max_interval == 1) {
343 get_row_descriptors(ai); 341 get_row_descriptors(ai);
diff --git a/drivers/video/backlight/88pm860x_bl.c b/drivers/video/backlight/88pm860x_bl.c
index a1376dc73d71..915943af3f21 100644
--- a/drivers/video/backlight/88pm860x_bl.c
+++ b/drivers/video/backlight/88pm860x_bl.c
@@ -187,7 +187,8 @@ static int pm860x_backlight_probe(struct platform_device *pdev)
187 return -EINVAL; 187 return -EINVAL;
188 } 188 }
189 189
190 data = kzalloc(sizeof(struct pm860x_backlight_data), GFP_KERNEL); 190 data = devm_kzalloc(&pdev->dev, sizeof(struct pm860x_backlight_data),
191 GFP_KERNEL);
191 if (data == NULL) 192 if (data == NULL)
192 return -ENOMEM; 193 return -ENOMEM;
193 strncpy(name, res->name, MFD_NAME_SIZE); 194 strncpy(name, res->name, MFD_NAME_SIZE);
@@ -200,7 +201,6 @@ static int pm860x_backlight_probe(struct platform_device *pdev)
200 data->port = pdata->flags; 201 data->port = pdata->flags;
201 if (data->port < 0) { 202 if (data->port < 0) {
202 dev_err(&pdev->dev, "wrong platform data is assigned"); 203 dev_err(&pdev->dev, "wrong platform data is assigned");
203 kfree(data);
204 return -EINVAL; 204 return -EINVAL;
205 } 205 }
206 206
@@ -211,7 +211,6 @@ static int pm860x_backlight_probe(struct platform_device *pdev)
211 &pm860x_backlight_ops, &props); 211 &pm860x_backlight_ops, &props);
212 if (IS_ERR(bl)) { 212 if (IS_ERR(bl)) {
213 dev_err(&pdev->dev, "failed to register backlight\n"); 213 dev_err(&pdev->dev, "failed to register backlight\n");
214 kfree(data);
215 return PTR_ERR(bl); 214 return PTR_ERR(bl);
216 } 215 }
217 bl->props.brightness = MAX_BRIGHTNESS; 216 bl->props.brightness = MAX_BRIGHTNESS;
@@ -247,17 +246,14 @@ static int pm860x_backlight_probe(struct platform_device *pdev)
247 return 0; 246 return 0;
248out: 247out:
249 backlight_device_unregister(bl); 248 backlight_device_unregister(bl);
250 kfree(data);
251 return ret; 249 return ret;
252} 250}
253 251
254static int pm860x_backlight_remove(struct platform_device *pdev) 252static int pm860x_backlight_remove(struct platform_device *pdev)
255{ 253{
256 struct backlight_device *bl = platform_get_drvdata(pdev); 254 struct backlight_device *bl = platform_get_drvdata(pdev);
257 struct pm860x_backlight_data *data = bl_get_data(bl);
258 255
259 backlight_device_unregister(bl); 256 backlight_device_unregister(bl);
260 kfree(data);
261 return 0; 257 return 0;
262} 258}
263 259
diff --git a/drivers/video/backlight/Kconfig b/drivers/video/backlight/Kconfig
index 681b36929fe4..7ed9991fa747 100644
--- a/drivers/video/backlight/Kconfig
+++ b/drivers/video/backlight/Kconfig
@@ -334,6 +334,27 @@ config BACKLIGHT_AAT2870
334 If you have a AnalogicTech AAT2870 say Y to enable the 334 If you have a AnalogicTech AAT2870 say Y to enable the
335 backlight driver. 335 backlight driver.
336 336
337config BACKLIGHT_LP855X
338 tristate "Backlight driver for TI LP855X"
339 depends on BACKLIGHT_CLASS_DEVICE && I2C
340 help
341 This supports TI LP8550, LP8551, LP8552, LP8553 and LP8556
342 backlight driver.
343
344config BACKLIGHT_OT200
345 tristate "Backlight driver for ot200 visualisation device"
346 depends on BACKLIGHT_CLASS_DEVICE && CS5535_MFGPT && GPIO_CS5535
347 help
348 To compile this driver as a module, choose M here: the module will be
349 called ot200_bl.
350
351config BACKLIGHT_PANDORA
352 tristate "Backlight driver for Pandora console"
353 depends on TWL4030_CORE
354 help
355 If you have a Pandora console, say Y to enable the
356 backlight driver.
357
337endif # BACKLIGHT_CLASS_DEVICE 358endif # BACKLIGHT_CLASS_DEVICE
338 359
339endif # BACKLIGHT_LCD_SUPPORT 360endif # BACKLIGHT_LCD_SUPPORT
diff --git a/drivers/video/backlight/Makefile b/drivers/video/backlight/Makefile
index af5cf654ec7c..8071eb656147 100644
--- a/drivers/video/backlight/Makefile
+++ b/drivers/video/backlight/Makefile
@@ -22,7 +22,9 @@ obj-$(CONFIG_BACKLIGHT_GENERIC) += generic_bl.o
22obj-$(CONFIG_BACKLIGHT_HP700) += jornada720_bl.o 22obj-$(CONFIG_BACKLIGHT_HP700) += jornada720_bl.o
23obj-$(CONFIG_BACKLIGHT_HP680) += hp680_bl.o 23obj-$(CONFIG_BACKLIGHT_HP680) += hp680_bl.o
24obj-$(CONFIG_BACKLIGHT_LOCOMO) += locomolcd.o 24obj-$(CONFIG_BACKLIGHT_LOCOMO) += locomolcd.o
25obj-$(CONFIG_BACKLIGHT_LP855X) += lp855x_bl.o
25obj-$(CONFIG_BACKLIGHT_OMAP1) += omap1_bl.o 26obj-$(CONFIG_BACKLIGHT_OMAP1) += omap1_bl.o
27obj-$(CONFIG_BACKLIGHT_PANDORA) += pandora_bl.o
26obj-$(CONFIG_BACKLIGHT_PROGEAR) += progear_bl.o 28obj-$(CONFIG_BACKLIGHT_PROGEAR) += progear_bl.o
27obj-$(CONFIG_BACKLIGHT_CARILLO_RANCH) += cr_bllcd.o 29obj-$(CONFIG_BACKLIGHT_CARILLO_RANCH) += cr_bllcd.o
28obj-$(CONFIG_BACKLIGHT_PWM) += pwm_bl.o 30obj-$(CONFIG_BACKLIGHT_PWM) += pwm_bl.o
@@ -38,4 +40,4 @@ obj-$(CONFIG_BACKLIGHT_ADP8870) += adp8870_bl.o
38obj-$(CONFIG_BACKLIGHT_88PM860X) += 88pm860x_bl.o 40obj-$(CONFIG_BACKLIGHT_88PM860X) += 88pm860x_bl.o
39obj-$(CONFIG_BACKLIGHT_PCF50633) += pcf50633-backlight.o 41obj-$(CONFIG_BACKLIGHT_PCF50633) += pcf50633-backlight.o
40obj-$(CONFIG_BACKLIGHT_AAT2870) += aat2870_bl.o 42obj-$(CONFIG_BACKLIGHT_AAT2870) += aat2870_bl.o
41 43obj-$(CONFIG_BACKLIGHT_OT200) += ot200_bl.o
diff --git a/drivers/video/backlight/aat2870_bl.c b/drivers/video/backlight/aat2870_bl.c
index 331f1ef1dad5..7ff752288b92 100644
--- a/drivers/video/backlight/aat2870_bl.c
+++ b/drivers/video/backlight/aat2870_bl.c
@@ -145,7 +145,9 @@ static int aat2870_bl_probe(struct platform_device *pdev)
145 goto out; 145 goto out;
146 } 146 }
147 147
148 aat2870_bl = kzalloc(sizeof(struct aat2870_bl_driver_data), GFP_KERNEL); 148 aat2870_bl = devm_kzalloc(&pdev->dev,
149 sizeof(struct aat2870_bl_driver_data),
150 GFP_KERNEL);
149 if (!aat2870_bl) { 151 if (!aat2870_bl) {
150 dev_err(&pdev->dev, 152 dev_err(&pdev->dev,
151 "Failed to allocate memory for aat2870 backlight\n"); 153 "Failed to allocate memory for aat2870 backlight\n");
@@ -162,7 +164,7 @@ static int aat2870_bl_probe(struct platform_device *pdev)
162 dev_err(&pdev->dev, 164 dev_err(&pdev->dev,
163 "Failed allocate memory for backlight device\n"); 165 "Failed allocate memory for backlight device\n");
164 ret = PTR_ERR(bd); 166 ret = PTR_ERR(bd);
165 goto out_kfree; 167 goto out;
166 } 168 }
167 169
168 aat2870_bl->pdev = pdev; 170 aat2870_bl->pdev = pdev;
@@ -199,8 +201,6 @@ static int aat2870_bl_probe(struct platform_device *pdev)
199 201
200out_bl_dev_unregister: 202out_bl_dev_unregister:
201 backlight_device_unregister(bd); 203 backlight_device_unregister(bd);
202out_kfree:
203 kfree(aat2870_bl);
204out: 204out:
205 return ret; 205 return ret;
206} 206}
@@ -215,7 +215,6 @@ static int aat2870_bl_remove(struct platform_device *pdev)
215 backlight_update_status(bd); 215 backlight_update_status(bd);
216 216
217 backlight_device_unregister(bd); 217 backlight_device_unregister(bd);
218 kfree(aat2870_bl);
219 218
220 return 0; 219 return 0;
221} 220}
diff --git a/drivers/video/backlight/adp5520_bl.c b/drivers/video/backlight/adp5520_bl.c
index 2e630bf1164c..4911ea7989c8 100644
--- a/drivers/video/backlight/adp5520_bl.c
+++ b/drivers/video/backlight/adp5520_bl.c
@@ -289,7 +289,7 @@ static int __devinit adp5520_bl_probe(struct platform_device *pdev)
289 struct adp5520_bl *data; 289 struct adp5520_bl *data;
290 int ret = 0; 290 int ret = 0;
291 291
292 data = kzalloc(sizeof(*data), GFP_KERNEL); 292 data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
293 if (data == NULL) 293 if (data == NULL)
294 return -ENOMEM; 294 return -ENOMEM;
295 295
@@ -298,7 +298,6 @@ static int __devinit adp5520_bl_probe(struct platform_device *pdev)
298 298
299 if (data->pdata == NULL) { 299 if (data->pdata == NULL) {
300 dev_err(&pdev->dev, "missing platform data\n"); 300 dev_err(&pdev->dev, "missing platform data\n");
301 kfree(data);
302 return -ENODEV; 301 return -ENODEV;
303 } 302 }
304 303
@@ -314,7 +313,6 @@ static int __devinit adp5520_bl_probe(struct platform_device *pdev)
314 &adp5520_bl_ops, &props); 313 &adp5520_bl_ops, &props);
315 if (IS_ERR(bl)) { 314 if (IS_ERR(bl)) {
316 dev_err(&pdev->dev, "failed to register backlight\n"); 315 dev_err(&pdev->dev, "failed to register backlight\n");
317 kfree(data);
318 return PTR_ERR(bl); 316 return PTR_ERR(bl);
319 } 317 }
320 318
@@ -326,7 +324,6 @@ static int __devinit adp5520_bl_probe(struct platform_device *pdev)
326 if (ret) { 324 if (ret) {
327 dev_err(&pdev->dev, "failed to register sysfs\n"); 325 dev_err(&pdev->dev, "failed to register sysfs\n");
328 backlight_device_unregister(bl); 326 backlight_device_unregister(bl);
329 kfree(data);
330 } 327 }
331 328
332 platform_set_drvdata(pdev, bl); 329 platform_set_drvdata(pdev, bl);
@@ -348,7 +345,6 @@ static int __devexit adp5520_bl_remove(struct platform_device *pdev)
348 &adp5520_bl_attr_group); 345 &adp5520_bl_attr_group);
349 346
350 backlight_device_unregister(bl); 347 backlight_device_unregister(bl);
351 kfree(data);
352 348
353 return 0; 349 return 0;
354} 350}
diff --git a/drivers/video/backlight/adp8860_bl.c b/drivers/video/backlight/adp8860_bl.c
index 378276c9d3cf..550dbf0bb896 100644
--- a/drivers/video/backlight/adp8860_bl.c
+++ b/drivers/video/backlight/adp8860_bl.c
@@ -819,17 +819,7 @@ static struct i2c_driver adp8860_driver = {
819 .id_table = adp8860_id, 819 .id_table = adp8860_id,
820}; 820};
821 821
822static int __init adp8860_init(void) 822module_i2c_driver(adp8860_driver);
823{
824 return i2c_add_driver(&adp8860_driver);
825}
826module_init(adp8860_init);
827
828static void __exit adp8860_exit(void)
829{
830 i2c_del_driver(&adp8860_driver);
831}
832module_exit(adp8860_exit);
833 823
834MODULE_LICENSE("GPL v2"); 824MODULE_LICENSE("GPL v2");
835MODULE_AUTHOR("Michael Hennerich <hennerich@blackfin.uclinux.org>"); 825MODULE_AUTHOR("Michael Hennerich <hennerich@blackfin.uclinux.org>");
diff --git a/drivers/video/backlight/adp8870_bl.c b/drivers/video/backlight/adp8870_bl.c
index 6735059376d6..9be58c6f18f1 100644
--- a/drivers/video/backlight/adp8870_bl.c
+++ b/drivers/video/backlight/adp8870_bl.c
@@ -991,17 +991,7 @@ static struct i2c_driver adp8870_driver = {
991 .id_table = adp8870_id, 991 .id_table = adp8870_id,
992}; 992};
993 993
994static int __init adp8870_init(void) 994module_i2c_driver(adp8870_driver);
995{
996 return i2c_add_driver(&adp8870_driver);
997}
998module_init(adp8870_init);
999
1000static void __exit adp8870_exit(void)
1001{
1002 i2c_del_driver(&adp8870_driver);
1003}
1004module_exit(adp8870_exit);
1005 995
1006MODULE_LICENSE("GPL v2"); 996MODULE_LICENSE("GPL v2");
1007MODULE_AUTHOR("Michael Hennerich <hennerich@blackfin.uclinux.org>"); 997MODULE_AUTHOR("Michael Hennerich <hennerich@blackfin.uclinux.org>");
diff --git a/drivers/video/backlight/ams369fg06.c b/drivers/video/backlight/ams369fg06.c
index 7838a23fbdd1..7bdadc790117 100644
--- a/drivers/video/backlight/ams369fg06.c
+++ b/drivers/video/backlight/ams369fg06.c
@@ -629,18 +629,7 @@ static struct spi_driver ams369fg06_driver = {
629 .resume = ams369fg06_resume, 629 .resume = ams369fg06_resume,
630}; 630};
631 631
632static int __init ams369fg06_init(void) 632module_spi_driver(ams369fg06_driver);
633{
634 return spi_register_driver(&ams369fg06_driver);
635}
636
637static void __exit ams369fg06_exit(void)
638{
639 spi_unregister_driver(&ams369fg06_driver);
640}
641
642module_init(ams369fg06_init);
643module_exit(ams369fg06_exit);
644 633
645MODULE_AUTHOR("Jingoo Han <jg1.han@samsung.com>"); 634MODULE_AUTHOR("Jingoo Han <jg1.han@samsung.com>");
646MODULE_DESCRIPTION("ams369fg06 LCD Driver"); 635MODULE_DESCRIPTION("ams369fg06 LCD Driver");
diff --git a/drivers/video/backlight/corgi_lcd.c b/drivers/video/backlight/corgi_lcd.c
index c6533bad26f8..6dab13fe562e 100644
--- a/drivers/video/backlight/corgi_lcd.c
+++ b/drivers/video/backlight/corgi_lcd.c
@@ -629,17 +629,7 @@ static struct spi_driver corgi_lcd_driver = {
629 .resume = corgi_lcd_resume, 629 .resume = corgi_lcd_resume,
630}; 630};
631 631
632static int __init corgi_lcd_init(void) 632module_spi_driver(corgi_lcd_driver);
633{
634 return spi_register_driver(&corgi_lcd_driver);
635}
636module_init(corgi_lcd_init);
637
638static void __exit corgi_lcd_exit(void)
639{
640 spi_unregister_driver(&corgi_lcd_driver);
641}
642module_exit(corgi_lcd_exit);
643 633
644MODULE_DESCRIPTION("LCD and backlight driver for SHARP C7x0/Cxx00"); 634MODULE_DESCRIPTION("LCD and backlight driver for SHARP C7x0/Cxx00");
645MODULE_AUTHOR("Eric Miao <eric.miao@marvell.com>"); 635MODULE_AUTHOR("Eric Miao <eric.miao@marvell.com>");
diff --git a/drivers/video/backlight/cr_bllcd.c b/drivers/video/backlight/cr_bllcd.c
index 6c8c54041fae..22489eb5f3e0 100644
--- a/drivers/video/backlight/cr_bllcd.c
+++ b/drivers/video/backlight/cr_bllcd.c
@@ -212,7 +212,7 @@ static int cr_backlight_probe(struct platform_device *pdev)
212 &gpio_bar); 212 &gpio_bar);
213 gpio_bar &= ~0x3F; 213 gpio_bar &= ~0x3F;
214 214
215 crp = kzalloc(sizeof(*crp), GFP_KERNEL); 215 crp = devm_kzalloc(&pdev->dev, sizeof(*crp), GFP_KERNEL);
216 if (!crp) { 216 if (!crp) {
217 lcd_device_unregister(ldp); 217 lcd_device_unregister(ldp);
218 backlight_device_unregister(bdp); 218 backlight_device_unregister(bdp);
@@ -243,7 +243,6 @@ static int cr_backlight_remove(struct platform_device *pdev)
243 backlight_device_unregister(crp->cr_backlight_device); 243 backlight_device_unregister(crp->cr_backlight_device);
244 lcd_device_unregister(crp->cr_lcd_device); 244 lcd_device_unregister(crp->cr_lcd_device);
245 pci_dev_put(lpc_dev); 245 pci_dev_put(lpc_dev);
246 kfree(crp);
247 246
248 return 0; 247 return 0;
249} 248}
diff --git a/drivers/video/backlight/da903x_bl.c b/drivers/video/backlight/da903x_bl.c
index abb4a06268f1..30e19681a30b 100644
--- a/drivers/video/backlight/da903x_bl.c
+++ b/drivers/video/backlight/da903x_bl.c
@@ -110,7 +110,7 @@ static int da903x_backlight_probe(struct platform_device *pdev)
110 struct backlight_properties props; 110 struct backlight_properties props;
111 int max_brightness; 111 int max_brightness;
112 112
113 data = kzalloc(sizeof(*data), GFP_KERNEL); 113 data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
114 if (data == NULL) 114 if (data == NULL)
115 return -ENOMEM; 115 return -ENOMEM;
116 116
@@ -124,7 +124,6 @@ static int da903x_backlight_probe(struct platform_device *pdev)
124 default: 124 default:
125 dev_err(&pdev->dev, "invalid backlight device ID(%d)\n", 125 dev_err(&pdev->dev, "invalid backlight device ID(%d)\n",
126 pdev->id); 126 pdev->id);
127 kfree(data);
128 return -EINVAL; 127 return -EINVAL;
129 } 128 }
130 129
@@ -143,7 +142,6 @@ static int da903x_backlight_probe(struct platform_device *pdev)
143 &da903x_backlight_ops, &props); 142 &da903x_backlight_ops, &props);
144 if (IS_ERR(bl)) { 143 if (IS_ERR(bl)) {
145 dev_err(&pdev->dev, "failed to register backlight\n"); 144 dev_err(&pdev->dev, "failed to register backlight\n");
146 kfree(data);
147 return PTR_ERR(bl); 145 return PTR_ERR(bl);
148 } 146 }
149 147
@@ -157,10 +155,8 @@ static int da903x_backlight_probe(struct platform_device *pdev)
157static int da903x_backlight_remove(struct platform_device *pdev) 155static int da903x_backlight_remove(struct platform_device *pdev)
158{ 156{
159 struct backlight_device *bl = platform_get_drvdata(pdev); 157 struct backlight_device *bl = platform_get_drvdata(pdev);
160 struct da903x_backlight_data *data = bl_get_data(bl);
161 158
162 backlight_device_unregister(bl); 159 backlight_device_unregister(bl);
163 kfree(data);
164 return 0; 160 return 0;
165} 161}
166 162
diff --git a/drivers/video/backlight/l4f00242t03.c b/drivers/video/backlight/l4f00242t03.c
index 27d1d7a29c77..6022b67285ec 100644
--- a/drivers/video/backlight/l4f00242t03.c
+++ b/drivers/video/backlight/l4f00242t03.c
@@ -274,18 +274,7 @@ static struct spi_driver l4f00242t03_driver = {
274 .shutdown = l4f00242t03_shutdown, 274 .shutdown = l4f00242t03_shutdown,
275}; 275};
276 276
277static __init int l4f00242t03_init(void) 277module_spi_driver(l4f00242t03_driver);
278{
279 return spi_register_driver(&l4f00242t03_driver);
280}
281
282static __exit void l4f00242t03_exit(void)
283{
284 spi_unregister_driver(&l4f00242t03_driver);
285}
286
287module_init(l4f00242t03_init);
288module_exit(l4f00242t03_exit);
289 278
290MODULE_AUTHOR("Alberto Panizzo <maramaopercheseimorto@gmail.com>"); 279MODULE_AUTHOR("Alberto Panizzo <maramaopercheseimorto@gmail.com>");
291MODULE_DESCRIPTION("EPSON L4F00242T03 LCD"); 280MODULE_DESCRIPTION("EPSON L4F00242T03 LCD");
diff --git a/drivers/video/backlight/ld9040.c b/drivers/video/backlight/ld9040.c
index 78dafc0c8fc5..efd352be21ae 100644
--- a/drivers/video/backlight/ld9040.c
+++ b/drivers/video/backlight/ld9040.c
@@ -856,18 +856,7 @@ static struct spi_driver ld9040_driver = {
856 .resume = ld9040_resume, 856 .resume = ld9040_resume,
857}; 857};
858 858
859static int __init ld9040_init(void) 859module_spi_driver(ld9040_driver);
860{
861 return spi_register_driver(&ld9040_driver);
862}
863
864static void __exit ld9040_exit(void)
865{
866 spi_unregister_driver(&ld9040_driver);
867}
868
869module_init(ld9040_init);
870module_exit(ld9040_exit);
871 860
872MODULE_AUTHOR("Donghwa Lee <dh09.lee@samsung.com>"); 861MODULE_AUTHOR("Donghwa Lee <dh09.lee@samsung.com>");
873MODULE_DESCRIPTION("ld9040 LCD Driver"); 862MODULE_DESCRIPTION("ld9040 LCD Driver");
diff --git a/drivers/video/backlight/lms283gf05.c b/drivers/video/backlight/lms283gf05.c
index 4ec78cfe26ea..4161f9e3982a 100644
--- a/drivers/video/backlight/lms283gf05.c
+++ b/drivers/video/backlight/lms283gf05.c
@@ -226,18 +226,7 @@ static struct spi_driver lms283gf05_driver = {
226 .remove = __devexit_p(lms283gf05_remove), 226 .remove = __devexit_p(lms283gf05_remove),
227}; 227};
228 228
229static __init int lms283gf05_init(void) 229module_spi_driver(lms283gf05_driver);
230{
231 return spi_register_driver(&lms283gf05_driver);
232}
233
234static __exit void lms283gf05_exit(void)
235{
236 spi_unregister_driver(&lms283gf05_driver);
237}
238
239module_init(lms283gf05_init);
240module_exit(lms283gf05_exit);
241 230
242MODULE_AUTHOR("Marek Vasut <marek.vasut@gmail.com>"); 231MODULE_AUTHOR("Marek Vasut <marek.vasut@gmail.com>");
243MODULE_DESCRIPTION("LCD283GF05 LCD"); 232MODULE_DESCRIPTION("LCD283GF05 LCD");
diff --git a/drivers/video/backlight/lp855x_bl.c b/drivers/video/backlight/lp855x_bl.c
new file mode 100644
index 000000000000..72a0e0c917cf
--- /dev/null
+++ b/drivers/video/backlight/lp855x_bl.c
@@ -0,0 +1,331 @@
1/*
2 * TI LP855x Backlight Driver
3 *
4 * Copyright (C) 2011 Texas Instruments
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 */
11
12#include <linux/module.h>
13#include <linux/slab.h>
14#include <linux/i2c.h>
15#include <linux/backlight.h>
16#include <linux/err.h>
17#include <linux/lp855x.h>
18
19/* Registers */
20#define BRIGHTNESS_CTRL (0x00)
21#define DEVICE_CTRL (0x01)
22
23#define BUF_SIZE 20
24#define DEFAULT_BL_NAME "lcd-backlight"
25#define MAX_BRIGHTNESS 255
26
27struct lp855x {
28 const char *chipname;
29 enum lp855x_chip_id chip_id;
30 struct i2c_client *client;
31 struct backlight_device *bl;
32 struct device *dev;
33 struct mutex xfer_lock;
34 struct lp855x_platform_data *pdata;
35};
36
37static int lp855x_read_byte(struct lp855x *lp, u8 reg, u8 *data)
38{
39 int ret;
40
41 mutex_lock(&lp->xfer_lock);
42 ret = i2c_smbus_read_byte_data(lp->client, reg);
43 if (ret < 0) {
44 mutex_unlock(&lp->xfer_lock);
45 dev_err(lp->dev, "failed to read 0x%.2x\n", reg);
46 return ret;
47 }
48 mutex_unlock(&lp->xfer_lock);
49
50 *data = (u8)ret;
51 return 0;
52}
53
54static int lp855x_write_byte(struct lp855x *lp, u8 reg, u8 data)
55{
56 int ret;
57
58 mutex_lock(&lp->xfer_lock);
59 ret = i2c_smbus_write_byte_data(lp->client, reg, data);
60 mutex_unlock(&lp->xfer_lock);
61
62 return ret;
63}
64
65static bool lp855x_is_valid_rom_area(struct lp855x *lp, u8 addr)
66{
67 u8 start, end;
68
69 switch (lp->chip_id) {
70 case LP8550:
71 case LP8551:
72 case LP8552:
73 case LP8553:
74 start = EEPROM_START;
75 end = EEPROM_END;
76 break;
77 case LP8556:
78 start = EPROM_START;
79 end = EPROM_END;
80 break;
81 default:
82 return false;
83 }
84
85 return (addr >= start && addr <= end);
86}
87
88static int lp855x_init_registers(struct lp855x *lp)
89{
90 u8 val, addr;
91 int i, ret;
92 struct lp855x_platform_data *pd = lp->pdata;
93
94 val = pd->initial_brightness;
95 ret = lp855x_write_byte(lp, BRIGHTNESS_CTRL, val);
96 if (ret)
97 return ret;
98
99 val = pd->device_control;
100 ret = lp855x_write_byte(lp, DEVICE_CTRL, val);
101 if (ret)
102 return ret;
103
104 if (pd->load_new_rom_data && pd->size_program) {
105 for (i = 0; i < pd->size_program; i++) {
106 addr = pd->rom_data[i].addr;
107 val = pd->rom_data[i].val;
108 if (!lp855x_is_valid_rom_area(lp, addr))
109 continue;
110
111 ret = lp855x_write_byte(lp, addr, val);
112 if (ret)
113 return ret;
114 }
115 }
116
117 return ret;
118}
119
120static int lp855x_bl_update_status(struct backlight_device *bl)
121{
122 struct lp855x *lp = bl_get_data(bl);
123 enum lp855x_brightness_ctrl_mode mode = lp->pdata->mode;
124
125 if (bl->props.state & BL_CORE_SUSPENDED)
126 bl->props.brightness = 0;
127
128 if (mode == PWM_BASED) {
129 struct lp855x_pwm_data *pd = &lp->pdata->pwm_data;
130 int br = bl->props.brightness;
131 int max_br = bl->props.max_brightness;
132
133 if (pd->pwm_set_intensity)
134 pd->pwm_set_intensity(br, max_br);
135
136 } else if (mode == REGISTER_BASED) {
137 u8 val = bl->props.brightness;
138 lp855x_write_byte(lp, BRIGHTNESS_CTRL, val);
139 }
140
141 return 0;
142}
143
144static int lp855x_bl_get_brightness(struct backlight_device *bl)
145{
146 struct lp855x *lp = bl_get_data(bl);
147 enum lp855x_brightness_ctrl_mode mode = lp->pdata->mode;
148
149 if (mode == PWM_BASED) {
150 struct lp855x_pwm_data *pd = &lp->pdata->pwm_data;
151 int max_br = bl->props.max_brightness;
152
153 if (pd->pwm_get_intensity)
154 bl->props.brightness = pd->pwm_get_intensity(max_br);
155
156 } else if (mode == REGISTER_BASED) {
157 u8 val = 0;
158
159 lp855x_read_byte(lp, BRIGHTNESS_CTRL, &val);
160 bl->props.brightness = val;
161 }
162
163 return bl->props.brightness;
164}
165
166static const struct backlight_ops lp855x_bl_ops = {
167 .options = BL_CORE_SUSPENDRESUME,
168 .update_status = lp855x_bl_update_status,
169 .get_brightness = lp855x_bl_get_brightness,
170};
171
172static int lp855x_backlight_register(struct lp855x *lp)
173{
174 struct backlight_device *bl;
175 struct backlight_properties props;
176 struct lp855x_platform_data *pdata = lp->pdata;
177 char *name = pdata->name ? : DEFAULT_BL_NAME;
178
179 props.type = BACKLIGHT_PLATFORM;
180 props.max_brightness = MAX_BRIGHTNESS;
181
182 if (pdata->initial_brightness > props.max_brightness)
183 pdata->initial_brightness = props.max_brightness;
184
185 props.brightness = pdata->initial_brightness;
186
187 bl = backlight_device_register(name, lp->dev, lp,
188 &lp855x_bl_ops, &props);
189 if (IS_ERR(bl))
190 return PTR_ERR(bl);
191
192 lp->bl = bl;
193
194 return 0;
195}
196
197static void lp855x_backlight_unregister(struct lp855x *lp)
198{
199 if (lp->bl)
200 backlight_device_unregister(lp->bl);
201}
202
203static ssize_t lp855x_get_chip_id(struct device *dev,
204 struct device_attribute *attr, char *buf)
205{
206 struct lp855x *lp = dev_get_drvdata(dev);
207 return scnprintf(buf, BUF_SIZE, "%s\n", lp->chipname);
208}
209
210static ssize_t lp855x_get_bl_ctl_mode(struct device *dev,
211 struct device_attribute *attr, char *buf)
212{
213 struct lp855x *lp = dev_get_drvdata(dev);
214 enum lp855x_brightness_ctrl_mode mode = lp->pdata->mode;
215 char *strmode = NULL;
216
217 if (mode == PWM_BASED)
218 strmode = "pwm based";
219 else if (mode == REGISTER_BASED)
220 strmode = "register based";
221
222 return scnprintf(buf, BUF_SIZE, "%s\n", strmode);
223}
224
225static DEVICE_ATTR(chip_id, S_IRUGO, lp855x_get_chip_id, NULL);
226static DEVICE_ATTR(bl_ctl_mode, S_IRUGO, lp855x_get_bl_ctl_mode, NULL);
227
228static struct attribute *lp855x_attributes[] = {
229 &dev_attr_chip_id.attr,
230 &dev_attr_bl_ctl_mode.attr,
231 NULL,
232};
233
234static const struct attribute_group lp855x_attr_group = {
235 .attrs = lp855x_attributes,
236};
237
238static int lp855x_probe(struct i2c_client *cl, const struct i2c_device_id *id)
239{
240 struct lp855x *lp;
241 struct lp855x_platform_data *pdata = cl->dev.platform_data;
242 enum lp855x_brightness_ctrl_mode mode;
243 int ret;
244
245 if (!pdata) {
246 dev_err(&cl->dev, "no platform data supplied\n");
247 return -EINVAL;
248 }
249
250 if (!i2c_check_functionality(cl->adapter, I2C_FUNC_SMBUS_I2C_BLOCK))
251 return -EIO;
252
253 lp = devm_kzalloc(&cl->dev, sizeof(struct lp855x), GFP_KERNEL);
254 if (!lp)
255 return -ENOMEM;
256
257 mode = pdata->mode;
258 lp->client = cl;
259 lp->dev = &cl->dev;
260 lp->pdata = pdata;
261 lp->chipname = id->name;
262 lp->chip_id = id->driver_data;
263 i2c_set_clientdata(cl, lp);
264
265 mutex_init(&lp->xfer_lock);
266
267 ret = lp855x_init_registers(lp);
268 if (ret) {
269 dev_err(lp->dev, "i2c communication err: %d", ret);
270 if (mode == REGISTER_BASED)
271 goto err_dev;
272 }
273
274 ret = lp855x_backlight_register(lp);
275 if (ret) {
276 dev_err(lp->dev,
277 "failed to register backlight. err: %d\n", ret);
278 goto err_dev;
279 }
280
281 ret = sysfs_create_group(&lp->dev->kobj, &lp855x_attr_group);
282 if (ret) {
283 dev_err(lp->dev, "failed to register sysfs. err: %d\n", ret);
284 goto err_sysfs;
285 }
286
287 backlight_update_status(lp->bl);
288 return 0;
289
290err_sysfs:
291 lp855x_backlight_unregister(lp);
292err_dev:
293 return ret;
294}
295
296static int __devexit lp855x_remove(struct i2c_client *cl)
297{
298 struct lp855x *lp = i2c_get_clientdata(cl);
299
300 lp->bl->props.brightness = 0;
301 backlight_update_status(lp->bl);
302 sysfs_remove_group(&lp->dev->kobj, &lp855x_attr_group);
303 lp855x_backlight_unregister(lp);
304
305 return 0;
306}
307
308static const struct i2c_device_id lp855x_ids[] = {
309 {"lp8550", LP8550},
310 {"lp8551", LP8551},
311 {"lp8552", LP8552},
312 {"lp8553", LP8553},
313 {"lp8556", LP8556},
314 { }
315};
316MODULE_DEVICE_TABLE(i2c, lp855x_ids);
317
318static struct i2c_driver lp855x_driver = {
319 .driver = {
320 .name = "lp855x",
321 },
322 .probe = lp855x_probe,
323 .remove = __devexit_p(lp855x_remove),
324 .id_table = lp855x_ids,
325};
326
327module_i2c_driver(lp855x_driver);
328
329MODULE_DESCRIPTION("Texas Instruments LP855x Backlight driver");
330MODULE_AUTHOR("Milo Kim <milo.kim@ti.com>");
331MODULE_LICENSE("GPL");
diff --git a/drivers/video/backlight/ltv350qv.c b/drivers/video/backlight/ltv350qv.c
index cca43c06d3c8..333949ff3265 100644
--- a/drivers/video/backlight/ltv350qv.c
+++ b/drivers/video/backlight/ltv350qv.c
@@ -321,17 +321,7 @@ static struct spi_driver ltv350qv_driver = {
321 .resume = ltv350qv_resume, 321 .resume = ltv350qv_resume,
322}; 322};
323 323
324static int __init ltv350qv_init(void) 324module_spi_driver(ltv350qv_driver);
325{
326 return spi_register_driver(&ltv350qv_driver);
327}
328
329static void __exit ltv350qv_exit(void)
330{
331 spi_unregister_driver(&ltv350qv_driver);
332}
333module_init(ltv350qv_init);
334module_exit(ltv350qv_exit);
335 325
336MODULE_AUTHOR("Haavard Skinnemoen (Atmel)"); 326MODULE_AUTHOR("Haavard Skinnemoen (Atmel)");
337MODULE_DESCRIPTION("Samsung LTV350QV LCD Driver"); 327MODULE_DESCRIPTION("Samsung LTV350QV LCD Driver");
diff --git a/drivers/video/backlight/max8925_bl.c b/drivers/video/backlight/max8925_bl.c
index c915e3b53886..e833ac72e063 100644
--- a/drivers/video/backlight/max8925_bl.c
+++ b/drivers/video/backlight/max8925_bl.c
@@ -129,7 +129,8 @@ static int __devinit max8925_backlight_probe(struct platform_device *pdev)
129 return -EINVAL; 129 return -EINVAL;
130 } 130 }
131 131
132 data = kzalloc(sizeof(struct max8925_backlight_data), GFP_KERNEL); 132 data = devm_kzalloc(&pdev->dev, sizeof(struct max8925_backlight_data),
133 GFP_KERNEL);
133 if (data == NULL) 134 if (data == NULL)
134 return -ENOMEM; 135 return -ENOMEM;
135 strncpy(name, res->name, MAX8925_NAME_SIZE); 136 strncpy(name, res->name, MAX8925_NAME_SIZE);
@@ -143,7 +144,6 @@ static int __devinit max8925_backlight_probe(struct platform_device *pdev)
143 &max8925_backlight_ops, &props); 144 &max8925_backlight_ops, &props);
144 if (IS_ERR(bl)) { 145 if (IS_ERR(bl)) {
145 dev_err(&pdev->dev, "failed to register backlight\n"); 146 dev_err(&pdev->dev, "failed to register backlight\n");
146 kfree(data);
147 return PTR_ERR(bl); 147 return PTR_ERR(bl);
148 } 148 }
149 bl->props.brightness = MAX_BRIGHTNESS; 149 bl->props.brightness = MAX_BRIGHTNESS;
@@ -165,17 +165,14 @@ static int __devinit max8925_backlight_probe(struct platform_device *pdev)
165 return 0; 165 return 0;
166out: 166out:
167 backlight_device_unregister(bl); 167 backlight_device_unregister(bl);
168 kfree(data);
169 return ret; 168 return ret;
170} 169}
171 170
172static int __devexit max8925_backlight_remove(struct platform_device *pdev) 171static int __devexit max8925_backlight_remove(struct platform_device *pdev)
173{ 172{
174 struct backlight_device *bl = platform_get_drvdata(pdev); 173 struct backlight_device *bl = platform_get_drvdata(pdev);
175 struct max8925_backlight_data *data = bl_get_data(bl);
176 174
177 backlight_device_unregister(bl); 175 backlight_device_unregister(bl);
178 kfree(data);
179 return 0; 176 return 0;
180} 177}
181 178
diff --git a/drivers/video/backlight/omap1_bl.c b/drivers/video/backlight/omap1_bl.c
index d8cde277ec83..0175bfb08a1c 100644
--- a/drivers/video/backlight/omap1_bl.c
+++ b/drivers/video/backlight/omap1_bl.c
@@ -141,7 +141,8 @@ static int omapbl_probe(struct platform_device *pdev)
141 if (!pdata) 141 if (!pdata)
142 return -ENXIO; 142 return -ENXIO;
143 143
144 bl = kzalloc(sizeof(struct omap_backlight), GFP_KERNEL); 144 bl = devm_kzalloc(&pdev->dev, sizeof(struct omap_backlight),
145 GFP_KERNEL);
145 if (unlikely(!bl)) 146 if (unlikely(!bl))
146 return -ENOMEM; 147 return -ENOMEM;
147 148
@@ -150,10 +151,8 @@ static int omapbl_probe(struct platform_device *pdev)
150 props.max_brightness = OMAPBL_MAX_INTENSITY; 151 props.max_brightness = OMAPBL_MAX_INTENSITY;
151 dev = backlight_device_register("omap-bl", &pdev->dev, bl, &omapbl_ops, 152 dev = backlight_device_register("omap-bl", &pdev->dev, bl, &omapbl_ops,
152 &props); 153 &props);
153 if (IS_ERR(dev)) { 154 if (IS_ERR(dev))
154 kfree(bl);
155 return PTR_ERR(dev); 155 return PTR_ERR(dev);
156 }
157 156
158 bl->powermode = FB_BLANK_POWERDOWN; 157 bl->powermode = FB_BLANK_POWERDOWN;
159 bl->current_intensity = 0; 158 bl->current_intensity = 0;
@@ -177,10 +176,8 @@ static int omapbl_probe(struct platform_device *pdev)
177static int omapbl_remove(struct platform_device *pdev) 176static int omapbl_remove(struct platform_device *pdev)
178{ 177{
179 struct backlight_device *dev = platform_get_drvdata(pdev); 178 struct backlight_device *dev = platform_get_drvdata(pdev);
180 struct omap_backlight *bl = dev_get_drvdata(&dev->dev);
181 179
182 backlight_device_unregister(dev); 180 backlight_device_unregister(dev);
183 kfree(bl);
184 181
185 return 0; 182 return 0;
186} 183}
diff --git a/drivers/video/backlight/ot200_bl.c b/drivers/video/backlight/ot200_bl.c
new file mode 100644
index 000000000000..f519d55a294c
--- /dev/null
+++ b/drivers/video/backlight/ot200_bl.c
@@ -0,0 +1,175 @@
1/*
2 * Copyright (C) 2012 Bachmann electronic GmbH
3 * Christian Gmeiner <christian.gmeiner@gmail.com>
4 *
5 * Backlight driver for ot200 visualisation device from
6 * Bachmann electronic GmbH.
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 version 2 as published by
10 * the Free Software Foundation.
11 */
12
13#include <linux/module.h>
14#include <linux/fb.h>
15#include <linux/backlight.h>
16#include <linux/gpio.h>
17#include <linux/cs5535.h>
18
19static struct cs5535_mfgpt_timer *pwm_timer;
20
21/* this array defines the mapping of brightness in % to pwm frequency */
22static const u8 dim_table[101] = {0, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2,
23 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4,
24 4, 5, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 9, 9,
25 10, 10, 11, 11, 12, 12, 13, 14, 15, 15, 16,
26 17, 18, 19, 20, 21, 22, 23, 24, 26, 27, 28,
27 30, 31, 33, 35, 37, 39, 41, 43, 45, 47, 50,
28 53, 55, 58, 61, 65, 68, 72, 75, 79, 84, 88,
29 93, 97, 103, 108, 114, 120, 126, 133, 140,
30 147, 155, 163};
31
32struct ot200_backlight_data {
33 int current_brightness;
34};
35
36#define GPIO_DIMM 27
37#define SCALE 1
38#define CMP1MODE 0x2 /* compare on GE; output high on compare
39 * greater than or equal */
40#define PWM_SETUP (SCALE | CMP1MODE << 6 | MFGPT_SETUP_CNTEN)
41#define MAX_COMP2 163
42
43static int ot200_backlight_update_status(struct backlight_device *bl)
44{
45 struct ot200_backlight_data *data = bl_get_data(bl);
46 int brightness = bl->props.brightness;
47
48 if (bl->props.state & BL_CORE_FBBLANK)
49 brightness = 0;
50
51 /* enable or disable PWM timer */
52 if (brightness == 0)
53 cs5535_mfgpt_write(pwm_timer, MFGPT_REG_SETUP, 0);
54 else if (data->current_brightness == 0) {
55 cs5535_mfgpt_write(pwm_timer, MFGPT_REG_COUNTER, 0);
56 cs5535_mfgpt_write(pwm_timer, MFGPT_REG_SETUP,
57 MFGPT_SETUP_CNTEN);
58 }
59
60 /* apply new brightness value */
61 cs5535_mfgpt_write(pwm_timer, MFGPT_REG_CMP1,
62 MAX_COMP2 - dim_table[brightness]);
63 data->current_brightness = brightness;
64
65 return 0;
66}
67
68static int ot200_backlight_get_brightness(struct backlight_device *bl)
69{
70 struct ot200_backlight_data *data = bl_get_data(bl);
71 return data->current_brightness;
72}
73
74static const struct backlight_ops ot200_backlight_ops = {
75 .update_status = ot200_backlight_update_status,
76 .get_brightness = ot200_backlight_get_brightness,
77};
78
79static int ot200_backlight_probe(struct platform_device *pdev)
80{
81 struct backlight_device *bl;
82 struct ot200_backlight_data *data;
83 struct backlight_properties props;
84 int retval = 0;
85
86 /* request gpio */
87 if (gpio_request(GPIO_DIMM, "ot200 backlight dimmer") < 0) {
88 dev_err(&pdev->dev, "failed to request GPIO %d\n", GPIO_DIMM);
89 return -ENODEV;
90 }
91
92 /* request timer */
93 pwm_timer = cs5535_mfgpt_alloc_timer(7, MFGPT_DOMAIN_ANY);
94 if (!pwm_timer) {
95 dev_err(&pdev->dev, "MFGPT 7 not available\n");
96 retval = -ENODEV;
97 goto error_mfgpt_alloc;
98 }
99
100 data = kzalloc(sizeof(*data), GFP_KERNEL);
101 if (!data) {
102 retval = -ENOMEM;
103 goto error_kzalloc;
104 }
105
106 /* setup gpio */
107 cs5535_gpio_set(GPIO_DIMM, GPIO_OUTPUT_ENABLE);
108 cs5535_gpio_set(GPIO_DIMM, GPIO_OUTPUT_AUX1);
109
110 /* setup timer */
111 cs5535_mfgpt_write(pwm_timer, MFGPT_REG_CMP1, 0);
112 cs5535_mfgpt_write(pwm_timer, MFGPT_REG_CMP2, MAX_COMP2);
113 cs5535_mfgpt_write(pwm_timer, MFGPT_REG_SETUP, PWM_SETUP);
114
115 data->current_brightness = 100;
116 props.max_brightness = 100;
117 props.brightness = 100;
118 props.type = BACKLIGHT_RAW;
119
120 bl = backlight_device_register(dev_name(&pdev->dev), &pdev->dev, data,
121 &ot200_backlight_ops, &props);
122 if (IS_ERR(bl)) {
123 dev_err(&pdev->dev, "failed to register backlight\n");
124 retval = PTR_ERR(bl);
125 goto error_backlight_device_register;
126 }
127
128 platform_set_drvdata(pdev, bl);
129
130 return 0;
131
132error_backlight_device_register:
133 kfree(data);
134error_kzalloc:
135 cs5535_mfgpt_free_timer(pwm_timer);
136error_mfgpt_alloc:
137 gpio_free(GPIO_DIMM);
138 return retval;
139}
140
141static int ot200_backlight_remove(struct platform_device *pdev)
142{
143 struct backlight_device *bl = platform_get_drvdata(pdev);
144 struct ot200_backlight_data *data = bl_get_data(bl);
145
146 backlight_device_unregister(bl);
147
148 /* on module unload set brightness to 100% */
149 cs5535_mfgpt_write(pwm_timer, MFGPT_REG_COUNTER, 0);
150 cs5535_mfgpt_write(pwm_timer, MFGPT_REG_SETUP, MFGPT_SETUP_CNTEN);
151 cs5535_mfgpt_write(pwm_timer, MFGPT_REG_CMP1,
152 MAX_COMP2 - dim_table[100]);
153
154 cs5535_mfgpt_free_timer(pwm_timer);
155 gpio_free(GPIO_DIMM);
156
157 kfree(data);
158 return 0;
159}
160
161static struct platform_driver ot200_backlight_driver = {
162 .driver = {
163 .name = "ot200-backlight",
164 .owner = THIS_MODULE,
165 },
166 .probe = ot200_backlight_probe,
167 .remove = ot200_backlight_remove,
168};
169
170module_platform_driver(ot200_backlight_driver);
171
172MODULE_DESCRIPTION("backlight driver for ot200 visualisation device");
173MODULE_AUTHOR("Christian Gmeiner <christian.gmeiner@gmail.com>");
174MODULE_LICENSE("GPL");
175MODULE_ALIAS("platform:ot200-backlight");
diff --git a/drivers/video/backlight/pandora_bl.c b/drivers/video/backlight/pandora_bl.c
new file mode 100644
index 000000000000..4ec30748b447
--- /dev/null
+++ b/drivers/video/backlight/pandora_bl.c
@@ -0,0 +1,171 @@
1/*
2 * Backlight driver for Pandora handheld.
3 * Pandora uses TWL4030 PWM0 -> TPS61161 combo for control backlight.
4 * Based on pwm_bl.c
5 *
6 * Copyright 2009,2012 Gražvydas Ignotas <notasas@gmail.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12
13#include <linux/module.h>
14#include <linux/kernel.h>
15#include <linux/platform_device.h>
16#include <linux/delay.h>
17#include <linux/fb.h>
18#include <linux/backlight.h>
19#include <linux/i2c/twl.h>
20#include <linux/err.h>
21
22#define TWL_PWM0_ON 0x00
23#define TWL_PWM0_OFF 0x01
24
25#define TWL_INTBR_GPBR1 0x0c
26#define TWL_INTBR_PMBR1 0x0d
27
28#define TWL_PMBR1_PWM0_MUXMASK 0x0c
29#define TWL_PMBR1_PWM0 0x04
30#define PWM0_CLK_ENABLE BIT(0)
31#define PWM0_ENABLE BIT(2)
32
33/* range accepted by hardware */
34#define MIN_VALUE 9
35#define MAX_VALUE 63
36#define MAX_USER_VALUE (MAX_VALUE - MIN_VALUE)
37
38#define PANDORABL_WAS_OFF BL_CORE_DRIVER1
39
40static int pandora_backlight_update_status(struct backlight_device *bl)
41{
42 int brightness = bl->props.brightness;
43 u8 r;
44
45 if (bl->props.power != FB_BLANK_UNBLANK)
46 brightness = 0;
47 if (bl->props.state & BL_CORE_FBBLANK)
48 brightness = 0;
49 if (bl->props.state & BL_CORE_SUSPENDED)
50 brightness = 0;
51
52 if ((unsigned int)brightness > MAX_USER_VALUE)
53 brightness = MAX_USER_VALUE;
54
55 if (brightness == 0) {
56 if (bl->props.state & PANDORABL_WAS_OFF)
57 goto done;
58
59 /* first disable PWM0 output, then clock */
60 twl_i2c_read_u8(TWL4030_MODULE_INTBR, &r, TWL_INTBR_GPBR1);
61 r &= ~PWM0_ENABLE;
62 twl_i2c_write_u8(TWL4030_MODULE_INTBR, r, TWL_INTBR_GPBR1);
63 r &= ~PWM0_CLK_ENABLE;
64 twl_i2c_write_u8(TWL4030_MODULE_INTBR, r, TWL_INTBR_GPBR1);
65
66 goto done;
67 }
68
69 if (bl->props.state & PANDORABL_WAS_OFF) {
70 /*
71 * set PWM duty cycle to max. TPS61161 seems to use this
72 * to calibrate it's PWM sensitivity when it starts.
73 */
74 twl_i2c_write_u8(TWL4030_MODULE_PWM0, MAX_VALUE,
75 TWL_PWM0_OFF);
76
77 /* first enable clock, then PWM0 out */
78 twl_i2c_read_u8(TWL4030_MODULE_INTBR, &r, TWL_INTBR_GPBR1);
79 r &= ~PWM0_ENABLE;
80 r |= PWM0_CLK_ENABLE;
81 twl_i2c_write_u8(TWL4030_MODULE_INTBR, r, TWL_INTBR_GPBR1);
82 r |= PWM0_ENABLE;
83 twl_i2c_write_u8(TWL4030_MODULE_INTBR, r, TWL_INTBR_GPBR1);
84
85 /*
86 * TI made it very easy to enable digital control, so easy that
87 * it often triggers unintentionally and disabes PWM control,
88 * so wait until 1 wire mode detection window ends.
89 */
90 usleep_range(2000, 10000);
91 }
92
93 twl_i2c_write_u8(TWL4030_MODULE_PWM0, MIN_VALUE + brightness,
94 TWL_PWM0_OFF);
95
96done:
97 if (brightness != 0)
98 bl->props.state &= ~PANDORABL_WAS_OFF;
99 else
100 bl->props.state |= PANDORABL_WAS_OFF;
101
102 return 0;
103}
104
105static int pandora_backlight_get_brightness(struct backlight_device *bl)
106{
107 return bl->props.brightness;
108}
109
110static const struct backlight_ops pandora_backlight_ops = {
111 .options = BL_CORE_SUSPENDRESUME,
112 .update_status = pandora_backlight_update_status,
113 .get_brightness = pandora_backlight_get_brightness,
114};
115
116static int pandora_backlight_probe(struct platform_device *pdev)
117{
118 struct backlight_properties props;
119 struct backlight_device *bl;
120 u8 r;
121
122 memset(&props, 0, sizeof(props));
123 props.max_brightness = MAX_USER_VALUE;
124 props.type = BACKLIGHT_RAW;
125 bl = backlight_device_register(pdev->name, &pdev->dev,
126 NULL, &pandora_backlight_ops, &props);
127 if (IS_ERR(bl)) {
128 dev_err(&pdev->dev, "failed to register backlight\n");
129 return PTR_ERR(bl);
130 }
131
132 platform_set_drvdata(pdev, bl);
133
134 /* 64 cycle period, ON position 0 */
135 twl_i2c_write_u8(TWL4030_MODULE_PWM0, 0x80, TWL_PWM0_ON);
136
137 bl->props.state |= PANDORABL_WAS_OFF;
138 bl->props.brightness = MAX_USER_VALUE;
139 backlight_update_status(bl);
140
141 /* enable PWM function in pin mux */
142 twl_i2c_read_u8(TWL4030_MODULE_INTBR, &r, TWL_INTBR_PMBR1);
143 r &= ~TWL_PMBR1_PWM0_MUXMASK;
144 r |= TWL_PMBR1_PWM0;
145 twl_i2c_write_u8(TWL4030_MODULE_INTBR, r, TWL_INTBR_PMBR1);
146
147 return 0;
148}
149
150static int pandora_backlight_remove(struct platform_device *pdev)
151{
152 struct backlight_device *bl = platform_get_drvdata(pdev);
153 backlight_device_unregister(bl);
154 return 0;
155}
156
157static struct platform_driver pandora_backlight_driver = {
158 .driver = {
159 .name = "pandora-backlight",
160 .owner = THIS_MODULE,
161 },
162 .probe = pandora_backlight_probe,
163 .remove = pandora_backlight_remove,
164};
165
166module_platform_driver(pandora_backlight_driver);
167
168MODULE_AUTHOR("Gražvydas Ignotas <notasas@gmail.com>");
169MODULE_DESCRIPTION("Pandora Backlight Driver");
170MODULE_LICENSE("GPL");
171MODULE_ALIAS("platform:pandora-backlight");
diff --git a/drivers/video/backlight/pcf50633-backlight.c b/drivers/video/backlight/pcf50633-backlight.c
index 13e88b71daec..c65853cb9740 100644
--- a/drivers/video/backlight/pcf50633-backlight.c
+++ b/drivers/video/backlight/pcf50633-backlight.c
@@ -101,14 +101,13 @@ static const struct backlight_ops pcf50633_bl_ops = {
101 101
102static int __devinit pcf50633_bl_probe(struct platform_device *pdev) 102static int __devinit pcf50633_bl_probe(struct platform_device *pdev)
103{ 103{
104 int ret;
105 struct pcf50633_bl *pcf_bl; 104 struct pcf50633_bl *pcf_bl;
106 struct device *parent = pdev->dev.parent; 105 struct device *parent = pdev->dev.parent;
107 struct pcf50633_platform_data *pcf50633_data = parent->platform_data; 106 struct pcf50633_platform_data *pcf50633_data = parent->platform_data;
108 struct pcf50633_bl_platform_data *pdata = pcf50633_data->backlight_data; 107 struct pcf50633_bl_platform_data *pdata = pcf50633_data->backlight_data;
109 struct backlight_properties bl_props; 108 struct backlight_properties bl_props;
110 109
111 pcf_bl = kzalloc(sizeof(*pcf_bl), GFP_KERNEL); 110 pcf_bl = devm_kzalloc(&pdev->dev, sizeof(*pcf_bl), GFP_KERNEL);
112 if (!pcf_bl) 111 if (!pcf_bl)
113 return -ENOMEM; 112 return -ENOMEM;
114 113
@@ -129,10 +128,8 @@ static int __devinit pcf50633_bl_probe(struct platform_device *pdev)
129 pcf_bl->bl = backlight_device_register(pdev->name, &pdev->dev, pcf_bl, 128 pcf_bl->bl = backlight_device_register(pdev->name, &pdev->dev, pcf_bl,
130 &pcf50633_bl_ops, &bl_props); 129 &pcf50633_bl_ops, &bl_props);
131 130
132 if (IS_ERR(pcf_bl->bl)) { 131 if (IS_ERR(pcf_bl->bl))
133 ret = PTR_ERR(pcf_bl->bl); 132 return PTR_ERR(pcf_bl->bl);
134 goto err_free;
135 }
136 133
137 platform_set_drvdata(pdev, pcf_bl); 134 platform_set_drvdata(pdev, pcf_bl);
138 135
@@ -145,11 +142,6 @@ static int __devinit pcf50633_bl_probe(struct platform_device *pdev)
145 backlight_update_status(pcf_bl->bl); 142 backlight_update_status(pcf_bl->bl);
146 143
147 return 0; 144 return 0;
148
149err_free:
150 kfree(pcf_bl);
151
152 return ret;
153} 145}
154 146
155static int __devexit pcf50633_bl_remove(struct platform_device *pdev) 147static int __devexit pcf50633_bl_remove(struct platform_device *pdev)
@@ -160,8 +152,6 @@ static int __devexit pcf50633_bl_remove(struct platform_device *pdev)
160 152
161 platform_set_drvdata(pdev, NULL); 153 platform_set_drvdata(pdev, NULL);
162 154
163 kfree(pcf_bl);
164
165 return 0; 155 return 0;
166} 156}
167 157
diff --git a/drivers/video/backlight/platform_lcd.c b/drivers/video/backlight/platform_lcd.c
index f0bf491ed087..b6672340d6c7 100644
--- a/drivers/video/backlight/platform_lcd.c
+++ b/drivers/video/backlight/platform_lcd.c
@@ -121,9 +121,9 @@ static int __devexit platform_lcd_remove(struct platform_device *pdev)
121} 121}
122 122
123#ifdef CONFIG_PM 123#ifdef CONFIG_PM
124static int platform_lcd_suspend(struct platform_device *pdev, pm_message_t st) 124static int platform_lcd_suspend(struct device *dev)
125{ 125{
126 struct platform_lcd *plcd = platform_get_drvdata(pdev); 126 struct platform_lcd *plcd = dev_get_drvdata(dev);
127 127
128 plcd->suspended = 1; 128 plcd->suspended = 1;
129 platform_lcd_set_power(plcd->lcd, plcd->power); 129 platform_lcd_set_power(plcd->lcd, plcd->power);
@@ -131,29 +131,30 @@ static int platform_lcd_suspend(struct platform_device *pdev, pm_message_t st)
131 return 0; 131 return 0;
132} 132}
133 133
134static int platform_lcd_resume(struct platform_device *pdev) 134static int platform_lcd_resume(struct device *dev)
135{ 135{
136 struct platform_lcd *plcd = platform_get_drvdata(pdev); 136 struct platform_lcd *plcd = dev_get_drvdata(dev);
137 137
138 plcd->suspended = 0; 138 plcd->suspended = 0;
139 platform_lcd_set_power(plcd->lcd, plcd->power); 139 platform_lcd_set_power(plcd->lcd, plcd->power);
140 140
141 return 0; 141 return 0;
142} 142}
143#else 143
144#define platform_lcd_suspend NULL 144static SIMPLE_DEV_PM_OPS(platform_lcd_pm_ops, platform_lcd_suspend,
145#define platform_lcd_resume NULL 145 platform_lcd_resume);
146#endif 146#endif
147 147
148static struct platform_driver platform_lcd_driver = { 148static struct platform_driver platform_lcd_driver = {
149 .driver = { 149 .driver = {
150 .name = "platform-lcd", 150 .name = "platform-lcd",
151 .owner = THIS_MODULE, 151 .owner = THIS_MODULE,
152#ifdef CONFIG_PM
153 .pm = &platform_lcd_pm_ops,
154#endif
152 }, 155 },
153 .probe = platform_lcd_probe, 156 .probe = platform_lcd_probe,
154 .remove = __devexit_p(platform_lcd_remove), 157 .remove = __devexit_p(platform_lcd_remove),
155 .suspend = platform_lcd_suspend,
156 .resume = platform_lcd_resume,
157}; 158};
158 159
159module_platform_driver(platform_lcd_driver); 160module_platform_driver(platform_lcd_driver);
diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c
index 7496d04e1d3c..342b7d7cbb63 100644
--- a/drivers/video/backlight/pwm_bl.c
+++ b/drivers/video/backlight/pwm_bl.c
@@ -102,7 +102,7 @@ static int pwm_backlight_probe(struct platform_device *pdev)
102 return ret; 102 return ret;
103 } 103 }
104 104
105 pb = kzalloc(sizeof(*pb), GFP_KERNEL); 105 pb = devm_kzalloc(&pdev->dev, sizeof(*pb), GFP_KERNEL);
106 if (!pb) { 106 if (!pb) {
107 dev_err(&pdev->dev, "no memory for state\n"); 107 dev_err(&pdev->dev, "no memory for state\n");
108 ret = -ENOMEM; 108 ret = -ENOMEM;
@@ -121,7 +121,7 @@ static int pwm_backlight_probe(struct platform_device *pdev)
121 if (IS_ERR(pb->pwm)) { 121 if (IS_ERR(pb->pwm)) {
122 dev_err(&pdev->dev, "unable to request PWM for backlight\n"); 122 dev_err(&pdev->dev, "unable to request PWM for backlight\n");
123 ret = PTR_ERR(pb->pwm); 123 ret = PTR_ERR(pb->pwm);
124 goto err_pwm; 124 goto err_alloc;
125 } else 125 } else
126 dev_dbg(&pdev->dev, "got pwm for backlight\n"); 126 dev_dbg(&pdev->dev, "got pwm for backlight\n");
127 127
@@ -144,8 +144,6 @@ static int pwm_backlight_probe(struct platform_device *pdev)
144 144
145err_bl: 145err_bl:
146 pwm_free(pb->pwm); 146 pwm_free(pb->pwm);
147err_pwm:
148 kfree(pb);
149err_alloc: 147err_alloc:
150 if (data->exit) 148 if (data->exit)
151 data->exit(&pdev->dev); 149 data->exit(&pdev->dev);
@@ -162,7 +160,6 @@ static int pwm_backlight_remove(struct platform_device *pdev)
162 pwm_config(pb->pwm, 0, pb->period); 160 pwm_config(pb->pwm, 0, pb->period);
163 pwm_disable(pb->pwm); 161 pwm_disable(pb->pwm);
164 pwm_free(pb->pwm); 162 pwm_free(pb->pwm);
165 kfree(pb);
166 if (data->exit) 163 if (data->exit)
167 data->exit(&pdev->dev); 164 data->exit(&pdev->dev);
168 return 0; 165 return 0;
diff --git a/drivers/video/backlight/s6e63m0.c b/drivers/video/backlight/s6e63m0.c
index 516db703dd24..e264f55b2574 100644
--- a/drivers/video/backlight/s6e63m0.c
+++ b/drivers/video/backlight/s6e63m0.c
@@ -909,18 +909,7 @@ static struct spi_driver s6e63m0_driver = {
909 .resume = s6e63m0_resume, 909 .resume = s6e63m0_resume,
910}; 910};
911 911
912static int __init s6e63m0_init(void) 912module_spi_driver(s6e63m0_driver);
913{
914 return spi_register_driver(&s6e63m0_driver);
915}
916
917static void __exit s6e63m0_exit(void)
918{
919 spi_unregister_driver(&s6e63m0_driver);
920}
921
922module_init(s6e63m0_init);
923module_exit(s6e63m0_exit);
924 913
925MODULE_AUTHOR("InKi Dae <inki.dae@samsung.com>"); 914MODULE_AUTHOR("InKi Dae <inki.dae@samsung.com>");
926MODULE_DESCRIPTION("S6E63M0 LCD Driver"); 915MODULE_DESCRIPTION("S6E63M0 LCD Driver");
diff --git a/drivers/video/backlight/tdo24m.c b/drivers/video/backlight/tdo24m.c
index 1997e12a1057..2368b8e5f89e 100644
--- a/drivers/video/backlight/tdo24m.c
+++ b/drivers/video/backlight/tdo24m.c
@@ -459,17 +459,7 @@ static struct spi_driver tdo24m_driver = {
459 .resume = tdo24m_resume, 459 .resume = tdo24m_resume,
460}; 460};
461 461
462static int __init tdo24m_init(void) 462module_spi_driver(tdo24m_driver);
463{
464 return spi_register_driver(&tdo24m_driver);
465}
466module_init(tdo24m_init);
467
468static void __exit tdo24m_exit(void)
469{
470 spi_unregister_driver(&tdo24m_driver);
471}
472module_exit(tdo24m_exit);
473 463
474MODULE_AUTHOR("Eric Miao <eric.miao@marvell.com>"); 464MODULE_AUTHOR("Eric Miao <eric.miao@marvell.com>");
475MODULE_DESCRIPTION("Driver for Toppoly TDO24M LCD Panel"); 465MODULE_DESCRIPTION("Driver for Toppoly TDO24M LCD Panel");
diff --git a/drivers/video/backlight/tosa_bl.c b/drivers/video/backlight/tosa_bl.c
index 425a7365470b..2b241abced43 100644
--- a/drivers/video/backlight/tosa_bl.c
+++ b/drivers/video/backlight/tosa_bl.c
@@ -181,18 +181,7 @@ static struct i2c_driver tosa_bl_driver = {
181 .id_table = tosa_bl_id, 181 .id_table = tosa_bl_id,
182}; 182};
183 183
184static int __init tosa_bl_init(void) 184module_i2c_driver(tosa_bl_driver);
185{
186 return i2c_add_driver(&tosa_bl_driver);
187}
188
189static void __exit tosa_bl_exit(void)
190{
191 i2c_del_driver(&tosa_bl_driver);
192}
193
194module_init(tosa_bl_init);
195module_exit(tosa_bl_exit);
196 185
197MODULE_AUTHOR("Dmitry Baryshkov"); 186MODULE_AUTHOR("Dmitry Baryshkov");
198MODULE_LICENSE("GPL v2"); 187MODULE_LICENSE("GPL v2");
diff --git a/drivers/video/backlight/tosa_lcd.c b/drivers/video/backlight/tosa_lcd.c
index 772f6015219a..a2161f631a83 100644
--- a/drivers/video/backlight/tosa_lcd.c
+++ b/drivers/video/backlight/tosa_lcd.c
@@ -285,18 +285,7 @@ static struct spi_driver tosa_lcd_driver = {
285 .resume = tosa_lcd_resume, 285 .resume = tosa_lcd_resume,
286}; 286};
287 287
288static int __init tosa_lcd_init(void) 288module_spi_driver(tosa_lcd_driver);
289{
290 return spi_register_driver(&tosa_lcd_driver);
291}
292
293static void __exit tosa_lcd_exit(void)
294{
295 spi_unregister_driver(&tosa_lcd_driver);
296}
297
298module_init(tosa_lcd_init);
299module_exit(tosa_lcd_exit);
300 289
301MODULE_AUTHOR("Dmitry Baryshkov"); 290MODULE_AUTHOR("Dmitry Baryshkov");
302MODULE_LICENSE("GPL v2"); 291MODULE_LICENSE("GPL v2");
diff --git a/drivers/video/backlight/vgg2432a4.c b/drivers/video/backlight/vgg2432a4.c
index b49063c831e7..b617fae9aa26 100644
--- a/drivers/video/backlight/vgg2432a4.c
+++ b/drivers/video/backlight/vgg2432a4.c
@@ -262,20 +262,7 @@ static struct spi_driver vgg2432a4_driver = {
262 .resume = vgg2432a4_resume, 262 .resume = vgg2432a4_resume,
263}; 263};
264 264
265/* Device driver initialisation */ 265module_spi_driver(vgg2432a4_driver);
266
267static int __init vgg2432a4_init(void)
268{
269 return spi_register_driver(&vgg2432a4_driver);
270}
271
272static void __exit vgg2432a4_exit(void)
273{
274 spi_unregister_driver(&vgg2432a4_driver);
275}
276
277module_init(vgg2432a4_init);
278module_exit(vgg2432a4_exit);
279 266
280MODULE_AUTHOR("Ben Dooks <ben-linux@fluff.org>"); 267MODULE_AUTHOR("Ben Dooks <ben-linux@fluff.org>");
281MODULE_DESCRIPTION("VGG2432A4 LCD Driver"); 268MODULE_DESCRIPTION("VGG2432A4 LCD Driver");
diff --git a/drivers/video/backlight/wm831x_bl.c b/drivers/video/backlight/wm831x_bl.c
index 4e915f5eca99..5d365deb5f82 100644
--- a/drivers/video/backlight/wm831x_bl.c
+++ b/drivers/video/backlight/wm831x_bl.c
@@ -186,7 +186,7 @@ static int wm831x_backlight_probe(struct platform_device *pdev)
186 if (ret < 0) 186 if (ret < 0)
187 return ret; 187 return ret;
188 188
189 data = kzalloc(sizeof(*data), GFP_KERNEL); 189 data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
190 if (data == NULL) 190 if (data == NULL)
191 return -ENOMEM; 191 return -ENOMEM;
192 192
@@ -200,7 +200,6 @@ static int wm831x_backlight_probe(struct platform_device *pdev)
200 &wm831x_backlight_ops, &props); 200 &wm831x_backlight_ops, &props);
201 if (IS_ERR(bl)) { 201 if (IS_ERR(bl)) {
202 dev_err(&pdev->dev, "failed to register backlight\n"); 202 dev_err(&pdev->dev, "failed to register backlight\n");
203 kfree(data);
204 return PTR_ERR(bl); 203 return PTR_ERR(bl);
205 } 204 }
206 205
@@ -211,7 +210,6 @@ static int wm831x_backlight_probe(struct platform_device *pdev)
211 /* Disable the DCDC if it was started so we can bootstrap */ 210 /* Disable the DCDC if it was started so we can bootstrap */
212 wm831x_set_bits(wm831x, WM831X_DCDC_ENABLE, WM831X_DC4_ENA, 0); 211 wm831x_set_bits(wm831x, WM831X_DCDC_ENABLE, WM831X_DC4_ENA, 0);
213 212
214
215 backlight_update_status(bl); 213 backlight_update_status(bl);
216 214
217 return 0; 215 return 0;
@@ -220,10 +218,8 @@ static int wm831x_backlight_probe(struct platform_device *pdev)
220static int wm831x_backlight_remove(struct platform_device *pdev) 218static int wm831x_backlight_remove(struct platform_device *pdev)
221{ 219{
222 struct backlight_device *bl = platform_get_drvdata(pdev); 220 struct backlight_device *bl = platform_get_drvdata(pdev);
223 struct wm831x_backlight_data *data = bl_get_data(bl);
224 221
225 backlight_device_unregister(bl); 222 backlight_device_unregister(bl);
226 kfree(data);
227 return 0; 223 return 0;
228} 224}
229 225
diff --git a/drivers/video/uvesafb.c b/drivers/video/uvesafb.c
index 9db3de3a8418..260cca7ddb41 100644
--- a/drivers/video/uvesafb.c
+++ b/drivers/video/uvesafb.c
@@ -121,7 +121,7 @@ static int uvesafb_helper_start(void)
121 NULL, 121 NULL,
122 }; 122 };
123 123
124 return call_usermodehelper(v86d_path, argv, envp, 1); 124 return call_usermodehelper(v86d_path, argv, envp, UMH_WAIT_PROC);
125} 125}
126 126
127/* 127/*