aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-07-30 20:25:34 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-07-30 20:25:34 -0400
commit27c1ee3f929555b71fa39ec0d81a7e7185de1b16 (patch)
tree42e40bdfe4efac660d650658019391536ce67a42 /drivers
parent37cd9600a9e20359b0283983c9e3a55d84347168 (diff)
parent086ff4b3a7fb9cdf41e6a5d0ccd99b86d84633a1 (diff)
Merge branch 'akpm' (Andrew's patch-bomb)
Merge Andrew's first set of patches: "Non-MM patches: - lots of misc bits - tree-wide have_clk() cleanups - quite a lot of printk tweaks. I draw your attention to "printk: convert the format for KERN_<LEVEL> to a 2 byte pattern" which looks a bit scary. But afaict it's solid. - backlight updates - lib/ feature work (notably the addition and use of memweight()) - checkpatch updates - rtc updates - nilfs updates - fatfs updates (partial, still waiting for acks) - kdump, proc, fork, IPC, sysctl, taskstats, pps, etc - new fault-injection feature work" * Merge emailed patches from Andrew Morton <akpm@linux-foundation.org>: (128 commits) drivers/misc/lkdtm.c: fix missing allocation failure check lib/scatterlist: do not re-write gfp_flags in __sg_alloc_table() fault-injection: add tool to run command with failslab or fail_page_alloc fault-injection: add selftests for cpu and memory hotplug powerpc: pSeries reconfig notifier error injection module memory: memory notifier error injection module PM: PM notifier error injection module cpu: rewrite cpu-notifier-error-inject module fault-injection: notifier error injection c/r: fcntl: add F_GETOWNER_UIDS option resource: make sure requested range is included in the root range include/linux/aio.h: cpp->C conversions fs: cachefiles: add support for large files in filesystem caching pps: return PTR_ERR on error in device_create taskstats: check nla_reserve() return sysctl: suppress kmemleak messages ipc: use Kconfig options for __ARCH_WANT_[COMPAT_]IPC_PARSE_VERSION ipc: compat: use signed size_t types for msgsnd and msgrcv ipc: allow compat IPC version field parsing if !ARCH_WANT_OLD_COMPAT_IPC ipc: add COMPAT_SHMLBA support ...
Diffstat (limited to 'drivers')
-rw-r--r--drivers/ata/pata_arasan_cf.c14
-rw-r--r--drivers/clk/Kconfig1
-rw-r--r--drivers/clk/clk.c3
-rw-r--r--drivers/firmware/memmap.c8
-rw-r--r--drivers/firmware/pcdp.c4
-rw-r--r--drivers/i2c/busses/i2c-pxa.c7
-rw-r--r--drivers/md/dm-log.c13
-rw-r--r--drivers/media/video/uvc/uvc_ctrl.c5
-rw-r--r--drivers/message/i2o/i2o_config.c7
-rw-r--r--drivers/message/i2o/i2o_proc.c37
-rw-r--r--drivers/misc/lkdtm.c2
-rw-r--r--drivers/misc/ti-st/st_core.c5
-rw-r--r--drivers/net/can/c_can/c_can_platform.c8
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac.h42
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_main.c33
-rw-r--r--drivers/pps/pps.c4
-rw-r--r--drivers/rtc/Kconfig1
-rw-r--r--drivers/rtc/rtc-ab8500.c42
-rw-r--r--drivers/rtc/rtc-coh901331.c61
-rw-r--r--drivers/rtc/rtc-da9052.c5
-rw-r--r--drivers/rtc/rtc-mc13xxx.c6
-rw-r--r--drivers/rtc/rtc-pcf8563.c11
-rw-r--r--drivers/rtc/rtc-pl031.c95
-rw-r--r--drivers/rtc/rtc-r9701.c6
-rw-r--r--drivers/rtc/rtc-s3c.c4
-rw-r--r--drivers/usb/gadget/m66592-udc.c9
-rw-r--r--drivers/usb/gadget/m66592-udc.h5
-rw-r--r--drivers/usb/gadget/r8a66597-udc.c11
-rw-r--r--drivers/usb/gadget/r8a66597-udc.h5
-rw-r--r--drivers/usb/host/r8a66597-hcd.c12
-rw-r--r--drivers/usb/host/r8a66597.h5
-rw-r--r--drivers/usb/musb/musb_core.h8
-rw-r--r--drivers/video/backlight/atmel-pwm-bl.c19
-rw-r--r--drivers/video/backlight/corgi_lcd.c19
-rw-r--r--drivers/video/backlight/l4f00242t03.c29
-rw-r--r--drivers/video/backlight/lm3533_bl.c8
-rw-r--r--drivers/video/backlight/lms283gf05.c24
-rw-r--r--drivers/video/backlight/lp855x_bl.c10
-rw-r--r--drivers/video/backlight/ot200_bl.c21
-rw-r--r--drivers/video/backlight/tosa_bl.c8
-rw-r--r--drivers/video/backlight/tosa_lcd.c7
41 files changed, 255 insertions, 369 deletions
diff --git a/drivers/ata/pata_arasan_cf.c b/drivers/ata/pata_arasan_cf.c
index ac6a5beb28f..bfaa5cb1629 100644
--- a/drivers/ata/pata_arasan_cf.c
+++ b/drivers/ata/pata_arasan_cf.c
@@ -184,10 +184,8 @@
184struct arasan_cf_dev { 184struct arasan_cf_dev {
185 /* pointer to ata_host structure */ 185 /* pointer to ata_host structure */
186 struct ata_host *host; 186 struct ata_host *host;
187 /* clk structure, only if HAVE_CLK is defined */ 187 /* clk structure */
188#ifdef CONFIG_HAVE_CLK
189 struct clk *clk; 188 struct clk *clk;
190#endif
191 189
192 /* physical base address of controller */ 190 /* physical base address of controller */
193 dma_addr_t pbase; 191 dma_addr_t pbase;
@@ -312,13 +310,11 @@ static int cf_init(struct arasan_cf_dev *acdev)
312 unsigned long flags; 310 unsigned long flags;
313 int ret = 0; 311 int ret = 0;
314 312
315#ifdef CONFIG_HAVE_CLK
316 ret = clk_enable(acdev->clk); 313 ret = clk_enable(acdev->clk);
317 if (ret) { 314 if (ret) {
318 dev_dbg(acdev->host->dev, "clock enable failed"); 315 dev_dbg(acdev->host->dev, "clock enable failed");
319 return ret; 316 return ret;
320 } 317 }
321#endif
322 318
323 spin_lock_irqsave(&acdev->host->lock, flags); 319 spin_lock_irqsave(&acdev->host->lock, flags);
324 /* configure CF interface clock */ 320 /* configure CF interface clock */
@@ -344,9 +340,7 @@ static void cf_exit(struct arasan_cf_dev *acdev)
344 writel(readl(acdev->vbase + OP_MODE) & ~CFHOST_ENB, 340 writel(readl(acdev->vbase + OP_MODE) & ~CFHOST_ENB,
345 acdev->vbase + OP_MODE); 341 acdev->vbase + OP_MODE);
346 spin_unlock_irqrestore(&acdev->host->lock, flags); 342 spin_unlock_irqrestore(&acdev->host->lock, flags);
347#ifdef CONFIG_HAVE_CLK
348 clk_disable(acdev->clk); 343 clk_disable(acdev->clk);
349#endif
350} 344}
351 345
352static void dma_callback(void *dev) 346static void dma_callback(void *dev)
@@ -828,13 +822,11 @@ static int __devinit arasan_cf_probe(struct platform_device *pdev)
828 return -ENOMEM; 822 return -ENOMEM;
829 } 823 }
830 824
831#ifdef CONFIG_HAVE_CLK
832 acdev->clk = clk_get(&pdev->dev, NULL); 825 acdev->clk = clk_get(&pdev->dev, NULL);
833 if (IS_ERR(acdev->clk)) { 826 if (IS_ERR(acdev->clk)) {
834 dev_warn(&pdev->dev, "Clock not found\n"); 827 dev_warn(&pdev->dev, "Clock not found\n");
835 return PTR_ERR(acdev->clk); 828 return PTR_ERR(acdev->clk);
836 } 829 }
837#endif
838 830
839 /* allocate host */ 831 /* allocate host */
840 host = ata_host_alloc(&pdev->dev, 1); 832 host = ata_host_alloc(&pdev->dev, 1);
@@ -899,9 +891,7 @@ static int __devinit arasan_cf_probe(struct platform_device *pdev)
899 &arasan_cf_sht); 891 &arasan_cf_sht);
900 892
901free_clk: 893free_clk:
902#ifdef CONFIG_HAVE_CLK
903 clk_put(acdev->clk); 894 clk_put(acdev->clk);
904#endif
905 return ret; 895 return ret;
906} 896}
907 897
@@ -912,9 +902,7 @@ static int __devexit arasan_cf_remove(struct platform_device *pdev)
912 902
913 ata_host_detach(host); 903 ata_host_detach(host);
914 cf_exit(acdev); 904 cf_exit(acdev);
915#ifdef CONFIG_HAVE_CLK
916 clk_put(acdev->clk); 905 clk_put(acdev->clk);
917#endif
918 906
919 return 0; 907 return 0;
920} 908}
diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig
index 3f99b909965..7f0b5ca7851 100644
--- a/drivers/clk/Kconfig
+++ b/drivers/clk/Kconfig
@@ -25,7 +25,6 @@ menu "Common Clock Framework"
25 25
26config COMMON_CLK_DEBUG 26config COMMON_CLK_DEBUG
27 bool "DebugFS representation of clock tree" 27 bool "DebugFS representation of clock tree"
28 depends on COMMON_CLK
29 select DEBUG_FS 28 select DEBUG_FS
30 ---help--- 29 ---help---
31 Creates a directory hierchy in debugfs for visualizing the clk 30 Creates a directory hierchy in debugfs for visualizing the clk
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index c87fdd71056..efdfd009c27 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -465,6 +465,9 @@ static void __clk_disable(struct clk *clk)
465 if (!clk) 465 if (!clk)
466 return; 466 return;
467 467
468 if (WARN_ON(IS_ERR(clk)))
469 return;
470
468 if (WARN_ON(clk->enable_count == 0)) 471 if (WARN_ON(clk->enable_count == 0))
469 return; 472 return;
470 473
diff --git a/drivers/firmware/memmap.c b/drivers/firmware/memmap.c
index adc07102a20..c1cdc923666 100644
--- a/drivers/firmware/memmap.c
+++ b/drivers/firmware/memmap.c
@@ -98,7 +98,7 @@ static LIST_HEAD(map_entries);
98/** 98/**
99 * firmware_map_add_entry() - Does the real work to add a firmware memmap entry. 99 * firmware_map_add_entry() - Does the real work to add a firmware memmap entry.
100 * @start: Start of the memory range. 100 * @start: Start of the memory range.
101 * @end: End of the memory range (inclusive). 101 * @end: End of the memory range (exclusive).
102 * @type: Type of the memory range. 102 * @type: Type of the memory range.
103 * @entry: Pre-allocated (either kmalloc() or bootmem allocator), uninitialised 103 * @entry: Pre-allocated (either kmalloc() or bootmem allocator), uninitialised
104 * entry. 104 * entry.
@@ -113,7 +113,7 @@ static int firmware_map_add_entry(u64 start, u64 end,
113 BUG_ON(start > end); 113 BUG_ON(start > end);
114 114
115 entry->start = start; 115 entry->start = start;
116 entry->end = end; 116 entry->end = end - 1;
117 entry->type = type; 117 entry->type = type;
118 INIT_LIST_HEAD(&entry->list); 118 INIT_LIST_HEAD(&entry->list);
119 kobject_init(&entry->kobj, &memmap_ktype); 119 kobject_init(&entry->kobj, &memmap_ktype);
@@ -148,7 +148,7 @@ static int add_sysfs_fw_map_entry(struct firmware_map_entry *entry)
148 * firmware_map_add_hotplug() - Adds a firmware mapping entry when we do 148 * firmware_map_add_hotplug() - Adds a firmware mapping entry when we do
149 * memory hotplug. 149 * memory hotplug.
150 * @start: Start of the memory range. 150 * @start: Start of the memory range.
151 * @end: End of the memory range (inclusive). 151 * @end: End of the memory range (exclusive)
152 * @type: Type of the memory range. 152 * @type: Type of the memory range.
153 * 153 *
154 * Adds a firmware mapping entry. This function is for memory hotplug, it is 154 * Adds a firmware mapping entry. This function is for memory hotplug, it is
@@ -175,7 +175,7 @@ int __meminit firmware_map_add_hotplug(u64 start, u64 end, const char *type)
175/** 175/**
176 * firmware_map_add_early() - Adds a firmware mapping entry. 176 * firmware_map_add_early() - Adds a firmware mapping entry.
177 * @start: Start of the memory range. 177 * @start: Start of the memory range.
178 * @end: End of the memory range (inclusive). 178 * @end: End of the memory range.
179 * @type: Type of the memory range. 179 * @type: Type of the memory range.
180 * 180 *
181 * Adds a firmware mapping entry. This function uses the bootmem allocator 181 * Adds a firmware mapping entry. This function uses the bootmem allocator
diff --git a/drivers/firmware/pcdp.c b/drivers/firmware/pcdp.c
index 51e0e2d8fac..a330492e06f 100644
--- a/drivers/firmware/pcdp.c
+++ b/drivers/firmware/pcdp.c
@@ -95,7 +95,7 @@ efi_setup_pcdp_console(char *cmdline)
95 if (efi.hcdp == EFI_INVALID_TABLE_ADDR) 95 if (efi.hcdp == EFI_INVALID_TABLE_ADDR)
96 return -ENODEV; 96 return -ENODEV;
97 97
98 pcdp = ioremap(efi.hcdp, 4096); 98 pcdp = early_ioremap(efi.hcdp, 4096);
99 printk(KERN_INFO "PCDP: v%d at 0x%lx\n", pcdp->rev, efi.hcdp); 99 printk(KERN_INFO "PCDP: v%d at 0x%lx\n", pcdp->rev, efi.hcdp);
100 100
101 if (strstr(cmdline, "console=hcdp")) { 101 if (strstr(cmdline, "console=hcdp")) {
@@ -131,6 +131,6 @@ efi_setup_pcdp_console(char *cmdline)
131 } 131 }
132 132
133out: 133out:
134 iounmap(pcdp); 134 early_iounmap(pcdp, 4096);
135 return rc; 135 return rc;
136} 136}
diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
index a997c7d3f95..1034d93fb83 100644
--- a/drivers/i2c/busses/i2c-pxa.c
+++ b/drivers/i2c/busses/i2c-pxa.c
@@ -41,13 +41,6 @@
41 41
42#include <asm/irq.h> 42#include <asm/irq.h>
43 43
44#ifndef CONFIG_HAVE_CLK
45#define clk_get(dev, id) NULL
46#define clk_put(clk) do { } while (0)
47#define clk_disable(clk) do { } while (0)
48#define clk_enable(clk) do { } while (0)
49#endif
50
51struct pxa_reg_layout { 44struct pxa_reg_layout {
52 u32 ibmr; 45 u32 ibmr;
53 u32 idbr; 46 u32 idbr;
diff --git a/drivers/md/dm-log.c b/drivers/md/dm-log.c
index 65ebaebf502..627d19186d5 100644
--- a/drivers/md/dm-log.c
+++ b/drivers/md/dm-log.c
@@ -571,16 +571,6 @@ static void disk_dtr(struct dm_dirty_log *log)
571 destroy_log_context(lc); 571 destroy_log_context(lc);
572} 572}
573 573
574static int count_bits32(uint32_t *addr, unsigned size)
575{
576 int count = 0, i;
577
578 for (i = 0; i < size; i++) {
579 count += hweight32(*(addr+i));
580 }
581 return count;
582}
583
584static void fail_log_device(struct log_c *lc) 574static void fail_log_device(struct log_c *lc)
585{ 575{
586 if (lc->log_dev_failed) 576 if (lc->log_dev_failed)
@@ -629,7 +619,8 @@ static int disk_resume(struct dm_dirty_log *log)
629 619
630 /* copy clean across to sync */ 620 /* copy clean across to sync */
631 memcpy(lc->sync_bits, lc->clean_bits, size); 621 memcpy(lc->sync_bits, lc->clean_bits, size);
632 lc->sync_count = count_bits32(lc->clean_bits, lc->bitset_uint32_count); 622 lc->sync_count = memweight(lc->clean_bits,
623 lc->bitset_uint32_count * sizeof(uint32_t));
633 lc->sync_search = 0; 624 lc->sync_search = 0;
634 625
635 /* set the correct number of regions in the header */ 626 /* set the correct number of regions in the header */
diff --git a/drivers/media/video/uvc/uvc_ctrl.c b/drivers/media/video/uvc/uvc_ctrl.c
index af26bbe6f76..f7061a5ef1d 100644
--- a/drivers/media/video/uvc/uvc_ctrl.c
+++ b/drivers/media/video/uvc/uvc_ctrl.c
@@ -2083,7 +2083,7 @@ int uvc_ctrl_init_device(struct uvc_device *dev)
2083 /* Walk the entities list and instantiate controls */ 2083 /* Walk the entities list and instantiate controls */
2084 list_for_each_entry(entity, &dev->entities, list) { 2084 list_for_each_entry(entity, &dev->entities, list) {
2085 struct uvc_control *ctrl; 2085 struct uvc_control *ctrl;
2086 unsigned int bControlSize = 0, ncontrols = 0; 2086 unsigned int bControlSize = 0, ncontrols;
2087 __u8 *bmControls = NULL; 2087 __u8 *bmControls = NULL;
2088 2088
2089 if (UVC_ENTITY_TYPE(entity) == UVC_VC_EXTENSION_UNIT) { 2089 if (UVC_ENTITY_TYPE(entity) == UVC_VC_EXTENSION_UNIT) {
@@ -2101,8 +2101,7 @@ int uvc_ctrl_init_device(struct uvc_device *dev)
2101 uvc_ctrl_prune_entity(dev, entity); 2101 uvc_ctrl_prune_entity(dev, entity);
2102 2102
2103 /* Count supported controls and allocate the controls array */ 2103 /* Count supported controls and allocate the controls array */
2104 for (i = 0; i < bControlSize; ++i) 2104 ncontrols = memweight(bmControls, bControlSize);
2105 ncontrols += hweight8(bmControls[i]);
2106 if (ncontrols == 0) 2105 if (ncontrols == 0)
2107 continue; 2106 continue;
2108 2107
diff --git a/drivers/message/i2o/i2o_config.c b/drivers/message/i2o/i2o_config.c
index 098de2b3578..9a49c243a6a 100644
--- a/drivers/message/i2o/i2o_config.c
+++ b/drivers/message/i2o/i2o_config.c
@@ -188,6 +188,13 @@ static int i2o_cfg_parms(unsigned long arg, unsigned int type)
188 if (!dev) 188 if (!dev)
189 return -ENXIO; 189 return -ENXIO;
190 190
191 /*
192 * Stop users being able to try and allocate arbitary amounts
193 * of DMA space. 64K is way more than sufficient for this.
194 */
195 if (kcmd.oplen > 65536)
196 return -EMSGSIZE;
197
191 ops = memdup_user(kcmd.opbuf, kcmd.oplen); 198 ops = memdup_user(kcmd.opbuf, kcmd.oplen);
192 if (IS_ERR(ops)) 199 if (IS_ERR(ops))
193 return PTR_ERR(ops); 200 return PTR_ERR(ops);
diff --git a/drivers/message/i2o/i2o_proc.c b/drivers/message/i2o/i2o_proc.c
index 506c36f6e1d..8001aa6bfb4 100644
--- a/drivers/message/i2o/i2o_proc.c
+++ b/drivers/message/i2o/i2o_proc.c
@@ -255,9 +255,8 @@ static char *scsi_devices[] = {
255 "Array Controller Device" 255 "Array Controller Device"
256}; 256};
257 257
258static char *chtostr(u8 * chars, int n) 258static char *chtostr(char *tmp, u8 *chars, int n)
259{ 259{
260 char tmp[256];
261 tmp[0] = 0; 260 tmp[0] = 0;
262 return strncat(tmp, (char *)chars, n); 261 return strncat(tmp, (char *)chars, n);
263} 262}
@@ -791,6 +790,7 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
791 } *result; 790 } *result;
792 791
793 i2o_exec_execute_ddm_table ddm_table; 792 i2o_exec_execute_ddm_table ddm_table;
793 char tmp[28 + 1];
794 794
795 result = kmalloc(sizeof(*result), GFP_KERNEL); 795 result = kmalloc(sizeof(*result), GFP_KERNEL);
796 if (!result) 796 if (!result)
@@ -826,7 +826,7 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
826 seq_printf(seq, "%-#7x", ddm_table.i2o_vendor_id); 826 seq_printf(seq, "%-#7x", ddm_table.i2o_vendor_id);
827 seq_printf(seq, "%-#8x", ddm_table.module_id); 827 seq_printf(seq, "%-#8x", ddm_table.module_id);
828 seq_printf(seq, "%-29s", 828 seq_printf(seq, "%-29s",
829 chtostr(ddm_table.module_name_version, 28)); 829 chtostr(tmp, ddm_table.module_name_version, 28));
830 seq_printf(seq, "%9d ", ddm_table.data_size); 830 seq_printf(seq, "%9d ", ddm_table.data_size);
831 seq_printf(seq, "%8d", ddm_table.code_size); 831 seq_printf(seq, "%8d", ddm_table.code_size);
832 832
@@ -893,6 +893,7 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
893 893
894 i2o_driver_result_table *result; 894 i2o_driver_result_table *result;
895 i2o_driver_store_table *dst; 895 i2o_driver_store_table *dst;
896 char tmp[28 + 1];
896 897
897 result = kmalloc(sizeof(i2o_driver_result_table), GFP_KERNEL); 898 result = kmalloc(sizeof(i2o_driver_result_table), GFP_KERNEL);
898 if (result == NULL) 899 if (result == NULL)
@@ -927,8 +928,9 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
927 928
928 seq_printf(seq, "%-#7x", dst->i2o_vendor_id); 929 seq_printf(seq, "%-#7x", dst->i2o_vendor_id);
929 seq_printf(seq, "%-#8x", dst->module_id); 930 seq_printf(seq, "%-#8x", dst->module_id);
930 seq_printf(seq, "%-29s", chtostr(dst->module_name_version, 28)); 931 seq_printf(seq, "%-29s",
931 seq_printf(seq, "%-9s", chtostr(dst->date, 8)); 932 chtostr(tmp, dst->module_name_version, 28));
933 seq_printf(seq, "%-9s", chtostr(tmp, dst->date, 8));
932 seq_printf(seq, "%8d ", dst->module_size); 934 seq_printf(seq, "%8d ", dst->module_size);
933 seq_printf(seq, "%8d ", dst->mpb_size); 935 seq_printf(seq, "%8d ", dst->mpb_size);
934 seq_printf(seq, "0x%04x", dst->module_flags); 936 seq_printf(seq, "0x%04x", dst->module_flags);
@@ -1248,6 +1250,7 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
1248 // == (allow) 512d bytes (max) 1250 // == (allow) 512d bytes (max)
1249 static u16 *work16 = (u16 *) work32; 1251 static u16 *work16 = (u16 *) work32;
1250 int token; 1252 int token;
1253 char tmp[16 + 1];
1251 1254
1252 token = i2o_parm_field_get(d, 0xF100, -1, &work32, sizeof(work32)); 1255 token = i2o_parm_field_get(d, 0xF100, -1, &work32, sizeof(work32));
1253 1256
@@ -1260,13 +1263,13 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
1260 seq_printf(seq, "Owner TID : %0#5x\n", work16[2]); 1263 seq_printf(seq, "Owner TID : %0#5x\n", work16[2]);
1261 seq_printf(seq, "Parent TID : %0#5x\n", work16[3]); 1264 seq_printf(seq, "Parent TID : %0#5x\n", work16[3]);
1262 seq_printf(seq, "Vendor info : %s\n", 1265 seq_printf(seq, "Vendor info : %s\n",
1263 chtostr((u8 *) (work32 + 2), 16)); 1266 chtostr(tmp, (u8 *) (work32 + 2), 16));
1264 seq_printf(seq, "Product info : %s\n", 1267 seq_printf(seq, "Product info : %s\n",
1265 chtostr((u8 *) (work32 + 6), 16)); 1268 chtostr(tmp, (u8 *) (work32 + 6), 16));
1266 seq_printf(seq, "Description : %s\n", 1269 seq_printf(seq, "Description : %s\n",
1267 chtostr((u8 *) (work32 + 10), 16)); 1270 chtostr(tmp, (u8 *) (work32 + 10), 16));
1268 seq_printf(seq, "Product rev. : %s\n", 1271 seq_printf(seq, "Product rev. : %s\n",
1269 chtostr((u8 *) (work32 + 14), 8)); 1272 chtostr(tmp, (u8 *) (work32 + 14), 8));
1270 1273
1271 seq_printf(seq, "Serial number : "); 1274 seq_printf(seq, "Serial number : ");
1272 print_serial_number(seq, (u8 *) (work32 + 16), 1275 print_serial_number(seq, (u8 *) (work32 + 16),
@@ -1303,6 +1306,8 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
1303 u8 pad[256]; // allow up to 256 byte (max) serial number 1306 u8 pad[256]; // allow up to 256 byte (max) serial number
1304 } result; 1307 } result;
1305 1308
1309 char tmp[24 + 1];
1310
1306 token = i2o_parm_field_get(d, 0xF101, -1, &result, sizeof(result)); 1311 token = i2o_parm_field_get(d, 0xF101, -1, &result, sizeof(result));
1307 1312
1308 if (token < 0) { 1313 if (token < 0) {
@@ -1312,9 +1317,9 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
1312 1317
1313 seq_printf(seq, "Registering DDM TID : 0x%03x\n", result.ddm_tid); 1318 seq_printf(seq, "Registering DDM TID : 0x%03x\n", result.ddm_tid);
1314 seq_printf(seq, "Module name : %s\n", 1319 seq_printf(seq, "Module name : %s\n",
1315 chtostr(result.module_name, 24)); 1320 chtostr(tmp, result.module_name, 24));
1316 seq_printf(seq, "Module revision : %s\n", 1321 seq_printf(seq, "Module revision : %s\n",
1317 chtostr(result.module_rev, 8)); 1322 chtostr(tmp, result.module_rev, 8));
1318 1323
1319 seq_printf(seq, "Serial number : "); 1324 seq_printf(seq, "Serial number : ");
1320 print_serial_number(seq, result.serial_number, sizeof(result) - 36); 1325 print_serial_number(seq, result.serial_number, sizeof(result) - 36);
@@ -1338,6 +1343,8 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
1338 u8 instance_number[4]; 1343 u8 instance_number[4];
1339 } result; 1344 } result;
1340 1345
1346 char tmp[64 + 1];
1347
1341 token = i2o_parm_field_get(d, 0xF102, -1, &result, sizeof(result)); 1348 token = i2o_parm_field_get(d, 0xF102, -1, &result, sizeof(result));
1342 1349
1343 if (token < 0) { 1350 if (token < 0) {
@@ -1346,13 +1353,13 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
1346 } 1353 }
1347 1354
1348 seq_printf(seq, "Device name : %s\n", 1355 seq_printf(seq, "Device name : %s\n",
1349 chtostr(result.device_name, 64)); 1356 chtostr(tmp, result.device_name, 64));
1350 seq_printf(seq, "Service name : %s\n", 1357 seq_printf(seq, "Service name : %s\n",
1351 chtostr(result.service_name, 64)); 1358 chtostr(tmp, result.service_name, 64));
1352 seq_printf(seq, "Physical name : %s\n", 1359 seq_printf(seq, "Physical name : %s\n",
1353 chtostr(result.physical_location, 64)); 1360 chtostr(tmp, result.physical_location, 64));
1354 seq_printf(seq, "Instance number : %s\n", 1361 seq_printf(seq, "Instance number : %s\n",
1355 chtostr(result.instance_number, 4)); 1362 chtostr(tmp, result.instance_number, 4));
1356 1363
1357 return 0; 1364 return 0;
1358} 1365}
diff --git a/drivers/misc/lkdtm.c b/drivers/misc/lkdtm.c
index 28adefe70f9..08aad69c8da 100644
--- a/drivers/misc/lkdtm.c
+++ b/drivers/misc/lkdtm.c
@@ -477,6 +477,8 @@ static ssize_t lkdtm_debugfs_read(struct file *f, char __user *user_buf,
477 int i, n, out; 477 int i, n, out;
478 478
479 buf = (char *)__get_free_page(GFP_KERNEL); 479 buf = (char *)__get_free_page(GFP_KERNEL);
480 if (buf == NULL)
481 return -ENOMEM;
480 482
481 n = snprintf(buf, PAGE_SIZE, "Available crash types:\n"); 483 n = snprintf(buf, PAGE_SIZE, "Available crash types:\n");
482 for (i = 0; i < ARRAY_SIZE(cp_type); i++) 484 for (i = 0; i < ARRAY_SIZE(cp_type); i++)
diff --git a/drivers/misc/ti-st/st_core.c b/drivers/misc/ti-st/st_core.c
index 2b62232c2c6..acfaeeb9e01 100644
--- a/drivers/misc/ti-st/st_core.c
+++ b/drivers/misc/ti-st/st_core.c
@@ -349,6 +349,11 @@ void st_int_recv(void *disc_data,
349 st_gdata->rx_skb = alloc_skb( 349 st_gdata->rx_skb = alloc_skb(
350 st_gdata->list[type]->max_frame_size, 350 st_gdata->list[type]->max_frame_size,
351 GFP_ATOMIC); 351 GFP_ATOMIC);
352 if (st_gdata->rx_skb == NULL) {
353 pr_err("out of memory: dropping\n");
354 goto done;
355 }
356
352 skb_reserve(st_gdata->rx_skb, 357 skb_reserve(st_gdata->rx_skb,
353 st_gdata->list[type]->reserve); 358 st_gdata->list[type]->reserve);
354 /* next 2 required for BT only */ 359 /* next 2 required for BT only */
diff --git a/drivers/net/can/c_can/c_can_platform.c b/drivers/net/can/c_can/c_can_platform.c
index f0921d16f0a..6ff7ad006c3 100644
--- a/drivers/net/can/c_can/c_can_platform.c
+++ b/drivers/net/can/c_can/c_can_platform.c
@@ -74,7 +74,6 @@ static int __devinit c_can_plat_probe(struct platform_device *pdev)
74 const struct platform_device_id *id; 74 const struct platform_device_id *id;
75 struct resource *mem; 75 struct resource *mem;
76 int irq; 76 int irq;
77#ifdef CONFIG_HAVE_CLK
78 struct clk *clk; 77 struct clk *clk;
79 78
80 /* get the appropriate clk */ 79 /* get the appropriate clk */
@@ -84,7 +83,6 @@ static int __devinit c_can_plat_probe(struct platform_device *pdev)
84 ret = -ENODEV; 83 ret = -ENODEV;
85 goto exit; 84 goto exit;
86 } 85 }
87#endif
88 86
89 /* get the platform data */ 87 /* get the platform data */
90 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); 88 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -145,10 +143,8 @@ static int __devinit c_can_plat_probe(struct platform_device *pdev)
145 143
146 dev->irq = irq; 144 dev->irq = irq;
147 priv->base = addr; 145 priv->base = addr;
148#ifdef CONFIG_HAVE_CLK
149 priv->can.clock.freq = clk_get_rate(clk); 146 priv->can.clock.freq = clk_get_rate(clk);
150 priv->priv = clk; 147 priv->priv = clk;
151#endif
152 148
153 platform_set_drvdata(pdev, dev); 149 platform_set_drvdata(pdev, dev);
154 SET_NETDEV_DEV(dev, &pdev->dev); 150 SET_NETDEV_DEV(dev, &pdev->dev);
@@ -172,10 +168,8 @@ exit_iounmap:
172exit_release_mem: 168exit_release_mem:
173 release_mem_region(mem->start, resource_size(mem)); 169 release_mem_region(mem->start, resource_size(mem));
174exit_free_clk: 170exit_free_clk:
175#ifdef CONFIG_HAVE_CLK
176 clk_put(clk); 171 clk_put(clk);
177exit: 172exit:
178#endif
179 dev_err(&pdev->dev, "probe failed\n"); 173 dev_err(&pdev->dev, "probe failed\n");
180 174
181 return ret; 175 return ret;
@@ -196,9 +190,7 @@ static int __devexit c_can_plat_remove(struct platform_device *pdev)
196 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); 190 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
197 release_mem_region(mem->start, resource_size(mem)); 191 release_mem_region(mem->start, resource_size(mem));
198 192
199#ifdef CONFIG_HAVE_CLK
200 clk_put(priv->priv); 193 clk_put(priv->priv);
201#endif
202 194
203 return 0; 195 return 0;
204} 196}
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h
index ab4c376cb27..f2d3665430a 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h
@@ -82,9 +82,7 @@ struct stmmac_priv {
82 struct stmmac_counters mmc; 82 struct stmmac_counters mmc;
83 struct dma_features dma_cap; 83 struct dma_features dma_cap;
84 int hw_cap_support; 84 int hw_cap_support;
85#ifdef CONFIG_HAVE_CLK
86 struct clk *stmmac_clk; 85 struct clk *stmmac_clk;
87#endif
88 int clk_csr; 86 int clk_csr;
89 int synopsys_id; 87 int synopsys_id;
90 struct timer_list eee_ctrl_timer; 88 struct timer_list eee_ctrl_timer;
@@ -113,46 +111,6 @@ struct stmmac_priv *stmmac_dvr_probe(struct device *device,
113void stmmac_disable_eee_mode(struct stmmac_priv *priv); 111void stmmac_disable_eee_mode(struct stmmac_priv *priv);
114bool stmmac_eee_init(struct stmmac_priv *priv); 112bool stmmac_eee_init(struct stmmac_priv *priv);
115 113
116#ifdef CONFIG_HAVE_CLK
117static inline int stmmac_clk_enable(struct stmmac_priv *priv)
118{
119 if (!IS_ERR(priv->stmmac_clk))
120 return clk_prepare_enable(priv->stmmac_clk);
121
122 return 0;
123}
124
125static inline void stmmac_clk_disable(struct stmmac_priv *priv)
126{
127 if (IS_ERR(priv->stmmac_clk))
128 return;
129
130 clk_disable_unprepare(priv->stmmac_clk);
131}
132static inline int stmmac_clk_get(struct stmmac_priv *priv)
133{
134 priv->stmmac_clk = clk_get(priv->device, NULL);
135
136 if (IS_ERR(priv->stmmac_clk))
137 return PTR_ERR(priv->stmmac_clk);
138
139 return 0;
140}
141#else
142static inline int stmmac_clk_enable(struct stmmac_priv *priv)
143{
144 return 0;
145}
146static inline void stmmac_clk_disable(struct stmmac_priv *priv)
147{
148}
149static inline int stmmac_clk_get(struct stmmac_priv *priv)
150{
151 return 0;
152}
153#endif /* CONFIG_HAVE_CLK */
154
155
156#ifdef CONFIG_STMMAC_PLATFORM 114#ifdef CONFIG_STMMAC_PLATFORM
157extern struct platform_driver stmmac_pltfr_driver; 115extern struct platform_driver stmmac_pltfr_driver;
158static inline int stmmac_register_platform(void) 116static inline int stmmac_register_platform(void)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index f6b04c1a367..fd8882f9602 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -28,6 +28,7 @@
28 https://bugzilla.stlinux.com/ 28 https://bugzilla.stlinux.com/
29*******************************************************************************/ 29*******************************************************************************/
30 30
31#include <linux/clk.h>
31#include <linux/kernel.h> 32#include <linux/kernel.h>
32#include <linux/interrupt.h> 33#include <linux/interrupt.h>
33#include <linux/ip.h> 34#include <linux/ip.h>
@@ -173,12 +174,8 @@ static void stmmac_verify_args(void)
173 174
174static void stmmac_clk_csr_set(struct stmmac_priv *priv) 175static void stmmac_clk_csr_set(struct stmmac_priv *priv)
175{ 176{
176#ifdef CONFIG_HAVE_CLK
177 u32 clk_rate; 177 u32 clk_rate;
178 178
179 if (IS_ERR(priv->stmmac_clk))
180 return;
181
182 clk_rate = clk_get_rate(priv->stmmac_clk); 179 clk_rate = clk_get_rate(priv->stmmac_clk);
183 180
184 /* Platform provided default clk_csr would be assumed valid 181 /* Platform provided default clk_csr would be assumed valid
@@ -200,7 +197,6 @@ static void stmmac_clk_csr_set(struct stmmac_priv *priv)
200 * we can not estimate the proper divider as it is not known 197 * we can not estimate the proper divider as it is not known
201 * the frequency of clk_csr_i. So we do not change the default 198 * the frequency of clk_csr_i. So we do not change the default
202 * divider. */ 199 * divider. */
203#endif
204} 200}
205 201
206#if defined(STMMAC_XMIT_DEBUG) || defined(STMMAC_RX_DEBUG) 202#if defined(STMMAC_XMIT_DEBUG) || defined(STMMAC_RX_DEBUG)
@@ -1070,7 +1066,7 @@ static int stmmac_open(struct net_device *dev)
1070 } else 1066 } else
1071 priv->tm->enable = 1; 1067 priv->tm->enable = 1;
1072#endif 1068#endif
1073 stmmac_clk_enable(priv); 1069 clk_enable(priv->stmmac_clk);
1074 1070
1075 stmmac_check_ether_addr(priv); 1071 stmmac_check_ether_addr(priv);
1076 1072
@@ -1192,7 +1188,7 @@ open_error:
1192 if (priv->phydev) 1188 if (priv->phydev)
1193 phy_disconnect(priv->phydev); 1189 phy_disconnect(priv->phydev);
1194 1190
1195 stmmac_clk_disable(priv); 1191 clk_disable(priv->stmmac_clk);
1196 1192
1197 return ret; 1193 return ret;
1198} 1194}
@@ -1250,7 +1246,7 @@ static int stmmac_release(struct net_device *dev)
1250#ifdef CONFIG_STMMAC_DEBUG_FS 1246#ifdef CONFIG_STMMAC_DEBUG_FS
1251 stmmac_exit_fs(); 1247 stmmac_exit_fs();
1252#endif 1248#endif
1253 stmmac_clk_disable(priv); 1249 clk_disable(priv->stmmac_clk);
1254 1250
1255 return 0; 1251 return 0;
1256} 1252}
@@ -2078,11 +2074,14 @@ struct stmmac_priv *stmmac_dvr_probe(struct device *device,
2078 ret = register_netdev(ndev); 2074 ret = register_netdev(ndev);
2079 if (ret) { 2075 if (ret) {
2080 pr_err("%s: ERROR %i registering the device\n", __func__, ret); 2076 pr_err("%s: ERROR %i registering the device\n", __func__, ret);
2081 goto error; 2077 goto error_netdev_register;
2082 } 2078 }
2083 2079
2084 if (stmmac_clk_get(priv)) 2080 priv->stmmac_clk = clk_get(priv->device, NULL);
2081 if (IS_ERR(priv->stmmac_clk)) {
2085 pr_warning("%s: warning: cannot get CSR clock\n", __func__); 2082 pr_warning("%s: warning: cannot get CSR clock\n", __func__);
2083 goto error_clk_get;
2084 }
2086 2085
2087 /* If a specific clk_csr value is passed from the platform 2086 /* If a specific clk_csr value is passed from the platform
2088 * this means that the CSR Clock Range selection cannot be 2087 * this means that the CSR Clock Range selection cannot be
@@ -2100,15 +2099,17 @@ struct stmmac_priv *stmmac_dvr_probe(struct device *device,
2100 if (ret < 0) { 2099 if (ret < 0) {
2101 pr_debug("%s: MDIO bus (id: %d) registration failed", 2100 pr_debug("%s: MDIO bus (id: %d) registration failed",
2102 __func__, priv->plat->bus_id); 2101 __func__, priv->plat->bus_id);
2103 goto error; 2102 goto error_mdio_register;
2104 } 2103 }
2105 2104
2106 return priv; 2105 return priv;
2107 2106
2108error: 2107error_mdio_register:
2109 netif_napi_del(&priv->napi); 2108 clk_put(priv->stmmac_clk);
2110 2109error_clk_get:
2111 unregister_netdev(ndev); 2110 unregister_netdev(ndev);
2111error_netdev_register:
2112 netif_napi_del(&priv->napi);
2112 free_netdev(ndev); 2113 free_netdev(ndev);
2113 2114
2114 return NULL; 2115 return NULL;
@@ -2177,7 +2178,7 @@ int stmmac_suspend(struct net_device *ndev)
2177 else { 2178 else {
2178 stmmac_set_mac(priv->ioaddr, false); 2179 stmmac_set_mac(priv->ioaddr, false);
2179 /* Disable clock in case of PWM is off */ 2180 /* Disable clock in case of PWM is off */
2180 stmmac_clk_disable(priv); 2181 clk_disable(priv->stmmac_clk);
2181 } 2182 }
2182 spin_unlock_irqrestore(&priv->lock, flags); 2183 spin_unlock_irqrestore(&priv->lock, flags);
2183 return 0; 2184 return 0;
@@ -2202,7 +2203,7 @@ int stmmac_resume(struct net_device *ndev)
2202 priv->hw->mac->pmt(priv->ioaddr, 0); 2203 priv->hw->mac->pmt(priv->ioaddr, 0);
2203 else 2204 else
2204 /* enable the clk prevously disabled */ 2205 /* enable the clk prevously disabled */
2205 stmmac_clk_enable(priv); 2206 clk_enable(priv->stmmac_clk);
2206 2207
2207 netif_device_attach(ndev); 2208 netif_device_attach(ndev);
2208 2209
diff --git a/drivers/pps/pps.c b/drivers/pps/pps.c
index 98fbe62694d..e771487132f 100644
--- a/drivers/pps/pps.c
+++ b/drivers/pps/pps.c
@@ -327,8 +327,10 @@ int pps_register_cdev(struct pps_device *pps)
327 } 327 }
328 pps->dev = device_create(pps_class, pps->info.dev, devt, pps, 328 pps->dev = device_create(pps_class, pps->info.dev, devt, pps,
329 "pps%d", pps->id); 329 "pps%d", pps->id);
330 if (IS_ERR(pps->dev)) 330 if (IS_ERR(pps->dev)) {
331 err = PTR_ERR(pps->dev);
331 goto del_cdev; 332 goto del_cdev;
333 }
332 334
333 pps->dev->release = pps_device_destruct; 335 pps->dev->release = pps_device_destruct;
334 336
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index f049c02413c..fabc99a75c6 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -704,6 +704,7 @@ config RTC_DRV_AB3100
704config RTC_DRV_AB8500 704config RTC_DRV_AB8500
705 tristate "ST-Ericsson AB8500 RTC" 705 tristate "ST-Ericsson AB8500 RTC"
706 depends on AB8500_CORE 706 depends on AB8500_CORE
707 select RTC_INTF_DEV_UIE_EMUL
707 help 708 help
708 Select this to enable the ST-Ericsson AB8500 power management IC RTC 709 Select this to enable the ST-Ericsson AB8500 power management IC RTC
709 support. This chip contains a battery- and capacitor-backed RTC. 710 support. This chip contains a battery- and capacitor-backed RTC.
diff --git a/drivers/rtc/rtc-ab8500.c b/drivers/rtc/rtc-ab8500.c
index 370889d0489..bf3c2f669c3 100644
--- a/drivers/rtc/rtc-ab8500.c
+++ b/drivers/rtc/rtc-ab8500.c
@@ -89,22 +89,17 @@ static int ab8500_rtc_read_time(struct device *dev, struct rtc_time *tm)
89 if (retval < 0) 89 if (retval < 0)
90 return retval; 90 return retval;
91 91
92 /* Early AB8500 chips will not clear the rtc read request bit */ 92 /* Wait for some cycles after enabling the rtc read in ab8500 */
93 if (abx500_get_chip_id(dev) == 0) { 93 while (time_before(jiffies, timeout)) {
94 usleep_range(1000, 1000); 94 retval = abx500_get_register_interruptible(dev,
95 } else { 95 AB8500_RTC, AB8500_RTC_READ_REQ_REG, &value);
96 /* Wait for some cycles after enabling the rtc read in ab8500 */ 96 if (retval < 0)
97 while (time_before(jiffies, timeout)) { 97 return retval;
98 retval = abx500_get_register_interruptible(dev, 98
99 AB8500_RTC, AB8500_RTC_READ_REQ_REG, &value); 99 if (!(value & RTC_READ_REQUEST))
100 if (retval < 0) 100 break;
101 return retval; 101
102 102 usleep_range(1000, 5000);
103 if (!(value & RTC_READ_REQUEST))
104 break;
105
106 usleep_range(1000, 5000);
107 }
108 } 103 }
109 104
110 /* Read the Watchtime registers */ 105 /* Read the Watchtime registers */
@@ -225,7 +220,8 @@ static int ab8500_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)
225{ 220{
226 int retval, i; 221 int retval, i;
227 unsigned char buf[ARRAY_SIZE(ab8500_rtc_alarm_regs)]; 222 unsigned char buf[ARRAY_SIZE(ab8500_rtc_alarm_regs)];
228 unsigned long mins, secs = 0; 223 unsigned long mins, secs = 0, cursec = 0;
224 struct rtc_time curtm;
229 225
230 if (alarm->time.tm_year < (AB8500_RTC_EPOCH - 1900)) { 226 if (alarm->time.tm_year < (AB8500_RTC_EPOCH - 1900)) {
231 dev_dbg(dev, "year should be equal to or greater than %d\n", 227 dev_dbg(dev, "year should be equal to or greater than %d\n",
@@ -237,6 +233,18 @@ static int ab8500_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)
237 rtc_tm_to_time(&alarm->time, &secs); 233 rtc_tm_to_time(&alarm->time, &secs);
238 234
239 /* 235 /*
236 * Check whether alarm is set less than 1min.
237 * Since our RTC doesn't support alarm resolution less than 1min,
238 * return -EINVAL, so UIE EMUL can take it up, incase of UIE_ON
239 */
240 ab8500_rtc_read_time(dev, &curtm); /* Read current time */
241 rtc_tm_to_time(&curtm, &cursec);
242 if ((secs - cursec) < 59) {
243 dev_dbg(dev, "Alarm less than 1 minute not supported\r\n");
244 return -EINVAL;
245 }
246
247 /*
240 * Convert it to the number of seconds since 01-01-2000 00:00:00, since 248 * Convert it to the number of seconds since 01-01-2000 00:00:00, since
241 * we only have a small counter in the RTC. 249 * we only have a small counter in the RTC.
242 */ 250 */
diff --git a/drivers/rtc/rtc-coh901331.c b/drivers/rtc/rtc-coh901331.c
index a5b8a0c4ea8..76b2156d3c6 100644
--- a/drivers/rtc/rtc-coh901331.c
+++ b/drivers/rtc/rtc-coh901331.c
@@ -155,13 +155,10 @@ static int __exit coh901331_remove(struct platform_device *pdev)
155 struct coh901331_port *rtap = dev_get_drvdata(&pdev->dev); 155 struct coh901331_port *rtap = dev_get_drvdata(&pdev->dev);
156 156
157 if (rtap) { 157 if (rtap) {
158 free_irq(rtap->irq, rtap);
159 rtc_device_unregister(rtap->rtc); 158 rtc_device_unregister(rtap->rtc);
159 clk_unprepare(rtap->clk);
160 clk_put(rtap->clk); 160 clk_put(rtap->clk);
161 iounmap(rtap->virtbase);
162 release_mem_region(rtap->phybase, rtap->physize);
163 platform_set_drvdata(pdev, NULL); 161 platform_set_drvdata(pdev, NULL);
164 kfree(rtap);
165 } 162 }
166 163
167 return 0; 164 return 0;
@@ -174,49 +171,43 @@ static int __init coh901331_probe(struct platform_device *pdev)
174 struct coh901331_port *rtap; 171 struct coh901331_port *rtap;
175 struct resource *res; 172 struct resource *res;
176 173
177 rtap = kzalloc(sizeof(struct coh901331_port), GFP_KERNEL); 174 rtap = devm_kzalloc(&pdev->dev,
175 sizeof(struct coh901331_port), GFP_KERNEL);
178 if (!rtap) 176 if (!rtap)
179 return -ENOMEM; 177 return -ENOMEM;
180 178
181 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 179 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
182 if (!res) { 180 if (!res)
183 ret = -ENOENT; 181 return -ENOENT;
184 goto out_no_resource; 182
185 }
186 rtap->phybase = res->start; 183 rtap->phybase = res->start;
187 rtap->physize = resource_size(res); 184 rtap->physize = resource_size(res);
188 185
189 if (request_mem_region(rtap->phybase, rtap->physize, 186 if (devm_request_mem_region(&pdev->dev, rtap->phybase, rtap->physize,
190 "rtc-coh901331") == NULL) { 187 "rtc-coh901331") == NULL)
191 ret = -EBUSY; 188 return -EBUSY;
192 goto out_no_memregion;
193 }
194 189
195 rtap->virtbase = ioremap(rtap->phybase, rtap->physize); 190 rtap->virtbase = devm_ioremap(&pdev->dev, rtap->phybase, rtap->physize);
196 if (!rtap->virtbase) { 191 if (!rtap->virtbase)
197 ret = -ENOMEM; 192 return -ENOMEM;
198 goto out_no_remap;
199 }
200 193
201 rtap->irq = platform_get_irq(pdev, 0); 194 rtap->irq = platform_get_irq(pdev, 0);
202 if (request_irq(rtap->irq, coh901331_interrupt, 0, 195 if (devm_request_irq(&pdev->dev, rtap->irq, coh901331_interrupt, 0,
203 "RTC COH 901 331 Alarm", rtap)) { 196 "RTC COH 901 331 Alarm", rtap))
204 ret = -EIO; 197 return -EIO;
205 goto out_no_irq;
206 }
207 198
208 rtap->clk = clk_get(&pdev->dev, NULL); 199 rtap->clk = clk_get(&pdev->dev, NULL);
209 if (IS_ERR(rtap->clk)) { 200 if (IS_ERR(rtap->clk)) {
210 ret = PTR_ERR(rtap->clk); 201 ret = PTR_ERR(rtap->clk);
211 dev_err(&pdev->dev, "could not get clock\n"); 202 dev_err(&pdev->dev, "could not get clock\n");
212 goto out_no_clk; 203 return ret;
213 } 204 }
214 205
215 /* We enable/disable the clock only to assure it works */ 206 /* We enable/disable the clock only to assure it works */
216 ret = clk_enable(rtap->clk); 207 ret = clk_prepare_enable(rtap->clk);
217 if (ret) { 208 if (ret) {
218 dev_err(&pdev->dev, "could not enable clock\n"); 209 dev_err(&pdev->dev, "could not enable clock\n");
219 goto out_no_clk_enable; 210 goto out_no_clk_prepenable;
220 } 211 }
221 clk_disable(rtap->clk); 212 clk_disable(rtap->clk);
222 213
@@ -232,18 +223,9 @@ static int __init coh901331_probe(struct platform_device *pdev)
232 223
233 out_no_rtc: 224 out_no_rtc:
234 platform_set_drvdata(pdev, NULL); 225 platform_set_drvdata(pdev, NULL);
235 out_no_clk_enable: 226 clk_unprepare(rtap->clk);
227 out_no_clk_prepenable:
236 clk_put(rtap->clk); 228 clk_put(rtap->clk);
237 out_no_clk:
238 free_irq(rtap->irq, rtap);
239 out_no_irq:
240 iounmap(rtap->virtbase);
241 out_no_remap:
242 platform_set_drvdata(pdev, NULL);
243 out_no_memregion:
244 release_mem_region(rtap->phybase, SZ_4K);
245 out_no_resource:
246 kfree(rtap);
247 return ret; 229 return ret;
248} 230}
249 231
@@ -265,6 +247,7 @@ static int coh901331_suspend(struct platform_device *pdev, pm_message_t state)
265 writel(0, rtap->virtbase + COH901331_IRQ_MASK); 247 writel(0, rtap->virtbase + COH901331_IRQ_MASK);
266 clk_disable(rtap->clk); 248 clk_disable(rtap->clk);
267 } 249 }
250 clk_unprepare(rtap->clk);
268 return 0; 251 return 0;
269} 252}
270 253
@@ -272,6 +255,7 @@ static int coh901331_resume(struct platform_device *pdev)
272{ 255{
273 struct coh901331_port *rtap = dev_get_drvdata(&pdev->dev); 256 struct coh901331_port *rtap = dev_get_drvdata(&pdev->dev);
274 257
258 clk_prepare(rtap->clk);
275 if (device_may_wakeup(&pdev->dev)) { 259 if (device_may_wakeup(&pdev->dev)) {
276 disable_irq_wake(rtap->irq); 260 disable_irq_wake(rtap->irq);
277 } else { 261 } else {
@@ -293,6 +277,7 @@ static void coh901331_shutdown(struct platform_device *pdev)
293 clk_enable(rtap->clk); 277 clk_enable(rtap->clk);
294 writel(0, rtap->virtbase + COH901331_IRQ_MASK); 278 writel(0, rtap->virtbase + COH901331_IRQ_MASK);
295 clk_disable(rtap->clk); 279 clk_disable(rtap->clk);
280 clk_unprepare(rtap->clk);
296} 281}
297 282
298static struct platform_driver coh901331_driver = { 283static struct platform_driver coh901331_driver = {
diff --git a/drivers/rtc/rtc-da9052.c b/drivers/rtc/rtc-da9052.c
index da6ab5291a4..78070255bd3 100644
--- a/drivers/rtc/rtc-da9052.c
+++ b/drivers/rtc/rtc-da9052.c
@@ -245,7 +245,7 @@ static int __devinit da9052_rtc_probe(struct platform_device *pdev)
245 "ALM", rtc); 245 "ALM", rtc);
246 if (ret != 0) { 246 if (ret != 0) {
247 rtc_err(rtc->da9052, "irq registration failed: %d\n", ret); 247 rtc_err(rtc->da9052, "irq registration failed: %d\n", ret);
248 goto err_mem; 248 return ret;
249 } 249 }
250 250
251 rtc->rtc = rtc_device_register(pdev->name, &pdev->dev, 251 rtc->rtc = rtc_device_register(pdev->name, &pdev->dev,
@@ -259,8 +259,6 @@ static int __devinit da9052_rtc_probe(struct platform_device *pdev)
259 259
260err_free_irq: 260err_free_irq:
261 free_irq(rtc->irq, rtc); 261 free_irq(rtc->irq, rtc);
262err_mem:
263 devm_kfree(&pdev->dev, rtc);
264 return ret; 262 return ret;
265} 263}
266 264
@@ -271,7 +269,6 @@ static int __devexit da9052_rtc_remove(struct platform_device *pdev)
271 rtc_device_unregister(rtc->rtc); 269 rtc_device_unregister(rtc->rtc);
272 free_irq(rtc->irq, rtc); 270 free_irq(rtc->irq, rtc);
273 platform_set_drvdata(pdev, NULL); 271 platform_set_drvdata(pdev, NULL);
274 devm_kfree(&pdev->dev, rtc);
275 272
276 return 0; 273 return 0;
277} 274}
diff --git a/drivers/rtc/rtc-mc13xxx.c b/drivers/rtc/rtc-mc13xxx.c
index 546f6850bff..2643d887492 100644
--- a/drivers/rtc/rtc-mc13xxx.c
+++ b/drivers/rtc/rtc-mc13xxx.c
@@ -404,9 +404,12 @@ static const struct platform_device_id mc13xxx_rtc_idtable[] = {
404 .name = "mc13783-rtc", 404 .name = "mc13783-rtc",
405 }, { 405 }, {
406 .name = "mc13892-rtc", 406 .name = "mc13892-rtc",
407 }, {
408 .name = "mc34708-rtc",
407 }, 409 },
408 { } 410 { /* sentinel */ }
409}; 411};
412MODULE_DEVICE_TABLE(platform, mc13xxx_rtc_idtable);
410 413
411static struct platform_driver mc13xxx_rtc_driver = { 414static struct platform_driver mc13xxx_rtc_driver = {
412 .id_table = mc13xxx_rtc_idtable, 415 .id_table = mc13xxx_rtc_idtable,
@@ -432,4 +435,3 @@ module_exit(mc13xxx_rtc_exit);
432MODULE_AUTHOR("Sascha Hauer <s.hauer@pengutronix.de>"); 435MODULE_AUTHOR("Sascha Hauer <s.hauer@pengutronix.de>");
433MODULE_DESCRIPTION("RTC driver for Freescale MC13XXX PMIC"); 436MODULE_DESCRIPTION("RTC driver for Freescale MC13XXX PMIC");
434MODULE_LICENSE("GPL v2"); 437MODULE_LICENSE("GPL v2");
435MODULE_ALIAS("platform:" DRIVER_NAME);
diff --git a/drivers/rtc/rtc-pcf8563.c b/drivers/rtc/rtc-pcf8563.c
index 97a3284bb7c..c2fe426a6ef 100644
--- a/drivers/rtc/rtc-pcf8563.c
+++ b/drivers/rtc/rtc-pcf8563.c
@@ -19,6 +19,7 @@
19#include <linux/rtc.h> 19#include <linux/rtc.h>
20#include <linux/slab.h> 20#include <linux/slab.h>
21#include <linux/module.h> 21#include <linux/module.h>
22#include <linux/of.h>
22 23
23#define DRV_VERSION "0.4.3" 24#define DRV_VERSION "0.4.3"
24 25
@@ -285,9 +286,19 @@ static const struct i2c_device_id pcf8563_id[] = {
285}; 286};
286MODULE_DEVICE_TABLE(i2c, pcf8563_id); 287MODULE_DEVICE_TABLE(i2c, pcf8563_id);
287 288
289#ifdef CONFIG_OF
290static const struct of_device_id pcf8563_of_match[] __devinitconst = {
291 { .compatible = "nxp,pcf8563" },
292 {}
293};
294MODULE_DEVICE_TABLE(of, pcf8563_of_match);
295#endif
296
288static struct i2c_driver pcf8563_driver = { 297static struct i2c_driver pcf8563_driver = {
289 .driver = { 298 .driver = {
290 .name = "rtc-pcf8563", 299 .name = "rtc-pcf8563",
300 .owner = THIS_MODULE,
301 .of_match_table = of_match_ptr(pcf8563_of_match),
291 }, 302 },
292 .probe = pcf8563_probe, 303 .probe = pcf8563_probe,
293 .remove = pcf8563_remove, 304 .remove = pcf8563_remove,
diff --git a/drivers/rtc/rtc-pl031.c b/drivers/rtc/rtc-pl031.c
index cc0533994f6..08378e3cc21 100644
--- a/drivers/rtc/rtc-pl031.c
+++ b/drivers/rtc/rtc-pl031.c
@@ -68,11 +68,26 @@
68 68
69#define RTC_TIMER_FREQ 32768 69#define RTC_TIMER_FREQ 32768
70 70
71/**
72 * struct pl031_vendor_data - per-vendor variations
73 * @ops: the vendor-specific operations used on this silicon version
74 * @clockwatch: if this is an ST Microelectronics silicon version with a
75 * clockwatch function
76 * @st_weekday: if this is an ST Microelectronics silicon version that need
77 * the weekday fix
78 * @irqflags: special IRQ flags per variant
79 */
80struct pl031_vendor_data {
81 struct rtc_class_ops ops;
82 bool clockwatch;
83 bool st_weekday;
84 unsigned long irqflags;
85};
86
71struct pl031_local { 87struct pl031_local {
88 struct pl031_vendor_data *vendor;
72 struct rtc_device *rtc; 89 struct rtc_device *rtc;
73 void __iomem *base; 90 void __iomem *base;
74 u8 hw_designer;
75 u8 hw_revision:4;
76}; 91};
77 92
78static int pl031_alarm_irq_enable(struct device *dev, 93static int pl031_alarm_irq_enable(struct device *dev,
@@ -303,7 +318,8 @@ static int pl031_probe(struct amba_device *adev, const struct amba_id *id)
303{ 318{
304 int ret; 319 int ret;
305 struct pl031_local *ldata; 320 struct pl031_local *ldata;
306 struct rtc_class_ops *ops = id->data; 321 struct pl031_vendor_data *vendor = id->data;
322 struct rtc_class_ops *ops = &vendor->ops;
307 unsigned long time; 323 unsigned long time;
308 324
309 ret = amba_request_regions(adev, NULL); 325 ret = amba_request_regions(adev, NULL);
@@ -315,6 +331,7 @@ static int pl031_probe(struct amba_device *adev, const struct amba_id *id)
315 ret = -ENOMEM; 331 ret = -ENOMEM;
316 goto out; 332 goto out;
317 } 333 }
334 ldata->vendor = vendor;
318 335
319 ldata->base = ioremap(adev->res.start, resource_size(&adev->res)); 336 ldata->base = ioremap(adev->res.start, resource_size(&adev->res));
320 337
@@ -325,14 +342,11 @@ static int pl031_probe(struct amba_device *adev, const struct amba_id *id)
325 342
326 amba_set_drvdata(adev, ldata); 343 amba_set_drvdata(adev, ldata);
327 344
328 ldata->hw_designer = amba_manf(adev); 345 dev_dbg(&adev->dev, "designer ID = 0x%02x\n", amba_manf(adev));
329 ldata->hw_revision = amba_rev(adev); 346 dev_dbg(&adev->dev, "revision = 0x%01x\n", amba_rev(adev));
330
331 dev_dbg(&adev->dev, "designer ID = 0x%02x\n", ldata->hw_designer);
332 dev_dbg(&adev->dev, "revision = 0x%01x\n", ldata->hw_revision);
333 347
334 /* Enable the clockwatch on ST Variants */ 348 /* Enable the clockwatch on ST Variants */
335 if (ldata->hw_designer == AMBA_VENDOR_ST) 349 if (vendor->clockwatch)
336 writel(readl(ldata->base + RTC_CR) | RTC_CR_CWEN, 350 writel(readl(ldata->base + RTC_CR) | RTC_CR_CWEN,
337 ldata->base + RTC_CR); 351 ldata->base + RTC_CR);
338 352
@@ -340,7 +354,7 @@ static int pl031_probe(struct amba_device *adev, const struct amba_id *id)
340 * On ST PL031 variants, the RTC reset value does not provide correct 354 * On ST PL031 variants, the RTC reset value does not provide correct
341 * weekday for 2000-01-01. Correct the erroneous sunday to saturday. 355 * weekday for 2000-01-01. Correct the erroneous sunday to saturday.
342 */ 356 */
343 if (ldata->hw_designer == AMBA_VENDOR_ST) { 357 if (vendor->st_weekday) {
344 if (readl(ldata->base + RTC_YDR) == 0x2000) { 358 if (readl(ldata->base + RTC_YDR) == 0x2000) {
345 time = readl(ldata->base + RTC_DR); 359 time = readl(ldata->base + RTC_DR);
346 if ((time & 360 if ((time &
@@ -361,7 +375,7 @@ static int pl031_probe(struct amba_device *adev, const struct amba_id *id)
361 } 375 }
362 376
363 if (request_irq(adev->irq[0], pl031_interrupt, 377 if (request_irq(adev->irq[0], pl031_interrupt,
364 0, "rtc-pl031", ldata)) { 378 vendor->irqflags, "rtc-pl031", ldata)) {
365 ret = -EIO; 379 ret = -EIO;
366 goto out_no_irq; 380 goto out_no_irq;
367 } 381 }
@@ -383,48 +397,65 @@ err_req:
383} 397}
384 398
385/* Operations for the original ARM version */ 399/* Operations for the original ARM version */
386static struct rtc_class_ops arm_pl031_ops = { 400static struct pl031_vendor_data arm_pl031 = {
387 .read_time = pl031_read_time, 401 .ops = {
388 .set_time = pl031_set_time, 402 .read_time = pl031_read_time,
389 .read_alarm = pl031_read_alarm, 403 .set_time = pl031_set_time,
390 .set_alarm = pl031_set_alarm, 404 .read_alarm = pl031_read_alarm,
391 .alarm_irq_enable = pl031_alarm_irq_enable, 405 .set_alarm = pl031_set_alarm,
406 .alarm_irq_enable = pl031_alarm_irq_enable,
407 },
408 .irqflags = IRQF_NO_SUSPEND,
392}; 409};
393 410
394/* The First ST derivative */ 411/* The First ST derivative */
395static struct rtc_class_ops stv1_pl031_ops = { 412static struct pl031_vendor_data stv1_pl031 = {
396 .read_time = pl031_read_time, 413 .ops = {
397 .set_time = pl031_set_time, 414 .read_time = pl031_read_time,
398 .read_alarm = pl031_read_alarm, 415 .set_time = pl031_set_time,
399 .set_alarm = pl031_set_alarm, 416 .read_alarm = pl031_read_alarm,
400 .alarm_irq_enable = pl031_alarm_irq_enable, 417 .set_alarm = pl031_set_alarm,
418 .alarm_irq_enable = pl031_alarm_irq_enable,
419 },
420 .clockwatch = true,
421 .st_weekday = true,
422 .irqflags = IRQF_NO_SUSPEND,
401}; 423};
402 424
403/* And the second ST derivative */ 425/* And the second ST derivative */
404static struct rtc_class_ops stv2_pl031_ops = { 426static struct pl031_vendor_data stv2_pl031 = {
405 .read_time = pl031_stv2_read_time, 427 .ops = {
406 .set_time = pl031_stv2_set_time, 428 .read_time = pl031_stv2_read_time,
407 .read_alarm = pl031_stv2_read_alarm, 429 .set_time = pl031_stv2_set_time,
408 .set_alarm = pl031_stv2_set_alarm, 430 .read_alarm = pl031_stv2_read_alarm,
409 .alarm_irq_enable = pl031_alarm_irq_enable, 431 .set_alarm = pl031_stv2_set_alarm,
432 .alarm_irq_enable = pl031_alarm_irq_enable,
433 },
434 .clockwatch = true,
435 .st_weekday = true,
436 /*
437 * This variant shares the IRQ with another block and must not
438 * suspend that IRQ line.
439 */
440 .irqflags = IRQF_SHARED | IRQF_NO_SUSPEND,
410}; 441};
411 442
412static struct amba_id pl031_ids[] = { 443static struct amba_id pl031_ids[] = {
413 { 444 {
414 .id = 0x00041031, 445 .id = 0x00041031,
415 .mask = 0x000fffff, 446 .mask = 0x000fffff,
416 .data = &arm_pl031_ops, 447 .data = &arm_pl031,
417 }, 448 },
418 /* ST Micro variants */ 449 /* ST Micro variants */
419 { 450 {
420 .id = 0x00180031, 451 .id = 0x00180031,
421 .mask = 0x00ffffff, 452 .mask = 0x00ffffff,
422 .data = &stv1_pl031_ops, 453 .data = &stv1_pl031,
423 }, 454 },
424 { 455 {
425 .id = 0x00280031, 456 .id = 0x00280031,
426 .mask = 0x00ffffff, 457 .mask = 0x00ffffff,
427 .data = &stv2_pl031_ops, 458 .data = &stv2_pl031,
428 }, 459 },
429 {0, 0}, 460 {0, 0},
430}; 461};
diff --git a/drivers/rtc/rtc-r9701.c b/drivers/rtc/rtc-r9701.c
index 33b6ba0afa0..2c183ebff71 100644
--- a/drivers/rtc/rtc-r9701.c
+++ b/drivers/rtc/rtc-r9701.c
@@ -138,8 +138,7 @@ static int __devinit r9701_probe(struct spi_device *spi)
138 * contain invalid values. If so, try to write a default date: 138 * contain invalid values. If so, try to write a default date:
139 * 2000/1/1 00:00:00 139 * 2000/1/1 00:00:00
140 */ 140 */
141 r9701_get_datetime(&spi->dev, &dt); 141 if (r9701_get_datetime(&spi->dev, &dt)) {
142 if (rtc_valid_tm(&dt)) {
143 dev_info(&spi->dev, "trying to repair invalid date/time\n"); 142 dev_info(&spi->dev, "trying to repair invalid date/time\n");
144 dt.tm_sec = 0; 143 dt.tm_sec = 0;
145 dt.tm_min = 0; 144 dt.tm_min = 0;
@@ -148,7 +147,8 @@ static int __devinit r9701_probe(struct spi_device *spi)
148 dt.tm_mon = 0; 147 dt.tm_mon = 0;
149 dt.tm_year = 100; 148 dt.tm_year = 100;
150 149
151 if (r9701_set_datetime(&spi->dev, &dt)) { 150 if (r9701_set_datetime(&spi->dev, &dt) ||
151 r9701_get_datetime(&spi->dev, &dt)) {
152 dev_err(&spi->dev, "cannot repair RTC register\n"); 152 dev_err(&spi->dev, "cannot repair RTC register\n");
153 return -ENODEV; 153 return -ENODEV;
154 } 154 }
diff --git a/drivers/rtc/rtc-s3c.c b/drivers/rtc/rtc-s3c.c
index 7e6af0b22f1..bfbd92c8d1c 100644
--- a/drivers/rtc/rtc-s3c.c
+++ b/drivers/rtc/rtc-s3c.c
@@ -26,10 +26,10 @@
26#include <linux/log2.h> 26#include <linux/log2.h>
27#include <linux/slab.h> 27#include <linux/slab.h>
28#include <linux/of.h> 28#include <linux/of.h>
29#include <linux/uaccess.h>
30#include <linux/io.h>
29 31
30#include <mach/hardware.h> 32#include <mach/hardware.h>
31#include <asm/uaccess.h>
32#include <asm/io.h>
33#include <asm/irq.h> 33#include <asm/irq.h>
34#include <plat/regs-rtc.h> 34#include <plat/regs-rtc.h>
35 35
diff --git a/drivers/usb/gadget/m66592-udc.c b/drivers/usb/gadget/m66592-udc.c
index 8981fbb5748..cf6bd626f3f 100644
--- a/drivers/usb/gadget/m66592-udc.c
+++ b/drivers/usb/gadget/m66592-udc.c
@@ -1583,12 +1583,10 @@ static int __exit m66592_remove(struct platform_device *pdev)
1583 iounmap(m66592->reg); 1583 iounmap(m66592->reg);
1584 free_irq(platform_get_irq(pdev, 0), m66592); 1584 free_irq(platform_get_irq(pdev, 0), m66592);
1585 m66592_free_request(&m66592->ep[0].ep, m66592->ep0_req); 1585 m66592_free_request(&m66592->ep[0].ep, m66592->ep0_req);
1586#ifdef CONFIG_HAVE_CLK
1587 if (m66592->pdata->on_chip) { 1586 if (m66592->pdata->on_chip) {
1588 clk_disable(m66592->clk); 1587 clk_disable(m66592->clk);
1589 clk_put(m66592->clk); 1588 clk_put(m66592->clk);
1590 } 1589 }
1591#endif
1592 kfree(m66592); 1590 kfree(m66592);
1593 return 0; 1591 return 0;
1594} 1592}
@@ -1602,9 +1600,7 @@ static int __init m66592_probe(struct platform_device *pdev)
1602 struct resource *res, *ires; 1600 struct resource *res, *ires;
1603 void __iomem *reg = NULL; 1601 void __iomem *reg = NULL;
1604 struct m66592 *m66592 = NULL; 1602 struct m66592 *m66592 = NULL;
1605#ifdef CONFIG_HAVE_CLK
1606 char clk_name[8]; 1603 char clk_name[8];
1607#endif
1608 int ret = 0; 1604 int ret = 0;
1609 int i; 1605 int i;
1610 1606
@@ -1671,7 +1667,6 @@ static int __init m66592_probe(struct platform_device *pdev)
1671 goto clean_up; 1667 goto clean_up;
1672 } 1668 }
1673 1669
1674#ifdef CONFIG_HAVE_CLK
1675 if (m66592->pdata->on_chip) { 1670 if (m66592->pdata->on_chip) {
1676 snprintf(clk_name, sizeof(clk_name), "usbf%d", pdev->id); 1671 snprintf(clk_name, sizeof(clk_name), "usbf%d", pdev->id);
1677 m66592->clk = clk_get(&pdev->dev, clk_name); 1672 m66592->clk = clk_get(&pdev->dev, clk_name);
@@ -1683,7 +1678,7 @@ static int __init m66592_probe(struct platform_device *pdev)
1683 } 1678 }
1684 clk_enable(m66592->clk); 1679 clk_enable(m66592->clk);
1685 } 1680 }
1686#endif 1681
1687 INIT_LIST_HEAD(&m66592->gadget.ep_list); 1682 INIT_LIST_HEAD(&m66592->gadget.ep_list);
1688 m66592->gadget.ep0 = &m66592->ep[0].ep; 1683 m66592->gadget.ep0 = &m66592->ep[0].ep;
1689 INIT_LIST_HEAD(&m66592->gadget.ep0->ep_list); 1684 INIT_LIST_HEAD(&m66592->gadget.ep0->ep_list);
@@ -1731,13 +1726,11 @@ err_add_udc:
1731 m66592_free_request(&m66592->ep[0].ep, m66592->ep0_req); 1726 m66592_free_request(&m66592->ep[0].ep, m66592->ep0_req);
1732 1727
1733clean_up3: 1728clean_up3:
1734#ifdef CONFIG_HAVE_CLK
1735 if (m66592->pdata->on_chip) { 1729 if (m66592->pdata->on_chip) {
1736 clk_disable(m66592->clk); 1730 clk_disable(m66592->clk);
1737 clk_put(m66592->clk); 1731 clk_put(m66592->clk);
1738 } 1732 }
1739clean_up2: 1733clean_up2:
1740#endif
1741 free_irq(ires->start, m66592); 1734 free_irq(ires->start, m66592);
1742clean_up: 1735clean_up:
1743 if (m66592) { 1736 if (m66592) {
diff --git a/drivers/usb/gadget/m66592-udc.h b/drivers/usb/gadget/m66592-udc.h
index 88c85b4116a..16c7e14678b 100644
--- a/drivers/usb/gadget/m66592-udc.h
+++ b/drivers/usb/gadget/m66592-udc.h
@@ -13,10 +13,7 @@
13#ifndef __M66592_UDC_H__ 13#ifndef __M66592_UDC_H__
14#define __M66592_UDC_H__ 14#define __M66592_UDC_H__
15 15
16#ifdef CONFIG_HAVE_CLK
17#include <linux/clk.h> 16#include <linux/clk.h>
18#endif
19
20#include <linux/usb/m66592.h> 17#include <linux/usb/m66592.h>
21 18
22#define M66592_SYSCFG 0x00 19#define M66592_SYSCFG 0x00
@@ -468,9 +465,7 @@ struct m66592_ep {
468struct m66592 { 465struct m66592 {
469 spinlock_t lock; 466 spinlock_t lock;
470 void __iomem *reg; 467 void __iomem *reg;
471#ifdef CONFIG_HAVE_CLK
472 struct clk *clk; 468 struct clk *clk;
473#endif
474 struct m66592_platdata *pdata; 469 struct m66592_platdata *pdata;
475 unsigned long irq_trigger; 470 unsigned long irq_trigger;
476 471
diff --git a/drivers/usb/gadget/r8a66597-udc.c b/drivers/usb/gadget/r8a66597-udc.c
index f3ac2a20c27..5a80751accb 100644
--- a/drivers/usb/gadget/r8a66597-udc.c
+++ b/drivers/usb/gadget/r8a66597-udc.c
@@ -1831,12 +1831,12 @@ static int __exit r8a66597_remove(struct platform_device *pdev)
1831 iounmap(r8a66597->sudmac_reg); 1831 iounmap(r8a66597->sudmac_reg);
1832 free_irq(platform_get_irq(pdev, 0), r8a66597); 1832 free_irq(platform_get_irq(pdev, 0), r8a66597);
1833 r8a66597_free_request(&r8a66597->ep[0].ep, r8a66597->ep0_req); 1833 r8a66597_free_request(&r8a66597->ep[0].ep, r8a66597->ep0_req);
1834#ifdef CONFIG_HAVE_CLK 1834
1835 if (r8a66597->pdata->on_chip) { 1835 if (r8a66597->pdata->on_chip) {
1836 clk_disable(r8a66597->clk); 1836 clk_disable(r8a66597->clk);
1837 clk_put(r8a66597->clk); 1837 clk_put(r8a66597->clk);
1838 } 1838 }
1839#endif 1839
1840 device_unregister(&r8a66597->gadget.dev); 1840 device_unregister(&r8a66597->gadget.dev);
1841 kfree(r8a66597); 1841 kfree(r8a66597);
1842 return 0; 1842 return 0;
@@ -1868,9 +1868,7 @@ static int __init r8a66597_sudmac_ioremap(struct r8a66597 *r8a66597,
1868 1868
1869static int __init r8a66597_probe(struct platform_device *pdev) 1869static int __init r8a66597_probe(struct platform_device *pdev)
1870{ 1870{
1871#ifdef CONFIG_HAVE_CLK
1872 char clk_name[8]; 1871 char clk_name[8];
1873#endif
1874 struct resource *res, *ires; 1872 struct resource *res, *ires;
1875 int irq; 1873 int irq;
1876 void __iomem *reg = NULL; 1874 void __iomem *reg = NULL;
@@ -1934,7 +1932,6 @@ static int __init r8a66597_probe(struct platform_device *pdev)
1934 r8a66597->timer.data = (unsigned long)r8a66597; 1932 r8a66597->timer.data = (unsigned long)r8a66597;
1935 r8a66597->reg = reg; 1933 r8a66597->reg = reg;
1936 1934
1937#ifdef CONFIG_HAVE_CLK
1938 if (r8a66597->pdata->on_chip) { 1935 if (r8a66597->pdata->on_chip) {
1939 snprintf(clk_name, sizeof(clk_name), "usb%d", pdev->id); 1936 snprintf(clk_name, sizeof(clk_name), "usb%d", pdev->id);
1940 r8a66597->clk = clk_get(&pdev->dev, clk_name); 1937 r8a66597->clk = clk_get(&pdev->dev, clk_name);
@@ -1946,7 +1943,7 @@ static int __init r8a66597_probe(struct platform_device *pdev)
1946 } 1943 }
1947 clk_enable(r8a66597->clk); 1944 clk_enable(r8a66597->clk);
1948 } 1945 }
1949#endif 1946
1950 if (r8a66597->pdata->sudmac) { 1947 if (r8a66597->pdata->sudmac) {
1951 ret = r8a66597_sudmac_ioremap(r8a66597, pdev); 1948 ret = r8a66597_sudmac_ioremap(r8a66597, pdev);
1952 if (ret < 0) 1949 if (ret < 0)
@@ -2006,13 +2003,11 @@ err_add_udc:
2006clean_up3: 2003clean_up3:
2007 free_irq(irq, r8a66597); 2004 free_irq(irq, r8a66597);
2008clean_up2: 2005clean_up2:
2009#ifdef CONFIG_HAVE_CLK
2010 if (r8a66597->pdata->on_chip) { 2006 if (r8a66597->pdata->on_chip) {
2011 clk_disable(r8a66597->clk); 2007 clk_disable(r8a66597->clk);
2012 clk_put(r8a66597->clk); 2008 clk_put(r8a66597->clk);
2013 } 2009 }
2014clean_up_dev: 2010clean_up_dev:
2015#endif
2016 device_unregister(&r8a66597->gadget.dev); 2011 device_unregister(&r8a66597->gadget.dev);
2017clean_up: 2012clean_up:
2018 if (r8a66597) { 2013 if (r8a66597) {
diff --git a/drivers/usb/gadget/r8a66597-udc.h b/drivers/usb/gadget/r8a66597-udc.h
index 99908c76ccd..45c4b2df178 100644
--- a/drivers/usb/gadget/r8a66597-udc.h
+++ b/drivers/usb/gadget/r8a66597-udc.h
@@ -13,10 +13,7 @@
13#ifndef __R8A66597_H__ 13#ifndef __R8A66597_H__
14#define __R8A66597_H__ 14#define __R8A66597_H__
15 15
16#ifdef CONFIG_HAVE_CLK
17#include <linux/clk.h> 16#include <linux/clk.h>
18#endif
19
20#include <linux/usb/r8a66597.h> 17#include <linux/usb/r8a66597.h>
21 18
22#define R8A66597_MAX_SAMPLING 10 19#define R8A66597_MAX_SAMPLING 10
@@ -92,9 +89,7 @@ struct r8a66597 {
92 void __iomem *reg; 89 void __iomem *reg;
93 void __iomem *sudmac_reg; 90 void __iomem *sudmac_reg;
94 91
95#ifdef CONFIG_HAVE_CLK
96 struct clk *clk; 92 struct clk *clk;
97#endif
98 struct r8a66597_platdata *pdata; 93 struct r8a66597_platdata *pdata;
99 94
100 struct usb_gadget gadget; 95 struct usb_gadget gadget;
diff --git a/drivers/usb/host/r8a66597-hcd.c b/drivers/usb/host/r8a66597-hcd.c
index c868be65e76..4c634eb5635 100644
--- a/drivers/usb/host/r8a66597-hcd.c
+++ b/drivers/usb/host/r8a66597-hcd.c
@@ -95,9 +95,7 @@ static int r8a66597_clock_enable(struct r8a66597 *r8a66597)
95 int i = 0; 95 int i = 0;
96 96
97 if (r8a66597->pdata->on_chip) { 97 if (r8a66597->pdata->on_chip) {
98#ifdef CONFIG_HAVE_CLK
99 clk_enable(r8a66597->clk); 98 clk_enable(r8a66597->clk);
100#endif
101 do { 99 do {
102 r8a66597_write(r8a66597, SCKE, SYSCFG0); 100 r8a66597_write(r8a66597, SCKE, SYSCFG0);
103 tmp = r8a66597_read(r8a66597, SYSCFG0); 101 tmp = r8a66597_read(r8a66597, SYSCFG0);
@@ -141,9 +139,7 @@ static void r8a66597_clock_disable(struct r8a66597 *r8a66597)
141 udelay(1); 139 udelay(1);
142 140
143 if (r8a66597->pdata->on_chip) { 141 if (r8a66597->pdata->on_chip) {
144#ifdef CONFIG_HAVE_CLK
145 clk_disable(r8a66597->clk); 142 clk_disable(r8a66597->clk);
146#endif
147 } else { 143 } else {
148 r8a66597_bclr(r8a66597, PLLC, SYSCFG0); 144 r8a66597_bclr(r8a66597, PLLC, SYSCFG0);
149 r8a66597_bclr(r8a66597, XCKE, SYSCFG0); 145 r8a66597_bclr(r8a66597, XCKE, SYSCFG0);
@@ -2406,19 +2402,15 @@ static int __devexit r8a66597_remove(struct platform_device *pdev)
2406 del_timer_sync(&r8a66597->rh_timer); 2402 del_timer_sync(&r8a66597->rh_timer);
2407 usb_remove_hcd(hcd); 2403 usb_remove_hcd(hcd);
2408 iounmap(r8a66597->reg); 2404 iounmap(r8a66597->reg);
2409#ifdef CONFIG_HAVE_CLK
2410 if (r8a66597->pdata->on_chip) 2405 if (r8a66597->pdata->on_chip)
2411 clk_put(r8a66597->clk); 2406 clk_put(r8a66597->clk);
2412#endif
2413 usb_put_hcd(hcd); 2407 usb_put_hcd(hcd);
2414 return 0; 2408 return 0;
2415} 2409}
2416 2410
2417static int __devinit r8a66597_probe(struct platform_device *pdev) 2411static int __devinit r8a66597_probe(struct platform_device *pdev)
2418{ 2412{
2419#ifdef CONFIG_HAVE_CLK
2420 char clk_name[8]; 2413 char clk_name[8];
2421#endif
2422 struct resource *res = NULL, *ires; 2414 struct resource *res = NULL, *ires;
2423 int irq = -1; 2415 int irq = -1;
2424 void __iomem *reg = NULL; 2416 void __iomem *reg = NULL;
@@ -2482,7 +2474,6 @@ static int __devinit r8a66597_probe(struct platform_device *pdev)
2482 r8a66597->irq_sense_low = irq_trigger == IRQF_TRIGGER_LOW; 2474 r8a66597->irq_sense_low = irq_trigger == IRQF_TRIGGER_LOW;
2483 2475
2484 if (r8a66597->pdata->on_chip) { 2476 if (r8a66597->pdata->on_chip) {
2485#ifdef CONFIG_HAVE_CLK
2486 snprintf(clk_name, sizeof(clk_name), "usb%d", pdev->id); 2477 snprintf(clk_name, sizeof(clk_name), "usb%d", pdev->id);
2487 r8a66597->clk = clk_get(&pdev->dev, clk_name); 2478 r8a66597->clk = clk_get(&pdev->dev, clk_name);
2488 if (IS_ERR(r8a66597->clk)) { 2479 if (IS_ERR(r8a66597->clk)) {
@@ -2491,7 +2482,6 @@ static int __devinit r8a66597_probe(struct platform_device *pdev)
2491 ret = PTR_ERR(r8a66597->clk); 2482 ret = PTR_ERR(r8a66597->clk);
2492 goto clean_up2; 2483 goto clean_up2;
2493 } 2484 }
2494#endif
2495 r8a66597->max_root_hub = 1; 2485 r8a66597->max_root_hub = 1;
2496 } else 2486 } else
2497 r8a66597->max_root_hub = 2; 2487 r8a66597->max_root_hub = 2;
@@ -2531,11 +2521,9 @@ static int __devinit r8a66597_probe(struct platform_device *pdev)
2531 return 0; 2521 return 0;
2532 2522
2533clean_up3: 2523clean_up3:
2534#ifdef CONFIG_HAVE_CLK
2535 if (r8a66597->pdata->on_chip) 2524 if (r8a66597->pdata->on_chip)
2536 clk_put(r8a66597->clk); 2525 clk_put(r8a66597->clk);
2537clean_up2: 2526clean_up2:
2538#endif
2539 usb_put_hcd(hcd); 2527 usb_put_hcd(hcd);
2540 2528
2541clean_up: 2529clean_up:
diff --git a/drivers/usb/host/r8a66597.h b/drivers/usb/host/r8a66597.h
index f28782d20ee..672cea307ab 100644
--- a/drivers/usb/host/r8a66597.h
+++ b/drivers/usb/host/r8a66597.h
@@ -26,10 +26,7 @@
26#ifndef __R8A66597_H__ 26#ifndef __R8A66597_H__
27#define __R8A66597_H__ 27#define __R8A66597_H__
28 28
29#ifdef CONFIG_HAVE_CLK
30#include <linux/clk.h> 29#include <linux/clk.h>
31#endif
32
33#include <linux/usb/r8a66597.h> 30#include <linux/usb/r8a66597.h>
34 31
35#define R8A66597_MAX_NUM_PIPE 10 32#define R8A66597_MAX_NUM_PIPE 10
@@ -113,9 +110,7 @@ struct r8a66597_root_hub {
113struct r8a66597 { 110struct r8a66597 {
114 spinlock_t lock; 111 spinlock_t lock;
115 void __iomem *reg; 112 void __iomem *reg;
116#ifdef CONFIG_HAVE_CLK
117 struct clk *clk; 113 struct clk *clk;
118#endif
119 struct r8a66597_platdata *pdata; 114 struct r8a66597_platdata *pdata;
120 struct r8a66597_device device0; 115 struct r8a66597_device device0;
121 struct r8a66597_root_hub root_hub[R8A66597_MAX_ROOT_HUB]; 116 struct r8a66597_root_hub root_hub[R8A66597_MAX_ROOT_HUB];
diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h
index dbcdeea30f0..586105b55a7 100644
--- a/drivers/usb/musb/musb_core.h
+++ b/drivers/usb/musb/musb_core.h
@@ -81,14 +81,6 @@ struct musb_ep;
81#define is_peripheral_active(m) (!(m)->is_host) 81#define is_peripheral_active(m) (!(m)->is_host)
82#define is_host_active(m) ((m)->is_host) 82#define is_host_active(m) ((m)->is_host)
83 83
84#ifndef CONFIG_HAVE_CLK
85/* Dummy stub for clk framework */
86#define clk_get(dev, id) NULL
87#define clk_put(clock) do {} while (0)
88#define clk_enable(clock) do {} while (0)
89#define clk_disable(clock) do {} while (0)
90#endif
91
92#ifdef CONFIG_PROC_FS 84#ifdef CONFIG_PROC_FS
93#include <linux/fs.h> 85#include <linux/fs.h>
94#define MUSB_CONFIG_PROC_FS 86#define MUSB_CONFIG_PROC_FS
diff --git a/drivers/video/backlight/atmel-pwm-bl.c b/drivers/video/backlight/atmel-pwm-bl.c
index 0443a4f7185..df1cbb7ef6c 100644
--- a/drivers/video/backlight/atmel-pwm-bl.c
+++ b/drivers/video/backlight/atmel-pwm-bl.c
@@ -127,7 +127,8 @@ static int atmel_pwm_bl_probe(struct platform_device *pdev)
127 struct atmel_pwm_bl *pwmbl; 127 struct atmel_pwm_bl *pwmbl;
128 int retval; 128 int retval;
129 129
130 pwmbl = kzalloc(sizeof(struct atmel_pwm_bl), GFP_KERNEL); 130 pwmbl = devm_kzalloc(&pdev->dev, sizeof(struct atmel_pwm_bl),
131 GFP_KERNEL);
131 if (!pwmbl) 132 if (!pwmbl)
132 return -ENOMEM; 133 return -ENOMEM;
133 134
@@ -154,7 +155,8 @@ static int atmel_pwm_bl_probe(struct platform_device *pdev)
154 goto err_free_mem; 155 goto err_free_mem;
155 156
156 if (pwmbl->gpio_on != -1) { 157 if (pwmbl->gpio_on != -1) {
157 retval = gpio_request(pwmbl->gpio_on, "gpio_atmel_pwm_bl"); 158 retval = devm_gpio_request(&pdev->dev, pwmbl->gpio_on,
159 "gpio_atmel_pwm_bl");
158 if (retval) { 160 if (retval) {
159 pwmbl->gpio_on = -1; 161 pwmbl->gpio_on = -1;
160 goto err_free_pwm; 162 goto err_free_pwm;
@@ -164,7 +166,7 @@ static int atmel_pwm_bl_probe(struct platform_device *pdev)
164 retval = gpio_direction_output(pwmbl->gpio_on, 166 retval = gpio_direction_output(pwmbl->gpio_on,
165 0 ^ pdata->on_active_low); 167 0 ^ pdata->on_active_low);
166 if (retval) 168 if (retval)
167 goto err_free_gpio; 169 goto err_free_pwm;
168 } 170 }
169 171
170 memset(&props, 0, sizeof(struct backlight_properties)); 172 memset(&props, 0, sizeof(struct backlight_properties));
@@ -174,7 +176,7 @@ static int atmel_pwm_bl_probe(struct platform_device *pdev)
174 &atmel_pwm_bl_ops, &props); 176 &atmel_pwm_bl_ops, &props);
175 if (IS_ERR(bldev)) { 177 if (IS_ERR(bldev)) {
176 retval = PTR_ERR(bldev); 178 retval = PTR_ERR(bldev);
177 goto err_free_gpio; 179 goto err_free_pwm;
178 } 180 }
179 181
180 pwmbl->bldev = bldev; 182 pwmbl->bldev = bldev;
@@ -196,13 +198,9 @@ static int atmel_pwm_bl_probe(struct platform_device *pdev)
196err_free_bl_dev: 198err_free_bl_dev:
197 platform_set_drvdata(pdev, NULL); 199 platform_set_drvdata(pdev, NULL);
198 backlight_device_unregister(bldev); 200 backlight_device_unregister(bldev);
199err_free_gpio:
200 if (pwmbl->gpio_on != -1)
201 gpio_free(pwmbl->gpio_on);
202err_free_pwm: 201err_free_pwm:
203 pwm_channel_free(&pwmbl->pwmc); 202 pwm_channel_free(&pwmbl->pwmc);
204err_free_mem: 203err_free_mem:
205 kfree(pwmbl);
206 return retval; 204 return retval;
207} 205}
208 206
@@ -210,15 +208,12 @@ static int __exit atmel_pwm_bl_remove(struct platform_device *pdev)
210{ 208{
211 struct atmel_pwm_bl *pwmbl = platform_get_drvdata(pdev); 209 struct atmel_pwm_bl *pwmbl = platform_get_drvdata(pdev);
212 210
213 if (pwmbl->gpio_on != -1) { 211 if (pwmbl->gpio_on != -1)
214 gpio_set_value(pwmbl->gpio_on, 0); 212 gpio_set_value(pwmbl->gpio_on, 0);
215 gpio_free(pwmbl->gpio_on);
216 }
217 pwm_channel_disable(&pwmbl->pwmc); 213 pwm_channel_disable(&pwmbl->pwmc);
218 pwm_channel_free(&pwmbl->pwmc); 214 pwm_channel_free(&pwmbl->pwmc);
219 backlight_device_unregister(pwmbl->bldev); 215 backlight_device_unregister(pwmbl->bldev);
220 platform_set_drvdata(pdev, NULL); 216 platform_set_drvdata(pdev, NULL);
221 kfree(pwmbl);
222 217
223 return 0; 218 return 0;
224} 219}
diff --git a/drivers/video/backlight/corgi_lcd.c b/drivers/video/backlight/corgi_lcd.c
index 23d732677ba..c781768ba89 100644
--- a/drivers/video/backlight/corgi_lcd.c
+++ b/drivers/video/backlight/corgi_lcd.c
@@ -492,7 +492,8 @@ static int setup_gpio_backlight(struct corgi_lcd *lcd,
492 lcd->gpio_backlight_cont = -1; 492 lcd->gpio_backlight_cont = -1;
493 493
494 if (gpio_is_valid(pdata->gpio_backlight_on)) { 494 if (gpio_is_valid(pdata->gpio_backlight_on)) {
495 err = gpio_request(pdata->gpio_backlight_on, "BL_ON"); 495 err = devm_gpio_request(&spi->dev, pdata->gpio_backlight_on,
496 "BL_ON");
496 if (err) { 497 if (err) {
497 dev_err(&spi->dev, "failed to request GPIO%d for " 498 dev_err(&spi->dev, "failed to request GPIO%d for "
498 "backlight_on\n", pdata->gpio_backlight_on); 499 "backlight_on\n", pdata->gpio_backlight_on);
@@ -504,11 +505,12 @@ static int setup_gpio_backlight(struct corgi_lcd *lcd,
504 } 505 }
505 506
506 if (gpio_is_valid(pdata->gpio_backlight_cont)) { 507 if (gpio_is_valid(pdata->gpio_backlight_cont)) {
507 err = gpio_request(pdata->gpio_backlight_cont, "BL_CONT"); 508 err = devm_gpio_request(&spi->dev, pdata->gpio_backlight_cont,
509 "BL_CONT");
508 if (err) { 510 if (err) {
509 dev_err(&spi->dev, "failed to request GPIO%d for " 511 dev_err(&spi->dev, "failed to request GPIO%d for "
510 "backlight_cont\n", pdata->gpio_backlight_cont); 512 "backlight_cont\n", pdata->gpio_backlight_cont);
511 goto err_free_backlight_on; 513 return err;
512 } 514 }
513 515
514 lcd->gpio_backlight_cont = pdata->gpio_backlight_cont; 516 lcd->gpio_backlight_cont = pdata->gpio_backlight_cont;
@@ -525,11 +527,6 @@ static int setup_gpio_backlight(struct corgi_lcd *lcd,
525 } 527 }
526 } 528 }
527 return 0; 529 return 0;
528
529err_free_backlight_on:
530 if (gpio_is_valid(lcd->gpio_backlight_on))
531 gpio_free(lcd->gpio_backlight_on);
532 return err;
533} 530}
534 531
535static int __devinit corgi_lcd_probe(struct spi_device *spi) 532static int __devinit corgi_lcd_probe(struct spi_device *spi)
@@ -602,12 +599,6 @@ static int __devexit corgi_lcd_remove(struct spi_device *spi)
602 backlight_update_status(lcd->bl_dev); 599 backlight_update_status(lcd->bl_dev);
603 backlight_device_unregister(lcd->bl_dev); 600 backlight_device_unregister(lcd->bl_dev);
604 601
605 if (gpio_is_valid(lcd->gpio_backlight_on))
606 gpio_free(lcd->gpio_backlight_on);
607
608 if (gpio_is_valid(lcd->gpio_backlight_cont))
609 gpio_free(lcd->gpio_backlight_cont);
610
611 corgi_lcd_set_power(lcd->lcd_dev, FB_BLANK_POWERDOWN); 602 corgi_lcd_set_power(lcd->lcd_dev, FB_BLANK_POWERDOWN);
612 lcd_device_unregister(lcd->lcd_dev); 603 lcd_device_unregister(lcd->lcd_dev);
613 604
diff --git a/drivers/video/backlight/l4f00242t03.c b/drivers/video/backlight/l4f00242t03.c
index 40f606a8609..2d90c0648aa 100644
--- a/drivers/video/backlight/l4f00242t03.c
+++ b/drivers/video/backlight/l4f00242t03.c
@@ -175,28 +175,27 @@ static int __devinit l4f00242t03_probe(struct spi_device *spi)
175 175
176 priv->spi = spi; 176 priv->spi = spi;
177 177
178 ret = gpio_request_one(pdata->reset_gpio, GPIOF_OUT_INIT_HIGH, 178 ret = devm_gpio_request_one(&spi->dev, pdata->reset_gpio,
179 "lcd l4f00242t03 reset"); 179 GPIOF_OUT_INIT_HIGH, "lcd l4f00242t03 reset");
180 if (ret) { 180 if (ret) {
181 dev_err(&spi->dev, 181 dev_err(&spi->dev,
182 "Unable to get the lcd l4f00242t03 reset gpio.\n"); 182 "Unable to get the lcd l4f00242t03 reset gpio.\n");
183 return ret; 183 return ret;
184 } 184 }
185 185
186 ret = gpio_request_one(pdata->data_enable_gpio, GPIOF_OUT_INIT_LOW, 186 ret = devm_gpio_request_one(&spi->dev, pdata->data_enable_gpio,
187 "lcd l4f00242t03 data enable"); 187 GPIOF_OUT_INIT_LOW, "lcd l4f00242t03 data enable");
188 if (ret) { 188 if (ret) {
189 dev_err(&spi->dev, 189 dev_err(&spi->dev,
190 "Unable to get the lcd l4f00242t03 data en gpio.\n"); 190 "Unable to get the lcd l4f00242t03 data en gpio.\n");
191 goto err; 191 return ret;
192 } 192 }
193 193
194 priv->io_reg = regulator_get(&spi->dev, "vdd"); 194 priv->io_reg = regulator_get(&spi->dev, "vdd");
195 if (IS_ERR(priv->io_reg)) { 195 if (IS_ERR(priv->io_reg)) {
196 ret = PTR_ERR(priv->io_reg);
197 dev_err(&spi->dev, "%s: Unable to get the IO regulator\n", 196 dev_err(&spi->dev, "%s: Unable to get the IO regulator\n",
198 __func__); 197 __func__);
199 goto err2; 198 return PTR_ERR(priv->io_reg);
200 } 199 }
201 200
202 priv->core_reg = regulator_get(&spi->dev, "vcore"); 201 priv->core_reg = regulator_get(&spi->dev, "vcore");
@@ -204,14 +203,14 @@ static int __devinit l4f00242t03_probe(struct spi_device *spi)
204 ret = PTR_ERR(priv->core_reg); 203 ret = PTR_ERR(priv->core_reg);
205 dev_err(&spi->dev, "%s: Unable to get the core regulator\n", 204 dev_err(&spi->dev, "%s: Unable to get the core regulator\n",
206 __func__); 205 __func__);
207 goto err3; 206 goto err1;
208 } 207 }
209 208
210 priv->ld = lcd_device_register("l4f00242t03", 209 priv->ld = lcd_device_register("l4f00242t03",
211 &spi->dev, priv, &l4f_ops); 210 &spi->dev, priv, &l4f_ops);
212 if (IS_ERR(priv->ld)) { 211 if (IS_ERR(priv->ld)) {
213 ret = PTR_ERR(priv->ld); 212 ret = PTR_ERR(priv->ld);
214 goto err4; 213 goto err2;
215 } 214 }
216 215
217 /* Init the LCD */ 216 /* Init the LCD */
@@ -223,14 +222,10 @@ static int __devinit l4f00242t03_probe(struct spi_device *spi)
223 222
224 return 0; 223 return 0;
225 224
226err4: 225err2:
227 regulator_put(priv->core_reg); 226 regulator_put(priv->core_reg);
228err3: 227err1:
229 regulator_put(priv->io_reg); 228 regulator_put(priv->io_reg);
230err2:
231 gpio_free(pdata->data_enable_gpio);
232err:
233 gpio_free(pdata->reset_gpio);
234 229
235 return ret; 230 return ret;
236} 231}
@@ -238,16 +233,12 @@ err:
238static int __devexit l4f00242t03_remove(struct spi_device *spi) 233static int __devexit l4f00242t03_remove(struct spi_device *spi)
239{ 234{
240 struct l4f00242t03_priv *priv = dev_get_drvdata(&spi->dev); 235 struct l4f00242t03_priv *priv = dev_get_drvdata(&spi->dev);
241 struct l4f00242t03_pdata *pdata = priv->spi->dev.platform_data;
242 236
243 l4f00242t03_lcd_power_set(priv->ld, FB_BLANK_POWERDOWN); 237 l4f00242t03_lcd_power_set(priv->ld, FB_BLANK_POWERDOWN);
244 lcd_device_unregister(priv->ld); 238 lcd_device_unregister(priv->ld);
245 239
246 dev_set_drvdata(&spi->dev, NULL); 240 dev_set_drvdata(&spi->dev, NULL);
247 241
248 gpio_free(pdata->data_enable_gpio);
249 gpio_free(pdata->reset_gpio);
250
251 regulator_put(priv->io_reg); 242 regulator_put(priv->io_reg);
252 regulator_put(priv->core_reg); 243 regulator_put(priv->core_reg);
253 244
diff --git a/drivers/video/backlight/lm3533_bl.c b/drivers/video/backlight/lm3533_bl.c
index bebeb63607d..18dca0c29c6 100644
--- a/drivers/video/backlight/lm3533_bl.c
+++ b/drivers/video/backlight/lm3533_bl.c
@@ -295,7 +295,7 @@ static int __devinit lm3533_bl_probe(struct platform_device *pdev)
295 return -EINVAL; 295 return -EINVAL;
296 } 296 }
297 297
298 bl = kzalloc(sizeof(*bl), GFP_KERNEL); 298 bl = devm_kzalloc(&pdev->dev, sizeof(*bl), GFP_KERNEL);
299 if (!bl) { 299 if (!bl) {
300 dev_err(&pdev->dev, 300 dev_err(&pdev->dev,
301 "failed to allocate memory for backlight\n"); 301 "failed to allocate memory for backlight\n");
@@ -317,8 +317,7 @@ static int __devinit lm3533_bl_probe(struct platform_device *pdev)
317 &lm3533_bl_ops, &props); 317 &lm3533_bl_ops, &props);
318 if (IS_ERR(bd)) { 318 if (IS_ERR(bd)) {
319 dev_err(&pdev->dev, "failed to register backlight device\n"); 319 dev_err(&pdev->dev, "failed to register backlight device\n");
320 ret = PTR_ERR(bd); 320 return PTR_ERR(bd);
321 goto err_free;
322 } 321 }
323 322
324 bl->bd = bd; 323 bl->bd = bd;
@@ -348,8 +347,6 @@ err_sysfs_remove:
348 sysfs_remove_group(&bd->dev.kobj, &lm3533_bl_attribute_group); 347 sysfs_remove_group(&bd->dev.kobj, &lm3533_bl_attribute_group);
349err_unregister: 348err_unregister:
350 backlight_device_unregister(bd); 349 backlight_device_unregister(bd);
351err_free:
352 kfree(bl);
353 350
354 return ret; 351 return ret;
355} 352}
@@ -367,7 +364,6 @@ static int __devexit lm3533_bl_remove(struct platform_device *pdev)
367 lm3533_ctrlbank_disable(&bl->cb); 364 lm3533_ctrlbank_disable(&bl->cb);
368 sysfs_remove_group(&bd->dev.kobj, &lm3533_bl_attribute_group); 365 sysfs_remove_group(&bd->dev.kobj, &lm3533_bl_attribute_group);
369 backlight_device_unregister(bd); 366 backlight_device_unregister(bd);
370 kfree(bl);
371 367
372 return 0; 368 return 0;
373} 369}
diff --git a/drivers/video/backlight/lms283gf05.c b/drivers/video/backlight/lms283gf05.c
index a9f2c36966f..ea43f225419 100644
--- a/drivers/video/backlight/lms283gf05.c
+++ b/drivers/video/backlight/lms283gf05.c
@@ -158,29 +158,27 @@ static int __devinit lms283gf05_probe(struct spi_device *spi)
158 int ret = 0; 158 int ret = 0;
159 159
160 if (pdata != NULL) { 160 if (pdata != NULL) {
161 ret = gpio_request(pdata->reset_gpio, "LMS285GF05 RESET"); 161 ret = devm_gpio_request(&spi->dev, pdata->reset_gpio,
162 "LMS285GF05 RESET");
162 if (ret) 163 if (ret)
163 return ret; 164 return ret;
164 165
165 ret = gpio_direction_output(pdata->reset_gpio, 166 ret = gpio_direction_output(pdata->reset_gpio,
166 !pdata->reset_inverted); 167 !pdata->reset_inverted);
167 if (ret) 168 if (ret)
168 goto err; 169 return ret;
169 } 170 }
170 171
171 st = devm_kzalloc(&spi->dev, sizeof(struct lms283gf05_state), 172 st = devm_kzalloc(&spi->dev, sizeof(struct lms283gf05_state),
172 GFP_KERNEL); 173 GFP_KERNEL);
173 if (st == NULL) { 174 if (st == NULL) {
174 dev_err(&spi->dev, "No memory for device state\n"); 175 dev_err(&spi->dev, "No memory for device state\n");
175 ret = -ENOMEM; 176 return -ENOMEM;
176 goto err;
177 } 177 }
178 178
179 ld = lcd_device_register("lms283gf05", &spi->dev, st, &lms_ops); 179 ld = lcd_device_register("lms283gf05", &spi->dev, st, &lms_ops);
180 if (IS_ERR(ld)) { 180 if (IS_ERR(ld))
181 ret = PTR_ERR(ld); 181 return PTR_ERR(ld);
182 goto err;
183 }
184 182
185 st->spi = spi; 183 st->spi = spi;
186 st->ld = ld; 184 st->ld = ld;
@@ -193,24 +191,14 @@ static int __devinit lms283gf05_probe(struct spi_device *spi)
193 lms283gf05_toggle(spi, disp_initseq, ARRAY_SIZE(disp_initseq)); 191 lms283gf05_toggle(spi, disp_initseq, ARRAY_SIZE(disp_initseq));
194 192
195 return 0; 193 return 0;
196
197err:
198 if (pdata != NULL)
199 gpio_free(pdata->reset_gpio);
200
201 return ret;
202} 194}
203 195
204static int __devexit lms283gf05_remove(struct spi_device *spi) 196static int __devexit lms283gf05_remove(struct spi_device *spi)
205{ 197{
206 struct lms283gf05_state *st = dev_get_drvdata(&spi->dev); 198 struct lms283gf05_state *st = dev_get_drvdata(&spi->dev);
207 struct lms283gf05_pdata *pdata = st->spi->dev.platform_data;
208 199
209 lcd_device_unregister(st->ld); 200 lcd_device_unregister(st->ld);
210 201
211 if (pdata != NULL)
212 gpio_free(pdata->reset_gpio);
213
214 return 0; 202 return 0;
215} 203}
216 204
diff --git a/drivers/video/backlight/lp855x_bl.c b/drivers/video/backlight/lp855x_bl.c
index 72a0e0c917c..aa6d4f71131 100644
--- a/drivers/video/backlight/lp855x_bl.c
+++ b/drivers/video/backlight/lp855x_bl.c
@@ -14,11 +14,15 @@
14#include <linux/i2c.h> 14#include <linux/i2c.h>
15#include <linux/backlight.h> 15#include <linux/backlight.h>
16#include <linux/err.h> 16#include <linux/err.h>
17#include <linux/lp855x.h> 17#include <linux/platform_data/lp855x.h>
18 18
19/* Registers */ 19/* Registers */
20#define BRIGHTNESS_CTRL (0x00) 20#define BRIGHTNESS_CTRL 0x00
21#define DEVICE_CTRL (0x01) 21#define DEVICE_CTRL 0x01
22#define EEPROM_START 0xA0
23#define EEPROM_END 0xA7
24#define EPROM_START 0xA0
25#define EPROM_END 0xAF
22 26
23#define BUF_SIZE 20 27#define BUF_SIZE 20
24#define DEFAULT_BL_NAME "lcd-backlight" 28#define DEFAULT_BL_NAME "lcd-backlight"
diff --git a/drivers/video/backlight/ot200_bl.c b/drivers/video/backlight/ot200_bl.c
index f519d55a294..469cf0f109d 100644
--- a/drivers/video/backlight/ot200_bl.c
+++ b/drivers/video/backlight/ot200_bl.c
@@ -84,7 +84,8 @@ static int ot200_backlight_probe(struct platform_device *pdev)
84 int retval = 0; 84 int retval = 0;
85 85
86 /* request gpio */ 86 /* request gpio */
87 if (gpio_request(GPIO_DIMM, "ot200 backlight dimmer") < 0) { 87 if (devm_gpio_request(&pdev->dev, GPIO_DIMM,
88 "ot200 backlight dimmer") < 0) {
88 dev_err(&pdev->dev, "failed to request GPIO %d\n", GPIO_DIMM); 89 dev_err(&pdev->dev, "failed to request GPIO %d\n", GPIO_DIMM);
89 return -ENODEV; 90 return -ENODEV;
90 } 91 }
@@ -93,14 +94,13 @@ static int ot200_backlight_probe(struct platform_device *pdev)
93 pwm_timer = cs5535_mfgpt_alloc_timer(7, MFGPT_DOMAIN_ANY); 94 pwm_timer = cs5535_mfgpt_alloc_timer(7, MFGPT_DOMAIN_ANY);
94 if (!pwm_timer) { 95 if (!pwm_timer) {
95 dev_err(&pdev->dev, "MFGPT 7 not available\n"); 96 dev_err(&pdev->dev, "MFGPT 7 not available\n");
96 retval = -ENODEV; 97 return -ENODEV;
97 goto error_mfgpt_alloc;
98 } 98 }
99 99
100 data = kzalloc(sizeof(*data), GFP_KERNEL); 100 data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
101 if (!data) { 101 if (!data) {
102 retval = -ENOMEM; 102 retval = -ENOMEM;
103 goto error_kzalloc; 103 goto error_devm_kzalloc;
104 } 104 }
105 105
106 /* setup gpio */ 106 /* setup gpio */
@@ -122,26 +122,21 @@ static int ot200_backlight_probe(struct platform_device *pdev)
122 if (IS_ERR(bl)) { 122 if (IS_ERR(bl)) {
123 dev_err(&pdev->dev, "failed to register backlight\n"); 123 dev_err(&pdev->dev, "failed to register backlight\n");
124 retval = PTR_ERR(bl); 124 retval = PTR_ERR(bl);
125 goto error_backlight_device_register; 125 goto error_devm_kzalloc;
126 } 126 }
127 127
128 platform_set_drvdata(pdev, bl); 128 platform_set_drvdata(pdev, bl);
129 129
130 return 0; 130 return 0;
131 131
132error_backlight_device_register: 132error_devm_kzalloc:
133 kfree(data);
134error_kzalloc:
135 cs5535_mfgpt_free_timer(pwm_timer); 133 cs5535_mfgpt_free_timer(pwm_timer);
136error_mfgpt_alloc:
137 gpio_free(GPIO_DIMM);
138 return retval; 134 return retval;
139} 135}
140 136
141static int ot200_backlight_remove(struct platform_device *pdev) 137static int ot200_backlight_remove(struct platform_device *pdev)
142{ 138{
143 struct backlight_device *bl = platform_get_drvdata(pdev); 139 struct backlight_device *bl = platform_get_drvdata(pdev);
144 struct ot200_backlight_data *data = bl_get_data(bl);
145 140
146 backlight_device_unregister(bl); 141 backlight_device_unregister(bl);
147 142
@@ -152,9 +147,7 @@ static int ot200_backlight_remove(struct platform_device *pdev)
152 MAX_COMP2 - dim_table[100]); 147 MAX_COMP2 - dim_table[100]);
153 148
154 cs5535_mfgpt_free_timer(pwm_timer); 149 cs5535_mfgpt_free_timer(pwm_timer);
155 gpio_free(GPIO_DIMM);
156 150
157 kfree(data);
158 return 0; 151 return 0;
159} 152}
160 153
diff --git a/drivers/video/backlight/tosa_bl.c b/drivers/video/backlight/tosa_bl.c
index 0d54e607e82..49342e1d20b 100644
--- a/drivers/video/backlight/tosa_bl.c
+++ b/drivers/video/backlight/tosa_bl.c
@@ -92,14 +92,14 @@ static int __devinit tosa_bl_probe(struct i2c_client *client,
92 92
93 data->comadj = sharpsl_param.comadj == -1 ? COMADJ_DEFAULT : sharpsl_param.comadj; 93 data->comadj = sharpsl_param.comadj == -1 ? COMADJ_DEFAULT : sharpsl_param.comadj;
94 94
95 ret = gpio_request(TOSA_GPIO_BL_C20MA, "backlight"); 95 ret = devm_gpio_request(&client->dev, TOSA_GPIO_BL_C20MA, "backlight");
96 if (ret) { 96 if (ret) {
97 dev_dbg(&data->bl->dev, "Unable to request gpio!\n"); 97 dev_dbg(&data->bl->dev, "Unable to request gpio!\n");
98 return ret; 98 return ret;
99 } 99 }
100 ret = gpio_direction_output(TOSA_GPIO_BL_C20MA, 0); 100 ret = gpio_direction_output(TOSA_GPIO_BL_C20MA, 0);
101 if (ret) 101 if (ret)
102 goto err_gpio_dir; 102 return ret;
103 103
104 i2c_set_clientdata(client, data); 104 i2c_set_clientdata(client, data);
105 data->i2c = client; 105 data->i2c = client;
@@ -123,8 +123,6 @@ static int __devinit tosa_bl_probe(struct i2c_client *client,
123 123
124err_reg: 124err_reg:
125 data->bl = NULL; 125 data->bl = NULL;
126err_gpio_dir:
127 gpio_free(TOSA_GPIO_BL_C20MA);
128 return ret; 126 return ret;
129} 127}
130 128
@@ -135,8 +133,6 @@ static int __devexit tosa_bl_remove(struct i2c_client *client)
135 backlight_device_unregister(data->bl); 133 backlight_device_unregister(data->bl);
136 data->bl = NULL; 134 data->bl = NULL;
137 135
138 gpio_free(TOSA_GPIO_BL_C20MA);
139
140 return 0; 136 return 0;
141} 137}
142 138
diff --git a/drivers/video/backlight/tosa_lcd.c b/drivers/video/backlight/tosa_lcd.c
index 47823b8efff..33047a66cc2 100644
--- a/drivers/video/backlight/tosa_lcd.c
+++ b/drivers/video/backlight/tosa_lcd.c
@@ -193,7 +193,7 @@ static int __devinit tosa_lcd_probe(struct spi_device *spi)
193 data->spi = spi; 193 data->spi = spi;
194 dev_set_drvdata(&spi->dev, data); 194 dev_set_drvdata(&spi->dev, data);
195 195
196 ret = gpio_request(TOSA_GPIO_TG_ON, "tg #pwr"); 196 ret = devm_gpio_request(&spi->dev, TOSA_GPIO_TG_ON, "tg #pwr");
197 if (ret < 0) 197 if (ret < 0)
198 goto err_gpio_tg; 198 goto err_gpio_tg;
199 199
@@ -201,7 +201,7 @@ static int __devinit tosa_lcd_probe(struct spi_device *spi)
201 201
202 ret = gpio_direction_output(TOSA_GPIO_TG_ON, 0); 202 ret = gpio_direction_output(TOSA_GPIO_TG_ON, 0);
203 if (ret < 0) 203 if (ret < 0)
204 goto err_gpio_dir; 204 goto err_gpio_tg;
205 205
206 mdelay(60); 206 mdelay(60);
207 tosa_lcd_tg_init(data); 207 tosa_lcd_tg_init(data);
@@ -221,8 +221,6 @@ static int __devinit tosa_lcd_probe(struct spi_device *spi)
221 221
222err_register: 222err_register:
223 tosa_lcd_tg_off(data); 223 tosa_lcd_tg_off(data);
224err_gpio_dir:
225 gpio_free(TOSA_GPIO_TG_ON);
226err_gpio_tg: 224err_gpio_tg:
227 dev_set_drvdata(&spi->dev, NULL); 225 dev_set_drvdata(&spi->dev, NULL);
228 return ret; 226 return ret;
@@ -239,7 +237,6 @@ static int __devexit tosa_lcd_remove(struct spi_device *spi)
239 237
240 tosa_lcd_tg_off(data); 238 tosa_lcd_tg_off(data);
241 239
242 gpio_free(TOSA_GPIO_TG_ON);
243 dev_set_drvdata(&spi->dev, NULL); 240 dev_set_drvdata(&spi->dev, NULL);
244 241
245 return 0; 242 return 0;