diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2013-04-29 22:47:50 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-04-29 22:47:50 -0400 |
commit | 56847d857cb0c3ee78c22ce776a26f88d9ffd4d4 (patch) | |
tree | a85bcf204a53e45d26f6a3984f16ddd525eef3e7 | |
parent | 191a712090bb8a10e6f129360eeed2d68f3d4c9a (diff) | |
parent | 8d564368a9a3197f43e56dadf4a18c5738849f94 (diff) |
Merge branch 'akpm' (incoming from Andrew)
Merge second batch of fixes from Andrew Morton:
- various misc bits
- some printk updates
- a new "SRAM" driver.
- MAINTAINERS updates
- the backlight driver queue
- checkpatch updates
- a few init/ changes
- a huge number of drivers/rtc changes
- fatfs updates
- some lib/idr.c work
- some renaming of the random driver interfaces
* emailed patches from Andrew Morton <akpm@linux-foundation.org>: (285 commits)
net: rename random32 to prandom
net/core: remove duplicate statements by do-while loop
net/core: rename random32() to prandom_u32()
net/netfilter: rename random32() to prandom_u32()
net/sched: rename random32() to prandom_u32()
net/sunrpc: rename random32() to prandom_u32()
scsi: rename random32() to prandom_u32()
lguest: rename random32() to prandom_u32()
uwb: rename random32() to prandom_u32()
video/uvesafb: rename random32() to prandom_u32()
mmc: rename random32() to prandom_u32()
drbd: rename random32() to prandom_u32()
kernel/: rename random32() to prandom_u32()
mm/: rename random32() to prandom_u32()
lib/: rename random32() to prandom_u32()
x86: rename random32() to prandom_u32()
x86: pageattr-test: remove srandom32 call
uuid: use prandom_bytes()
raid6test: use prandom_bytes()
sctp: convert sctp_assoc_set_id() to use idr_alloc_cyclic()
...
218 files changed, 2859 insertions, 2303 deletions
@@ -761,6 +761,10 @@ S: Northampton | |||
761 | S: NN1 3QT | 761 | S: NN1 3QT |
762 | S: United Kingdom | 762 | S: United Kingdom |
763 | 763 | ||
764 | N: Massimo Dal Zotto | ||
765 | E: dz@debian.org | ||
766 | D: i8k Dell laptop SMM driver | ||
767 | |||
764 | N: Uwe Dannowski | 768 | N: Uwe Dannowski |
765 | E: Uwe.Dannowski@ira.uka.de | 769 | E: Uwe.Dannowski@ira.uka.de |
766 | W: http://i30www.ira.uka.de/~dannowsk/ | 770 | W: http://i30www.ira.uka.de/~dannowsk/ |
diff --git a/Documentation/SubmittingPatches b/Documentation/SubmittingPatches index aa0c1e63f050..6e97e73d87b5 100644 --- a/Documentation/SubmittingPatches +++ b/Documentation/SubmittingPatches | |||
@@ -420,7 +420,7 @@ person it names. This tag documents that potentially interested parties | |||
420 | have been included in the discussion | 420 | have been included in the discussion |
421 | 421 | ||
422 | 422 | ||
423 | 14) Using Reported-by:, Tested-by: and Reviewed-by: | 423 | 14) Using Reported-by:, Tested-by:, Reviewed-by: and Suggested-by: |
424 | 424 | ||
425 | If this patch fixes a problem reported by somebody else, consider adding a | 425 | If this patch fixes a problem reported by somebody else, consider adding a |
426 | Reported-by: tag to credit the reporter for their contribution. Please | 426 | Reported-by: tag to credit the reporter for their contribution. Please |
@@ -468,6 +468,13 @@ done on the patch. Reviewed-by: tags, when supplied by reviewers known to | |||
468 | understand the subject area and to perform thorough reviews, will normally | 468 | understand the subject area and to perform thorough reviews, will normally |
469 | increase the likelihood of your patch getting into the kernel. | 469 | increase the likelihood of your patch getting into the kernel. |
470 | 470 | ||
471 | A Suggested-by: tag indicates that the patch idea is suggested by the person | ||
472 | named and ensures credit to the person for the idea. Please note that this | ||
473 | tag should not be added without the reporter's permission, especially if the | ||
474 | idea was not posted in a public forum. That said, if we diligently credit our | ||
475 | idea reporters, they will, hopefully, be inspired to help us again in the | ||
476 | future. | ||
477 | |||
471 | 478 | ||
472 | 15) The canonical patch format | 479 | 15) The canonical patch format |
473 | 480 | ||
diff --git a/Documentation/backlight/lp855x-driver.txt b/Documentation/backlight/lp855x-driver.txt index 18b06ca038ea..1c732f0c6758 100644 --- a/Documentation/backlight/lp855x-driver.txt +++ b/Documentation/backlight/lp855x-driver.txt | |||
@@ -32,14 +32,10 @@ Platform data for lp855x | |||
32 | For supporting platform specific data, the lp855x platform data can be used. | 32 | For supporting platform specific data, the lp855x platform data can be used. |
33 | 33 | ||
34 | * name : Backlight driver name. If it is not defined, default name is set. | 34 | * name : Backlight driver name. If it is not defined, default name is set. |
35 | * mode : Brightness control mode. PWM or register based. | ||
36 | * device_control : Value of DEVICE CONTROL register. | 35 | * device_control : Value of DEVICE CONTROL register. |
37 | * initial_brightness : Initial value of backlight brightness. | 36 | * initial_brightness : Initial value of backlight brightness. |
38 | * period_ns : Platform specific PWM period value. unit is nano. | 37 | * period_ns : Platform specific PWM period value. unit is nano. |
39 | Only valid when brightness is pwm input mode. | 38 | Only valid when brightness is pwm input mode. |
40 | * load_new_rom_data : | ||
41 | 0 : use default configuration data | ||
42 | 1 : update values of eeprom or eprom registers on loading driver | ||
43 | * size_program : Total size of lp855x_rom_data. | 39 | * size_program : Total size of lp855x_rom_data. |
44 | * rom_data : List of new eeprom/eprom registers. | 40 | * rom_data : List of new eeprom/eprom registers. |
45 | 41 | ||
@@ -54,10 +50,8 @@ static struct lp855x_rom_data lp8552_eeprom_arr[] = { | |||
54 | 50 | ||
55 | static struct lp855x_platform_data lp8552_pdata = { | 51 | static struct lp855x_platform_data lp8552_pdata = { |
56 | .name = "lcd-bl", | 52 | .name = "lcd-bl", |
57 | .mode = REGISTER_BASED, | ||
58 | .device_control = I2C_CONFIG(LP8552), | 53 | .device_control = I2C_CONFIG(LP8552), |
59 | .initial_brightness = INITIAL_BRT, | 54 | .initial_brightness = INITIAL_BRT, |
60 | .load_new_rom_data = 1, | ||
61 | .size_program = ARRAY_SIZE(lp8552_eeprom_arr), | 55 | .size_program = ARRAY_SIZE(lp8552_eeprom_arr), |
62 | .rom_data = lp8552_eeprom_arr, | 56 | .rom_data = lp8552_eeprom_arr, |
63 | }; | 57 | }; |
@@ -65,7 +59,6 @@ static struct lp855x_platform_data lp8552_pdata = { | |||
65 | example 2) lp8556 platform data : pwm input mode with default rom data | 59 | example 2) lp8556 platform data : pwm input mode with default rom data |
66 | 60 | ||
67 | static struct lp855x_platform_data lp8556_pdata = { | 61 | static struct lp855x_platform_data lp8556_pdata = { |
68 | .mode = PWM_BASED, | ||
69 | .device_control = PWM_CONFIG(LP8556), | 62 | .device_control = PWM_CONFIG(LP8556), |
70 | .initial_brightness = INITIAL_BRT, | 63 | .initial_brightness = INITIAL_BRT, |
71 | .period_ns = 1000000, | 64 | .period_ns = 1000000, |
diff --git a/Documentation/devicetree/bindings/media/coda.txt b/Documentation/devicetree/bindings/media/coda.txt new file mode 100644 index 000000000000..2865d04e4030 --- /dev/null +++ b/Documentation/devicetree/bindings/media/coda.txt | |||
@@ -0,0 +1,30 @@ | |||
1 | Chips&Media Coda multi-standard codec IP | ||
2 | ======================================== | ||
3 | |||
4 | Coda codec IPs are present in i.MX SoCs in various versions, | ||
5 | called VPU (Video Processing Unit). | ||
6 | |||
7 | Required properties: | ||
8 | - compatible : should be "fsl,<chip>-src" for i.MX SoCs: | ||
9 | (a) "fsl,imx27-vpu" for CodaDx6 present in i.MX27 | ||
10 | (b) "fsl,imx53-vpu" for CODA7541 present in i.MX53 | ||
11 | (c) "fsl,imx6q-vpu" for CODA960 present in i.MX6q | ||
12 | - reg: should be register base and length as documented in the | ||
13 | SoC reference manual | ||
14 | - interrupts : Should contain the VPU interrupt. For CODA960, | ||
15 | a second interrupt is needed for the MJPEG unit. | ||
16 | - clocks : Should contain the ahb and per clocks, in the order | ||
17 | determined by the clock-names property. | ||
18 | - clock-names : Should be "ahb", "per" | ||
19 | - iram : phandle pointing to the SRAM device node | ||
20 | |||
21 | Example: | ||
22 | |||
23 | vpu: vpu@63ff4000 { | ||
24 | compatible = "fsl,imx53-vpu"; | ||
25 | reg = <0x63ff4000 0x1000>; | ||
26 | interrupts = <9>; | ||
27 | clocks = <&clks 63>, <&clks 63>; | ||
28 | clock-names = "ahb", "per"; | ||
29 | iram = <&ocram>; | ||
30 | }; | ||
diff --git a/Documentation/devicetree/bindings/misc/sram.txt b/Documentation/devicetree/bindings/misc/sram.txt new file mode 100644 index 000000000000..4d0a00e453a8 --- /dev/null +++ b/Documentation/devicetree/bindings/misc/sram.txt | |||
@@ -0,0 +1,16 @@ | |||
1 | Generic on-chip SRAM | ||
2 | |||
3 | Simple IO memory regions to be managed by the genalloc API. | ||
4 | |||
5 | Required properties: | ||
6 | |||
7 | - compatible : mmio-sram | ||
8 | |||
9 | - reg : SRAM iomem address range | ||
10 | |||
11 | Example: | ||
12 | |||
13 | sram: sram@5c000000 { | ||
14 | compatible = "mmio-sram"; | ||
15 | reg = <0x5c000000 0x40000>; /* 256 KiB SRAM at address 0x5c000000 */ | ||
16 | }; | ||
diff --git a/Documentation/devicetree/bindings/rtc/atmel,at91rm9200-rtc.txt b/Documentation/devicetree/bindings/rtc/atmel,at91rm9200-rtc.txt new file mode 100644 index 000000000000..2a3feabd3b22 --- /dev/null +++ b/Documentation/devicetree/bindings/rtc/atmel,at91rm9200-rtc.txt | |||
@@ -0,0 +1,15 @@ | |||
1 | Atmel AT91RM9200 Real Time Clock | ||
2 | |||
3 | Required properties: | ||
4 | - compatible: should be: "atmel,at91rm9200-rtc" | ||
5 | - reg: physical base address of the controller and length of memory mapped | ||
6 | region. | ||
7 | - interrupts: rtc alarm/event interrupt | ||
8 | |||
9 | Example: | ||
10 | |||
11 | rtc@fffffe00 { | ||
12 | compatible = "atmel,at91rm9200-rtc"; | ||
13 | reg = <0xfffffe00 0x100>; | ||
14 | interrupts = <1 4 7>; | ||
15 | }; | ||
diff --git a/Documentation/devicetree/bindings/video/backlight/lp855x.txt b/Documentation/devicetree/bindings/video/backlight/lp855x.txt new file mode 100644 index 000000000000..1482103d288f --- /dev/null +++ b/Documentation/devicetree/bindings/video/backlight/lp855x.txt | |||
@@ -0,0 +1,41 @@ | |||
1 | lp855x bindings | ||
2 | |||
3 | Required properties: | ||
4 | - compatible: "ti,lp8550", "ti,lp8551", "ti,lp8552", "ti,lp8553", | ||
5 | "ti,lp8556", "ti,lp8557" | ||
6 | - reg: I2C slave address (u8) | ||
7 | - dev-ctrl: Value of DEVICE CONTROL register (u8). It depends on the device. | ||
8 | |||
9 | Optional properties: | ||
10 | - bl-name: Backlight device name (string) | ||
11 | - init-brt: Initial value of backlight brightness (u8) | ||
12 | - pwm-period: PWM period value. Set only PWM input mode used (u32) | ||
13 | - rom-addr: Register address of ROM area to be updated (u8) | ||
14 | - rom-val: Register value to be updated (u8) | ||
15 | |||
16 | Example: | ||
17 | |||
18 | /* LP8556 */ | ||
19 | backlight@2c { | ||
20 | compatible = "ti,lp8556"; | ||
21 | reg = <0x2c>; | ||
22 | |||
23 | bl-name = "lcd-bl"; | ||
24 | dev-ctrl = /bits/ 8 <0x85>; | ||
25 | init-brt = /bits/ 8 <0x10>; | ||
26 | }; | ||
27 | |||
28 | /* LP8557 */ | ||
29 | backlight@2c { | ||
30 | compatible = "ti,lp8557"; | ||
31 | reg = <0x2c>; | ||
32 | |||
33 | dev-ctrl = /bits/ 8 <0x41>; | ||
34 | init-brt = /bits/ 8 <0x0a>; | ||
35 | |||
36 | /* 4V OV, 4 output LED string enabled */ | ||
37 | rom_14h { | ||
38 | rom-addr = /bits/ 8 <0x14>; | ||
39 | rom-val = /bits/ 8 <0xcf>; | ||
40 | }; | ||
41 | }; | ||
diff --git a/Documentation/devicetree/bindings/video/backlight/tps65217-backlight.txt b/Documentation/devicetree/bindings/video/backlight/tps65217-backlight.txt new file mode 100644 index 000000000000..5fb9279ac287 --- /dev/null +++ b/Documentation/devicetree/bindings/video/backlight/tps65217-backlight.txt | |||
@@ -0,0 +1,27 @@ | |||
1 | TPS65217 family of regulators | ||
2 | |||
3 | The TPS65217 chip contains a boost converter and current sinks which can be | ||
4 | used to drive LEDs for use as backlights. | ||
5 | |||
6 | Required properties: | ||
7 | - compatible: "ti,tps65217" | ||
8 | - reg: I2C slave address | ||
9 | - backlight: node for specifying WLED1 and WLED2 lines in TPS65217 | ||
10 | - isel: selection bit, valid values: 1 for ISEL1 (low-level) and 2 for ISEL2 (high-level) | ||
11 | - fdim: PWM dimming frequency, valid values: 100, 200, 500, 1000 | ||
12 | - default-brightness: valid values: 0-100 | ||
13 | |||
14 | Each regulator is defined using the standard binding for regulators. | ||
15 | |||
16 | Example: | ||
17 | |||
18 | tps: tps@24 { | ||
19 | reg = <0x24>; | ||
20 | compatible = "ti,tps65217"; | ||
21 | backlight { | ||
22 | isel = <1>; /* 1 - ISET1, 2 ISET2 */ | ||
23 | fdim = <100>; /* TPS65217_BL_FDIM_100HZ */ | ||
24 | default-brightness = <50>; | ||
25 | }; | ||
26 | }; | ||
27 | |||
diff --git a/Documentation/filesystems/vfat.txt b/Documentation/filesystems/vfat.txt index d230dd9c99b0..4a93e98b290a 100644 --- a/Documentation/filesystems/vfat.txt +++ b/Documentation/filesystems/vfat.txt | |||
@@ -150,12 +150,28 @@ discard -- If set, issues discard/TRIM commands to the block | |||
150 | device when blocks are freed. This is useful for SSD devices | 150 | device when blocks are freed. This is useful for SSD devices |
151 | and sparse/thinly-provisoned LUNs. | 151 | and sparse/thinly-provisoned LUNs. |
152 | 152 | ||
153 | nfs -- This option maintains an index (cache) of directory | 153 | nfs=stale_rw|nostale_ro |
154 | inodes by i_logstart which is used by the nfs-related code to | 154 | Enable this only if you want to export the FAT filesystem |
155 | improve look-ups. | 155 | over NFS. |
156 | |||
157 | stale_rw: This option maintains an index (cache) of directory | ||
158 | inodes by i_logstart which is used by the nfs-related code to | ||
159 | improve look-ups. Full file operations (read/write) over NFS is | ||
160 | supported but with cache eviction at NFS server, this could | ||
161 | result in ESTALE issues. | ||
162 | |||
163 | nostale_ro: This option bases the inode number and filehandle | ||
164 | on the on-disk location of a file in the MS-DOS directory entry. | ||
165 | This ensures that ESTALE will not be returned after a file is | ||
166 | evicted from the inode cache. However, it means that operations | ||
167 | such as rename, create and unlink could cause filehandles that | ||
168 | previously pointed at one file to point at a different file, | ||
169 | potentially causing data corruption. For this reason, this | ||
170 | option also mounts the filesystem readonly. | ||
171 | |||
172 | To maintain backward compatibility, '-o nfs' is also accepted, | ||
173 | defaulting to stale_rw | ||
156 | 174 | ||
157 | Enable this only if you want to export the FAT filesystem | ||
158 | over NFS | ||
159 | 175 | ||
160 | <bool>: 0,1,yes,no,true,false | 176 | <bool>: 0,1,yes,no,true,false |
161 | 177 | ||
diff --git a/MAINTAINERS b/MAINTAINERS index 0d0108fea26f..e8f8c3549684 100644 --- a/MAINTAINERS +++ b/MAINTAINERS | |||
@@ -90,6 +90,9 @@ Descriptions of section entries: | |||
90 | F: drivers/net/* all files in drivers/net, but not below | 90 | F: drivers/net/* all files in drivers/net, but not below |
91 | F: */net/* all files in "any top level directory"/net | 91 | F: */net/* all files in "any top level directory"/net |
92 | One pattern per line. Multiple F: lines acceptable. | 92 | One pattern per line. Multiple F: lines acceptable. |
93 | N: Files and directories with regex patterns. | ||
94 | N: [^a-z]tegra all files whose path contains the word tegra | ||
95 | One pattern per line. Multiple N: lines acceptable. | ||
93 | X: Files and directories that are NOT maintained, same rules as F: | 96 | X: Files and directories that are NOT maintained, same rules as F: |
94 | Files exclusions are tested before file matches. | 97 | Files exclusions are tested before file matches. |
95 | Can be useful for excluding a specific subdirectory, for instance: | 98 | Can be useful for excluding a specific subdirectory, for instance: |
@@ -97,13 +100,12 @@ Descriptions of section entries: | |||
97 | X: net/ipv6/ | 100 | X: net/ipv6/ |
98 | matches all files in and below net excluding net/ipv6/ | 101 | matches all files in and below net excluding net/ipv6/ |
99 | K: Keyword perl extended regex pattern to match content in a | 102 | K: Keyword perl extended regex pattern to match content in a |
100 | patch or file, or an affected filename. For instance: | 103 | patch or file. For instance: |
101 | K: of_get_profile | 104 | K: of_get_profile |
102 | matches patch or file content, or filenames, that contain | 105 | matches patches or files that contain "of_get_profile" |
103 | "of_get_profile" | ||
104 | K: \b(printk|pr_(info|err))\b | 106 | K: \b(printk|pr_(info|err))\b |
105 | matches patch or file content, or filenames, that contain one or | 107 | matches patches or files that contain one or more of the words |
106 | more of the words printk, pr_info or pr_err | 108 | printk, pr_info or pr_err |
107 | One regex pattern per line. Multiple K: lines acceptable. | 109 | One regex pattern per line. Multiple K: lines acceptable. |
108 | 110 | ||
109 | Note: For the hard of thinking, this list is meant to remain in alphabetical | 111 | Note: For the hard of thinking, this list is meant to remain in alphabetical |
@@ -2442,9 +2444,7 @@ S: Maintained | |||
2442 | F: drivers/platform/x86/dell-laptop.c | 2444 | F: drivers/platform/x86/dell-laptop.c |
2443 | 2445 | ||
2444 | DELL LAPTOP SMM DRIVER | 2446 | DELL LAPTOP SMM DRIVER |
2445 | M: Massimo Dal Zotto <dz@debian.org> | 2447 | S: Orphan |
2446 | W: http://www.debian.org/~dz/i8k/ | ||
2447 | S: Maintained | ||
2448 | F: drivers/char/i8k.c | 2448 | F: drivers/char/i8k.c |
2449 | F: include/uapi/linux/i8k.h | 2449 | F: include/uapi/linux/i8k.h |
2450 | 2450 | ||
@@ -7893,7 +7893,7 @@ L: linux-tegra@vger.kernel.org | |||
7893 | Q: http://patchwork.ozlabs.org/project/linux-tegra/list/ | 7893 | Q: http://patchwork.ozlabs.org/project/linux-tegra/list/ |
7894 | T: git git://git.kernel.org/pub/scm/linux/kernel/git/swarren/linux-tegra.git | 7894 | T: git git://git.kernel.org/pub/scm/linux/kernel/git/swarren/linux-tegra.git |
7895 | S: Supported | 7895 | S: Supported |
7896 | K: (?i)[^a-z]tegra | 7896 | N: [^a-z]tegra |
7897 | 7897 | ||
7898 | TEHUTI ETHERNET DRIVER | 7898 | TEHUTI ETHERNET DRIVER |
7899 | M: Andy Gospodarek <andy@greyhouse.net> | 7899 | M: Andy Gospodarek <andy@greyhouse.net> |
@@ -8379,9 +8379,10 @@ S: Maintained | |||
8379 | F: drivers/usb/serial/option.c | 8379 | F: drivers/usb/serial/option.c |
8380 | 8380 | ||
8381 | USB PEGASUS DRIVER | 8381 | USB PEGASUS DRIVER |
8382 | M: Petko Manolov <petkan@users.sourceforge.net> | 8382 | M: Petko Manolov <petkan@nucleusys.com> |
8383 | L: linux-usb@vger.kernel.org | 8383 | L: linux-usb@vger.kernel.org |
8384 | L: netdev@vger.kernel.org | 8384 | L: netdev@vger.kernel.org |
8385 | T: git git://git.code.sf.net/p/pegasus2/git | ||
8385 | W: http://pegasus2.sourceforge.net/ | 8386 | W: http://pegasus2.sourceforge.net/ |
8386 | S: Maintained | 8387 | S: Maintained |
8387 | F: drivers/net/usb/pegasus.* | 8388 | F: drivers/net/usb/pegasus.* |
@@ -8401,9 +8402,10 @@ S: Supported | |||
8401 | F: drivers/usb/class/usblp.c | 8402 | F: drivers/usb/class/usblp.c |
8402 | 8403 | ||
8403 | USB RTL8150 DRIVER | 8404 | USB RTL8150 DRIVER |
8404 | M: Petko Manolov <petkan@users.sourceforge.net> | 8405 | M: Petko Manolov <petkan@nucleusys.com> |
8405 | L: linux-usb@vger.kernel.org | 8406 | L: linux-usb@vger.kernel.org |
8406 | L: netdev@vger.kernel.org | 8407 | L: netdev@vger.kernel.org |
8408 | T: git git://git.code.sf.net/p/pegasus2/git | ||
8407 | W: http://pegasus2.sourceforge.net/ | 8409 | W: http://pegasus2.sourceforge.net/ |
8408 | S: Maintained | 8410 | S: Maintained |
8409 | F: drivers/net/usb/rtl8150.c | 8411 | F: drivers/net/usb/rtl8150.c |
diff --git a/arch/arm/kernel/early_printk.c b/arch/arm/kernel/early_printk.c index 85aa2b292692..43076536965c 100644 --- a/arch/arm/kernel/early_printk.c +++ b/arch/arm/kernel/early_printk.c | |||
@@ -29,28 +29,17 @@ static void early_console_write(struct console *con, const char *s, unsigned n) | |||
29 | early_write(s, n); | 29 | early_write(s, n); |
30 | } | 30 | } |
31 | 31 | ||
32 | static struct console early_console = { | 32 | static struct console early_console_dev = { |
33 | .name = "earlycon", | 33 | .name = "earlycon", |
34 | .write = early_console_write, | 34 | .write = early_console_write, |
35 | .flags = CON_PRINTBUFFER | CON_BOOT, | 35 | .flags = CON_PRINTBUFFER | CON_BOOT, |
36 | .index = -1, | 36 | .index = -1, |
37 | }; | 37 | }; |
38 | 38 | ||
39 | asmlinkage void early_printk(const char *fmt, ...) | ||
40 | { | ||
41 | char buf[512]; | ||
42 | int n; | ||
43 | va_list ap; | ||
44 | |||
45 | va_start(ap, fmt); | ||
46 | n = vscnprintf(buf, sizeof(buf), fmt, ap); | ||
47 | early_write(buf, n); | ||
48 | va_end(ap); | ||
49 | } | ||
50 | |||
51 | static int __init setup_early_printk(char *buf) | 39 | static int __init setup_early_printk(char *buf) |
52 | { | 40 | { |
53 | register_console(&early_console); | 41 | early_console = &early_console_dev; |
42 | register_console(&early_console_dev); | ||
54 | return 0; | 43 | return 0; |
55 | } | 44 | } |
56 | 45 | ||
diff --git a/arch/blackfin/kernel/early_printk.c b/arch/blackfin/kernel/early_printk.c index 84ed8375113c..61fbd2de993d 100644 --- a/arch/blackfin/kernel/early_printk.c +++ b/arch/blackfin/kernel/early_printk.c | |||
@@ -25,8 +25,6 @@ extern struct console *bfin_earlyserial_init(unsigned int port, | |||
25 | extern struct console *bfin_jc_early_init(void); | 25 | extern struct console *bfin_jc_early_init(void); |
26 | #endif | 26 | #endif |
27 | 27 | ||
28 | static struct console *early_console; | ||
29 | |||
30 | /* Default console */ | 28 | /* Default console */ |
31 | #define DEFAULT_PORT 0 | 29 | #define DEFAULT_PORT 0 |
32 | #define DEFAULT_CFLAG CS8|B57600 | 30 | #define DEFAULT_CFLAG CS8|B57600 |
diff --git a/arch/microblaze/kernel/early_printk.c b/arch/microblaze/kernel/early_printk.c index 60dcacc68038..365f2d53f1b2 100644 --- a/arch/microblaze/kernel/early_printk.c +++ b/arch/microblaze/kernel/early_printk.c | |||
@@ -21,7 +21,6 @@ | |||
21 | #include <asm/setup.h> | 21 | #include <asm/setup.h> |
22 | #include <asm/prom.h> | 22 | #include <asm/prom.h> |
23 | 23 | ||
24 | static u32 early_console_initialized; | ||
25 | static u32 base_addr; | 24 | static u32 base_addr; |
26 | 25 | ||
27 | #ifdef CONFIG_SERIAL_UARTLITE_CONSOLE | 26 | #ifdef CONFIG_SERIAL_UARTLITE_CONSOLE |
@@ -109,27 +108,11 @@ static struct console early_serial_uart16550_console = { | |||
109 | }; | 108 | }; |
110 | #endif /* CONFIG_SERIAL_8250_CONSOLE */ | 109 | #endif /* CONFIG_SERIAL_8250_CONSOLE */ |
111 | 110 | ||
112 | static struct console *early_console; | ||
113 | |||
114 | void early_printk(const char *fmt, ...) | ||
115 | { | ||
116 | char buf[512]; | ||
117 | int n; | ||
118 | va_list ap; | ||
119 | |||
120 | if (early_console_initialized) { | ||
121 | va_start(ap, fmt); | ||
122 | n = vscnprintf(buf, 512, fmt, ap); | ||
123 | early_console->write(early_console, buf, n); | ||
124 | va_end(ap); | ||
125 | } | ||
126 | } | ||
127 | |||
128 | int __init setup_early_printk(char *opt) | 111 | int __init setup_early_printk(char *opt) |
129 | { | 112 | { |
130 | int version = 0; | 113 | int version = 0; |
131 | 114 | ||
132 | if (early_console_initialized) | 115 | if (early_console) |
133 | return 1; | 116 | return 1; |
134 | 117 | ||
135 | base_addr = of_early_console(&version); | 118 | base_addr = of_early_console(&version); |
@@ -159,7 +142,6 @@ int __init setup_early_printk(char *opt) | |||
159 | } | 142 | } |
160 | 143 | ||
161 | register_console(early_console); | 144 | register_console(early_console); |
162 | early_console_initialized = 1; | ||
163 | return 0; | 145 | return 0; |
164 | } | 146 | } |
165 | return 1; | 147 | return 1; |
@@ -169,7 +151,7 @@ int __init setup_early_printk(char *opt) | |||
169 | * only for early console because of performance degression */ | 151 | * only for early console because of performance degression */ |
170 | void __init remap_early_printk(void) | 152 | void __init remap_early_printk(void) |
171 | { | 153 | { |
172 | if (!early_console_initialized || !early_console) | 154 | if (!early_console) |
173 | return; | 155 | return; |
174 | pr_info("early_printk_console remapping from 0x%x to ", base_addr); | 156 | pr_info("early_printk_console remapping from 0x%x to ", base_addr); |
175 | base_addr = (u32) ioremap(base_addr, PAGE_SIZE); | 157 | base_addr = (u32) ioremap(base_addr, PAGE_SIZE); |
@@ -194,9 +176,9 @@ void __init remap_early_printk(void) | |||
194 | 176 | ||
195 | void __init disable_early_printk(void) | 177 | void __init disable_early_printk(void) |
196 | { | 178 | { |
197 | if (!early_console_initialized || !early_console) | 179 | if (!early_console) |
198 | return; | 180 | return; |
199 | pr_warn("disabling early console\n"); | 181 | pr_warn("disabling early console\n"); |
200 | unregister_console(early_console); | 182 | unregister_console(early_console); |
201 | early_console_initialized = 0; | 183 | early_console = NULL; |
202 | } | 184 | } |
diff --git a/arch/mips/kernel/early_printk.c b/arch/mips/kernel/early_printk.c index 9e6440eaa455..505cb77d1280 100644 --- a/arch/mips/kernel/early_printk.c +++ b/arch/mips/kernel/early_printk.c | |||
@@ -7,7 +7,9 @@ | |||
7 | * Copyright (C) 2007 MIPS Technologies, Inc. | 7 | * Copyright (C) 2007 MIPS Technologies, Inc. |
8 | * written by Ralf Baechle (ralf@linux-mips.org) | 8 | * written by Ralf Baechle (ralf@linux-mips.org) |
9 | */ | 9 | */ |
10 | #include <linux/kernel.h> | ||
10 | #include <linux/console.h> | 11 | #include <linux/console.h> |
12 | #include <linux/printk.h> | ||
11 | #include <linux/init.h> | 13 | #include <linux/init.h> |
12 | 14 | ||
13 | #include <asm/setup.h> | 15 | #include <asm/setup.h> |
@@ -24,20 +26,18 @@ static void early_console_write(struct console *con, const char *s, unsigned n) | |||
24 | } | 26 | } |
25 | } | 27 | } |
26 | 28 | ||
27 | static struct console early_console = { | 29 | static struct console early_console_prom = { |
28 | .name = "early", | 30 | .name = "early", |
29 | .write = early_console_write, | 31 | .write = early_console_write, |
30 | .flags = CON_PRINTBUFFER | CON_BOOT, | 32 | .flags = CON_PRINTBUFFER | CON_BOOT, |
31 | .index = -1 | 33 | .index = -1 |
32 | }; | 34 | }; |
33 | 35 | ||
34 | static int early_console_initialized __initdata; | ||
35 | |||
36 | void __init setup_early_printk(void) | 36 | void __init setup_early_printk(void) |
37 | { | 37 | { |
38 | if (early_console_initialized) | 38 | if (early_console) |
39 | return; | 39 | return; |
40 | early_console_initialized = 1; | 40 | early_console = &early_console_prom; |
41 | 41 | ||
42 | register_console(&early_console); | 42 | register_console(&early_console_prom); |
43 | } | 43 | } |
diff --git a/arch/powerpc/kernel/udbg.c b/arch/powerpc/kernel/udbg.c index f9748498fe58..13b867093499 100644 --- a/arch/powerpc/kernel/udbg.c +++ b/arch/powerpc/kernel/udbg.c | |||
@@ -156,15 +156,13 @@ static struct console udbg_console = { | |||
156 | .index = 0, | 156 | .index = 0, |
157 | }; | 157 | }; |
158 | 158 | ||
159 | static int early_console_initialized; | ||
160 | |||
161 | /* | 159 | /* |
162 | * Called by setup_system after ppc_md->probe and ppc_md->early_init. | 160 | * Called by setup_system after ppc_md->probe and ppc_md->early_init. |
163 | * Call it again after setting udbg_putc in ppc_md->setup_arch. | 161 | * Call it again after setting udbg_putc in ppc_md->setup_arch. |
164 | */ | 162 | */ |
165 | void __init register_early_udbg_console(void) | 163 | void __init register_early_udbg_console(void) |
166 | { | 164 | { |
167 | if (early_console_initialized) | 165 | if (early_console) |
168 | return; | 166 | return; |
169 | 167 | ||
170 | if (!udbg_putc) | 168 | if (!udbg_putc) |
@@ -174,7 +172,7 @@ void __init register_early_udbg_console(void) | |||
174 | printk(KERN_INFO "early console immortal !\n"); | 172 | printk(KERN_INFO "early console immortal !\n"); |
175 | udbg_console.flags &= ~CON_BOOT; | 173 | udbg_console.flags &= ~CON_BOOT; |
176 | } | 174 | } |
177 | early_console_initialized = 1; | 175 | early_console = &udbg_console; |
178 | register_console(&udbg_console); | 176 | register_console(&udbg_console); |
179 | } | 177 | } |
180 | 178 | ||
diff --git a/arch/sh/kernel/sh_bios.c b/arch/sh/kernel/sh_bios.c index 47475cca068a..fe584e516964 100644 --- a/arch/sh/kernel/sh_bios.c +++ b/arch/sh/kernel/sh_bios.c | |||
@@ -104,6 +104,7 @@ void sh_bios_vbr_reload(void) | |||
104 | ); | 104 | ); |
105 | } | 105 | } |
106 | 106 | ||
107 | #ifdef CONFIG_EARLY_PRINTK | ||
107 | /* | 108 | /* |
108 | * Print a string through the BIOS | 109 | * Print a string through the BIOS |
109 | */ | 110 | */ |
@@ -144,8 +145,6 @@ static struct console bios_console = { | |||
144 | .index = -1, | 145 | .index = -1, |
145 | }; | 146 | }; |
146 | 147 | ||
147 | static struct console *early_console; | ||
148 | |||
149 | static int __init setup_early_printk(char *buf) | 148 | static int __init setup_early_printk(char *buf) |
150 | { | 149 | { |
151 | int keep_early = 0; | 150 | int keep_early = 0; |
@@ -170,3 +169,4 @@ static int __init setup_early_printk(char *buf) | |||
170 | return 0; | 169 | return 0; |
171 | } | 170 | } |
172 | early_param("earlyprintk", setup_early_printk); | 171 | early_param("earlyprintk", setup_early_printk); |
172 | #endif | ||
diff --git a/arch/tile/kernel/early_printk.c b/arch/tile/kernel/early_printk.c index afb9c9a0d887..34d72a151bf3 100644 --- a/arch/tile/kernel/early_printk.c +++ b/arch/tile/kernel/early_printk.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <linux/init.h> | 17 | #include <linux/init.h> |
18 | #include <linux/string.h> | 18 | #include <linux/string.h> |
19 | #include <linux/irqflags.h> | 19 | #include <linux/irqflags.h> |
20 | #include <linux/printk.h> | ||
20 | #include <asm/setup.h> | 21 | #include <asm/setup.h> |
21 | #include <hv/hypervisor.h> | 22 | #include <hv/hypervisor.h> |
22 | 23 | ||
@@ -33,25 +34,8 @@ static struct console early_hv_console = { | |||
33 | }; | 34 | }; |
34 | 35 | ||
35 | /* Direct interface for emergencies */ | 36 | /* Direct interface for emergencies */ |
36 | static struct console *early_console = &early_hv_console; | ||
37 | static int early_console_initialized; | ||
38 | static int early_console_complete; | 37 | static int early_console_complete; |
39 | 38 | ||
40 | static void early_vprintk(const char *fmt, va_list ap) | ||
41 | { | ||
42 | char buf[512]; | ||
43 | int n = vscnprintf(buf, sizeof(buf), fmt, ap); | ||
44 | early_console->write(early_console, buf, n); | ||
45 | } | ||
46 | |||
47 | void early_printk(const char *fmt, ...) | ||
48 | { | ||
49 | va_list ap; | ||
50 | va_start(ap, fmt); | ||
51 | early_vprintk(fmt, ap); | ||
52 | va_end(ap); | ||
53 | } | ||
54 | |||
55 | void early_panic(const char *fmt, ...) | 39 | void early_panic(const char *fmt, ...) |
56 | { | 40 | { |
57 | va_list ap; | 41 | va_list ap; |
@@ -69,14 +53,13 @@ static int __initdata keep_early; | |||
69 | 53 | ||
70 | static int __init setup_early_printk(char *str) | 54 | static int __init setup_early_printk(char *str) |
71 | { | 55 | { |
72 | if (early_console_initialized) | 56 | if (early_console) |
73 | return 1; | 57 | return 1; |
74 | 58 | ||
75 | if (str != NULL && strncmp(str, "keep", 4) == 0) | 59 | if (str != NULL && strncmp(str, "keep", 4) == 0) |
76 | keep_early = 1; | 60 | keep_early = 1; |
77 | 61 | ||
78 | early_console = &early_hv_console; | 62 | early_console = &early_hv_console; |
79 | early_console_initialized = 1; | ||
80 | register_console(early_console); | 63 | register_console(early_console); |
81 | 64 | ||
82 | return 0; | 65 | return 0; |
@@ -85,12 +68,12 @@ static int __init setup_early_printk(char *str) | |||
85 | void __init disable_early_printk(void) | 68 | void __init disable_early_printk(void) |
86 | { | 69 | { |
87 | early_console_complete = 1; | 70 | early_console_complete = 1; |
88 | if (!early_console_initialized || !early_console) | 71 | if (!early_console) |
89 | return; | 72 | return; |
90 | if (!keep_early) { | 73 | if (!keep_early) { |
91 | early_printk("disabling early console\n"); | 74 | early_printk("disabling early console\n"); |
92 | unregister_console(early_console); | 75 | unregister_console(early_console); |
93 | early_console_initialized = 0; | 76 | early_console = NULL; |
94 | } else { | 77 | } else { |
95 | early_printk("keeping early console\n"); | 78 | early_printk("keeping early console\n"); |
96 | } | 79 | } |
@@ -98,7 +81,7 @@ void __init disable_early_printk(void) | |||
98 | 81 | ||
99 | void warn_early_printk(void) | 82 | void warn_early_printk(void) |
100 | { | 83 | { |
101 | if (early_console_complete || early_console_initialized) | 84 | if (early_console_complete || early_console) |
102 | return; | 85 | return; |
103 | early_printk("\ | 86 | early_printk("\ |
104 | Machine shutting down before console output is fully initialized.\n\ | 87 | Machine shutting down before console output is fully initialized.\n\ |
diff --git a/arch/um/kernel/early_printk.c b/arch/um/kernel/early_printk.c index 49480f092456..4a0800bc37b2 100644 --- a/arch/um/kernel/early_printk.c +++ b/arch/um/kernel/early_printk.c | |||
@@ -16,7 +16,7 @@ static void early_console_write(struct console *con, const char *s, unsigned int | |||
16 | um_early_printk(s, n); | 16 | um_early_printk(s, n); |
17 | } | 17 | } |
18 | 18 | ||
19 | static struct console early_console = { | 19 | static struct console early_console_dev = { |
20 | .name = "earlycon", | 20 | .name = "earlycon", |
21 | .write = early_console_write, | 21 | .write = early_console_write, |
22 | .flags = CON_BOOT, | 22 | .flags = CON_BOOT, |
@@ -25,8 +25,10 @@ static struct console early_console = { | |||
25 | 25 | ||
26 | static int __init setup_early_printk(char *buf) | 26 | static int __init setup_early_printk(char *buf) |
27 | { | 27 | { |
28 | register_console(&early_console); | 28 | if (!early_console) { |
29 | 29 | early_console = &early_console_dev; | |
30 | register_console(&early_console_dev); | ||
31 | } | ||
30 | return 0; | 32 | return 0; |
31 | } | 33 | } |
32 | 34 | ||
diff --git a/arch/unicore32/kernel/early_printk.c b/arch/unicore32/kernel/early_printk.c index 3922255f1fa8..9be0d5d02a9a 100644 --- a/arch/unicore32/kernel/early_printk.c +++ b/arch/unicore32/kernel/early_printk.c | |||
@@ -33,21 +33,17 @@ static struct console early_ocd_console = { | |||
33 | .index = -1, | 33 | .index = -1, |
34 | }; | 34 | }; |
35 | 35 | ||
36 | /* Direct interface for emergencies */ | ||
37 | static struct console *early_console = &early_ocd_console; | ||
38 | |||
39 | static int __initdata keep_early; | ||
40 | |||
41 | static int __init setup_early_printk(char *buf) | 36 | static int __init setup_early_printk(char *buf) |
42 | { | 37 | { |
43 | if (!buf) | 38 | int keep_early; |
39 | |||
40 | if (!buf || early_console) | ||
44 | return 0; | 41 | return 0; |
45 | 42 | ||
46 | if (strstr(buf, "keep")) | 43 | if (strstr(buf, "keep")) |
47 | keep_early = 1; | 44 | keep_early = 1; |
48 | 45 | ||
49 | if (!strncmp(buf, "ocd", 3)) | 46 | early_console = &early_ocd_console; |
50 | early_console = &early_ocd_console; | ||
51 | 47 | ||
52 | if (keep_early) | 48 | if (keep_early) |
53 | early_console->flags &= ~CON_BOOT; | 49 | early_console->flags &= ~CON_BOOT; |
diff --git a/arch/x86/kernel/early_printk.c b/arch/x86/kernel/early_printk.c index 9b9f18b49918..d15f575a861b 100644 --- a/arch/x86/kernel/early_printk.c +++ b/arch/x86/kernel/early_printk.c | |||
@@ -169,25 +169,9 @@ static struct console early_serial_console = { | |||
169 | .index = -1, | 169 | .index = -1, |
170 | }; | 170 | }; |
171 | 171 | ||
172 | /* Direct interface for emergencies */ | ||
173 | static struct console *early_console = &early_vga_console; | ||
174 | static int __initdata early_console_initialized; | ||
175 | |||
176 | asmlinkage void early_printk(const char *fmt, ...) | ||
177 | { | ||
178 | char buf[512]; | ||
179 | int n; | ||
180 | va_list ap; | ||
181 | |||
182 | va_start(ap, fmt); | ||
183 | n = vscnprintf(buf, sizeof(buf), fmt, ap); | ||
184 | early_console->write(early_console, buf, n); | ||
185 | va_end(ap); | ||
186 | } | ||
187 | |||
188 | static inline void early_console_register(struct console *con, int keep_early) | 172 | static inline void early_console_register(struct console *con, int keep_early) |
189 | { | 173 | { |
190 | if (early_console->index != -1) { | 174 | if (con->index != -1) { |
191 | printk(KERN_CRIT "ERROR: earlyprintk= %s already used\n", | 175 | printk(KERN_CRIT "ERROR: earlyprintk= %s already used\n", |
192 | con->name); | 176 | con->name); |
193 | return; | 177 | return; |
@@ -207,9 +191,8 @@ static int __init setup_early_printk(char *buf) | |||
207 | if (!buf) | 191 | if (!buf) |
208 | return 0; | 192 | return 0; |
209 | 193 | ||
210 | if (early_console_initialized) | 194 | if (early_console) |
211 | return 0; | 195 | return 0; |
212 | early_console_initialized = 1; | ||
213 | 196 | ||
214 | keep = (strstr(buf, "keep") != NULL); | 197 | keep = (strstr(buf, "keep") != NULL); |
215 | 198 | ||
diff --git a/arch/x86/mm/pageattr-test.c b/arch/x86/mm/pageattr-test.c index 0e38951e65eb..d0b1773d9d2e 100644 --- a/arch/x86/mm/pageattr-test.c +++ b/arch/x86/mm/pageattr-test.c | |||
@@ -130,13 +130,12 @@ static int pageattr_test(void) | |||
130 | } | 130 | } |
131 | 131 | ||
132 | failed += print_split(&sa); | 132 | failed += print_split(&sa); |
133 | srandom32(100); | ||
134 | 133 | ||
135 | for (i = 0; i < NTEST; i++) { | 134 | for (i = 0; i < NTEST; i++) { |
136 | unsigned long pfn = random32() % max_pfn_mapped; | 135 | unsigned long pfn = prandom_u32() % max_pfn_mapped; |
137 | 136 | ||
138 | addr[i] = (unsigned long)__va(pfn << PAGE_SHIFT); | 137 | addr[i] = (unsigned long)__va(pfn << PAGE_SHIFT); |
139 | len[i] = random32() % 100; | 138 | len[i] = prandom_u32() % 100; |
140 | len[i] = min_t(unsigned long, len[i], max_pfn_mapped - pfn - 1); | 139 | len[i] = min_t(unsigned long, len[i], max_pfn_mapped - pfn - 1); |
141 | 140 | ||
142 | if (len[i] == 0) | 141 | if (len[i] == 0) |
diff --git a/crypto/async_tx/raid6test.c b/crypto/async_tx/raid6test.c index aa2b0270ed16..4a92bac744dc 100644 --- a/crypto/async_tx/raid6test.c +++ b/crypto/async_tx/raid6test.c | |||
@@ -46,15 +46,10 @@ static void callback(void *param) | |||
46 | 46 | ||
47 | static void makedata(int disks) | 47 | static void makedata(int disks) |
48 | { | 48 | { |
49 | int i, j; | 49 | int i; |
50 | 50 | ||
51 | for (i = 0; i < disks; i++) { | 51 | for (i = 0; i < disks; i++) { |
52 | for (j = 0; j < PAGE_SIZE/sizeof(u32); j += sizeof(u32)) { | 52 | prandom_bytes(page_address(data[i]), PAGE_SIZE); |
53 | u32 *p = page_address(data[i]) + j; | ||
54 | |||
55 | *p = random32(); | ||
56 | } | ||
57 | |||
58 | dataptrs[i] = data[i]; | 53 | dataptrs[i] = data[i]; |
59 | } | 54 | } |
60 | } | 55 | } |
diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c index a9eccfc6079b..83c5ae0ed56b 100644 --- a/drivers/block/drbd/drbd_receiver.c +++ b/drivers/block/drbd/drbd_receiver.c | |||
@@ -757,7 +757,8 @@ static struct socket *drbd_wait_for_connect(struct drbd_tconn *tconn, struct acc | |||
757 | rcu_read_unlock(); | 757 | rcu_read_unlock(); |
758 | 758 | ||
759 | timeo = connect_int * HZ; | 759 | timeo = connect_int * HZ; |
760 | timeo += (random32() & 1) ? timeo / 7 : -timeo / 7; /* 28.5% random jitter */ | 760 | /* 28.5% random jitter */ |
761 | timeo += (prandom_u32() & 1) ? timeo / 7 : -timeo / 7; | ||
761 | 762 | ||
762 | err = wait_for_completion_interruptible_timeout(&ad->door_bell, timeo); | 763 | err = wait_for_completion_interruptible_timeout(&ad->door_bell, timeo); |
763 | if (err <= 0) | 764 | if (err <= 0) |
@@ -953,7 +954,7 @@ retry: | |||
953 | conn_warn(tconn, "Error receiving initial packet\n"); | 954 | conn_warn(tconn, "Error receiving initial packet\n"); |
954 | sock_release(s); | 955 | sock_release(s); |
955 | randomize: | 956 | randomize: |
956 | if (random32() & 1) | 957 | if (prandom_u32() & 1) |
957 | goto retry; | 958 | goto retry; |
958 | } | 959 | } |
959 | } | 960 | } |
diff --git a/drivers/infiniband/hw/amso1100/c2.h b/drivers/infiniband/hw/amso1100/c2.h index ba7a1208ff9e..d619d735838b 100644 --- a/drivers/infiniband/hw/amso1100/c2.h +++ b/drivers/infiniband/hw/amso1100/c2.h | |||
@@ -265,7 +265,6 @@ struct c2_pd_table { | |||
265 | struct c2_qp_table { | 265 | struct c2_qp_table { |
266 | struct idr idr; | 266 | struct idr idr; |
267 | spinlock_t lock; | 267 | spinlock_t lock; |
268 | int last; | ||
269 | }; | 268 | }; |
270 | 269 | ||
271 | struct c2_element { | 270 | struct c2_element { |
diff --git a/drivers/infiniband/hw/amso1100/c2_qp.c b/drivers/infiniband/hw/amso1100/c2_qp.c index 0ab826b280b2..86708dee58b1 100644 --- a/drivers/infiniband/hw/amso1100/c2_qp.c +++ b/drivers/infiniband/hw/amso1100/c2_qp.c | |||
@@ -385,8 +385,7 @@ static int c2_alloc_qpn(struct c2_dev *c2dev, struct c2_qp *qp) | |||
385 | idr_preload(GFP_KERNEL); | 385 | idr_preload(GFP_KERNEL); |
386 | spin_lock_irq(&c2dev->qp_table.lock); | 386 | spin_lock_irq(&c2dev->qp_table.lock); |
387 | 387 | ||
388 | ret = idr_alloc(&c2dev->qp_table.idr, qp, c2dev->qp_table.last++, 0, | 388 | ret = idr_alloc_cyclic(&c2dev->qp_table.idr, qp, 0, 0, GFP_NOWAIT); |
389 | GFP_NOWAIT); | ||
390 | if (ret >= 0) | 389 | if (ret >= 0) |
391 | qp->qpn = ret; | 390 | qp->qpn = ret; |
392 | 391 | ||
diff --git a/drivers/infiniband/hw/mlx4/cm.c b/drivers/infiniband/hw/mlx4/cm.c index add98d01476c..d1f5f1dd77b0 100644 --- a/drivers/infiniband/hw/mlx4/cm.c +++ b/drivers/infiniband/hw/mlx4/cm.c | |||
@@ -204,7 +204,6 @@ static struct id_map_entry * | |||
204 | id_map_alloc(struct ib_device *ibdev, int slave_id, u32 sl_cm_id) | 204 | id_map_alloc(struct ib_device *ibdev, int slave_id, u32 sl_cm_id) |
205 | { | 205 | { |
206 | int ret; | 206 | int ret; |
207 | static int next_id; | ||
208 | struct id_map_entry *ent; | 207 | struct id_map_entry *ent; |
209 | struct mlx4_ib_sriov *sriov = &to_mdev(ibdev)->sriov; | 208 | struct mlx4_ib_sriov *sriov = &to_mdev(ibdev)->sriov; |
210 | 209 | ||
@@ -223,9 +222,8 @@ id_map_alloc(struct ib_device *ibdev, int slave_id, u32 sl_cm_id) | |||
223 | idr_preload(GFP_KERNEL); | 222 | idr_preload(GFP_KERNEL); |
224 | spin_lock(&to_mdev(ibdev)->sriov.id_map_lock); | 223 | spin_lock(&to_mdev(ibdev)->sriov.id_map_lock); |
225 | 224 | ||
226 | ret = idr_alloc(&sriov->pv_id_table, ent, next_id, 0, GFP_NOWAIT); | 225 | ret = idr_alloc_cyclic(&sriov->pv_id_table, ent, 0, 0, GFP_NOWAIT); |
227 | if (ret >= 0) { | 226 | if (ret >= 0) { |
228 | next_id = max(ret + 1, 0); | ||
229 | ent->pv_cm_id = (u32)ret; | 227 | ent->pv_cm_id = (u32)ret; |
230 | sl_id_map_add(ibdev, ent); | 228 | sl_id_map_add(ibdev, ent); |
231 | list_add_tail(&ent->list, &sriov->cm_list); | 229 | list_add_tail(&ent->list, &sriov->cm_list); |
diff --git a/drivers/lguest/page_tables.c b/drivers/lguest/page_tables.c index 3b62be160a6e..864baabaee25 100644 --- a/drivers/lguest/page_tables.c +++ b/drivers/lguest/page_tables.c | |||
@@ -686,7 +686,7 @@ static unsigned int new_pgdir(struct lg_cpu *cpu, | |||
686 | * We pick one entry at random to throw out. Choosing the Least | 686 | * We pick one entry at random to throw out. Choosing the Least |
687 | * Recently Used might be better, but this is easy. | 687 | * Recently Used might be better, but this is easy. |
688 | */ | 688 | */ |
689 | next = random32() % ARRAY_SIZE(cpu->lg->pgdirs); | 689 | next = prandom_u32() % ARRAY_SIZE(cpu->lg->pgdirs); |
690 | /* If it's never been allocated at all before, try now. */ | 690 | /* If it's never been allocated at all before, try now. */ |
691 | if (!cpu->lg->pgdirs[next].pgdir) { | 691 | if (!cpu->lg->pgdirs[next].pgdir) { |
692 | cpu->lg->pgdirs[next].pgdir = | 692 | cpu->lg->pgdirs[next].pgdir = |
diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig index a0639e779973..26500094de7c 100644 --- a/drivers/media/platform/Kconfig +++ b/drivers/media/platform/Kconfig | |||
@@ -145,7 +145,6 @@ config VIDEO_CODA | |||
145 | depends on VIDEO_DEV && VIDEO_V4L2 && ARCH_MXC | 145 | depends on VIDEO_DEV && VIDEO_V4L2 && ARCH_MXC |
146 | select VIDEOBUF2_DMA_CONTIG | 146 | select VIDEOBUF2_DMA_CONTIG |
147 | select V4L2_MEM2MEM_DEV | 147 | select V4L2_MEM2MEM_DEV |
148 | select IRAM_ALLOC if SOC_IMX53 | ||
149 | ---help--- | 148 | ---help--- |
150 | Coda is a range of video codec IPs that supports | 149 | Coda is a range of video codec IPs that supports |
151 | H.264, MPEG-4, and other video formats. | 150 | H.264, MPEG-4, and other video formats. |
diff --git a/drivers/media/platform/coda.c b/drivers/media/platform/coda.c index 20827ba168fc..b931c2a5c7fc 100644 --- a/drivers/media/platform/coda.c +++ b/drivers/media/platform/coda.c | |||
@@ -14,6 +14,7 @@ | |||
14 | #include <linux/clk.h> | 14 | #include <linux/clk.h> |
15 | #include <linux/delay.h> | 15 | #include <linux/delay.h> |
16 | #include <linux/firmware.h> | 16 | #include <linux/firmware.h> |
17 | #include <linux/genalloc.h> | ||
17 | #include <linux/interrupt.h> | 18 | #include <linux/interrupt.h> |
18 | #include <linux/io.h> | 19 | #include <linux/io.h> |
19 | #include <linux/irq.h> | 20 | #include <linux/irq.h> |
@@ -23,7 +24,7 @@ | |||
23 | #include <linux/slab.h> | 24 | #include <linux/slab.h> |
24 | #include <linux/videodev2.h> | 25 | #include <linux/videodev2.h> |
25 | #include <linux/of.h> | 26 | #include <linux/of.h> |
26 | #include <linux/platform_data/imx-iram.h> | 27 | #include <linux/platform_data/coda.h> |
27 | 28 | ||
28 | #include <media/v4l2-ctrls.h> | 29 | #include <media/v4l2-ctrls.h> |
29 | #include <media/v4l2-device.h> | 30 | #include <media/v4l2-device.h> |
@@ -43,6 +44,7 @@ | |||
43 | #define CODA7_WORK_BUF_SIZE (512 * 1024 + CODA_FMO_BUF_SIZE * 8 * 1024) | 44 | #define CODA7_WORK_BUF_SIZE (512 * 1024 + CODA_FMO_BUF_SIZE * 8 * 1024) |
44 | #define CODA_PARA_BUF_SIZE (10 * 1024) | 45 | #define CODA_PARA_BUF_SIZE (10 * 1024) |
45 | #define CODA_ISRAM_SIZE (2048 * 2) | 46 | #define CODA_ISRAM_SIZE (2048 * 2) |
47 | #define CODADX6_IRAM_SIZE 0xb000 | ||
46 | #define CODA7_IRAM_SIZE 0x14000 /* 81920 bytes */ | 48 | #define CODA7_IRAM_SIZE 0x14000 /* 81920 bytes */ |
47 | 49 | ||
48 | #define CODA_MAX_FRAMEBUFFERS 2 | 50 | #define CODA_MAX_FRAMEBUFFERS 2 |
@@ -128,7 +130,10 @@ struct coda_dev { | |||
128 | 130 | ||
129 | struct coda_aux_buf codebuf; | 131 | struct coda_aux_buf codebuf; |
130 | struct coda_aux_buf workbuf; | 132 | struct coda_aux_buf workbuf; |
133 | struct gen_pool *iram_pool; | ||
134 | long unsigned int iram_vaddr; | ||
131 | long unsigned int iram_paddr; | 135 | long unsigned int iram_paddr; |
136 | unsigned long iram_size; | ||
132 | 137 | ||
133 | spinlock_t irqlock; | 138 | spinlock_t irqlock; |
134 | struct mutex dev_mutex; | 139 | struct mutex dev_mutex; |
@@ -1926,6 +1931,9 @@ static int coda_probe(struct platform_device *pdev) | |||
1926 | const struct of_device_id *of_id = | 1931 | const struct of_device_id *of_id = |
1927 | of_match_device(of_match_ptr(coda_dt_ids), &pdev->dev); | 1932 | of_match_device(of_match_ptr(coda_dt_ids), &pdev->dev); |
1928 | const struct platform_device_id *pdev_id; | 1933 | const struct platform_device_id *pdev_id; |
1934 | struct coda_platform_data *pdata = pdev->dev.platform_data; | ||
1935 | struct device_node *np = pdev->dev.of_node; | ||
1936 | struct gen_pool *pool; | ||
1929 | struct coda_dev *dev; | 1937 | struct coda_dev *dev; |
1930 | struct resource *res; | 1938 | struct resource *res; |
1931 | int ret, irq; | 1939 | int ret, irq; |
@@ -1988,6 +1996,16 @@ static int coda_probe(struct platform_device *pdev) | |||
1988 | return -ENOENT; | 1996 | return -ENOENT; |
1989 | } | 1997 | } |
1990 | 1998 | ||
1999 | /* Get IRAM pool from device tree or platform data */ | ||
2000 | pool = of_get_named_gen_pool(np, "iram", 0); | ||
2001 | if (!pool && pdata) | ||
2002 | pool = dev_get_gen_pool(pdata->iram_dev); | ||
2003 | if (!pool) { | ||
2004 | dev_err(&pdev->dev, "iram pool not available\n"); | ||
2005 | return -ENOMEM; | ||
2006 | } | ||
2007 | dev->iram_pool = pool; | ||
2008 | |||
1991 | ret = v4l2_device_register(&pdev->dev, &dev->v4l2_dev); | 2009 | ret = v4l2_device_register(&pdev->dev, &dev->v4l2_dev); |
1992 | if (ret) | 2010 | if (ret) |
1993 | return ret; | 2011 | return ret; |
@@ -2022,18 +2040,17 @@ static int coda_probe(struct platform_device *pdev) | |||
2022 | return -ENOMEM; | 2040 | return -ENOMEM; |
2023 | } | 2041 | } |
2024 | 2042 | ||
2025 | if (dev->devtype->product == CODA_DX6) { | 2043 | if (dev->devtype->product == CODA_DX6) |
2026 | dev->iram_paddr = 0xffff4c00; | 2044 | dev->iram_size = CODADX6_IRAM_SIZE; |
2027 | } else { | 2045 | else |
2028 | void __iomem *iram_vaddr; | 2046 | dev->iram_size = CODA7_IRAM_SIZE; |
2029 | 2047 | dev->iram_vaddr = gen_pool_alloc(dev->iram_pool, dev->iram_size); | |
2030 | iram_vaddr = iram_alloc(CODA7_IRAM_SIZE, | 2048 | if (!dev->iram_vaddr) { |
2031 | &dev->iram_paddr); | 2049 | dev_err(&pdev->dev, "unable to alloc iram\n"); |
2032 | if (!iram_vaddr) { | 2050 | return -ENOMEM; |
2033 | dev_err(&pdev->dev, "unable to alloc iram\n"); | ||
2034 | return -ENOMEM; | ||
2035 | } | ||
2036 | } | 2051 | } |
2052 | dev->iram_paddr = gen_pool_virt_to_phys(dev->iram_pool, | ||
2053 | dev->iram_vaddr); | ||
2037 | 2054 | ||
2038 | platform_set_drvdata(pdev, dev); | 2055 | platform_set_drvdata(pdev, dev); |
2039 | 2056 | ||
@@ -2050,8 +2067,8 @@ static int coda_remove(struct platform_device *pdev) | |||
2050 | if (dev->alloc_ctx) | 2067 | if (dev->alloc_ctx) |
2051 | vb2_dma_contig_cleanup_ctx(dev->alloc_ctx); | 2068 | vb2_dma_contig_cleanup_ctx(dev->alloc_ctx); |
2052 | v4l2_device_unregister(&dev->v4l2_dev); | 2069 | v4l2_device_unregister(&dev->v4l2_dev); |
2053 | if (dev->iram_paddr) | 2070 | if (dev->iram_vaddr) |
2054 | iram_free(dev->iram_paddr, CODA7_IRAM_SIZE); | 2071 | gen_pool_free(dev->iram_pool, dev->iram_vaddr, dev->iram_size); |
2055 | if (dev->codebuf.vaddr) | 2072 | if (dev->codebuf.vaddr) |
2056 | dma_free_coherent(&pdev->dev, dev->codebuf.size, | 2073 | dma_free_coherent(&pdev->dev, dev->codebuf.size, |
2057 | &dev->codebuf.vaddr, dev->codebuf.paddr); | 2074 | &dev->codebuf.vaddr, dev->codebuf.paddr); |
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig index e29e7980a359..3659d00efdc5 100644 --- a/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig | |||
@@ -518,6 +518,15 @@ config LATTICE_ECP3_CONFIG | |||
518 | 518 | ||
519 | If unsure, say N. | 519 | If unsure, say N. |
520 | 520 | ||
521 | config SRAM | ||
522 | bool "Generic on-chip SRAM driver" | ||
523 | depends on HAS_IOMEM | ||
524 | select GENERIC_ALLOCATOR | ||
525 | help | ||
526 | This driver allows you to declare a memory region to be managed by | ||
527 | the genalloc API. It is supposed to be used for small on-chip SRAM | ||
528 | areas found on many SoCs. | ||
529 | |||
521 | source "drivers/misc/c2port/Kconfig" | 530 | source "drivers/misc/c2port/Kconfig" |
522 | source "drivers/misc/eeprom/Kconfig" | 531 | source "drivers/misc/eeprom/Kconfig" |
523 | source "drivers/misc/cb710/Kconfig" | 532 | source "drivers/misc/cb710/Kconfig" |
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile index 865cbc6a7ae1..c235d5b68311 100644 --- a/drivers/misc/Makefile +++ b/drivers/misc/Makefile | |||
@@ -52,3 +52,4 @@ obj-$(CONFIG_ALTERA_STAPL) +=altera-stapl/ | |||
52 | obj-$(CONFIG_INTEL_MEI) += mei/ | 52 | obj-$(CONFIG_INTEL_MEI) += mei/ |
53 | obj-$(CONFIG_VMWARE_VMCI) += vmw_vmci/ | 53 | obj-$(CONFIG_VMWARE_VMCI) += vmw_vmci/ |
54 | obj-$(CONFIG_LATTICE_ECP3_CONFIG) += lattice-ecp3-config.o | 54 | obj-$(CONFIG_LATTICE_ECP3_CONFIG) += lattice-ecp3-config.o |
55 | obj-$(CONFIG_SRAM) += sram.o | ||
diff --git a/drivers/misc/sram.c b/drivers/misc/sram.c new file mode 100644 index 000000000000..437192e43006 --- /dev/null +++ b/drivers/misc/sram.c | |||
@@ -0,0 +1,121 @@ | |||
1 | /* | ||
2 | * Generic on-chip SRAM allocation driver | ||
3 | * | ||
4 | * Copyright (C) 2012 Philipp Zabel, Pengutronix | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public License | ||
8 | * as published by the Free Software Foundation; either version 2 | ||
9 | * of the License, or (at your option) any later version. | ||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program; if not, write to the Free Software | ||
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | ||
18 | * MA 02110-1301, USA. | ||
19 | */ | ||
20 | |||
21 | #include <linux/kernel.h> | ||
22 | #include <linux/init.h> | ||
23 | #include <linux/clk.h> | ||
24 | #include <linux/err.h> | ||
25 | #include <linux/io.h> | ||
26 | #include <linux/of.h> | ||
27 | #include <linux/platform_device.h> | ||
28 | #include <linux/slab.h> | ||
29 | #include <linux/spinlock.h> | ||
30 | #include <linux/genalloc.h> | ||
31 | |||
32 | #define SRAM_GRANULARITY 32 | ||
33 | |||
34 | struct sram_dev { | ||
35 | struct gen_pool *pool; | ||
36 | struct clk *clk; | ||
37 | }; | ||
38 | |||
39 | static int sram_probe(struct platform_device *pdev) | ||
40 | { | ||
41 | void __iomem *virt_base; | ||
42 | struct sram_dev *sram; | ||
43 | struct resource *res; | ||
44 | unsigned long size; | ||
45 | int ret; | ||
46 | |||
47 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
48 | if (!res) | ||
49 | return -EINVAL; | ||
50 | |||
51 | size = resource_size(res); | ||
52 | |||
53 | virt_base = devm_request_and_ioremap(&pdev->dev, res); | ||
54 | if (!virt_base) | ||
55 | return -EADDRNOTAVAIL; | ||
56 | |||
57 | sram = devm_kzalloc(&pdev->dev, sizeof(*sram), GFP_KERNEL); | ||
58 | if (!sram) | ||
59 | return -ENOMEM; | ||
60 | |||
61 | sram->clk = devm_clk_get(&pdev->dev, NULL); | ||
62 | if (IS_ERR(sram->clk)) | ||
63 | sram->clk = NULL; | ||
64 | else | ||
65 | clk_prepare_enable(sram->clk); | ||
66 | |||
67 | sram->pool = devm_gen_pool_create(&pdev->dev, ilog2(SRAM_GRANULARITY), -1); | ||
68 | if (!sram->pool) | ||
69 | return -ENOMEM; | ||
70 | |||
71 | ret = gen_pool_add_virt(sram->pool, (unsigned long)virt_base, | ||
72 | res->start, size, -1); | ||
73 | if (ret < 0) { | ||
74 | gen_pool_destroy(sram->pool); | ||
75 | return ret; | ||
76 | } | ||
77 | |||
78 | platform_set_drvdata(pdev, sram); | ||
79 | |||
80 | dev_dbg(&pdev->dev, "SRAM pool: %ld KiB @ 0x%p\n", size / 1024, virt_base); | ||
81 | |||
82 | return 0; | ||
83 | } | ||
84 | |||
85 | static int sram_remove(struct platform_device *pdev) | ||
86 | { | ||
87 | struct sram_dev *sram = platform_get_drvdata(pdev); | ||
88 | |||
89 | if (gen_pool_avail(sram->pool) < gen_pool_size(sram->pool)) | ||
90 | dev_dbg(&pdev->dev, "removed while SRAM allocated\n"); | ||
91 | |||
92 | gen_pool_destroy(sram->pool); | ||
93 | |||
94 | if (sram->clk) | ||
95 | clk_disable_unprepare(sram->clk); | ||
96 | |||
97 | return 0; | ||
98 | } | ||
99 | |||
100 | #ifdef CONFIG_OF | ||
101 | static struct of_device_id sram_dt_ids[] = { | ||
102 | { .compatible = "mmio-sram" }, | ||
103 | {} | ||
104 | }; | ||
105 | #endif | ||
106 | |||
107 | static struct platform_driver sram_driver = { | ||
108 | .driver = { | ||
109 | .name = "sram", | ||
110 | .of_match_table = of_match_ptr(sram_dt_ids), | ||
111 | }, | ||
112 | .probe = sram_probe, | ||
113 | .remove = sram_remove, | ||
114 | }; | ||
115 | |||
116 | static int __init sram_init(void) | ||
117 | { | ||
118 | return platform_driver_register(&sram_driver); | ||
119 | } | ||
120 | |||
121 | postcore_initcall(sram_init); | ||
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 08a3cf2a7610..9290bb51a06a 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c | |||
@@ -120,8 +120,8 @@ static void mmc_should_fail_request(struct mmc_host *host, | |||
120 | !should_fail(&host->fail_mmc_request, data->blksz * data->blocks)) | 120 | !should_fail(&host->fail_mmc_request, data->blksz * data->blocks)) |
121 | return; | 121 | return; |
122 | 122 | ||
123 | data->error = data_errors[random32() % ARRAY_SIZE(data_errors)]; | 123 | data->error = data_errors[prandom_u32() % ARRAY_SIZE(data_errors)]; |
124 | data->bytes_xfered = (random32() % (data->bytes_xfered >> 9)) << 9; | 124 | data->bytes_xfered = (prandom_u32() % (data->bytes_xfered >> 9)) << 9; |
125 | } | 125 | } |
126 | 126 | ||
127 | #else /* CONFIG_FAIL_MMC_REQUEST */ | 127 | #else /* CONFIG_FAIL_MMC_REQUEST */ |
diff --git a/drivers/rpmsg/virtio_rpmsg_bus.c b/drivers/rpmsg/virtio_rpmsg_bus.c index a59684b5fc68..7861f1119b7d 100644 --- a/drivers/rpmsg/virtio_rpmsg_bus.c +++ b/drivers/rpmsg/virtio_rpmsg_bus.c | |||
@@ -951,8 +951,10 @@ static int rpmsg_probe(struct virtio_device *vdev) | |||
951 | bufs_va = dma_alloc_coherent(vdev->dev.parent->parent, | 951 | bufs_va = dma_alloc_coherent(vdev->dev.parent->parent, |
952 | RPMSG_TOTAL_BUF_SPACE, | 952 | RPMSG_TOTAL_BUF_SPACE, |
953 | &vrp->bufs_dma, GFP_KERNEL); | 953 | &vrp->bufs_dma, GFP_KERNEL); |
954 | if (!bufs_va) | 954 | if (!bufs_va) { |
955 | err = -ENOMEM; | ||
955 | goto vqs_del; | 956 | goto vqs_del; |
957 | } | ||
956 | 958 | ||
957 | dev_dbg(&vdev->dev, "buffers: va %p, dma 0x%llx\n", bufs_va, | 959 | dev_dbg(&vdev->dev, "buffers: va %p, dma 0x%llx\n", bufs_va, |
958 | (unsigned long long)vrp->bufs_dma); | 960 | (unsigned long long)vrp->bufs_dma); |
diff --git a/drivers/rtc/class.c b/drivers/rtc/class.c index 9b742d3ffb94..66385402d20e 100644 --- a/drivers/rtc/class.c +++ b/drivers/rtc/class.c | |||
@@ -259,6 +259,76 @@ void rtc_device_unregister(struct rtc_device *rtc) | |||
259 | } | 259 | } |
260 | EXPORT_SYMBOL_GPL(rtc_device_unregister); | 260 | EXPORT_SYMBOL_GPL(rtc_device_unregister); |
261 | 261 | ||
262 | static void devm_rtc_device_release(struct device *dev, void *res) | ||
263 | { | ||
264 | struct rtc_device *rtc = *(struct rtc_device **)res; | ||
265 | |||
266 | rtc_device_unregister(rtc); | ||
267 | } | ||
268 | |||
269 | static int devm_rtc_device_match(struct device *dev, void *res, void *data) | ||
270 | { | ||
271 | struct rtc **r = res; | ||
272 | |||
273 | return *r == data; | ||
274 | } | ||
275 | |||
276 | /** | ||
277 | * devm_rtc_device_register - resource managed rtc_device_register() | ||
278 | * @dev: the device to register | ||
279 | * @name: the name of the device | ||
280 | * @ops: the rtc operations structure | ||
281 | * @owner: the module owner | ||
282 | * | ||
283 | * @return a struct rtc on success, or an ERR_PTR on error | ||
284 | * | ||
285 | * Managed rtc_device_register(). The rtc_device returned from this function | ||
286 | * are automatically freed on driver detach. See rtc_device_register() | ||
287 | * for more information. | ||
288 | */ | ||
289 | |||
290 | struct rtc_device *devm_rtc_device_register(struct device *dev, | ||
291 | const char *name, | ||
292 | const struct rtc_class_ops *ops, | ||
293 | struct module *owner) | ||
294 | { | ||
295 | struct rtc_device **ptr, *rtc; | ||
296 | |||
297 | ptr = devres_alloc(devm_rtc_device_release, sizeof(*ptr), GFP_KERNEL); | ||
298 | if (!ptr) | ||
299 | return ERR_PTR(-ENOMEM); | ||
300 | |||
301 | rtc = rtc_device_register(name, dev, ops, owner); | ||
302 | if (!IS_ERR(rtc)) { | ||
303 | *ptr = rtc; | ||
304 | devres_add(dev, ptr); | ||
305 | } else { | ||
306 | devres_free(ptr); | ||
307 | } | ||
308 | |||
309 | return rtc; | ||
310 | } | ||
311 | EXPORT_SYMBOL_GPL(devm_rtc_device_register); | ||
312 | |||
313 | /** | ||
314 | * devm_rtc_device_unregister - resource managed devm_rtc_device_unregister() | ||
315 | * @dev: the device to unregister | ||
316 | * @rtc: the RTC class device to unregister | ||
317 | * | ||
318 | * Deallocated a rtc allocated with devm_rtc_device_register(). Normally this | ||
319 | * function will not need to be called and the resource management code will | ||
320 | * ensure that the resource is freed. | ||
321 | */ | ||
322 | void devm_rtc_device_unregister(struct device *dev, struct rtc_device *rtc) | ||
323 | { | ||
324 | int rc; | ||
325 | |||
326 | rc = devres_release(dev, devm_rtc_device_release, | ||
327 | devm_rtc_device_match, rtc); | ||
328 | WARN_ON(rc); | ||
329 | } | ||
330 | EXPORT_SYMBOL_GPL(devm_rtc_device_unregister); | ||
331 | |||
262 | static int __init rtc_init(void) | 332 | static int __init rtc_init(void) |
263 | { | 333 | { |
264 | rtc_class = class_create(THIS_MODULE, "rtc"); | 334 | rtc_class = class_create(THIS_MODULE, "rtc"); |
diff --git a/drivers/rtc/rtc-88pm80x.c b/drivers/rtc/rtc-88pm80x.c index 63b17ebe90e8..f3742f364eb8 100644 --- a/drivers/rtc/rtc-88pm80x.c +++ b/drivers/rtc/rtc-88pm80x.c | |||
@@ -234,7 +234,7 @@ static const struct rtc_class_ops pm80x_rtc_ops = { | |||
234 | .alarm_irq_enable = pm80x_rtc_alarm_irq_enable, | 234 | .alarm_irq_enable = pm80x_rtc_alarm_irq_enable, |
235 | }; | 235 | }; |
236 | 236 | ||
237 | #ifdef CONFIG_PM | 237 | #ifdef CONFIG_PM_SLEEP |
238 | static int pm80x_rtc_suspend(struct device *dev) | 238 | static int pm80x_rtc_suspend(struct device *dev) |
239 | { | 239 | { |
240 | return pm80x_dev_suspend(dev); | 240 | return pm80x_dev_suspend(dev); |
@@ -312,7 +312,7 @@ static int pm80x_rtc_probe(struct platform_device *pdev) | |||
312 | } | 312 | } |
313 | rtc_tm_to_time(&tm, &ticks); | 313 | rtc_tm_to_time(&tm, &ticks); |
314 | 314 | ||
315 | info->rtc_dev = rtc_device_register("88pm80x-rtc", &pdev->dev, | 315 | info->rtc_dev = devm_rtc_device_register(&pdev->dev, "88pm80x-rtc", |
316 | &pm80x_rtc_ops, THIS_MODULE); | 316 | &pm80x_rtc_ops, THIS_MODULE); |
317 | if (IS_ERR(info->rtc_dev)) { | 317 | if (IS_ERR(info->rtc_dev)) { |
318 | ret = PTR_ERR(info->rtc_dev); | 318 | ret = PTR_ERR(info->rtc_dev); |
@@ -346,7 +346,6 @@ static int pm80x_rtc_remove(struct platform_device *pdev) | |||
346 | { | 346 | { |
347 | struct pm80x_rtc_info *info = platform_get_drvdata(pdev); | 347 | struct pm80x_rtc_info *info = platform_get_drvdata(pdev); |
348 | platform_set_drvdata(pdev, NULL); | 348 | platform_set_drvdata(pdev, NULL); |
349 | rtc_device_unregister(info->rtc_dev); | ||
350 | pm80x_free_irq(info->chip, info->irq, info); | 349 | pm80x_free_irq(info->chip, info->irq, info); |
351 | return 0; | 350 | return 0; |
352 | } | 351 | } |
diff --git a/drivers/rtc/rtc-88pm860x.c b/drivers/rtc/rtc-88pm860x.c index f663746f4603..0f2b91bfee37 100644 --- a/drivers/rtc/rtc-88pm860x.c +++ b/drivers/rtc/rtc-88pm860x.c | |||
@@ -318,14 +318,14 @@ static int pm860x_rtc_probe(struct platform_device *pdev) | |||
318 | 318 | ||
319 | pdata = pdev->dev.platform_data; | 319 | pdata = pdev->dev.platform_data; |
320 | 320 | ||
321 | info = kzalloc(sizeof(struct pm860x_rtc_info), GFP_KERNEL); | 321 | info = devm_kzalloc(&pdev->dev, sizeof(struct pm860x_rtc_info), |
322 | GFP_KERNEL); | ||
322 | if (!info) | 323 | if (!info) |
323 | return -ENOMEM; | 324 | return -ENOMEM; |
324 | info->irq = platform_get_irq(pdev, 0); | 325 | info->irq = platform_get_irq(pdev, 0); |
325 | if (info->irq < 0) { | 326 | if (info->irq < 0) { |
326 | dev_err(&pdev->dev, "No IRQ resource!\n"); | 327 | dev_err(&pdev->dev, "No IRQ resource!\n"); |
327 | ret = -EINVAL; | 328 | return info->irq; |
328 | goto out; | ||
329 | } | 329 | } |
330 | 330 | ||
331 | info->chip = chip; | 331 | info->chip = chip; |
@@ -333,12 +333,13 @@ static int pm860x_rtc_probe(struct platform_device *pdev) | |||
333 | info->dev = &pdev->dev; | 333 | info->dev = &pdev->dev; |
334 | dev_set_drvdata(&pdev->dev, info); | 334 | dev_set_drvdata(&pdev->dev, info); |
335 | 335 | ||
336 | ret = request_threaded_irq(info->irq, NULL, rtc_update_handler, | 336 | ret = devm_request_threaded_irq(&pdev->dev, info->irq, NULL, |
337 | IRQF_ONESHOT, "rtc", info); | 337 | rtc_update_handler, IRQF_ONESHOT, "rtc", |
338 | info); | ||
338 | if (ret < 0) { | 339 | if (ret < 0) { |
339 | dev_err(chip->dev, "Failed to request IRQ: #%d: %d\n", | 340 | dev_err(chip->dev, "Failed to request IRQ: #%d: %d\n", |
340 | info->irq, ret); | 341 | info->irq, ret); |
341 | goto out; | 342 | return ret; |
342 | } | 343 | } |
343 | 344 | ||
344 | /* set addresses of 32-bit base value for RTC time */ | 345 | /* set addresses of 32-bit base value for RTC time */ |
@@ -350,7 +351,7 @@ static int pm860x_rtc_probe(struct platform_device *pdev) | |||
350 | ret = pm860x_rtc_read_time(&pdev->dev, &tm); | 351 | ret = pm860x_rtc_read_time(&pdev->dev, &tm); |
351 | if (ret < 0) { | 352 | if (ret < 0) { |
352 | dev_err(&pdev->dev, "Failed to read initial time.\n"); | 353 | dev_err(&pdev->dev, "Failed to read initial time.\n"); |
353 | goto out_rtc; | 354 | return ret; |
354 | } | 355 | } |
355 | if ((tm.tm_year < 70) || (tm.tm_year > 138)) { | 356 | if ((tm.tm_year < 70) || (tm.tm_year > 138)) { |
356 | tm.tm_year = 70; | 357 | tm.tm_year = 70; |
@@ -362,7 +363,7 @@ static int pm860x_rtc_probe(struct platform_device *pdev) | |||
362 | ret = pm860x_rtc_set_time(&pdev->dev, &tm); | 363 | ret = pm860x_rtc_set_time(&pdev->dev, &tm); |
363 | if (ret < 0) { | 364 | if (ret < 0) { |
364 | dev_err(&pdev->dev, "Failed to set initial time.\n"); | 365 | dev_err(&pdev->dev, "Failed to set initial time.\n"); |
365 | goto out_rtc; | 366 | return ret; |
366 | } | 367 | } |
367 | } | 368 | } |
368 | rtc_tm_to_time(&tm, &ticks); | 369 | rtc_tm_to_time(&tm, &ticks); |
@@ -373,12 +374,12 @@ static int pm860x_rtc_probe(struct platform_device *pdev) | |||
373 | } | 374 | } |
374 | } | 375 | } |
375 | 376 | ||
376 | info->rtc_dev = rtc_device_register("88pm860x-rtc", &pdev->dev, | 377 | info->rtc_dev = devm_rtc_device_register(&pdev->dev, "88pm860x-rtc", |
377 | &pm860x_rtc_ops, THIS_MODULE); | 378 | &pm860x_rtc_ops, THIS_MODULE); |
378 | ret = PTR_ERR(info->rtc_dev); | 379 | ret = PTR_ERR(info->rtc_dev); |
379 | if (IS_ERR(info->rtc_dev)) { | 380 | if (IS_ERR(info->rtc_dev)) { |
380 | dev_err(&pdev->dev, "Failed to register RTC device: %d\n", ret); | 381 | dev_err(&pdev->dev, "Failed to register RTC device: %d\n", ret); |
381 | goto out_rtc; | 382 | return ret; |
382 | } | 383 | } |
383 | 384 | ||
384 | /* | 385 | /* |
@@ -405,11 +406,6 @@ static int pm860x_rtc_probe(struct platform_device *pdev) | |||
405 | device_init_wakeup(&pdev->dev, 1); | 406 | device_init_wakeup(&pdev->dev, 1); |
406 | 407 | ||
407 | return 0; | 408 | return 0; |
408 | out_rtc: | ||
409 | free_irq(info->irq, info); | ||
410 | out: | ||
411 | kfree(info); | ||
412 | return ret; | ||
413 | } | 409 | } |
414 | 410 | ||
415 | static int pm860x_rtc_remove(struct platform_device *pdev) | 411 | static int pm860x_rtc_remove(struct platform_device *pdev) |
@@ -423,9 +419,6 @@ static int pm860x_rtc_remove(struct platform_device *pdev) | |||
423 | #endif /* VRTC_CALIBRATION */ | 419 | #endif /* VRTC_CALIBRATION */ |
424 | 420 | ||
425 | platform_set_drvdata(pdev, NULL); | 421 | platform_set_drvdata(pdev, NULL); |
426 | rtc_device_unregister(info->rtc_dev); | ||
427 | free_irq(info->irq, info); | ||
428 | kfree(info); | ||
429 | return 0; | 422 | return 0; |
430 | } | 423 | } |
431 | 424 | ||
diff --git a/drivers/rtc/rtc-ab3100.c b/drivers/rtc/rtc-ab3100.c index 261a07e0fb24..47a4f2c4d30e 100644 --- a/drivers/rtc/rtc-ab3100.c +++ b/drivers/rtc/rtc-ab3100.c | |||
@@ -229,8 +229,8 @@ static int __init ab3100_rtc_probe(struct platform_device *pdev) | |||
229 | /* Ignore any error on this write */ | 229 | /* Ignore any error on this write */ |
230 | } | 230 | } |
231 | 231 | ||
232 | rtc = rtc_device_register("ab3100-rtc", &pdev->dev, &ab3100_rtc_ops, | 232 | rtc = devm_rtc_device_register(&pdev->dev, "ab3100-rtc", |
233 | THIS_MODULE); | 233 | &ab3100_rtc_ops, THIS_MODULE); |
234 | if (IS_ERR(rtc)) { | 234 | if (IS_ERR(rtc)) { |
235 | err = PTR_ERR(rtc); | 235 | err = PTR_ERR(rtc); |
236 | return err; | 236 | return err; |
@@ -242,9 +242,6 @@ static int __init ab3100_rtc_probe(struct platform_device *pdev) | |||
242 | 242 | ||
243 | static int __exit ab3100_rtc_remove(struct platform_device *pdev) | 243 | static int __exit ab3100_rtc_remove(struct platform_device *pdev) |
244 | { | 244 | { |
245 | struct rtc_device *rtc = platform_get_drvdata(pdev); | ||
246 | |||
247 | rtc_device_unregister(rtc); | ||
248 | platform_set_drvdata(pdev, NULL); | 245 | platform_set_drvdata(pdev, NULL); |
249 | return 0; | 246 | return 0; |
250 | } | 247 | } |
@@ -257,19 +254,7 @@ static struct platform_driver ab3100_rtc_driver = { | |||
257 | .remove = __exit_p(ab3100_rtc_remove), | 254 | .remove = __exit_p(ab3100_rtc_remove), |
258 | }; | 255 | }; |
259 | 256 | ||
260 | static int __init ab3100_rtc_init(void) | 257 | module_platform_driver_probe(ab3100_rtc_driver, ab3100_rtc_probe); |
261 | { | ||
262 | return platform_driver_probe(&ab3100_rtc_driver, | ||
263 | ab3100_rtc_probe); | ||
264 | } | ||
265 | |||
266 | static void __exit ab3100_rtc_exit(void) | ||
267 | { | ||
268 | platform_driver_unregister(&ab3100_rtc_driver); | ||
269 | } | ||
270 | |||
271 | module_init(ab3100_rtc_init); | ||
272 | module_exit(ab3100_rtc_exit); | ||
273 | 258 | ||
274 | MODULE_AUTHOR("Linus Walleij <linus.walleij@stericsson.com>"); | 259 | MODULE_AUTHOR("Linus Walleij <linus.walleij@stericsson.com>"); |
275 | MODULE_DESCRIPTION("AB3100 RTC Driver"); | 260 | MODULE_DESCRIPTION("AB3100 RTC Driver"); |
diff --git a/drivers/rtc/rtc-ab8500.c b/drivers/rtc/rtc-ab8500.c index 57cde2b061e6..63cfa314a39f 100644 --- a/drivers/rtc/rtc-ab8500.c +++ b/drivers/rtc/rtc-ab8500.c | |||
@@ -422,20 +422,19 @@ static int ab8500_rtc_probe(struct platform_device *pdev) | |||
422 | 422 | ||
423 | device_init_wakeup(&pdev->dev, true); | 423 | device_init_wakeup(&pdev->dev, true); |
424 | 424 | ||
425 | rtc = rtc_device_register("ab8500-rtc", &pdev->dev, &ab8500_rtc_ops, | 425 | rtc = devm_rtc_device_register(&pdev->dev, "ab8500-rtc", |
426 | THIS_MODULE); | 426 | &ab8500_rtc_ops, THIS_MODULE); |
427 | if (IS_ERR(rtc)) { | 427 | if (IS_ERR(rtc)) { |
428 | dev_err(&pdev->dev, "Registration failed\n"); | 428 | dev_err(&pdev->dev, "Registration failed\n"); |
429 | err = PTR_ERR(rtc); | 429 | err = PTR_ERR(rtc); |
430 | return err; | 430 | return err; |
431 | } | 431 | } |
432 | 432 | ||
433 | err = request_threaded_irq(irq, NULL, rtc_alarm_handler, | 433 | err = devm_request_threaded_irq(&pdev->dev, irq, NULL, |
434 | IRQF_NO_SUSPEND | IRQF_ONESHOT, "ab8500-rtc", rtc); | 434 | rtc_alarm_handler, IRQF_NO_SUSPEND | IRQF_ONESHOT, |
435 | if (err < 0) { | 435 | "ab8500-rtc", rtc); |
436 | rtc_device_unregister(rtc); | 436 | if (err < 0) |
437 | return err; | 437 | return err; |
438 | } | ||
439 | 438 | ||
440 | platform_set_drvdata(pdev, rtc); | 439 | platform_set_drvdata(pdev, rtc); |
441 | 440 | ||
@@ -450,13 +449,8 @@ static int ab8500_rtc_probe(struct platform_device *pdev) | |||
450 | 449 | ||
451 | static int ab8500_rtc_remove(struct platform_device *pdev) | 450 | static int ab8500_rtc_remove(struct platform_device *pdev) |
452 | { | 451 | { |
453 | struct rtc_device *rtc = platform_get_drvdata(pdev); | ||
454 | int irq = platform_get_irq_byname(pdev, "ALARM"); | ||
455 | |||
456 | ab8500_sysfs_rtc_unregister(&pdev->dev); | 452 | ab8500_sysfs_rtc_unregister(&pdev->dev); |
457 | 453 | ||
458 | free_irq(irq, rtc); | ||
459 | rtc_device_unregister(rtc); | ||
460 | platform_set_drvdata(pdev, NULL); | 454 | platform_set_drvdata(pdev, NULL); |
461 | 455 | ||
462 | return 0; | 456 | return 0; |
diff --git a/drivers/rtc/rtc-at32ap700x.c b/drivers/rtc/rtc-at32ap700x.c index 8dd08305aae1..f47fbb5eee8b 100644 --- a/drivers/rtc/rtc-at32ap700x.c +++ b/drivers/rtc/rtc-at32ap700x.c | |||
@@ -202,7 +202,8 @@ static int __init at32_rtc_probe(struct platform_device *pdev) | |||
202 | int irq; | 202 | int irq; |
203 | int ret; | 203 | int ret; |
204 | 204 | ||
205 | rtc = kzalloc(sizeof(struct rtc_at32ap700x), GFP_KERNEL); | 205 | rtc = devm_kzalloc(&pdev->dev, sizeof(struct rtc_at32ap700x), |
206 | GFP_KERNEL); | ||
206 | if (!rtc) { | 207 | if (!rtc) { |
207 | dev_dbg(&pdev->dev, "out of memory\n"); | 208 | dev_dbg(&pdev->dev, "out of memory\n"); |
208 | return -ENOMEM; | 209 | return -ENOMEM; |
@@ -223,7 +224,7 @@ static int __init at32_rtc_probe(struct platform_device *pdev) | |||
223 | } | 224 | } |
224 | 225 | ||
225 | rtc->irq = irq; | 226 | rtc->irq = irq; |
226 | rtc->regs = ioremap(regs->start, resource_size(regs)); | 227 | rtc->regs = devm_ioremap(&pdev->dev, regs->start, resource_size(regs)); |
227 | if (!rtc->regs) { | 228 | if (!rtc->regs) { |
228 | ret = -ENOMEM; | 229 | ret = -ENOMEM; |
229 | dev_dbg(&pdev->dev, "could not map I/O memory\n"); | 230 | dev_dbg(&pdev->dev, "could not map I/O memory\n"); |
@@ -244,20 +245,21 @@ static int __init at32_rtc_probe(struct platform_device *pdev) | |||
244 | | RTC_BIT(CTRL_EN)); | 245 | | RTC_BIT(CTRL_EN)); |
245 | } | 246 | } |
246 | 247 | ||
247 | ret = request_irq(irq, at32_rtc_interrupt, IRQF_SHARED, "rtc", rtc); | 248 | ret = devm_request_irq(&pdev->dev, irq, at32_rtc_interrupt, IRQF_SHARED, |
249 | "rtc", rtc); | ||
248 | if (ret) { | 250 | if (ret) { |
249 | dev_dbg(&pdev->dev, "could not request irq %d\n", irq); | 251 | dev_dbg(&pdev->dev, "could not request irq %d\n", irq); |
250 | goto out_iounmap; | 252 | goto out; |
251 | } | 253 | } |
252 | 254 | ||
253 | platform_set_drvdata(pdev, rtc); | 255 | platform_set_drvdata(pdev, rtc); |
254 | 256 | ||
255 | rtc->rtc = rtc_device_register(pdev->name, &pdev->dev, | 257 | rtc->rtc = devm_rtc_device_register(&pdev->dev, pdev->name, |
256 | &at32_rtc_ops, THIS_MODULE); | 258 | &at32_rtc_ops, THIS_MODULE); |
257 | if (IS_ERR(rtc->rtc)) { | 259 | if (IS_ERR(rtc->rtc)) { |
258 | dev_dbg(&pdev->dev, "could not register rtc device\n"); | 260 | dev_dbg(&pdev->dev, "could not register rtc device\n"); |
259 | ret = PTR_ERR(rtc->rtc); | 261 | ret = PTR_ERR(rtc->rtc); |
260 | goto out_free_irq; | 262 | goto out; |
261 | } | 263 | } |
262 | 264 | ||
263 | device_init_wakeup(&pdev->dev, 1); | 265 | device_init_wakeup(&pdev->dev, 1); |
@@ -267,26 +269,15 @@ static int __init at32_rtc_probe(struct platform_device *pdev) | |||
267 | 269 | ||
268 | return 0; | 270 | return 0; |
269 | 271 | ||
270 | out_free_irq: | ||
271 | platform_set_drvdata(pdev, NULL); | ||
272 | free_irq(irq, rtc); | ||
273 | out_iounmap: | ||
274 | iounmap(rtc->regs); | ||
275 | out: | 272 | out: |
276 | kfree(rtc); | 273 | platform_set_drvdata(pdev, NULL); |
277 | return ret; | 274 | return ret; |
278 | } | 275 | } |
279 | 276 | ||
280 | static int __exit at32_rtc_remove(struct platform_device *pdev) | 277 | static int __exit at32_rtc_remove(struct platform_device *pdev) |
281 | { | 278 | { |
282 | struct rtc_at32ap700x *rtc = platform_get_drvdata(pdev); | ||
283 | |||
284 | device_init_wakeup(&pdev->dev, 0); | 279 | device_init_wakeup(&pdev->dev, 0); |
285 | 280 | ||
286 | free_irq(rtc->irq, rtc); | ||
287 | iounmap(rtc->regs); | ||
288 | rtc_device_unregister(rtc->rtc); | ||
289 | kfree(rtc); | ||
290 | platform_set_drvdata(pdev, NULL); | 281 | platform_set_drvdata(pdev, NULL); |
291 | 282 | ||
292 | return 0; | 283 | return 0; |
@@ -302,17 +293,7 @@ static struct platform_driver at32_rtc_driver = { | |||
302 | }, | 293 | }, |
303 | }; | 294 | }; |
304 | 295 | ||
305 | static int __init at32_rtc_init(void) | 296 | module_platform_driver_probe(at32_rtc_driver, at32_rtc_probe); |
306 | { | ||
307 | return platform_driver_probe(&at32_rtc_driver, at32_rtc_probe); | ||
308 | } | ||
309 | module_init(at32_rtc_init); | ||
310 | |||
311 | static void __exit at32_rtc_exit(void) | ||
312 | { | ||
313 | platform_driver_unregister(&at32_rtc_driver); | ||
314 | } | ||
315 | module_exit(at32_rtc_exit); | ||
316 | 297 | ||
317 | MODULE_AUTHOR("Hans-Christian Egtvedt <hcegtvedt@atmel.com>"); | 298 | MODULE_AUTHOR("Hans-Christian Egtvedt <hcegtvedt@atmel.com>"); |
318 | MODULE_DESCRIPTION("Real time clock for AVR32 AT32AP700x"); | 299 | MODULE_DESCRIPTION("Real time clock for AVR32 AT32AP700x"); |
diff --git a/drivers/rtc/rtc-at91rm9200.c b/drivers/rtc/rtc-at91rm9200.c index 434ebc3a99dc..0eab77b22340 100644 --- a/drivers/rtc/rtc-at91rm9200.c +++ b/drivers/rtc/rtc-at91rm9200.c | |||
@@ -28,6 +28,8 @@ | |||
28 | #include <linux/ioctl.h> | 28 | #include <linux/ioctl.h> |
29 | #include <linux/completion.h> | 29 | #include <linux/completion.h> |
30 | #include <linux/io.h> | 30 | #include <linux/io.h> |
31 | #include <linux/of.h> | ||
32 | #include <linux/of_device.h> | ||
31 | 33 | ||
32 | #include <asm/uaccess.h> | 34 | #include <asm/uaccess.h> |
33 | 35 | ||
@@ -297,7 +299,7 @@ static int __init at91_rtc_probe(struct platform_device *pdev) | |||
297 | "at91_rtc", pdev); | 299 | "at91_rtc", pdev); |
298 | if (ret) { | 300 | if (ret) { |
299 | dev_err(&pdev->dev, "IRQ %d already in use.\n", irq); | 301 | dev_err(&pdev->dev, "IRQ %d already in use.\n", irq); |
300 | return ret; | 302 | goto err_unmap; |
301 | } | 303 | } |
302 | 304 | ||
303 | /* cpu init code should really have flagged this device as | 305 | /* cpu init code should really have flagged this device as |
@@ -309,13 +311,20 @@ static int __init at91_rtc_probe(struct platform_device *pdev) | |||
309 | rtc = rtc_device_register(pdev->name, &pdev->dev, | 311 | rtc = rtc_device_register(pdev->name, &pdev->dev, |
310 | &at91_rtc_ops, THIS_MODULE); | 312 | &at91_rtc_ops, THIS_MODULE); |
311 | if (IS_ERR(rtc)) { | 313 | if (IS_ERR(rtc)) { |
312 | free_irq(irq, pdev); | 314 | ret = PTR_ERR(rtc); |
313 | return PTR_ERR(rtc); | 315 | goto err_free_irq; |
314 | } | 316 | } |
315 | platform_set_drvdata(pdev, rtc); | 317 | platform_set_drvdata(pdev, rtc); |
316 | 318 | ||
317 | dev_info(&pdev->dev, "AT91 Real Time Clock driver.\n"); | 319 | dev_info(&pdev->dev, "AT91 Real Time Clock driver.\n"); |
318 | return 0; | 320 | return 0; |
321 | |||
322 | err_free_irq: | ||
323 | free_irq(irq, pdev); | ||
324 | err_unmap: | ||
325 | iounmap(at91_rtc_regs); | ||
326 | |||
327 | return ret; | ||
319 | } | 328 | } |
320 | 329 | ||
321 | /* | 330 | /* |
@@ -332,12 +341,13 @@ static int __exit at91_rtc_remove(struct platform_device *pdev) | |||
332 | free_irq(irq, pdev); | 341 | free_irq(irq, pdev); |
333 | 342 | ||
334 | rtc_device_unregister(rtc); | 343 | rtc_device_unregister(rtc); |
344 | iounmap(at91_rtc_regs); | ||
335 | platform_set_drvdata(pdev, NULL); | 345 | platform_set_drvdata(pdev, NULL); |
336 | 346 | ||
337 | return 0; | 347 | return 0; |
338 | } | 348 | } |
339 | 349 | ||
340 | #ifdef CONFIG_PM | 350 | #ifdef CONFIG_PM_SLEEP |
341 | 351 | ||
342 | /* AT91RM9200 RTC Power management control */ | 352 | /* AT91RM9200 RTC Power management control */ |
343 | 353 | ||
@@ -369,39 +379,27 @@ static int at91_rtc_resume(struct device *dev) | |||
369 | } | 379 | } |
370 | return 0; | 380 | return 0; |
371 | } | 381 | } |
382 | #endif | ||
372 | 383 | ||
373 | static const struct dev_pm_ops at91_rtc_pm = { | 384 | static SIMPLE_DEV_PM_OPS(at91_rtc_pm_ops, at91_rtc_suspend, at91_rtc_resume); |
374 | .suspend = at91_rtc_suspend, | ||
375 | .resume = at91_rtc_resume, | ||
376 | }; | ||
377 | |||
378 | #define at91_rtc_pm_ptr &at91_rtc_pm | ||
379 | 385 | ||
380 | #else | 386 | static const struct of_device_id at91_rtc_dt_ids[] = { |
381 | #define at91_rtc_pm_ptr NULL | 387 | { .compatible = "atmel,at91rm9200-rtc" }, |
382 | #endif | 388 | { /* sentinel */ } |
389 | }; | ||
390 | MODULE_DEVICE_TABLE(of, at91_rtc_dt_ids); | ||
383 | 391 | ||
384 | static struct platform_driver at91_rtc_driver = { | 392 | static struct platform_driver at91_rtc_driver = { |
385 | .remove = __exit_p(at91_rtc_remove), | 393 | .remove = __exit_p(at91_rtc_remove), |
386 | .driver = { | 394 | .driver = { |
387 | .name = "at91_rtc", | 395 | .name = "at91_rtc", |
388 | .owner = THIS_MODULE, | 396 | .owner = THIS_MODULE, |
389 | .pm = at91_rtc_pm_ptr, | 397 | .pm = &at91_rtc_pm_ops, |
398 | .of_match_table = of_match_ptr(at91_rtc_dt_ids), | ||
390 | }, | 399 | }, |
391 | }; | 400 | }; |
392 | 401 | ||
393 | static int __init at91_rtc_init(void) | 402 | module_platform_driver_probe(at91_rtc_driver, at91_rtc_probe); |
394 | { | ||
395 | return platform_driver_probe(&at91_rtc_driver, at91_rtc_probe); | ||
396 | } | ||
397 | |||
398 | static void __exit at91_rtc_exit(void) | ||
399 | { | ||
400 | platform_driver_unregister(&at91_rtc_driver); | ||
401 | } | ||
402 | |||
403 | module_init(at91_rtc_init); | ||
404 | module_exit(at91_rtc_exit); | ||
405 | 403 | ||
406 | MODULE_AUTHOR("Rick Bronson"); | 404 | MODULE_AUTHOR("Rick Bronson"); |
407 | MODULE_DESCRIPTION("RTC driver for Atmel AT91RM9200"); | 405 | MODULE_DESCRIPTION("RTC driver for Atmel AT91RM9200"); |
diff --git a/drivers/rtc/rtc-at91sam9.c b/drivers/rtc/rtc-at91sam9.c index 39cfd2ee0042..b60a34cb145a 100644 --- a/drivers/rtc/rtc-at91sam9.c +++ b/drivers/rtc/rtc-at91sam9.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <linux/ioctl.h> | 20 | #include <linux/ioctl.h> |
21 | #include <linux/slab.h> | 21 | #include <linux/slab.h> |
22 | #include <linux/platform_data/atmel.h> | 22 | #include <linux/platform_data/atmel.h> |
23 | #include <linux/io.h> | ||
23 | 24 | ||
24 | #include <mach/at91_rtt.h> | 25 | #include <mach/at91_rtt.h> |
25 | #include <mach/cpu.h> | 26 | #include <mach/cpu.h> |
@@ -309,7 +310,7 @@ static int at91_rtc_probe(struct platform_device *pdev) | |||
309 | return irq; | 310 | return irq; |
310 | } | 311 | } |
311 | 312 | ||
312 | rtc = kzalloc(sizeof *rtc, GFP_KERNEL); | 313 | rtc = devm_kzalloc(&pdev->dev, sizeof(*rtc), GFP_KERNEL); |
313 | if (!rtc) | 314 | if (!rtc) |
314 | return -ENOMEM; | 315 | return -ENOMEM; |
315 | 316 | ||
@@ -320,18 +321,19 @@ static int at91_rtc_probe(struct platform_device *pdev) | |||
320 | device_init_wakeup(&pdev->dev, 1); | 321 | device_init_wakeup(&pdev->dev, 1); |
321 | 322 | ||
322 | platform_set_drvdata(pdev, rtc); | 323 | platform_set_drvdata(pdev, rtc); |
323 | rtc->rtt = ioremap(r->start, resource_size(r)); | 324 | rtc->rtt = devm_ioremap(&pdev->dev, r->start, resource_size(r)); |
324 | if (!rtc->rtt) { | 325 | if (!rtc->rtt) { |
325 | dev_err(&pdev->dev, "failed to map registers, aborting.\n"); | 326 | dev_err(&pdev->dev, "failed to map registers, aborting.\n"); |
326 | ret = -ENOMEM; | 327 | ret = -ENOMEM; |
327 | goto fail; | 328 | goto fail; |
328 | } | 329 | } |
329 | 330 | ||
330 | rtc->gpbr = ioremap(r_gpbr->start, resource_size(r_gpbr)); | 331 | rtc->gpbr = devm_ioremap(&pdev->dev, r_gpbr->start, |
332 | resource_size(r_gpbr)); | ||
331 | if (!rtc->gpbr) { | 333 | if (!rtc->gpbr) { |
332 | dev_err(&pdev->dev, "failed to map gpbr registers, aborting.\n"); | 334 | dev_err(&pdev->dev, "failed to map gpbr registers, aborting.\n"); |
333 | ret = -ENOMEM; | 335 | ret = -ENOMEM; |
334 | goto fail_gpbr; | 336 | goto fail; |
335 | } | 337 | } |
336 | 338 | ||
337 | mr = rtt_readl(rtc, MR); | 339 | mr = rtt_readl(rtc, MR); |
@@ -346,20 +348,19 @@ static int at91_rtc_probe(struct platform_device *pdev) | |||
346 | mr &= ~(AT91_RTT_ALMIEN | AT91_RTT_RTTINCIEN); | 348 | mr &= ~(AT91_RTT_ALMIEN | AT91_RTT_RTTINCIEN); |
347 | rtt_writel(rtc, MR, mr); | 349 | rtt_writel(rtc, MR, mr); |
348 | 350 | ||
349 | rtc->rtcdev = rtc_device_register(pdev->name, &pdev->dev, | 351 | rtc->rtcdev = devm_rtc_device_register(&pdev->dev, pdev->name, |
350 | &at91_rtc_ops, THIS_MODULE); | 352 | &at91_rtc_ops, THIS_MODULE); |
351 | if (IS_ERR(rtc->rtcdev)) { | 353 | if (IS_ERR(rtc->rtcdev)) { |
352 | ret = PTR_ERR(rtc->rtcdev); | 354 | ret = PTR_ERR(rtc->rtcdev); |
353 | goto fail_register; | 355 | goto fail; |
354 | } | 356 | } |
355 | 357 | ||
356 | /* register irq handler after we know what name we'll use */ | 358 | /* register irq handler after we know what name we'll use */ |
357 | ret = request_irq(rtc->irq, at91_rtc_interrupt, IRQF_SHARED, | 359 | ret = devm_request_irq(&pdev->dev, rtc->irq, at91_rtc_interrupt, |
358 | dev_name(&rtc->rtcdev->dev), rtc); | 360 | IRQF_SHARED, dev_name(&rtc->rtcdev->dev), rtc); |
359 | if (ret) { | 361 | if (ret) { |
360 | dev_dbg(&pdev->dev, "can't share IRQ %d?\n", rtc->irq); | 362 | dev_dbg(&pdev->dev, "can't share IRQ %d?\n", rtc->irq); |
361 | rtc_device_unregister(rtc->rtcdev); | 363 | goto fail; |
362 | goto fail_register; | ||
363 | } | 364 | } |
364 | 365 | ||
365 | /* NOTE: sam9260 rev A silicon has a ROM bug which resets the | 366 | /* NOTE: sam9260 rev A silicon has a ROM bug which resets the |
@@ -374,13 +375,8 @@ static int at91_rtc_probe(struct platform_device *pdev) | |||
374 | 375 | ||
375 | return 0; | 376 | return 0; |
376 | 377 | ||
377 | fail_register: | ||
378 | iounmap(rtc->gpbr); | ||
379 | fail_gpbr: | ||
380 | iounmap(rtc->rtt); | ||
381 | fail: | 378 | fail: |
382 | platform_set_drvdata(pdev, NULL); | 379 | platform_set_drvdata(pdev, NULL); |
383 | kfree(rtc); | ||
384 | return ret; | 380 | return ret; |
385 | } | 381 | } |
386 | 382 | ||
@@ -394,14 +390,8 @@ static int at91_rtc_remove(struct platform_device *pdev) | |||
394 | 390 | ||
395 | /* disable all interrupts */ | 391 | /* disable all interrupts */ |
396 | rtt_writel(rtc, MR, mr & ~(AT91_RTT_ALMIEN | AT91_RTT_RTTINCIEN)); | 392 | rtt_writel(rtc, MR, mr & ~(AT91_RTT_ALMIEN | AT91_RTT_RTTINCIEN)); |
397 | free_irq(rtc->irq, rtc); | ||
398 | |||
399 | rtc_device_unregister(rtc->rtcdev); | ||
400 | 393 | ||
401 | iounmap(rtc->gpbr); | ||
402 | iounmap(rtc->rtt); | ||
403 | platform_set_drvdata(pdev, NULL); | 394 | platform_set_drvdata(pdev, NULL); |
404 | kfree(rtc); | ||
405 | return 0; | 395 | return 0; |
406 | } | 396 | } |
407 | 397 | ||
@@ -414,14 +404,13 @@ static void at91_rtc_shutdown(struct platform_device *pdev) | |||
414 | rtt_writel(rtc, MR, mr & ~rtc->imr); | 404 | rtt_writel(rtc, MR, mr & ~rtc->imr); |
415 | } | 405 | } |
416 | 406 | ||
417 | #ifdef CONFIG_PM | 407 | #ifdef CONFIG_PM_SLEEP |
418 | 408 | ||
419 | /* AT91SAM9 RTC Power management control */ | 409 | /* AT91SAM9 RTC Power management control */ |
420 | 410 | ||
421 | static int at91_rtc_suspend(struct platform_device *pdev, | 411 | static int at91_rtc_suspend(struct device *dev) |
422 | pm_message_t state) | ||
423 | { | 412 | { |
424 | struct sam9_rtc *rtc = platform_get_drvdata(pdev); | 413 | struct sam9_rtc *rtc = dev_get_drvdata(dev); |
425 | u32 mr = rtt_readl(rtc, MR); | 414 | u32 mr = rtt_readl(rtc, MR); |
426 | 415 | ||
427 | /* | 416 | /* |
@@ -430,7 +419,7 @@ static int at91_rtc_suspend(struct platform_device *pdev, | |||
430 | */ | 419 | */ |
431 | rtc->imr = mr & (AT91_RTT_ALMIEN | AT91_RTT_RTTINCIEN); | 420 | rtc->imr = mr & (AT91_RTT_ALMIEN | AT91_RTT_RTTINCIEN); |
432 | if (rtc->imr) { | 421 | if (rtc->imr) { |
433 | if (device_may_wakeup(&pdev->dev) && (mr & AT91_RTT_ALMIEN)) { | 422 | if (device_may_wakeup(dev) && (mr & AT91_RTT_ALMIEN)) { |
434 | enable_irq_wake(rtc->irq); | 423 | enable_irq_wake(rtc->irq); |
435 | /* don't let RTTINC cause wakeups */ | 424 | /* don't let RTTINC cause wakeups */ |
436 | if (mr & AT91_RTT_RTTINCIEN) | 425 | if (mr & AT91_RTT_RTTINCIEN) |
@@ -442,13 +431,13 @@ static int at91_rtc_suspend(struct platform_device *pdev, | |||
442 | return 0; | 431 | return 0; |
443 | } | 432 | } |
444 | 433 | ||
445 | static int at91_rtc_resume(struct platform_device *pdev) | 434 | static int at91_rtc_resume(struct device *dev) |
446 | { | 435 | { |
447 | struct sam9_rtc *rtc = platform_get_drvdata(pdev); | 436 | struct sam9_rtc *rtc = dev_get_drvdata(dev); |
448 | u32 mr; | 437 | u32 mr; |
449 | 438 | ||
450 | if (rtc->imr) { | 439 | if (rtc->imr) { |
451 | if (device_may_wakeup(&pdev->dev)) | 440 | if (device_may_wakeup(dev)) |
452 | disable_irq_wake(rtc->irq); | 441 | disable_irq_wake(rtc->irq); |
453 | mr = rtt_readl(rtc, MR); | 442 | mr = rtt_readl(rtc, MR); |
454 | rtt_writel(rtc, MR, mr | rtc->imr); | 443 | rtt_writel(rtc, MR, mr | rtc->imr); |
@@ -456,20 +445,18 @@ static int at91_rtc_resume(struct platform_device *pdev) | |||
456 | 445 | ||
457 | return 0; | 446 | return 0; |
458 | } | 447 | } |
459 | #else | ||
460 | #define at91_rtc_suspend NULL | ||
461 | #define at91_rtc_resume NULL | ||
462 | #endif | 448 | #endif |
463 | 449 | ||
450 | static SIMPLE_DEV_PM_OPS(at91_rtc_pm_ops, at91_rtc_suspend, at91_rtc_resume); | ||
451 | |||
464 | static struct platform_driver at91_rtc_driver = { | 452 | static struct platform_driver at91_rtc_driver = { |
465 | .probe = at91_rtc_probe, | 453 | .probe = at91_rtc_probe, |
466 | .remove = at91_rtc_remove, | 454 | .remove = at91_rtc_remove, |
467 | .shutdown = at91_rtc_shutdown, | 455 | .shutdown = at91_rtc_shutdown, |
468 | .suspend = at91_rtc_suspend, | ||
469 | .resume = at91_rtc_resume, | ||
470 | .driver = { | 456 | .driver = { |
471 | .name = "rtc-at91sam9", | 457 | .name = "rtc-at91sam9", |
472 | .owner = THIS_MODULE, | 458 | .owner = THIS_MODULE, |
459 | .pm = &at91_rtc_pm_ops, | ||
473 | }, | 460 | }, |
474 | }; | 461 | }; |
475 | 462 | ||
diff --git a/drivers/rtc/rtc-au1xxx.c b/drivers/rtc/rtc-au1xxx.c index b309da4ec745..7995abc391fc 100644 --- a/drivers/rtc/rtc-au1xxx.c +++ b/drivers/rtc/rtc-au1xxx.c | |||
@@ -101,7 +101,7 @@ static int au1xtoy_rtc_probe(struct platform_device *pdev) | |||
101 | while (au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_C0S) | 101 | while (au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_C0S) |
102 | msleep(1); | 102 | msleep(1); |
103 | 103 | ||
104 | rtcdev = rtc_device_register("rtc-au1xxx", &pdev->dev, | 104 | rtcdev = devm_rtc_device_register(&pdev->dev, "rtc-au1xxx", |
105 | &au1xtoy_rtc_ops, THIS_MODULE); | 105 | &au1xtoy_rtc_ops, THIS_MODULE); |
106 | if (IS_ERR(rtcdev)) { | 106 | if (IS_ERR(rtcdev)) { |
107 | ret = PTR_ERR(rtcdev); | 107 | ret = PTR_ERR(rtcdev); |
@@ -118,9 +118,6 @@ out_err: | |||
118 | 118 | ||
119 | static int au1xtoy_rtc_remove(struct platform_device *pdev) | 119 | static int au1xtoy_rtc_remove(struct platform_device *pdev) |
120 | { | 120 | { |
121 | struct rtc_device *rtcdev = platform_get_drvdata(pdev); | ||
122 | |||
123 | rtc_device_unregister(rtcdev); | ||
124 | platform_set_drvdata(pdev, NULL); | 121 | platform_set_drvdata(pdev, NULL); |
125 | 122 | ||
126 | return 0; | 123 | return 0; |
@@ -134,18 +131,7 @@ static struct platform_driver au1xrtc_driver = { | |||
134 | .remove = au1xtoy_rtc_remove, | 131 | .remove = au1xtoy_rtc_remove, |
135 | }; | 132 | }; |
136 | 133 | ||
137 | static int __init au1xtoy_rtc_init(void) | 134 | module_platform_driver_probe(au1xrtc_driver, au1xtoy_rtc_probe); |
138 | { | ||
139 | return platform_driver_probe(&au1xrtc_driver, au1xtoy_rtc_probe); | ||
140 | } | ||
141 | |||
142 | static void __exit au1xtoy_rtc_exit(void) | ||
143 | { | ||
144 | platform_driver_unregister(&au1xrtc_driver); | ||
145 | } | ||
146 | |||
147 | module_init(au1xtoy_rtc_init); | ||
148 | module_exit(au1xtoy_rtc_exit); | ||
149 | 135 | ||
150 | MODULE_DESCRIPTION("Au1xxx TOY-counter-based RTC driver"); | 136 | MODULE_DESCRIPTION("Au1xxx TOY-counter-based RTC driver"); |
151 | MODULE_AUTHOR("Manuel Lauss <manuel.lauss@gmail.com>"); | 137 | MODULE_AUTHOR("Manuel Lauss <manuel.lauss@gmail.com>"); |
diff --git a/drivers/rtc/rtc-bfin.c b/drivers/rtc/rtc-bfin.c index 4ec614b0954d..ad44ec5dc29a 100644 --- a/drivers/rtc/rtc-bfin.c +++ b/drivers/rtc/rtc-bfin.c | |||
@@ -352,14 +352,14 @@ static int bfin_rtc_probe(struct platform_device *pdev) | |||
352 | dev_dbg_stamp(dev); | 352 | dev_dbg_stamp(dev); |
353 | 353 | ||
354 | /* Allocate memory for our RTC struct */ | 354 | /* Allocate memory for our RTC struct */ |
355 | rtc = kzalloc(sizeof(*rtc), GFP_KERNEL); | 355 | rtc = devm_kzalloc(dev, sizeof(*rtc), GFP_KERNEL); |
356 | if (unlikely(!rtc)) | 356 | if (unlikely(!rtc)) |
357 | return -ENOMEM; | 357 | return -ENOMEM; |
358 | platform_set_drvdata(pdev, rtc); | 358 | platform_set_drvdata(pdev, rtc); |
359 | device_init_wakeup(dev, 1); | 359 | device_init_wakeup(dev, 1); |
360 | 360 | ||
361 | /* Register our RTC with the RTC framework */ | 361 | /* Register our RTC with the RTC framework */ |
362 | rtc->rtc_dev = rtc_device_register(pdev->name, dev, &bfin_rtc_ops, | 362 | rtc->rtc_dev = devm_rtc_device_register(dev, pdev->name, &bfin_rtc_ops, |
363 | THIS_MODULE); | 363 | THIS_MODULE); |
364 | if (unlikely(IS_ERR(rtc->rtc_dev))) { | 364 | if (unlikely(IS_ERR(rtc->rtc_dev))) { |
365 | ret = PTR_ERR(rtc->rtc_dev); | 365 | ret = PTR_ERR(rtc->rtc_dev); |
@@ -367,9 +367,10 @@ static int bfin_rtc_probe(struct platform_device *pdev) | |||
367 | } | 367 | } |
368 | 368 | ||
369 | /* Grab the IRQ and init the hardware */ | 369 | /* Grab the IRQ and init the hardware */ |
370 | ret = request_irq(IRQ_RTC, bfin_rtc_interrupt, 0, pdev->name, dev); | 370 | ret = devm_request_irq(dev, IRQ_RTC, bfin_rtc_interrupt, 0, |
371 | pdev->name, dev); | ||
371 | if (unlikely(ret)) | 372 | if (unlikely(ret)) |
372 | goto err_reg; | 373 | goto err; |
373 | /* sometimes the bootloader touched things, but the write complete was not | 374 | /* sometimes the bootloader touched things, but the write complete was not |
374 | * enabled, so let's just do a quick timeout here since the IRQ will not fire ... | 375 | * enabled, so let's just do a quick timeout here since the IRQ will not fire ... |
375 | */ | 376 | */ |
@@ -381,32 +382,23 @@ static int bfin_rtc_probe(struct platform_device *pdev) | |||
381 | 382 | ||
382 | return 0; | 383 | return 0; |
383 | 384 | ||
384 | err_reg: | ||
385 | rtc_device_unregister(rtc->rtc_dev); | ||
386 | err: | 385 | err: |
387 | kfree(rtc); | ||
388 | return ret; | 386 | return ret; |
389 | } | 387 | } |
390 | 388 | ||
391 | static int bfin_rtc_remove(struct platform_device *pdev) | 389 | static int bfin_rtc_remove(struct platform_device *pdev) |
392 | { | 390 | { |
393 | struct bfin_rtc *rtc = platform_get_drvdata(pdev); | ||
394 | struct device *dev = &pdev->dev; | 391 | struct device *dev = &pdev->dev; |
395 | 392 | ||
396 | bfin_rtc_reset(dev, 0); | 393 | bfin_rtc_reset(dev, 0); |
397 | free_irq(IRQ_RTC, dev); | ||
398 | rtc_device_unregister(rtc->rtc_dev); | ||
399 | platform_set_drvdata(pdev, NULL); | 394 | platform_set_drvdata(pdev, NULL); |
400 | kfree(rtc); | ||
401 | 395 | ||
402 | return 0; | 396 | return 0; |
403 | } | 397 | } |
404 | 398 | ||
405 | #ifdef CONFIG_PM | 399 | #ifdef CONFIG_PM_SLEEP |
406 | static int bfin_rtc_suspend(struct platform_device *pdev, pm_message_t state) | 400 | static int bfin_rtc_suspend(struct device *dev) |
407 | { | 401 | { |
408 | struct device *dev = &pdev->dev; | ||
409 | |||
410 | dev_dbg_stamp(dev); | 402 | dev_dbg_stamp(dev); |
411 | 403 | ||
412 | if (device_may_wakeup(dev)) { | 404 | if (device_may_wakeup(dev)) { |
@@ -418,10 +410,8 @@ static int bfin_rtc_suspend(struct platform_device *pdev, pm_message_t state) | |||
418 | return 0; | 410 | return 0; |
419 | } | 411 | } |
420 | 412 | ||
421 | static int bfin_rtc_resume(struct platform_device *pdev) | 413 | static int bfin_rtc_resume(struct device *dev) |
422 | { | 414 | { |
423 | struct device *dev = &pdev->dev; | ||
424 | |||
425 | dev_dbg_stamp(dev); | 415 | dev_dbg_stamp(dev); |
426 | 416 | ||
427 | if (device_may_wakeup(dev)) | 417 | if (device_may_wakeup(dev)) |
@@ -440,20 +430,18 @@ static int bfin_rtc_resume(struct platform_device *pdev) | |||
440 | 430 | ||
441 | return 0; | 431 | return 0; |
442 | } | 432 | } |
443 | #else | ||
444 | # define bfin_rtc_suspend NULL | ||
445 | # define bfin_rtc_resume NULL | ||
446 | #endif | 433 | #endif |
447 | 434 | ||
435 | static SIMPLE_DEV_PM_OPS(bfin_rtc_pm_ops, bfin_rtc_suspend, bfin_rtc_resume); | ||
436 | |||
448 | static struct platform_driver bfin_rtc_driver = { | 437 | static struct platform_driver bfin_rtc_driver = { |
449 | .driver = { | 438 | .driver = { |
450 | .name = "rtc-bfin", | 439 | .name = "rtc-bfin", |
451 | .owner = THIS_MODULE, | 440 | .owner = THIS_MODULE, |
441 | .pm = &bfin_rtc_pm_ops, | ||
452 | }, | 442 | }, |
453 | .probe = bfin_rtc_probe, | 443 | .probe = bfin_rtc_probe, |
454 | .remove = bfin_rtc_remove, | 444 | .remove = bfin_rtc_remove, |
455 | .suspend = bfin_rtc_suspend, | ||
456 | .resume = bfin_rtc_resume, | ||
457 | }; | 445 | }; |
458 | 446 | ||
459 | module_platform_driver(bfin_rtc_driver); | 447 | module_platform_driver(bfin_rtc_driver); |
diff --git a/drivers/rtc/rtc-bq32k.c b/drivers/rtc/rtc-bq32k.c index 036cb89f8188..fea78bc713ca 100644 --- a/drivers/rtc/rtc-bq32k.c +++ b/drivers/rtc/rtc-bq32k.c | |||
@@ -153,7 +153,7 @@ static int bq32k_probe(struct i2c_client *client, | |||
153 | if (error) | 153 | if (error) |
154 | return error; | 154 | return error; |
155 | 155 | ||
156 | rtc = rtc_device_register(bq32k_driver.driver.name, &client->dev, | 156 | rtc = devm_rtc_device_register(&client->dev, bq32k_driver.driver.name, |
157 | &bq32k_rtc_ops, THIS_MODULE); | 157 | &bq32k_rtc_ops, THIS_MODULE); |
158 | if (IS_ERR(rtc)) | 158 | if (IS_ERR(rtc)) |
159 | return PTR_ERR(rtc); | 159 | return PTR_ERR(rtc); |
@@ -165,9 +165,6 @@ static int bq32k_probe(struct i2c_client *client, | |||
165 | 165 | ||
166 | static int bq32k_remove(struct i2c_client *client) | 166 | static int bq32k_remove(struct i2c_client *client) |
167 | { | 167 | { |
168 | struct rtc_device *rtc = i2c_get_clientdata(client); | ||
169 | |||
170 | rtc_device_unregister(rtc); | ||
171 | return 0; | 168 | return 0; |
172 | } | 169 | } |
173 | 170 | ||
diff --git a/drivers/rtc/rtc-bq4802.c b/drivers/rtc/rtc-bq4802.c index 693be71b5b18..af2886784a7b 100644 --- a/drivers/rtc/rtc-bq4802.c +++ b/drivers/rtc/rtc-bq4802.c | |||
@@ -142,7 +142,7 @@ static const struct rtc_class_ops bq4802_ops = { | |||
142 | 142 | ||
143 | static int bq4802_probe(struct platform_device *pdev) | 143 | static int bq4802_probe(struct platform_device *pdev) |
144 | { | 144 | { |
145 | struct bq4802 *p = kzalloc(sizeof(*p), GFP_KERNEL); | 145 | struct bq4802 *p = devm_kzalloc(&pdev->dev, sizeof(*p), GFP_KERNEL); |
146 | int err = -ENOMEM; | 146 | int err = -ENOMEM; |
147 | 147 | ||
148 | if (!p) | 148 | if (!p) |
@@ -155,54 +155,41 @@ static int bq4802_probe(struct platform_device *pdev) | |||
155 | p->r = platform_get_resource(pdev, IORESOURCE_IO, 0); | 155 | p->r = platform_get_resource(pdev, IORESOURCE_IO, 0); |
156 | err = -EINVAL; | 156 | err = -EINVAL; |
157 | if (!p->r) | 157 | if (!p->r) |
158 | goto out_free; | 158 | goto out; |
159 | } | 159 | } |
160 | if (p->r->flags & IORESOURCE_IO) { | 160 | if (p->r->flags & IORESOURCE_IO) { |
161 | p->ioport = p->r->start; | 161 | p->ioport = p->r->start; |
162 | p->read = bq4802_read_io; | 162 | p->read = bq4802_read_io; |
163 | p->write = bq4802_write_io; | 163 | p->write = bq4802_write_io; |
164 | } else if (p->r->flags & IORESOURCE_MEM) { | 164 | } else if (p->r->flags & IORESOURCE_MEM) { |
165 | p->regs = ioremap(p->r->start, resource_size(p->r)); | 165 | p->regs = devm_ioremap(&pdev->dev, p->r->start, |
166 | resource_size(p->r)); | ||
166 | p->read = bq4802_read_mem; | 167 | p->read = bq4802_read_mem; |
167 | p->write = bq4802_write_mem; | 168 | p->write = bq4802_write_mem; |
168 | } else { | 169 | } else { |
169 | err = -EINVAL; | 170 | err = -EINVAL; |
170 | goto out_free; | 171 | goto out; |
171 | } | 172 | } |
172 | 173 | ||
173 | platform_set_drvdata(pdev, p); | 174 | platform_set_drvdata(pdev, p); |
174 | 175 | ||
175 | p->rtc = rtc_device_register("bq4802", &pdev->dev, | 176 | p->rtc = devm_rtc_device_register(&pdev->dev, "bq4802", |
176 | &bq4802_ops, THIS_MODULE); | 177 | &bq4802_ops, THIS_MODULE); |
177 | if (IS_ERR(p->rtc)) { | 178 | if (IS_ERR(p->rtc)) { |
178 | err = PTR_ERR(p->rtc); | 179 | err = PTR_ERR(p->rtc); |
179 | goto out_iounmap; | 180 | goto out; |
180 | } | 181 | } |
181 | 182 | ||
182 | err = 0; | 183 | err = 0; |
183 | out: | 184 | out: |
184 | return err; | 185 | return err; |
185 | 186 | ||
186 | out_iounmap: | ||
187 | if (p->r->flags & IORESOURCE_MEM) | ||
188 | iounmap(p->regs); | ||
189 | out_free: | ||
190 | kfree(p); | ||
191 | goto out; | ||
192 | } | 187 | } |
193 | 188 | ||
194 | static int bq4802_remove(struct platform_device *pdev) | 189 | static int bq4802_remove(struct platform_device *pdev) |
195 | { | 190 | { |
196 | struct bq4802 *p = platform_get_drvdata(pdev); | ||
197 | |||
198 | rtc_device_unregister(p->rtc); | ||
199 | if (p->r->flags & IORESOURCE_MEM) | ||
200 | iounmap(p->regs); | ||
201 | |||
202 | platform_set_drvdata(pdev, NULL); | 191 | platform_set_drvdata(pdev, NULL); |
203 | 192 | ||
204 | kfree(p); | ||
205 | |||
206 | return 0; | 193 | return 0; |
207 | } | 194 | } |
208 | 195 | ||
diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c index af97c94e8a3a..cc5bea9c4b1c 100644 --- a/drivers/rtc/rtc-cmos.c +++ b/drivers/rtc/rtc-cmos.c | |||
@@ -804,9 +804,8 @@ static int cmos_suspend(struct device *dev) | |||
804 | mask = RTC_IRQMASK; | 804 | mask = RTC_IRQMASK; |
805 | tmp &= ~mask; | 805 | tmp &= ~mask; |
806 | CMOS_WRITE(tmp, RTC_CONTROL); | 806 | CMOS_WRITE(tmp, RTC_CONTROL); |
807 | hpet_mask_rtc_irq_bit(mask); | ||
807 | 808 | ||
808 | /* shut down hpet emulation - we don't need it for alarm */ | ||
809 | hpet_mask_rtc_irq_bit(RTC_PIE|RTC_AIE|RTC_UIE); | ||
810 | cmos_checkintr(cmos, tmp); | 809 | cmos_checkintr(cmos, tmp); |
811 | } | 810 | } |
812 | spin_unlock_irq(&rtc_lock); | 811 | spin_unlock_irq(&rtc_lock); |
@@ -870,6 +869,7 @@ static int cmos_resume(struct device *dev) | |||
870 | rtc_update_irq(cmos->rtc, 1, mask); | 869 | rtc_update_irq(cmos->rtc, 1, mask); |
871 | tmp &= ~RTC_AIE; | 870 | tmp &= ~RTC_AIE; |
872 | hpet_mask_rtc_irq_bit(RTC_AIE); | 871 | hpet_mask_rtc_irq_bit(RTC_AIE); |
872 | hpet_rtc_timer_init(); | ||
873 | } while (mask & RTC_AIE); | 873 | } while (mask & RTC_AIE); |
874 | spin_unlock_irq(&rtc_lock); | 874 | spin_unlock_irq(&rtc_lock); |
875 | } | 875 | } |
diff --git a/drivers/rtc/rtc-coh901331.c b/drivers/rtc/rtc-coh901331.c index 2d28ec1aa1cd..93c06588ddca 100644 --- a/drivers/rtc/rtc-coh901331.c +++ b/drivers/rtc/rtc-coh901331.c | |||
@@ -47,7 +47,7 @@ struct coh901331_port { | |||
47 | u32 physize; | 47 | u32 physize; |
48 | void __iomem *virtbase; | 48 | void __iomem *virtbase; |
49 | int irq; | 49 | int irq; |
50 | #ifdef CONFIG_PM | 50 | #ifdef CONFIG_PM_SLEEP |
51 | u32 irqmaskstore; | 51 | u32 irqmaskstore; |
52 | #endif | 52 | #endif |
53 | }; | 53 | }; |
@@ -155,7 +155,6 @@ 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 | rtc_device_unregister(rtap->rtc); | ||
159 | clk_unprepare(rtap->clk); | 158 | clk_unprepare(rtap->clk); |
160 | platform_set_drvdata(pdev, NULL); | 159 | platform_set_drvdata(pdev, NULL); |
161 | } | 160 | } |
@@ -211,8 +210,8 @@ static int __init coh901331_probe(struct platform_device *pdev) | |||
211 | clk_disable(rtap->clk); | 210 | clk_disable(rtap->clk); |
212 | 211 | ||
213 | platform_set_drvdata(pdev, rtap); | 212 | platform_set_drvdata(pdev, rtap); |
214 | rtap->rtc = rtc_device_register("coh901331", &pdev->dev, &coh901331_ops, | 213 | rtap->rtc = devm_rtc_device_register(&pdev->dev, "coh901331", |
215 | THIS_MODULE); | 214 | &coh901331_ops, THIS_MODULE); |
216 | if (IS_ERR(rtap->rtc)) { | 215 | if (IS_ERR(rtap->rtc)) { |
217 | ret = PTR_ERR(rtap->rtc); | 216 | ret = PTR_ERR(rtap->rtc); |
218 | goto out_no_rtc; | 217 | goto out_no_rtc; |
@@ -226,17 +225,17 @@ static int __init coh901331_probe(struct platform_device *pdev) | |||
226 | return ret; | 225 | return ret; |
227 | } | 226 | } |
228 | 227 | ||
229 | #ifdef CONFIG_PM | 228 | #ifdef CONFIG_PM_SLEEP |
230 | static int coh901331_suspend(struct platform_device *pdev, pm_message_t state) | 229 | static int coh901331_suspend(struct device *dev) |
231 | { | 230 | { |
232 | struct coh901331_port *rtap = dev_get_drvdata(&pdev->dev); | 231 | struct coh901331_port *rtap = dev_get_drvdata(dev); |
233 | 232 | ||
234 | /* | 233 | /* |
235 | * If this RTC alarm will be used for waking the system up, | 234 | * If this RTC alarm will be used for waking the system up, |
236 | * don't disable it of course. Else we just disable the alarm | 235 | * don't disable it of course. Else we just disable the alarm |
237 | * and await suspension. | 236 | * and await suspension. |
238 | */ | 237 | */ |
239 | if (device_may_wakeup(&pdev->dev)) { | 238 | if (device_may_wakeup(dev)) { |
240 | enable_irq_wake(rtap->irq); | 239 | enable_irq_wake(rtap->irq); |
241 | } else { | 240 | } else { |
242 | clk_enable(rtap->clk); | 241 | clk_enable(rtap->clk); |
@@ -248,12 +247,12 @@ static int coh901331_suspend(struct platform_device *pdev, pm_message_t state) | |||
248 | return 0; | 247 | return 0; |
249 | } | 248 | } |
250 | 249 | ||
251 | static int coh901331_resume(struct platform_device *pdev) | 250 | static int coh901331_resume(struct device *dev) |
252 | { | 251 | { |
253 | struct coh901331_port *rtap = dev_get_drvdata(&pdev->dev); | 252 | struct coh901331_port *rtap = dev_get_drvdata(dev); |
254 | 253 | ||
255 | clk_prepare(rtap->clk); | 254 | clk_prepare(rtap->clk); |
256 | if (device_may_wakeup(&pdev->dev)) { | 255 | if (device_may_wakeup(dev)) { |
257 | disable_irq_wake(rtap->irq); | 256 | disable_irq_wake(rtap->irq); |
258 | } else { | 257 | } else { |
259 | clk_enable(rtap->clk); | 258 | clk_enable(rtap->clk); |
@@ -262,11 +261,10 @@ static int coh901331_resume(struct platform_device *pdev) | |||
262 | } | 261 | } |
263 | return 0; | 262 | return 0; |
264 | } | 263 | } |
265 | #else | ||
266 | #define coh901331_suspend NULL | ||
267 | #define coh901331_resume NULL | ||
268 | #endif | 264 | #endif |
269 | 265 | ||
266 | static SIMPLE_DEV_PM_OPS(coh901331_pm_ops, coh901331_suspend, coh901331_resume); | ||
267 | |||
270 | static void coh901331_shutdown(struct platform_device *pdev) | 268 | static void coh901331_shutdown(struct platform_device *pdev) |
271 | { | 269 | { |
272 | struct coh901331_port *rtap = dev_get_drvdata(&pdev->dev); | 270 | struct coh901331_port *rtap = dev_get_drvdata(&pdev->dev); |
@@ -280,25 +278,13 @@ static struct platform_driver coh901331_driver = { | |||
280 | .driver = { | 278 | .driver = { |
281 | .name = "rtc-coh901331", | 279 | .name = "rtc-coh901331", |
282 | .owner = THIS_MODULE, | 280 | .owner = THIS_MODULE, |
281 | .pm = &coh901331_pm_ops, | ||
283 | }, | 282 | }, |
284 | .remove = __exit_p(coh901331_remove), | 283 | .remove = __exit_p(coh901331_remove), |
285 | .suspend = coh901331_suspend, | ||
286 | .resume = coh901331_resume, | ||
287 | .shutdown = coh901331_shutdown, | 284 | .shutdown = coh901331_shutdown, |
288 | }; | 285 | }; |
289 | 286 | ||
290 | static int __init coh901331_init(void) | 287 | module_platform_driver_probe(coh901331_driver, coh901331_probe); |
291 | { | ||
292 | return platform_driver_probe(&coh901331_driver, coh901331_probe); | ||
293 | } | ||
294 | |||
295 | static void __exit coh901331_exit(void) | ||
296 | { | ||
297 | platform_driver_unregister(&coh901331_driver); | ||
298 | } | ||
299 | |||
300 | module_init(coh901331_init); | ||
301 | module_exit(coh901331_exit); | ||
302 | 288 | ||
303 | MODULE_AUTHOR("Linus Walleij <linus.walleij@stericsson.com>"); | 289 | MODULE_AUTHOR("Linus Walleij <linus.walleij@stericsson.com>"); |
304 | MODULE_DESCRIPTION("ST-Ericsson AB COH 901 331 RTC Driver"); | 290 | MODULE_DESCRIPTION("ST-Ericsson AB COH 901 331 RTC Driver"); |
diff --git a/drivers/rtc/rtc-da9052.c b/drivers/rtc/rtc-da9052.c index 969abbad7fe3..7286b279cf2d 100644 --- a/drivers/rtc/rtc-da9052.c +++ b/drivers/rtc/rtc-da9052.c | |||
@@ -247,7 +247,7 @@ static int da9052_rtc_probe(struct platform_device *pdev) | |||
247 | return ret; | 247 | return ret; |
248 | } | 248 | } |
249 | 249 | ||
250 | rtc->rtc = rtc_device_register(pdev->name, &pdev->dev, | 250 | rtc->rtc = devm_rtc_device_register(&pdev->dev, pdev->name, |
251 | &da9052_rtc_ops, THIS_MODULE); | 251 | &da9052_rtc_ops, THIS_MODULE); |
252 | if (IS_ERR(rtc->rtc)) | 252 | if (IS_ERR(rtc->rtc)) |
253 | return PTR_ERR(rtc->rtc); | 253 | return PTR_ERR(rtc->rtc); |
@@ -257,9 +257,6 @@ static int da9052_rtc_probe(struct platform_device *pdev) | |||
257 | 257 | ||
258 | static int da9052_rtc_remove(struct platform_device *pdev) | 258 | static int da9052_rtc_remove(struct platform_device *pdev) |
259 | { | 259 | { |
260 | struct da9052_rtc *rtc = pdev->dev.platform_data; | ||
261 | |||
262 | rtc_device_unregister(rtc->rtc); | ||
263 | platform_set_drvdata(pdev, NULL); | 260 | platform_set_drvdata(pdev, NULL); |
264 | 261 | ||
265 | return 0; | 262 | return 0; |
diff --git a/drivers/rtc/rtc-da9055.c b/drivers/rtc/rtc-da9055.c index 8f0dcfedb83c..73858ca9709a 100644 --- a/drivers/rtc/rtc-da9055.c +++ b/drivers/rtc/rtc-da9055.c | |||
@@ -294,7 +294,7 @@ static int da9055_rtc_probe(struct platform_device *pdev) | |||
294 | 294 | ||
295 | device_init_wakeup(&pdev->dev, 1); | 295 | device_init_wakeup(&pdev->dev, 1); |
296 | 296 | ||
297 | rtc->rtc = rtc_device_register(pdev->name, &pdev->dev, | 297 | rtc->rtc = devm_rtc_device_register(&pdev->dev, pdev->name, |
298 | &da9055_rtc_ops, THIS_MODULE); | 298 | &da9055_rtc_ops, THIS_MODULE); |
299 | if (IS_ERR(rtc->rtc)) { | 299 | if (IS_ERR(rtc->rtc)) { |
300 | ret = PTR_ERR(rtc->rtc); | 300 | ret = PTR_ERR(rtc->rtc); |
@@ -317,9 +317,6 @@ err_rtc: | |||
317 | 317 | ||
318 | static int da9055_rtc_remove(struct platform_device *pdev) | 318 | static int da9055_rtc_remove(struct platform_device *pdev) |
319 | { | 319 | { |
320 | struct da9055_rtc *rtc = pdev->dev.platform_data; | ||
321 | |||
322 | rtc_device_unregister(rtc->rtc); | ||
323 | platform_set_drvdata(pdev, NULL); | 320 | platform_set_drvdata(pdev, NULL); |
324 | 321 | ||
325 | return 0; | 322 | return 0; |
diff --git a/drivers/rtc/rtc-davinci.c b/drivers/rtc/rtc-davinci.c index 56b73089bb29..a55048c3e26f 100644 --- a/drivers/rtc/rtc-davinci.c +++ b/drivers/rtc/rtc-davinci.c | |||
@@ -523,7 +523,7 @@ static int __init davinci_rtc_probe(struct platform_device *pdev) | |||
523 | 523 | ||
524 | platform_set_drvdata(pdev, davinci_rtc); | 524 | platform_set_drvdata(pdev, davinci_rtc); |
525 | 525 | ||
526 | davinci_rtc->rtc = rtc_device_register(pdev->name, &pdev->dev, | 526 | davinci_rtc->rtc = devm_rtc_device_register(&pdev->dev, pdev->name, |
527 | &davinci_rtc_ops, THIS_MODULE); | 527 | &davinci_rtc_ops, THIS_MODULE); |
528 | if (IS_ERR(davinci_rtc->rtc)) { | 528 | if (IS_ERR(davinci_rtc->rtc)) { |
529 | ret = PTR_ERR(davinci_rtc->rtc); | 529 | ret = PTR_ERR(davinci_rtc->rtc); |
@@ -543,7 +543,7 @@ static int __init davinci_rtc_probe(struct platform_device *pdev) | |||
543 | 0, "davinci_rtc", davinci_rtc); | 543 | 0, "davinci_rtc", davinci_rtc); |
544 | if (ret < 0) { | 544 | if (ret < 0) { |
545 | dev_err(dev, "unable to register davinci RTC interrupt\n"); | 545 | dev_err(dev, "unable to register davinci RTC interrupt\n"); |
546 | goto fail2; | 546 | goto fail1; |
547 | } | 547 | } |
548 | 548 | ||
549 | /* Enable interrupts */ | 549 | /* Enable interrupts */ |
@@ -557,14 +557,12 @@ static int __init davinci_rtc_probe(struct platform_device *pdev) | |||
557 | 557 | ||
558 | return 0; | 558 | return 0; |
559 | 559 | ||
560 | fail2: | ||
561 | rtc_device_unregister(davinci_rtc->rtc); | ||
562 | fail1: | 560 | fail1: |
563 | platform_set_drvdata(pdev, NULL); | 561 | platform_set_drvdata(pdev, NULL); |
564 | return ret; | 562 | return ret; |
565 | } | 563 | } |
566 | 564 | ||
567 | static int davinci_rtc_remove(struct platform_device *pdev) | 565 | static int __exit davinci_rtc_remove(struct platform_device *pdev) |
568 | { | 566 | { |
569 | struct davinci_rtc *davinci_rtc = platform_get_drvdata(pdev); | 567 | struct davinci_rtc *davinci_rtc = platform_get_drvdata(pdev); |
570 | 568 | ||
@@ -572,8 +570,6 @@ static int davinci_rtc_remove(struct platform_device *pdev) | |||
572 | 570 | ||
573 | rtcif_write(davinci_rtc, 0, PRTCIF_INTEN); | 571 | rtcif_write(davinci_rtc, 0, PRTCIF_INTEN); |
574 | 572 | ||
575 | rtc_device_unregister(davinci_rtc->rtc); | ||
576 | |||
577 | platform_set_drvdata(pdev, NULL); | 573 | platform_set_drvdata(pdev, NULL); |
578 | 574 | ||
579 | return 0; | 575 | return 0; |
@@ -581,24 +577,14 @@ static int davinci_rtc_remove(struct platform_device *pdev) | |||
581 | 577 | ||
582 | static struct platform_driver davinci_rtc_driver = { | 578 | static struct platform_driver davinci_rtc_driver = { |
583 | .probe = davinci_rtc_probe, | 579 | .probe = davinci_rtc_probe, |
584 | .remove = davinci_rtc_remove, | 580 | .remove = __exit_p(davinci_rtc_remove), |
585 | .driver = { | 581 | .driver = { |
586 | .name = "rtc_davinci", | 582 | .name = "rtc_davinci", |
587 | .owner = THIS_MODULE, | 583 | .owner = THIS_MODULE, |
588 | }, | 584 | }, |
589 | }; | 585 | }; |
590 | 586 | ||
591 | static int __init rtc_init(void) | 587 | module_platform_driver_probe(davinci_rtc_driver, davinci_rtc_probe); |
592 | { | ||
593 | return platform_driver_probe(&davinci_rtc_driver, davinci_rtc_probe); | ||
594 | } | ||
595 | module_init(rtc_init); | ||
596 | |||
597 | static void __exit rtc_exit(void) | ||
598 | { | ||
599 | platform_driver_unregister(&davinci_rtc_driver); | ||
600 | } | ||
601 | module_exit(rtc_exit); | ||
602 | 588 | ||
603 | MODULE_AUTHOR("Miguel Aguilar <miguel.aguilar@ridgerun.com>"); | 589 | MODULE_AUTHOR("Miguel Aguilar <miguel.aguilar@ridgerun.com>"); |
604 | MODULE_DESCRIPTION("Texas Instruments DaVinci PRTC Driver"); | 590 | MODULE_DESCRIPTION("Texas Instruments DaVinci PRTC Driver"); |
diff --git a/drivers/rtc/rtc-dm355evm.c b/drivers/rtc/rtc-dm355evm.c index b2ed2c94b081..1e1ca63d58a9 100644 --- a/drivers/rtc/rtc-dm355evm.c +++ b/drivers/rtc/rtc-dm355evm.c | |||
@@ -127,8 +127,8 @@ static int dm355evm_rtc_probe(struct platform_device *pdev) | |||
127 | { | 127 | { |
128 | struct rtc_device *rtc; | 128 | struct rtc_device *rtc; |
129 | 129 | ||
130 | rtc = rtc_device_register(pdev->name, | 130 | rtc = devm_rtc_device_register(&pdev->dev, pdev->name, |
131 | &pdev->dev, &dm355evm_rtc_ops, THIS_MODULE); | 131 | &dm355evm_rtc_ops, THIS_MODULE); |
132 | if (IS_ERR(rtc)) { | 132 | if (IS_ERR(rtc)) { |
133 | dev_err(&pdev->dev, "can't register RTC device, err %ld\n", | 133 | dev_err(&pdev->dev, "can't register RTC device, err %ld\n", |
134 | PTR_ERR(rtc)); | 134 | PTR_ERR(rtc)); |
@@ -141,9 +141,6 @@ static int dm355evm_rtc_probe(struct platform_device *pdev) | |||
141 | 141 | ||
142 | static int dm355evm_rtc_remove(struct platform_device *pdev) | 142 | static int dm355evm_rtc_remove(struct platform_device *pdev) |
143 | { | 143 | { |
144 | struct rtc_device *rtc = platform_get_drvdata(pdev); | ||
145 | |||
146 | rtc_device_unregister(rtc); | ||
147 | platform_set_drvdata(pdev, NULL); | 144 | platform_set_drvdata(pdev, NULL); |
148 | return 0; | 145 | return 0; |
149 | } | 146 | } |
diff --git a/drivers/rtc/rtc-ds1216.c b/drivers/rtc/rtc-ds1216.c index 45cd8c9f5a39..c7702b7269f7 100644 --- a/drivers/rtc/rtc-ds1216.c +++ b/drivers/rtc/rtc-ds1216.c | |||
@@ -30,8 +30,6 @@ struct ds1216_regs { | |||
30 | struct ds1216_priv { | 30 | struct ds1216_priv { |
31 | struct rtc_device *rtc; | 31 | struct rtc_device *rtc; |
32 | void __iomem *ioaddr; | 32 | void __iomem *ioaddr; |
33 | size_t size; | ||
34 | unsigned long baseaddr; | ||
35 | }; | 33 | }; |
36 | 34 | ||
37 | static const u8 magic[] = { | 35 | static const u8 magic[] = { |
@@ -144,57 +142,33 @@ static int __init ds1216_rtc_probe(struct platform_device *pdev) | |||
144 | { | 142 | { |
145 | struct resource *res; | 143 | struct resource *res; |
146 | struct ds1216_priv *priv; | 144 | struct ds1216_priv *priv; |
147 | int ret = 0; | ||
148 | u8 dummy[8]; | 145 | u8 dummy[8]; |
149 | 146 | ||
150 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 147 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
151 | if (!res) | 148 | if (!res) |
152 | return -ENODEV; | 149 | return -ENODEV; |
153 | priv = kzalloc(sizeof *priv, GFP_KERNEL); | 150 | priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); |
154 | if (!priv) | 151 | if (!priv) |
155 | return -ENOMEM; | 152 | return -ENOMEM; |
156 | 153 | ||
157 | platform_set_drvdata(pdev, priv); | 154 | platform_set_drvdata(pdev, priv); |
158 | 155 | ||
159 | priv->size = resource_size(res); | 156 | priv->ioaddr = devm_ioremap_resource(&pdev->dev, res); |
160 | if (!request_mem_region(res->start, priv->size, pdev->name)) { | 157 | if (IS_ERR(priv->ioaddr)) |
161 | ret = -EBUSY; | 158 | return PTR_ERR(priv->ioaddr); |
162 | goto out; | 159 | |
163 | } | 160 | priv->rtc = devm_rtc_device_register(&pdev->dev, "ds1216", |
164 | priv->baseaddr = res->start; | 161 | &ds1216_rtc_ops, THIS_MODULE); |
165 | priv->ioaddr = ioremap(priv->baseaddr, priv->size); | 162 | if (IS_ERR(priv->rtc)) |
166 | if (!priv->ioaddr) { | 163 | return PTR_ERR(priv->rtc); |
167 | ret = -ENOMEM; | ||
168 | goto out; | ||
169 | } | ||
170 | priv->rtc = rtc_device_register("ds1216", &pdev->dev, | ||
171 | &ds1216_rtc_ops, THIS_MODULE); | ||
172 | if (IS_ERR(priv->rtc)) { | ||
173 | ret = PTR_ERR(priv->rtc); | ||
174 | goto out; | ||
175 | } | ||
176 | 164 | ||
177 | /* dummy read to get clock into a known state */ | 165 | /* dummy read to get clock into a known state */ |
178 | ds1216_read(priv->ioaddr, dummy); | 166 | ds1216_read(priv->ioaddr, dummy); |
179 | return 0; | 167 | return 0; |
180 | |||
181 | out: | ||
182 | if (priv->ioaddr) | ||
183 | iounmap(priv->ioaddr); | ||
184 | if (priv->baseaddr) | ||
185 | release_mem_region(priv->baseaddr, priv->size); | ||
186 | kfree(priv); | ||
187 | return ret; | ||
188 | } | 168 | } |
189 | 169 | ||
190 | static int __exit ds1216_rtc_remove(struct platform_device *pdev) | 170 | static int __exit ds1216_rtc_remove(struct platform_device *pdev) |
191 | { | 171 | { |
192 | struct ds1216_priv *priv = platform_get_drvdata(pdev); | ||
193 | |||
194 | rtc_device_unregister(priv->rtc); | ||
195 | iounmap(priv->ioaddr); | ||
196 | release_mem_region(priv->baseaddr, priv->size); | ||
197 | kfree(priv); | ||
198 | return 0; | 172 | return 0; |
199 | } | 173 | } |
200 | 174 | ||
diff --git a/drivers/rtc/rtc-ds1286.c b/drivers/rtc/rtc-ds1286.c index d989412a348a..398c96a98fc4 100644 --- a/drivers/rtc/rtc-ds1286.c +++ b/drivers/rtc/rtc-ds1286.c | |||
@@ -25,8 +25,6 @@ | |||
25 | struct ds1286_priv { | 25 | struct ds1286_priv { |
26 | struct rtc_device *rtc; | 26 | struct rtc_device *rtc; |
27 | u32 __iomem *rtcregs; | 27 | u32 __iomem *rtcregs; |
28 | size_t size; | ||
29 | unsigned long baseaddr; | ||
30 | spinlock_t lock; | 28 | spinlock_t lock; |
31 | }; | 29 | }; |
32 | 30 | ||
@@ -270,7 +268,6 @@ static int ds1286_set_time(struct device *dev, struct rtc_time *tm) | |||
270 | static int ds1286_read_alarm(struct device *dev, struct rtc_wkalrm *alm) | 268 | static int ds1286_read_alarm(struct device *dev, struct rtc_wkalrm *alm) |
271 | { | 269 | { |
272 | struct ds1286_priv *priv = dev_get_drvdata(dev); | 270 | struct ds1286_priv *priv = dev_get_drvdata(dev); |
273 | unsigned char cmd; | ||
274 | unsigned long flags; | 271 | unsigned long flags; |
275 | 272 | ||
276 | /* | 273 | /* |
@@ -281,7 +278,7 @@ static int ds1286_read_alarm(struct device *dev, struct rtc_wkalrm *alm) | |||
281 | alm->time.tm_min = ds1286_rtc_read(priv, RTC_MINUTES_ALARM) & 0x7f; | 278 | alm->time.tm_min = ds1286_rtc_read(priv, RTC_MINUTES_ALARM) & 0x7f; |
282 | alm->time.tm_hour = ds1286_rtc_read(priv, RTC_HOURS_ALARM) & 0x1f; | 279 | alm->time.tm_hour = ds1286_rtc_read(priv, RTC_HOURS_ALARM) & 0x1f; |
283 | alm->time.tm_wday = ds1286_rtc_read(priv, RTC_DAY_ALARM) & 0x07; | 280 | alm->time.tm_wday = ds1286_rtc_read(priv, RTC_DAY_ALARM) & 0x07; |
284 | cmd = ds1286_rtc_read(priv, RTC_CMD); | 281 | ds1286_rtc_read(priv, RTC_CMD); |
285 | spin_unlock_irqrestore(&priv->lock, flags); | 282 | spin_unlock_irqrestore(&priv->lock, flags); |
286 | 283 | ||
287 | alm->time.tm_min = bcd2bin(alm->time.tm_min); | 284 | alm->time.tm_min = bcd2bin(alm->time.tm_min); |
@@ -334,56 +331,30 @@ static int ds1286_probe(struct platform_device *pdev) | |||
334 | struct rtc_device *rtc; | 331 | struct rtc_device *rtc; |
335 | struct resource *res; | 332 | struct resource *res; |
336 | struct ds1286_priv *priv; | 333 | struct ds1286_priv *priv; |
337 | int ret = 0; | ||
338 | 334 | ||
339 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 335 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
340 | if (!res) | 336 | if (!res) |
341 | return -ENODEV; | 337 | return -ENODEV; |
342 | priv = kzalloc(sizeof(struct ds1286_priv), GFP_KERNEL); | 338 | priv = devm_kzalloc(&pdev->dev, sizeof(struct ds1286_priv), GFP_KERNEL); |
343 | if (!priv) | 339 | if (!priv) |
344 | return -ENOMEM; | 340 | return -ENOMEM; |
345 | 341 | ||
346 | priv->size = resource_size(res); | 342 | priv->rtcregs = devm_ioremap_resource(&pdev->dev, res); |
347 | if (!request_mem_region(res->start, priv->size, pdev->name)) { | 343 | if (IS_ERR(priv->rtcregs)) |
348 | ret = -EBUSY; | 344 | return PTR_ERR(priv->rtcregs); |
349 | goto out; | 345 | |
350 | } | ||
351 | priv->baseaddr = res->start; | ||
352 | priv->rtcregs = ioremap(priv->baseaddr, priv->size); | ||
353 | if (!priv->rtcregs) { | ||
354 | ret = -ENOMEM; | ||
355 | goto out; | ||
356 | } | ||
357 | spin_lock_init(&priv->lock); | 346 | spin_lock_init(&priv->lock); |
358 | platform_set_drvdata(pdev, priv); | 347 | platform_set_drvdata(pdev, priv); |
359 | rtc = rtc_device_register("ds1286", &pdev->dev, | 348 | rtc = devm_rtc_device_register(&pdev->dev, "ds1286", &ds1286_ops, |
360 | &ds1286_ops, THIS_MODULE); | 349 | THIS_MODULE); |
361 | if (IS_ERR(rtc)) { | 350 | if (IS_ERR(rtc)) |
362 | ret = PTR_ERR(rtc); | 351 | return PTR_ERR(rtc); |
363 | goto out; | ||
364 | } | ||
365 | priv->rtc = rtc; | 352 | priv->rtc = rtc; |
366 | return 0; | 353 | return 0; |
367 | |||
368 | out: | ||
369 | if (priv->rtc) | ||
370 | rtc_device_unregister(priv->rtc); | ||
371 | if (priv->rtcregs) | ||
372 | iounmap(priv->rtcregs); | ||
373 | if (priv->baseaddr) | ||
374 | release_mem_region(priv->baseaddr, priv->size); | ||
375 | kfree(priv); | ||
376 | return ret; | ||
377 | } | 354 | } |
378 | 355 | ||
379 | static int ds1286_remove(struct platform_device *pdev) | 356 | static int ds1286_remove(struct platform_device *pdev) |
380 | { | 357 | { |
381 | struct ds1286_priv *priv = platform_get_drvdata(pdev); | ||
382 | |||
383 | rtc_device_unregister(priv->rtc); | ||
384 | iounmap(priv->rtcregs); | ||
385 | release_mem_region(priv->baseaddr, priv->size); | ||
386 | kfree(priv); | ||
387 | return 0; | 358 | return 0; |
388 | } | 359 | } |
389 | 360 | ||
diff --git a/drivers/rtc/rtc-ds1302.c b/drivers/rtc/rtc-ds1302.c index fdbcdb289d60..d13954346286 100644 --- a/drivers/rtc/rtc-ds1302.c +++ b/drivers/rtc/rtc-ds1302.c | |||
@@ -224,7 +224,7 @@ static int __init ds1302_rtc_probe(struct platform_device *pdev) | |||
224 | return -ENODEV; | 224 | return -ENODEV; |
225 | } | 225 | } |
226 | 226 | ||
227 | rtc = rtc_device_register("ds1302", &pdev->dev, | 227 | rtc = devm_rtc_device_register(&pdev->dev, "ds1302", |
228 | &ds1302_rtc_ops, THIS_MODULE); | 228 | &ds1302_rtc_ops, THIS_MODULE); |
229 | if (IS_ERR(rtc)) | 229 | if (IS_ERR(rtc)) |
230 | return PTR_ERR(rtc); | 230 | return PTR_ERR(rtc); |
@@ -234,11 +234,8 @@ static int __init ds1302_rtc_probe(struct platform_device *pdev) | |||
234 | return 0; | 234 | return 0; |
235 | } | 235 | } |
236 | 236 | ||
237 | static int ds1302_rtc_remove(struct platform_device *pdev) | 237 | static int __exit ds1302_rtc_remove(struct platform_device *pdev) |
238 | { | 238 | { |
239 | struct rtc_device *rtc = platform_get_drvdata(pdev); | ||
240 | |||
241 | rtc_device_unregister(rtc); | ||
242 | platform_set_drvdata(pdev, NULL); | 239 | platform_set_drvdata(pdev, NULL); |
243 | 240 | ||
244 | return 0; | 241 | return 0; |
@@ -249,21 +246,10 @@ static struct platform_driver ds1302_platform_driver = { | |||
249 | .name = DRV_NAME, | 246 | .name = DRV_NAME, |
250 | .owner = THIS_MODULE, | 247 | .owner = THIS_MODULE, |
251 | }, | 248 | }, |
252 | .remove = ds1302_rtc_remove, | 249 | .remove = __exit_p(ds1302_rtc_remove), |
253 | }; | 250 | }; |
254 | 251 | ||
255 | static int __init ds1302_rtc_init(void) | 252 | module_platform_driver_probe(ds1302_platform_driver, ds1302_rtc_probe); |
256 | { | ||
257 | return platform_driver_probe(&ds1302_platform_driver, ds1302_rtc_probe); | ||
258 | } | ||
259 | |||
260 | static void __exit ds1302_rtc_exit(void) | ||
261 | { | ||
262 | platform_driver_unregister(&ds1302_platform_driver); | ||
263 | } | ||
264 | |||
265 | module_init(ds1302_rtc_init); | ||
266 | module_exit(ds1302_rtc_exit); | ||
267 | 253 | ||
268 | MODULE_DESCRIPTION("Dallas DS1302 RTC driver"); | 254 | MODULE_DESCRIPTION("Dallas DS1302 RTC driver"); |
269 | MODULE_VERSION(DRV_VERSION); | 255 | MODULE_VERSION(DRV_VERSION); |
diff --git a/drivers/rtc/rtc-ds1305.c b/drivers/rtc/rtc-ds1305.c index b05a6dc96405..bb5f13f63630 100644 --- a/drivers/rtc/rtc-ds1305.c +++ b/drivers/rtc/rtc-ds1305.c | |||
@@ -619,7 +619,7 @@ static int ds1305_probe(struct spi_device *spi) | |||
619 | return -EINVAL; | 619 | return -EINVAL; |
620 | 620 | ||
621 | /* set up driver data */ | 621 | /* set up driver data */ |
622 | ds1305 = kzalloc(sizeof *ds1305, GFP_KERNEL); | 622 | ds1305 = devm_kzalloc(&spi->dev, sizeof(*ds1305), GFP_KERNEL); |
623 | if (!ds1305) | 623 | if (!ds1305) |
624 | return -ENOMEM; | 624 | return -ENOMEM; |
625 | ds1305->spi = spi; | 625 | ds1305->spi = spi; |
@@ -632,7 +632,7 @@ static int ds1305_probe(struct spi_device *spi) | |||
632 | if (status < 0) { | 632 | if (status < 0) { |
633 | dev_dbg(&spi->dev, "can't %s, %d\n", | 633 | dev_dbg(&spi->dev, "can't %s, %d\n", |
634 | "read", status); | 634 | "read", status); |
635 | goto fail0; | 635 | return status; |
636 | } | 636 | } |
637 | 637 | ||
638 | dev_dbg(&spi->dev, "ctrl %s: %3ph\n", "read", ds1305->ctrl); | 638 | dev_dbg(&spi->dev, "ctrl %s: %3ph\n", "read", ds1305->ctrl); |
@@ -644,8 +644,7 @@ static int ds1305_probe(struct spi_device *spi) | |||
644 | */ | 644 | */ |
645 | if ((ds1305->ctrl[0] & 0x38) != 0 || (ds1305->ctrl[1] & 0xfc) != 0) { | 645 | if ((ds1305->ctrl[0] & 0x38) != 0 || (ds1305->ctrl[1] & 0xfc) != 0) { |
646 | dev_dbg(&spi->dev, "RTC chip is not present\n"); | 646 | dev_dbg(&spi->dev, "RTC chip is not present\n"); |
647 | status = -ENODEV; | 647 | return -ENODEV; |
648 | goto fail0; | ||
649 | } | 648 | } |
650 | if (ds1305->ctrl[2] == 0) | 649 | if (ds1305->ctrl[2] == 0) |
651 | dev_dbg(&spi->dev, "chip may not be present\n"); | 650 | dev_dbg(&spi->dev, "chip may not be present\n"); |
@@ -664,7 +663,7 @@ static int ds1305_probe(struct spi_device *spi) | |||
664 | 663 | ||
665 | dev_dbg(&spi->dev, "clear WP --> %d\n", status); | 664 | dev_dbg(&spi->dev, "clear WP --> %d\n", status); |
666 | if (status < 0) | 665 | if (status < 0) |
667 | goto fail0; | 666 | return status; |
668 | } | 667 | } |
669 | 668 | ||
670 | /* on DS1305, maybe start oscillator; like most low power | 669 | /* on DS1305, maybe start oscillator; like most low power |
@@ -718,7 +717,7 @@ static int ds1305_probe(struct spi_device *spi) | |||
718 | if (status < 0) { | 717 | if (status < 0) { |
719 | dev_dbg(&spi->dev, "can't %s, %d\n", | 718 | dev_dbg(&spi->dev, "can't %s, %d\n", |
720 | "write", status); | 719 | "write", status); |
721 | goto fail0; | 720 | return status; |
722 | } | 721 | } |
723 | 722 | ||
724 | dev_dbg(&spi->dev, "ctrl %s: %3ph\n", "write", ds1305->ctrl); | 723 | dev_dbg(&spi->dev, "ctrl %s: %3ph\n", "write", ds1305->ctrl); |
@@ -730,7 +729,7 @@ static int ds1305_probe(struct spi_device *spi) | |||
730 | &value, sizeof value); | 729 | &value, sizeof value); |
731 | if (status < 0) { | 730 | if (status < 0) { |
732 | dev_dbg(&spi->dev, "read HOUR --> %d\n", status); | 731 | dev_dbg(&spi->dev, "read HOUR --> %d\n", status); |
733 | goto fail0; | 732 | return status; |
734 | } | 733 | } |
735 | 734 | ||
736 | ds1305->hr12 = (DS1305_HR_12 & value) != 0; | 735 | ds1305->hr12 = (DS1305_HR_12 & value) != 0; |
@@ -738,12 +737,12 @@ static int ds1305_probe(struct spi_device *spi) | |||
738 | dev_dbg(&spi->dev, "AM/PM\n"); | 737 | dev_dbg(&spi->dev, "AM/PM\n"); |
739 | 738 | ||
740 | /* register RTC ... from here on, ds1305->ctrl needs locking */ | 739 | /* register RTC ... from here on, ds1305->ctrl needs locking */ |
741 | ds1305->rtc = rtc_device_register("ds1305", &spi->dev, | 740 | ds1305->rtc = devm_rtc_device_register(&spi->dev, "ds1305", |
742 | &ds1305_ops, THIS_MODULE); | 741 | &ds1305_ops, THIS_MODULE); |
743 | if (IS_ERR(ds1305->rtc)) { | 742 | if (IS_ERR(ds1305->rtc)) { |
744 | status = PTR_ERR(ds1305->rtc); | 743 | status = PTR_ERR(ds1305->rtc); |
745 | dev_dbg(&spi->dev, "register rtc --> %d\n", status); | 744 | dev_dbg(&spi->dev, "register rtc --> %d\n", status); |
746 | goto fail0; | 745 | return status; |
747 | } | 746 | } |
748 | 747 | ||
749 | /* Maybe set up alarm IRQ; be ready to handle it triggering right | 748 | /* Maybe set up alarm IRQ; be ready to handle it triggering right |
@@ -754,12 +753,12 @@ static int ds1305_probe(struct spi_device *spi) | |||
754 | */ | 753 | */ |
755 | if (spi->irq) { | 754 | if (spi->irq) { |
756 | INIT_WORK(&ds1305->work, ds1305_work); | 755 | INIT_WORK(&ds1305->work, ds1305_work); |
757 | status = request_irq(spi->irq, ds1305_irq, | 756 | status = devm_request_irq(&spi->dev, spi->irq, ds1305_irq, |
758 | 0, dev_name(&ds1305->rtc->dev), ds1305); | 757 | 0, dev_name(&ds1305->rtc->dev), ds1305); |
759 | if (status < 0) { | 758 | if (status < 0) { |
760 | dev_dbg(&spi->dev, "request_irq %d --> %d\n", | 759 | dev_dbg(&spi->dev, "request_irq %d --> %d\n", |
761 | spi->irq, status); | 760 | spi->irq, status); |
762 | goto fail1; | 761 | return status; |
763 | } | 762 | } |
764 | 763 | ||
765 | device_set_wakeup_capable(&spi->dev, 1); | 764 | device_set_wakeup_capable(&spi->dev, 1); |
@@ -769,18 +768,10 @@ static int ds1305_probe(struct spi_device *spi) | |||
769 | status = sysfs_create_bin_file(&spi->dev.kobj, &nvram); | 768 | status = sysfs_create_bin_file(&spi->dev.kobj, &nvram); |
770 | if (status < 0) { | 769 | if (status < 0) { |
771 | dev_dbg(&spi->dev, "register nvram --> %d\n", status); | 770 | dev_dbg(&spi->dev, "register nvram --> %d\n", status); |
772 | goto fail2; | 771 | return status; |
773 | } | 772 | } |
774 | 773 | ||
775 | return 0; | 774 | return 0; |
776 | |||
777 | fail2: | ||
778 | free_irq(spi->irq, ds1305); | ||
779 | fail1: | ||
780 | rtc_device_unregister(ds1305->rtc); | ||
781 | fail0: | ||
782 | kfree(ds1305); | ||
783 | return status; | ||
784 | } | 775 | } |
785 | 776 | ||
786 | static int ds1305_remove(struct spi_device *spi) | 777 | static int ds1305_remove(struct spi_device *spi) |
@@ -792,13 +783,11 @@ static int ds1305_remove(struct spi_device *spi) | |||
792 | /* carefully shut down irq and workqueue, if present */ | 783 | /* carefully shut down irq and workqueue, if present */ |
793 | if (spi->irq) { | 784 | if (spi->irq) { |
794 | set_bit(FLAG_EXITING, &ds1305->flags); | 785 | set_bit(FLAG_EXITING, &ds1305->flags); |
795 | free_irq(spi->irq, ds1305); | 786 | devm_free_irq(&spi->dev, spi->irq, ds1305); |
796 | cancel_work_sync(&ds1305->work); | 787 | cancel_work_sync(&ds1305->work); |
797 | } | 788 | } |
798 | 789 | ||
799 | rtc_device_unregister(ds1305->rtc); | ||
800 | spi_set_drvdata(spi, NULL); | 790 | spi_set_drvdata(spi, NULL); |
801 | kfree(ds1305); | ||
802 | return 0; | 791 | return 0; |
803 | } | 792 | } |
804 | 793 | ||
diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c index 970a236b147a..b53992ab3090 100644 --- a/drivers/rtc/rtc-ds1307.c +++ b/drivers/rtc/rtc-ds1307.c | |||
@@ -4,6 +4,7 @@ | |||
4 | * Copyright (C) 2005 James Chapman (ds1337 core) | 4 | * Copyright (C) 2005 James Chapman (ds1337 core) |
5 | * Copyright (C) 2006 David Brownell | 5 | * Copyright (C) 2006 David Brownell |
6 | * Copyright (C) 2009 Matthias Fuchs (rx8025 support) | 6 | * Copyright (C) 2009 Matthias Fuchs (rx8025 support) |
7 | * Copyright (C) 2012 Bertrand Achard (nvram access fixes) | ||
7 | * | 8 | * |
8 | * This program is free software; you can redistribute it and/or modify | 9 | * 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 | * it under the terms of the GNU General Public License version 2 as |
@@ -196,7 +197,7 @@ static s32 ds1307_read_block_data_once(const struct i2c_client *client, | |||
196 | static s32 ds1307_read_block_data(const struct i2c_client *client, u8 command, | 197 | static s32 ds1307_read_block_data(const struct i2c_client *client, u8 command, |
197 | u8 length, u8 *values) | 198 | u8 length, u8 *values) |
198 | { | 199 | { |
199 | u8 oldvalues[I2C_SMBUS_BLOCK_MAX]; | 200 | u8 oldvalues[255]; |
200 | s32 ret; | 201 | s32 ret; |
201 | int tries = 0; | 202 | int tries = 0; |
202 | 203 | ||
@@ -222,7 +223,7 @@ static s32 ds1307_read_block_data(const struct i2c_client *client, u8 command, | |||
222 | static s32 ds1307_write_block_data(const struct i2c_client *client, u8 command, | 223 | static s32 ds1307_write_block_data(const struct i2c_client *client, u8 command, |
223 | u8 length, const u8 *values) | 224 | u8 length, const u8 *values) |
224 | { | 225 | { |
225 | u8 currvalues[I2C_SMBUS_BLOCK_MAX]; | 226 | u8 currvalues[255]; |
226 | int tries = 0; | 227 | int tries = 0; |
227 | 228 | ||
228 | dev_dbg(&client->dev, "ds1307_write_block_data (length=%d)\n", length); | 229 | dev_dbg(&client->dev, "ds1307_write_block_data (length=%d)\n", length); |
@@ -250,6 +251,57 @@ static s32 ds1307_write_block_data(const struct i2c_client *client, u8 command, | |||
250 | 251 | ||
251 | /*----------------------------------------------------------------------*/ | 252 | /*----------------------------------------------------------------------*/ |
252 | 253 | ||
254 | /* These RTC devices are not designed to be connected to a SMbus adapter. | ||
255 | SMbus limits block operations length to 32 bytes, whereas it's not | ||
256 | limited on I2C buses. As a result, accesses may exceed 32 bytes; | ||
257 | in that case, split them into smaller blocks */ | ||
258 | |||
259 | static s32 ds1307_native_smbus_write_block_data(const struct i2c_client *client, | ||
260 | u8 command, u8 length, const u8 *values) | ||
261 | { | ||
262 | u8 suboffset = 0; | ||
263 | |||
264 | if (length <= I2C_SMBUS_BLOCK_MAX) | ||
265 | return i2c_smbus_write_i2c_block_data(client, | ||
266 | command, length, values); | ||
267 | |||
268 | while (suboffset < length) { | ||
269 | s32 retval = i2c_smbus_write_i2c_block_data(client, | ||
270 | command + suboffset, | ||
271 | min(I2C_SMBUS_BLOCK_MAX, length - suboffset), | ||
272 | values + suboffset); | ||
273 | if (retval < 0) | ||
274 | return retval; | ||
275 | |||
276 | suboffset += I2C_SMBUS_BLOCK_MAX; | ||
277 | } | ||
278 | return length; | ||
279 | } | ||
280 | |||
281 | static s32 ds1307_native_smbus_read_block_data(const struct i2c_client *client, | ||
282 | u8 command, u8 length, u8 *values) | ||
283 | { | ||
284 | u8 suboffset = 0; | ||
285 | |||
286 | if (length <= I2C_SMBUS_BLOCK_MAX) | ||
287 | return i2c_smbus_read_i2c_block_data(client, | ||
288 | command, length, values); | ||
289 | |||
290 | while (suboffset < length) { | ||
291 | s32 retval = i2c_smbus_read_i2c_block_data(client, | ||
292 | command + suboffset, | ||
293 | min(I2C_SMBUS_BLOCK_MAX, length - suboffset), | ||
294 | values + suboffset); | ||
295 | if (retval < 0) | ||
296 | return retval; | ||
297 | |||
298 | suboffset += I2C_SMBUS_BLOCK_MAX; | ||
299 | } | ||
300 | return length; | ||
301 | } | ||
302 | |||
303 | /*----------------------------------------------------------------------*/ | ||
304 | |||
253 | /* | 305 | /* |
254 | * The IRQ logic includes a "real" handler running in IRQ context just | 306 | * The IRQ logic includes a "real" handler running in IRQ context just |
255 | * long enough to schedule this workqueue entry. We need a task context | 307 | * long enough to schedule this workqueue entry. We need a task context |
@@ -646,8 +698,8 @@ static int ds1307_probe(struct i2c_client *client, | |||
646 | 698 | ||
647 | buf = ds1307->regs; | 699 | buf = ds1307->regs; |
648 | if (i2c_check_functionality(adapter, I2C_FUNC_SMBUS_I2C_BLOCK)) { | 700 | if (i2c_check_functionality(adapter, I2C_FUNC_SMBUS_I2C_BLOCK)) { |
649 | ds1307->read_block_data = i2c_smbus_read_i2c_block_data; | 701 | ds1307->read_block_data = ds1307_native_smbus_read_block_data; |
650 | ds1307->write_block_data = i2c_smbus_write_i2c_block_data; | 702 | ds1307->write_block_data = ds1307_native_smbus_write_block_data; |
651 | } else { | 703 | } else { |
652 | ds1307->read_block_data = ds1307_read_block_data; | 704 | ds1307->read_block_data = ds1307_read_block_data; |
653 | ds1307->write_block_data = ds1307_write_block_data; | 705 | ds1307->write_block_data = ds1307_write_block_data; |
@@ -661,7 +713,7 @@ static int ds1307_probe(struct i2c_client *client, | |||
661 | tmp = ds1307->read_block_data(ds1307->client, | 713 | tmp = ds1307->read_block_data(ds1307->client, |
662 | DS1337_REG_CONTROL, 2, buf); | 714 | DS1337_REG_CONTROL, 2, buf); |
663 | if (tmp != 2) { | 715 | if (tmp != 2) { |
664 | pr_debug("read error %d\n", tmp); | 716 | dev_dbg(&client->dev, "read error %d\n", tmp); |
665 | err = -EIO; | 717 | err = -EIO; |
666 | goto exit_free; | 718 | goto exit_free; |
667 | } | 719 | } |
@@ -700,7 +752,7 @@ static int ds1307_probe(struct i2c_client *client, | |||
700 | tmp = i2c_smbus_read_i2c_block_data(ds1307->client, | 752 | tmp = i2c_smbus_read_i2c_block_data(ds1307->client, |
701 | RX8025_REG_CTRL1 << 4 | 0x08, 2, buf); | 753 | RX8025_REG_CTRL1 << 4 | 0x08, 2, buf); |
702 | if (tmp != 2) { | 754 | if (tmp != 2) { |
703 | pr_debug("read error %d\n", tmp); | 755 | dev_dbg(&client->dev, "read error %d\n", tmp); |
704 | err = -EIO; | 756 | err = -EIO; |
705 | goto exit_free; | 757 | goto exit_free; |
706 | } | 758 | } |
@@ -744,7 +796,7 @@ static int ds1307_probe(struct i2c_client *client, | |||
744 | tmp = i2c_smbus_read_i2c_block_data(ds1307->client, | 796 | tmp = i2c_smbus_read_i2c_block_data(ds1307->client, |
745 | RX8025_REG_CTRL1 << 4 | 0x08, 2, buf); | 797 | RX8025_REG_CTRL1 << 4 | 0x08, 2, buf); |
746 | if (tmp != 2) { | 798 | if (tmp != 2) { |
747 | pr_debug("read error %d\n", tmp); | 799 | dev_dbg(&client->dev, "read error %d\n", tmp); |
748 | err = -EIO; | 800 | err = -EIO; |
749 | goto exit_free; | 801 | goto exit_free; |
750 | } | 802 | } |
@@ -772,7 +824,7 @@ read_rtc: | |||
772 | /* read RTC registers */ | 824 | /* read RTC registers */ |
773 | tmp = ds1307->read_block_data(ds1307->client, ds1307->offset, 8, buf); | 825 | tmp = ds1307->read_block_data(ds1307->client, ds1307->offset, 8, buf); |
774 | if (tmp != 8) { | 826 | if (tmp != 8) { |
775 | pr_debug("read error %d\n", tmp); | 827 | dev_dbg(&client->dev, "read error %d\n", tmp); |
776 | err = -EIO; | 828 | err = -EIO; |
777 | goto exit_free; | 829 | goto exit_free; |
778 | } | 830 | } |
@@ -814,7 +866,7 @@ read_rtc: | |||
814 | 866 | ||
815 | tmp = i2c_smbus_read_byte_data(client, DS1340_REG_FLAG); | 867 | tmp = i2c_smbus_read_byte_data(client, DS1340_REG_FLAG); |
816 | if (tmp < 0) { | 868 | if (tmp < 0) { |
817 | pr_debug("read error %d\n", tmp); | 869 | dev_dbg(&client->dev, "read error %d\n", tmp); |
818 | err = -EIO; | 870 | err = -EIO; |
819 | goto exit_free; | 871 | goto exit_free; |
820 | } | 872 | } |
@@ -908,8 +960,8 @@ read_rtc: | |||
908 | ds1307->nvram->attr.name = "nvram"; | 960 | ds1307->nvram->attr.name = "nvram"; |
909 | ds1307->nvram->attr.mode = S_IRUGO | S_IWUSR; | 961 | ds1307->nvram->attr.mode = S_IRUGO | S_IWUSR; |
910 | sysfs_bin_attr_init(ds1307->nvram); | 962 | sysfs_bin_attr_init(ds1307->nvram); |
911 | ds1307->nvram->read = ds1307_nvram_read, | 963 | ds1307->nvram->read = ds1307_nvram_read; |
912 | ds1307->nvram->write = ds1307_nvram_write, | 964 | ds1307->nvram->write = ds1307_nvram_write; |
913 | ds1307->nvram->size = chip->nvram_size; | 965 | ds1307->nvram->size = chip->nvram_size; |
914 | ds1307->nvram_offset = chip->nvram_offset; | 966 | ds1307->nvram_offset = chip->nvram_offset; |
915 | err = sysfs_create_bin_file(&client->dev.kobj, ds1307->nvram); | 967 | err = sysfs_create_bin_file(&client->dev.kobj, ds1307->nvram); |
diff --git a/drivers/rtc/rtc-ds1374.c b/drivers/rtc/rtc-ds1374.c index fef76868aae0..94366e12f40f 100644 --- a/drivers/rtc/rtc-ds1374.c +++ b/drivers/rtc/rtc-ds1374.c | |||
@@ -347,7 +347,7 @@ static int ds1374_probe(struct i2c_client *client, | |||
347 | struct ds1374 *ds1374; | 347 | struct ds1374 *ds1374; |
348 | int ret; | 348 | int ret; |
349 | 349 | ||
350 | ds1374 = kzalloc(sizeof(struct ds1374), GFP_KERNEL); | 350 | ds1374 = devm_kzalloc(&client->dev, sizeof(struct ds1374), GFP_KERNEL); |
351 | if (!ds1374) | 351 | if (!ds1374) |
352 | return -ENOMEM; | 352 | return -ENOMEM; |
353 | 353 | ||
@@ -359,36 +359,27 @@ static int ds1374_probe(struct i2c_client *client, | |||
359 | 359 | ||
360 | ret = ds1374_check_rtc_status(client); | 360 | ret = ds1374_check_rtc_status(client); |
361 | if (ret) | 361 | if (ret) |
362 | goto out_free; | 362 | return ret; |
363 | 363 | ||
364 | if (client->irq > 0) { | 364 | if (client->irq > 0) { |
365 | ret = request_irq(client->irq, ds1374_irq, 0, | 365 | ret = devm_request_irq(&client->dev, client->irq, ds1374_irq, 0, |
366 | "ds1374", client); | 366 | "ds1374", client); |
367 | if (ret) { | 367 | if (ret) { |
368 | dev_err(&client->dev, "unable to request IRQ\n"); | 368 | dev_err(&client->dev, "unable to request IRQ\n"); |
369 | goto out_free; | 369 | return ret; |
370 | } | 370 | } |
371 | 371 | ||
372 | device_set_wakeup_capable(&client->dev, 1); | 372 | device_set_wakeup_capable(&client->dev, 1); |
373 | } | 373 | } |
374 | 374 | ||
375 | ds1374->rtc = rtc_device_register(client->name, &client->dev, | 375 | ds1374->rtc = devm_rtc_device_register(&client->dev, client->name, |
376 | &ds1374_rtc_ops, THIS_MODULE); | 376 | &ds1374_rtc_ops, THIS_MODULE); |
377 | if (IS_ERR(ds1374->rtc)) { | 377 | if (IS_ERR(ds1374->rtc)) { |
378 | ret = PTR_ERR(ds1374->rtc); | ||
379 | dev_err(&client->dev, "unable to register the class device\n"); | 378 | dev_err(&client->dev, "unable to register the class device\n"); |
380 | goto out_irq; | 379 | return PTR_ERR(ds1374->rtc); |
381 | } | 380 | } |
382 | 381 | ||
383 | return 0; | 382 | return 0; |
384 | |||
385 | out_irq: | ||
386 | if (client->irq > 0) | ||
387 | free_irq(client->irq, client); | ||
388 | |||
389 | out_free: | ||
390 | kfree(ds1374); | ||
391 | return ret; | ||
392 | } | 383 | } |
393 | 384 | ||
394 | static int ds1374_remove(struct i2c_client *client) | 385 | static int ds1374_remove(struct i2c_client *client) |
@@ -400,16 +391,14 @@ static int ds1374_remove(struct i2c_client *client) | |||
400 | ds1374->exiting = 1; | 391 | ds1374->exiting = 1; |
401 | mutex_unlock(&ds1374->mutex); | 392 | mutex_unlock(&ds1374->mutex); |
402 | 393 | ||
403 | free_irq(client->irq, client); | 394 | devm_free_irq(&client->dev, client->irq, client); |
404 | cancel_work_sync(&ds1374->work); | 395 | cancel_work_sync(&ds1374->work); |
405 | } | 396 | } |
406 | 397 | ||
407 | rtc_device_unregister(ds1374->rtc); | ||
408 | kfree(ds1374); | ||
409 | return 0; | 398 | return 0; |
410 | } | 399 | } |
411 | 400 | ||
412 | #ifdef CONFIG_PM | 401 | #ifdef CONFIG_PM_SLEEP |
413 | static int ds1374_suspend(struct device *dev) | 402 | static int ds1374_suspend(struct device *dev) |
414 | { | 403 | { |
415 | struct i2c_client *client = to_i2c_client(dev); | 404 | struct i2c_client *client = to_i2c_client(dev); |
@@ -427,19 +416,15 @@ static int ds1374_resume(struct device *dev) | |||
427 | disable_irq_wake(client->irq); | 416 | disable_irq_wake(client->irq); |
428 | return 0; | 417 | return 0; |
429 | } | 418 | } |
419 | #endif | ||
430 | 420 | ||
431 | static SIMPLE_DEV_PM_OPS(ds1374_pm, ds1374_suspend, ds1374_resume); | 421 | static SIMPLE_DEV_PM_OPS(ds1374_pm, ds1374_suspend, ds1374_resume); |
432 | 422 | ||
433 | #define DS1374_PM (&ds1374_pm) | ||
434 | #else | ||
435 | #define DS1374_PM NULL | ||
436 | #endif | ||
437 | |||
438 | static struct i2c_driver ds1374_driver = { | 423 | static struct i2c_driver ds1374_driver = { |
439 | .driver = { | 424 | .driver = { |
440 | .name = "rtc-ds1374", | 425 | .name = "rtc-ds1374", |
441 | .owner = THIS_MODULE, | 426 | .owner = THIS_MODULE, |
442 | .pm = DS1374_PM, | 427 | .pm = &ds1374_pm, |
443 | }, | 428 | }, |
444 | .probe = ds1374_probe, | 429 | .probe = ds1374_probe, |
445 | .remove = ds1374_remove, | 430 | .remove = ds1374_remove, |
diff --git a/drivers/rtc/rtc-ds1390.c b/drivers/rtc/rtc-ds1390.c index f994257981a0..289af419dff4 100644 --- a/drivers/rtc/rtc-ds1390.c +++ b/drivers/rtc/rtc-ds1390.c | |||
@@ -131,26 +131,24 @@ static int ds1390_probe(struct spi_device *spi) | |||
131 | spi->bits_per_word = 8; | 131 | spi->bits_per_word = 8; |
132 | spi_setup(spi); | 132 | spi_setup(spi); |
133 | 133 | ||
134 | chip = kzalloc(sizeof *chip, GFP_KERNEL); | 134 | chip = devm_kzalloc(&spi->dev, sizeof(*chip), GFP_KERNEL); |
135 | if (!chip) { | 135 | if (!chip) { |
136 | dev_err(&spi->dev, "unable to allocate device memory\n"); | 136 | dev_err(&spi->dev, "unable to allocate device memory\n"); |
137 | return -ENOMEM; | 137 | return -ENOMEM; |
138 | } | 138 | } |
139 | dev_set_drvdata(&spi->dev, chip); | 139 | spi_set_drvdata(spi, chip); |
140 | 140 | ||
141 | res = ds1390_get_reg(&spi->dev, DS1390_REG_SECONDS, &tmp); | 141 | res = ds1390_get_reg(&spi->dev, DS1390_REG_SECONDS, &tmp); |
142 | if (res != 0) { | 142 | if (res != 0) { |
143 | dev_err(&spi->dev, "unable to read device\n"); | 143 | dev_err(&spi->dev, "unable to read device\n"); |
144 | kfree(chip); | ||
145 | return res; | 144 | return res; |
146 | } | 145 | } |
147 | 146 | ||
148 | chip->rtc = rtc_device_register("ds1390", | 147 | chip->rtc = devm_rtc_device_register(&spi->dev, "ds1390", |
149 | &spi->dev, &ds1390_rtc_ops, THIS_MODULE); | 148 | &ds1390_rtc_ops, THIS_MODULE); |
150 | if (IS_ERR(chip->rtc)) { | 149 | if (IS_ERR(chip->rtc)) { |
151 | dev_err(&spi->dev, "unable to register device\n"); | 150 | dev_err(&spi->dev, "unable to register device\n"); |
152 | res = PTR_ERR(chip->rtc); | 151 | res = PTR_ERR(chip->rtc); |
153 | kfree(chip); | ||
154 | } | 152 | } |
155 | 153 | ||
156 | return res; | 154 | return res; |
@@ -158,11 +156,6 @@ static int ds1390_probe(struct spi_device *spi) | |||
158 | 156 | ||
159 | static int ds1390_remove(struct spi_device *spi) | 157 | static int ds1390_remove(struct spi_device *spi) |
160 | { | 158 | { |
161 | struct ds1390 *chip = spi_get_drvdata(spi); | ||
162 | |||
163 | rtc_device_unregister(chip->rtc); | ||
164 | kfree(chip); | ||
165 | |||
166 | return 0; | 159 | return 0; |
167 | } | 160 | } |
168 | 161 | ||
diff --git a/drivers/rtc/rtc-ds1511.c b/drivers/rtc/rtc-ds1511.c index 6a3fcfe3b0e7..6ce8a997cf51 100644 --- a/drivers/rtc/rtc-ds1511.c +++ b/drivers/rtc/rtc-ds1511.c | |||
@@ -538,15 +538,14 @@ static int ds1511_rtc_probe(struct platform_device *pdev) | |||
538 | } | 538 | } |
539 | } | 539 | } |
540 | 540 | ||
541 | rtc = rtc_device_register(pdev->name, &pdev->dev, &ds1511_rtc_ops, | 541 | rtc = devm_rtc_device_register(&pdev->dev, pdev->name, &ds1511_rtc_ops, |
542 | THIS_MODULE); | 542 | THIS_MODULE); |
543 | if (IS_ERR(rtc)) | 543 | if (IS_ERR(rtc)) |
544 | return PTR_ERR(rtc); | 544 | return PTR_ERR(rtc); |
545 | pdata->rtc = rtc; | 545 | pdata->rtc = rtc; |
546 | 546 | ||
547 | ret = sysfs_create_bin_file(&pdev->dev.kobj, &ds1511_nvram_attr); | 547 | ret = sysfs_create_bin_file(&pdev->dev.kobj, &ds1511_nvram_attr); |
548 | if (ret) | 548 | |
549 | rtc_device_unregister(pdata->rtc); | ||
550 | return ret; | 549 | return ret; |
551 | } | 550 | } |
552 | 551 | ||
@@ -555,7 +554,6 @@ static int ds1511_rtc_remove(struct platform_device *pdev) | |||
555 | struct rtc_plat_data *pdata = platform_get_drvdata(pdev); | 554 | struct rtc_plat_data *pdata = platform_get_drvdata(pdev); |
556 | 555 | ||
557 | sysfs_remove_bin_file(&pdev->dev.kobj, &ds1511_nvram_attr); | 556 | sysfs_remove_bin_file(&pdev->dev.kobj, &ds1511_nvram_attr); |
558 | rtc_device_unregister(pdata->rtc); | ||
559 | if (pdata->irq > 0) { | 557 | if (pdata->irq > 0) { |
560 | /* | 558 | /* |
561 | * disable the alarm interrupt | 559 | * disable the alarm interrupt |
diff --git a/drivers/rtc/rtc-ds1553.c b/drivers/rtc/rtc-ds1553.c index 25ce0621ade9..8c6c952e90b1 100644 --- a/drivers/rtc/rtc-ds1553.c +++ b/drivers/rtc/rtc-ds1553.c | |||
@@ -326,15 +326,14 @@ static int ds1553_rtc_probe(struct platform_device *pdev) | |||
326 | } | 326 | } |
327 | } | 327 | } |
328 | 328 | ||
329 | rtc = rtc_device_register(pdev->name, &pdev->dev, | 329 | rtc = devm_rtc_device_register(&pdev->dev, pdev->name, |
330 | &ds1553_rtc_ops, THIS_MODULE); | 330 | &ds1553_rtc_ops, THIS_MODULE); |
331 | if (IS_ERR(rtc)) | 331 | if (IS_ERR(rtc)) |
332 | return PTR_ERR(rtc); | 332 | return PTR_ERR(rtc); |
333 | pdata->rtc = rtc; | 333 | pdata->rtc = rtc; |
334 | 334 | ||
335 | ret = sysfs_create_bin_file(&pdev->dev.kobj, &ds1553_nvram_attr); | 335 | ret = sysfs_create_bin_file(&pdev->dev.kobj, &ds1553_nvram_attr); |
336 | if (ret) | 336 | |
337 | rtc_device_unregister(rtc); | ||
338 | return ret; | 337 | return ret; |
339 | } | 338 | } |
340 | 339 | ||
@@ -343,7 +342,6 @@ static int ds1553_rtc_remove(struct platform_device *pdev) | |||
343 | struct rtc_plat_data *pdata = platform_get_drvdata(pdev); | 342 | struct rtc_plat_data *pdata = platform_get_drvdata(pdev); |
344 | 343 | ||
345 | sysfs_remove_bin_file(&pdev->dev.kobj, &ds1553_nvram_attr); | 344 | sysfs_remove_bin_file(&pdev->dev.kobj, &ds1553_nvram_attr); |
346 | rtc_device_unregister(pdata->rtc); | ||
347 | if (pdata->irq > 0) | 345 | if (pdata->irq > 0) |
348 | writeb(0, pdata->ioaddr + RTC_INTERRUPTS); | 346 | writeb(0, pdata->ioaddr + RTC_INTERRUPTS); |
349 | return 0; | 347 | return 0; |
diff --git a/drivers/rtc/rtc-ds1672.c b/drivers/rtc/rtc-ds1672.c index 45d65c0b3a85..3fc2a4738027 100644 --- a/drivers/rtc/rtc-ds1672.c +++ b/drivers/rtc/rtc-ds1672.c | |||
@@ -155,11 +155,6 @@ static const struct rtc_class_ops ds1672_rtc_ops = { | |||
155 | 155 | ||
156 | static int ds1672_remove(struct i2c_client *client) | 156 | static int ds1672_remove(struct i2c_client *client) |
157 | { | 157 | { |
158 | struct rtc_device *rtc = i2c_get_clientdata(client); | ||
159 | |||
160 | if (rtc) | ||
161 | rtc_device_unregister(rtc); | ||
162 | |||
163 | return 0; | 158 | return 0; |
164 | } | 159 | } |
165 | 160 | ||
@@ -177,7 +172,7 @@ static int ds1672_probe(struct i2c_client *client, | |||
177 | 172 | ||
178 | dev_info(&client->dev, "chip found, driver version " DRV_VERSION "\n"); | 173 | dev_info(&client->dev, "chip found, driver version " DRV_VERSION "\n"); |
179 | 174 | ||
180 | rtc = rtc_device_register(ds1672_driver.driver.name, &client->dev, | 175 | rtc = devm_rtc_device_register(&client->dev, ds1672_driver.driver.name, |
181 | &ds1672_rtc_ops, THIS_MODULE); | 176 | &ds1672_rtc_ops, THIS_MODULE); |
182 | 177 | ||
183 | if (IS_ERR(rtc)) | 178 | if (IS_ERR(rtc)) |
@@ -202,7 +197,6 @@ static int ds1672_probe(struct i2c_client *client, | |||
202 | return 0; | 197 | return 0; |
203 | 198 | ||
204 | exit_devreg: | 199 | exit_devreg: |
205 | rtc_device_unregister(rtc); | ||
206 | return err; | 200 | return err; |
207 | } | 201 | } |
208 | 202 | ||
diff --git a/drivers/rtc/rtc-ds1742.c b/drivers/rtc/rtc-ds1742.c index 609c870e2cc5..eccdc62ae1c0 100644 --- a/drivers/rtc/rtc-ds1742.c +++ b/drivers/rtc/rtc-ds1742.c | |||
@@ -208,17 +208,14 @@ static int ds1742_rtc_probe(struct platform_device *pdev) | |||
208 | 208 | ||
209 | pdata->last_jiffies = jiffies; | 209 | pdata->last_jiffies = jiffies; |
210 | platform_set_drvdata(pdev, pdata); | 210 | platform_set_drvdata(pdev, pdata); |
211 | rtc = rtc_device_register(pdev->name, &pdev->dev, | 211 | rtc = devm_rtc_device_register(&pdev->dev, pdev->name, |
212 | &ds1742_rtc_ops, THIS_MODULE); | 212 | &ds1742_rtc_ops, THIS_MODULE); |
213 | if (IS_ERR(rtc)) | 213 | if (IS_ERR(rtc)) |
214 | return PTR_ERR(rtc); | 214 | return PTR_ERR(rtc); |
215 | pdata->rtc = rtc; | 215 | pdata->rtc = rtc; |
216 | 216 | ||
217 | ret = sysfs_create_bin_file(&pdev->dev.kobj, &pdata->nvram_attr); | 217 | ret = sysfs_create_bin_file(&pdev->dev.kobj, &pdata->nvram_attr); |
218 | if (ret) { | 218 | |
219 | dev_err(&pdev->dev, "creating nvram file in sysfs failed\n"); | ||
220 | rtc_device_unregister(rtc); | ||
221 | } | ||
222 | return ret; | 219 | return ret; |
223 | } | 220 | } |
224 | 221 | ||
@@ -227,7 +224,6 @@ static int ds1742_rtc_remove(struct platform_device *pdev) | |||
227 | struct rtc_plat_data *pdata = platform_get_drvdata(pdev); | 224 | struct rtc_plat_data *pdata = platform_get_drvdata(pdev); |
228 | 225 | ||
229 | sysfs_remove_bin_file(&pdev->dev.kobj, &pdata->nvram_attr); | 226 | sysfs_remove_bin_file(&pdev->dev.kobj, &pdata->nvram_attr); |
230 | rtc_device_unregister(pdata->rtc); | ||
231 | return 0; | 227 | return 0; |
232 | } | 228 | } |
233 | 229 | ||
diff --git a/drivers/rtc/rtc-ds2404.c b/drivers/rtc/rtc-ds2404.c index b04fc4272fb3..2ca5a23aba8a 100644 --- a/drivers/rtc/rtc-ds2404.c +++ b/drivers/rtc/rtc-ds2404.c | |||
@@ -228,7 +228,7 @@ static int rtc_probe(struct platform_device *pdev) | |||
228 | struct ds2404 *chip; | 228 | struct ds2404 *chip; |
229 | int retval = -EBUSY; | 229 | int retval = -EBUSY; |
230 | 230 | ||
231 | chip = kzalloc(sizeof(struct ds2404), GFP_KERNEL); | 231 | chip = devm_kzalloc(&pdev->dev, sizeof(struct ds2404), GFP_KERNEL); |
232 | if (!chip) | 232 | if (!chip) |
233 | return -ENOMEM; | 233 | return -ENOMEM; |
234 | 234 | ||
@@ -244,8 +244,8 @@ static int rtc_probe(struct platform_device *pdev) | |||
244 | 244 | ||
245 | platform_set_drvdata(pdev, chip); | 245 | platform_set_drvdata(pdev, chip); |
246 | 246 | ||
247 | chip->rtc = rtc_device_register("ds2404", | 247 | chip->rtc = devm_rtc_device_register(&pdev->dev, "ds2404", |
248 | &pdev->dev, &ds2404_rtc_ops, THIS_MODULE); | 248 | &ds2404_rtc_ops, THIS_MODULE); |
249 | if (IS_ERR(chip->rtc)) { | 249 | if (IS_ERR(chip->rtc)) { |
250 | retval = PTR_ERR(chip->rtc); | 250 | retval = PTR_ERR(chip->rtc); |
251 | goto err_io; | 251 | goto err_io; |
@@ -257,20 +257,14 @@ static int rtc_probe(struct platform_device *pdev) | |||
257 | err_io: | 257 | err_io: |
258 | chip->ops->unmap_io(chip); | 258 | chip->ops->unmap_io(chip); |
259 | err_chip: | 259 | err_chip: |
260 | kfree(chip); | ||
261 | return retval; | 260 | return retval; |
262 | } | 261 | } |
263 | 262 | ||
264 | static int rtc_remove(struct platform_device *dev) | 263 | static int rtc_remove(struct platform_device *dev) |
265 | { | 264 | { |
266 | struct ds2404 *chip = platform_get_drvdata(dev); | 265 | struct ds2404 *chip = platform_get_drvdata(dev); |
267 | struct rtc_device *rtc = chip->rtc; | ||
268 | |||
269 | if (rtc) | ||
270 | rtc_device_unregister(rtc); | ||
271 | 266 | ||
272 | chip->ops->unmap_io(chip); | 267 | chip->ops->unmap_io(chip); |
273 | kfree(chip); | ||
274 | 268 | ||
275 | return 0; | 269 | return 0; |
276 | } | 270 | } |
diff --git a/drivers/rtc/rtc-ds3232.c b/drivers/rtc/rtc-ds3232.c index db0ca08db315..b83bb5a527f8 100644 --- a/drivers/rtc/rtc-ds3232.c +++ b/drivers/rtc/rtc-ds3232.c | |||
@@ -397,7 +397,7 @@ static int ds3232_probe(struct i2c_client *client, | |||
397 | struct ds3232 *ds3232; | 397 | struct ds3232 *ds3232; |
398 | int ret; | 398 | int ret; |
399 | 399 | ||
400 | ds3232 = kzalloc(sizeof(struct ds3232), GFP_KERNEL); | 400 | ds3232 = devm_kzalloc(&client->dev, sizeof(struct ds3232), GFP_KERNEL); |
401 | if (!ds3232) | 401 | if (!ds3232) |
402 | return -ENOMEM; | 402 | return -ENOMEM; |
403 | 403 | ||
@@ -409,34 +409,25 @@ static int ds3232_probe(struct i2c_client *client, | |||
409 | 409 | ||
410 | ret = ds3232_check_rtc_status(client); | 410 | ret = ds3232_check_rtc_status(client); |
411 | if (ret) | 411 | if (ret) |
412 | goto out_free; | 412 | return ret; |
413 | 413 | ||
414 | ds3232->rtc = rtc_device_register(client->name, &client->dev, | 414 | ds3232->rtc = devm_rtc_device_register(&client->dev, client->name, |
415 | &ds3232_rtc_ops, THIS_MODULE); | 415 | &ds3232_rtc_ops, THIS_MODULE); |
416 | if (IS_ERR(ds3232->rtc)) { | 416 | if (IS_ERR(ds3232->rtc)) { |
417 | ret = PTR_ERR(ds3232->rtc); | ||
418 | dev_err(&client->dev, "unable to register the class device\n"); | 417 | dev_err(&client->dev, "unable to register the class device\n"); |
419 | goto out_irq; | 418 | return PTR_ERR(ds3232->rtc); |
420 | } | 419 | } |
421 | 420 | ||
422 | if (client->irq >= 0) { | 421 | if (client->irq >= 0) { |
423 | ret = request_irq(client->irq, ds3232_irq, 0, | 422 | ret = devm_request_irq(&client->dev, client->irq, ds3232_irq, 0, |
424 | "ds3232", client); | 423 | "ds3232", client); |
425 | if (ret) { | 424 | if (ret) { |
426 | dev_err(&client->dev, "unable to request IRQ\n"); | 425 | dev_err(&client->dev, "unable to request IRQ\n"); |
427 | goto out_free; | 426 | return ret; |
428 | } | 427 | } |
429 | } | 428 | } |
430 | 429 | ||
431 | return 0; | 430 | return 0; |
432 | |||
433 | out_irq: | ||
434 | if (client->irq >= 0) | ||
435 | free_irq(client->irq, client); | ||
436 | |||
437 | out_free: | ||
438 | kfree(ds3232); | ||
439 | return ret; | ||
440 | } | 431 | } |
441 | 432 | ||
442 | static int ds3232_remove(struct i2c_client *client) | 433 | static int ds3232_remove(struct i2c_client *client) |
@@ -448,12 +439,10 @@ static int ds3232_remove(struct i2c_client *client) | |||
448 | ds3232->exiting = 1; | 439 | ds3232->exiting = 1; |
449 | mutex_unlock(&ds3232->mutex); | 440 | mutex_unlock(&ds3232->mutex); |
450 | 441 | ||
451 | free_irq(client->irq, client); | 442 | devm_free_irq(&client->dev, client->irq, client); |
452 | cancel_work_sync(&ds3232->work); | 443 | cancel_work_sync(&ds3232->work); |
453 | } | 444 | } |
454 | 445 | ||
455 | rtc_device_unregister(ds3232->rtc); | ||
456 | kfree(ds3232); | ||
457 | return 0; | 446 | return 0; |
458 | } | 447 | } |
459 | 448 | ||
diff --git a/drivers/rtc/rtc-ds3234.c b/drivers/rtc/rtc-ds3234.c index 7a4495ef1c39..ba98c0e9580d 100644 --- a/drivers/rtc/rtc-ds3234.c +++ b/drivers/rtc/rtc-ds3234.c | |||
@@ -146,21 +146,18 @@ static int ds3234_probe(struct spi_device *spi) | |||
146 | ds3234_get_reg(&spi->dev, DS3234_REG_CONT_STAT, &tmp); | 146 | ds3234_get_reg(&spi->dev, DS3234_REG_CONT_STAT, &tmp); |
147 | dev_info(&spi->dev, "Ctrl/Stat Reg: 0x%02x\n", tmp); | 147 | dev_info(&spi->dev, "Ctrl/Stat Reg: 0x%02x\n", tmp); |
148 | 148 | ||
149 | rtc = rtc_device_register("ds3234", | 149 | rtc = devm_rtc_device_register(&spi->dev, "ds3234", |
150 | &spi->dev, &ds3234_rtc_ops, THIS_MODULE); | 150 | &ds3234_rtc_ops, THIS_MODULE); |
151 | if (IS_ERR(rtc)) | 151 | if (IS_ERR(rtc)) |
152 | return PTR_ERR(rtc); | 152 | return PTR_ERR(rtc); |
153 | 153 | ||
154 | dev_set_drvdata(&spi->dev, rtc); | 154 | spi_set_drvdata(spi, rtc); |
155 | 155 | ||
156 | return 0; | 156 | return 0; |
157 | } | 157 | } |
158 | 158 | ||
159 | static int ds3234_remove(struct spi_device *spi) | 159 | static int ds3234_remove(struct spi_device *spi) |
160 | { | 160 | { |
161 | struct rtc_device *rtc = spi_get_drvdata(spi); | ||
162 | |||
163 | rtc_device_unregister(rtc); | ||
164 | return 0; | 161 | return 0; |
165 | } | 162 | } |
166 | 163 | ||
diff --git a/drivers/rtc/rtc-efi.c b/drivers/rtc/rtc-efi.c index 1a0c37c9152b..b3c8c0b1709d 100644 --- a/drivers/rtc/rtc-efi.c +++ b/drivers/rtc/rtc-efi.c | |||
@@ -191,7 +191,7 @@ static int __init efi_rtc_probe(struct platform_device *dev) | |||
191 | { | 191 | { |
192 | struct rtc_device *rtc; | 192 | struct rtc_device *rtc; |
193 | 193 | ||
194 | rtc = rtc_device_register("rtc-efi", &dev->dev, &efi_rtc_ops, | 194 | rtc = devm_rtc_device_register(&dev->dev, "rtc-efi", &efi_rtc_ops, |
195 | THIS_MODULE); | 195 | THIS_MODULE); |
196 | if (IS_ERR(rtc)) | 196 | if (IS_ERR(rtc)) |
197 | return PTR_ERR(rtc); | 197 | return PTR_ERR(rtc); |
@@ -203,10 +203,6 @@ static int __init efi_rtc_probe(struct platform_device *dev) | |||
203 | 203 | ||
204 | static int __exit efi_rtc_remove(struct platform_device *dev) | 204 | static int __exit efi_rtc_remove(struct platform_device *dev) |
205 | { | 205 | { |
206 | struct rtc_device *rtc = platform_get_drvdata(dev); | ||
207 | |||
208 | rtc_device_unregister(rtc); | ||
209 | |||
210 | return 0; | 206 | return 0; |
211 | } | 207 | } |
212 | 208 | ||
@@ -218,18 +214,7 @@ static struct platform_driver efi_rtc_driver = { | |||
218 | .remove = __exit_p(efi_rtc_remove), | 214 | .remove = __exit_p(efi_rtc_remove), |
219 | }; | 215 | }; |
220 | 216 | ||
221 | static int __init efi_rtc_init(void) | 217 | module_platform_driver_probe(efi_rtc_driver, efi_rtc_probe); |
222 | { | ||
223 | return platform_driver_probe(&efi_rtc_driver, efi_rtc_probe); | ||
224 | } | ||
225 | |||
226 | static void __exit efi_rtc_exit(void) | ||
227 | { | ||
228 | platform_driver_unregister(&efi_rtc_driver); | ||
229 | } | ||
230 | |||
231 | module_init(efi_rtc_init); | ||
232 | module_exit(efi_rtc_exit); | ||
233 | 218 | ||
234 | MODULE_AUTHOR("dann frazier <dannf@hp.com>"); | 219 | MODULE_AUTHOR("dann frazier <dannf@hp.com>"); |
235 | MODULE_LICENSE("GPL"); | 220 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/rtc/rtc-em3027.c b/drivers/rtc/rtc-em3027.c index f6c24ce35d36..3f9eb57d0486 100644 --- a/drivers/rtc/rtc-em3027.c +++ b/drivers/rtc/rtc-em3027.c | |||
@@ -121,7 +121,7 @@ static int em3027_probe(struct i2c_client *client, | |||
121 | if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) | 121 | if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) |
122 | return -ENODEV; | 122 | return -ENODEV; |
123 | 123 | ||
124 | rtc = rtc_device_register(em3027_driver.driver.name, &client->dev, | 124 | rtc = devm_rtc_device_register(&client->dev, em3027_driver.driver.name, |
125 | &em3027_rtc_ops, THIS_MODULE); | 125 | &em3027_rtc_ops, THIS_MODULE); |
126 | if (IS_ERR(rtc)) | 126 | if (IS_ERR(rtc)) |
127 | return PTR_ERR(rtc); | 127 | return PTR_ERR(rtc); |
@@ -133,11 +133,6 @@ static int em3027_probe(struct i2c_client *client, | |||
133 | 133 | ||
134 | static int em3027_remove(struct i2c_client *client) | 134 | static int em3027_remove(struct i2c_client *client) |
135 | { | 135 | { |
136 | struct rtc_device *rtc = i2c_get_clientdata(client); | ||
137 | |||
138 | if (rtc) | ||
139 | rtc_device_unregister(rtc); | ||
140 | |||
141 | return 0; | 136 | return 0; |
142 | } | 137 | } |
143 | 138 | ||
diff --git a/drivers/rtc/rtc-ep93xx.c b/drivers/rtc/rtc-ep93xx.c index 1a4e5e4a70cd..5807b77c444a 100644 --- a/drivers/rtc/rtc-ep93xx.c +++ b/drivers/rtc/rtc-ep93xx.c | |||
@@ -153,8 +153,8 @@ static int ep93xx_rtc_probe(struct platform_device *pdev) | |||
153 | pdev->dev.platform_data = ep93xx_rtc; | 153 | pdev->dev.platform_data = ep93xx_rtc; |
154 | platform_set_drvdata(pdev, ep93xx_rtc); | 154 | platform_set_drvdata(pdev, ep93xx_rtc); |
155 | 155 | ||
156 | ep93xx_rtc->rtc = rtc_device_register(pdev->name, | 156 | ep93xx_rtc->rtc = devm_rtc_device_register(&pdev->dev, |
157 | &pdev->dev, &ep93xx_rtc_ops, THIS_MODULE); | 157 | pdev->name, &ep93xx_rtc_ops, THIS_MODULE); |
158 | if (IS_ERR(ep93xx_rtc->rtc)) { | 158 | if (IS_ERR(ep93xx_rtc->rtc)) { |
159 | err = PTR_ERR(ep93xx_rtc->rtc); | 159 | err = PTR_ERR(ep93xx_rtc->rtc); |
160 | goto exit; | 160 | goto exit; |
@@ -162,12 +162,10 @@ static int ep93xx_rtc_probe(struct platform_device *pdev) | |||
162 | 162 | ||
163 | err = sysfs_create_group(&pdev->dev.kobj, &ep93xx_rtc_sysfs_files); | 163 | err = sysfs_create_group(&pdev->dev.kobj, &ep93xx_rtc_sysfs_files); |
164 | if (err) | 164 | if (err) |
165 | goto fail; | 165 | goto exit; |
166 | 166 | ||
167 | return 0; | 167 | return 0; |
168 | 168 | ||
169 | fail: | ||
170 | rtc_device_unregister(ep93xx_rtc->rtc); | ||
171 | exit: | 169 | exit: |
172 | platform_set_drvdata(pdev, NULL); | 170 | platform_set_drvdata(pdev, NULL); |
173 | pdev->dev.platform_data = NULL; | 171 | pdev->dev.platform_data = NULL; |
@@ -176,11 +174,8 @@ exit: | |||
176 | 174 | ||
177 | static int ep93xx_rtc_remove(struct platform_device *pdev) | 175 | static int ep93xx_rtc_remove(struct platform_device *pdev) |
178 | { | 176 | { |
179 | struct ep93xx_rtc *ep93xx_rtc = platform_get_drvdata(pdev); | ||
180 | |||
181 | sysfs_remove_group(&pdev->dev.kobj, &ep93xx_rtc_sysfs_files); | 177 | sysfs_remove_group(&pdev->dev.kobj, &ep93xx_rtc_sysfs_files); |
182 | platform_set_drvdata(pdev, NULL); | 178 | platform_set_drvdata(pdev, NULL); |
183 | rtc_device_unregister(ep93xx_rtc->rtc); | ||
184 | pdev->dev.platform_data = NULL; | 179 | pdev->dev.platform_data = NULL; |
185 | 180 | ||
186 | return 0; | 181 | return 0; |
diff --git a/drivers/rtc/rtc-fm3130.c b/drivers/rtc/rtc-fm3130.c index bff3cdc5140e..2835fb6c1965 100644 --- a/drivers/rtc/rtc-fm3130.c +++ b/drivers/rtc/rtc-fm3130.c | |||
@@ -358,7 +358,7 @@ static int fm3130_probe(struct i2c_client *client, | |||
358 | I2C_FUNC_I2C | I2C_FUNC_SMBUS_WRITE_BYTE_DATA)) | 358 | I2C_FUNC_I2C | I2C_FUNC_SMBUS_WRITE_BYTE_DATA)) |
359 | return -EIO; | 359 | return -EIO; |
360 | 360 | ||
361 | fm3130 = kzalloc(sizeof(struct fm3130), GFP_KERNEL); | 361 | fm3130 = devm_kzalloc(&client->dev, sizeof(struct fm3130), GFP_KERNEL); |
362 | 362 | ||
363 | if (!fm3130) | 363 | if (!fm3130) |
364 | return -ENOMEM; | 364 | return -ENOMEM; |
@@ -395,7 +395,7 @@ static int fm3130_probe(struct i2c_client *client, | |||
395 | 395 | ||
396 | tmp = i2c_transfer(adapter, fm3130->msg, 4); | 396 | tmp = i2c_transfer(adapter, fm3130->msg, 4); |
397 | if (tmp != 4) { | 397 | if (tmp != 4) { |
398 | pr_debug("read error %d\n", tmp); | 398 | dev_dbg(&client->dev, "read error %d\n", tmp); |
399 | err = -EIO; | 399 | err = -EIO; |
400 | goto exit_free; | 400 | goto exit_free; |
401 | } | 401 | } |
@@ -507,7 +507,7 @@ bad_clock: | |||
507 | 507 | ||
508 | /* We won't bail out here because we just got invalid data. | 508 | /* We won't bail out here because we just got invalid data. |
509 | Time setting from u-boot doesn't work anyway */ | 509 | Time setting from u-boot doesn't work anyway */ |
510 | fm3130->rtc = rtc_device_register(client->name, &client->dev, | 510 | fm3130->rtc = devm_rtc_device_register(&client->dev, client->name, |
511 | &fm3130_rtc_ops, THIS_MODULE); | 511 | &fm3130_rtc_ops, THIS_MODULE); |
512 | if (IS_ERR(fm3130->rtc)) { | 512 | if (IS_ERR(fm3130->rtc)) { |
513 | err = PTR_ERR(fm3130->rtc); | 513 | err = PTR_ERR(fm3130->rtc); |
@@ -517,16 +517,11 @@ bad_clock: | |||
517 | } | 517 | } |
518 | return 0; | 518 | return 0; |
519 | exit_free: | 519 | exit_free: |
520 | kfree(fm3130); | ||
521 | return err; | 520 | return err; |
522 | } | 521 | } |
523 | 522 | ||
524 | static int fm3130_remove(struct i2c_client *client) | 523 | static int fm3130_remove(struct i2c_client *client) |
525 | { | 524 | { |
526 | struct fm3130 *fm3130 = i2c_get_clientdata(client); | ||
527 | |||
528 | rtc_device_unregister(fm3130->rtc); | ||
529 | kfree(fm3130); | ||
530 | return 0; | 525 | return 0; |
531 | } | 526 | } |
532 | 527 | ||
diff --git a/drivers/rtc/rtc-generic.c b/drivers/rtc/rtc-generic.c index 98322004ad2e..06279ce6bff2 100644 --- a/drivers/rtc/rtc-generic.c +++ b/drivers/rtc/rtc-generic.c | |||
@@ -38,8 +38,8 @@ static int __init generic_rtc_probe(struct platform_device *dev) | |||
38 | { | 38 | { |
39 | struct rtc_device *rtc; | 39 | struct rtc_device *rtc; |
40 | 40 | ||
41 | rtc = rtc_device_register("rtc-generic", &dev->dev, &generic_rtc_ops, | 41 | rtc = devm_rtc_device_register(&dev->dev, "rtc-generic", |
42 | THIS_MODULE); | 42 | &generic_rtc_ops, THIS_MODULE); |
43 | if (IS_ERR(rtc)) | 43 | if (IS_ERR(rtc)) |
44 | return PTR_ERR(rtc); | 44 | return PTR_ERR(rtc); |
45 | 45 | ||
@@ -50,10 +50,6 @@ static int __init generic_rtc_probe(struct platform_device *dev) | |||
50 | 50 | ||
51 | static int __exit generic_rtc_remove(struct platform_device *dev) | 51 | static int __exit generic_rtc_remove(struct platform_device *dev) |
52 | { | 52 | { |
53 | struct rtc_device *rtc = platform_get_drvdata(dev); | ||
54 | |||
55 | rtc_device_unregister(rtc); | ||
56 | |||
57 | return 0; | 53 | return 0; |
58 | } | 54 | } |
59 | 55 | ||
@@ -65,18 +61,7 @@ static struct platform_driver generic_rtc_driver = { | |||
65 | .remove = __exit_p(generic_rtc_remove), | 61 | .remove = __exit_p(generic_rtc_remove), |
66 | }; | 62 | }; |
67 | 63 | ||
68 | static int __init generic_rtc_init(void) | 64 | module_platform_driver_probe(generic_rtc_driver, generic_rtc_probe); |
69 | { | ||
70 | return platform_driver_probe(&generic_rtc_driver, generic_rtc_probe); | ||
71 | } | ||
72 | |||
73 | static void __exit generic_rtc_fini(void) | ||
74 | { | ||
75 | platform_driver_unregister(&generic_rtc_driver); | ||
76 | } | ||
77 | |||
78 | module_init(generic_rtc_init); | ||
79 | module_exit(generic_rtc_fini); | ||
80 | 65 | ||
81 | MODULE_AUTHOR("Kyle McMartin <kyle@mcmartin.ca>"); | 66 | MODULE_AUTHOR("Kyle McMartin <kyle@mcmartin.ca>"); |
82 | MODULE_LICENSE("GPL"); | 67 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/rtc/rtc-hid-sensor-time.c b/drivers/rtc/rtc-hid-sensor-time.c index 31c5728ef629..63024505dddc 100644 --- a/drivers/rtc/rtc-hid-sensor-time.c +++ b/drivers/rtc/rtc-hid-sensor-time.c | |||
@@ -255,8 +255,9 @@ static int hid_time_probe(struct platform_device *pdev) | |||
255 | return ret; | 255 | return ret; |
256 | } | 256 | } |
257 | 257 | ||
258 | time_state->rtc = rtc_device_register("hid-sensor-time", | 258 | time_state->rtc = devm_rtc_device_register(&pdev->dev, |
259 | &pdev->dev, &hid_time_rtc_ops, THIS_MODULE); | 259 | "hid-sensor-time", &hid_time_rtc_ops, |
260 | THIS_MODULE); | ||
260 | 261 | ||
261 | if (IS_ERR(time_state->rtc)) { | 262 | if (IS_ERR(time_state->rtc)) { |
262 | dev_err(&pdev->dev, "rtc device register failed!\n"); | 263 | dev_err(&pdev->dev, "rtc device register failed!\n"); |
@@ -269,9 +270,7 @@ static int hid_time_probe(struct platform_device *pdev) | |||
269 | static int hid_time_remove(struct platform_device *pdev) | 270 | static int hid_time_remove(struct platform_device *pdev) |
270 | { | 271 | { |
271 | struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data; | 272 | struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data; |
272 | struct hid_time_state *time_state = platform_get_drvdata(pdev); | ||
273 | 273 | ||
274 | rtc_device_unregister(time_state->rtc); | ||
275 | sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_TIME); | 274 | sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_TIME); |
276 | 275 | ||
277 | return 0; | 276 | return 0; |
diff --git a/drivers/rtc/rtc-imxdi.c b/drivers/rtc/rtc-imxdi.c index 82aad695979e..d3a8c8e255de 100644 --- a/drivers/rtc/rtc-imxdi.c +++ b/drivers/rtc/rtc-imxdi.c | |||
@@ -369,7 +369,7 @@ static void dryice_work(struct work_struct *work) | |||
369 | /* | 369 | /* |
370 | * probe for dryice rtc device | 370 | * probe for dryice rtc device |
371 | */ | 371 | */ |
372 | static int dryice_rtc_probe(struct platform_device *pdev) | 372 | static int __init dryice_rtc_probe(struct platform_device *pdev) |
373 | { | 373 | { |
374 | struct resource *res; | 374 | struct resource *res; |
375 | struct imxdi_dev *imxdi; | 375 | struct imxdi_dev *imxdi; |
@@ -464,7 +464,7 @@ static int dryice_rtc_probe(struct platform_device *pdev) | |||
464 | } | 464 | } |
465 | 465 | ||
466 | platform_set_drvdata(pdev, imxdi); | 466 | platform_set_drvdata(pdev, imxdi); |
467 | imxdi->rtc = rtc_device_register(pdev->name, &pdev->dev, | 467 | imxdi->rtc = devm_rtc_device_register(&pdev->dev, pdev->name, |
468 | &dryice_rtc_ops, THIS_MODULE); | 468 | &dryice_rtc_ops, THIS_MODULE); |
469 | if (IS_ERR(imxdi->rtc)) { | 469 | if (IS_ERR(imxdi->rtc)) { |
470 | rc = PTR_ERR(imxdi->rtc); | 470 | rc = PTR_ERR(imxdi->rtc); |
@@ -479,7 +479,7 @@ err: | |||
479 | return rc; | 479 | return rc; |
480 | } | 480 | } |
481 | 481 | ||
482 | static int dryice_rtc_remove(struct platform_device *pdev) | 482 | static int __exit dryice_rtc_remove(struct platform_device *pdev) |
483 | { | 483 | { |
484 | struct imxdi_dev *imxdi = platform_get_drvdata(pdev); | 484 | struct imxdi_dev *imxdi = platform_get_drvdata(pdev); |
485 | 485 | ||
@@ -488,8 +488,6 @@ static int dryice_rtc_remove(struct platform_device *pdev) | |||
488 | /* mask all interrupts */ | 488 | /* mask all interrupts */ |
489 | __raw_writel(0, imxdi->ioaddr + DIER); | 489 | __raw_writel(0, imxdi->ioaddr + DIER); |
490 | 490 | ||
491 | rtc_device_unregister(imxdi->rtc); | ||
492 | |||
493 | clk_disable_unprepare(imxdi->clk); | 491 | clk_disable_unprepare(imxdi->clk); |
494 | 492 | ||
495 | return 0; | 493 | return 0; |
@@ -510,21 +508,10 @@ static struct platform_driver dryice_rtc_driver = { | |||
510 | .owner = THIS_MODULE, | 508 | .owner = THIS_MODULE, |
511 | .of_match_table = of_match_ptr(dryice_dt_ids), | 509 | .of_match_table = of_match_ptr(dryice_dt_ids), |
512 | }, | 510 | }, |
513 | .remove = dryice_rtc_remove, | 511 | .remove = __exit_p(dryice_rtc_remove), |
514 | }; | 512 | }; |
515 | 513 | ||
516 | static int __init dryice_rtc_init(void) | 514 | module_platform_driver_probe(dryice_rtc_driver, dryice_rtc_probe); |
517 | { | ||
518 | return platform_driver_probe(&dryice_rtc_driver, dryice_rtc_probe); | ||
519 | } | ||
520 | |||
521 | static void __exit dryice_rtc_exit(void) | ||
522 | { | ||
523 | platform_driver_unregister(&dryice_rtc_driver); | ||
524 | } | ||
525 | |||
526 | module_init(dryice_rtc_init); | ||
527 | module_exit(dryice_rtc_exit); | ||
528 | 515 | ||
529 | MODULE_AUTHOR("Freescale Semiconductor, Inc."); | 516 | MODULE_AUTHOR("Freescale Semiconductor, Inc."); |
530 | MODULE_AUTHOR("Baruch Siach <baruch@tkos.co.il>"); | 517 | MODULE_AUTHOR("Baruch Siach <baruch@tkos.co.il>"); |
diff --git a/drivers/rtc/rtc-isl12022.c b/drivers/rtc/rtc-isl12022.c index 6b4298ea683d..a1bbbb8de029 100644 --- a/drivers/rtc/rtc-isl12022.c +++ b/drivers/rtc/rtc-isl12022.c | |||
@@ -252,12 +252,11 @@ static int isl12022_probe(struct i2c_client *client, | |||
252 | { | 252 | { |
253 | struct isl12022 *isl12022; | 253 | struct isl12022 *isl12022; |
254 | 254 | ||
255 | int ret = 0; | ||
256 | |||
257 | if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) | 255 | if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) |
258 | return -ENODEV; | 256 | return -ENODEV; |
259 | 257 | ||
260 | isl12022 = kzalloc(sizeof(struct isl12022), GFP_KERNEL); | 258 | isl12022 = devm_kzalloc(&client->dev, sizeof(struct isl12022), |
259 | GFP_KERNEL); | ||
261 | if (!isl12022) | 260 | if (!isl12022) |
262 | return -ENOMEM; | 261 | return -ENOMEM; |
263 | 262 | ||
@@ -265,37 +264,22 @@ static int isl12022_probe(struct i2c_client *client, | |||
265 | 264 | ||
266 | i2c_set_clientdata(client, isl12022); | 265 | i2c_set_clientdata(client, isl12022); |
267 | 266 | ||
268 | isl12022->rtc = rtc_device_register(isl12022_driver.driver.name, | 267 | isl12022->rtc = devm_rtc_device_register(&client->dev, |
269 | &client->dev, | 268 | isl12022_driver.driver.name, |
270 | &isl12022_rtc_ops, | 269 | &isl12022_rtc_ops, THIS_MODULE); |
271 | THIS_MODULE); | 270 | if (IS_ERR(isl12022->rtc)) |
272 | 271 | return PTR_ERR(isl12022->rtc); | |
273 | if (IS_ERR(isl12022->rtc)) { | ||
274 | ret = PTR_ERR(isl12022->rtc); | ||
275 | goto exit_kfree; | ||
276 | } | ||
277 | 272 | ||
278 | return 0; | 273 | return 0; |
279 | |||
280 | exit_kfree: | ||
281 | kfree(isl12022); | ||
282 | |||
283 | return ret; | ||
284 | } | 274 | } |
285 | 275 | ||
286 | static int isl12022_remove(struct i2c_client *client) | 276 | static int isl12022_remove(struct i2c_client *client) |
287 | { | 277 | { |
288 | struct isl12022 *isl12022 = i2c_get_clientdata(client); | ||
289 | |||
290 | rtc_device_unregister(isl12022->rtc); | ||
291 | kfree(isl12022); | ||
292 | |||
293 | return 0; | 278 | return 0; |
294 | } | 279 | } |
295 | 280 | ||
296 | static const struct i2c_device_id isl12022_id[] = { | 281 | static const struct i2c_device_id isl12022_id[] = { |
297 | { "isl12022", 0 }, | 282 | { "isl12022", 0 }, |
298 | { "rtc8564", 0 }, | ||
299 | { } | 283 | { } |
300 | }; | 284 | }; |
301 | MODULE_DEVICE_TABLE(i2c, isl12022_id); | 285 | MODULE_DEVICE_TABLE(i2c, isl12022_id); |
diff --git a/drivers/rtc/rtc-lp8788.c b/drivers/rtc/rtc-lp8788.c index 9a4631218f41..9853ac15b296 100644 --- a/drivers/rtc/rtc-lp8788.c +++ b/drivers/rtc/rtc-lp8788.c | |||
@@ -299,7 +299,7 @@ static int lp8788_rtc_probe(struct platform_device *pdev) | |||
299 | 299 | ||
300 | device_init_wakeup(dev, 1); | 300 | device_init_wakeup(dev, 1); |
301 | 301 | ||
302 | rtc->rdev = rtc_device_register("lp8788_rtc", dev, | 302 | rtc->rdev = devm_rtc_device_register(dev, "lp8788_rtc", |
303 | &lp8788_rtc_ops, THIS_MODULE); | 303 | &lp8788_rtc_ops, THIS_MODULE); |
304 | if (IS_ERR(rtc->rdev)) { | 304 | if (IS_ERR(rtc->rdev)) { |
305 | dev_err(dev, "can not register rtc device\n"); | 305 | dev_err(dev, "can not register rtc device\n"); |
@@ -314,9 +314,6 @@ static int lp8788_rtc_probe(struct platform_device *pdev) | |||
314 | 314 | ||
315 | static int lp8788_rtc_remove(struct platform_device *pdev) | 315 | static int lp8788_rtc_remove(struct platform_device *pdev) |
316 | { | 316 | { |
317 | struct lp8788_rtc *rtc = platform_get_drvdata(pdev); | ||
318 | |||
319 | rtc_device_unregister(rtc->rdev); | ||
320 | platform_set_drvdata(pdev, NULL); | 317 | platform_set_drvdata(pdev, NULL); |
321 | 318 | ||
322 | return 0; | 319 | return 0; |
diff --git a/drivers/rtc/rtc-lpc32xx.c b/drivers/rtc/rtc-lpc32xx.c index 40a598332bac..787550d756e9 100644 --- a/drivers/rtc/rtc-lpc32xx.c +++ b/drivers/rtc/rtc-lpc32xx.c | |||
@@ -273,8 +273,8 @@ static int lpc32xx_rtc_probe(struct platform_device *pdev) | |||
273 | 273 | ||
274 | platform_set_drvdata(pdev, rtc); | 274 | platform_set_drvdata(pdev, rtc); |
275 | 275 | ||
276 | rtc->rtc = rtc_device_register(RTC_NAME, &pdev->dev, &lpc32xx_rtc_ops, | 276 | rtc->rtc = devm_rtc_device_register(&pdev->dev, RTC_NAME, |
277 | THIS_MODULE); | 277 | &lpc32xx_rtc_ops, THIS_MODULE); |
278 | if (IS_ERR(rtc->rtc)) { | 278 | if (IS_ERR(rtc->rtc)) { |
279 | dev_err(&pdev->dev, "Can't get RTC\n"); | 279 | dev_err(&pdev->dev, "Can't get RTC\n"); |
280 | platform_set_drvdata(pdev, NULL); | 280 | platform_set_drvdata(pdev, NULL); |
@@ -307,7 +307,6 @@ static int lpc32xx_rtc_remove(struct platform_device *pdev) | |||
307 | device_init_wakeup(&pdev->dev, 0); | 307 | device_init_wakeup(&pdev->dev, 0); |
308 | 308 | ||
309 | platform_set_drvdata(pdev, NULL); | 309 | platform_set_drvdata(pdev, NULL); |
310 | rtc_device_unregister(rtc->rtc); | ||
311 | 310 | ||
312 | return 0; | 311 | return 0; |
313 | } | 312 | } |
diff --git a/drivers/rtc/rtc-ls1x.c b/drivers/rtc/rtc-ls1x.c index f59b6349551a..db82f91f4562 100644 --- a/drivers/rtc/rtc-ls1x.c +++ b/drivers/rtc/rtc-ls1x.c | |||
@@ -172,7 +172,7 @@ static int ls1x_rtc_probe(struct platform_device *pdev) | |||
172 | while (readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_TTS) | 172 | while (readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_TTS) |
173 | usleep_range(1000, 3000); | 173 | usleep_range(1000, 3000); |
174 | 174 | ||
175 | rtcdev = rtc_device_register("ls1x-rtc", &pdev->dev, | 175 | rtcdev = devm_rtc_device_register(&pdev->dev, "ls1x-rtc", |
176 | &ls1x_rtc_ops , THIS_MODULE); | 176 | &ls1x_rtc_ops , THIS_MODULE); |
177 | if (IS_ERR(rtcdev)) { | 177 | if (IS_ERR(rtcdev)) { |
178 | ret = PTR_ERR(rtcdev); | 178 | ret = PTR_ERR(rtcdev); |
@@ -187,9 +187,6 @@ err: | |||
187 | 187 | ||
188 | static int ls1x_rtc_remove(struct platform_device *pdev) | 188 | static int ls1x_rtc_remove(struct platform_device *pdev) |
189 | { | 189 | { |
190 | struct rtc_device *rtcdev = platform_get_drvdata(pdev); | ||
191 | |||
192 | rtc_device_unregister(rtcdev); | ||
193 | platform_set_drvdata(pdev, NULL); | 190 | platform_set_drvdata(pdev, NULL); |
194 | 191 | ||
195 | return 0; | 192 | return 0; |
diff --git a/drivers/rtc/rtc-m41t80.c b/drivers/rtc/rtc-m41t80.c index b885bcd08908..89674b5e6efd 100644 --- a/drivers/rtc/rtc-m41t80.c +++ b/drivers/rtc/rtc-m41t80.c | |||
@@ -637,7 +637,8 @@ static int m41t80_probe(struct i2c_client *client, | |||
637 | dev_info(&client->dev, | 637 | dev_info(&client->dev, |
638 | "chip found, driver version " DRV_VERSION "\n"); | 638 | "chip found, driver version " DRV_VERSION "\n"); |
639 | 639 | ||
640 | clientdata = kzalloc(sizeof(*clientdata), GFP_KERNEL); | 640 | clientdata = devm_kzalloc(&client->dev, sizeof(*clientdata), |
641 | GFP_KERNEL); | ||
641 | if (!clientdata) { | 642 | if (!clientdata) { |
642 | rc = -ENOMEM; | 643 | rc = -ENOMEM; |
643 | goto exit; | 644 | goto exit; |
@@ -646,8 +647,8 @@ static int m41t80_probe(struct i2c_client *client, | |||
646 | clientdata->features = id->driver_data; | 647 | clientdata->features = id->driver_data; |
647 | i2c_set_clientdata(client, clientdata); | 648 | i2c_set_clientdata(client, clientdata); |
648 | 649 | ||
649 | rtc = rtc_device_register(client->name, &client->dev, | 650 | rtc = devm_rtc_device_register(&client->dev, client->name, |
650 | &m41t80_rtc_ops, THIS_MODULE); | 651 | &m41t80_rtc_ops, THIS_MODULE); |
651 | if (IS_ERR(rtc)) { | 652 | if (IS_ERR(rtc)) { |
652 | rc = PTR_ERR(rtc); | 653 | rc = PTR_ERR(rtc); |
653 | rtc = NULL; | 654 | rtc = NULL; |
@@ -718,26 +719,19 @@ ht_err: | |||
718 | goto exit; | 719 | goto exit; |
719 | 720 | ||
720 | exit: | 721 | exit: |
721 | if (rtc) | ||
722 | rtc_device_unregister(rtc); | ||
723 | kfree(clientdata); | ||
724 | return rc; | 722 | return rc; |
725 | } | 723 | } |
726 | 724 | ||
727 | static int m41t80_remove(struct i2c_client *client) | 725 | static int m41t80_remove(struct i2c_client *client) |
728 | { | 726 | { |
727 | #ifdef CONFIG_RTC_DRV_M41T80_WDT | ||
729 | struct m41t80_data *clientdata = i2c_get_clientdata(client); | 728 | struct m41t80_data *clientdata = i2c_get_clientdata(client); |
730 | struct rtc_device *rtc = clientdata->rtc; | ||
731 | 729 | ||
732 | #ifdef CONFIG_RTC_DRV_M41T80_WDT | ||
733 | if (clientdata->features & M41T80_FEATURE_HT) { | 730 | if (clientdata->features & M41T80_FEATURE_HT) { |
734 | misc_deregister(&wdt_dev); | 731 | misc_deregister(&wdt_dev); |
735 | unregister_reboot_notifier(&wdt_notifier); | 732 | unregister_reboot_notifier(&wdt_notifier); |
736 | } | 733 | } |
737 | #endif | 734 | #endif |
738 | if (rtc) | ||
739 | rtc_device_unregister(rtc); | ||
740 | kfree(clientdata); | ||
741 | 735 | ||
742 | return 0; | 736 | return 0; |
743 | } | 737 | } |
diff --git a/drivers/rtc/rtc-m41t93.c b/drivers/rtc/rtc-m41t93.c index 49169680786e..9707d36e8b15 100644 --- a/drivers/rtc/rtc-m41t93.c +++ b/drivers/rtc/rtc-m41t93.c | |||
@@ -184,12 +184,12 @@ static int m41t93_probe(struct spi_device *spi) | |||
184 | return -ENODEV; | 184 | return -ENODEV; |
185 | } | 185 | } |
186 | 186 | ||
187 | rtc = rtc_device_register(m41t93_driver.driver.name, | 187 | rtc = devm_rtc_device_register(&spi->dev, m41t93_driver.driver.name, |
188 | &spi->dev, &m41t93_rtc_ops, THIS_MODULE); | 188 | &m41t93_rtc_ops, THIS_MODULE); |
189 | if (IS_ERR(rtc)) | 189 | if (IS_ERR(rtc)) |
190 | return PTR_ERR(rtc); | 190 | return PTR_ERR(rtc); |
191 | 191 | ||
192 | dev_set_drvdata(&spi->dev, rtc); | 192 | spi_set_drvdata(spi, rtc); |
193 | 193 | ||
194 | return 0; | 194 | return 0; |
195 | } | 195 | } |
@@ -197,11 +197,6 @@ static int m41t93_probe(struct spi_device *spi) | |||
197 | 197 | ||
198 | static int m41t93_remove(struct spi_device *spi) | 198 | static int m41t93_remove(struct spi_device *spi) |
199 | { | 199 | { |
200 | struct rtc_device *rtc = spi_get_drvdata(spi); | ||
201 | |||
202 | if (rtc) | ||
203 | rtc_device_unregister(rtc); | ||
204 | |||
205 | return 0; | 200 | return 0; |
206 | } | 201 | } |
207 | 202 | ||
diff --git a/drivers/rtc/rtc-m41t94.c b/drivers/rtc/rtc-m41t94.c index 89266c6764bc..7454ef0a4cfa 100644 --- a/drivers/rtc/rtc-m41t94.c +++ b/drivers/rtc/rtc-m41t94.c | |||
@@ -124,23 +124,18 @@ static int m41t94_probe(struct spi_device *spi) | |||
124 | return res; | 124 | return res; |
125 | } | 125 | } |
126 | 126 | ||
127 | rtc = rtc_device_register(m41t94_driver.driver.name, | 127 | rtc = devm_rtc_device_register(&spi->dev, m41t94_driver.driver.name, |
128 | &spi->dev, &m41t94_rtc_ops, THIS_MODULE); | 128 | &m41t94_rtc_ops, THIS_MODULE); |
129 | if (IS_ERR(rtc)) | 129 | if (IS_ERR(rtc)) |
130 | return PTR_ERR(rtc); | 130 | return PTR_ERR(rtc); |
131 | 131 | ||
132 | dev_set_drvdata(&spi->dev, rtc); | 132 | spi_set_drvdata(spi, rtc); |
133 | 133 | ||
134 | return 0; | 134 | return 0; |
135 | } | 135 | } |
136 | 136 | ||
137 | static int m41t94_remove(struct spi_device *spi) | 137 | static int m41t94_remove(struct spi_device *spi) |
138 | { | 138 | { |
139 | struct rtc_device *rtc = spi_get_drvdata(spi); | ||
140 | |||
141 | if (rtc) | ||
142 | rtc_device_unregister(rtc); | ||
143 | |||
144 | return 0; | 139 | return 0; |
145 | } | 140 | } |
146 | 141 | ||
diff --git a/drivers/rtc/rtc-m48t35.c b/drivers/rtc/rtc-m48t35.c index 31c9190a1fcb..37444246e5e4 100644 --- a/drivers/rtc/rtc-m48t35.c +++ b/drivers/rtc/rtc-m48t35.c | |||
@@ -145,12 +145,11 @@ static int m48t35_probe(struct platform_device *pdev) | |||
145 | { | 145 | { |
146 | struct resource *res; | 146 | struct resource *res; |
147 | struct m48t35_priv *priv; | 147 | struct m48t35_priv *priv; |
148 | int ret = 0; | ||
149 | 148 | ||
150 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 149 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
151 | if (!res) | 150 | if (!res) |
152 | return -ENODEV; | 151 | return -ENODEV; |
153 | priv = kzalloc(sizeof(struct m48t35_priv), GFP_KERNEL); | 152 | priv = devm_kzalloc(&pdev->dev, sizeof(struct m48t35_priv), GFP_KERNEL); |
154 | if (!priv) | 153 | if (!priv) |
155 | return -ENOMEM; | 154 | return -ENOMEM; |
156 | 155 | ||
@@ -160,50 +159,29 @@ static int m48t35_probe(struct platform_device *pdev) | |||
160 | * conflicts are resolved | 159 | * conflicts are resolved |
161 | */ | 160 | */ |
162 | #ifndef CONFIG_SGI_IP27 | 161 | #ifndef CONFIG_SGI_IP27 |
163 | if (!request_mem_region(res->start, priv->size, pdev->name)) { | 162 | if (!devm_request_mem_region(&pdev->dev, res->start, priv->size, |
164 | ret = -EBUSY; | 163 | pdev->name)) |
165 | goto out; | 164 | return -EBUSY; |
166 | } | ||
167 | #endif | 165 | #endif |
168 | priv->baseaddr = res->start; | 166 | priv->baseaddr = res->start; |
169 | priv->reg = ioremap(priv->baseaddr, priv->size); | 167 | priv->reg = devm_ioremap(&pdev->dev, priv->baseaddr, priv->size); |
170 | if (!priv->reg) { | 168 | if (!priv->reg) |
171 | ret = -ENOMEM; | 169 | return -ENOMEM; |
172 | goto out; | ||
173 | } | ||
174 | 170 | ||
175 | spin_lock_init(&priv->lock); | 171 | spin_lock_init(&priv->lock); |
176 | 172 | ||
177 | platform_set_drvdata(pdev, priv); | 173 | platform_set_drvdata(pdev, priv); |
178 | 174 | ||
179 | priv->rtc = rtc_device_register("m48t35", &pdev->dev, | 175 | priv->rtc = devm_rtc_device_register(&pdev->dev, "m48t35", |
180 | &m48t35_ops, THIS_MODULE); | 176 | &m48t35_ops, THIS_MODULE); |
181 | if (IS_ERR(priv->rtc)) { | 177 | if (IS_ERR(priv->rtc)) |
182 | ret = PTR_ERR(priv->rtc); | 178 | return PTR_ERR(priv->rtc); |
183 | goto out; | ||
184 | } | ||
185 | 179 | ||
186 | return 0; | 180 | return 0; |
187 | |||
188 | out: | ||
189 | if (priv->reg) | ||
190 | iounmap(priv->reg); | ||
191 | if (priv->baseaddr) | ||
192 | release_mem_region(priv->baseaddr, priv->size); | ||
193 | kfree(priv); | ||
194 | return ret; | ||
195 | } | 181 | } |
196 | 182 | ||
197 | static int m48t35_remove(struct platform_device *pdev) | 183 | static int m48t35_remove(struct platform_device *pdev) |
198 | { | 184 | { |
199 | struct m48t35_priv *priv = platform_get_drvdata(pdev); | ||
200 | |||
201 | rtc_device_unregister(priv->rtc); | ||
202 | iounmap(priv->reg); | ||
203 | #ifndef CONFIG_SGI_IP27 | ||
204 | release_mem_region(priv->baseaddr, priv->size); | ||
205 | #endif | ||
206 | kfree(priv); | ||
207 | return 0; | 185 | return 0; |
208 | } | 186 | } |
209 | 187 | ||
diff --git a/drivers/rtc/rtc-m48t86.c b/drivers/rtc/rtc-m48t86.c index 2ffbcacd2439..33a91c484533 100644 --- a/drivers/rtc/rtc-m48t86.c +++ b/drivers/rtc/rtc-m48t86.c | |||
@@ -148,8 +148,10 @@ static int m48t86_rtc_probe(struct platform_device *dev) | |||
148 | { | 148 | { |
149 | unsigned char reg; | 149 | unsigned char reg; |
150 | struct m48t86_ops *ops = dev->dev.platform_data; | 150 | struct m48t86_ops *ops = dev->dev.platform_data; |
151 | struct rtc_device *rtc = rtc_device_register("m48t86", | 151 | struct rtc_device *rtc; |
152 | &dev->dev, &m48t86_rtc_ops, THIS_MODULE); | 152 | |
153 | rtc = devm_rtc_device_register(&dev->dev, "m48t86", | ||
154 | &m48t86_rtc_ops, THIS_MODULE); | ||
153 | 155 | ||
154 | if (IS_ERR(rtc)) | 156 | if (IS_ERR(rtc)) |
155 | return PTR_ERR(rtc); | 157 | return PTR_ERR(rtc); |
@@ -166,11 +168,6 @@ static int m48t86_rtc_probe(struct platform_device *dev) | |||
166 | 168 | ||
167 | static int m48t86_rtc_remove(struct platform_device *dev) | 169 | static int m48t86_rtc_remove(struct platform_device *dev) |
168 | { | 170 | { |
169 | struct rtc_device *rtc = platform_get_drvdata(dev); | ||
170 | |||
171 | if (rtc) | ||
172 | rtc_device_unregister(rtc); | ||
173 | |||
174 | platform_set_drvdata(dev, NULL); | 171 | platform_set_drvdata(dev, NULL); |
175 | 172 | ||
176 | return 0; | 173 | return 0; |
diff --git a/drivers/rtc/rtc-max6900.c b/drivers/rtc/rtc-max6900.c index a00e33204b91..8669d6d09a00 100644 --- a/drivers/rtc/rtc-max6900.c +++ b/drivers/rtc/rtc-max6900.c | |||
@@ -214,11 +214,6 @@ static int max6900_rtc_set_time(struct device *dev, struct rtc_time *tm) | |||
214 | 214 | ||
215 | static int max6900_remove(struct i2c_client *client) | 215 | static int max6900_remove(struct i2c_client *client) |
216 | { | 216 | { |
217 | struct rtc_device *rtc = i2c_get_clientdata(client); | ||
218 | |||
219 | if (rtc) | ||
220 | rtc_device_unregister(rtc); | ||
221 | |||
222 | return 0; | 217 | return 0; |
223 | } | 218 | } |
224 | 219 | ||
@@ -237,8 +232,8 @@ max6900_probe(struct i2c_client *client, const struct i2c_device_id *id) | |||
237 | 232 | ||
238 | dev_info(&client->dev, "chip found, driver version " DRV_VERSION "\n"); | 233 | dev_info(&client->dev, "chip found, driver version " DRV_VERSION "\n"); |
239 | 234 | ||
240 | rtc = rtc_device_register(max6900_driver.driver.name, | 235 | rtc = devm_rtc_device_register(&client->dev, max6900_driver.driver.name, |
241 | &client->dev, &max6900_rtc_ops, THIS_MODULE); | 236 | &max6900_rtc_ops, THIS_MODULE); |
242 | if (IS_ERR(rtc)) | 237 | if (IS_ERR(rtc)) |
243 | return PTR_ERR(rtc); | 238 | return PTR_ERR(rtc); |
244 | 239 | ||
diff --git a/drivers/rtc/rtc-max6902.c b/drivers/rtc/rtc-max6902.c index 7d0bf698b79e..e3aea00c3145 100644 --- a/drivers/rtc/rtc-max6902.c +++ b/drivers/rtc/rtc-max6902.c | |||
@@ -93,24 +93,24 @@ static int max6902_set_time(struct device *dev, struct rtc_time *dt) | |||
93 | dt->tm_year = dt->tm_year + 1900; | 93 | dt->tm_year = dt->tm_year + 1900; |
94 | 94 | ||
95 | /* Remove write protection */ | 95 | /* Remove write protection */ |
96 | max6902_set_reg(dev, 0xF, 0); | 96 | max6902_set_reg(dev, MAX6902_REG_CONTROL, 0); |
97 | 97 | ||
98 | max6902_set_reg(dev, 0x01, bin2bcd(dt->tm_sec)); | 98 | max6902_set_reg(dev, MAX6902_REG_SECONDS, bin2bcd(dt->tm_sec)); |
99 | max6902_set_reg(dev, 0x03, bin2bcd(dt->tm_min)); | 99 | max6902_set_reg(dev, MAX6902_REG_MINUTES, bin2bcd(dt->tm_min)); |
100 | max6902_set_reg(dev, 0x05, bin2bcd(dt->tm_hour)); | 100 | max6902_set_reg(dev, MAX6902_REG_HOURS, bin2bcd(dt->tm_hour)); |
101 | 101 | ||
102 | max6902_set_reg(dev, 0x07, bin2bcd(dt->tm_mday)); | 102 | max6902_set_reg(dev, MAX6902_REG_DATE, bin2bcd(dt->tm_mday)); |
103 | max6902_set_reg(dev, 0x09, bin2bcd(dt->tm_mon + 1)); | 103 | max6902_set_reg(dev, MAX6902_REG_MONTH, bin2bcd(dt->tm_mon + 1)); |
104 | max6902_set_reg(dev, 0x0B, bin2bcd(dt->tm_wday)); | 104 | max6902_set_reg(dev, MAX6902_REG_DAY, bin2bcd(dt->tm_wday)); |
105 | max6902_set_reg(dev, 0x0D, bin2bcd(dt->tm_year % 100)); | 105 | max6902_set_reg(dev, MAX6902_REG_YEAR, bin2bcd(dt->tm_year % 100)); |
106 | max6902_set_reg(dev, 0x13, bin2bcd(dt->tm_year / 100)); | 106 | max6902_set_reg(dev, MAX6902_REG_CENTURY, bin2bcd(dt->tm_year / 100)); |
107 | 107 | ||
108 | /* Compulab used a delay here. However, the datasheet | 108 | /* Compulab used a delay here. However, the datasheet |
109 | * does not mention a delay being required anywhere... */ | 109 | * does not mention a delay being required anywhere... */ |
110 | /* delay(2000); */ | 110 | /* delay(2000); */ |
111 | 111 | ||
112 | /* Write protect */ | 112 | /* Write protect */ |
113 | max6902_set_reg(dev, 0xF, 0x80); | 113 | max6902_set_reg(dev, MAX6902_REG_CONTROL, 0x80); |
114 | 114 | ||
115 | return 0; | 115 | return 0; |
116 | } | 116 | } |
@@ -134,20 +134,17 @@ static int max6902_probe(struct spi_device *spi) | |||
134 | if (res != 0) | 134 | if (res != 0) |
135 | return res; | 135 | return res; |
136 | 136 | ||
137 | rtc = rtc_device_register("max6902", | 137 | rtc = devm_rtc_device_register(&spi->dev, "max6902", |
138 | &spi->dev, &max6902_rtc_ops, THIS_MODULE); | 138 | &max6902_rtc_ops, THIS_MODULE); |
139 | if (IS_ERR(rtc)) | 139 | if (IS_ERR(rtc)) |
140 | return PTR_ERR(rtc); | 140 | return PTR_ERR(rtc); |
141 | 141 | ||
142 | dev_set_drvdata(&spi->dev, rtc); | 142 | spi_set_drvdata(spi, rtc); |
143 | return 0; | 143 | return 0; |
144 | } | 144 | } |
145 | 145 | ||
146 | static int max6902_remove(struct spi_device *spi) | 146 | static int max6902_remove(struct spi_device *spi) |
147 | { | 147 | { |
148 | struct rtc_device *rtc = dev_get_drvdata(&spi->dev); | ||
149 | |||
150 | rtc_device_unregister(rtc); | ||
151 | return 0; | 148 | return 0; |
152 | } | 149 | } |
153 | 150 | ||
diff --git a/drivers/rtc/rtc-max77686.c b/drivers/rtc/rtc-max77686.c index 6b1337f9baf4..771812d62e6b 100644 --- a/drivers/rtc/rtc-max77686.c +++ b/drivers/rtc/rtc-max77686.c | |||
@@ -24,7 +24,7 @@ | |||
24 | 24 | ||
25 | /* RTC Control Register */ | 25 | /* RTC Control Register */ |
26 | #define BCD_EN_SHIFT 0 | 26 | #define BCD_EN_SHIFT 0 |
27 | #define BCD_EN_MASK (1 << BCD_EN_SHIFT) | 27 | #define BCD_EN_MASK (1 << BCD_EN_SHIFT) |
28 | #define MODEL24_SHIFT 1 | 28 | #define MODEL24_SHIFT 1 |
29 | #define MODEL24_MASK (1 << MODEL24_SHIFT) | 29 | #define MODEL24_MASK (1 << MODEL24_SHIFT) |
30 | /* RTC Update Register1 */ | 30 | /* RTC Update Register1 */ |
@@ -33,12 +33,12 @@ | |||
33 | #define RTC_RBUDR_SHIFT 4 | 33 | #define RTC_RBUDR_SHIFT 4 |
34 | #define RTC_RBUDR_MASK (1 << RTC_RBUDR_SHIFT) | 34 | #define RTC_RBUDR_MASK (1 << RTC_RBUDR_SHIFT) |
35 | /* WTSR and SMPL Register */ | 35 | /* WTSR and SMPL Register */ |
36 | #define WTSRT_SHIFT 0 | 36 | #define WTSRT_SHIFT 0 |
37 | #define SMPLT_SHIFT 2 | 37 | #define SMPLT_SHIFT 2 |
38 | #define WTSR_EN_SHIFT 6 | 38 | #define WTSR_EN_SHIFT 6 |
39 | #define SMPL_EN_SHIFT 7 | 39 | #define SMPL_EN_SHIFT 7 |
40 | #define WTSRT_MASK (3 << WTSRT_SHIFT) | 40 | #define WTSRT_MASK (3 << WTSRT_SHIFT) |
41 | #define SMPLT_MASK (3 << SMPLT_SHIFT) | 41 | #define SMPLT_MASK (3 << SMPLT_SHIFT) |
42 | #define WTSR_EN_MASK (1 << WTSR_EN_SHIFT) | 42 | #define WTSR_EN_MASK (1 << WTSR_EN_SHIFT) |
43 | #define SMPL_EN_MASK (1 << SMPL_EN_SHIFT) | 43 | #define SMPL_EN_MASK (1 << SMPL_EN_SHIFT) |
44 | /* RTC Hour register */ | 44 | /* RTC Hour register */ |
@@ -466,7 +466,7 @@ static void max77686_rtc_enable_smpl(struct max77686_rtc_info *info, bool enable | |||
466 | 466 | ||
467 | val = 0; | 467 | val = 0; |
468 | regmap_read(info->max77686->rtc_regmap, MAX77686_WTSR_SMPL_CNTL, &val); | 468 | regmap_read(info->max77686->rtc_regmap, MAX77686_WTSR_SMPL_CNTL, &val); |
469 | pr_info("%s: WTSR_SMPL(0x%02x)\n", __func__, val); | 469 | dev_info(info->dev, "%s: WTSR_SMPL(0x%02x)\n", __func__, val); |
470 | } | 470 | } |
471 | #endif /* MAX77686_RTC_WTSR_SMPL */ | 471 | #endif /* MAX77686_RTC_WTSR_SMPL */ |
472 | 472 | ||
@@ -505,7 +505,8 @@ static int max77686_rtc_probe(struct platform_device *pdev) | |||
505 | 505 | ||
506 | dev_info(&pdev->dev, "%s\n", __func__); | 506 | dev_info(&pdev->dev, "%s\n", __func__); |
507 | 507 | ||
508 | info = kzalloc(sizeof(struct max77686_rtc_info), GFP_KERNEL); | 508 | info = devm_kzalloc(&pdev->dev, sizeof(struct max77686_rtc_info), |
509 | GFP_KERNEL); | ||
509 | if (!info) | 510 | if (!info) |
510 | return -ENOMEM; | 511 | return -ENOMEM; |
511 | 512 | ||
@@ -513,13 +514,12 @@ static int max77686_rtc_probe(struct platform_device *pdev) | |||
513 | info->dev = &pdev->dev; | 514 | info->dev = &pdev->dev; |
514 | info->max77686 = max77686; | 515 | info->max77686 = max77686; |
515 | info->rtc = max77686->rtc; | 516 | info->rtc = max77686->rtc; |
516 | info->max77686->rtc_regmap = regmap_init_i2c(info->max77686->rtc, | 517 | info->max77686->rtc_regmap = devm_regmap_init_i2c(info->max77686->rtc, |
517 | &max77686_rtc_regmap_config); | 518 | &max77686_rtc_regmap_config); |
518 | if (IS_ERR(info->max77686->rtc_regmap)) { | 519 | if (IS_ERR(info->max77686->rtc_regmap)) { |
519 | ret = PTR_ERR(info->max77686->rtc_regmap); | 520 | ret = PTR_ERR(info->max77686->rtc_regmap); |
520 | dev_err(info->max77686->dev, "Failed to allocate register map: %d\n", | 521 | dev_err(info->max77686->dev, "Failed to allocate register map: %d\n", |
521 | ret); | 522 | ret); |
522 | kfree(info); | ||
523 | return ret; | 523 | return ret; |
524 | } | 524 | } |
525 | platform_set_drvdata(pdev, info); | 525 | platform_set_drvdata(pdev, info); |
@@ -538,8 +538,8 @@ static int max77686_rtc_probe(struct platform_device *pdev) | |||
538 | 538 | ||
539 | device_init_wakeup(&pdev->dev, 1); | 539 | device_init_wakeup(&pdev->dev, 1); |
540 | 540 | ||
541 | info->rtc_dev = rtc_device_register("max77686-rtc", &pdev->dev, | 541 | info->rtc_dev = devm_rtc_device_register(&pdev->dev, "max77686-rtc", |
542 | &max77686_rtc_ops, THIS_MODULE); | 542 | &max77686_rtc_ops, THIS_MODULE); |
543 | 543 | ||
544 | if (IS_ERR(info->rtc_dev)) { | 544 | if (IS_ERR(info->rtc_dev)) { |
545 | dev_info(&pdev->dev, "%s: fail\n", __func__); | 545 | dev_info(&pdev->dev, "%s: fail\n", __func__); |
@@ -551,36 +551,24 @@ static int max77686_rtc_probe(struct platform_device *pdev) | |||
551 | goto err_rtc; | 551 | goto err_rtc; |
552 | } | 552 | } |
553 | virq = irq_create_mapping(max77686->irq_domain, MAX77686_RTCIRQ_RTCA1); | 553 | virq = irq_create_mapping(max77686->irq_domain, MAX77686_RTCIRQ_RTCA1); |
554 | if (!virq) | 554 | if (!virq) { |
555 | ret = -ENXIO; | ||
555 | goto err_rtc; | 556 | goto err_rtc; |
557 | } | ||
556 | info->virq = virq; | 558 | info->virq = virq; |
557 | 559 | ||
558 | ret = request_threaded_irq(virq, NULL, max77686_rtc_alarm_irq, 0, | 560 | ret = devm_request_threaded_irq(&pdev->dev, virq, NULL, |
559 | "rtc-alarm0", info); | 561 | max77686_rtc_alarm_irq, 0, "rtc-alarm0", info); |
560 | if (ret < 0) { | 562 | if (ret < 0) |
561 | dev_err(&pdev->dev, "Failed to request alarm IRQ: %d: %d\n", | 563 | dev_err(&pdev->dev, "Failed to request alarm IRQ: %d: %d\n", |
562 | info->virq, ret); | 564 | info->virq, ret); |
563 | goto err_rtc; | ||
564 | } | ||
565 | 565 | ||
566 | goto out; | ||
567 | err_rtc: | 566 | err_rtc: |
568 | kfree(info); | ||
569 | return ret; | ||
570 | out: | ||
571 | return ret; | 567 | return ret; |
572 | } | 568 | } |
573 | 569 | ||
574 | static int max77686_rtc_remove(struct platform_device *pdev) | 570 | static int max77686_rtc_remove(struct platform_device *pdev) |
575 | { | 571 | { |
576 | struct max77686_rtc_info *info = platform_get_drvdata(pdev); | ||
577 | |||
578 | if (info) { | ||
579 | free_irq(info->virq, info); | ||
580 | rtc_device_unregister(info->rtc_dev); | ||
581 | kfree(info); | ||
582 | } | ||
583 | |||
584 | return 0; | 572 | return 0; |
585 | } | 573 | } |
586 | 574 | ||
@@ -594,11 +582,14 @@ static void max77686_rtc_shutdown(struct platform_device *pdev) | |||
594 | for (i = 0; i < 3; i++) { | 582 | for (i = 0; i < 3; i++) { |
595 | max77686_rtc_enable_wtsr(info, false); | 583 | max77686_rtc_enable_wtsr(info, false); |
596 | regmap_read(info->max77686->rtc_regmap, MAX77686_WTSR_SMPL_CNTL, &val); | 584 | regmap_read(info->max77686->rtc_regmap, MAX77686_WTSR_SMPL_CNTL, &val); |
597 | pr_info("%s: WTSR_SMPL reg(0x%02x)\n", __func__, val); | 585 | dev_info(info->dev, "%s: WTSR_SMPL reg(0x%02x)\n", __func__, |
598 | if (val & WTSR_EN_MASK) | 586 | val); |
599 | pr_emerg("%s: fail to disable WTSR\n", __func__); | 587 | if (val & WTSR_EN_MASK) { |
600 | else { | 588 | dev_emerg(info->dev, "%s: fail to disable WTSR\n", |
601 | pr_info("%s: success to disable WTSR\n", __func__); | 589 | __func__); |
590 | } else { | ||
591 | dev_info(info->dev, "%s: success to disable WTSR\n", | ||
592 | __func__); | ||
602 | break; | 593 | break; |
603 | } | 594 | } |
604 | } | 595 | } |
@@ -624,18 +615,8 @@ static struct platform_driver max77686_rtc_driver = { | |||
624 | .id_table = rtc_id, | 615 | .id_table = rtc_id, |
625 | }; | 616 | }; |
626 | 617 | ||
627 | static int __init max77686_rtc_init(void) | 618 | module_platform_driver(max77686_rtc_driver); |
628 | { | ||
629 | return platform_driver_register(&max77686_rtc_driver); | ||
630 | } | ||
631 | module_init(max77686_rtc_init); | ||
632 | |||
633 | static void __exit max77686_rtc_exit(void) | ||
634 | { | ||
635 | platform_driver_unregister(&max77686_rtc_driver); | ||
636 | } | ||
637 | module_exit(max77686_rtc_exit); | ||
638 | 619 | ||
639 | MODULE_DESCRIPTION("Maxim MAX77686 RTC driver"); | 620 | MODULE_DESCRIPTION("Maxim MAX77686 RTC driver"); |
640 | MODULE_AUTHOR("<woong.byun@samsung.com>"); | 621 | MODULE_AUTHOR("Chiwoong Byun <woong.byun@samsung.com>"); |
641 | MODULE_LICENSE("GPL"); | 622 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/rtc/rtc-max8907.c b/drivers/rtc/rtc-max8907.c index 31ca8faf9f05..86afb797125d 100644 --- a/drivers/rtc/rtc-max8907.c +++ b/drivers/rtc/rtc-max8907.c | |||
@@ -190,7 +190,7 @@ static int max8907_rtc_probe(struct platform_device *pdev) | |||
190 | rtc->max8907 = max8907; | 190 | rtc->max8907 = max8907; |
191 | rtc->regmap = max8907->regmap_rtc; | 191 | rtc->regmap = max8907->regmap_rtc; |
192 | 192 | ||
193 | rtc->rtc_dev = rtc_device_register("max8907-rtc", &pdev->dev, | 193 | rtc->rtc_dev = devm_rtc_device_register(&pdev->dev, "max8907-rtc", |
194 | &max8907_rtc_ops, THIS_MODULE); | 194 | &max8907_rtc_ops, THIS_MODULE); |
195 | if (IS_ERR(rtc->rtc_dev)) { | 195 | if (IS_ERR(rtc->rtc_dev)) { |
196 | ret = PTR_ERR(rtc->rtc_dev); | 196 | ret = PTR_ERR(rtc->rtc_dev); |
@@ -200,33 +200,21 @@ static int max8907_rtc_probe(struct platform_device *pdev) | |||
200 | 200 | ||
201 | rtc->irq = regmap_irq_get_virq(max8907->irqc_rtc, | 201 | rtc->irq = regmap_irq_get_virq(max8907->irqc_rtc, |
202 | MAX8907_IRQ_RTC_ALARM0); | 202 | MAX8907_IRQ_RTC_ALARM0); |
203 | if (rtc->irq < 0) { | 203 | if (rtc->irq < 0) |
204 | ret = rtc->irq; | 204 | return rtc->irq; |
205 | goto err_unregister; | ||
206 | } | ||
207 | 205 | ||
208 | ret = devm_request_threaded_irq(&pdev->dev, rtc->irq, NULL, | 206 | ret = devm_request_threaded_irq(&pdev->dev, rtc->irq, NULL, |
209 | max8907_irq_handler, | 207 | max8907_irq_handler, |
210 | IRQF_ONESHOT, "max8907-alarm0", rtc); | 208 | IRQF_ONESHOT, "max8907-alarm0", rtc); |
211 | if (ret < 0) { | 209 | if (ret < 0) |
212 | dev_err(&pdev->dev, "Failed to request IRQ%d: %d\n", | 210 | dev_err(&pdev->dev, "Failed to request IRQ%d: %d\n", |
213 | rtc->irq, ret); | 211 | rtc->irq, ret); |
214 | goto err_unregister; | ||
215 | } | ||
216 | 212 | ||
217 | return 0; | ||
218 | |||
219 | err_unregister: | ||
220 | rtc_device_unregister(rtc->rtc_dev); | ||
221 | return ret; | 213 | return ret; |
222 | } | 214 | } |
223 | 215 | ||
224 | static int max8907_rtc_remove(struct platform_device *pdev) | 216 | static int max8907_rtc_remove(struct platform_device *pdev) |
225 | { | 217 | { |
226 | struct max8907_rtc *rtc = platform_get_drvdata(pdev); | ||
227 | |||
228 | rtc_device_unregister(rtc->rtc_dev); | ||
229 | |||
230 | return 0; | 218 | return 0; |
231 | } | 219 | } |
232 | 220 | ||
diff --git a/drivers/rtc/rtc-max8925.c b/drivers/rtc/rtc-max8925.c index a0c8265646d2..7c90f4e45e27 100644 --- a/drivers/rtc/rtc-max8925.c +++ b/drivers/rtc/rtc-max8925.c | |||
@@ -253,7 +253,8 @@ static int max8925_rtc_probe(struct platform_device *pdev) | |||
253 | struct max8925_rtc_info *info; | 253 | struct max8925_rtc_info *info; |
254 | int ret; | 254 | int ret; |
255 | 255 | ||
256 | info = kzalloc(sizeof(struct max8925_rtc_info), GFP_KERNEL); | 256 | info = devm_kzalloc(&pdev->dev, sizeof(struct max8925_rtc_info), |
257 | GFP_KERNEL); | ||
257 | if (!info) | 258 | if (!info) |
258 | return -ENOMEM; | 259 | return -ENOMEM; |
259 | info->chip = chip; | 260 | info->chip = chip; |
@@ -261,12 +262,13 @@ static int max8925_rtc_probe(struct platform_device *pdev) | |||
261 | info->dev = &pdev->dev; | 262 | info->dev = &pdev->dev; |
262 | info->irq = platform_get_irq(pdev, 0); | 263 | info->irq = platform_get_irq(pdev, 0); |
263 | 264 | ||
264 | ret = request_threaded_irq(info->irq, NULL, rtc_update_handler, | 265 | ret = devm_request_threaded_irq(&pdev->dev, info->irq, NULL, |
265 | IRQF_ONESHOT, "rtc-alarm0", info); | 266 | rtc_update_handler, IRQF_ONESHOT, |
267 | "rtc-alarm0", info); | ||
266 | if (ret < 0) { | 268 | if (ret < 0) { |
267 | dev_err(chip->dev, "Failed to request IRQ: #%d: %d\n", | 269 | dev_err(chip->dev, "Failed to request IRQ: #%d: %d\n", |
268 | info->irq, ret); | 270 | info->irq, ret); |
269 | goto out_irq; | 271 | goto err; |
270 | } | 272 | } |
271 | 273 | ||
272 | dev_set_drvdata(&pdev->dev, info); | 274 | dev_set_drvdata(&pdev->dev, info); |
@@ -275,32 +277,22 @@ static int max8925_rtc_probe(struct platform_device *pdev) | |||
275 | 277 | ||
276 | device_init_wakeup(&pdev->dev, 1); | 278 | device_init_wakeup(&pdev->dev, 1); |
277 | 279 | ||
278 | info->rtc_dev = rtc_device_register("max8925-rtc", &pdev->dev, | 280 | info->rtc_dev = devm_rtc_device_register(&pdev->dev, "max8925-rtc", |
279 | &max8925_rtc_ops, THIS_MODULE); | 281 | &max8925_rtc_ops, THIS_MODULE); |
280 | ret = PTR_ERR(info->rtc_dev); | 282 | ret = PTR_ERR(info->rtc_dev); |
281 | if (IS_ERR(info->rtc_dev)) { | 283 | if (IS_ERR(info->rtc_dev)) { |
282 | dev_err(&pdev->dev, "Failed to register RTC device: %d\n", ret); | 284 | dev_err(&pdev->dev, "Failed to register RTC device: %d\n", ret); |
283 | goto out_rtc; | 285 | goto err; |
284 | } | 286 | } |
285 | 287 | ||
286 | return 0; | 288 | return 0; |
287 | out_rtc: | 289 | err: |
288 | platform_set_drvdata(pdev, NULL); | 290 | platform_set_drvdata(pdev, NULL); |
289 | free_irq(info->irq, info); | ||
290 | out_irq: | ||
291 | kfree(info); | ||
292 | return ret; | 291 | return ret; |
293 | } | 292 | } |
294 | 293 | ||
295 | static int max8925_rtc_remove(struct platform_device *pdev) | 294 | static int max8925_rtc_remove(struct platform_device *pdev) |
296 | { | 295 | { |
297 | struct max8925_rtc_info *info = platform_get_drvdata(pdev); | ||
298 | |||
299 | if (info) { | ||
300 | free_irq(info->irq, info); | ||
301 | rtc_device_unregister(info->rtc_dev); | ||
302 | kfree(info); | ||
303 | } | ||
304 | return 0; | 296 | return 0; |
305 | } | 297 | } |
306 | 298 | ||
diff --git a/drivers/rtc/rtc-max8997.c b/drivers/rtc/rtc-max8997.c index 00e505b6bee3..5693619614f4 100644 --- a/drivers/rtc/rtc-max8997.c +++ b/drivers/rtc/rtc-max8997.c | |||
@@ -479,8 +479,8 @@ static int max8997_rtc_probe(struct platform_device *pdev) | |||
479 | 479 | ||
480 | device_init_wakeup(&pdev->dev, 1); | 480 | device_init_wakeup(&pdev->dev, 1); |
481 | 481 | ||
482 | info->rtc_dev = rtc_device_register("max8997-rtc", &pdev->dev, | 482 | info->rtc_dev = devm_rtc_device_register(&pdev->dev, "max8997-rtc", |
483 | &max8997_rtc_ops, THIS_MODULE); | 483 | &max8997_rtc_ops, THIS_MODULE); |
484 | 484 | ||
485 | if (IS_ERR(info->rtc_dev)) { | 485 | if (IS_ERR(info->rtc_dev)) { |
486 | ret = PTR_ERR(info->rtc_dev); | 486 | ret = PTR_ERR(info->rtc_dev); |
@@ -491,6 +491,7 @@ static int max8997_rtc_probe(struct platform_device *pdev) | |||
491 | virq = irq_create_mapping(max8997->irq_domain, MAX8997_PMICIRQ_RTCA1); | 491 | virq = irq_create_mapping(max8997->irq_domain, MAX8997_PMICIRQ_RTCA1); |
492 | if (!virq) { | 492 | if (!virq) { |
493 | dev_err(&pdev->dev, "Failed to create mapping alarm IRQ\n"); | 493 | dev_err(&pdev->dev, "Failed to create mapping alarm IRQ\n"); |
494 | ret = -ENXIO; | ||
494 | goto err_out; | 495 | goto err_out; |
495 | } | 496 | } |
496 | info->virq = virq; | 497 | info->virq = virq; |
@@ -498,26 +499,16 @@ static int max8997_rtc_probe(struct platform_device *pdev) | |||
498 | ret = devm_request_threaded_irq(&pdev->dev, virq, NULL, | 499 | ret = devm_request_threaded_irq(&pdev->dev, virq, NULL, |
499 | max8997_rtc_alarm_irq, 0, | 500 | max8997_rtc_alarm_irq, 0, |
500 | "rtc-alarm0", info); | 501 | "rtc-alarm0", info); |
501 | if (ret < 0) { | 502 | if (ret < 0) |
502 | dev_err(&pdev->dev, "Failed to request alarm IRQ: %d: %d\n", | 503 | dev_err(&pdev->dev, "Failed to request alarm IRQ: %d: %d\n", |
503 | info->virq, ret); | 504 | info->virq, ret); |
504 | goto err_out; | ||
505 | } | ||
506 | |||
507 | return ret; | ||
508 | 505 | ||
509 | err_out: | 506 | err_out: |
510 | rtc_device_unregister(info->rtc_dev); | ||
511 | return ret; | 507 | return ret; |
512 | } | 508 | } |
513 | 509 | ||
514 | static int max8997_rtc_remove(struct platform_device *pdev) | 510 | static int max8997_rtc_remove(struct platform_device *pdev) |
515 | { | 511 | { |
516 | struct max8997_rtc_info *info = platform_get_drvdata(pdev); | ||
517 | |||
518 | if (info) | ||
519 | rtc_device_unregister(info->rtc_dev); | ||
520 | |||
521 | return 0; | 512 | return 0; |
522 | } | 513 | } |
523 | 514 | ||
diff --git a/drivers/rtc/rtc-max8998.c b/drivers/rtc/rtc-max8998.c index 8f234a075e8f..48b6612fae7f 100644 --- a/drivers/rtc/rtc-max8998.c +++ b/drivers/rtc/rtc-max8998.c | |||
@@ -256,7 +256,8 @@ static int max8998_rtc_probe(struct platform_device *pdev) | |||
256 | struct max8998_rtc_info *info; | 256 | struct max8998_rtc_info *info; |
257 | int ret; | 257 | int ret; |
258 | 258 | ||
259 | info = kzalloc(sizeof(struct max8998_rtc_info), GFP_KERNEL); | 259 | info = devm_kzalloc(&pdev->dev, sizeof(struct max8998_rtc_info), |
260 | GFP_KERNEL); | ||
260 | if (!info) | 261 | if (!info) |
261 | return -ENOMEM; | 262 | return -ENOMEM; |
262 | 263 | ||
@@ -267,7 +268,7 @@ static int max8998_rtc_probe(struct platform_device *pdev) | |||
267 | 268 | ||
268 | platform_set_drvdata(pdev, info); | 269 | platform_set_drvdata(pdev, info); |
269 | 270 | ||
270 | info->rtc_dev = rtc_device_register("max8998-rtc", &pdev->dev, | 271 | info->rtc_dev = devm_rtc_device_register(&pdev->dev, "max8998-rtc", |
271 | &max8998_rtc_ops, THIS_MODULE); | 272 | &max8998_rtc_ops, THIS_MODULE); |
272 | 273 | ||
273 | if (IS_ERR(info->rtc_dev)) { | 274 | if (IS_ERR(info->rtc_dev)) { |
@@ -276,8 +277,8 @@ static int max8998_rtc_probe(struct platform_device *pdev) | |||
276 | goto out_rtc; | 277 | goto out_rtc; |
277 | } | 278 | } |
278 | 279 | ||
279 | ret = request_threaded_irq(info->irq, NULL, max8998_rtc_alarm_irq, 0, | 280 | ret = devm_request_threaded_irq(&pdev->dev, info->irq, NULL, |
280 | "rtc-alarm0", info); | 281 | max8998_rtc_alarm_irq, 0, "rtc-alarm0", info); |
281 | 282 | ||
282 | if (ret < 0) | 283 | if (ret < 0) |
283 | dev_err(&pdev->dev, "Failed to request alarm IRQ: %d: %d\n", | 284 | dev_err(&pdev->dev, "Failed to request alarm IRQ: %d: %d\n", |
@@ -294,20 +295,11 @@ static int max8998_rtc_probe(struct platform_device *pdev) | |||
294 | 295 | ||
295 | out_rtc: | 296 | out_rtc: |
296 | platform_set_drvdata(pdev, NULL); | 297 | platform_set_drvdata(pdev, NULL); |
297 | kfree(info); | ||
298 | return ret; | 298 | return ret; |
299 | } | 299 | } |
300 | 300 | ||
301 | static int max8998_rtc_remove(struct platform_device *pdev) | 301 | static int max8998_rtc_remove(struct platform_device *pdev) |
302 | { | 302 | { |
303 | struct max8998_rtc_info *info = platform_get_drvdata(pdev); | ||
304 | |||
305 | if (info) { | ||
306 | free_irq(info->irq, info); | ||
307 | rtc_device_unregister(info->rtc_dev); | ||
308 | kfree(info); | ||
309 | } | ||
310 | |||
311 | return 0; | 303 | return 0; |
312 | } | 304 | } |
313 | 305 | ||
diff --git a/drivers/rtc/rtc-mc13xxx.c b/drivers/rtc/rtc-mc13xxx.c index 2643d8874925..7a8ed27a5f2e 100644 --- a/drivers/rtc/rtc-mc13xxx.c +++ b/drivers/rtc/rtc-mc13xxx.c | |||
@@ -316,7 +316,7 @@ static int __init mc13xxx_rtc_probe(struct platform_device *pdev) | |||
316 | struct mc13xxx *mc13xxx; | 316 | struct mc13xxx *mc13xxx; |
317 | int rtcrst_pending; | 317 | int rtcrst_pending; |
318 | 318 | ||
319 | priv = kzalloc(sizeof(*priv), GFP_KERNEL); | 319 | priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); |
320 | if (!priv) | 320 | if (!priv) |
321 | return -ENOMEM; | 321 | return -ENOMEM; |
322 | 322 | ||
@@ -351,8 +351,8 @@ static int __init mc13xxx_rtc_probe(struct platform_device *pdev) | |||
351 | 351 | ||
352 | mc13xxx_unlock(mc13xxx); | 352 | mc13xxx_unlock(mc13xxx); |
353 | 353 | ||
354 | priv->rtc = rtc_device_register(pdev->name, | 354 | priv->rtc = devm_rtc_device_register(&pdev->dev, pdev->name, |
355 | &pdev->dev, &mc13xxx_rtc_ops, THIS_MODULE); | 355 | &mc13xxx_rtc_ops, THIS_MODULE); |
356 | if (IS_ERR(priv->rtc)) { | 356 | if (IS_ERR(priv->rtc)) { |
357 | ret = PTR_ERR(priv->rtc); | 357 | ret = PTR_ERR(priv->rtc); |
358 | 358 | ||
@@ -372,7 +372,6 @@ err_reset_irq_request: | |||
372 | mc13xxx_unlock(mc13xxx); | 372 | mc13xxx_unlock(mc13xxx); |
373 | 373 | ||
374 | platform_set_drvdata(pdev, NULL); | 374 | platform_set_drvdata(pdev, NULL); |
375 | kfree(priv); | ||
376 | } | 375 | } |
377 | 376 | ||
378 | return ret; | 377 | return ret; |
@@ -384,8 +383,6 @@ static int __exit mc13xxx_rtc_remove(struct platform_device *pdev) | |||
384 | 383 | ||
385 | mc13xxx_lock(priv->mc13xxx); | 384 | mc13xxx_lock(priv->mc13xxx); |
386 | 385 | ||
387 | rtc_device_unregister(priv->rtc); | ||
388 | |||
389 | mc13xxx_irq_free(priv->mc13xxx, MC13XXX_IRQ_TODA, priv); | 386 | mc13xxx_irq_free(priv->mc13xxx, MC13XXX_IRQ_TODA, priv); |
390 | mc13xxx_irq_free(priv->mc13xxx, MC13XXX_IRQ_1HZ, priv); | 387 | mc13xxx_irq_free(priv->mc13xxx, MC13XXX_IRQ_1HZ, priv); |
391 | mc13xxx_irq_free(priv->mc13xxx, MC13XXX_IRQ_RTCRST, priv); | 388 | mc13xxx_irq_free(priv->mc13xxx, MC13XXX_IRQ_RTCRST, priv); |
@@ -394,8 +391,6 @@ static int __exit mc13xxx_rtc_remove(struct platform_device *pdev) | |||
394 | 391 | ||
395 | platform_set_drvdata(pdev, NULL); | 392 | platform_set_drvdata(pdev, NULL); |
396 | 393 | ||
397 | kfree(priv); | ||
398 | |||
399 | return 0; | 394 | return 0; |
400 | } | 395 | } |
401 | 396 | ||
@@ -420,17 +415,7 @@ static struct platform_driver mc13xxx_rtc_driver = { | |||
420 | }, | 415 | }, |
421 | }; | 416 | }; |
422 | 417 | ||
423 | static int __init mc13xxx_rtc_init(void) | 418 | module_platform_driver_probe(mc13xxx_rtc_driver, &mc13xxx_rtc_probe); |
424 | { | ||
425 | return platform_driver_probe(&mc13xxx_rtc_driver, &mc13xxx_rtc_probe); | ||
426 | } | ||
427 | module_init(mc13xxx_rtc_init); | ||
428 | |||
429 | static void __exit mc13xxx_rtc_exit(void) | ||
430 | { | ||
431 | platform_driver_unregister(&mc13xxx_rtc_driver); | ||
432 | } | ||
433 | module_exit(mc13xxx_rtc_exit); | ||
434 | 419 | ||
435 | MODULE_AUTHOR("Sascha Hauer <s.hauer@pengutronix.de>"); | 420 | MODULE_AUTHOR("Sascha Hauer <s.hauer@pengutronix.de>"); |
436 | MODULE_DESCRIPTION("RTC driver for Freescale MC13XXX PMIC"); | 421 | MODULE_DESCRIPTION("RTC driver for Freescale MC13XXX PMIC"); |
diff --git a/drivers/rtc/rtc-msm6242.c b/drivers/rtc/rtc-msm6242.c index fcb113c11122..771f86a05d14 100644 --- a/drivers/rtc/rtc-msm6242.c +++ b/drivers/rtc/rtc-msm6242.c | |||
@@ -194,30 +194,28 @@ static const struct rtc_class_ops msm6242_rtc_ops = { | |||
194 | .set_time = msm6242_set_time, | 194 | .set_time = msm6242_set_time, |
195 | }; | 195 | }; |
196 | 196 | ||
197 | static int __init msm6242_rtc_probe(struct platform_device *dev) | 197 | static int __init msm6242_rtc_probe(struct platform_device *pdev) |
198 | { | 198 | { |
199 | struct resource *res; | 199 | struct resource *res; |
200 | struct msm6242_priv *priv; | 200 | struct msm6242_priv *priv; |
201 | struct rtc_device *rtc; | 201 | struct rtc_device *rtc; |
202 | int error; | 202 | int error; |
203 | 203 | ||
204 | res = platform_get_resource(dev, IORESOURCE_MEM, 0); | 204 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
205 | if (!res) | 205 | if (!res) |
206 | return -ENODEV; | 206 | return -ENODEV; |
207 | 207 | ||
208 | priv = kzalloc(sizeof(*priv), GFP_KERNEL); | 208 | priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); |
209 | if (!priv) | 209 | if (!priv) |
210 | return -ENOMEM; | 210 | return -ENOMEM; |
211 | 211 | ||
212 | priv->regs = ioremap(res->start, resource_size(res)); | 212 | priv->regs = devm_ioremap(&pdev->dev, res->start, resource_size(res)); |
213 | if (!priv->regs) { | 213 | if (!priv->regs) |
214 | error = -ENOMEM; | 214 | return -ENOMEM; |
215 | goto out_free_priv; | 215 | platform_set_drvdata(pdev, priv); |
216 | } | ||
217 | platform_set_drvdata(dev, priv); | ||
218 | 216 | ||
219 | rtc = rtc_device_register("rtc-msm6242", &dev->dev, &msm6242_rtc_ops, | 217 | rtc = devm_rtc_device_register(&pdev->dev, "rtc-msm6242", |
220 | THIS_MODULE); | 218 | &msm6242_rtc_ops, THIS_MODULE); |
221 | if (IS_ERR(rtc)) { | 219 | if (IS_ERR(rtc)) { |
222 | error = PTR_ERR(rtc); | 220 | error = PTR_ERR(rtc); |
223 | goto out_unmap; | 221 | goto out_unmap; |
@@ -227,20 +225,12 @@ static int __init msm6242_rtc_probe(struct platform_device *dev) | |||
227 | return 0; | 225 | return 0; |
228 | 226 | ||
229 | out_unmap: | 227 | out_unmap: |
230 | platform_set_drvdata(dev, NULL); | 228 | platform_set_drvdata(pdev, NULL); |
231 | iounmap(priv->regs); | ||
232 | out_free_priv: | ||
233 | kfree(priv); | ||
234 | return error; | 229 | return error; |
235 | } | 230 | } |
236 | 231 | ||
237 | static int __exit msm6242_rtc_remove(struct platform_device *dev) | 232 | static int __exit msm6242_rtc_remove(struct platform_device *pdev) |
238 | { | 233 | { |
239 | struct msm6242_priv *priv = platform_get_drvdata(dev); | ||
240 | |||
241 | rtc_device_unregister(priv->rtc); | ||
242 | iounmap(priv->regs); | ||
243 | kfree(priv); | ||
244 | return 0; | 234 | return 0; |
245 | } | 235 | } |
246 | 236 | ||
@@ -252,18 +242,7 @@ static struct platform_driver msm6242_rtc_driver = { | |||
252 | .remove = __exit_p(msm6242_rtc_remove), | 242 | .remove = __exit_p(msm6242_rtc_remove), |
253 | }; | 243 | }; |
254 | 244 | ||
255 | static int __init msm6242_rtc_init(void) | 245 | module_platform_driver_probe(msm6242_rtc_driver, msm6242_rtc_probe); |
256 | { | ||
257 | return platform_driver_probe(&msm6242_rtc_driver, msm6242_rtc_probe); | ||
258 | } | ||
259 | |||
260 | static void __exit msm6242_rtc_fini(void) | ||
261 | { | ||
262 | platform_driver_unregister(&msm6242_rtc_driver); | ||
263 | } | ||
264 | |||
265 | module_init(msm6242_rtc_init); | ||
266 | module_exit(msm6242_rtc_fini); | ||
267 | 246 | ||
268 | MODULE_AUTHOR("Geert Uytterhoeven <geert@linux-m68k.org>"); | 247 | MODULE_AUTHOR("Geert Uytterhoeven <geert@linux-m68k.org>"); |
269 | MODULE_LICENSE("GPL"); | 248 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/rtc/rtc-mv.c b/drivers/rtc/rtc-mv.c index 8f87fec27ce7..baab802f2153 100644 --- a/drivers/rtc/rtc-mv.c +++ b/drivers/rtc/rtc-mv.c | |||
@@ -217,7 +217,7 @@ static const struct rtc_class_ops mv_rtc_alarm_ops = { | |||
217 | .alarm_irq_enable = mv_rtc_alarm_irq_enable, | 217 | .alarm_irq_enable = mv_rtc_alarm_irq_enable, |
218 | }; | 218 | }; |
219 | 219 | ||
220 | static int mv_rtc_probe(struct platform_device *pdev) | 220 | static int __init mv_rtc_probe(struct platform_device *pdev) |
221 | { | 221 | { |
222 | struct resource *res; | 222 | struct resource *res; |
223 | struct rtc_plat_data *pdata; | 223 | struct rtc_plat_data *pdata; |
@@ -272,12 +272,13 @@ static int mv_rtc_probe(struct platform_device *pdev) | |||
272 | 272 | ||
273 | if (pdata->irq >= 0) { | 273 | if (pdata->irq >= 0) { |
274 | device_init_wakeup(&pdev->dev, 1); | 274 | device_init_wakeup(&pdev->dev, 1); |
275 | pdata->rtc = rtc_device_register(pdev->name, &pdev->dev, | 275 | pdata->rtc = devm_rtc_device_register(&pdev->dev, pdev->name, |
276 | &mv_rtc_alarm_ops, | 276 | &mv_rtc_alarm_ops, |
277 | THIS_MODULE); | 277 | THIS_MODULE); |
278 | } else | 278 | } else { |
279 | pdata->rtc = rtc_device_register(pdev->name, &pdev->dev, | 279 | pdata->rtc = devm_rtc_device_register(&pdev->dev, pdev->name, |
280 | &mv_rtc_ops, THIS_MODULE); | 280 | &mv_rtc_ops, THIS_MODULE); |
281 | } | ||
281 | if (IS_ERR(pdata->rtc)) { | 282 | if (IS_ERR(pdata->rtc)) { |
282 | ret = PTR_ERR(pdata->rtc); | 283 | ret = PTR_ERR(pdata->rtc); |
283 | goto out; | 284 | goto out; |
@@ -308,7 +309,6 @@ static int __exit mv_rtc_remove(struct platform_device *pdev) | |||
308 | if (pdata->irq >= 0) | 309 | if (pdata->irq >= 0) |
309 | device_init_wakeup(&pdev->dev, 0); | 310 | device_init_wakeup(&pdev->dev, 0); |
310 | 311 | ||
311 | rtc_device_unregister(pdata->rtc); | ||
312 | if (!IS_ERR(pdata->clk)) | 312 | if (!IS_ERR(pdata->clk)) |
313 | clk_disable_unprepare(pdata->clk); | 313 | clk_disable_unprepare(pdata->clk); |
314 | 314 | ||
@@ -331,18 +331,7 @@ static struct platform_driver mv_rtc_driver = { | |||
331 | }, | 331 | }, |
332 | }; | 332 | }; |
333 | 333 | ||
334 | static __init int mv_init(void) | 334 | module_platform_driver_probe(mv_rtc_driver, mv_rtc_probe); |
335 | { | ||
336 | return platform_driver_probe(&mv_rtc_driver, mv_rtc_probe); | ||
337 | } | ||
338 | |||
339 | static __exit void mv_exit(void) | ||
340 | { | ||
341 | platform_driver_unregister(&mv_rtc_driver); | ||
342 | } | ||
343 | |||
344 | module_init(mv_init); | ||
345 | module_exit(mv_exit); | ||
346 | 335 | ||
347 | MODULE_AUTHOR("Saeed Bishara <saeed@marvell.com>"); | 336 | MODULE_AUTHOR("Saeed Bishara <saeed@marvell.com>"); |
348 | MODULE_DESCRIPTION("Marvell RTC driver"); | 337 | MODULE_DESCRIPTION("Marvell RTC driver"); |
diff --git a/drivers/rtc/rtc-mxc.c b/drivers/rtc/rtc-mxc.c index 1c3ef7289565..9a3895bc4f4d 100644 --- a/drivers/rtc/rtc-mxc.c +++ b/drivers/rtc/rtc-mxc.c | |||
@@ -439,7 +439,7 @@ static int mxc_rtc_probe(struct platform_device *pdev) | |||
439 | if (pdata->irq >=0) | 439 | if (pdata->irq >=0) |
440 | device_init_wakeup(&pdev->dev, 1); | 440 | device_init_wakeup(&pdev->dev, 1); |
441 | 441 | ||
442 | rtc = rtc_device_register(pdev->name, &pdev->dev, &mxc_rtc_ops, | 442 | rtc = devm_rtc_device_register(&pdev->dev, pdev->name, &mxc_rtc_ops, |
443 | THIS_MODULE); | 443 | THIS_MODULE); |
444 | if (IS_ERR(rtc)) { | 444 | if (IS_ERR(rtc)) { |
445 | ret = PTR_ERR(rtc); | 445 | ret = PTR_ERR(rtc); |
@@ -464,15 +464,13 @@ static int mxc_rtc_remove(struct platform_device *pdev) | |||
464 | { | 464 | { |
465 | struct rtc_plat_data *pdata = platform_get_drvdata(pdev); | 465 | struct rtc_plat_data *pdata = platform_get_drvdata(pdev); |
466 | 466 | ||
467 | rtc_device_unregister(pdata->rtc); | ||
468 | |||
469 | clk_disable_unprepare(pdata->clk); | 467 | clk_disable_unprepare(pdata->clk); |
470 | platform_set_drvdata(pdev, NULL); | 468 | platform_set_drvdata(pdev, NULL); |
471 | 469 | ||
472 | return 0; | 470 | return 0; |
473 | } | 471 | } |
474 | 472 | ||
475 | #ifdef CONFIG_PM | 473 | #ifdef CONFIG_PM_SLEEP |
476 | static int mxc_rtc_suspend(struct device *dev) | 474 | static int mxc_rtc_suspend(struct device *dev) |
477 | { | 475 | { |
478 | struct rtc_plat_data *pdata = dev_get_drvdata(dev); | 476 | struct rtc_plat_data *pdata = dev_get_drvdata(dev); |
@@ -492,19 +490,14 @@ static int mxc_rtc_resume(struct device *dev) | |||
492 | 490 | ||
493 | return 0; | 491 | return 0; |
494 | } | 492 | } |
495 | |||
496 | static struct dev_pm_ops mxc_rtc_pm_ops = { | ||
497 | .suspend = mxc_rtc_suspend, | ||
498 | .resume = mxc_rtc_resume, | ||
499 | }; | ||
500 | #endif | 493 | #endif |
501 | 494 | ||
495 | static SIMPLE_DEV_PM_OPS(mxc_rtc_pm_ops, mxc_rtc_suspend, mxc_rtc_resume); | ||
496 | |||
502 | static struct platform_driver mxc_rtc_driver = { | 497 | static struct platform_driver mxc_rtc_driver = { |
503 | .driver = { | 498 | .driver = { |
504 | .name = "mxc_rtc", | 499 | .name = "mxc_rtc", |
505 | #ifdef CONFIG_PM | ||
506 | .pm = &mxc_rtc_pm_ops, | 500 | .pm = &mxc_rtc_pm_ops, |
507 | #endif | ||
508 | .owner = THIS_MODULE, | 501 | .owner = THIS_MODULE, |
509 | }, | 502 | }, |
510 | .id_table = imx_rtc_devtype, | 503 | .id_table = imx_rtc_devtype, |
diff --git a/drivers/rtc/rtc-nuc900.c b/drivers/rtc/rtc-nuc900.c index a63680850fef..f5dfb6e5e7d9 100644 --- a/drivers/rtc/rtc-nuc900.c +++ b/drivers/rtc/rtc-nuc900.c | |||
@@ -222,13 +222,13 @@ static struct rtc_class_ops nuc900_rtc_ops = { | |||
222 | .alarm_irq_enable = nuc900_alarm_irq_enable, | 222 | .alarm_irq_enable = nuc900_alarm_irq_enable, |
223 | }; | 223 | }; |
224 | 224 | ||
225 | static int nuc900_rtc_probe(struct platform_device *pdev) | 225 | static int __init nuc900_rtc_probe(struct platform_device *pdev) |
226 | { | 226 | { |
227 | struct resource *res; | 227 | struct resource *res; |
228 | struct nuc900_rtc *nuc900_rtc; | 228 | struct nuc900_rtc *nuc900_rtc; |
229 | int err = 0; | ||
230 | 229 | ||
231 | nuc900_rtc = kzalloc(sizeof(struct nuc900_rtc), GFP_KERNEL); | 230 | nuc900_rtc = devm_kzalloc(&pdev->dev, sizeof(struct nuc900_rtc), |
231 | GFP_KERNEL); | ||
232 | if (!nuc900_rtc) { | 232 | if (!nuc900_rtc) { |
233 | dev_err(&pdev->dev, "kzalloc nuc900_rtc failed\n"); | 233 | dev_err(&pdev->dev, "kzalloc nuc900_rtc failed\n"); |
234 | return -ENOMEM; | 234 | return -ENOMEM; |
@@ -236,93 +236,51 @@ static int nuc900_rtc_probe(struct platform_device *pdev) | |||
236 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 236 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
237 | if (!res) { | 237 | if (!res) { |
238 | dev_err(&pdev->dev, "platform_get_resource failed\n"); | 238 | dev_err(&pdev->dev, "platform_get_resource failed\n"); |
239 | err = -ENXIO; | 239 | return -ENXIO; |
240 | goto fail1; | ||
241 | } | 240 | } |
242 | 241 | ||
243 | if (!request_mem_region(res->start, resource_size(res), | 242 | nuc900_rtc->rtc_reg = devm_ioremap_resource(&pdev->dev, res); |
244 | pdev->name)) { | 243 | if (IS_ERR(nuc900_rtc->rtc_reg)) |
245 | dev_err(&pdev->dev, "request_mem_region failed\n"); | 244 | return PTR_ERR(nuc900_rtc->rtc_reg); |
246 | err = -EBUSY; | ||
247 | goto fail1; | ||
248 | } | ||
249 | |||
250 | nuc900_rtc->rtc_reg = ioremap(res->start, resource_size(res)); | ||
251 | if (!nuc900_rtc->rtc_reg) { | ||
252 | dev_err(&pdev->dev, "ioremap rtc_reg failed\n"); | ||
253 | err = -ENOMEM; | ||
254 | goto fail2; | ||
255 | } | ||
256 | 245 | ||
257 | platform_set_drvdata(pdev, nuc900_rtc); | 246 | platform_set_drvdata(pdev, nuc900_rtc); |
258 | 247 | ||
259 | nuc900_rtc->rtcdev = rtc_device_register(pdev->name, &pdev->dev, | 248 | nuc900_rtc->rtcdev = devm_rtc_device_register(&pdev->dev, pdev->name, |
260 | &nuc900_rtc_ops, THIS_MODULE); | 249 | &nuc900_rtc_ops, THIS_MODULE); |
261 | if (IS_ERR(nuc900_rtc->rtcdev)) { | 250 | if (IS_ERR(nuc900_rtc->rtcdev)) { |
262 | dev_err(&pdev->dev, "rtc device register failed\n"); | 251 | dev_err(&pdev->dev, "rtc device register failed\n"); |
263 | err = PTR_ERR(nuc900_rtc->rtcdev); | 252 | return PTR_ERR(nuc900_rtc->rtcdev); |
264 | goto fail3; | ||
265 | } | 253 | } |
266 | 254 | ||
267 | __raw_writel(__raw_readl(nuc900_rtc->rtc_reg + REG_RTC_TSSR) | MODE24, | 255 | __raw_writel(__raw_readl(nuc900_rtc->rtc_reg + REG_RTC_TSSR) | MODE24, |
268 | nuc900_rtc->rtc_reg + REG_RTC_TSSR); | 256 | nuc900_rtc->rtc_reg + REG_RTC_TSSR); |
269 | 257 | ||
270 | nuc900_rtc->irq_num = platform_get_irq(pdev, 0); | 258 | nuc900_rtc->irq_num = platform_get_irq(pdev, 0); |
271 | if (request_irq(nuc900_rtc->irq_num, nuc900_rtc_interrupt, | 259 | if (devm_request_irq(&pdev->dev, nuc900_rtc->irq_num, |
272 | 0, "nuc900rtc", nuc900_rtc)) { | 260 | nuc900_rtc_interrupt, 0, "nuc900rtc", nuc900_rtc)) { |
273 | dev_err(&pdev->dev, "NUC900 RTC request irq failed\n"); | 261 | dev_err(&pdev->dev, "NUC900 RTC request irq failed\n"); |
274 | err = -EBUSY; | 262 | return -EBUSY; |
275 | goto fail4; | ||
276 | } | 263 | } |
277 | 264 | ||
278 | return 0; | 265 | return 0; |
279 | |||
280 | fail4: rtc_device_unregister(nuc900_rtc->rtcdev); | ||
281 | fail3: iounmap(nuc900_rtc->rtc_reg); | ||
282 | fail2: release_mem_region(res->start, resource_size(res)); | ||
283 | fail1: kfree(nuc900_rtc); | ||
284 | return err; | ||
285 | } | 266 | } |
286 | 267 | ||
287 | static int nuc900_rtc_remove(struct platform_device *pdev) | 268 | static int __exit nuc900_rtc_remove(struct platform_device *pdev) |
288 | { | 269 | { |
289 | struct nuc900_rtc *nuc900_rtc = platform_get_drvdata(pdev); | ||
290 | struct resource *res; | ||
291 | |||
292 | free_irq(nuc900_rtc->irq_num, nuc900_rtc); | ||
293 | rtc_device_unregister(nuc900_rtc->rtcdev); | ||
294 | iounmap(nuc900_rtc->rtc_reg); | ||
295 | |||
296 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
297 | release_mem_region(res->start, resource_size(res)); | ||
298 | |||
299 | kfree(nuc900_rtc); | ||
300 | |||
301 | platform_set_drvdata(pdev, NULL); | 270 | platform_set_drvdata(pdev, NULL); |
302 | 271 | ||
303 | return 0; | 272 | return 0; |
304 | } | 273 | } |
305 | 274 | ||
306 | static struct platform_driver nuc900_rtc_driver = { | 275 | static struct platform_driver nuc900_rtc_driver = { |
307 | .remove = nuc900_rtc_remove, | 276 | .remove = __exit_p(nuc900_rtc_remove), |
308 | .driver = { | 277 | .driver = { |
309 | .name = "nuc900-rtc", | 278 | .name = "nuc900-rtc", |
310 | .owner = THIS_MODULE, | 279 | .owner = THIS_MODULE, |
311 | }, | 280 | }, |
312 | }; | 281 | }; |
313 | 282 | ||
314 | static int __init nuc900_rtc_init(void) | 283 | module_platform_driver_probe(nuc900_rtc_driver, nuc900_rtc_probe); |
315 | { | ||
316 | return platform_driver_probe(&nuc900_rtc_driver, nuc900_rtc_probe); | ||
317 | } | ||
318 | |||
319 | static void __exit nuc900_rtc_exit(void) | ||
320 | { | ||
321 | platform_driver_unregister(&nuc900_rtc_driver); | ||
322 | } | ||
323 | |||
324 | module_init(nuc900_rtc_init); | ||
325 | module_exit(nuc900_rtc_exit); | ||
326 | 284 | ||
327 | MODULE_AUTHOR("Wan ZongShun <mcuos.com@gmail.com>"); | 285 | MODULE_AUTHOR("Wan ZongShun <mcuos.com@gmail.com>"); |
328 | MODULE_DESCRIPTION("nuc910/nuc920 RTC driver"); | 286 | MODULE_DESCRIPTION("nuc910/nuc920 RTC driver"); |
diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c index 600971407aac..4e1bdb832e37 100644 --- a/drivers/rtc/rtc-omap.c +++ b/drivers/rtc/rtc-omap.c | |||
@@ -324,7 +324,7 @@ MODULE_DEVICE_TABLE(of, omap_rtc_of_match); | |||
324 | 324 | ||
325 | static int __init omap_rtc_probe(struct platform_device *pdev) | 325 | static int __init omap_rtc_probe(struct platform_device *pdev) |
326 | { | 326 | { |
327 | struct resource *res, *mem; | 327 | struct resource *res; |
328 | struct rtc_device *rtc; | 328 | struct rtc_device *rtc; |
329 | u8 reg, new_ctrl; | 329 | u8 reg, new_ctrl; |
330 | const struct platform_device_id *id_entry; | 330 | const struct platform_device_id *id_entry; |
@@ -352,18 +352,9 @@ static int __init omap_rtc_probe(struct platform_device *pdev) | |||
352 | return -ENOENT; | 352 | return -ENOENT; |
353 | } | 353 | } |
354 | 354 | ||
355 | mem = request_mem_region(res->start, resource_size(res), pdev->name); | 355 | rtc_base = devm_ioremap_resource(&pdev->dev, res); |
356 | if (!mem) { | 356 | if (IS_ERR(rtc_base)) |
357 | pr_debug("%s: RTC registers at %08x are not free\n", | 357 | return PTR_ERR(rtc_base); |
358 | pdev->name, res->start); | ||
359 | return -EBUSY; | ||
360 | } | ||
361 | |||
362 | rtc_base = ioremap(res->start, resource_size(res)); | ||
363 | if (!rtc_base) { | ||
364 | pr_debug("%s: RTC registers can't be mapped\n", pdev->name); | ||
365 | goto fail; | ||
366 | } | ||
367 | 358 | ||
368 | /* Enable the clock/module so that we can access the registers */ | 359 | /* Enable the clock/module so that we can access the registers */ |
369 | pm_runtime_enable(&pdev->dev); | 360 | pm_runtime_enable(&pdev->dev); |
@@ -375,7 +366,7 @@ static int __init omap_rtc_probe(struct platform_device *pdev) | |||
375 | rtc_writel(KICK1_VALUE, OMAP_RTC_KICK1_REG); | 366 | rtc_writel(KICK1_VALUE, OMAP_RTC_KICK1_REG); |
376 | } | 367 | } |
377 | 368 | ||
378 | rtc = rtc_device_register(pdev->name, &pdev->dev, | 369 | rtc = devm_rtc_device_register(&pdev->dev, pdev->name, |
379 | &omap_rtc_ops, THIS_MODULE); | 370 | &omap_rtc_ops, THIS_MODULE); |
380 | if (IS_ERR(rtc)) { | 371 | if (IS_ERR(rtc)) { |
381 | pr_debug("%s: can't register RTC device, err %ld\n", | 372 | pr_debug("%s: can't register RTC device, err %ld\n", |
@@ -383,7 +374,6 @@ static int __init omap_rtc_probe(struct platform_device *pdev) | |||
383 | goto fail0; | 374 | goto fail0; |
384 | } | 375 | } |
385 | platform_set_drvdata(pdev, rtc); | 376 | platform_set_drvdata(pdev, rtc); |
386 | dev_set_drvdata(&rtc->dev, mem); | ||
387 | 377 | ||
388 | /* clear pending irqs, and set 1/second periodic, | 378 | /* clear pending irqs, and set 1/second periodic, |
389 | * which we'll use instead of update irqs | 379 | * which we'll use instead of update irqs |
@@ -401,18 +391,18 @@ static int __init omap_rtc_probe(struct platform_device *pdev) | |||
401 | rtc_write(OMAP_RTC_STATUS_ALARM, OMAP_RTC_STATUS_REG); | 391 | rtc_write(OMAP_RTC_STATUS_ALARM, OMAP_RTC_STATUS_REG); |
402 | 392 | ||
403 | /* handle periodic and alarm irqs */ | 393 | /* handle periodic and alarm irqs */ |
404 | if (request_irq(omap_rtc_timer, rtc_irq, 0, | 394 | if (devm_request_irq(&pdev->dev, omap_rtc_timer, rtc_irq, 0, |
405 | dev_name(&rtc->dev), rtc)) { | 395 | dev_name(&rtc->dev), rtc)) { |
406 | pr_debug("%s: RTC timer interrupt IRQ%d already claimed\n", | 396 | pr_debug("%s: RTC timer interrupt IRQ%d already claimed\n", |
407 | pdev->name, omap_rtc_timer); | 397 | pdev->name, omap_rtc_timer); |
408 | goto fail1; | 398 | goto fail0; |
409 | } | 399 | } |
410 | if ((omap_rtc_timer != omap_rtc_alarm) && | 400 | if ((omap_rtc_timer != omap_rtc_alarm) && |
411 | (request_irq(omap_rtc_alarm, rtc_irq, 0, | 401 | (devm_request_irq(&pdev->dev, omap_rtc_alarm, rtc_irq, 0, |
412 | dev_name(&rtc->dev), rtc))) { | 402 | dev_name(&rtc->dev), rtc))) { |
413 | pr_debug("%s: RTC alarm interrupt IRQ%d already claimed\n", | 403 | pr_debug("%s: RTC alarm interrupt IRQ%d already claimed\n", |
414 | pdev->name, omap_rtc_alarm); | 404 | pdev->name, omap_rtc_alarm); |
415 | goto fail2; | 405 | goto fail0; |
416 | } | 406 | } |
417 | 407 | ||
418 | /* On boards with split power, RTC_ON_NOFF won't reset the RTC */ | 408 | /* On boards with split power, RTC_ON_NOFF won't reset the RTC */ |
@@ -446,25 +436,16 @@ static int __init omap_rtc_probe(struct platform_device *pdev) | |||
446 | 436 | ||
447 | return 0; | 437 | return 0; |
448 | 438 | ||
449 | fail2: | ||
450 | free_irq(omap_rtc_timer, rtc); | ||
451 | fail1: | ||
452 | rtc_device_unregister(rtc); | ||
453 | fail0: | 439 | fail0: |
454 | if (id_entry && (id_entry->driver_data & OMAP_RTC_HAS_KICKER)) | 440 | if (id_entry && (id_entry->driver_data & OMAP_RTC_HAS_KICKER)) |
455 | rtc_writel(0, OMAP_RTC_KICK0_REG); | 441 | rtc_writel(0, OMAP_RTC_KICK0_REG); |
456 | pm_runtime_put_sync(&pdev->dev); | 442 | pm_runtime_put_sync(&pdev->dev); |
457 | pm_runtime_disable(&pdev->dev); | 443 | pm_runtime_disable(&pdev->dev); |
458 | iounmap(rtc_base); | ||
459 | fail: | ||
460 | release_mem_region(mem->start, resource_size(mem)); | ||
461 | return -EIO; | 444 | return -EIO; |
462 | } | 445 | } |
463 | 446 | ||
464 | static int __exit omap_rtc_remove(struct platform_device *pdev) | 447 | static int __exit omap_rtc_remove(struct platform_device *pdev) |
465 | { | 448 | { |
466 | struct rtc_device *rtc = platform_get_drvdata(pdev); | ||
467 | struct resource *mem = dev_get_drvdata(&rtc->dev); | ||
468 | const struct platform_device_id *id_entry = | 449 | const struct platform_device_id *id_entry = |
469 | platform_get_device_id(pdev); | 450 | platform_get_device_id(pdev); |
470 | 451 | ||
@@ -473,12 +454,6 @@ static int __exit omap_rtc_remove(struct platform_device *pdev) | |||
473 | /* leave rtc running, but disable irqs */ | 454 | /* leave rtc running, but disable irqs */ |
474 | rtc_write(0, OMAP_RTC_INTERRUPTS_REG); | 455 | rtc_write(0, OMAP_RTC_INTERRUPTS_REG); |
475 | 456 | ||
476 | free_irq(omap_rtc_timer, rtc); | ||
477 | |||
478 | if (omap_rtc_timer != omap_rtc_alarm) | ||
479 | free_irq(omap_rtc_alarm, rtc); | ||
480 | |||
481 | rtc_device_unregister(rtc); | ||
482 | if (id_entry && (id_entry->driver_data & OMAP_RTC_HAS_KICKER)) | 457 | if (id_entry && (id_entry->driver_data & OMAP_RTC_HAS_KICKER)) |
483 | rtc_writel(0, OMAP_RTC_KICK0_REG); | 458 | rtc_writel(0, OMAP_RTC_KICK0_REG); |
484 | 459 | ||
@@ -486,16 +461,13 @@ static int __exit omap_rtc_remove(struct platform_device *pdev) | |||
486 | pm_runtime_put_sync(&pdev->dev); | 461 | pm_runtime_put_sync(&pdev->dev); |
487 | pm_runtime_disable(&pdev->dev); | 462 | pm_runtime_disable(&pdev->dev); |
488 | 463 | ||
489 | iounmap(rtc_base); | ||
490 | release_mem_region(mem->start, resource_size(mem)); | ||
491 | return 0; | 464 | return 0; |
492 | } | 465 | } |
493 | 466 | ||
494 | #ifdef CONFIG_PM | 467 | #ifdef CONFIG_PM_SLEEP |
495 | |||
496 | static u8 irqstat; | 468 | static u8 irqstat; |
497 | 469 | ||
498 | static int omap_rtc_suspend(struct platform_device *pdev, pm_message_t state) | 470 | static int omap_rtc_suspend(struct device *dev) |
499 | { | 471 | { |
500 | irqstat = rtc_read(OMAP_RTC_INTERRUPTS_REG); | 472 | irqstat = rtc_read(OMAP_RTC_INTERRUPTS_REG); |
501 | 473 | ||
@@ -503,34 +475,32 @@ static int omap_rtc_suspend(struct platform_device *pdev, pm_message_t state) | |||
503 | * source, and in fact this enable() call is just saving a flag | 475 | * source, and in fact this enable() call is just saving a flag |
504 | * that's never used... | 476 | * that's never used... |
505 | */ | 477 | */ |
506 | if (device_may_wakeup(&pdev->dev)) | 478 | if (device_may_wakeup(dev)) |
507 | enable_irq_wake(omap_rtc_alarm); | 479 | enable_irq_wake(omap_rtc_alarm); |
508 | else | 480 | else |
509 | rtc_write(0, OMAP_RTC_INTERRUPTS_REG); | 481 | rtc_write(0, OMAP_RTC_INTERRUPTS_REG); |
510 | 482 | ||
511 | /* Disable the clock/module */ | 483 | /* Disable the clock/module */ |
512 | pm_runtime_put_sync(&pdev->dev); | 484 | pm_runtime_put_sync(dev); |
513 | 485 | ||
514 | return 0; | 486 | return 0; |
515 | } | 487 | } |
516 | 488 | ||
517 | static int omap_rtc_resume(struct platform_device *pdev) | 489 | static int omap_rtc_resume(struct device *dev) |
518 | { | 490 | { |
519 | /* Enable the clock/module so that we can access the registers */ | 491 | /* Enable the clock/module so that we can access the registers */ |
520 | pm_runtime_get_sync(&pdev->dev); | 492 | pm_runtime_get_sync(dev); |
521 | 493 | ||
522 | if (device_may_wakeup(&pdev->dev)) | 494 | if (device_may_wakeup(dev)) |
523 | disable_irq_wake(omap_rtc_alarm); | 495 | disable_irq_wake(omap_rtc_alarm); |
524 | else | 496 | else |
525 | rtc_write(irqstat, OMAP_RTC_INTERRUPTS_REG); | 497 | rtc_write(irqstat, OMAP_RTC_INTERRUPTS_REG); |
526 | return 0; | 498 | return 0; |
527 | } | 499 | } |
528 | |||
529 | #else | ||
530 | #define omap_rtc_suspend NULL | ||
531 | #define omap_rtc_resume NULL | ||
532 | #endif | 500 | #endif |
533 | 501 | ||
502 | static SIMPLE_DEV_PM_OPS(omap_rtc_pm_ops, omap_rtc_suspend, omap_rtc_resume); | ||
503 | |||
534 | static void omap_rtc_shutdown(struct platform_device *pdev) | 504 | static void omap_rtc_shutdown(struct platform_device *pdev) |
535 | { | 505 | { |
536 | rtc_write(0, OMAP_RTC_INTERRUPTS_REG); | 506 | rtc_write(0, OMAP_RTC_INTERRUPTS_REG); |
@@ -539,28 +509,17 @@ static void omap_rtc_shutdown(struct platform_device *pdev) | |||
539 | MODULE_ALIAS("platform:omap_rtc"); | 509 | MODULE_ALIAS("platform:omap_rtc"); |
540 | static struct platform_driver omap_rtc_driver = { | 510 | static struct platform_driver omap_rtc_driver = { |
541 | .remove = __exit_p(omap_rtc_remove), | 511 | .remove = __exit_p(omap_rtc_remove), |
542 | .suspend = omap_rtc_suspend, | ||
543 | .resume = omap_rtc_resume, | ||
544 | .shutdown = omap_rtc_shutdown, | 512 | .shutdown = omap_rtc_shutdown, |
545 | .driver = { | 513 | .driver = { |
546 | .name = DRIVER_NAME, | 514 | .name = DRIVER_NAME, |
547 | .owner = THIS_MODULE, | 515 | .owner = THIS_MODULE, |
516 | .pm = &omap_rtc_pm_ops, | ||
548 | .of_match_table = of_match_ptr(omap_rtc_of_match), | 517 | .of_match_table = of_match_ptr(omap_rtc_of_match), |
549 | }, | 518 | }, |
550 | .id_table = omap_rtc_devtype, | 519 | .id_table = omap_rtc_devtype, |
551 | }; | 520 | }; |
552 | 521 | ||
553 | static int __init rtc_init(void) | 522 | module_platform_driver_probe(omap_rtc_driver, omap_rtc_probe); |
554 | { | ||
555 | return platform_driver_probe(&omap_rtc_driver, omap_rtc_probe); | ||
556 | } | ||
557 | module_init(rtc_init); | ||
558 | |||
559 | static void __exit rtc_exit(void) | ||
560 | { | ||
561 | platform_driver_unregister(&omap_rtc_driver); | ||
562 | } | ||
563 | module_exit(rtc_exit); | ||
564 | 523 | ||
565 | MODULE_AUTHOR("George G. Davis (and others)"); | 524 | MODULE_AUTHOR("George G. Davis (and others)"); |
566 | MODULE_LICENSE("GPL"); | 525 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/rtc/rtc-palmas.c b/drivers/rtc/rtc-palmas.c index 59c42986254e..50204d474eb7 100644 --- a/drivers/rtc/rtc-palmas.c +++ b/drivers/rtc/rtc-palmas.c | |||
@@ -30,6 +30,7 @@ | |||
30 | #include <linux/kernel.h> | 30 | #include <linux/kernel.h> |
31 | #include <linux/mfd/palmas.h> | 31 | #include <linux/mfd/palmas.h> |
32 | #include <linux/module.h> | 32 | #include <linux/module.h> |
33 | #include <linux/of.h> | ||
33 | #include <linux/rtc.h> | 34 | #include <linux/rtc.h> |
34 | #include <linux/types.h> | 35 | #include <linux/types.h> |
35 | #include <linux/platform_device.h> | 36 | #include <linux/platform_device.h> |
@@ -264,7 +265,7 @@ static int palmas_rtc_probe(struct platform_device *pdev) | |||
264 | 265 | ||
265 | palmas_rtc->irq = platform_get_irq(pdev, 0); | 266 | palmas_rtc->irq = platform_get_irq(pdev, 0); |
266 | 267 | ||
267 | palmas_rtc->rtc = rtc_device_register(pdev->name, &pdev->dev, | 268 | palmas_rtc->rtc = devm_rtc_device_register(&pdev->dev, pdev->name, |
268 | &palmas_rtc_ops, THIS_MODULE); | 269 | &palmas_rtc_ops, THIS_MODULE); |
269 | if (IS_ERR(palmas_rtc->rtc)) { | 270 | if (IS_ERR(palmas_rtc->rtc)) { |
270 | ret = PTR_ERR(palmas_rtc->rtc); | 271 | ret = PTR_ERR(palmas_rtc->rtc); |
@@ -272,14 +273,13 @@ static int palmas_rtc_probe(struct platform_device *pdev) | |||
272 | return ret; | 273 | return ret; |
273 | } | 274 | } |
274 | 275 | ||
275 | ret = request_threaded_irq(palmas_rtc->irq, NULL, | 276 | ret = devm_request_threaded_irq(&pdev->dev, palmas_rtc->irq, NULL, |
276 | palmas_rtc_interrupt, | 277 | palmas_rtc_interrupt, |
277 | IRQF_TRIGGER_LOW | IRQF_ONESHOT | | 278 | IRQF_TRIGGER_LOW | IRQF_ONESHOT | |
278 | IRQF_EARLY_RESUME, | 279 | IRQF_EARLY_RESUME, |
279 | dev_name(&pdev->dev), palmas_rtc); | 280 | dev_name(&pdev->dev), palmas_rtc); |
280 | if (ret < 0) { | 281 | if (ret < 0) { |
281 | dev_err(&pdev->dev, "IRQ request failed, err = %d\n", ret); | 282 | dev_err(&pdev->dev, "IRQ request failed, err = %d\n", ret); |
282 | rtc_device_unregister(palmas_rtc->rtc); | ||
283 | return ret; | 283 | return ret; |
284 | } | 284 | } |
285 | 285 | ||
@@ -289,11 +289,7 @@ static int palmas_rtc_probe(struct platform_device *pdev) | |||
289 | 289 | ||
290 | static int palmas_rtc_remove(struct platform_device *pdev) | 290 | static int palmas_rtc_remove(struct platform_device *pdev) |
291 | { | 291 | { |
292 | struct palmas_rtc *palmas_rtc = platform_get_drvdata(pdev); | ||
293 | |||
294 | palmas_rtc_alarm_irq_enable(&pdev->dev, 0); | 292 | palmas_rtc_alarm_irq_enable(&pdev->dev, 0); |
295 | free_irq(palmas_rtc->irq, palmas_rtc); | ||
296 | rtc_device_unregister(palmas_rtc->rtc); | ||
297 | return 0; | 293 | return 0; |
298 | } | 294 | } |
299 | 295 | ||
@@ -321,6 +317,14 @@ static const struct dev_pm_ops palmas_rtc_pm_ops = { | |||
321 | SET_SYSTEM_SLEEP_PM_OPS(palmas_rtc_suspend, palmas_rtc_resume) | 317 | SET_SYSTEM_SLEEP_PM_OPS(palmas_rtc_suspend, palmas_rtc_resume) |
322 | }; | 318 | }; |
323 | 319 | ||
320 | #ifdef CONFIG_OF | ||
321 | static struct of_device_id of_palmas_rtc_match[] = { | ||
322 | { .compatible = "ti,palmas-rtc"}, | ||
323 | { }, | ||
324 | }; | ||
325 | MODULE_DEVICE_TABLE(of, of_palmas_rtc_match); | ||
326 | #endif | ||
327 | |||
324 | static struct platform_driver palmas_rtc_driver = { | 328 | static struct platform_driver palmas_rtc_driver = { |
325 | .probe = palmas_rtc_probe, | 329 | .probe = palmas_rtc_probe, |
326 | .remove = palmas_rtc_remove, | 330 | .remove = palmas_rtc_remove, |
@@ -328,6 +332,7 @@ static struct platform_driver palmas_rtc_driver = { | |||
328 | .owner = THIS_MODULE, | 332 | .owner = THIS_MODULE, |
329 | .name = "palmas-rtc", | 333 | .name = "palmas-rtc", |
330 | .pm = &palmas_rtc_pm_ops, | 334 | .pm = &palmas_rtc_pm_ops, |
335 | .of_match_table = of_match_ptr(of_palmas_rtc_match), | ||
331 | }, | 336 | }, |
332 | }; | 337 | }; |
333 | 338 | ||
diff --git a/drivers/rtc/rtc-pcap.c b/drivers/rtc/rtc-pcap.c index e0019cd0bf71..539a90b98bc5 100644 --- a/drivers/rtc/rtc-pcap.c +++ b/drivers/rtc/rtc-pcap.c | |||
@@ -139,13 +139,14 @@ static const struct rtc_class_ops pcap_rtc_ops = { | |||
139 | .alarm_irq_enable = pcap_rtc_alarm_irq_enable, | 139 | .alarm_irq_enable = pcap_rtc_alarm_irq_enable, |
140 | }; | 140 | }; |
141 | 141 | ||
142 | static int pcap_rtc_probe(struct platform_device *pdev) | 142 | static int __init pcap_rtc_probe(struct platform_device *pdev) |
143 | { | 143 | { |
144 | struct pcap_rtc *pcap_rtc; | 144 | struct pcap_rtc *pcap_rtc; |
145 | int timer_irq, alarm_irq; | 145 | int timer_irq, alarm_irq; |
146 | int err = -ENOMEM; | 146 | int err = -ENOMEM; |
147 | 147 | ||
148 | pcap_rtc = kmalloc(sizeof(struct pcap_rtc), GFP_KERNEL); | 148 | pcap_rtc = devm_kzalloc(&pdev->dev, sizeof(struct pcap_rtc), |
149 | GFP_KERNEL); | ||
149 | if (!pcap_rtc) | 150 | if (!pcap_rtc) |
150 | return err; | 151 | return err; |
151 | 152 | ||
@@ -153,68 +154,46 @@ static int pcap_rtc_probe(struct platform_device *pdev) | |||
153 | 154 | ||
154 | platform_set_drvdata(pdev, pcap_rtc); | 155 | platform_set_drvdata(pdev, pcap_rtc); |
155 | 156 | ||
156 | pcap_rtc->rtc = rtc_device_register("pcap", &pdev->dev, | 157 | pcap_rtc->rtc = devm_rtc_device_register(&pdev->dev, "pcap", |
157 | &pcap_rtc_ops, THIS_MODULE); | 158 | &pcap_rtc_ops, THIS_MODULE); |
158 | if (IS_ERR(pcap_rtc->rtc)) { | 159 | if (IS_ERR(pcap_rtc->rtc)) { |
159 | err = PTR_ERR(pcap_rtc->rtc); | 160 | err = PTR_ERR(pcap_rtc->rtc); |
160 | goto fail_rtc; | 161 | goto fail; |
161 | } | 162 | } |
162 | 163 | ||
163 | |||
164 | timer_irq = pcap_to_irq(pcap_rtc->pcap, PCAP_IRQ_1HZ); | 164 | timer_irq = pcap_to_irq(pcap_rtc->pcap, PCAP_IRQ_1HZ); |
165 | alarm_irq = pcap_to_irq(pcap_rtc->pcap, PCAP_IRQ_TODA); | 165 | alarm_irq = pcap_to_irq(pcap_rtc->pcap, PCAP_IRQ_TODA); |
166 | 166 | ||
167 | err = request_irq(timer_irq, pcap_rtc_irq, 0, "RTC Timer", pcap_rtc); | 167 | err = devm_request_irq(&pdev->dev, timer_irq, pcap_rtc_irq, 0, |
168 | "RTC Timer", pcap_rtc); | ||
168 | if (err) | 169 | if (err) |
169 | goto fail_timer; | 170 | goto fail; |
170 | 171 | ||
171 | err = request_irq(alarm_irq, pcap_rtc_irq, 0, "RTC Alarm", pcap_rtc); | 172 | err = devm_request_irq(&pdev->dev, alarm_irq, pcap_rtc_irq, 0, |
173 | "RTC Alarm", pcap_rtc); | ||
172 | if (err) | 174 | if (err) |
173 | goto fail_alarm; | 175 | goto fail; |
174 | 176 | ||
175 | return 0; | 177 | return 0; |
176 | fail_alarm: | 178 | fail: |
177 | free_irq(timer_irq, pcap_rtc); | ||
178 | fail_timer: | ||
179 | rtc_device_unregister(pcap_rtc->rtc); | ||
180 | fail_rtc: | ||
181 | platform_set_drvdata(pdev, NULL); | 179 | platform_set_drvdata(pdev, NULL); |
182 | kfree(pcap_rtc); | ||
183 | return err; | 180 | return err; |
184 | } | 181 | } |
185 | 182 | ||
186 | static int pcap_rtc_remove(struct platform_device *pdev) | 183 | static int __exit pcap_rtc_remove(struct platform_device *pdev) |
187 | { | 184 | { |
188 | struct pcap_rtc *pcap_rtc = platform_get_drvdata(pdev); | ||
189 | |||
190 | free_irq(pcap_to_irq(pcap_rtc->pcap, PCAP_IRQ_1HZ), pcap_rtc); | ||
191 | free_irq(pcap_to_irq(pcap_rtc->pcap, PCAP_IRQ_TODA), pcap_rtc); | ||
192 | rtc_device_unregister(pcap_rtc->rtc); | ||
193 | kfree(pcap_rtc); | ||
194 | |||
195 | return 0; | 185 | return 0; |
196 | } | 186 | } |
197 | 187 | ||
198 | static struct platform_driver pcap_rtc_driver = { | 188 | static struct platform_driver pcap_rtc_driver = { |
199 | .remove = pcap_rtc_remove, | 189 | .remove = __exit_p(pcap_rtc_remove), |
200 | .driver = { | 190 | .driver = { |
201 | .name = "pcap-rtc", | 191 | .name = "pcap-rtc", |
202 | .owner = THIS_MODULE, | 192 | .owner = THIS_MODULE, |
203 | }, | 193 | }, |
204 | }; | 194 | }; |
205 | 195 | ||
206 | static int __init rtc_pcap_init(void) | 196 | module_platform_driver_probe(pcap_rtc_driver, pcap_rtc_probe); |
207 | { | ||
208 | return platform_driver_probe(&pcap_rtc_driver, pcap_rtc_probe); | ||
209 | } | ||
210 | |||
211 | static void __exit rtc_pcap_exit(void) | ||
212 | { | ||
213 | platform_driver_unregister(&pcap_rtc_driver); | ||
214 | } | ||
215 | |||
216 | module_init(rtc_pcap_init); | ||
217 | module_exit(rtc_pcap_exit); | ||
218 | 197 | ||
219 | MODULE_DESCRIPTION("Motorola pcap rtc driver"); | 198 | MODULE_DESCRIPTION("Motorola pcap rtc driver"); |
220 | MODULE_AUTHOR("guiming zhuo <gmzhuo@gmail.com>"); | 199 | MODULE_AUTHOR("guiming zhuo <gmzhuo@gmail.com>"); |
diff --git a/drivers/rtc/rtc-pcf2123.c b/drivers/rtc/rtc-pcf2123.c index 02b742afa761..796a6c5067dd 100644 --- a/drivers/rtc/rtc-pcf2123.c +++ b/drivers/rtc/rtc-pcf2123.c | |||
@@ -226,7 +226,8 @@ static int pcf2123_probe(struct spi_device *spi) | |||
226 | u8 txbuf[2], rxbuf[2]; | 226 | u8 txbuf[2], rxbuf[2]; |
227 | int ret, i; | 227 | int ret, i; |
228 | 228 | ||
229 | pdata = kzalloc(sizeof(struct pcf2123_plat_data), GFP_KERNEL); | 229 | pdata = devm_kzalloc(&spi->dev, sizeof(struct pcf2123_plat_data), |
230 | GFP_KERNEL); | ||
230 | if (!pdata) | 231 | if (!pdata) |
231 | return -ENOMEM; | 232 | return -ENOMEM; |
232 | spi->dev.platform_data = pdata; | 233 | spi->dev.platform_data = pdata; |
@@ -265,6 +266,7 @@ static int pcf2123_probe(struct spi_device *spi) | |||
265 | 266 | ||
266 | if (!(rxbuf[0] & 0x20)) { | 267 | if (!(rxbuf[0] & 0x20)) { |
267 | dev_err(&spi->dev, "chip not found\n"); | 268 | dev_err(&spi->dev, "chip not found\n"); |
269 | ret = -ENODEV; | ||
268 | goto kfree_exit; | 270 | goto kfree_exit; |
269 | } | 271 | } |
270 | 272 | ||
@@ -281,7 +283,7 @@ static int pcf2123_probe(struct spi_device *spi) | |||
281 | pcf2123_delay_trec(); | 283 | pcf2123_delay_trec(); |
282 | 284 | ||
283 | /* Finalize the initialization */ | 285 | /* Finalize the initialization */ |
284 | rtc = rtc_device_register(pcf2123_driver.driver.name, &spi->dev, | 286 | rtc = devm_rtc_device_register(&spi->dev, pcf2123_driver.driver.name, |
285 | &pcf2123_rtc_ops, THIS_MODULE); | 287 | &pcf2123_rtc_ops, THIS_MODULE); |
286 | 288 | ||
287 | if (IS_ERR(rtc)) { | 289 | if (IS_ERR(rtc)) { |
@@ -314,7 +316,6 @@ sysfs_exit: | |||
314 | device_remove_file(&spi->dev, &pdata->regs[i].attr); | 316 | device_remove_file(&spi->dev, &pdata->regs[i].attr); |
315 | 317 | ||
316 | kfree_exit: | 318 | kfree_exit: |
317 | kfree(pdata); | ||
318 | spi->dev.platform_data = NULL; | 319 | spi->dev.platform_data = NULL; |
319 | return ret; | 320 | return ret; |
320 | } | 321 | } |
@@ -325,15 +326,10 @@ static int pcf2123_remove(struct spi_device *spi) | |||
325 | int i; | 326 | int i; |
326 | 327 | ||
327 | if (pdata) { | 328 | if (pdata) { |
328 | struct rtc_device *rtc = pdata->rtc; | ||
329 | |||
330 | if (rtc) | ||
331 | rtc_device_unregister(rtc); | ||
332 | for (i = 0; i < 16; i++) | 329 | for (i = 0; i < 16; i++) |
333 | if (pdata->regs[i].name[0]) | 330 | if (pdata->regs[i].name[0]) |
334 | device_remove_file(&spi->dev, | 331 | device_remove_file(&spi->dev, |
335 | &pdata->regs[i].attr); | 332 | &pdata->regs[i].attr); |
336 | kfree(pdata); | ||
337 | } | 333 | } |
338 | 334 | ||
339 | return 0; | 335 | return 0; |
diff --git a/drivers/rtc/rtc-pcf50633.c b/drivers/rtc/rtc-pcf50633.c index e9f3135d305f..e6b6911c8e05 100644 --- a/drivers/rtc/rtc-pcf50633.c +++ b/drivers/rtc/rtc-pcf50633.c | |||
@@ -252,20 +252,17 @@ static int pcf50633_rtc_probe(struct platform_device *pdev) | |||
252 | { | 252 | { |
253 | struct pcf50633_rtc *rtc; | 253 | struct pcf50633_rtc *rtc; |
254 | 254 | ||
255 | rtc = kzalloc(sizeof(*rtc), GFP_KERNEL); | 255 | rtc = devm_kzalloc(&pdev->dev, sizeof(*rtc), GFP_KERNEL); |
256 | if (!rtc) | 256 | if (!rtc) |
257 | return -ENOMEM; | 257 | return -ENOMEM; |
258 | 258 | ||
259 | rtc->pcf = dev_to_pcf50633(pdev->dev.parent); | 259 | rtc->pcf = dev_to_pcf50633(pdev->dev.parent); |
260 | platform_set_drvdata(pdev, rtc); | 260 | platform_set_drvdata(pdev, rtc); |
261 | rtc->rtc_dev = rtc_device_register("pcf50633-rtc", &pdev->dev, | 261 | rtc->rtc_dev = devm_rtc_device_register(&pdev->dev, "pcf50633-rtc", |
262 | &pcf50633_rtc_ops, THIS_MODULE); | 262 | &pcf50633_rtc_ops, THIS_MODULE); |
263 | 263 | ||
264 | if (IS_ERR(rtc->rtc_dev)) { | 264 | if (IS_ERR(rtc->rtc_dev)) |
265 | int ret = PTR_ERR(rtc->rtc_dev); | 265 | return PTR_ERR(rtc->rtc_dev); |
266 | kfree(rtc); | ||
267 | return ret; | ||
268 | } | ||
269 | 266 | ||
270 | pcf50633_register_irq(rtc->pcf, PCF50633_IRQ_ALARM, | 267 | pcf50633_register_irq(rtc->pcf, PCF50633_IRQ_ALARM, |
271 | pcf50633_rtc_irq, rtc); | 268 | pcf50633_rtc_irq, rtc); |
@@ -277,12 +274,8 @@ static int pcf50633_rtc_remove(struct platform_device *pdev) | |||
277 | struct pcf50633_rtc *rtc; | 274 | struct pcf50633_rtc *rtc; |
278 | 275 | ||
279 | rtc = platform_get_drvdata(pdev); | 276 | rtc = platform_get_drvdata(pdev); |
280 | |||
281 | pcf50633_free_irq(rtc->pcf, PCF50633_IRQ_ALARM); | 277 | pcf50633_free_irq(rtc->pcf, PCF50633_IRQ_ALARM); |
282 | 278 | ||
283 | rtc_device_unregister(rtc->rtc_dev); | ||
284 | kfree(rtc); | ||
285 | |||
286 | return 0; | 279 | return 0; |
287 | } | 280 | } |
288 | 281 | ||
diff --git a/drivers/rtc/rtc-pcf8523.c b/drivers/rtc/rtc-pcf8523.c index 889e3160e701..305c9515e5bb 100644 --- a/drivers/rtc/rtc-pcf8523.c +++ b/drivers/rtc/rtc-pcf8523.c | |||
@@ -307,7 +307,7 @@ static int pcf8523_probe(struct i2c_client *client, | |||
307 | if (err < 0) | 307 | if (err < 0) |
308 | return err; | 308 | return err; |
309 | 309 | ||
310 | pcf->rtc = rtc_device_register(DRIVER_NAME, &client->dev, | 310 | pcf->rtc = devm_rtc_device_register(&client->dev, DRIVER_NAME, |
311 | &pcf8523_rtc_ops, THIS_MODULE); | 311 | &pcf8523_rtc_ops, THIS_MODULE); |
312 | if (IS_ERR(pcf->rtc)) | 312 | if (IS_ERR(pcf->rtc)) |
313 | return PTR_ERR(pcf->rtc); | 313 | return PTR_ERR(pcf->rtc); |
@@ -319,10 +319,6 @@ static int pcf8523_probe(struct i2c_client *client, | |||
319 | 319 | ||
320 | static int pcf8523_remove(struct i2c_client *client) | 320 | static int pcf8523_remove(struct i2c_client *client) |
321 | { | 321 | { |
322 | struct pcf8523 *pcf = i2c_get_clientdata(client); | ||
323 | |||
324 | rtc_device_unregister(pcf->rtc); | ||
325 | |||
326 | return 0; | 322 | return 0; |
327 | } | 323 | } |
328 | 324 | ||
diff --git a/drivers/rtc/rtc-pcf8563.c b/drivers/rtc/rtc-pcf8563.c index f7daf18a112e..97b354a26a44 100644 --- a/drivers/rtc/rtc-pcf8563.c +++ b/drivers/rtc/rtc-pcf8563.c | |||
@@ -245,14 +245,13 @@ static int pcf8563_probe(struct i2c_client *client, | |||
245 | { | 245 | { |
246 | struct pcf8563 *pcf8563; | 246 | struct pcf8563 *pcf8563; |
247 | 247 | ||
248 | int err = 0; | ||
249 | |||
250 | dev_dbg(&client->dev, "%s\n", __func__); | 248 | dev_dbg(&client->dev, "%s\n", __func__); |
251 | 249 | ||
252 | if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) | 250 | if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) |
253 | return -ENODEV; | 251 | return -ENODEV; |
254 | 252 | ||
255 | pcf8563 = kzalloc(sizeof(struct pcf8563), GFP_KERNEL); | 253 | pcf8563 = devm_kzalloc(&client->dev, sizeof(struct pcf8563), |
254 | GFP_KERNEL); | ||
256 | if (!pcf8563) | 255 | if (!pcf8563) |
257 | return -ENOMEM; | 256 | return -ENOMEM; |
258 | 257 | ||
@@ -260,31 +259,18 @@ static int pcf8563_probe(struct i2c_client *client, | |||
260 | 259 | ||
261 | i2c_set_clientdata(client, pcf8563); | 260 | i2c_set_clientdata(client, pcf8563); |
262 | 261 | ||
263 | pcf8563->rtc = rtc_device_register(pcf8563_driver.driver.name, | 262 | pcf8563->rtc = devm_rtc_device_register(&client->dev, |
264 | &client->dev, &pcf8563_rtc_ops, THIS_MODULE); | 263 | pcf8563_driver.driver.name, |
264 | &pcf8563_rtc_ops, THIS_MODULE); | ||
265 | 265 | ||
266 | if (IS_ERR(pcf8563->rtc)) { | 266 | if (IS_ERR(pcf8563->rtc)) |
267 | err = PTR_ERR(pcf8563->rtc); | 267 | return PTR_ERR(pcf8563->rtc); |
268 | goto exit_kfree; | ||
269 | } | ||
270 | 268 | ||
271 | return 0; | 269 | return 0; |
272 | |||
273 | exit_kfree: | ||
274 | kfree(pcf8563); | ||
275 | |||
276 | return err; | ||
277 | } | 270 | } |
278 | 271 | ||
279 | static int pcf8563_remove(struct i2c_client *client) | 272 | static int pcf8563_remove(struct i2c_client *client) |
280 | { | 273 | { |
281 | struct pcf8563 *pcf8563 = i2c_get_clientdata(client); | ||
282 | |||
283 | if (pcf8563->rtc) | ||
284 | rtc_device_unregister(pcf8563->rtc); | ||
285 | |||
286 | kfree(pcf8563); | ||
287 | |||
288 | return 0; | 274 | return 0; |
289 | } | 275 | } |
290 | 276 | ||
diff --git a/drivers/rtc/rtc-pcf8583.c b/drivers/rtc/rtc-pcf8583.c index 5f97c61247d5..95886dcf4a39 100644 --- a/drivers/rtc/rtc-pcf8583.c +++ b/drivers/rtc/rtc-pcf8583.c | |||
@@ -268,39 +268,29 @@ static int pcf8583_probe(struct i2c_client *client, | |||
268 | const struct i2c_device_id *id) | 268 | const struct i2c_device_id *id) |
269 | { | 269 | { |
270 | struct pcf8583 *pcf8583; | 270 | struct pcf8583 *pcf8583; |
271 | int err; | ||
272 | 271 | ||
273 | if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) | 272 | if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) |
274 | return -ENODEV; | 273 | return -ENODEV; |
275 | 274 | ||
276 | pcf8583 = kzalloc(sizeof(struct pcf8583), GFP_KERNEL); | 275 | pcf8583 = devm_kzalloc(&client->dev, sizeof(struct pcf8583), |
276 | GFP_KERNEL); | ||
277 | if (!pcf8583) | 277 | if (!pcf8583) |
278 | return -ENOMEM; | 278 | return -ENOMEM; |
279 | 279 | ||
280 | i2c_set_clientdata(client, pcf8583); | 280 | i2c_set_clientdata(client, pcf8583); |
281 | 281 | ||
282 | pcf8583->rtc = rtc_device_register(pcf8583_driver.driver.name, | 282 | pcf8583->rtc = devm_rtc_device_register(&client->dev, |
283 | &client->dev, &pcf8583_rtc_ops, THIS_MODULE); | 283 | pcf8583_driver.driver.name, |
284 | &pcf8583_rtc_ops, THIS_MODULE); | ||
284 | 285 | ||
285 | if (IS_ERR(pcf8583->rtc)) { | 286 | if (IS_ERR(pcf8583->rtc)) |
286 | err = PTR_ERR(pcf8583->rtc); | 287 | return PTR_ERR(pcf8583->rtc); |
287 | goto exit_kfree; | ||
288 | } | ||
289 | 288 | ||
290 | return 0; | 289 | return 0; |
291 | |||
292 | exit_kfree: | ||
293 | kfree(pcf8583); | ||
294 | return err; | ||
295 | } | 290 | } |
296 | 291 | ||
297 | static int pcf8583_remove(struct i2c_client *client) | 292 | static int pcf8583_remove(struct i2c_client *client) |
298 | { | 293 | { |
299 | struct pcf8583 *pcf8583 = i2c_get_clientdata(client); | ||
300 | |||
301 | if (pcf8583->rtc) | ||
302 | rtc_device_unregister(pcf8583->rtc); | ||
303 | kfree(pcf8583); | ||
304 | return 0; | 294 | return 0; |
305 | } | 295 | } |
306 | 296 | ||
diff --git a/drivers/rtc/rtc-ps3.c b/drivers/rtc/rtc-ps3.c index 968133ce1ee8..4bb825bb5804 100644 --- a/drivers/rtc/rtc-ps3.c +++ b/drivers/rtc/rtc-ps3.c | |||
@@ -62,7 +62,7 @@ static int __init ps3_rtc_probe(struct platform_device *dev) | |||
62 | { | 62 | { |
63 | struct rtc_device *rtc; | 63 | struct rtc_device *rtc; |
64 | 64 | ||
65 | rtc = rtc_device_register("rtc-ps3", &dev->dev, &ps3_rtc_ops, | 65 | rtc = devm_rtc_device_register(&dev->dev, "rtc-ps3", &ps3_rtc_ops, |
66 | THIS_MODULE); | 66 | THIS_MODULE); |
67 | if (IS_ERR(rtc)) | 67 | if (IS_ERR(rtc)) |
68 | return PTR_ERR(rtc); | 68 | return PTR_ERR(rtc); |
@@ -73,7 +73,6 @@ static int __init ps3_rtc_probe(struct platform_device *dev) | |||
73 | 73 | ||
74 | static int __exit ps3_rtc_remove(struct platform_device *dev) | 74 | static int __exit ps3_rtc_remove(struct platform_device *dev) |
75 | { | 75 | { |
76 | rtc_device_unregister(platform_get_drvdata(dev)); | ||
77 | return 0; | 76 | return 0; |
78 | } | 77 | } |
79 | 78 | ||
@@ -85,18 +84,7 @@ static struct platform_driver ps3_rtc_driver = { | |||
85 | .remove = __exit_p(ps3_rtc_remove), | 84 | .remove = __exit_p(ps3_rtc_remove), |
86 | }; | 85 | }; |
87 | 86 | ||
88 | static int __init ps3_rtc_init(void) | 87 | module_platform_driver_probe(ps3_rtc_driver, ps3_rtc_probe); |
89 | { | ||
90 | return platform_driver_probe(&ps3_rtc_driver, ps3_rtc_probe); | ||
91 | } | ||
92 | |||
93 | static void __exit ps3_rtc_fini(void) | ||
94 | { | ||
95 | platform_driver_unregister(&ps3_rtc_driver); | ||
96 | } | ||
97 | |||
98 | module_init(ps3_rtc_init); | ||
99 | module_exit(ps3_rtc_fini); | ||
100 | 88 | ||
101 | MODULE_AUTHOR("Sony Corporation"); | 89 | MODULE_AUTHOR("Sony Corporation"); |
102 | MODULE_LICENSE("GPL"); | 90 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/rtc/rtc-puv3.c b/drivers/rtc/rtc-puv3.c index 0407e13d4de4..72f437170d2e 100644 --- a/drivers/rtc/rtc-puv3.c +++ b/drivers/rtc/rtc-puv3.c | |||
@@ -207,14 +207,14 @@ static const struct rtc_class_ops puv3_rtcops = { | |||
207 | .proc = puv3_rtc_proc, | 207 | .proc = puv3_rtc_proc, |
208 | }; | 208 | }; |
209 | 209 | ||
210 | static void puv3_rtc_enable(struct platform_device *pdev, int en) | 210 | static void puv3_rtc_enable(struct device *dev, int en) |
211 | { | 211 | { |
212 | if (!en) { | 212 | if (!en) { |
213 | writel(readl(RTC_RTSR) & ~RTC_RTSR_HZE, RTC_RTSR); | 213 | writel(readl(RTC_RTSR) & ~RTC_RTSR_HZE, RTC_RTSR); |
214 | } else { | 214 | } else { |
215 | /* re-enable the device, and check it is ok */ | 215 | /* re-enable the device, and check it is ok */ |
216 | if ((readl(RTC_RTSR) & RTC_RTSR_HZE) == 0) { | 216 | if ((readl(RTC_RTSR) & RTC_RTSR_HZE) == 0) { |
217 | dev_info(&pdev->dev, "rtc disabled, re-enabling\n"); | 217 | dev_info(dev, "rtc disabled, re-enabling\n"); |
218 | writel(readl(RTC_RTSR) | RTC_RTSR_HZE, RTC_RTSR); | 218 | writel(readl(RTC_RTSR) | RTC_RTSR_HZE, RTC_RTSR); |
219 | } | 219 | } |
220 | } | 220 | } |
@@ -276,7 +276,7 @@ static int puv3_rtc_probe(struct platform_device *pdev) | |||
276 | goto err_nores; | 276 | goto err_nores; |
277 | } | 277 | } |
278 | 278 | ||
279 | puv3_rtc_enable(pdev, 1); | 279 | puv3_rtc_enable(&pdev->dev, 1); |
280 | 280 | ||
281 | /* register RTC and exit */ | 281 | /* register RTC and exit */ |
282 | rtc = rtc_device_register("pkunity", &pdev->dev, &puv3_rtcops, | 282 | rtc = rtc_device_register("pkunity", &pdev->dev, &puv3_rtcops, |
@@ -296,44 +296,41 @@ static int puv3_rtc_probe(struct platform_device *pdev) | |||
296 | return 0; | 296 | return 0; |
297 | 297 | ||
298 | err_nortc: | 298 | err_nortc: |
299 | puv3_rtc_enable(pdev, 0); | 299 | puv3_rtc_enable(&pdev->dev, 0); |
300 | release_resource(puv3_rtc_mem); | 300 | release_resource(puv3_rtc_mem); |
301 | 301 | ||
302 | err_nores: | 302 | err_nores: |
303 | return ret; | 303 | return ret; |
304 | } | 304 | } |
305 | 305 | ||
306 | #ifdef CONFIG_PM | 306 | #ifdef CONFIG_PM_SLEEP |
307 | |||
308 | static int ticnt_save; | 307 | static int ticnt_save; |
309 | 308 | ||
310 | static int puv3_rtc_suspend(struct platform_device *pdev, pm_message_t state) | 309 | static int puv3_rtc_suspend(struct device *dev) |
311 | { | 310 | { |
312 | /* save RTAR for anyone using periodic interrupts */ | 311 | /* save RTAR for anyone using periodic interrupts */ |
313 | ticnt_save = readl(RTC_RTAR); | 312 | ticnt_save = readl(RTC_RTAR); |
314 | puv3_rtc_enable(pdev, 0); | 313 | puv3_rtc_enable(dev, 0); |
315 | return 0; | 314 | return 0; |
316 | } | 315 | } |
317 | 316 | ||
318 | static int puv3_rtc_resume(struct platform_device *pdev) | 317 | static int puv3_rtc_resume(struct device *dev) |
319 | { | 318 | { |
320 | puv3_rtc_enable(pdev, 1); | 319 | puv3_rtc_enable(dev, 1); |
321 | writel(ticnt_save, RTC_RTAR); | 320 | writel(ticnt_save, RTC_RTAR); |
322 | return 0; | 321 | return 0; |
323 | } | 322 | } |
324 | #else | ||
325 | #define puv3_rtc_suspend NULL | ||
326 | #define puv3_rtc_resume NULL | ||
327 | #endif | 323 | #endif |
328 | 324 | ||
325 | static SIMPLE_DEV_PM_OPS(puv3_rtc_pm_ops, puv3_rtc_suspend, puv3_rtc_resume); | ||
326 | |||
329 | static struct platform_driver puv3_rtc_driver = { | 327 | static struct platform_driver puv3_rtc_driver = { |
330 | .probe = puv3_rtc_probe, | 328 | .probe = puv3_rtc_probe, |
331 | .remove = puv3_rtc_remove, | 329 | .remove = puv3_rtc_remove, |
332 | .suspend = puv3_rtc_suspend, | ||
333 | .resume = puv3_rtc_resume, | ||
334 | .driver = { | 330 | .driver = { |
335 | .name = "PKUnity-v3-RTC", | 331 | .name = "PKUnity-v3-RTC", |
336 | .owner = THIS_MODULE, | 332 | .owner = THIS_MODULE, |
333 | .pm = &puv3_rtc_pm_ops, | ||
337 | } | 334 | } |
338 | }; | 335 | }; |
339 | 336 | ||
diff --git a/drivers/rtc/rtc-pxa.c b/drivers/rtc/rtc-pxa.c index 03c85ee719a7..ed037ae91c5f 100644 --- a/drivers/rtc/rtc-pxa.c +++ b/drivers/rtc/rtc-pxa.c | |||
@@ -416,7 +416,7 @@ static struct of_device_id pxa_rtc_dt_ids[] = { | |||
416 | MODULE_DEVICE_TABLE(of, pxa_rtc_dt_ids); | 416 | MODULE_DEVICE_TABLE(of, pxa_rtc_dt_ids); |
417 | #endif | 417 | #endif |
418 | 418 | ||
419 | #ifdef CONFIG_PM | 419 | #ifdef CONFIG_PM_SLEEP |
420 | static int pxa_rtc_suspend(struct device *dev) | 420 | static int pxa_rtc_suspend(struct device *dev) |
421 | { | 421 | { |
422 | struct pxa_rtc *pxa_rtc = dev_get_drvdata(dev); | 422 | struct pxa_rtc *pxa_rtc = dev_get_drvdata(dev); |
@@ -434,36 +434,20 @@ static int pxa_rtc_resume(struct device *dev) | |||
434 | disable_irq_wake(pxa_rtc->irq_Alrm); | 434 | disable_irq_wake(pxa_rtc->irq_Alrm); |
435 | return 0; | 435 | return 0; |
436 | } | 436 | } |
437 | |||
438 | static const struct dev_pm_ops pxa_rtc_pm_ops = { | ||
439 | .suspend = pxa_rtc_suspend, | ||
440 | .resume = pxa_rtc_resume, | ||
441 | }; | ||
442 | #endif | 437 | #endif |
443 | 438 | ||
439 | static SIMPLE_DEV_PM_OPS(pxa_rtc_pm_ops, pxa_rtc_suspend, pxa_rtc_resume); | ||
440 | |||
444 | static struct platform_driver pxa_rtc_driver = { | 441 | static struct platform_driver pxa_rtc_driver = { |
445 | .remove = __exit_p(pxa_rtc_remove), | 442 | .remove = __exit_p(pxa_rtc_remove), |
446 | .driver = { | 443 | .driver = { |
447 | .name = "pxa-rtc", | 444 | .name = "pxa-rtc", |
448 | .of_match_table = of_match_ptr(pxa_rtc_dt_ids), | 445 | .of_match_table = of_match_ptr(pxa_rtc_dt_ids), |
449 | #ifdef CONFIG_PM | ||
450 | .pm = &pxa_rtc_pm_ops, | 446 | .pm = &pxa_rtc_pm_ops, |
451 | #endif | ||
452 | }, | 447 | }, |
453 | }; | 448 | }; |
454 | 449 | ||
455 | static int __init pxa_rtc_init(void) | 450 | module_platform_driver_probe(pxa_rtc_driver, pxa_rtc_probe); |
456 | { | ||
457 | return platform_driver_probe(&pxa_rtc_driver, pxa_rtc_probe); | ||
458 | } | ||
459 | |||
460 | static void __exit pxa_rtc_exit(void) | ||
461 | { | ||
462 | platform_driver_unregister(&pxa_rtc_driver); | ||
463 | } | ||
464 | |||
465 | module_init(pxa_rtc_init); | ||
466 | module_exit(pxa_rtc_exit); | ||
467 | 451 | ||
468 | MODULE_AUTHOR("Robert Jarzmik <robert.jarzmik@free.fr>"); | 452 | MODULE_AUTHOR("Robert Jarzmik <robert.jarzmik@free.fr>"); |
469 | MODULE_DESCRIPTION("PXA27x/PXA3xx Realtime Clock Driver (RTC)"); | 453 | MODULE_DESCRIPTION("PXA27x/PXA3xx Realtime Clock Driver (RTC)"); |
diff --git a/drivers/rtc/rtc-r9701.c b/drivers/rtc/rtc-r9701.c index 7726f4a4f2d0..feeedbd82000 100644 --- a/drivers/rtc/rtc-r9701.c +++ b/drivers/rtc/rtc-r9701.c | |||
@@ -154,21 +154,18 @@ static int r9701_probe(struct spi_device *spi) | |||
154 | } | 154 | } |
155 | } | 155 | } |
156 | 156 | ||
157 | rtc = rtc_device_register("r9701", | 157 | rtc = devm_rtc_device_register(&spi->dev, "r9701", |
158 | &spi->dev, &r9701_rtc_ops, THIS_MODULE); | 158 | &r9701_rtc_ops, THIS_MODULE); |
159 | if (IS_ERR(rtc)) | 159 | if (IS_ERR(rtc)) |
160 | return PTR_ERR(rtc); | 160 | return PTR_ERR(rtc); |
161 | 161 | ||
162 | dev_set_drvdata(&spi->dev, rtc); | 162 | spi_set_drvdata(spi, rtc); |
163 | 163 | ||
164 | return 0; | 164 | return 0; |
165 | } | 165 | } |
166 | 166 | ||
167 | static int r9701_remove(struct spi_device *spi) | 167 | static int r9701_remove(struct spi_device *spi) |
168 | { | 168 | { |
169 | struct rtc_device *rtc = dev_get_drvdata(&spi->dev); | ||
170 | |||
171 | rtc_device_unregister(rtc); | ||
172 | return 0; | 169 | return 0; |
173 | } | 170 | } |
174 | 171 | ||
diff --git a/drivers/rtc/rtc-rc5t583.c b/drivers/rtc/rtc-rc5t583.c index eb3194d664a8..8eabcf51b35a 100644 --- a/drivers/rtc/rtc-rc5t583.c +++ b/drivers/rtc/rtc-rc5t583.c | |||
@@ -256,7 +256,7 @@ static int rc5t583_rtc_probe(struct platform_device *pdev) | |||
256 | } | 256 | } |
257 | device_init_wakeup(&pdev->dev, 1); | 257 | device_init_wakeup(&pdev->dev, 1); |
258 | 258 | ||
259 | ricoh_rtc->rtc = rtc_device_register(pdev->name, &pdev->dev, | 259 | ricoh_rtc->rtc = devm_rtc_device_register(&pdev->dev, pdev->name, |
260 | &rc5t583_rtc_ops, THIS_MODULE); | 260 | &rc5t583_rtc_ops, THIS_MODULE); |
261 | if (IS_ERR(ricoh_rtc->rtc)) { | 261 | if (IS_ERR(ricoh_rtc->rtc)) { |
262 | ret = PTR_ERR(ricoh_rtc->rtc); | 262 | ret = PTR_ERR(ricoh_rtc->rtc); |
@@ -276,13 +276,10 @@ static int rc5t583_rtc_remove(struct platform_device *pdev) | |||
276 | struct rc5t583_rtc *rc5t583_rtc = dev_get_drvdata(&pdev->dev); | 276 | struct rc5t583_rtc *rc5t583_rtc = dev_get_drvdata(&pdev->dev); |
277 | 277 | ||
278 | rc5t583_rtc_alarm_irq_enable(&rc5t583_rtc->rtc->dev, 0); | 278 | rc5t583_rtc_alarm_irq_enable(&rc5t583_rtc->rtc->dev, 0); |
279 | |||
280 | rtc_device_unregister(rc5t583_rtc->rtc); | ||
281 | return 0; | 279 | return 0; |
282 | } | 280 | } |
283 | 281 | ||
284 | #ifdef CONFIG_PM_SLEEP | 282 | #ifdef CONFIG_PM_SLEEP |
285 | |||
286 | static int rc5t583_rtc_suspend(struct device *dev) | 283 | static int rc5t583_rtc_suspend(struct device *dev) |
287 | { | 284 | { |
288 | struct rc5t583 *rc5t583 = dev_get_drvdata(dev->parent); | 285 | struct rc5t583 *rc5t583 = dev_get_drvdata(dev->parent); |
@@ -304,24 +301,18 @@ static int rc5t583_rtc_resume(struct device *dev) | |||
304 | return regmap_write(rc5t583->regmap, RC5T583_RTC_CTL1, | 301 | return regmap_write(rc5t583->regmap, RC5T583_RTC_CTL1, |
305 | rc5t583_rtc->irqen); | 302 | rc5t583_rtc->irqen); |
306 | } | 303 | } |
307 | |||
308 | static const struct dev_pm_ops rc5t583_rtc_pm_ops = { | ||
309 | .suspend = rc5t583_rtc_suspend, | ||
310 | .resume = rc5t583_rtc_resume, | ||
311 | }; | ||
312 | |||
313 | #define DEV_PM_OPS (&rc5t583_rtc_pm_ops) | ||
314 | #else | ||
315 | #define DEV_PM_OPS NULL | ||
316 | #endif | 304 | #endif |
317 | 305 | ||
306 | static SIMPLE_DEV_PM_OPS(rc5t583_rtc_pm_ops, rc5t583_rtc_suspend, | ||
307 | rc5t583_rtc_resume); | ||
308 | |||
318 | static struct platform_driver rc5t583_rtc_driver = { | 309 | static struct platform_driver rc5t583_rtc_driver = { |
319 | .probe = rc5t583_rtc_probe, | 310 | .probe = rc5t583_rtc_probe, |
320 | .remove = rc5t583_rtc_remove, | 311 | .remove = rc5t583_rtc_remove, |
321 | .driver = { | 312 | .driver = { |
322 | .owner = THIS_MODULE, | 313 | .owner = THIS_MODULE, |
323 | .name = "rtc-rc5t583", | 314 | .name = "rtc-rc5t583", |
324 | .pm = DEV_PM_OPS, | 315 | .pm = &rc5t583_rtc_pm_ops, |
325 | }, | 316 | }, |
326 | }; | 317 | }; |
327 | 318 | ||
diff --git a/drivers/rtc/rtc-rp5c01.c b/drivers/rtc/rtc-rp5c01.c index 359da6d020b9..873c689f01c3 100644 --- a/drivers/rtc/rtc-rp5c01.c +++ b/drivers/rtc/rtc-rp5c01.c | |||
@@ -230,15 +230,13 @@ static int __init rp5c01_rtc_probe(struct platform_device *dev) | |||
230 | if (!res) | 230 | if (!res) |
231 | return -ENODEV; | 231 | return -ENODEV; |
232 | 232 | ||
233 | priv = kzalloc(sizeof(*priv), GFP_KERNEL); | 233 | priv = devm_kzalloc(&dev->dev, sizeof(*priv), GFP_KERNEL); |
234 | if (!priv) | 234 | if (!priv) |
235 | return -ENOMEM; | 235 | return -ENOMEM; |
236 | 236 | ||
237 | priv->regs = ioremap(res->start, resource_size(res)); | 237 | priv->regs = devm_ioremap(&dev->dev, res->start, resource_size(res)); |
238 | if (!priv->regs) { | 238 | if (!priv->regs) |
239 | error = -ENOMEM; | 239 | return -ENOMEM; |
240 | goto out_free_priv; | ||
241 | } | ||
242 | 240 | ||
243 | sysfs_bin_attr_init(&priv->nvram_attr); | 241 | sysfs_bin_attr_init(&priv->nvram_attr); |
244 | priv->nvram_attr.attr.name = "nvram"; | 242 | priv->nvram_attr.attr.name = "nvram"; |
@@ -251,27 +249,22 @@ static int __init rp5c01_rtc_probe(struct platform_device *dev) | |||
251 | 249 | ||
252 | platform_set_drvdata(dev, priv); | 250 | platform_set_drvdata(dev, priv); |
253 | 251 | ||
254 | rtc = rtc_device_register("rtc-rp5c01", &dev->dev, &rp5c01_rtc_ops, | 252 | rtc = devm_rtc_device_register(&dev->dev, "rtc-rp5c01", &rp5c01_rtc_ops, |
255 | THIS_MODULE); | 253 | THIS_MODULE); |
256 | if (IS_ERR(rtc)) { | 254 | if (IS_ERR(rtc)) { |
257 | error = PTR_ERR(rtc); | 255 | error = PTR_ERR(rtc); |
258 | goto out_unmap; | 256 | goto out; |
259 | } | 257 | } |
260 | priv->rtc = rtc; | 258 | priv->rtc = rtc; |
261 | 259 | ||
262 | error = sysfs_create_bin_file(&dev->dev.kobj, &priv->nvram_attr); | 260 | error = sysfs_create_bin_file(&dev->dev.kobj, &priv->nvram_attr); |
263 | if (error) | 261 | if (error) |
264 | goto out_unregister; | 262 | goto out; |
265 | 263 | ||
266 | return 0; | 264 | return 0; |
267 | 265 | ||
268 | out_unregister: | 266 | out: |
269 | rtc_device_unregister(rtc); | ||
270 | out_unmap: | ||
271 | platform_set_drvdata(dev, NULL); | 267 | platform_set_drvdata(dev, NULL); |
272 | iounmap(priv->regs); | ||
273 | out_free_priv: | ||
274 | kfree(priv); | ||
275 | return error; | 268 | return error; |
276 | } | 269 | } |
277 | 270 | ||
@@ -280,9 +273,6 @@ static int __exit rp5c01_rtc_remove(struct platform_device *dev) | |||
280 | struct rp5c01_priv *priv = platform_get_drvdata(dev); | 273 | struct rp5c01_priv *priv = platform_get_drvdata(dev); |
281 | 274 | ||
282 | sysfs_remove_bin_file(&dev->dev.kobj, &priv->nvram_attr); | 275 | sysfs_remove_bin_file(&dev->dev.kobj, &priv->nvram_attr); |
283 | rtc_device_unregister(priv->rtc); | ||
284 | iounmap(priv->regs); | ||
285 | kfree(priv); | ||
286 | return 0; | 276 | return 0; |
287 | } | 277 | } |
288 | 278 | ||
@@ -294,18 +284,7 @@ static struct platform_driver rp5c01_rtc_driver = { | |||
294 | .remove = __exit_p(rp5c01_rtc_remove), | 284 | .remove = __exit_p(rp5c01_rtc_remove), |
295 | }; | 285 | }; |
296 | 286 | ||
297 | static int __init rp5c01_rtc_init(void) | 287 | module_platform_driver_probe(rp5c01_rtc_driver, rp5c01_rtc_probe); |
298 | { | ||
299 | return platform_driver_probe(&rp5c01_rtc_driver, rp5c01_rtc_probe); | ||
300 | } | ||
301 | |||
302 | static void __exit rp5c01_rtc_fini(void) | ||
303 | { | ||
304 | platform_driver_unregister(&rp5c01_rtc_driver); | ||
305 | } | ||
306 | |||
307 | module_init(rp5c01_rtc_init); | ||
308 | module_exit(rp5c01_rtc_fini); | ||
309 | 288 | ||
310 | MODULE_AUTHOR("Geert Uytterhoeven <geert@linux-m68k.org>"); | 289 | MODULE_AUTHOR("Geert Uytterhoeven <geert@linux-m68k.org>"); |
311 | MODULE_LICENSE("GPL"); | 290 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/rtc/rtc-rs5c313.c b/drivers/rtc/rtc-rs5c313.c index d98ea5b759c8..8089fc63e403 100644 --- a/drivers/rtc/rtc-rs5c313.c +++ b/drivers/rtc/rtc-rs5c313.c | |||
@@ -367,7 +367,7 @@ static const struct rtc_class_ops rs5c313_rtc_ops = { | |||
367 | 367 | ||
368 | static int rs5c313_rtc_probe(struct platform_device *pdev) | 368 | static int rs5c313_rtc_probe(struct platform_device *pdev) |
369 | { | 369 | { |
370 | struct rtc_device *rtc = rtc_device_register("rs5c313", &pdev->dev, | 370 | struct rtc_device *rtc = devm_rtc_device_register(&pdev->dev, "rs5c313", |
371 | &rs5c313_rtc_ops, THIS_MODULE); | 371 | &rs5c313_rtc_ops, THIS_MODULE); |
372 | 372 | ||
373 | if (IS_ERR(rtc)) | 373 | if (IS_ERR(rtc)) |
@@ -380,10 +380,6 @@ static int rs5c313_rtc_probe(struct platform_device *pdev) | |||
380 | 380 | ||
381 | static int rs5c313_rtc_remove(struct platform_device *pdev) | 381 | static int rs5c313_rtc_remove(struct platform_device *pdev) |
382 | { | 382 | { |
383 | struct rtc_device *rtc = platform_get_drvdata( pdev ); | ||
384 | |||
385 | rtc_device_unregister(rtc); | ||
386 | |||
387 | return 0; | 383 | return 0; |
388 | } | 384 | } |
389 | 385 | ||
diff --git a/drivers/rtc/rtc-rs5c348.c b/drivers/rtc/rtc-rs5c348.c index 72ef10be8662..2c37df3586c7 100644 --- a/drivers/rtc/rtc-rs5c348.c +++ b/drivers/rtc/rtc-rs5c348.c | |||
@@ -158,7 +158,8 @@ static int rs5c348_probe(struct spi_device *spi) | |||
158 | struct rtc_device *rtc; | 158 | struct rtc_device *rtc; |
159 | struct rs5c348_plat_data *pdata; | 159 | struct rs5c348_plat_data *pdata; |
160 | 160 | ||
161 | pdata = kzalloc(sizeof(struct rs5c348_plat_data), GFP_KERNEL); | 161 | pdata = devm_kzalloc(&spi->dev, sizeof(struct rs5c348_plat_data), |
162 | GFP_KERNEL); | ||
162 | if (!pdata) | 163 | if (!pdata) |
163 | return -ENOMEM; | 164 | return -ENOMEM; |
164 | spi->dev.platform_data = pdata; | 165 | spi->dev.platform_data = pdata; |
@@ -202,7 +203,7 @@ static int rs5c348_probe(struct spi_device *spi) | |||
202 | if (ret & RS5C348_BIT_24H) | 203 | if (ret & RS5C348_BIT_24H) |
203 | pdata->rtc_24h = 1; | 204 | pdata->rtc_24h = 1; |
204 | 205 | ||
205 | rtc = rtc_device_register(rs5c348_driver.driver.name, &spi->dev, | 206 | rtc = devm_rtc_device_register(&spi->dev, rs5c348_driver.driver.name, |
206 | &rs5c348_rtc_ops, THIS_MODULE); | 207 | &rs5c348_rtc_ops, THIS_MODULE); |
207 | 208 | ||
208 | if (IS_ERR(rtc)) { | 209 | if (IS_ERR(rtc)) { |
@@ -214,18 +215,11 @@ static int rs5c348_probe(struct spi_device *spi) | |||
214 | 215 | ||
215 | return 0; | 216 | return 0; |
216 | kfree_exit: | 217 | kfree_exit: |
217 | kfree(pdata); | ||
218 | return ret; | 218 | return ret; |
219 | } | 219 | } |
220 | 220 | ||
221 | static int rs5c348_remove(struct spi_device *spi) | 221 | static int rs5c348_remove(struct spi_device *spi) |
222 | { | 222 | { |
223 | struct rs5c348_plat_data *pdata = spi->dev.platform_data; | ||
224 | struct rtc_device *rtc = pdata->rtc; | ||
225 | |||
226 | if (rtc) | ||
227 | rtc_device_unregister(rtc); | ||
228 | kfree(pdata); | ||
229 | return 0; | 223 | return 0; |
230 | } | 224 | } |
231 | 225 | ||
diff --git a/drivers/rtc/rtc-rs5c372.c b/drivers/rtc/rtc-rs5c372.c index 581739f40097..224d634322b4 100644 --- a/drivers/rtc/rtc-rs5c372.c +++ b/drivers/rtc/rtc-rs5c372.c | |||
@@ -579,7 +579,9 @@ static int rs5c372_probe(struct i2c_client *client, | |||
579 | } | 579 | } |
580 | } | 580 | } |
581 | 581 | ||
582 | if (!(rs5c372 = kzalloc(sizeof(struct rs5c372), GFP_KERNEL))) { | 582 | rs5c372 = devm_kzalloc(&client->dev, sizeof(struct rs5c372), |
583 | GFP_KERNEL); | ||
584 | if (!rs5c372) { | ||
583 | err = -ENOMEM; | 585 | err = -ENOMEM; |
584 | goto exit; | 586 | goto exit; |
585 | } | 587 | } |
@@ -594,7 +596,7 @@ static int rs5c372_probe(struct i2c_client *client, | |||
594 | 596 | ||
595 | err = rs5c_get_regs(rs5c372); | 597 | err = rs5c_get_regs(rs5c372); |
596 | if (err < 0) | 598 | if (err < 0) |
597 | goto exit_kfree; | 599 | goto exit; |
598 | 600 | ||
599 | /* clock may be set for am/pm or 24 hr time */ | 601 | /* clock may be set for am/pm or 24 hr time */ |
600 | switch (rs5c372->type) { | 602 | switch (rs5c372->type) { |
@@ -617,7 +619,7 @@ static int rs5c372_probe(struct i2c_client *client, | |||
617 | break; | 619 | break; |
618 | default: | 620 | default: |
619 | dev_err(&client->dev, "unknown RTC type\n"); | 621 | dev_err(&client->dev, "unknown RTC type\n"); |
620 | goto exit_kfree; | 622 | goto exit; |
621 | } | 623 | } |
622 | 624 | ||
623 | /* if the oscillator lost power and no other software (like | 625 | /* if the oscillator lost power and no other software (like |
@@ -629,7 +631,7 @@ static int rs5c372_probe(struct i2c_client *client, | |||
629 | err = rs5c_oscillator_setup(rs5c372); | 631 | err = rs5c_oscillator_setup(rs5c372); |
630 | if (unlikely(err < 0)) { | 632 | if (unlikely(err < 0)) { |
631 | dev_err(&client->dev, "setup error\n"); | 633 | dev_err(&client->dev, "setup error\n"); |
632 | goto exit_kfree; | 634 | goto exit; |
633 | } | 635 | } |
634 | 636 | ||
635 | if (rs5c372_get_datetime(client, &tm) < 0) | 637 | if (rs5c372_get_datetime(client, &tm) < 0) |
@@ -648,38 +650,28 @@ static int rs5c372_probe(struct i2c_client *client, | |||
648 | ); | 650 | ); |
649 | 651 | ||
650 | /* REVISIT use client->irq to register alarm irq ... */ | 652 | /* REVISIT use client->irq to register alarm irq ... */ |
651 | 653 | rs5c372->rtc = devm_rtc_device_register(&client->dev, | |
652 | rs5c372->rtc = rtc_device_register(rs5c372_driver.driver.name, | 654 | rs5c372_driver.driver.name, |
653 | &client->dev, &rs5c372_rtc_ops, THIS_MODULE); | 655 | &rs5c372_rtc_ops, THIS_MODULE); |
654 | 656 | ||
655 | if (IS_ERR(rs5c372->rtc)) { | 657 | if (IS_ERR(rs5c372->rtc)) { |
656 | err = PTR_ERR(rs5c372->rtc); | 658 | err = PTR_ERR(rs5c372->rtc); |
657 | goto exit_kfree; | 659 | goto exit; |
658 | } | 660 | } |
659 | 661 | ||
660 | err = rs5c_sysfs_register(&client->dev); | 662 | err = rs5c_sysfs_register(&client->dev); |
661 | if (err) | 663 | if (err) |
662 | goto exit_devreg; | 664 | goto exit; |
663 | 665 | ||
664 | return 0; | 666 | return 0; |
665 | 667 | ||
666 | exit_devreg: | ||
667 | rtc_device_unregister(rs5c372->rtc); | ||
668 | |||
669 | exit_kfree: | ||
670 | kfree(rs5c372); | ||
671 | |||
672 | exit: | 668 | exit: |
673 | return err; | 669 | return err; |
674 | } | 670 | } |
675 | 671 | ||
676 | static int rs5c372_remove(struct i2c_client *client) | 672 | static int rs5c372_remove(struct i2c_client *client) |
677 | { | 673 | { |
678 | struct rs5c372 *rs5c372 = i2c_get_clientdata(client); | ||
679 | |||
680 | rtc_device_unregister(rs5c372->rtc); | ||
681 | rs5c_sysfs_unregister(&client->dev); | 674 | rs5c_sysfs_unregister(&client->dev); |
682 | kfree(rs5c372); | ||
683 | return 0; | 675 | return 0; |
684 | } | 676 | } |
685 | 677 | ||
diff --git a/drivers/rtc/rtc-rv3029c2.c b/drivers/rtc/rtc-rv3029c2.c index f8ee8ad7825e..5032c24ec159 100644 --- a/drivers/rtc/rtc-rv3029c2.c +++ b/drivers/rtc/rtc-rv3029c2.c | |||
@@ -395,9 +395,8 @@ static int rv3029c2_probe(struct i2c_client *client, | |||
395 | if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_EMUL)) | 395 | if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_EMUL)) |
396 | return -ENODEV; | 396 | return -ENODEV; |
397 | 397 | ||
398 | rtc = rtc_device_register(client->name, | 398 | rtc = devm_rtc_device_register(&client->dev, client->name, |
399 | &client->dev, &rv3029c2_rtc_ops, | 399 | &rv3029c2_rtc_ops, THIS_MODULE); |
400 | THIS_MODULE); | ||
401 | 400 | ||
402 | if (IS_ERR(rtc)) | 401 | if (IS_ERR(rtc)) |
403 | return PTR_ERR(rtc); | 402 | return PTR_ERR(rtc); |
@@ -407,23 +406,14 @@ static int rv3029c2_probe(struct i2c_client *client, | |||
407 | rc = rv3029c2_i2c_get_sr(client, buf); | 406 | rc = rv3029c2_i2c_get_sr(client, buf); |
408 | if (rc < 0) { | 407 | if (rc < 0) { |
409 | dev_err(&client->dev, "reading status failed\n"); | 408 | dev_err(&client->dev, "reading status failed\n"); |
410 | goto exit_unregister; | 409 | return rc; |
411 | } | 410 | } |
412 | 411 | ||
413 | return 0; | 412 | return 0; |
414 | |||
415 | exit_unregister: | ||
416 | rtc_device_unregister(rtc); | ||
417 | |||
418 | return rc; | ||
419 | } | 413 | } |
420 | 414 | ||
421 | static int rv3029c2_remove(struct i2c_client *client) | 415 | static int rv3029c2_remove(struct i2c_client *client) |
422 | { | 416 | { |
423 | struct rtc_device *rtc = i2c_get_clientdata(client); | ||
424 | |||
425 | rtc_device_unregister(rtc); | ||
426 | |||
427 | return 0; | 417 | return 0; |
428 | } | 418 | } |
429 | 419 | ||
diff --git a/drivers/rtc/rtc-rx4581.c b/drivers/rtc/rtc-rx4581.c index 599ec73ec886..84eb08d65d30 100644 --- a/drivers/rtc/rtc-rx4581.c +++ b/drivers/rtc/rtc-rx4581.c | |||
@@ -273,20 +273,17 @@ static int rx4581_probe(struct spi_device *spi) | |||
273 | if (res != 0) | 273 | if (res != 0) |
274 | return res; | 274 | return res; |
275 | 275 | ||
276 | rtc = rtc_device_register("rx4581", | 276 | rtc = devm_rtc_device_register(&spi->dev, "rx4581", |
277 | &spi->dev, &rx4581_rtc_ops, THIS_MODULE); | 277 | &rx4581_rtc_ops, THIS_MODULE); |
278 | if (IS_ERR(rtc)) | 278 | if (IS_ERR(rtc)) |
279 | return PTR_ERR(rtc); | 279 | return PTR_ERR(rtc); |
280 | 280 | ||
281 | dev_set_drvdata(&spi->dev, rtc); | 281 | spi_set_drvdata(spi, rtc); |
282 | return 0; | 282 | return 0; |
283 | } | 283 | } |
284 | 284 | ||
285 | static int rx4581_remove(struct spi_device *spi) | 285 | static int rx4581_remove(struct spi_device *spi) |
286 | { | 286 | { |
287 | struct rtc_device *rtc = dev_get_drvdata(&spi->dev); | ||
288 | |||
289 | rtc_device_unregister(rtc); | ||
290 | return 0; | 287 | return 0; |
291 | } | 288 | } |
292 | 289 | ||
diff --git a/drivers/rtc/rtc-rx8581.c b/drivers/rtc/rtc-rx8581.c index b0c272658fa2..07f3037b18f4 100644 --- a/drivers/rtc/rtc-rx8581.c +++ b/drivers/rtc/rtc-rx8581.c | |||
@@ -240,8 +240,8 @@ static int rx8581_probe(struct i2c_client *client, | |||
240 | 240 | ||
241 | dev_info(&client->dev, "chip found, driver version " DRV_VERSION "\n"); | 241 | dev_info(&client->dev, "chip found, driver version " DRV_VERSION "\n"); |
242 | 242 | ||
243 | rtc = rtc_device_register(rx8581_driver.driver.name, | 243 | rtc = devm_rtc_device_register(&client->dev, rx8581_driver.driver.name, |
244 | &client->dev, &rx8581_rtc_ops, THIS_MODULE); | 244 | &rx8581_rtc_ops, THIS_MODULE); |
245 | 245 | ||
246 | if (IS_ERR(rtc)) | 246 | if (IS_ERR(rtc)) |
247 | return PTR_ERR(rtc); | 247 | return PTR_ERR(rtc); |
@@ -253,10 +253,6 @@ static int rx8581_probe(struct i2c_client *client, | |||
253 | 253 | ||
254 | static int rx8581_remove(struct i2c_client *client) | 254 | static int rx8581_remove(struct i2c_client *client) |
255 | { | 255 | { |
256 | struct rtc_device *rtc = i2c_get_clientdata(client); | ||
257 | |||
258 | rtc_device_unregister(rtc); | ||
259 | |||
260 | return 0; | 256 | return 0; |
261 | } | 257 | } |
262 | 258 | ||
diff --git a/drivers/rtc/rtc-s35390a.c b/drivers/rtc/rtc-s35390a.c index 8a092325188d..f40afdd0e5f5 100644 --- a/drivers/rtc/rtc-s35390a.c +++ b/drivers/rtc/rtc-s35390a.c | |||
@@ -338,7 +338,8 @@ static int s35390a_probe(struct i2c_client *client, | |||
338 | goto exit; | 338 | goto exit; |
339 | } | 339 | } |
340 | 340 | ||
341 | s35390a = kzalloc(sizeof(struct s35390a), GFP_KERNEL); | 341 | s35390a = devm_kzalloc(&client->dev, sizeof(struct s35390a), |
342 | GFP_KERNEL); | ||
342 | if (!s35390a) { | 343 | if (!s35390a) { |
343 | err = -ENOMEM; | 344 | err = -ENOMEM; |
344 | goto exit; | 345 | goto exit; |
@@ -386,8 +387,9 @@ static int s35390a_probe(struct i2c_client *client, | |||
386 | 387 | ||
387 | device_set_wakeup_capable(&client->dev, 1); | 388 | device_set_wakeup_capable(&client->dev, 1); |
388 | 389 | ||
389 | s35390a->rtc = rtc_device_register(s35390a_driver.driver.name, | 390 | s35390a->rtc = devm_rtc_device_register(&client->dev, |
390 | &client->dev, &s35390a_rtc_ops, THIS_MODULE); | 391 | s35390a_driver.driver.name, |
392 | &s35390a_rtc_ops, THIS_MODULE); | ||
391 | 393 | ||
392 | if (IS_ERR(s35390a->rtc)) { | 394 | if (IS_ERR(s35390a->rtc)) { |
393 | err = PTR_ERR(s35390a->rtc); | 395 | err = PTR_ERR(s35390a->rtc); |
@@ -399,7 +401,6 @@ exit_dummy: | |||
399 | for (i = 1; i < 8; ++i) | 401 | for (i = 1; i < 8; ++i) |
400 | if (s35390a->client[i]) | 402 | if (s35390a->client[i]) |
401 | i2c_unregister_device(s35390a->client[i]); | 403 | i2c_unregister_device(s35390a->client[i]); |
402 | kfree(s35390a); | ||
403 | 404 | ||
404 | exit: | 405 | exit: |
405 | return err; | 406 | return err; |
@@ -408,15 +409,12 @@ exit: | |||
408 | static int s35390a_remove(struct i2c_client *client) | 409 | static int s35390a_remove(struct i2c_client *client) |
409 | { | 410 | { |
410 | unsigned int i; | 411 | unsigned int i; |
411 | |||
412 | struct s35390a *s35390a = i2c_get_clientdata(client); | 412 | struct s35390a *s35390a = i2c_get_clientdata(client); |
413 | |||
413 | for (i = 1; i < 8; ++i) | 414 | for (i = 1; i < 8; ++i) |
414 | if (s35390a->client[i]) | 415 | if (s35390a->client[i]) |
415 | i2c_unregister_device(s35390a->client[i]); | 416 | i2c_unregister_device(s35390a->client[i]); |
416 | 417 | ||
417 | rtc_device_unregister(s35390a->rtc); | ||
418 | kfree(s35390a); | ||
419 | |||
420 | return 0; | 418 | return 0; |
421 | } | 419 | } |
422 | 420 | ||
diff --git a/drivers/rtc/rtc-s3c.c b/drivers/rtc/rtc-s3c.c index fb994e9ddc15..8e96c00936be 100644 --- a/drivers/rtc/rtc-s3c.c +++ b/drivers/rtc/rtc-s3c.c | |||
@@ -51,7 +51,6 @@ static struct clk *rtc_clk; | |||
51 | static void __iomem *s3c_rtc_base; | 51 | static void __iomem *s3c_rtc_base; |
52 | static int s3c_rtc_alarmno = NO_IRQ; | 52 | static int s3c_rtc_alarmno = NO_IRQ; |
53 | static int s3c_rtc_tickno = NO_IRQ; | 53 | static int s3c_rtc_tickno = NO_IRQ; |
54 | static bool wake_en; | ||
55 | static enum s3c_cpu_type s3c_rtc_cpu_type; | 54 | static enum s3c_cpu_type s3c_rtc_cpu_type; |
56 | 55 | ||
57 | static DEFINE_SPINLOCK(s3c_rtc_pie_lock); | 56 | static DEFINE_SPINLOCK(s3c_rtc_pie_lock); |
@@ -423,13 +422,11 @@ static void s3c_rtc_enable(struct platform_device *pdev, int en) | |||
423 | 422 | ||
424 | static int s3c_rtc_remove(struct platform_device *dev) | 423 | static int s3c_rtc_remove(struct platform_device *dev) |
425 | { | 424 | { |
426 | struct rtc_device *rtc = platform_get_drvdata(dev); | ||
427 | |||
428 | platform_set_drvdata(dev, NULL); | 425 | platform_set_drvdata(dev, NULL); |
429 | rtc_device_unregister(rtc); | ||
430 | 426 | ||
431 | s3c_rtc_setaie(&dev->dev, 0); | 427 | s3c_rtc_setaie(&dev->dev, 0); |
432 | 428 | ||
429 | clk_unprepare(rtc_clk); | ||
433 | rtc_clk = NULL; | 430 | rtc_clk = NULL; |
434 | 431 | ||
435 | return 0; | 432 | return 0; |
@@ -498,7 +495,7 @@ static int s3c_rtc_probe(struct platform_device *pdev) | |||
498 | return ret; | 495 | return ret; |
499 | } | 496 | } |
500 | 497 | ||
501 | clk_enable(rtc_clk); | 498 | clk_prepare_enable(rtc_clk); |
502 | 499 | ||
503 | /* check to see if everything is setup correctly */ | 500 | /* check to see if everything is setup correctly */ |
504 | 501 | ||
@@ -511,7 +508,7 @@ static int s3c_rtc_probe(struct platform_device *pdev) | |||
511 | 508 | ||
512 | /* register RTC and exit */ | 509 | /* register RTC and exit */ |
513 | 510 | ||
514 | rtc = rtc_device_register("s3c", &pdev->dev, &s3c_rtcops, | 511 | rtc = devm_rtc_device_register(&pdev->dev, "s3c", &s3c_rtcops, |
515 | THIS_MODULE); | 512 | THIS_MODULE); |
516 | 513 | ||
517 | if (IS_ERR(rtc)) { | 514 | if (IS_ERR(rtc)) { |
@@ -574,23 +571,24 @@ static int s3c_rtc_probe(struct platform_device *pdev) | |||
574 | 571 | ||
575 | err_alarm_irq: | 572 | err_alarm_irq: |
576 | platform_set_drvdata(pdev, NULL); | 573 | platform_set_drvdata(pdev, NULL); |
577 | rtc_device_unregister(rtc); | ||
578 | 574 | ||
579 | err_nortc: | 575 | err_nortc: |
580 | s3c_rtc_enable(pdev, 0); | 576 | s3c_rtc_enable(pdev, 0); |
581 | clk_disable(rtc_clk); | 577 | clk_disable_unprepare(rtc_clk); |
582 | 578 | ||
583 | return ret; | 579 | return ret; |
584 | } | 580 | } |
585 | 581 | ||
586 | #ifdef CONFIG_PM | 582 | #ifdef CONFIG_PM_SLEEP |
587 | |||
588 | /* RTC Power management control */ | 583 | /* RTC Power management control */ |
589 | 584 | ||
590 | static int ticnt_save, ticnt_en_save; | 585 | static int ticnt_save, ticnt_en_save; |
586 | static bool wake_en; | ||
591 | 587 | ||
592 | static int s3c_rtc_suspend(struct platform_device *pdev, pm_message_t state) | 588 | static int s3c_rtc_suspend(struct device *dev) |
593 | { | 589 | { |
590 | struct platform_device *pdev = to_platform_device(dev); | ||
591 | |||
594 | clk_enable(rtc_clk); | 592 | clk_enable(rtc_clk); |
595 | /* save TICNT for anyone using periodic interrupts */ | 593 | /* save TICNT for anyone using periodic interrupts */ |
596 | ticnt_save = readb(s3c_rtc_base + S3C2410_TICNT); | 594 | ticnt_save = readb(s3c_rtc_base + S3C2410_TICNT); |
@@ -600,19 +598,20 @@ static int s3c_rtc_suspend(struct platform_device *pdev, pm_message_t state) | |||
600 | } | 598 | } |
601 | s3c_rtc_enable(pdev, 0); | 599 | s3c_rtc_enable(pdev, 0); |
602 | 600 | ||
603 | if (device_may_wakeup(&pdev->dev) && !wake_en) { | 601 | if (device_may_wakeup(dev) && !wake_en) { |
604 | if (enable_irq_wake(s3c_rtc_alarmno) == 0) | 602 | if (enable_irq_wake(s3c_rtc_alarmno) == 0) |
605 | wake_en = true; | 603 | wake_en = true; |
606 | else | 604 | else |
607 | dev_err(&pdev->dev, "enable_irq_wake failed\n"); | 605 | dev_err(dev, "enable_irq_wake failed\n"); |
608 | } | 606 | } |
609 | clk_disable(rtc_clk); | 607 | clk_disable(rtc_clk); |
610 | 608 | ||
611 | return 0; | 609 | return 0; |
612 | } | 610 | } |
613 | 611 | ||
614 | static int s3c_rtc_resume(struct platform_device *pdev) | 612 | static int s3c_rtc_resume(struct device *dev) |
615 | { | 613 | { |
614 | struct platform_device *pdev = to_platform_device(dev); | ||
616 | unsigned int tmp; | 615 | unsigned int tmp; |
617 | 616 | ||
618 | clk_enable(rtc_clk); | 617 | clk_enable(rtc_clk); |
@@ -623,7 +622,7 @@ static int s3c_rtc_resume(struct platform_device *pdev) | |||
623 | writew(tmp | ticnt_en_save, s3c_rtc_base + S3C2410_RTCCON); | 622 | writew(tmp | ticnt_en_save, s3c_rtc_base + S3C2410_RTCCON); |
624 | } | 623 | } |
625 | 624 | ||
626 | if (device_may_wakeup(&pdev->dev) && wake_en) { | 625 | if (device_may_wakeup(dev) && wake_en) { |
627 | disable_irq_wake(s3c_rtc_alarmno); | 626 | disable_irq_wake(s3c_rtc_alarmno); |
628 | wake_en = false; | 627 | wake_en = false; |
629 | } | 628 | } |
@@ -631,11 +630,10 @@ static int s3c_rtc_resume(struct platform_device *pdev) | |||
631 | 630 | ||
632 | return 0; | 631 | return 0; |
633 | } | 632 | } |
634 | #else | ||
635 | #define s3c_rtc_suspend NULL | ||
636 | #define s3c_rtc_resume NULL | ||
637 | #endif | 633 | #endif |
638 | 634 | ||
635 | static SIMPLE_DEV_PM_OPS(s3c_rtc_pm_ops, s3c_rtc_suspend, s3c_rtc_resume); | ||
636 | |||
639 | #ifdef CONFIG_OF | 637 | #ifdef CONFIG_OF |
640 | static struct s3c_rtc_drv_data s3c_rtc_drv_data_array[] = { | 638 | static struct s3c_rtc_drv_data s3c_rtc_drv_data_array[] = { |
641 | [TYPE_S3C2410] = { TYPE_S3C2410 }, | 639 | [TYPE_S3C2410] = { TYPE_S3C2410 }, |
@@ -685,12 +683,11 @@ MODULE_DEVICE_TABLE(platform, s3c_rtc_driver_ids); | |||
685 | static struct platform_driver s3c_rtc_driver = { | 683 | static struct platform_driver s3c_rtc_driver = { |
686 | .probe = s3c_rtc_probe, | 684 | .probe = s3c_rtc_probe, |
687 | .remove = s3c_rtc_remove, | 685 | .remove = s3c_rtc_remove, |
688 | .suspend = s3c_rtc_suspend, | ||
689 | .resume = s3c_rtc_resume, | ||
690 | .id_table = s3c_rtc_driver_ids, | 686 | .id_table = s3c_rtc_driver_ids, |
691 | .driver = { | 687 | .driver = { |
692 | .name = "s3c-rtc", | 688 | .name = "s3c-rtc", |
693 | .owner = THIS_MODULE, | 689 | .owner = THIS_MODULE, |
690 | .pm = &s3c_rtc_pm_ops, | ||
694 | .of_match_table = of_match_ptr(s3c_rtc_dt_match), | 691 | .of_match_table = of_match_ptr(s3c_rtc_dt_match), |
695 | }, | 692 | }, |
696 | }; | 693 | }; |
diff --git a/drivers/rtc/rtc-sa1100.c b/drivers/rtc/rtc-sa1100.c index 5ec5036df0bc..00605601dbf7 100644 --- a/drivers/rtc/rtc-sa1100.c +++ b/drivers/rtc/rtc-sa1100.c | |||
@@ -234,14 +234,13 @@ static int sa1100_rtc_probe(struct platform_device *pdev) | |||
234 | if (irq_1hz < 0 || irq_alarm < 0) | 234 | if (irq_1hz < 0 || irq_alarm < 0) |
235 | return -ENODEV; | 235 | return -ENODEV; |
236 | 236 | ||
237 | info = kzalloc(sizeof(struct sa1100_rtc), GFP_KERNEL); | 237 | info = devm_kzalloc(&pdev->dev, sizeof(struct sa1100_rtc), GFP_KERNEL); |
238 | if (!info) | 238 | if (!info) |
239 | return -ENOMEM; | 239 | return -ENOMEM; |
240 | info->clk = clk_get(&pdev->dev, NULL); | 240 | info->clk = devm_clk_get(&pdev->dev, NULL); |
241 | if (IS_ERR(info->clk)) { | 241 | if (IS_ERR(info->clk)) { |
242 | dev_err(&pdev->dev, "failed to find rtc clock source\n"); | 242 | dev_err(&pdev->dev, "failed to find rtc clock source\n"); |
243 | ret = PTR_ERR(info->clk); | 243 | return PTR_ERR(info->clk); |
244 | goto err_clk; | ||
245 | } | 244 | } |
246 | info->irq_1hz = irq_1hz; | 245 | info->irq_1hz = irq_1hz; |
247 | info->irq_alarm = irq_alarm; | 246 | info->irq_alarm = irq_alarm; |
@@ -268,8 +267,8 @@ static int sa1100_rtc_probe(struct platform_device *pdev) | |||
268 | 267 | ||
269 | device_init_wakeup(&pdev->dev, 1); | 268 | device_init_wakeup(&pdev->dev, 1); |
270 | 269 | ||
271 | rtc = rtc_device_register(pdev->name, &pdev->dev, &sa1100_rtc_ops, | 270 | rtc = devm_rtc_device_register(&pdev->dev, pdev->name, &sa1100_rtc_ops, |
272 | THIS_MODULE); | 271 | THIS_MODULE); |
273 | 272 | ||
274 | if (IS_ERR(rtc)) { | 273 | if (IS_ERR(rtc)) { |
275 | ret = PTR_ERR(rtc); | 274 | ret = PTR_ERR(rtc); |
@@ -306,9 +305,6 @@ err_dev: | |||
306 | clk_disable_unprepare(info->clk); | 305 | clk_disable_unprepare(info->clk); |
307 | err_enable_clk: | 306 | err_enable_clk: |
308 | platform_set_drvdata(pdev, NULL); | 307 | platform_set_drvdata(pdev, NULL); |
309 | clk_put(info->clk); | ||
310 | err_clk: | ||
311 | kfree(info); | ||
312 | return ret; | 308 | return ret; |
313 | } | 309 | } |
314 | 310 | ||
@@ -317,17 +313,14 @@ static int sa1100_rtc_remove(struct platform_device *pdev) | |||
317 | struct sa1100_rtc *info = platform_get_drvdata(pdev); | 313 | struct sa1100_rtc *info = platform_get_drvdata(pdev); |
318 | 314 | ||
319 | if (info) { | 315 | if (info) { |
320 | rtc_device_unregister(info->rtc); | ||
321 | clk_disable_unprepare(info->clk); | 316 | clk_disable_unprepare(info->clk); |
322 | clk_put(info->clk); | ||
323 | platform_set_drvdata(pdev, NULL); | 317 | platform_set_drvdata(pdev, NULL); |
324 | kfree(info); | ||
325 | } | 318 | } |
326 | 319 | ||
327 | return 0; | 320 | return 0; |
328 | } | 321 | } |
329 | 322 | ||
330 | #ifdef CONFIG_PM | 323 | #ifdef CONFIG_PM_SLEEP |
331 | static int sa1100_rtc_suspend(struct device *dev) | 324 | static int sa1100_rtc_suspend(struct device *dev) |
332 | { | 325 | { |
333 | struct sa1100_rtc *info = dev_get_drvdata(dev); | 326 | struct sa1100_rtc *info = dev_get_drvdata(dev); |
@@ -343,13 +336,11 @@ static int sa1100_rtc_resume(struct device *dev) | |||
343 | disable_irq_wake(info->irq_alarm); | 336 | disable_irq_wake(info->irq_alarm); |
344 | return 0; | 337 | return 0; |
345 | } | 338 | } |
346 | |||
347 | static const struct dev_pm_ops sa1100_rtc_pm_ops = { | ||
348 | .suspend = sa1100_rtc_suspend, | ||
349 | .resume = sa1100_rtc_resume, | ||
350 | }; | ||
351 | #endif | 339 | #endif |
352 | 340 | ||
341 | static SIMPLE_DEV_PM_OPS(sa1100_rtc_pm_ops, sa1100_rtc_suspend, | ||
342 | sa1100_rtc_resume); | ||
343 | |||
353 | #ifdef CONFIG_OF | 344 | #ifdef CONFIG_OF |
354 | static struct of_device_id sa1100_rtc_dt_ids[] = { | 345 | static struct of_device_id sa1100_rtc_dt_ids[] = { |
355 | { .compatible = "mrvl,sa1100-rtc", }, | 346 | { .compatible = "mrvl,sa1100-rtc", }, |
@@ -364,9 +355,7 @@ static struct platform_driver sa1100_rtc_driver = { | |||
364 | .remove = sa1100_rtc_remove, | 355 | .remove = sa1100_rtc_remove, |
365 | .driver = { | 356 | .driver = { |
366 | .name = "sa1100-rtc", | 357 | .name = "sa1100-rtc", |
367 | #ifdef CONFIG_PM | ||
368 | .pm = &sa1100_rtc_pm_ops, | 358 | .pm = &sa1100_rtc_pm_ops, |
369 | #endif | ||
370 | .of_match_table = of_match_ptr(sa1100_rtc_dt_ids), | 359 | .of_match_table = of_match_ptr(sa1100_rtc_dt_ids), |
371 | }, | 360 | }, |
372 | }; | 361 | }; |
diff --git a/drivers/rtc/rtc-sh.c b/drivers/rtc/rtc-sh.c index e55a7635ae5f..8d5bd2e36776 100644 --- a/drivers/rtc/rtc-sh.c +++ b/drivers/rtc/rtc-sh.c | |||
@@ -790,6 +790,7 @@ static void sh_rtc_set_irq_wake(struct device *dev, int enabled) | |||
790 | } | 790 | } |
791 | } | 791 | } |
792 | 792 | ||
793 | #ifdef CONFIG_PM_SLEEP | ||
793 | static int sh_rtc_suspend(struct device *dev) | 794 | static int sh_rtc_suspend(struct device *dev) |
794 | { | 795 | { |
795 | if (device_may_wakeup(dev)) | 796 | if (device_may_wakeup(dev)) |
@@ -805,33 +806,20 @@ static int sh_rtc_resume(struct device *dev) | |||
805 | 806 | ||
806 | return 0; | 807 | return 0; |
807 | } | 808 | } |
809 | #endif | ||
808 | 810 | ||
809 | static const struct dev_pm_ops sh_rtc_dev_pm_ops = { | 811 | static SIMPLE_DEV_PM_OPS(sh_rtc_pm_ops, sh_rtc_suspend, sh_rtc_resume); |
810 | .suspend = sh_rtc_suspend, | ||
811 | .resume = sh_rtc_resume, | ||
812 | }; | ||
813 | 812 | ||
814 | static struct platform_driver sh_rtc_platform_driver = { | 813 | static struct platform_driver sh_rtc_platform_driver = { |
815 | .driver = { | 814 | .driver = { |
816 | .name = DRV_NAME, | 815 | .name = DRV_NAME, |
817 | .owner = THIS_MODULE, | 816 | .owner = THIS_MODULE, |
818 | .pm = &sh_rtc_dev_pm_ops, | 817 | .pm = &sh_rtc_pm_ops, |
819 | }, | 818 | }, |
820 | .remove = __exit_p(sh_rtc_remove), | 819 | .remove = __exit_p(sh_rtc_remove), |
821 | }; | 820 | }; |
822 | 821 | ||
823 | static int __init sh_rtc_init(void) | 822 | module_platform_driver_probe(sh_rtc_platform_driver, sh_rtc_probe); |
824 | { | ||
825 | return platform_driver_probe(&sh_rtc_platform_driver, sh_rtc_probe); | ||
826 | } | ||
827 | |||
828 | static void __exit sh_rtc_exit(void) | ||
829 | { | ||
830 | platform_driver_unregister(&sh_rtc_platform_driver); | ||
831 | } | ||
832 | |||
833 | module_init(sh_rtc_init); | ||
834 | module_exit(sh_rtc_exit); | ||
835 | 823 | ||
836 | MODULE_DESCRIPTION("SuperH on-chip RTC driver"); | 824 | MODULE_DESCRIPTION("SuperH on-chip RTC driver"); |
837 | MODULE_VERSION(DRV_VERSION); | 825 | MODULE_VERSION(DRV_VERSION); |
diff --git a/drivers/rtc/rtc-snvs.c b/drivers/rtc/rtc-snvs.c index f7d90703db5e..b04f09a1df2a 100644 --- a/drivers/rtc/rtc-snvs.c +++ b/drivers/rtc/rtc-snvs.c | |||
@@ -283,7 +283,7 @@ static int snvs_rtc_probe(struct platform_device *pdev) | |||
283 | return ret; | 283 | return ret; |
284 | } | 284 | } |
285 | 285 | ||
286 | data->rtc = rtc_device_register(pdev->name, &pdev->dev, | 286 | data->rtc = devm_rtc_device_register(&pdev->dev, pdev->name, |
287 | &snvs_rtc_ops, THIS_MODULE); | 287 | &snvs_rtc_ops, THIS_MODULE); |
288 | if (IS_ERR(data->rtc)) { | 288 | if (IS_ERR(data->rtc)) { |
289 | ret = PTR_ERR(data->rtc); | 289 | ret = PTR_ERR(data->rtc); |
@@ -296,10 +296,6 @@ static int snvs_rtc_probe(struct platform_device *pdev) | |||
296 | 296 | ||
297 | static int snvs_rtc_remove(struct platform_device *pdev) | 297 | static int snvs_rtc_remove(struct platform_device *pdev) |
298 | { | 298 | { |
299 | struct snvs_rtc_data *data = platform_get_drvdata(pdev); | ||
300 | |||
301 | rtc_device_unregister(data->rtc); | ||
302 | |||
303 | return 0; | 299 | return 0; |
304 | } | 300 | } |
305 | 301 | ||
diff --git a/drivers/rtc/rtc-spear.c b/drivers/rtc/rtc-spear.c index a18c3192ed40..574359c48f65 100644 --- a/drivers/rtc/rtc-spear.c +++ b/drivers/rtc/rtc-spear.c | |||
@@ -400,8 +400,8 @@ static int spear_rtc_probe(struct platform_device *pdev) | |||
400 | spin_lock_init(&config->lock); | 400 | spin_lock_init(&config->lock); |
401 | platform_set_drvdata(pdev, config); | 401 | platform_set_drvdata(pdev, config); |
402 | 402 | ||
403 | config->rtc = rtc_device_register(pdev->name, &pdev->dev, | 403 | config->rtc = devm_rtc_device_register(&pdev->dev, pdev->name, |
404 | &spear_rtc_ops, THIS_MODULE); | 404 | &spear_rtc_ops, THIS_MODULE); |
405 | if (IS_ERR(config->rtc)) { | 405 | if (IS_ERR(config->rtc)) { |
406 | dev_err(&pdev->dev, "can't register RTC device, err %ld\n", | 406 | dev_err(&pdev->dev, "can't register RTC device, err %ld\n", |
407 | PTR_ERR(config->rtc)); | 407 | PTR_ERR(config->rtc)); |
@@ -427,7 +427,6 @@ static int spear_rtc_remove(struct platform_device *pdev) | |||
427 | { | 427 | { |
428 | struct spear_rtc_config *config = platform_get_drvdata(pdev); | 428 | struct spear_rtc_config *config = platform_get_drvdata(pdev); |
429 | 429 | ||
430 | rtc_device_unregister(config->rtc); | ||
431 | spear_rtc_disable_interrupt(config); | 430 | spear_rtc_disable_interrupt(config); |
432 | clk_disable_unprepare(config->clk); | 431 | clk_disable_unprepare(config->clk); |
433 | device_init_wakeup(&pdev->dev, 0); | 432 | device_init_wakeup(&pdev->dev, 0); |
@@ -435,10 +434,10 @@ static int spear_rtc_remove(struct platform_device *pdev) | |||
435 | return 0; | 434 | return 0; |
436 | } | 435 | } |
437 | 436 | ||
438 | #ifdef CONFIG_PM | 437 | #ifdef CONFIG_PM_SLEEP |
439 | 438 | static int spear_rtc_suspend(struct device *dev) | |
440 | static int spear_rtc_suspend(struct platform_device *pdev, pm_message_t state) | ||
441 | { | 439 | { |
440 | struct platform_device *pdev = to_platform_device(dev); | ||
442 | struct spear_rtc_config *config = platform_get_drvdata(pdev); | 441 | struct spear_rtc_config *config = platform_get_drvdata(pdev); |
443 | int irq; | 442 | int irq; |
444 | 443 | ||
@@ -454,8 +453,9 @@ static int spear_rtc_suspend(struct platform_device *pdev, pm_message_t state) | |||
454 | return 0; | 453 | return 0; |
455 | } | 454 | } |
456 | 455 | ||
457 | static int spear_rtc_resume(struct platform_device *pdev) | 456 | static int spear_rtc_resume(struct device *dev) |
458 | { | 457 | { |
458 | struct platform_device *pdev = to_platform_device(dev); | ||
459 | struct spear_rtc_config *config = platform_get_drvdata(pdev); | 459 | struct spear_rtc_config *config = platform_get_drvdata(pdev); |
460 | int irq; | 460 | int irq; |
461 | 461 | ||
@@ -473,12 +473,10 @@ static int spear_rtc_resume(struct platform_device *pdev) | |||
473 | 473 | ||
474 | return 0; | 474 | return 0; |
475 | } | 475 | } |
476 | |||
477 | #else | ||
478 | #define spear_rtc_suspend NULL | ||
479 | #define spear_rtc_resume NULL | ||
480 | #endif | 476 | #endif |
481 | 477 | ||
478 | static SIMPLE_DEV_PM_OPS(spear_rtc_pm_ops, spear_rtc_suspend, spear_rtc_resume); | ||
479 | |||
482 | static void spear_rtc_shutdown(struct platform_device *pdev) | 480 | static void spear_rtc_shutdown(struct platform_device *pdev) |
483 | { | 481 | { |
484 | struct spear_rtc_config *config = platform_get_drvdata(pdev); | 482 | struct spear_rtc_config *config = platform_get_drvdata(pdev); |
@@ -498,11 +496,10 @@ MODULE_DEVICE_TABLE(of, spear_rtc_id_table); | |||
498 | static struct platform_driver spear_rtc_driver = { | 496 | static struct platform_driver spear_rtc_driver = { |
499 | .probe = spear_rtc_probe, | 497 | .probe = spear_rtc_probe, |
500 | .remove = spear_rtc_remove, | 498 | .remove = spear_rtc_remove, |
501 | .suspend = spear_rtc_suspend, | ||
502 | .resume = spear_rtc_resume, | ||
503 | .shutdown = spear_rtc_shutdown, | 499 | .shutdown = spear_rtc_shutdown, |
504 | .driver = { | 500 | .driver = { |
505 | .name = "rtc-spear", | 501 | .name = "rtc-spear", |
502 | .pm = &spear_rtc_pm_ops, | ||
506 | .of_match_table = of_match_ptr(spear_rtc_id_table), | 503 | .of_match_table = of_match_ptr(spear_rtc_id_table), |
507 | }, | 504 | }, |
508 | }; | 505 | }; |
diff --git a/drivers/rtc/rtc-starfire.c b/drivers/rtc/rtc-starfire.c index 5be98bfd7ed3..987b5ec0ae56 100644 --- a/drivers/rtc/rtc-starfire.c +++ b/drivers/rtc/rtc-starfire.c | |||
@@ -39,8 +39,10 @@ static const struct rtc_class_ops starfire_rtc_ops = { | |||
39 | 39 | ||
40 | static int __init starfire_rtc_probe(struct platform_device *pdev) | 40 | static int __init starfire_rtc_probe(struct platform_device *pdev) |
41 | { | 41 | { |
42 | struct rtc_device *rtc = rtc_device_register("starfire", &pdev->dev, | 42 | struct rtc_device *rtc; |
43 | &starfire_rtc_ops, THIS_MODULE); | 43 | |
44 | rtc = devm_rtc_device_register(&pdev->dev, "starfire", | ||
45 | &starfire_rtc_ops, THIS_MODULE); | ||
44 | if (IS_ERR(rtc)) | 46 | if (IS_ERR(rtc)) |
45 | return PTR_ERR(rtc); | 47 | return PTR_ERR(rtc); |
46 | 48 | ||
@@ -51,10 +53,6 @@ static int __init starfire_rtc_probe(struct platform_device *pdev) | |||
51 | 53 | ||
52 | static int __exit starfire_rtc_remove(struct platform_device *pdev) | 54 | static int __exit starfire_rtc_remove(struct platform_device *pdev) |
53 | { | 55 | { |
54 | struct rtc_device *rtc = platform_get_drvdata(pdev); | ||
55 | |||
56 | rtc_device_unregister(rtc); | ||
57 | |||
58 | return 0; | 56 | return 0; |
59 | } | 57 | } |
60 | 58 | ||
@@ -66,15 +64,4 @@ static struct platform_driver starfire_rtc_driver = { | |||
66 | .remove = __exit_p(starfire_rtc_remove), | 64 | .remove = __exit_p(starfire_rtc_remove), |
67 | }; | 65 | }; |
68 | 66 | ||
69 | static int __init starfire_rtc_init(void) | 67 | module_platform_driver_probe(starfire_rtc_driver, starfire_rtc_probe); |
70 | { | ||
71 | return platform_driver_probe(&starfire_rtc_driver, starfire_rtc_probe); | ||
72 | } | ||
73 | |||
74 | static void __exit starfire_rtc_exit(void) | ||
75 | { | ||
76 | platform_driver_unregister(&starfire_rtc_driver); | ||
77 | } | ||
78 | |||
79 | module_init(starfire_rtc_init); | ||
80 | module_exit(starfire_rtc_exit); | ||
diff --git a/drivers/rtc/rtc-stk17ta8.c b/drivers/rtc/rtc-stk17ta8.c index 7e4a6f65cb91..af5e97e3f272 100644 --- a/drivers/rtc/rtc-stk17ta8.c +++ b/drivers/rtc/rtc-stk17ta8.c | |||
@@ -336,14 +336,13 @@ static int stk17ta8_rtc_probe(struct platform_device *pdev) | |||
336 | } | 336 | } |
337 | } | 337 | } |
338 | 338 | ||
339 | pdata->rtc = rtc_device_register(pdev->name, &pdev->dev, | 339 | pdata->rtc = devm_rtc_device_register(&pdev->dev, pdev->name, |
340 | &stk17ta8_rtc_ops, THIS_MODULE); | 340 | &stk17ta8_rtc_ops, THIS_MODULE); |
341 | if (IS_ERR(pdata->rtc)) | 341 | if (IS_ERR(pdata->rtc)) |
342 | return PTR_ERR(pdata->rtc); | 342 | return PTR_ERR(pdata->rtc); |
343 | 343 | ||
344 | ret = sysfs_create_bin_file(&pdev->dev.kobj, &stk17ta8_nvram_attr); | 344 | ret = sysfs_create_bin_file(&pdev->dev.kobj, &stk17ta8_nvram_attr); |
345 | if (ret) | 345 | |
346 | rtc_device_unregister(pdata->rtc); | ||
347 | return ret; | 346 | return ret; |
348 | } | 347 | } |
349 | 348 | ||
@@ -352,7 +351,6 @@ static int stk17ta8_rtc_remove(struct platform_device *pdev) | |||
352 | struct rtc_plat_data *pdata = platform_get_drvdata(pdev); | 351 | struct rtc_plat_data *pdata = platform_get_drvdata(pdev); |
353 | 352 | ||
354 | sysfs_remove_bin_file(&pdev->dev.kobj, &stk17ta8_nvram_attr); | 353 | sysfs_remove_bin_file(&pdev->dev.kobj, &stk17ta8_nvram_attr); |
355 | rtc_device_unregister(pdata->rtc); | ||
356 | if (pdata->irq > 0) | 354 | if (pdata->irq > 0) |
357 | writeb(0, pdata->ioaddr + RTC_INTERRUPTS); | 355 | writeb(0, pdata->ioaddr + RTC_INTERRUPTS); |
358 | return 0; | 356 | return 0; |
diff --git a/drivers/rtc/rtc-stmp3xxx.c b/drivers/rtc/rtc-stmp3xxx.c index 98f0d3c30738..a9cd26a26dc0 100644 --- a/drivers/rtc/rtc-stmp3xxx.c +++ b/drivers/rtc/rtc-stmp3xxx.c | |||
@@ -227,11 +227,7 @@ static int stmp3xxx_rtc_remove(struct platform_device *pdev) | |||
227 | 227 | ||
228 | writel(STMP3XXX_RTC_CTRL_ALARM_IRQ_EN, | 228 | writel(STMP3XXX_RTC_CTRL_ALARM_IRQ_EN, |
229 | rtc_data->io + STMP3XXX_RTC_CTRL_CLR); | 229 | rtc_data->io + STMP3XXX_RTC_CTRL_CLR); |
230 | free_irq(rtc_data->irq_alarm, &pdev->dev); | ||
231 | rtc_device_unregister(rtc_data->rtc); | ||
232 | platform_set_drvdata(pdev, NULL); | 230 | platform_set_drvdata(pdev, NULL); |
233 | iounmap(rtc_data->io); | ||
234 | kfree(rtc_data); | ||
235 | 231 | ||
236 | return 0; | 232 | return 0; |
237 | } | 233 | } |
@@ -242,22 +238,20 @@ static int stmp3xxx_rtc_probe(struct platform_device *pdev) | |||
242 | struct resource *r; | 238 | struct resource *r; |
243 | int err; | 239 | int err; |
244 | 240 | ||
245 | rtc_data = kzalloc(sizeof *rtc_data, GFP_KERNEL); | 241 | rtc_data = devm_kzalloc(&pdev->dev, sizeof(*rtc_data), GFP_KERNEL); |
246 | if (!rtc_data) | 242 | if (!rtc_data) |
247 | return -ENOMEM; | 243 | return -ENOMEM; |
248 | 244 | ||
249 | r = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 245 | r = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
250 | if (!r) { | 246 | if (!r) { |
251 | dev_err(&pdev->dev, "failed to get resource\n"); | 247 | dev_err(&pdev->dev, "failed to get resource\n"); |
252 | err = -ENXIO; | 248 | return -ENXIO; |
253 | goto out_free; | ||
254 | } | 249 | } |
255 | 250 | ||
256 | rtc_data->io = ioremap(r->start, resource_size(r)); | 251 | rtc_data->io = devm_ioremap(&pdev->dev, r->start, resource_size(r)); |
257 | if (!rtc_data->io) { | 252 | if (!rtc_data->io) { |
258 | dev_err(&pdev->dev, "ioremap failed\n"); | 253 | dev_err(&pdev->dev, "ioremap failed\n"); |
259 | err = -EIO; | 254 | return -EIO; |
260 | goto out_free; | ||
261 | } | 255 | } |
262 | 256 | ||
263 | rtc_data->irq_alarm = platform_get_irq(pdev, 0); | 257 | rtc_data->irq_alarm = platform_get_irq(pdev, 0); |
@@ -265,8 +259,7 @@ static int stmp3xxx_rtc_probe(struct platform_device *pdev) | |||
265 | if (!(readl(STMP3XXX_RTC_STAT + rtc_data->io) & | 259 | if (!(readl(STMP3XXX_RTC_STAT + rtc_data->io) & |
266 | STMP3XXX_RTC_STAT_RTC_PRESENT)) { | 260 | STMP3XXX_RTC_STAT_RTC_PRESENT)) { |
267 | dev_err(&pdev->dev, "no device onboard\n"); | 261 | dev_err(&pdev->dev, "no device onboard\n"); |
268 | err = -ENODEV; | 262 | return -ENODEV; |
269 | goto out_remap; | ||
270 | } | 263 | } |
271 | 264 | ||
272 | platform_set_drvdata(pdev, rtc_data); | 265 | platform_set_drvdata(pdev, rtc_data); |
@@ -281,43 +274,38 @@ static int stmp3xxx_rtc_probe(struct platform_device *pdev) | |||
281 | STMP3XXX_RTC_CTRL_ALARM_IRQ_EN, | 274 | STMP3XXX_RTC_CTRL_ALARM_IRQ_EN, |
282 | rtc_data->io + STMP3XXX_RTC_CTRL_CLR); | 275 | rtc_data->io + STMP3XXX_RTC_CTRL_CLR); |
283 | 276 | ||
284 | rtc_data->rtc = rtc_device_register(pdev->name, &pdev->dev, | 277 | rtc_data->rtc = devm_rtc_device_register(&pdev->dev, pdev->name, |
285 | &stmp3xxx_rtc_ops, THIS_MODULE); | 278 | &stmp3xxx_rtc_ops, THIS_MODULE); |
286 | if (IS_ERR(rtc_data->rtc)) { | 279 | if (IS_ERR(rtc_data->rtc)) { |
287 | err = PTR_ERR(rtc_data->rtc); | 280 | err = PTR_ERR(rtc_data->rtc); |
288 | goto out_remap; | 281 | goto out; |
289 | } | 282 | } |
290 | 283 | ||
291 | err = request_irq(rtc_data->irq_alarm, stmp3xxx_rtc_interrupt, 0, | 284 | err = devm_request_irq(&pdev->dev, rtc_data->irq_alarm, |
292 | "RTC alarm", &pdev->dev); | 285 | stmp3xxx_rtc_interrupt, 0, "RTC alarm", &pdev->dev); |
293 | if (err) { | 286 | if (err) { |
294 | dev_err(&pdev->dev, "Cannot claim IRQ%d\n", | 287 | dev_err(&pdev->dev, "Cannot claim IRQ%d\n", |
295 | rtc_data->irq_alarm); | 288 | rtc_data->irq_alarm); |
296 | goto out_irq_alarm; | 289 | goto out; |
297 | } | 290 | } |
298 | 291 | ||
299 | stmp3xxx_wdt_register(pdev); | 292 | stmp3xxx_wdt_register(pdev); |
300 | return 0; | 293 | return 0; |
301 | 294 | ||
302 | out_irq_alarm: | 295 | out: |
303 | rtc_device_unregister(rtc_data->rtc); | ||
304 | out_remap: | ||
305 | platform_set_drvdata(pdev, NULL); | 296 | platform_set_drvdata(pdev, NULL); |
306 | iounmap(rtc_data->io); | ||
307 | out_free: | ||
308 | kfree(rtc_data); | ||
309 | return err; | 297 | return err; |
310 | } | 298 | } |
311 | 299 | ||
312 | #ifdef CONFIG_PM | 300 | #ifdef CONFIG_PM_SLEEP |
313 | static int stmp3xxx_rtc_suspend(struct platform_device *dev, pm_message_t state) | 301 | static int stmp3xxx_rtc_suspend(struct device *dev) |
314 | { | 302 | { |
315 | return 0; | 303 | return 0; |
316 | } | 304 | } |
317 | 305 | ||
318 | static int stmp3xxx_rtc_resume(struct platform_device *dev) | 306 | static int stmp3xxx_rtc_resume(struct device *dev) |
319 | { | 307 | { |
320 | struct stmp3xxx_rtc_data *rtc_data = platform_get_drvdata(dev); | 308 | struct stmp3xxx_rtc_data *rtc_data = dev_get_drvdata(dev); |
321 | 309 | ||
322 | mxs_reset_block(rtc_data->io); | 310 | mxs_reset_block(rtc_data->io); |
323 | writel(STMP3XXX_RTC_PERSISTENT0_ALARM_EN | | 311 | writel(STMP3XXX_RTC_PERSISTENT0_ALARM_EN | |
@@ -326,11 +314,11 @@ static int stmp3xxx_rtc_resume(struct platform_device *dev) | |||
326 | rtc_data->io + STMP3XXX_RTC_PERSISTENT0_CLR); | 314 | rtc_data->io + STMP3XXX_RTC_PERSISTENT0_CLR); |
327 | return 0; | 315 | return 0; |
328 | } | 316 | } |
329 | #else | ||
330 | #define stmp3xxx_rtc_suspend NULL | ||
331 | #define stmp3xxx_rtc_resume NULL | ||
332 | #endif | 317 | #endif |
333 | 318 | ||
319 | static SIMPLE_DEV_PM_OPS(stmp3xxx_rtc_pm_ops, stmp3xxx_rtc_suspend, | ||
320 | stmp3xxx_rtc_resume); | ||
321 | |||
334 | static const struct of_device_id rtc_dt_ids[] = { | 322 | static const struct of_device_id rtc_dt_ids[] = { |
335 | { .compatible = "fsl,stmp3xxx-rtc", }, | 323 | { .compatible = "fsl,stmp3xxx-rtc", }, |
336 | { /* sentinel */ } | 324 | { /* sentinel */ } |
@@ -340,11 +328,10 @@ MODULE_DEVICE_TABLE(of, rtc_dt_ids); | |||
340 | static struct platform_driver stmp3xxx_rtcdrv = { | 328 | static struct platform_driver stmp3xxx_rtcdrv = { |
341 | .probe = stmp3xxx_rtc_probe, | 329 | .probe = stmp3xxx_rtc_probe, |
342 | .remove = stmp3xxx_rtc_remove, | 330 | .remove = stmp3xxx_rtc_remove, |
343 | .suspend = stmp3xxx_rtc_suspend, | ||
344 | .resume = stmp3xxx_rtc_resume, | ||
345 | .driver = { | 331 | .driver = { |
346 | .name = "stmp3xxx-rtc", | 332 | .name = "stmp3xxx-rtc", |
347 | .owner = THIS_MODULE, | 333 | .owner = THIS_MODULE, |
334 | .pm = &stmp3xxx_rtc_pm_ops, | ||
348 | .of_match_table = of_match_ptr(rtc_dt_ids), | 335 | .of_match_table = of_match_ptr(rtc_dt_ids), |
349 | }, | 336 | }, |
350 | }; | 337 | }; |
diff --git a/drivers/rtc/rtc-sun4v.c b/drivers/rtc/rtc-sun4v.c index 59b5c2dcb58c..ce42e5fa9e09 100644 --- a/drivers/rtc/rtc-sun4v.c +++ b/drivers/rtc/rtc-sun4v.c | |||
@@ -81,8 +81,10 @@ static const struct rtc_class_ops sun4v_rtc_ops = { | |||
81 | 81 | ||
82 | static int __init sun4v_rtc_probe(struct platform_device *pdev) | 82 | static int __init sun4v_rtc_probe(struct platform_device *pdev) |
83 | { | 83 | { |
84 | struct rtc_device *rtc = rtc_device_register("sun4v", &pdev->dev, | 84 | struct rtc_device *rtc; |
85 | &sun4v_rtc_ops, THIS_MODULE); | 85 | |
86 | rtc = devm_rtc_device_register(&pdev->dev, "sun4v", | ||
87 | &sun4v_rtc_ops, THIS_MODULE); | ||
86 | if (IS_ERR(rtc)) | 88 | if (IS_ERR(rtc)) |
87 | return PTR_ERR(rtc); | 89 | return PTR_ERR(rtc); |
88 | 90 | ||
@@ -92,9 +94,6 @@ static int __init sun4v_rtc_probe(struct platform_device *pdev) | |||
92 | 94 | ||
93 | static int __exit sun4v_rtc_remove(struct platform_device *pdev) | 95 | static int __exit sun4v_rtc_remove(struct platform_device *pdev) |
94 | { | 96 | { |
95 | struct rtc_device *rtc = platform_get_drvdata(pdev); | ||
96 | |||
97 | rtc_device_unregister(rtc); | ||
98 | return 0; | 97 | return 0; |
99 | } | 98 | } |
100 | 99 | ||
@@ -106,18 +105,7 @@ static struct platform_driver sun4v_rtc_driver = { | |||
106 | .remove = __exit_p(sun4v_rtc_remove), | 105 | .remove = __exit_p(sun4v_rtc_remove), |
107 | }; | 106 | }; |
108 | 107 | ||
109 | static int __init sun4v_rtc_init(void) | 108 | module_platform_driver_probe(sun4v_rtc_driver, sun4v_rtc_probe); |
110 | { | ||
111 | return platform_driver_probe(&sun4v_rtc_driver, sun4v_rtc_probe); | ||
112 | } | ||
113 | |||
114 | static void __exit sun4v_rtc_exit(void) | ||
115 | { | ||
116 | platform_driver_unregister(&sun4v_rtc_driver); | ||
117 | } | ||
118 | |||
119 | module_init(sun4v_rtc_init); | ||
120 | module_exit(sun4v_rtc_exit); | ||
121 | 109 | ||
122 | MODULE_AUTHOR("David S. Miller <davem@davemloft.net>"); | 110 | MODULE_AUTHOR("David S. Miller <davem@davemloft.net>"); |
123 | MODULE_DESCRIPTION("SUN4V RTC driver"); | 111 | MODULE_DESCRIPTION("SUN4V RTC driver"); |
diff --git a/drivers/rtc/rtc-tegra.c b/drivers/rtc/rtc-tegra.c index 7c033756d6b5..a34315d25478 100644 --- a/drivers/rtc/rtc-tegra.c +++ b/drivers/rtc/rtc-tegra.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include <linux/delay.h> | 26 | #include <linux/delay.h> |
27 | #include <linux/rtc.h> | 27 | #include <linux/rtc.h> |
28 | #include <linux/platform_device.h> | 28 | #include <linux/platform_device.h> |
29 | #include <linux/pm.h> | ||
29 | 30 | ||
30 | /* set to 1 = busy every eight 32kHz clocks during copy of sec+msec to AHB */ | 31 | /* set to 1 = busy every eight 32kHz clocks during copy of sec+msec to AHB */ |
31 | #define TEGRA_RTC_REG_BUSY 0x004 | 32 | #define TEGRA_RTC_REG_BUSY 0x004 |
@@ -309,7 +310,7 @@ static const struct of_device_id tegra_rtc_dt_match[] = { | |||
309 | }; | 310 | }; |
310 | MODULE_DEVICE_TABLE(of, tegra_rtc_dt_match); | 311 | MODULE_DEVICE_TABLE(of, tegra_rtc_dt_match); |
311 | 312 | ||
312 | static int tegra_rtc_probe(struct platform_device *pdev) | 313 | static int __init tegra_rtc_probe(struct platform_device *pdev) |
313 | { | 314 | { |
314 | struct tegra_rtc_info *info; | 315 | struct tegra_rtc_info *info; |
315 | struct resource *res; | 316 | struct resource *res; |
@@ -348,53 +349,35 @@ static int tegra_rtc_probe(struct platform_device *pdev) | |||
348 | 349 | ||
349 | device_init_wakeup(&pdev->dev, 1); | 350 | device_init_wakeup(&pdev->dev, 1); |
350 | 351 | ||
351 | info->rtc_dev = rtc_device_register( | 352 | info->rtc_dev = devm_rtc_device_register(&pdev->dev, |
352 | pdev->name, &pdev->dev, &tegra_rtc_ops, THIS_MODULE); | 353 | dev_name(&pdev->dev), &tegra_rtc_ops, |
354 | THIS_MODULE); | ||
353 | if (IS_ERR(info->rtc_dev)) { | 355 | if (IS_ERR(info->rtc_dev)) { |
354 | ret = PTR_ERR(info->rtc_dev); | 356 | ret = PTR_ERR(info->rtc_dev); |
355 | info->rtc_dev = NULL; | 357 | dev_err(&pdev->dev, "Unable to register device (err=%d).\n", |
356 | dev_err(&pdev->dev, | ||
357 | "Unable to register device (err=%d).\n", | ||
358 | ret); | 358 | ret); |
359 | return ret; | 359 | return ret; |
360 | } | 360 | } |
361 | 361 | ||
362 | ret = devm_request_irq(&pdev->dev, info->tegra_rtc_irq, | 362 | ret = devm_request_irq(&pdev->dev, info->tegra_rtc_irq, |
363 | tegra_rtc_irq_handler, IRQF_TRIGGER_HIGH, | 363 | tegra_rtc_irq_handler, IRQF_TRIGGER_HIGH, |
364 | "rtc alarm", &pdev->dev); | 364 | dev_name(&pdev->dev), &pdev->dev); |
365 | if (ret) { | 365 | if (ret) { |
366 | dev_err(&pdev->dev, | 366 | dev_err(&pdev->dev, |
367 | "Unable to request interrupt for device (err=%d).\n", | 367 | "Unable to request interrupt for device (err=%d).\n", |
368 | ret); | 368 | ret); |
369 | goto err_dev_unreg; | 369 | return ret; |
370 | } | 370 | } |
371 | 371 | ||
372 | dev_notice(&pdev->dev, "Tegra internal Real Time Clock\n"); | 372 | dev_notice(&pdev->dev, "Tegra internal Real Time Clock\n"); |
373 | 373 | ||
374 | return 0; | 374 | return 0; |
375 | |||
376 | err_dev_unreg: | ||
377 | rtc_device_unregister(info->rtc_dev); | ||
378 | |||
379 | return ret; | ||
380 | } | 375 | } |
381 | 376 | ||
382 | static int tegra_rtc_remove(struct platform_device *pdev) | 377 | #ifdef CONFIG_PM_SLEEP |
378 | static int tegra_rtc_suspend(struct device *dev) | ||
383 | { | 379 | { |
384 | struct tegra_rtc_info *info = platform_get_drvdata(pdev); | 380 | struct tegra_rtc_info *info = dev_get_drvdata(dev); |
385 | |||
386 | rtc_device_unregister(info->rtc_dev); | ||
387 | |||
388 | platform_set_drvdata(pdev, NULL); | ||
389 | |||
390 | return 0; | ||
391 | } | ||
392 | |||
393 | #ifdef CONFIG_PM | ||
394 | static int tegra_rtc_suspend(struct platform_device *pdev, pm_message_t state) | ||
395 | { | ||
396 | struct device *dev = &pdev->dev; | ||
397 | struct tegra_rtc_info *info = platform_get_drvdata(pdev); | ||
398 | 381 | ||
399 | tegra_rtc_wait_while_busy(dev); | 382 | tegra_rtc_wait_while_busy(dev); |
400 | 383 | ||
@@ -416,10 +399,9 @@ static int tegra_rtc_suspend(struct platform_device *pdev, pm_message_t state) | |||
416 | return 0; | 399 | return 0; |
417 | } | 400 | } |
418 | 401 | ||
419 | static int tegra_rtc_resume(struct platform_device *pdev) | 402 | static int tegra_rtc_resume(struct device *dev) |
420 | { | 403 | { |
421 | struct device *dev = &pdev->dev; | 404 | struct tegra_rtc_info *info = dev_get_drvdata(dev); |
422 | struct tegra_rtc_info *info = platform_get_drvdata(pdev); | ||
423 | 405 | ||
424 | dev_vdbg(dev, "Resume (device_may_wakeup=%d)\n", | 406 | dev_vdbg(dev, "Resume (device_may_wakeup=%d)\n", |
425 | device_may_wakeup(dev)); | 407 | device_may_wakeup(dev)); |
@@ -431,6 +413,8 @@ static int tegra_rtc_resume(struct platform_device *pdev) | |||
431 | } | 413 | } |
432 | #endif | 414 | #endif |
433 | 415 | ||
416 | static SIMPLE_DEV_PM_OPS(tegra_rtc_pm_ops, tegra_rtc_suspend, tegra_rtc_resume); | ||
417 | |||
434 | static void tegra_rtc_shutdown(struct platform_device *pdev) | 418 | static void tegra_rtc_shutdown(struct platform_device *pdev) |
435 | { | 419 | { |
436 | dev_vdbg(&pdev->dev, "disabling interrupts.\n"); | 420 | dev_vdbg(&pdev->dev, "disabling interrupts.\n"); |
@@ -439,30 +423,16 @@ static void tegra_rtc_shutdown(struct platform_device *pdev) | |||
439 | 423 | ||
440 | MODULE_ALIAS("platform:tegra_rtc"); | 424 | MODULE_ALIAS("platform:tegra_rtc"); |
441 | static struct platform_driver tegra_rtc_driver = { | 425 | static struct platform_driver tegra_rtc_driver = { |
442 | .remove = tegra_rtc_remove, | ||
443 | .shutdown = tegra_rtc_shutdown, | 426 | .shutdown = tegra_rtc_shutdown, |
444 | .driver = { | 427 | .driver = { |
445 | .name = "tegra_rtc", | 428 | .name = "tegra_rtc", |
446 | .owner = THIS_MODULE, | 429 | .owner = THIS_MODULE, |
447 | .of_match_table = tegra_rtc_dt_match, | 430 | .of_match_table = tegra_rtc_dt_match, |
431 | .pm = &tegra_rtc_pm_ops, | ||
448 | }, | 432 | }, |
449 | #ifdef CONFIG_PM | ||
450 | .suspend = tegra_rtc_suspend, | ||
451 | .resume = tegra_rtc_resume, | ||
452 | #endif | ||
453 | }; | 433 | }; |
454 | 434 | ||
455 | static int __init tegra_rtc_init(void) | 435 | module_platform_driver_probe(tegra_rtc_driver, tegra_rtc_probe); |
456 | { | ||
457 | return platform_driver_probe(&tegra_rtc_driver, tegra_rtc_probe); | ||
458 | } | ||
459 | module_init(tegra_rtc_init); | ||
460 | |||
461 | static void __exit tegra_rtc_exit(void) | ||
462 | { | ||
463 | platform_driver_unregister(&tegra_rtc_driver); | ||
464 | } | ||
465 | module_exit(tegra_rtc_exit); | ||
466 | 436 | ||
467 | MODULE_AUTHOR("Jon Mayo <jmayo@nvidia.com>"); | 437 | MODULE_AUTHOR("Jon Mayo <jmayo@nvidia.com>"); |
468 | MODULE_DESCRIPTION("driver for Tegra internal RTC"); | 438 | MODULE_DESCRIPTION("driver for Tegra internal RTC"); |
diff --git a/drivers/rtc/rtc-test.c b/drivers/rtc/rtc-test.c index b92e0f6383e6..7746e65b93f2 100644 --- a/drivers/rtc/rtc-test.c +++ b/drivers/rtc/rtc-test.c | |||
@@ -99,8 +99,10 @@ static DEVICE_ATTR(irq, S_IRUGO | S_IWUSR, test_irq_show, test_irq_store); | |||
99 | static int test_probe(struct platform_device *plat_dev) | 99 | static int test_probe(struct platform_device *plat_dev) |
100 | { | 100 | { |
101 | int err; | 101 | int err; |
102 | struct rtc_device *rtc = rtc_device_register("test", &plat_dev->dev, | 102 | struct rtc_device *rtc; |
103 | &test_rtc_ops, THIS_MODULE); | 103 | |
104 | rtc = devm_rtc_device_register(&plat_dev->dev, "test", | ||
105 | &test_rtc_ops, THIS_MODULE); | ||
104 | if (IS_ERR(rtc)) { | 106 | if (IS_ERR(rtc)) { |
105 | err = PTR_ERR(rtc); | 107 | err = PTR_ERR(rtc); |
106 | return err; | 108 | return err; |
@@ -115,15 +117,11 @@ static int test_probe(struct platform_device *plat_dev) | |||
115 | return 0; | 117 | return 0; |
116 | 118 | ||
117 | err: | 119 | err: |
118 | rtc_device_unregister(rtc); | ||
119 | return err; | 120 | return err; |
120 | } | 121 | } |
121 | 122 | ||
122 | static int test_remove(struct platform_device *plat_dev) | 123 | static int test_remove(struct platform_device *plat_dev) |
123 | { | 124 | { |
124 | struct rtc_device *rtc = platform_get_drvdata(plat_dev); | ||
125 | |||
126 | rtc_device_unregister(rtc); | ||
127 | device_remove_file(&plat_dev->dev, &dev_attr_irq); | 125 | device_remove_file(&plat_dev->dev, &dev_attr_irq); |
128 | 126 | ||
129 | return 0; | 127 | return 0; |
diff --git a/drivers/rtc/rtc-tile.c b/drivers/rtc/rtc-tile.c index 62db4841078b..249b6531f119 100644 --- a/drivers/rtc/rtc-tile.c +++ b/drivers/rtc/rtc-tile.c | |||
@@ -80,8 +80,8 @@ static int tile_rtc_probe(struct platform_device *dev) | |||
80 | { | 80 | { |
81 | struct rtc_device *rtc; | 81 | struct rtc_device *rtc; |
82 | 82 | ||
83 | rtc = rtc_device_register("tile", | 83 | rtc = devm_rtc_device_register(&dev->dev, "tile", |
84 | &dev->dev, &tile_rtc_ops, THIS_MODULE); | 84 | &tile_rtc_ops, THIS_MODULE); |
85 | 85 | ||
86 | if (IS_ERR(rtc)) | 86 | if (IS_ERR(rtc)) |
87 | return PTR_ERR(rtc); | 87 | return PTR_ERR(rtc); |
@@ -96,11 +96,6 @@ static int tile_rtc_probe(struct platform_device *dev) | |||
96 | */ | 96 | */ |
97 | static int tile_rtc_remove(struct platform_device *dev) | 97 | static int tile_rtc_remove(struct platform_device *dev) |
98 | { | 98 | { |
99 | struct rtc_device *rtc = platform_get_drvdata(dev); | ||
100 | |||
101 | if (rtc) | ||
102 | rtc_device_unregister(rtc); | ||
103 | |||
104 | platform_set_drvdata(dev, NULL); | 99 | platform_set_drvdata(dev, NULL); |
105 | 100 | ||
106 | return 0; | 101 | return 0; |
diff --git a/drivers/rtc/rtc-tps6586x.c b/drivers/rtc/rtc-tps6586x.c index aab4e8c93622..459c2ffc95a6 100644 --- a/drivers/rtc/rtc-tps6586x.c +++ b/drivers/rtc/rtc-tps6586x.c | |||
@@ -274,7 +274,7 @@ static int tps6586x_rtc_probe(struct platform_device *pdev) | |||
274 | } | 274 | } |
275 | 275 | ||
276 | platform_set_drvdata(pdev, rtc); | 276 | platform_set_drvdata(pdev, rtc); |
277 | rtc->rtc = rtc_device_register(dev_name(&pdev->dev), &pdev->dev, | 277 | rtc->rtc = devm_rtc_device_register(&pdev->dev, dev_name(&pdev->dev), |
278 | &tps6586x_rtc_ops, THIS_MODULE); | 278 | &tps6586x_rtc_ops, THIS_MODULE); |
279 | if (IS_ERR(rtc->rtc)) { | 279 | if (IS_ERR(rtc->rtc)) { |
280 | ret = PTR_ERR(rtc->rtc); | 280 | ret = PTR_ERR(rtc->rtc); |
@@ -289,15 +289,12 @@ static int tps6586x_rtc_probe(struct platform_device *pdev) | |||
289 | if (ret < 0) { | 289 | if (ret < 0) { |
290 | dev_err(&pdev->dev, "request IRQ(%d) failed with ret %d\n", | 290 | dev_err(&pdev->dev, "request IRQ(%d) failed with ret %d\n", |
291 | rtc->irq, ret); | 291 | rtc->irq, ret); |
292 | goto fail_req_irq; | 292 | goto fail_rtc_register; |
293 | } | 293 | } |
294 | disable_irq(rtc->irq); | 294 | disable_irq(rtc->irq); |
295 | device_set_wakeup_capable(&pdev->dev, 1); | 295 | device_set_wakeup_capable(&pdev->dev, 1); |
296 | return 0; | 296 | return 0; |
297 | 297 | ||
298 | fail_req_irq: | ||
299 | rtc_device_unregister(rtc->rtc); | ||
300 | |||
301 | fail_rtc_register: | 298 | fail_rtc_register: |
302 | tps6586x_update(tps_dev, RTC_CTRL, 0, | 299 | tps6586x_update(tps_dev, RTC_CTRL, 0, |
303 | RTC_ENABLE | OSC_SRC_SEL | PRE_BYPASS | CL_SEL_MASK); | 300 | RTC_ENABLE | OSC_SRC_SEL | PRE_BYPASS | CL_SEL_MASK); |
@@ -306,12 +303,10 @@ fail_rtc_register: | |||
306 | 303 | ||
307 | static int tps6586x_rtc_remove(struct platform_device *pdev) | 304 | static int tps6586x_rtc_remove(struct platform_device *pdev) |
308 | { | 305 | { |
309 | struct tps6586x_rtc *rtc = platform_get_drvdata(pdev); | ||
310 | struct device *tps_dev = to_tps6586x_dev(&pdev->dev); | 306 | struct device *tps_dev = to_tps6586x_dev(&pdev->dev); |
311 | 307 | ||
312 | tps6586x_update(tps_dev, RTC_CTRL, 0, | 308 | tps6586x_update(tps_dev, RTC_CTRL, 0, |
313 | RTC_ENABLE | OSC_SRC_SEL | PRE_BYPASS | CL_SEL_MASK); | 309 | RTC_ENABLE | OSC_SRC_SEL | PRE_BYPASS | CL_SEL_MASK); |
314 | rtc_device_unregister(rtc->rtc); | ||
315 | return 0; | 310 | return 0; |
316 | } | 311 | } |
317 | 312 | ||
@@ -335,9 +330,8 @@ static int tps6586x_rtc_resume(struct device *dev) | |||
335 | } | 330 | } |
336 | #endif | 331 | #endif |
337 | 332 | ||
338 | static const struct dev_pm_ops tps6586x_pm_ops = { | 333 | static SIMPLE_DEV_PM_OPS(tps6586x_pm_ops, tps6586x_rtc_suspend, |
339 | SET_SYSTEM_SLEEP_PM_OPS(tps6586x_rtc_suspend, tps6586x_rtc_resume) | 334 | tps6586x_rtc_resume); |
340 | }; | ||
341 | 335 | ||
342 | static struct platform_driver tps6586x_rtc_driver = { | 336 | static struct platform_driver tps6586x_rtc_driver = { |
343 | .driver = { | 337 | .driver = { |
diff --git a/drivers/rtc/rtc-tps65910.c b/drivers/rtc/rtc-tps65910.c index 8bd8115329b5..a9caf043b0ce 100644 --- a/drivers/rtc/rtc-tps65910.c +++ b/drivers/rtc/rtc-tps65910.c | |||
@@ -263,7 +263,7 @@ static int tps65910_rtc_probe(struct platform_device *pdev) | |||
263 | if (irq <= 0) { | 263 | if (irq <= 0) { |
264 | dev_warn(&pdev->dev, "Wake up is not possible as irq = %d\n", | 264 | dev_warn(&pdev->dev, "Wake up is not possible as irq = %d\n", |
265 | irq); | 265 | irq); |
266 | return ret; | 266 | return -ENXIO; |
267 | } | 267 | } |
268 | 268 | ||
269 | ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, | 269 | ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, |
@@ -276,7 +276,7 @@ static int tps65910_rtc_probe(struct platform_device *pdev) | |||
276 | tps_rtc->irq = irq; | 276 | tps_rtc->irq = irq; |
277 | device_set_wakeup_capable(&pdev->dev, 1); | 277 | device_set_wakeup_capable(&pdev->dev, 1); |
278 | 278 | ||
279 | tps_rtc->rtc = rtc_device_register(pdev->name, &pdev->dev, | 279 | tps_rtc->rtc = devm_rtc_device_register(&pdev->dev, pdev->name, |
280 | &tps65910_rtc_ops, THIS_MODULE); | 280 | &tps65910_rtc_ops, THIS_MODULE); |
281 | if (IS_ERR(tps_rtc->rtc)) { | 281 | if (IS_ERR(tps_rtc->rtc)) { |
282 | ret = PTR_ERR(tps_rtc->rtc); | 282 | ret = PTR_ERR(tps_rtc->rtc); |
@@ -295,12 +295,8 @@ static int tps65910_rtc_probe(struct platform_device *pdev) | |||
295 | */ | 295 | */ |
296 | static int tps65910_rtc_remove(struct platform_device *pdev) | 296 | static int tps65910_rtc_remove(struct platform_device *pdev) |
297 | { | 297 | { |
298 | /* leave rtc running, but disable irqs */ | ||
299 | struct tps65910_rtc *tps_rtc = platform_get_drvdata(pdev); | ||
300 | |||
301 | tps65910_rtc_alarm_irq_enable(&pdev->dev, 0); | 298 | tps65910_rtc_alarm_irq_enable(&pdev->dev, 0); |
302 | 299 | ||
303 | rtc_device_unregister(tps_rtc->rtc); | ||
304 | return 0; | 300 | return 0; |
305 | } | 301 | } |
306 | 302 | ||
@@ -324,9 +320,8 @@ static int tps65910_rtc_resume(struct device *dev) | |||
324 | } | 320 | } |
325 | #endif | 321 | #endif |
326 | 322 | ||
327 | static const struct dev_pm_ops tps65910_rtc_pm_ops = { | 323 | static SIMPLE_DEV_PM_OPS(tps65910_rtc_pm_ops, tps65910_rtc_suspend, |
328 | SET_SYSTEM_SLEEP_PM_OPS(tps65910_rtc_suspend, tps65910_rtc_resume) | 324 | tps65910_rtc_resume); |
329 | }; | ||
330 | 325 | ||
331 | static struct platform_driver tps65910_rtc_driver = { | 326 | static struct platform_driver tps65910_rtc_driver = { |
332 | .probe = tps65910_rtc_probe, | 327 | .probe = tps65910_rtc_probe, |
diff --git a/drivers/rtc/rtc-tps80031.c b/drivers/rtc/rtc-tps80031.c index 9aaf8aaebae9..72662eafb938 100644 --- a/drivers/rtc/rtc-tps80031.c +++ b/drivers/rtc/rtc-tps80031.c | |||
@@ -277,7 +277,7 @@ static int tps80031_rtc_probe(struct platform_device *pdev) | |||
277 | return ret; | 277 | return ret; |
278 | } | 278 | } |
279 | 279 | ||
280 | rtc->rtc = rtc_device_register(pdev->name, &pdev->dev, | 280 | rtc->rtc = devm_rtc_device_register(&pdev->dev, pdev->name, |
281 | &tps80031_rtc_ops, THIS_MODULE); | 281 | &tps80031_rtc_ops, THIS_MODULE); |
282 | if (IS_ERR(rtc->rtc)) { | 282 | if (IS_ERR(rtc->rtc)) { |
283 | ret = PTR_ERR(rtc->rtc); | 283 | ret = PTR_ERR(rtc->rtc); |
@@ -292,7 +292,6 @@ static int tps80031_rtc_probe(struct platform_device *pdev) | |||
292 | if (ret < 0) { | 292 | if (ret < 0) { |
293 | dev_err(&pdev->dev, "request IRQ:%d failed, err = %d\n", | 293 | dev_err(&pdev->dev, "request IRQ:%d failed, err = %d\n", |
294 | rtc->irq, ret); | 294 | rtc->irq, ret); |
295 | rtc_device_unregister(rtc->rtc); | ||
296 | return ret; | 295 | return ret; |
297 | } | 296 | } |
298 | device_set_wakeup_capable(&pdev->dev, 1); | 297 | device_set_wakeup_capable(&pdev->dev, 1); |
@@ -301,9 +300,6 @@ static int tps80031_rtc_probe(struct platform_device *pdev) | |||
301 | 300 | ||
302 | static int tps80031_rtc_remove(struct platform_device *pdev) | 301 | static int tps80031_rtc_remove(struct platform_device *pdev) |
303 | { | 302 | { |
304 | struct tps80031_rtc *rtc = platform_get_drvdata(pdev); | ||
305 | |||
306 | rtc_device_unregister(rtc->rtc); | ||
307 | return 0; | 303 | return 0; |
308 | } | 304 | } |
309 | 305 | ||
@@ -327,9 +323,8 @@ static int tps80031_rtc_resume(struct device *dev) | |||
327 | }; | 323 | }; |
328 | #endif | 324 | #endif |
329 | 325 | ||
330 | static const struct dev_pm_ops tps80031_pm_ops = { | 326 | static SIMPLE_DEV_PM_OPS(tps80031_pm_ops, tps80031_rtc_suspend, |
331 | SET_SYSTEM_SLEEP_PM_OPS(tps80031_rtc_suspend, tps80031_rtc_resume) | 327 | tps80031_rtc_resume); |
332 | }; | ||
333 | 328 | ||
334 | static struct platform_driver tps80031_rtc_driver = { | 329 | static struct platform_driver tps80031_rtc_driver = { |
335 | .driver = { | 330 | .driver = { |
diff --git a/drivers/rtc/rtc-twl.c b/drivers/rtc/rtc-twl.c index 8bc6c80b184c..8751a5240c99 100644 --- a/drivers/rtc/rtc-twl.c +++ b/drivers/rtc/rtc-twl.c | |||
@@ -566,11 +566,10 @@ static void twl_rtc_shutdown(struct platform_device *pdev) | |||
566 | mask_rtc_irq_bit(BIT_RTC_INTERRUPTS_REG_IT_TIMER_M); | 566 | mask_rtc_irq_bit(BIT_RTC_INTERRUPTS_REG_IT_TIMER_M); |
567 | } | 567 | } |
568 | 568 | ||
569 | #ifdef CONFIG_PM | 569 | #ifdef CONFIG_PM_SLEEP |
570 | |||
571 | static unsigned char irqstat; | 570 | static unsigned char irqstat; |
572 | 571 | ||
573 | static int twl_rtc_suspend(struct platform_device *pdev, pm_message_t state) | 572 | static int twl_rtc_suspend(struct device *dev) |
574 | { | 573 | { |
575 | irqstat = rtc_irq_bits; | 574 | irqstat = rtc_irq_bits; |
576 | 575 | ||
@@ -578,17 +577,15 @@ static int twl_rtc_suspend(struct platform_device *pdev, pm_message_t state) | |||
578 | return 0; | 577 | return 0; |
579 | } | 578 | } |
580 | 579 | ||
581 | static int twl_rtc_resume(struct platform_device *pdev) | 580 | static int twl_rtc_resume(struct device *dev) |
582 | { | 581 | { |
583 | set_rtc_irq_bit(irqstat); | 582 | set_rtc_irq_bit(irqstat); |
584 | return 0; | 583 | return 0; |
585 | } | 584 | } |
586 | |||
587 | #else | ||
588 | #define twl_rtc_suspend NULL | ||
589 | #define twl_rtc_resume NULL | ||
590 | #endif | 585 | #endif |
591 | 586 | ||
587 | static SIMPLE_DEV_PM_OPS(twl_rtc_pm_ops, twl_rtc_suspend, twl_rtc_resume); | ||
588 | |||
592 | #ifdef CONFIG_OF | 589 | #ifdef CONFIG_OF |
593 | static const struct of_device_id twl_rtc_of_match[] = { | 590 | static const struct of_device_id twl_rtc_of_match[] = { |
594 | {.compatible = "ti,twl4030-rtc", }, | 591 | {.compatible = "ti,twl4030-rtc", }, |
@@ -603,11 +600,10 @@ static struct platform_driver twl4030rtc_driver = { | |||
603 | .probe = twl_rtc_probe, | 600 | .probe = twl_rtc_probe, |
604 | .remove = twl_rtc_remove, | 601 | .remove = twl_rtc_remove, |
605 | .shutdown = twl_rtc_shutdown, | 602 | .shutdown = twl_rtc_shutdown, |
606 | .suspend = twl_rtc_suspend, | ||
607 | .resume = twl_rtc_resume, | ||
608 | .driver = { | 603 | .driver = { |
609 | .owner = THIS_MODULE, | 604 | .owner = THIS_MODULE, |
610 | .name = "twl_rtc", | 605 | .name = "twl_rtc", |
606 | .pm = &twl_rtc_pm_ops, | ||
611 | .of_match_table = of_match_ptr(twl_rtc_of_match), | 607 | .of_match_table = of_match_ptr(twl_rtc_of_match), |
612 | }, | 608 | }, |
613 | }; | 609 | }; |
diff --git a/drivers/rtc/rtc-tx4939.c b/drivers/rtc/rtc-tx4939.c index a12bfac49d36..f9a0677e4e3b 100644 --- a/drivers/rtc/rtc-tx4939.c +++ b/drivers/rtc/rtc-tx4939.c | |||
@@ -268,14 +268,13 @@ static int __init tx4939_rtc_probe(struct platform_device *pdev) | |||
268 | if (devm_request_irq(&pdev->dev, irq, tx4939_rtc_interrupt, | 268 | if (devm_request_irq(&pdev->dev, irq, tx4939_rtc_interrupt, |
269 | 0, 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 = devm_rtc_device_register(&pdev->dev, pdev->name, |
272 | &tx4939_rtc_ops, THIS_MODULE); | 272 | &tx4939_rtc_ops, THIS_MODULE); |
273 | if (IS_ERR(rtc)) | 273 | if (IS_ERR(rtc)) |
274 | return PTR_ERR(rtc); | 274 | return PTR_ERR(rtc); |
275 | pdata->rtc = rtc; | 275 | pdata->rtc = rtc; |
276 | ret = sysfs_create_bin_file(&pdev->dev.kobj, &tx4939_rtc_nvram_attr); | 276 | ret = sysfs_create_bin_file(&pdev->dev.kobj, &tx4939_rtc_nvram_attr); |
277 | if (ret) | 277 | |
278 | rtc_device_unregister(rtc); | ||
279 | return ret; | 278 | return ret; |
280 | } | 279 | } |
281 | 280 | ||
@@ -284,7 +283,6 @@ static int __exit tx4939_rtc_remove(struct platform_device *pdev) | |||
284 | struct tx4939rtc_plat_data *pdata = platform_get_drvdata(pdev); | 283 | struct tx4939rtc_plat_data *pdata = platform_get_drvdata(pdev); |
285 | 284 | ||
286 | sysfs_remove_bin_file(&pdev->dev.kobj, &tx4939_rtc_nvram_attr); | 285 | sysfs_remove_bin_file(&pdev->dev.kobj, &tx4939_rtc_nvram_attr); |
287 | rtc_device_unregister(pdata->rtc); | ||
288 | spin_lock_irq(&pdata->lock); | 286 | spin_lock_irq(&pdata->lock); |
289 | tx4939_rtc_cmd(pdata->rtcreg, TX4939_RTCCTL_COMMAND_NOP); | 287 | tx4939_rtc_cmd(pdata->rtcreg, TX4939_RTCCTL_COMMAND_NOP); |
290 | spin_unlock_irq(&pdata->lock); | 288 | spin_unlock_irq(&pdata->lock); |
@@ -299,18 +297,7 @@ static struct platform_driver tx4939_rtc_driver = { | |||
299 | }, | 297 | }, |
300 | }; | 298 | }; |
301 | 299 | ||
302 | static int __init tx4939rtc_init(void) | 300 | module_platform_driver_probe(tx4939_rtc_driver, tx4939_rtc_probe); |
303 | { | ||
304 | return platform_driver_probe(&tx4939_rtc_driver, tx4939_rtc_probe); | ||
305 | } | ||
306 | |||
307 | static void __exit tx4939rtc_exit(void) | ||
308 | { | ||
309 | platform_driver_unregister(&tx4939_rtc_driver); | ||
310 | } | ||
311 | |||
312 | module_init(tx4939rtc_init); | ||
313 | module_exit(tx4939rtc_exit); | ||
314 | 301 | ||
315 | MODULE_AUTHOR("Atsushi Nemoto <anemo@mba.ocn.ne.jp>"); | 302 | MODULE_AUTHOR("Atsushi Nemoto <anemo@mba.ocn.ne.jp>"); |
316 | MODULE_DESCRIPTION("TX4939 internal RTC driver"); | 303 | MODULE_DESCRIPTION("TX4939 internal RTC driver"); |
diff --git a/drivers/rtc/rtc-v3020.c b/drivers/rtc/rtc-v3020.c index bca5d677bc85..6e0cba8f47d5 100644 --- a/drivers/rtc/rtc-v3020.c +++ b/drivers/rtc/rtc-v3020.c | |||
@@ -309,7 +309,7 @@ static int rtc_probe(struct platform_device *pdev) | |||
309 | int i; | 309 | int i; |
310 | int temp; | 310 | int temp; |
311 | 311 | ||
312 | chip = kzalloc(sizeof *chip, GFP_KERNEL); | 312 | chip = devm_kzalloc(&pdev->dev, sizeof(*chip), GFP_KERNEL); |
313 | if (!chip) | 313 | if (!chip) |
314 | return -ENOMEM; | 314 | return -ENOMEM; |
315 | 315 | ||
@@ -353,8 +353,8 @@ static int rtc_probe(struct platform_device *pdev) | |||
353 | 353 | ||
354 | platform_set_drvdata(pdev, chip); | 354 | platform_set_drvdata(pdev, chip); |
355 | 355 | ||
356 | chip->rtc = rtc_device_register("v3020", | 356 | chip->rtc = devm_rtc_device_register(&pdev->dev, "v3020", |
357 | &pdev->dev, &v3020_rtc_ops, THIS_MODULE); | 357 | &v3020_rtc_ops, THIS_MODULE); |
358 | if (IS_ERR(chip->rtc)) { | 358 | if (IS_ERR(chip->rtc)) { |
359 | retval = PTR_ERR(chip->rtc); | 359 | retval = PTR_ERR(chip->rtc); |
360 | goto err_io; | 360 | goto err_io; |
@@ -365,21 +365,14 @@ static int rtc_probe(struct platform_device *pdev) | |||
365 | err_io: | 365 | err_io: |
366 | chip->ops->unmap_io(chip); | 366 | chip->ops->unmap_io(chip); |
367 | err_chip: | 367 | err_chip: |
368 | kfree(chip); | ||
369 | |||
370 | return retval; | 368 | return retval; |
371 | } | 369 | } |
372 | 370 | ||
373 | static int rtc_remove(struct platform_device *dev) | 371 | static int rtc_remove(struct platform_device *dev) |
374 | { | 372 | { |
375 | struct v3020 *chip = platform_get_drvdata(dev); | 373 | struct v3020 *chip = platform_get_drvdata(dev); |
376 | struct rtc_device *rtc = chip->rtc; | ||
377 | |||
378 | if (rtc) | ||
379 | rtc_device_unregister(rtc); | ||
380 | 374 | ||
381 | chip->ops->unmap_io(chip); | 375 | chip->ops->unmap_io(chip); |
382 | kfree(chip); | ||
383 | 376 | ||
384 | return 0; | 377 | return 0; |
385 | } | 378 | } |
diff --git a/drivers/rtc/rtc-vt8500.c b/drivers/rtc/rtc-vt8500.c index a000bc0a8bff..d89efee6d29e 100644 --- a/drivers/rtc/rtc-vt8500.c +++ b/drivers/rtc/rtc-vt8500.c | |||
@@ -252,7 +252,7 @@ static int vt8500_rtc_probe(struct platform_device *pdev) | |||
252 | writel(VT8500_RTC_CR_ENABLE, | 252 | writel(VT8500_RTC_CR_ENABLE, |
253 | vt8500_rtc->regbase + VT8500_RTC_CR); | 253 | vt8500_rtc->regbase + VT8500_RTC_CR); |
254 | 254 | ||
255 | vt8500_rtc->rtc = rtc_device_register("vt8500-rtc", &pdev->dev, | 255 | vt8500_rtc->rtc = devm_rtc_device_register(&pdev->dev, "vt8500-rtc", |
256 | &vt8500_rtc_ops, THIS_MODULE); | 256 | &vt8500_rtc_ops, THIS_MODULE); |
257 | if (IS_ERR(vt8500_rtc->rtc)) { | 257 | if (IS_ERR(vt8500_rtc->rtc)) { |
258 | ret = PTR_ERR(vt8500_rtc->rtc); | 258 | ret = PTR_ERR(vt8500_rtc->rtc); |
@@ -266,13 +266,11 @@ static int vt8500_rtc_probe(struct platform_device *pdev) | |||
266 | if (ret < 0) { | 266 | if (ret < 0) { |
267 | dev_err(&pdev->dev, "can't get irq %i, err %d\n", | 267 | dev_err(&pdev->dev, "can't get irq %i, err %d\n", |
268 | vt8500_rtc->irq_alarm, ret); | 268 | vt8500_rtc->irq_alarm, ret); |
269 | goto err_unreg; | 269 | goto err_return; |
270 | } | 270 | } |
271 | 271 | ||
272 | return 0; | 272 | return 0; |
273 | 273 | ||
274 | err_unreg: | ||
275 | rtc_device_unregister(vt8500_rtc->rtc); | ||
276 | err_return: | 274 | err_return: |
277 | return ret; | 275 | return ret; |
278 | } | 276 | } |
@@ -281,8 +279,6 @@ static int vt8500_rtc_remove(struct platform_device *pdev) | |||
281 | { | 279 | { |
282 | struct vt8500_rtc *vt8500_rtc = platform_get_drvdata(pdev); | 280 | struct vt8500_rtc *vt8500_rtc = platform_get_drvdata(pdev); |
283 | 281 | ||
284 | rtc_device_unregister(vt8500_rtc->rtc); | ||
285 | |||
286 | /* Disable alarm matching */ | 282 | /* Disable alarm matching */ |
287 | writel(0, vt8500_rtc->regbase + VT8500_RTC_IS); | 283 | writel(0, vt8500_rtc->regbase + VT8500_RTC_IS); |
288 | 284 | ||
diff --git a/drivers/rtc/rtc-wm831x.c b/drivers/rtc/rtc-wm831x.c index 2f0ac7b30a0c..8d65b94e5a7e 100644 --- a/drivers/rtc/rtc-wm831x.c +++ b/drivers/rtc/rtc-wm831x.c | |||
@@ -436,7 +436,7 @@ static int wm831x_rtc_probe(struct platform_device *pdev) | |||
436 | 436 | ||
437 | device_init_wakeup(&pdev->dev, 1); | 437 | device_init_wakeup(&pdev->dev, 1); |
438 | 438 | ||
439 | wm831x_rtc->rtc = rtc_device_register("wm831x", &pdev->dev, | 439 | wm831x_rtc->rtc = devm_rtc_device_register(&pdev->dev, "wm831x", |
440 | &wm831x_rtc_ops, THIS_MODULE); | 440 | &wm831x_rtc_ops, THIS_MODULE); |
441 | if (IS_ERR(wm831x_rtc->rtc)) { | 441 | if (IS_ERR(wm831x_rtc->rtc)) { |
442 | ret = PTR_ERR(wm831x_rtc->rtc); | 442 | ret = PTR_ERR(wm831x_rtc->rtc); |
@@ -462,10 +462,6 @@ err: | |||
462 | 462 | ||
463 | static int wm831x_rtc_remove(struct platform_device *pdev) | 463 | static int wm831x_rtc_remove(struct platform_device *pdev) |
464 | { | 464 | { |
465 | struct wm831x_rtc *wm831x_rtc = platform_get_drvdata(pdev); | ||
466 | |||
467 | rtc_device_unregister(wm831x_rtc->rtc); | ||
468 | |||
469 | return 0; | 465 | return 0; |
470 | } | 466 | } |
471 | 467 | ||
diff --git a/drivers/rtc/rtc-wm8350.c b/drivers/rtc/rtc-wm8350.c index 8ad86ae0d30f..fa247deb9cf4 100644 --- a/drivers/rtc/rtc-wm8350.c +++ b/drivers/rtc/rtc-wm8350.c | |||
@@ -339,7 +339,7 @@ static const struct rtc_class_ops wm8350_rtc_ops = { | |||
339 | .alarm_irq_enable = wm8350_rtc_alarm_irq_enable, | 339 | .alarm_irq_enable = wm8350_rtc_alarm_irq_enable, |
340 | }; | 340 | }; |
341 | 341 | ||
342 | #ifdef CONFIG_PM | 342 | #ifdef CONFIG_PM_SLEEP |
343 | static int wm8350_rtc_suspend(struct device *dev) | 343 | static int wm8350_rtc_suspend(struct device *dev) |
344 | { | 344 | { |
345 | struct platform_device *pdev = to_platform_device(dev); | 345 | struct platform_device *pdev = to_platform_device(dev); |
@@ -375,10 +375,6 @@ static int wm8350_rtc_resume(struct device *dev) | |||
375 | 375 | ||
376 | return 0; | 376 | return 0; |
377 | } | 377 | } |
378 | |||
379 | #else | ||
380 | #define wm8350_rtc_suspend NULL | ||
381 | #define wm8350_rtc_resume NULL | ||
382 | #endif | 378 | #endif |
383 | 379 | ||
384 | static int wm8350_rtc_probe(struct platform_device *pdev) | 380 | static int wm8350_rtc_probe(struct platform_device *pdev) |
@@ -439,8 +435,8 @@ static int wm8350_rtc_probe(struct platform_device *pdev) | |||
439 | 435 | ||
440 | device_init_wakeup(&pdev->dev, 1); | 436 | device_init_wakeup(&pdev->dev, 1); |
441 | 437 | ||
442 | wm_rtc->rtc = rtc_device_register("wm8350", &pdev->dev, | 438 | wm_rtc->rtc = devm_rtc_device_register(&pdev->dev, "wm8350", |
443 | &wm8350_rtc_ops, THIS_MODULE); | 439 | &wm8350_rtc_ops, THIS_MODULE); |
444 | if (IS_ERR(wm_rtc->rtc)) { | 440 | if (IS_ERR(wm_rtc->rtc)) { |
445 | ret = PTR_ERR(wm_rtc->rtc); | 441 | ret = PTR_ERR(wm_rtc->rtc); |
446 | dev_err(&pdev->dev, "failed to register RTC: %d\n", ret); | 442 | dev_err(&pdev->dev, "failed to register RTC: %d\n", ret); |
@@ -462,20 +458,15 @@ static int wm8350_rtc_probe(struct platform_device *pdev) | |||
462 | static int wm8350_rtc_remove(struct platform_device *pdev) | 458 | static int wm8350_rtc_remove(struct platform_device *pdev) |
463 | { | 459 | { |
464 | struct wm8350 *wm8350 = platform_get_drvdata(pdev); | 460 | struct wm8350 *wm8350 = platform_get_drvdata(pdev); |
465 | struct wm8350_rtc *wm_rtc = &wm8350->rtc; | ||
466 | 461 | ||
467 | wm8350_free_irq(wm8350, WM8350_IRQ_RTC_SEC, wm8350); | 462 | wm8350_free_irq(wm8350, WM8350_IRQ_RTC_SEC, wm8350); |
468 | wm8350_free_irq(wm8350, WM8350_IRQ_RTC_ALM, wm8350); | 463 | wm8350_free_irq(wm8350, WM8350_IRQ_RTC_ALM, wm8350); |
469 | 464 | ||
470 | rtc_device_unregister(wm_rtc->rtc); | ||
471 | |||
472 | return 0; | 465 | return 0; |
473 | } | 466 | } |
474 | 467 | ||
475 | static struct dev_pm_ops wm8350_rtc_pm_ops = { | 468 | static SIMPLE_DEV_PM_OPS(wm8350_rtc_pm_ops, wm8350_rtc_suspend, |
476 | .suspend = wm8350_rtc_suspend, | 469 | wm8350_rtc_resume); |
477 | .resume = wm8350_rtc_resume, | ||
478 | }; | ||
479 | 470 | ||
480 | static struct platform_driver wm8350_rtc_driver = { | 471 | static struct platform_driver wm8350_rtc_driver = { |
481 | .probe = wm8350_rtc_probe, | 472 | .probe = wm8350_rtc_probe, |
diff --git a/drivers/rtc/rtc-x1205.c b/drivers/rtc/rtc-x1205.c index f36e59c6bc01..fa9b0679fb60 100644 --- a/drivers/rtc/rtc-x1205.c +++ b/drivers/rtc/rtc-x1205.c | |||
@@ -630,8 +630,8 @@ static int x1205_probe(struct i2c_client *client, | |||
630 | 630 | ||
631 | dev_info(&client->dev, "chip found, driver version " DRV_VERSION "\n"); | 631 | dev_info(&client->dev, "chip found, driver version " DRV_VERSION "\n"); |
632 | 632 | ||
633 | rtc = rtc_device_register(x1205_driver.driver.name, &client->dev, | 633 | rtc = devm_rtc_device_register(&client->dev, x1205_driver.driver.name, |
634 | &x1205_rtc_ops, THIS_MODULE); | 634 | &x1205_rtc_ops, THIS_MODULE); |
635 | 635 | ||
636 | if (IS_ERR(rtc)) | 636 | if (IS_ERR(rtc)) |
637 | return PTR_ERR(rtc); | 637 | return PTR_ERR(rtc); |
@@ -653,21 +653,13 @@ static int x1205_probe(struct i2c_client *client, | |||
653 | 653 | ||
654 | err = x1205_sysfs_register(&client->dev); | 654 | err = x1205_sysfs_register(&client->dev); |
655 | if (err) | 655 | if (err) |
656 | goto exit_devreg; | 656 | return err; |
657 | 657 | ||
658 | return 0; | 658 | return 0; |
659 | |||
660 | exit_devreg: | ||
661 | rtc_device_unregister(rtc); | ||
662 | |||
663 | return err; | ||
664 | } | 659 | } |
665 | 660 | ||
666 | static int x1205_remove(struct i2c_client *client) | 661 | static int x1205_remove(struct i2c_client *client) |
667 | { | 662 | { |
668 | struct rtc_device *rtc = i2c_get_clientdata(client); | ||
669 | |||
670 | rtc_device_unregister(rtc); | ||
671 | x1205_sysfs_unregister(&client->dev); | 663 | x1205_sysfs_unregister(&client->dev); |
672 | return 0; | 664 | return 0; |
673 | } | 665 | } |
diff --git a/drivers/scsi/fcoe/fcoe_ctlr.c b/drivers/scsi/fcoe/fcoe_ctlr.c index a76247201be5..cd743c545ce9 100644 --- a/drivers/scsi/fcoe/fcoe_ctlr.c +++ b/drivers/scsi/fcoe/fcoe_ctlr.c | |||
@@ -2161,7 +2161,7 @@ static void fcoe_ctlr_vn_restart(struct fcoe_ctlr *fip) | |||
2161 | 2161 | ||
2162 | if (fip->probe_tries < FIP_VN_RLIM_COUNT) { | 2162 | if (fip->probe_tries < FIP_VN_RLIM_COUNT) { |
2163 | fip->probe_tries++; | 2163 | fip->probe_tries++; |
2164 | wait = random32() % FIP_VN_PROBE_WAIT; | 2164 | wait = prandom_u32() % FIP_VN_PROBE_WAIT; |
2165 | } else | 2165 | } else |
2166 | wait = FIP_VN_RLIM_INT; | 2166 | wait = FIP_VN_RLIM_INT; |
2167 | mod_timer(&fip->timer, jiffies + msecs_to_jiffies(wait)); | 2167 | mod_timer(&fip->timer, jiffies + msecs_to_jiffies(wait)); |
@@ -2794,7 +2794,7 @@ static void fcoe_ctlr_vn_timeout(struct fcoe_ctlr *fip) | |||
2794 | fcoe_all_vn2vn, 0); | 2794 | fcoe_all_vn2vn, 0); |
2795 | fip->port_ka_time = jiffies + | 2795 | fip->port_ka_time = jiffies + |
2796 | msecs_to_jiffies(FIP_VN_BEACON_INT + | 2796 | msecs_to_jiffies(FIP_VN_BEACON_INT + |
2797 | (random32() % FIP_VN_BEACON_FUZZ)); | 2797 | (prandom_u32() % FIP_VN_BEACON_FUZZ)); |
2798 | } | 2798 | } |
2799 | if (time_before(fip->port_ka_time, next_time)) | 2799 | if (time_before(fip->port_ka_time, next_time)) |
2800 | next_time = fip->port_ka_time; | 2800 | next_time = fip->port_ka_time; |
diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c index d7096ad94d3f..bfda18467ee6 100644 --- a/drivers/scsi/lpfc/lpfc_hbadisc.c +++ b/drivers/scsi/lpfc/lpfc_hbadisc.c | |||
@@ -1732,7 +1732,7 @@ lpfc_check_pending_fcoe_event(struct lpfc_hba *phba, uint8_t unreg_fcf) | |||
1732 | * use through a sequence of @fcf_cnt eligible FCF records with equal | 1732 | * use through a sequence of @fcf_cnt eligible FCF records with equal |
1733 | * probability. To perform integer manunipulation of random numbers with | 1733 | * probability. To perform integer manunipulation of random numbers with |
1734 | * size unit32_t, the lower 16 bits of the 32-bit random number returned | 1734 | * size unit32_t, the lower 16 bits of the 32-bit random number returned |
1735 | * from random32() are taken as the random random number generated. | 1735 | * from prandom_u32() are taken as the random random number generated. |
1736 | * | 1736 | * |
1737 | * Returns true when outcome is for the newly read FCF record should be | 1737 | * Returns true when outcome is for the newly read FCF record should be |
1738 | * chosen; otherwise, return false when outcome is for keeping the previously | 1738 | * chosen; otherwise, return false when outcome is for keeping the previously |
@@ -1744,7 +1744,7 @@ lpfc_sli4_new_fcf_random_select(struct lpfc_hba *phba, uint32_t fcf_cnt) | |||
1744 | uint32_t rand_num; | 1744 | uint32_t rand_num; |
1745 | 1745 | ||
1746 | /* Get 16-bit uniform random number */ | 1746 | /* Get 16-bit uniform random number */ |
1747 | rand_num = (0xFFFF & random32()); | 1747 | rand_num = 0xFFFF & prandom_u32(); |
1748 | 1748 | ||
1749 | /* Decision with probability 1/fcf_cnt */ | 1749 | /* Decision with probability 1/fcf_cnt */ |
1750 | if ((fcf_cnt * rand_num) < 0xFFFF) | 1750 | if ((fcf_cnt * rand_num) < 0xFFFF) |
@@ -2380,7 +2380,7 @@ lpfc_mbx_cmpl_fcf_scan_read_fcf_rec(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) | |||
2380 | phba->fcf.eligible_fcf_cnt = 1; | 2380 | phba->fcf.eligible_fcf_cnt = 1; |
2381 | /* Seeding the random number generator for random selection */ | 2381 | /* Seeding the random number generator for random selection */ |
2382 | seed = (uint32_t)(0xFFFFFFFF & jiffies); | 2382 | seed = (uint32_t)(0xFFFFFFFF & jiffies); |
2383 | srandom32(seed); | 2383 | prandom_seed(seed); |
2384 | } | 2384 | } |
2385 | spin_unlock_irq(&phba->hbalock); | 2385 | spin_unlock_irq(&phba->hbalock); |
2386 | goto read_next_fcf; | 2386 | goto read_next_fcf; |
diff --git a/drivers/uwb/rsv.c b/drivers/uwb/rsv.c index 0b0d8bce842e..f4ae05f78c42 100644 --- a/drivers/uwb/rsv.c +++ b/drivers/uwb/rsv.c | |||
@@ -231,7 +231,7 @@ void uwb_rsv_backoff_win_increment(struct uwb_rc *rc) | |||
231 | return; | 231 | return; |
232 | 232 | ||
233 | bow->window <<= 1; | 233 | bow->window <<= 1; |
234 | bow->n = random32() & (bow->window - 1); | 234 | bow->n = prandom_u32() & (bow->window - 1); |
235 | dev_dbg(dev, "new_window=%d, n=%d\n: ", bow->window, bow->n); | 235 | dev_dbg(dev, "new_window=%d, n=%d\n: ", bow->window, bow->n); |
236 | 236 | ||
237 | /* reset the timer associated variables */ | 237 | /* reset the timer associated variables */ |
@@ -557,7 +557,7 @@ int uwb_rsv_establish(struct uwb_rsv *rsv) | |||
557 | if (ret) | 557 | if (ret) |
558 | goto out; | 558 | goto out; |
559 | 559 | ||
560 | rsv->tiebreaker = random32() & 1; | 560 | rsv->tiebreaker = prandom_u32() & 1; |
561 | /* get available mas bitmap */ | 561 | /* get available mas bitmap */ |
562 | uwb_drp_available(rc, &available); | 562 | uwb_drp_available(rc, &available); |
563 | 563 | ||
diff --git a/drivers/video/backlight/Kconfig b/drivers/video/backlight/Kconfig index db10d0120d2b..2e166c3fc4c3 100644 --- a/drivers/video/backlight/Kconfig +++ b/drivers/video/backlight/Kconfig | |||
@@ -59,6 +59,13 @@ config LCD_LTV350QV | |||
59 | 59 | ||
60 | The LTV350QV panel is present on all ATSTK1000 boards. | 60 | The LTV350QV panel is present on all ATSTK1000 boards. |
61 | 61 | ||
62 | config LCD_ILI922X | ||
63 | tristate "ILI Technology ILI9221/ILI9222 support" | ||
64 | depends on SPI | ||
65 | help | ||
66 | If you have a panel based on the ILI9221/9222 controller | ||
67 | chip then say y to include a driver for it. | ||
68 | |||
62 | config LCD_ILI9320 | 69 | config LCD_ILI9320 |
63 | tristate "ILI Technology ILI9320 controller support" | 70 | tristate "ILI Technology ILI9320 controller support" |
64 | depends on SPI | 71 | depends on SPI |
@@ -161,7 +168,7 @@ if BACKLIGHT_CLASS_DEVICE | |||
161 | config BACKLIGHT_ATMEL_LCDC | 168 | config BACKLIGHT_ATMEL_LCDC |
162 | bool "Atmel LCDC Contrast-as-Backlight control" | 169 | bool "Atmel LCDC Contrast-as-Backlight control" |
163 | depends on FB_ATMEL | 170 | depends on FB_ATMEL |
164 | default y if MACH_SAM9261EK || MACH_SAM9G10EK || MACH_SAM9263EK | 171 | default y if MACH_AT91SAM9261EK || MACH_AT91SAM9G10EK || MACH_AT91SAM9263EK |
165 | help | 172 | help |
166 | This provides a backlight control internal to the Atmel LCDC | 173 | This provides a backlight control internal to the Atmel LCDC |
167 | driver. If the LCD "contrast control" on your board is wired | 174 | driver. If the LCD "contrast control" on your board is wired |
diff --git a/drivers/video/backlight/Makefile b/drivers/video/backlight/Makefile index 96c4d620c5ce..92711fe60464 100644 --- a/drivers/video/backlight/Makefile +++ b/drivers/video/backlight/Makefile | |||
@@ -5,6 +5,7 @@ obj-$(CONFIG_LCD_CLASS_DEVICE) += lcd.o | |||
5 | obj-$(CONFIG_LCD_CORGI) += corgi_lcd.o | 5 | obj-$(CONFIG_LCD_CORGI) += corgi_lcd.o |
6 | obj-$(CONFIG_LCD_HP700) += jornada720_lcd.o | 6 | obj-$(CONFIG_LCD_HP700) += jornada720_lcd.o |
7 | obj-$(CONFIG_LCD_HX8357) += hx8357.o | 7 | obj-$(CONFIG_LCD_HX8357) += hx8357.o |
8 | obj-$(CONFIG_LCD_ILI922X) += ili922x.o | ||
8 | obj-$(CONFIG_LCD_ILI9320) += ili9320.o | 9 | obj-$(CONFIG_LCD_ILI9320) += ili9320.o |
9 | obj-$(CONFIG_LCD_L4F00242T03) += l4f00242t03.o | 10 | obj-$(CONFIG_LCD_L4F00242T03) += l4f00242t03.o |
10 | obj-$(CONFIG_LCD_LD9040) += ld9040.o | 11 | obj-$(CONFIG_LCD_LD9040) += ld9040.o |
diff --git a/drivers/video/backlight/adp5520_bl.c b/drivers/video/backlight/adp5520_bl.c index a1e41d4faa71..c84701b7ca6e 100644 --- a/drivers/video/backlight/adp5520_bl.c +++ b/drivers/video/backlight/adp5520_bl.c | |||
@@ -143,13 +143,16 @@ static int adp5520_bl_setup(struct backlight_device *bl) | |||
143 | static ssize_t adp5520_show(struct device *dev, char *buf, int reg) | 143 | static ssize_t adp5520_show(struct device *dev, char *buf, int reg) |
144 | { | 144 | { |
145 | struct adp5520_bl *data = dev_get_drvdata(dev); | 145 | struct adp5520_bl *data = dev_get_drvdata(dev); |
146 | int error; | 146 | int ret; |
147 | uint8_t reg_val; | 147 | uint8_t reg_val; |
148 | 148 | ||
149 | mutex_lock(&data->lock); | 149 | mutex_lock(&data->lock); |
150 | error = adp5520_read(data->master, reg, ®_val); | 150 | ret = adp5520_read(data->master, reg, ®_val); |
151 | mutex_unlock(&data->lock); | 151 | mutex_unlock(&data->lock); |
152 | 152 | ||
153 | if (ret < 0) | ||
154 | return ret; | ||
155 | |||
153 | return sprintf(buf, "%u\n", reg_val); | 156 | return sprintf(buf, "%u\n", reg_val); |
154 | } | 157 | } |
155 | 158 | ||
@@ -349,35 +352,34 @@ static int adp5520_bl_remove(struct platform_device *pdev) | |||
349 | return 0; | 352 | return 0; |
350 | } | 353 | } |
351 | 354 | ||
352 | #ifdef CONFIG_PM | 355 | #ifdef CONFIG_PM_SLEEP |
353 | static int adp5520_bl_suspend(struct platform_device *pdev, | 356 | static int adp5520_bl_suspend(struct device *dev) |
354 | pm_message_t state) | ||
355 | { | 357 | { |
356 | struct backlight_device *bl = platform_get_drvdata(pdev); | 358 | struct backlight_device *bl = dev_get_drvdata(dev); |
359 | |||
357 | return adp5520_bl_set(bl, 0); | 360 | return adp5520_bl_set(bl, 0); |
358 | } | 361 | } |
359 | 362 | ||
360 | static int adp5520_bl_resume(struct platform_device *pdev) | 363 | static int adp5520_bl_resume(struct device *dev) |
361 | { | 364 | { |
362 | struct backlight_device *bl = platform_get_drvdata(pdev); | 365 | struct backlight_device *bl = dev_get_drvdata(dev); |
363 | 366 | ||
364 | backlight_update_status(bl); | 367 | backlight_update_status(bl); |
365 | return 0; | 368 | return 0; |
366 | } | 369 | } |
367 | #else | ||
368 | #define adp5520_bl_suspend NULL | ||
369 | #define adp5520_bl_resume NULL | ||
370 | #endif | 370 | #endif |
371 | 371 | ||
372 | static SIMPLE_DEV_PM_OPS(adp5520_bl_pm_ops, adp5520_bl_suspend, | ||
373 | adp5520_bl_resume); | ||
374 | |||
372 | static struct platform_driver adp5520_bl_driver = { | 375 | static struct platform_driver adp5520_bl_driver = { |
373 | .driver = { | 376 | .driver = { |
374 | .name = "adp5520-backlight", | 377 | .name = "adp5520-backlight", |
375 | .owner = THIS_MODULE, | 378 | .owner = THIS_MODULE, |
379 | .pm = &adp5520_bl_pm_ops, | ||
376 | }, | 380 | }, |
377 | .probe = adp5520_bl_probe, | 381 | .probe = adp5520_bl_probe, |
378 | .remove = adp5520_bl_remove, | 382 | .remove = adp5520_bl_remove, |
379 | .suspend = adp5520_bl_suspend, | ||
380 | .resume = adp5520_bl_resume, | ||
381 | }; | 383 | }; |
382 | 384 | ||
383 | module_platform_driver(adp5520_bl_driver); | 385 | module_platform_driver(adp5520_bl_driver); |
diff --git a/drivers/video/backlight/adp8860_bl.c b/drivers/video/backlight/adp8860_bl.c index a77c9cad3320..75b10f876127 100644 --- a/drivers/video/backlight/adp8860_bl.c +++ b/drivers/video/backlight/adp8860_bl.c | |||
@@ -249,12 +249,14 @@ static int adp8860_led_probe(struct i2c_client *client) | |||
249 | if (led_dat->id > 7 || led_dat->id < 1) { | 249 | if (led_dat->id > 7 || led_dat->id < 1) { |
250 | dev_err(&client->dev, "Invalid LED ID %d\n", | 250 | dev_err(&client->dev, "Invalid LED ID %d\n", |
251 | led_dat->id); | 251 | led_dat->id); |
252 | ret = -EINVAL; | ||
252 | goto err; | 253 | goto err; |
253 | } | 254 | } |
254 | 255 | ||
255 | if (pdata->bl_led_assign & (1 << (led_dat->id - 1))) { | 256 | if (pdata->bl_led_assign & (1 << (led_dat->id - 1))) { |
256 | dev_err(&client->dev, "LED %d used by Backlight\n", | 257 | dev_err(&client->dev, "LED %d used by Backlight\n", |
257 | led_dat->id); | 258 | led_dat->id); |
259 | ret = -EBUSY; | ||
258 | goto err; | 260 | goto err; |
259 | } | 261 | } |
260 | 262 | ||
@@ -773,25 +775,29 @@ static int adp8860_remove(struct i2c_client *client) | |||
773 | return 0; | 775 | return 0; |
774 | } | 776 | } |
775 | 777 | ||
776 | #ifdef CONFIG_PM | 778 | #ifdef CONFIG_PM_SLEEP |
777 | static int adp8860_i2c_suspend(struct i2c_client *client, pm_message_t message) | 779 | static int adp8860_i2c_suspend(struct device *dev) |
778 | { | 780 | { |
781 | struct i2c_client *client = to_i2c_client(dev); | ||
782 | |||
779 | adp8860_clr_bits(client, ADP8860_MDCR, NSTBY); | 783 | adp8860_clr_bits(client, ADP8860_MDCR, NSTBY); |
780 | 784 | ||
781 | return 0; | 785 | return 0; |
782 | } | 786 | } |
783 | 787 | ||
784 | static int adp8860_i2c_resume(struct i2c_client *client) | 788 | static int adp8860_i2c_resume(struct device *dev) |
785 | { | 789 | { |
790 | struct i2c_client *client = to_i2c_client(dev); | ||
791 | |||
786 | adp8860_set_bits(client, ADP8860_MDCR, NSTBY | BLEN); | 792 | adp8860_set_bits(client, ADP8860_MDCR, NSTBY | BLEN); |
787 | 793 | ||
788 | return 0; | 794 | return 0; |
789 | } | 795 | } |
790 | #else | ||
791 | #define adp8860_i2c_suspend NULL | ||
792 | #define adp8860_i2c_resume NULL | ||
793 | #endif | 796 | #endif |
794 | 797 | ||
798 | static SIMPLE_DEV_PM_OPS(adp8860_i2c_pm_ops, adp8860_i2c_suspend, | ||
799 | adp8860_i2c_resume); | ||
800 | |||
795 | static const struct i2c_device_id adp8860_id[] = { | 801 | static const struct i2c_device_id adp8860_id[] = { |
796 | { "adp8860", adp8860 }, | 802 | { "adp8860", adp8860 }, |
797 | { "adp8861", adp8861 }, | 803 | { "adp8861", adp8861 }, |
@@ -802,12 +808,11 @@ MODULE_DEVICE_TABLE(i2c, adp8860_id); | |||
802 | 808 | ||
803 | static struct i2c_driver adp8860_driver = { | 809 | static struct i2c_driver adp8860_driver = { |
804 | .driver = { | 810 | .driver = { |
805 | .name = KBUILD_MODNAME, | 811 | .name = KBUILD_MODNAME, |
812 | .pm = &adp8860_i2c_pm_ops, | ||
806 | }, | 813 | }, |
807 | .probe = adp8860_probe, | 814 | .probe = adp8860_probe, |
808 | .remove = adp8860_remove, | 815 | .remove = adp8860_remove, |
809 | .suspend = adp8860_i2c_suspend, | ||
810 | .resume = adp8860_i2c_resume, | ||
811 | .id_table = adp8860_id, | 816 | .id_table = adp8860_id, |
812 | }; | 817 | }; |
813 | 818 | ||
diff --git a/drivers/video/backlight/adp8870_bl.c b/drivers/video/backlight/adp8870_bl.c index 712c25a0d8fe..90049d7b5c60 100644 --- a/drivers/video/backlight/adp8870_bl.c +++ b/drivers/video/backlight/adp8870_bl.c | |||
@@ -274,12 +274,14 @@ static int adp8870_led_probe(struct i2c_client *client) | |||
274 | if (led_dat->id > 7 || led_dat->id < 1) { | 274 | if (led_dat->id > 7 || led_dat->id < 1) { |
275 | dev_err(&client->dev, "Invalid LED ID %d\n", | 275 | dev_err(&client->dev, "Invalid LED ID %d\n", |
276 | led_dat->id); | 276 | led_dat->id); |
277 | ret = -EINVAL; | ||
277 | goto err; | 278 | goto err; |
278 | } | 279 | } |
279 | 280 | ||
280 | if (pdata->bl_led_assign & (1 << (led_dat->id - 1))) { | 281 | if (pdata->bl_led_assign & (1 << (led_dat->id - 1))) { |
281 | dev_err(&client->dev, "LED %d used by Backlight\n", | 282 | dev_err(&client->dev, "LED %d used by Backlight\n", |
282 | led_dat->id); | 283 | led_dat->id); |
284 | ret = -EBUSY; | ||
283 | goto err; | 285 | goto err; |
284 | } | 286 | } |
285 | 287 | ||
@@ -895,13 +897,13 @@ static int adp8870_probe(struct i2c_client *client, | |||
895 | 897 | ||
896 | data->bl = bl; | 898 | data->bl = bl; |
897 | 899 | ||
898 | if (pdata->en_ambl_sens) | 900 | if (pdata->en_ambl_sens) { |
899 | ret = sysfs_create_group(&bl->dev.kobj, | 901 | ret = sysfs_create_group(&bl->dev.kobj, |
900 | &adp8870_bl_attr_group); | 902 | &adp8870_bl_attr_group); |
901 | 903 | if (ret) { | |
902 | if (ret) { | 904 | dev_err(&client->dev, "failed to register sysfs\n"); |
903 | dev_err(&client->dev, "failed to register sysfs\n"); | 905 | goto out1; |
904 | goto out1; | 906 | } |
905 | } | 907 | } |
906 | 908 | ||
907 | ret = adp8870_bl_setup(bl); | 909 | ret = adp8870_bl_setup(bl); |
@@ -947,25 +949,29 @@ static int adp8870_remove(struct i2c_client *client) | |||
947 | return 0; | 949 | return 0; |
948 | } | 950 | } |
949 | 951 | ||
950 | #ifdef CONFIG_PM | 952 | #ifdef CONFIG_PM_SLEEP |
951 | static int adp8870_i2c_suspend(struct i2c_client *client, pm_message_t message) | 953 | static int adp8870_i2c_suspend(struct device *dev) |
952 | { | 954 | { |
955 | struct i2c_client *client = to_i2c_client(dev); | ||
956 | |||
953 | adp8870_clr_bits(client, ADP8870_MDCR, NSTBY); | 957 | adp8870_clr_bits(client, ADP8870_MDCR, NSTBY); |
954 | 958 | ||
955 | return 0; | 959 | return 0; |
956 | } | 960 | } |
957 | 961 | ||
958 | static int adp8870_i2c_resume(struct i2c_client *client) | 962 | static int adp8870_i2c_resume(struct device *dev) |
959 | { | 963 | { |
964 | struct i2c_client *client = to_i2c_client(dev); | ||
965 | |||
960 | adp8870_set_bits(client, ADP8870_MDCR, NSTBY | BLEN); | 966 | adp8870_set_bits(client, ADP8870_MDCR, NSTBY | BLEN); |
961 | 967 | ||
962 | return 0; | 968 | return 0; |
963 | } | 969 | } |
964 | #else | ||
965 | #define adp8870_i2c_suspend NULL | ||
966 | #define adp8870_i2c_resume NULL | ||
967 | #endif | 970 | #endif |
968 | 971 | ||
972 | static SIMPLE_DEV_PM_OPS(adp8870_i2c_pm_ops, adp8870_i2c_suspend, | ||
973 | adp8870_i2c_resume); | ||
974 | |||
969 | static const struct i2c_device_id adp8870_id[] = { | 975 | static const struct i2c_device_id adp8870_id[] = { |
970 | { "adp8870", 0 }, | 976 | { "adp8870", 0 }, |
971 | { } | 977 | { } |
@@ -974,12 +980,11 @@ MODULE_DEVICE_TABLE(i2c, adp8870_id); | |||
974 | 980 | ||
975 | static struct i2c_driver adp8870_driver = { | 981 | static struct i2c_driver adp8870_driver = { |
976 | .driver = { | 982 | .driver = { |
977 | .name = KBUILD_MODNAME, | 983 | .name = KBUILD_MODNAME, |
984 | .pm = &adp8870_i2c_pm_ops, | ||
978 | }, | 985 | }, |
979 | .probe = adp8870_probe, | 986 | .probe = adp8870_probe, |
980 | .remove = adp8870_remove, | 987 | .remove = adp8870_remove, |
981 | .suspend = adp8870_i2c_suspend, | ||
982 | .resume = adp8870_i2c_resume, | ||
983 | .id_table = adp8870_id, | 988 | .id_table = adp8870_id, |
984 | }; | 989 | }; |
985 | 990 | ||
diff --git a/drivers/video/backlight/ams369fg06.c b/drivers/video/backlight/ams369fg06.c index c02aa2c2575a..319fef6cb422 100644 --- a/drivers/video/backlight/ams369fg06.c +++ b/drivers/video/backlight/ams369fg06.c | |||
@@ -533,12 +533,12 @@ static int ams369fg06_remove(struct spi_device *spi) | |||
533 | return 0; | 533 | return 0; |
534 | } | 534 | } |
535 | 535 | ||
536 | #if defined(CONFIG_PM) | 536 | #ifdef CONFIG_PM_SLEEP |
537 | static int ams369fg06_suspend(struct spi_device *spi, pm_message_t mesg) | 537 | static int ams369fg06_suspend(struct device *dev) |
538 | { | 538 | { |
539 | struct ams369fg06 *lcd = spi_get_drvdata(spi); | 539 | struct ams369fg06 *lcd = dev_get_drvdata(dev); |
540 | 540 | ||
541 | dev_dbg(&spi->dev, "lcd->power = %d\n", lcd->power); | 541 | dev_dbg(dev, "lcd->power = %d\n", lcd->power); |
542 | 542 | ||
543 | /* | 543 | /* |
544 | * when lcd panel is suspend, lcd panel becomes off | 544 | * when lcd panel is suspend, lcd panel becomes off |
@@ -547,19 +547,19 @@ static int ams369fg06_suspend(struct spi_device *spi, pm_message_t mesg) | |||
547 | return ams369fg06_power(lcd, FB_BLANK_POWERDOWN); | 547 | return ams369fg06_power(lcd, FB_BLANK_POWERDOWN); |
548 | } | 548 | } |
549 | 549 | ||
550 | static int ams369fg06_resume(struct spi_device *spi) | 550 | static int ams369fg06_resume(struct device *dev) |
551 | { | 551 | { |
552 | struct ams369fg06 *lcd = spi_get_drvdata(spi); | 552 | struct ams369fg06 *lcd = dev_get_drvdata(dev); |
553 | 553 | ||
554 | lcd->power = FB_BLANK_POWERDOWN; | 554 | lcd->power = FB_BLANK_POWERDOWN; |
555 | 555 | ||
556 | return ams369fg06_power(lcd, FB_BLANK_UNBLANK); | 556 | return ams369fg06_power(lcd, FB_BLANK_UNBLANK); |
557 | } | 557 | } |
558 | #else | ||
559 | #define ams369fg06_suspend NULL | ||
560 | #define ams369fg06_resume NULL | ||
561 | #endif | 558 | #endif |
562 | 559 | ||
560 | static SIMPLE_DEV_PM_OPS(ams369fg06_pm_ops, ams369fg06_suspend, | ||
561 | ams369fg06_resume); | ||
562 | |||
563 | static void ams369fg06_shutdown(struct spi_device *spi) | 563 | static void ams369fg06_shutdown(struct spi_device *spi) |
564 | { | 564 | { |
565 | struct ams369fg06 *lcd = spi_get_drvdata(spi); | 565 | struct ams369fg06 *lcd = spi_get_drvdata(spi); |
@@ -571,12 +571,11 @@ static struct spi_driver ams369fg06_driver = { | |||
571 | .driver = { | 571 | .driver = { |
572 | .name = "ams369fg06", | 572 | .name = "ams369fg06", |
573 | .owner = THIS_MODULE, | 573 | .owner = THIS_MODULE, |
574 | .pm = &ams369fg06_pm_ops, | ||
574 | }, | 575 | }, |
575 | .probe = ams369fg06_probe, | 576 | .probe = ams369fg06_probe, |
576 | .remove = ams369fg06_remove, | 577 | .remove = ams369fg06_remove, |
577 | .shutdown = ams369fg06_shutdown, | 578 | .shutdown = ams369fg06_shutdown, |
578 | .suspend = ams369fg06_suspend, | ||
579 | .resume = ams369fg06_resume, | ||
580 | }; | 579 | }; |
581 | 580 | ||
582 | module_spi_driver(ams369fg06_driver); | 581 | module_spi_driver(ams369fg06_driver); |
diff --git a/drivers/video/backlight/as3711_bl.c b/drivers/video/backlight/as3711_bl.c index 41d52fe52543..123887cd76bd 100644 --- a/drivers/video/backlight/as3711_bl.c +++ b/drivers/video/backlight/as3711_bl.c | |||
@@ -258,6 +258,109 @@ static int as3711_bl_register(struct platform_device *pdev, | |||
258 | return 0; | 258 | return 0; |
259 | } | 259 | } |
260 | 260 | ||
261 | static int as3711_backlight_parse_dt(struct device *dev) | ||
262 | { | ||
263 | struct as3711_bl_pdata *pdata = dev_get_platdata(dev); | ||
264 | struct device_node *bl = | ||
265 | of_find_node_by_name(dev->parent->of_node, "backlight"), *fb; | ||
266 | int ret; | ||
267 | |||
268 | if (!bl) { | ||
269 | dev_dbg(dev, "backlight node not found\n"); | ||
270 | return -ENODEV; | ||
271 | } | ||
272 | |||
273 | fb = of_parse_phandle(bl, "su1-dev", 0); | ||
274 | if (fb) { | ||
275 | pdata->su1_fb = fb->full_name; | ||
276 | |||
277 | ret = of_property_read_u32(bl, "su1-max-uA", &pdata->su1_max_uA); | ||
278 | if (pdata->su1_max_uA <= 0) | ||
279 | ret = -EINVAL; | ||
280 | if (ret < 0) | ||
281 | return ret; | ||
282 | } | ||
283 | |||
284 | fb = of_parse_phandle(bl, "su2-dev", 0); | ||
285 | if (fb) { | ||
286 | int count = 0; | ||
287 | |||
288 | pdata->su2_fb = fb->full_name; | ||
289 | |||
290 | ret = of_property_read_u32(bl, "su2-max-uA", &pdata->su2_max_uA); | ||
291 | if (pdata->su2_max_uA <= 0) | ||
292 | ret = -EINVAL; | ||
293 | if (ret < 0) | ||
294 | return ret; | ||
295 | |||
296 | if (of_find_property(bl, "su2-feedback-voltage", NULL)) { | ||
297 | pdata->su2_feedback = AS3711_SU2_VOLTAGE; | ||
298 | count++; | ||
299 | } | ||
300 | if (of_find_property(bl, "su2-feedback-curr1", NULL)) { | ||
301 | pdata->su2_feedback = AS3711_SU2_CURR1; | ||
302 | count++; | ||
303 | } | ||
304 | if (of_find_property(bl, "su2-feedback-curr2", NULL)) { | ||
305 | pdata->su2_feedback = AS3711_SU2_CURR2; | ||
306 | count++; | ||
307 | } | ||
308 | if (of_find_property(bl, "su2-feedback-curr3", NULL)) { | ||
309 | pdata->su2_feedback = AS3711_SU2_CURR3; | ||
310 | count++; | ||
311 | } | ||
312 | if (of_find_property(bl, "su2-feedback-curr-auto", NULL)) { | ||
313 | pdata->su2_feedback = AS3711_SU2_CURR_AUTO; | ||
314 | count++; | ||
315 | } | ||
316 | if (count != 1) | ||
317 | return -EINVAL; | ||
318 | |||
319 | count = 0; | ||
320 | if (of_find_property(bl, "su2-fbprot-lx-sd4", NULL)) { | ||
321 | pdata->su2_fbprot = AS3711_SU2_LX_SD4; | ||
322 | count++; | ||
323 | } | ||
324 | if (of_find_property(bl, "su2-fbprot-gpio2", NULL)) { | ||
325 | pdata->su2_fbprot = AS3711_SU2_GPIO2; | ||
326 | count++; | ||
327 | } | ||
328 | if (of_find_property(bl, "su2-fbprot-gpio3", NULL)) { | ||
329 | pdata->su2_fbprot = AS3711_SU2_GPIO3; | ||
330 | count++; | ||
331 | } | ||
332 | if (of_find_property(bl, "su2-fbprot-gpio4", NULL)) { | ||
333 | pdata->su2_fbprot = AS3711_SU2_GPIO4; | ||
334 | count++; | ||
335 | } | ||
336 | if (count != 1) | ||
337 | return -EINVAL; | ||
338 | |||
339 | count = 0; | ||
340 | if (of_find_property(bl, "su2-auto-curr1", NULL)) { | ||
341 | pdata->su2_auto_curr1 = true; | ||
342 | count++; | ||
343 | } | ||
344 | if (of_find_property(bl, "su2-auto-curr2", NULL)) { | ||
345 | pdata->su2_auto_curr2 = true; | ||
346 | count++; | ||
347 | } | ||
348 | if (of_find_property(bl, "su2-auto-curr3", NULL)) { | ||
349 | pdata->su2_auto_curr3 = true; | ||
350 | count++; | ||
351 | } | ||
352 | |||
353 | /* | ||
354 | * At least one su2-auto-curr* must be specified iff | ||
355 | * AS3711_SU2_CURR_AUTO is used | ||
356 | */ | ||
357 | if (!count ^ (pdata->su2_feedback != AS3711_SU2_CURR_AUTO)) | ||
358 | return -EINVAL; | ||
359 | } | ||
360 | |||
361 | return 0; | ||
362 | } | ||
363 | |||
261 | static int as3711_backlight_probe(struct platform_device *pdev) | 364 | static int as3711_backlight_probe(struct platform_device *pdev) |
262 | { | 365 | { |
263 | struct as3711_bl_pdata *pdata = dev_get_platdata(&pdev->dev); | 366 | struct as3711_bl_pdata *pdata = dev_get_platdata(&pdev->dev); |
@@ -267,11 +370,24 @@ static int as3711_backlight_probe(struct platform_device *pdev) | |||
267 | unsigned int max_brightness; | 370 | unsigned int max_brightness; |
268 | int ret; | 371 | int ret; |
269 | 372 | ||
270 | if (!pdata || (!pdata->su1_fb && !pdata->su2_fb)) { | 373 | if (!pdata) { |
271 | dev_err(&pdev->dev, "No platform data, exiting...\n"); | 374 | dev_err(&pdev->dev, "No platform data, exiting...\n"); |
272 | return -ENODEV; | 375 | return -ENODEV; |
273 | } | 376 | } |
274 | 377 | ||
378 | if (pdev->dev.parent->of_node) { | ||
379 | ret = as3711_backlight_parse_dt(&pdev->dev); | ||
380 | if (ret < 0) { | ||
381 | dev_err(&pdev->dev, "DT parsing failed: %d\n", ret); | ||
382 | return ret; | ||
383 | } | ||
384 | } | ||
385 | |||
386 | if (!pdata->su1_fb && !pdata->su2_fb) { | ||
387 | dev_err(&pdev->dev, "No framebuffer specified\n"); | ||
388 | return -EINVAL; | ||
389 | } | ||
390 | |||
275 | /* | 391 | /* |
276 | * Due to possible hardware damage I chose to block all modes, | 392 | * Due to possible hardware damage I chose to block all modes, |
277 | * unsupported on my hardware. Anyone, wishing to use any of those modes | 393 | * unsupported on my hardware. Anyone, wishing to use any of those modes |
diff --git a/drivers/video/backlight/atmel-pwm-bl.c b/drivers/video/backlight/atmel-pwm-bl.c index de5e5e74e2a7..a60d6afca97c 100644 --- a/drivers/video/backlight/atmel-pwm-bl.c +++ b/drivers/video/backlight/atmel-pwm-bl.c | |||
@@ -118,7 +118,7 @@ static const struct backlight_ops atmel_pwm_bl_ops = { | |||
118 | .update_status = atmel_pwm_bl_set_intensity, | 118 | .update_status = atmel_pwm_bl_set_intensity, |
119 | }; | 119 | }; |
120 | 120 | ||
121 | static int atmel_pwm_bl_probe(struct platform_device *pdev) | 121 | static int __init atmel_pwm_bl_probe(struct platform_device *pdev) |
122 | { | 122 | { |
123 | struct backlight_properties props; | 123 | struct backlight_properties props; |
124 | const struct atmel_pwm_bl_platform_data *pdata; | 124 | const struct atmel_pwm_bl_platform_data *pdata; |
@@ -225,17 +225,7 @@ static struct platform_driver atmel_pwm_bl_driver = { | |||
225 | .remove = __exit_p(atmel_pwm_bl_remove), | 225 | .remove = __exit_p(atmel_pwm_bl_remove), |
226 | }; | 226 | }; |
227 | 227 | ||
228 | static int __init atmel_pwm_bl_init(void) | 228 | module_platform_driver_probe(atmel_pwm_bl_driver, atmel_pwm_bl_probe); |
229 | { | ||
230 | return platform_driver_probe(&atmel_pwm_bl_driver, atmel_pwm_bl_probe); | ||
231 | } | ||
232 | module_init(atmel_pwm_bl_init); | ||
233 | |||
234 | static void __exit atmel_pwm_bl_exit(void) | ||
235 | { | ||
236 | platform_driver_unregister(&atmel_pwm_bl_driver); | ||
237 | } | ||
238 | module_exit(atmel_pwm_bl_exit); | ||
239 | 229 | ||
240 | MODULE_AUTHOR("Hans-Christian egtvedt <hans-christian.egtvedt@atmel.com>"); | 230 | MODULE_AUTHOR("Hans-Christian egtvedt <hans-christian.egtvedt@atmel.com>"); |
241 | MODULE_DESCRIPTION("Atmel PWM backlight driver"); | 231 | MODULE_DESCRIPTION("Atmel PWM backlight driver"); |
diff --git a/drivers/video/backlight/corgi_lcd.c b/drivers/video/backlight/corgi_lcd.c index aa782f302983..c97867a717a7 100644 --- a/drivers/video/backlight/corgi_lcd.c +++ b/drivers/video/backlight/corgi_lcd.c | |||
@@ -457,10 +457,10 @@ static const struct backlight_ops corgi_bl_ops = { | |||
457 | .update_status = corgi_bl_update_status, | 457 | .update_status = corgi_bl_update_status, |
458 | }; | 458 | }; |
459 | 459 | ||
460 | #ifdef CONFIG_PM | 460 | #ifdef CONFIG_PM_SLEEP |
461 | static int corgi_lcd_suspend(struct spi_device *spi, pm_message_t state) | 461 | static int corgi_lcd_suspend(struct device *dev) |
462 | { | 462 | { |
463 | struct corgi_lcd *lcd = spi_get_drvdata(spi); | 463 | struct corgi_lcd *lcd = dev_get_drvdata(dev); |
464 | 464 | ||
465 | corgibl_flags |= CORGIBL_SUSPENDED; | 465 | corgibl_flags |= CORGIBL_SUSPENDED; |
466 | corgi_bl_set_intensity(lcd, 0); | 466 | corgi_bl_set_intensity(lcd, 0); |
@@ -468,20 +468,19 @@ static int corgi_lcd_suspend(struct spi_device *spi, pm_message_t state) | |||
468 | return 0; | 468 | return 0; |
469 | } | 469 | } |
470 | 470 | ||
471 | static int corgi_lcd_resume(struct spi_device *spi) | 471 | static int corgi_lcd_resume(struct device *dev) |
472 | { | 472 | { |
473 | struct corgi_lcd *lcd = spi_get_drvdata(spi); | 473 | struct corgi_lcd *lcd = dev_get_drvdata(dev); |
474 | 474 | ||
475 | corgibl_flags &= ~CORGIBL_SUSPENDED; | 475 | corgibl_flags &= ~CORGIBL_SUSPENDED; |
476 | corgi_lcd_set_power(lcd->lcd_dev, FB_BLANK_UNBLANK); | 476 | corgi_lcd_set_power(lcd->lcd_dev, FB_BLANK_UNBLANK); |
477 | backlight_update_status(lcd->bl_dev); | 477 | backlight_update_status(lcd->bl_dev); |
478 | return 0; | 478 | return 0; |
479 | } | 479 | } |
480 | #else | ||
481 | #define corgi_lcd_suspend NULL | ||
482 | #define corgi_lcd_resume NULL | ||
483 | #endif | 480 | #endif |
484 | 481 | ||
482 | static SIMPLE_DEV_PM_OPS(corgi_lcd_pm_ops, corgi_lcd_suspend, corgi_lcd_resume); | ||
483 | |||
485 | static int setup_gpio_backlight(struct corgi_lcd *lcd, | 484 | static int setup_gpio_backlight(struct corgi_lcd *lcd, |
486 | struct corgi_lcd_platform_data *pdata) | 485 | struct corgi_lcd_platform_data *pdata) |
487 | { | 486 | { |
@@ -611,11 +610,10 @@ static struct spi_driver corgi_lcd_driver = { | |||
611 | .driver = { | 610 | .driver = { |
612 | .name = "corgi-lcd", | 611 | .name = "corgi-lcd", |
613 | .owner = THIS_MODULE, | 612 | .owner = THIS_MODULE, |
613 | .pm = &corgi_lcd_pm_ops, | ||
614 | }, | 614 | }, |
615 | .probe = corgi_lcd_probe, | 615 | .probe = corgi_lcd_probe, |
616 | .remove = corgi_lcd_remove, | 616 | .remove = corgi_lcd_remove, |
617 | .suspend = corgi_lcd_suspend, | ||
618 | .resume = corgi_lcd_resume, | ||
619 | }; | 617 | }; |
620 | 618 | ||
621 | module_spi_driver(corgi_lcd_driver); | 619 | module_spi_driver(corgi_lcd_driver); |
diff --git a/drivers/video/backlight/da903x_bl.c b/drivers/video/backlight/da903x_bl.c index 8179cef0730f..67cadd30e273 100644 --- a/drivers/video/backlight/da903x_bl.c +++ b/drivers/video/backlight/da903x_bl.c | |||
@@ -88,16 +88,21 @@ static int da903x_backlight_update_status(struct backlight_device *bl) | |||
88 | if (bl->props.fb_blank != FB_BLANK_UNBLANK) | 88 | if (bl->props.fb_blank != FB_BLANK_UNBLANK) |
89 | brightness = 0; | 89 | brightness = 0; |
90 | 90 | ||
91 | if (bl->props.state & BL_CORE_SUSPENDED) | ||
92 | brightness = 0; | ||
93 | |||
91 | return da903x_backlight_set(bl, brightness); | 94 | return da903x_backlight_set(bl, brightness); |
92 | } | 95 | } |
93 | 96 | ||
94 | static int da903x_backlight_get_brightness(struct backlight_device *bl) | 97 | static int da903x_backlight_get_brightness(struct backlight_device *bl) |
95 | { | 98 | { |
96 | struct da903x_backlight_data *data = bl_get_data(bl); | 99 | struct da903x_backlight_data *data = bl_get_data(bl); |
100 | |||
97 | return data->current_brightness; | 101 | return data->current_brightness; |
98 | } | 102 | } |
99 | 103 | ||
100 | static const struct backlight_ops da903x_backlight_ops = { | 104 | static const struct backlight_ops da903x_backlight_ops = { |
105 | .options = BL_CORE_SUSPENDRESUME, | ||
101 | .update_status = da903x_backlight_update_status, | 106 | .update_status = da903x_backlight_update_status, |
102 | .get_brightness = da903x_backlight_get_brightness, | 107 | .get_brightness = da903x_backlight_get_brightness, |
103 | }; | 108 | }; |
@@ -161,35 +166,10 @@ static int da903x_backlight_remove(struct platform_device *pdev) | |||
161 | return 0; | 166 | return 0; |
162 | } | 167 | } |
163 | 168 | ||
164 | #ifdef CONFIG_PM | ||
165 | static int da903x_backlight_suspend(struct device *dev) | ||
166 | { | ||
167 | struct backlight_device *bl = dev_get_drvdata(dev); | ||
168 | |||
169 | return da903x_backlight_set(bl, 0); | ||
170 | } | ||
171 | |||
172 | static int da903x_backlight_resume(struct device *dev) | ||
173 | { | ||
174 | struct backlight_device *bl = dev_get_drvdata(dev); | ||
175 | |||
176 | backlight_update_status(bl); | ||
177 | return 0; | ||
178 | } | ||
179 | |||
180 | static const struct dev_pm_ops da903x_backlight_pm_ops = { | ||
181 | .suspend = da903x_backlight_suspend, | ||
182 | .resume = da903x_backlight_resume, | ||
183 | }; | ||
184 | #endif | ||
185 | |||
186 | static struct platform_driver da903x_backlight_driver = { | 169 | static struct platform_driver da903x_backlight_driver = { |
187 | .driver = { | 170 | .driver = { |
188 | .name = "da903x-backlight", | 171 | .name = "da903x-backlight", |
189 | .owner = THIS_MODULE, | 172 | .owner = THIS_MODULE, |
190 | #ifdef CONFIG_PM | ||
191 | .pm = &da903x_backlight_pm_ops, | ||
192 | #endif | ||
193 | }, | 173 | }, |
194 | .probe = da903x_backlight_probe, | 174 | .probe = da903x_backlight_probe, |
195 | .remove = da903x_backlight_remove, | 175 | .remove = da903x_backlight_remove, |
diff --git a/drivers/video/backlight/ep93xx_bl.c b/drivers/video/backlight/ep93xx_bl.c index ef3e21e8f825..33455821dd31 100644 --- a/drivers/video/backlight/ep93xx_bl.c +++ b/drivers/video/backlight/ep93xx_bl.c | |||
@@ -60,7 +60,7 @@ static const struct backlight_ops ep93xxbl_ops = { | |||
60 | .get_brightness = ep93xxbl_get_brightness, | 60 | .get_brightness = ep93xxbl_get_brightness, |
61 | }; | 61 | }; |
62 | 62 | ||
63 | static int __init ep93xxbl_probe(struct platform_device *dev) | 63 | static int ep93xxbl_probe(struct platform_device *dev) |
64 | { | 64 | { |
65 | struct ep93xxbl *ep93xxbl; | 65 | struct ep93xxbl *ep93xxbl; |
66 | struct backlight_device *bl; | 66 | struct backlight_device *bl; |
@@ -115,35 +115,33 @@ static int ep93xxbl_remove(struct platform_device *dev) | |||
115 | return 0; | 115 | return 0; |
116 | } | 116 | } |
117 | 117 | ||
118 | #ifdef CONFIG_PM | 118 | #ifdef CONFIG_PM_SLEEP |
119 | static int ep93xxbl_suspend(struct platform_device *dev, pm_message_t state) | 119 | static int ep93xxbl_suspend(struct device *dev) |
120 | { | 120 | { |
121 | struct backlight_device *bl = platform_get_drvdata(dev); | 121 | struct backlight_device *bl = dev_get_drvdata(dev); |
122 | 122 | ||
123 | return ep93xxbl_set(bl, 0); | 123 | return ep93xxbl_set(bl, 0); |
124 | } | 124 | } |
125 | 125 | ||
126 | static int ep93xxbl_resume(struct platform_device *dev) | 126 | static int ep93xxbl_resume(struct device *dev) |
127 | { | 127 | { |
128 | struct backlight_device *bl = platform_get_drvdata(dev); | 128 | struct backlight_device *bl = dev_get_drvdata(dev); |
129 | 129 | ||
130 | backlight_update_status(bl); | 130 | backlight_update_status(bl); |
131 | return 0; | 131 | return 0; |
132 | } | 132 | } |
133 | #else | ||
134 | #define ep93xxbl_suspend NULL | ||
135 | #define ep93xxbl_resume NULL | ||
136 | #endif | 133 | #endif |
137 | 134 | ||
135 | static SIMPLE_DEV_PM_OPS(ep93xxbl_pm_ops, ep93xxbl_suspend, ep93xxbl_resume); | ||
136 | |||
138 | static struct platform_driver ep93xxbl_driver = { | 137 | static struct platform_driver ep93xxbl_driver = { |
139 | .driver = { | 138 | .driver = { |
140 | .name = "ep93xx-bl", | 139 | .name = "ep93xx-bl", |
141 | .owner = THIS_MODULE, | 140 | .owner = THIS_MODULE, |
141 | .pm = &ep93xxbl_pm_ops, | ||
142 | }, | 142 | }, |
143 | .probe = ep93xxbl_probe, | 143 | .probe = ep93xxbl_probe, |
144 | .remove = ep93xxbl_remove, | 144 | .remove = ep93xxbl_remove, |
145 | .suspend = ep93xxbl_suspend, | ||
146 | .resume = ep93xxbl_resume, | ||
147 | }; | 145 | }; |
148 | 146 | ||
149 | module_platform_driver(ep93xxbl_driver); | 147 | module_platform_driver(ep93xxbl_driver); |
diff --git a/drivers/video/backlight/generic_bl.c b/drivers/video/backlight/generic_bl.c index 0ae155be9c89..19e393b41438 100644 --- a/drivers/video/backlight/generic_bl.c +++ b/drivers/video/backlight/generic_bl.c | |||
@@ -9,8 +9,6 @@ | |||
9 | * | 9 | * |
10 | */ | 10 | */ |
11 | 11 | ||
12 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
13 | |||
14 | #include <linux/module.h> | 12 | #include <linux/module.h> |
15 | #include <linux/kernel.h> | 13 | #include <linux/kernel.h> |
16 | #include <linux/init.h> | 14 | #include <linux/init.h> |
@@ -108,7 +106,7 @@ static int genericbl_probe(struct platform_device *pdev) | |||
108 | 106 | ||
109 | generic_backlight_device = bd; | 107 | generic_backlight_device = bd; |
110 | 108 | ||
111 | pr_info("Generic Backlight Driver Initialized.\n"); | 109 | dev_info(&pdev->dev, "Generic Backlight Driver Initialized.\n"); |
112 | return 0; | 110 | return 0; |
113 | } | 111 | } |
114 | 112 | ||
@@ -122,7 +120,7 @@ static int genericbl_remove(struct platform_device *pdev) | |||
122 | 120 | ||
123 | backlight_device_unregister(bd); | 121 | backlight_device_unregister(bd); |
124 | 122 | ||
125 | pr_info("Generic Backlight Driver Unloaded\n"); | 123 | dev_info(&pdev->dev, "Generic Backlight Driver Unloaded\n"); |
126 | return 0; | 124 | return 0; |
127 | } | 125 | } |
128 | 126 | ||
diff --git a/drivers/video/backlight/hp680_bl.c b/drivers/video/backlight/hp680_bl.c index 5cefd73526f8..00076ecfe9b8 100644 --- a/drivers/video/backlight/hp680_bl.c +++ b/drivers/video/backlight/hp680_bl.c | |||
@@ -64,29 +64,28 @@ static void hp680bl_send_intensity(struct backlight_device *bd) | |||
64 | } | 64 | } |
65 | 65 | ||
66 | 66 | ||
67 | #ifdef CONFIG_PM | 67 | #ifdef CONFIG_PM_SLEEP |
68 | static int hp680bl_suspend(struct platform_device *pdev, pm_message_t state) | 68 | static int hp680bl_suspend(struct device *dev) |
69 | { | 69 | { |
70 | struct backlight_device *bd = platform_get_drvdata(pdev); | 70 | struct backlight_device *bd = dev_get_drvdata(dev); |
71 | 71 | ||
72 | hp680bl_suspended = 1; | 72 | hp680bl_suspended = 1; |
73 | hp680bl_send_intensity(bd); | 73 | hp680bl_send_intensity(bd); |
74 | return 0; | 74 | return 0; |
75 | } | 75 | } |
76 | 76 | ||
77 | static int hp680bl_resume(struct platform_device *pdev) | 77 | static int hp680bl_resume(struct device *dev) |
78 | { | 78 | { |
79 | struct backlight_device *bd = platform_get_drvdata(pdev); | 79 | struct backlight_device *bd = dev_get_drvdata(dev); |
80 | 80 | ||
81 | hp680bl_suspended = 0; | 81 | hp680bl_suspended = 0; |
82 | hp680bl_send_intensity(bd); | 82 | hp680bl_send_intensity(bd); |
83 | return 0; | 83 | return 0; |
84 | } | 84 | } |
85 | #else | ||
86 | #define hp680bl_suspend NULL | ||
87 | #define hp680bl_resume NULL | ||
88 | #endif | 85 | #endif |
89 | 86 | ||
87 | static SIMPLE_DEV_PM_OPS(hp680bl_pm_ops, hp680bl_suspend, hp680bl_resume); | ||
88 | |||
90 | static int hp680bl_set_intensity(struct backlight_device *bd) | 89 | static int hp680bl_set_intensity(struct backlight_device *bd) |
91 | { | 90 | { |
92 | hp680bl_send_intensity(bd); | 91 | hp680bl_send_intensity(bd); |
@@ -140,10 +139,9 @@ static int hp680bl_remove(struct platform_device *pdev) | |||
140 | static struct platform_driver hp680bl_driver = { | 139 | static struct platform_driver hp680bl_driver = { |
141 | .probe = hp680bl_probe, | 140 | .probe = hp680bl_probe, |
142 | .remove = hp680bl_remove, | 141 | .remove = hp680bl_remove, |
143 | .suspend = hp680bl_suspend, | ||
144 | .resume = hp680bl_resume, | ||
145 | .driver = { | 142 | .driver = { |
146 | .name = "hp680-bl", | 143 | .name = "hp680-bl", |
144 | .pm = &hp680bl_pm_ops, | ||
147 | }, | 145 | }, |
148 | }; | 146 | }; |
149 | 147 | ||
diff --git a/drivers/video/backlight/ili922x.c b/drivers/video/backlight/ili922x.c new file mode 100644 index 000000000000..d9f65c2d9b01 --- /dev/null +++ b/drivers/video/backlight/ili922x.c | |||
@@ -0,0 +1,555 @@ | |||
1 | /* | ||
2 | * (C) Copyright 2008 | ||
3 | * Stefano Babic, DENX Software Engineering, sbabic@denx.de. | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or | ||
6 | * modify it under the terms of the GNU General Public License as | ||
7 | * published by the Free Software Foundation; either version 2 of | ||
8 | * the License, or (at your option) any later version. | ||
9 | * | ||
10 | * This driver implements a lcd device for the ILITEK 922x display | ||
11 | * controller. The interface to the display is SPI and the display's | ||
12 | * memory is cyclically updated over the RGB interface. | ||
13 | */ | ||
14 | |||
15 | #include <linux/fb.h> | ||
16 | #include <linux/delay.h> | ||
17 | #include <linux/errno.h> | ||
18 | #include <linux/init.h> | ||
19 | #include <linux/kernel.h> | ||
20 | #include <linux/lcd.h> | ||
21 | #include <linux/module.h> | ||
22 | #include <linux/of.h> | ||
23 | #include <linux/slab.h> | ||
24 | #include <linux/spi/spi.h> | ||
25 | #include <linux/string.h> | ||
26 | |||
27 | /* Register offset, see manual section 8.2 */ | ||
28 | #define REG_START_OSCILLATION 0x00 | ||
29 | #define REG_DRIVER_CODE_READ 0x00 | ||
30 | #define REG_DRIVER_OUTPUT_CONTROL 0x01 | ||
31 | #define REG_LCD_AC_DRIVEING_CONTROL 0x02 | ||
32 | #define REG_ENTRY_MODE 0x03 | ||
33 | #define REG_COMPARE_1 0x04 | ||
34 | #define REG_COMPARE_2 0x05 | ||
35 | #define REG_DISPLAY_CONTROL_1 0x07 | ||
36 | #define REG_DISPLAY_CONTROL_2 0x08 | ||
37 | #define REG_DISPLAY_CONTROL_3 0x09 | ||
38 | #define REG_FRAME_CYCLE_CONTROL 0x0B | ||
39 | #define REG_EXT_INTF_CONTROL 0x0C | ||
40 | #define REG_POWER_CONTROL_1 0x10 | ||
41 | #define REG_POWER_CONTROL_2 0x11 | ||
42 | #define REG_POWER_CONTROL_3 0x12 | ||
43 | #define REG_POWER_CONTROL_4 0x13 | ||
44 | #define REG_RAM_ADDRESS_SET 0x21 | ||
45 | #define REG_WRITE_DATA_TO_GRAM 0x22 | ||
46 | #define REG_RAM_WRITE_MASK1 0x23 | ||
47 | #define REG_RAM_WRITE_MASK2 0x24 | ||
48 | #define REG_GAMMA_CONTROL_1 0x30 | ||
49 | #define REG_GAMMA_CONTROL_2 0x31 | ||
50 | #define REG_GAMMA_CONTROL_3 0x32 | ||
51 | #define REG_GAMMA_CONTROL_4 0x33 | ||
52 | #define REG_GAMMA_CONTROL_5 0x34 | ||
53 | #define REG_GAMMA_CONTROL_6 0x35 | ||
54 | #define REG_GAMMA_CONTROL_7 0x36 | ||
55 | #define REG_GAMMA_CONTROL_8 0x37 | ||
56 | #define REG_GAMMA_CONTROL_9 0x38 | ||
57 | #define REG_GAMMA_CONTROL_10 0x39 | ||
58 | #define REG_GATE_SCAN_CONTROL 0x40 | ||
59 | #define REG_VERT_SCROLL_CONTROL 0x41 | ||
60 | #define REG_FIRST_SCREEN_DRIVE_POS 0x42 | ||
61 | #define REG_SECOND_SCREEN_DRIVE_POS 0x43 | ||
62 | #define REG_RAM_ADDR_POS_H 0x44 | ||
63 | #define REG_RAM_ADDR_POS_V 0x45 | ||
64 | #define REG_OSCILLATOR_CONTROL 0x4F | ||
65 | #define REG_GPIO 0x60 | ||
66 | #define REG_OTP_VCM_PROGRAMMING 0x61 | ||
67 | #define REG_OTP_VCM_STATUS_ENABLE 0x62 | ||
68 | #define REG_OTP_PROGRAMMING_ID_KEY 0x65 | ||
69 | |||
70 | /* | ||
71 | * maximum frequency for register access | ||
72 | * (not for the GRAM access) | ||
73 | */ | ||
74 | #define ILITEK_MAX_FREQ_REG 4000000 | ||
75 | |||
76 | /* | ||
77 | * Device ID as found in the datasheet (supports 9221 and 9222) | ||
78 | */ | ||
79 | #define ILITEK_DEVICE_ID 0x9220 | ||
80 | #define ILITEK_DEVICE_ID_MASK 0xFFF0 | ||
81 | |||
82 | /* Last two bits in the START BYTE */ | ||
83 | #define START_RS_INDEX 0 | ||
84 | #define START_RS_REG 1 | ||
85 | #define START_RW_WRITE 0 | ||
86 | #define START_RW_READ 1 | ||
87 | |||
88 | /** | ||
89 | * START_BYTE(id, rs, rw) | ||
90 | * | ||
91 | * Set the start byte according to the required operation. | ||
92 | * The start byte is defined as: | ||
93 | * ---------------------------------- | ||
94 | * | 0 | 1 | 1 | 1 | 0 | ID | RS | RW | | ||
95 | * ---------------------------------- | ||
96 | * @id: display's id as set by the manufacturer | ||
97 | * @rs: operation type bit, one of: | ||
98 | * - START_RS_INDEX set the index register | ||
99 | * - START_RS_REG write/read registers/GRAM | ||
100 | * @rw: read/write operation | ||
101 | * - START_RW_WRITE write | ||
102 | * - START_RW_READ read | ||
103 | */ | ||
104 | #define START_BYTE(id, rs, rw) \ | ||
105 | (0x70 | (((id) & 0x01) << 2) | (((rs) & 0x01) << 1) | ((rw) & 0x01)) | ||
106 | |||
107 | /** | ||
108 | * CHECK_FREQ_REG(spi_device s, spi_transfer x) - Check the frequency | ||
109 | * for the SPI transfer. According to the datasheet, the controller | ||
110 | * accept higher frequency for the GRAM transfer, but it requires | ||
111 | * lower frequency when the registers are read/written. | ||
112 | * The macro sets the frequency in the spi_transfer structure if | ||
113 | * the frequency exceeds the maximum value. | ||
114 | */ | ||
115 | #define CHECK_FREQ_REG(s, x) \ | ||
116 | do { \ | ||
117 | if (s->max_speed_hz > ILITEK_MAX_FREQ_REG) \ | ||
118 | ((struct spi_transfer *)x)->speed_hz = \ | ||
119 | ILITEK_MAX_FREQ_REG; \ | ||
120 | } while (0) | ||
121 | |||
122 | #define CMD_BUFSIZE 16 | ||
123 | |||
124 | #define POWER_IS_ON(pwr) ((pwr) <= FB_BLANK_NORMAL) | ||
125 | |||
126 | #define set_tx_byte(b) (tx_invert ? ~(b) : b) | ||
127 | |||
128 | /** | ||
129 | * ili922x_id - id as set by manufacturer | ||
130 | */ | ||
131 | static int ili922x_id = 1; | ||
132 | module_param(ili922x_id, int, 0); | ||
133 | |||
134 | static int tx_invert; | ||
135 | module_param(tx_invert, int, 0); | ||
136 | |||
137 | /** | ||
138 | * driver's private structure | ||
139 | */ | ||
140 | struct ili922x { | ||
141 | struct spi_device *spi; | ||
142 | struct lcd_device *ld; | ||
143 | int power; | ||
144 | }; | ||
145 | |||
146 | /** | ||
147 | * ili922x_read_status - read status register from display | ||
148 | * @spi: spi device | ||
149 | * @rs: output value | ||
150 | */ | ||
151 | static int ili922x_read_status(struct spi_device *spi, u16 *rs) | ||
152 | { | ||
153 | struct spi_message msg; | ||
154 | struct spi_transfer xfer; | ||
155 | unsigned char tbuf[CMD_BUFSIZE]; | ||
156 | unsigned char rbuf[CMD_BUFSIZE]; | ||
157 | int ret, i; | ||
158 | |||
159 | memset(&xfer, 0, sizeof(struct spi_transfer)); | ||
160 | spi_message_init(&msg); | ||
161 | xfer.tx_buf = tbuf; | ||
162 | xfer.rx_buf = rbuf; | ||
163 | xfer.cs_change = 1; | ||
164 | CHECK_FREQ_REG(spi, &xfer); | ||
165 | |||
166 | tbuf[0] = set_tx_byte(START_BYTE(ili922x_id, START_RS_INDEX, | ||
167 | START_RW_READ)); | ||
168 | /* | ||
169 | * we need 4-byte xfer here due to invalid dummy byte | ||
170 | * received after start byte | ||
171 | */ | ||
172 | for (i = 1; i < 4; i++) | ||
173 | tbuf[i] = set_tx_byte(0); /* dummy */ | ||
174 | |||
175 | xfer.bits_per_word = 8; | ||
176 | xfer.len = 4; | ||
177 | spi_message_add_tail(&xfer, &msg); | ||
178 | ret = spi_sync(spi, &msg); | ||
179 | if (ret < 0) { | ||
180 | dev_dbg(&spi->dev, "Error sending SPI message 0x%x", ret); | ||
181 | return ret; | ||
182 | } | ||
183 | |||
184 | *rs = (rbuf[2] << 8) + rbuf[3]; | ||
185 | return 0; | ||
186 | } | ||
187 | |||
188 | /** | ||
189 | * ili922x_read - read register from display | ||
190 | * @spi: spi device | ||
191 | * @reg: offset of the register to be read | ||
192 | * @rx: output value | ||
193 | */ | ||
194 | static int ili922x_read(struct spi_device *spi, u8 reg, u16 *rx) | ||
195 | { | ||
196 | struct spi_message msg; | ||
197 | struct spi_transfer xfer_regindex, xfer_regvalue; | ||
198 | unsigned char tbuf[CMD_BUFSIZE]; | ||
199 | unsigned char rbuf[CMD_BUFSIZE]; | ||
200 | int ret, len = 0, send_bytes; | ||
201 | |||
202 | memset(&xfer_regindex, 0, sizeof(struct spi_transfer)); | ||
203 | memset(&xfer_regvalue, 0, sizeof(struct spi_transfer)); | ||
204 | spi_message_init(&msg); | ||
205 | xfer_regindex.tx_buf = tbuf; | ||
206 | xfer_regindex.rx_buf = rbuf; | ||
207 | xfer_regindex.cs_change = 1; | ||
208 | CHECK_FREQ_REG(spi, &xfer_regindex); | ||
209 | |||
210 | tbuf[0] = set_tx_byte(START_BYTE(ili922x_id, START_RS_INDEX, | ||
211 | START_RW_WRITE)); | ||
212 | tbuf[1] = set_tx_byte(0); | ||
213 | tbuf[2] = set_tx_byte(reg); | ||
214 | xfer_regindex.bits_per_word = 8; | ||
215 | len = xfer_regindex.len = 3; | ||
216 | spi_message_add_tail(&xfer_regindex, &msg); | ||
217 | |||
218 | send_bytes = len; | ||
219 | |||
220 | tbuf[len++] = set_tx_byte(START_BYTE(ili922x_id, START_RS_REG, | ||
221 | START_RW_READ)); | ||
222 | tbuf[len++] = set_tx_byte(0); | ||
223 | tbuf[len] = set_tx_byte(0); | ||
224 | |||
225 | xfer_regvalue.cs_change = 1; | ||
226 | xfer_regvalue.len = 3; | ||
227 | xfer_regvalue.tx_buf = &tbuf[send_bytes]; | ||
228 | xfer_regvalue.rx_buf = &rbuf[send_bytes]; | ||
229 | CHECK_FREQ_REG(spi, &xfer_regvalue); | ||
230 | |||
231 | spi_message_add_tail(&xfer_regvalue, &msg); | ||
232 | ret = spi_sync(spi, &msg); | ||
233 | if (ret < 0) { | ||
234 | dev_dbg(&spi->dev, "Error sending SPI message 0x%x", ret); | ||
235 | return ret; | ||
236 | } | ||
237 | |||
238 | *rx = (rbuf[1 + send_bytes] << 8) + rbuf[2 + send_bytes]; | ||
239 | return 0; | ||
240 | } | ||
241 | |||
242 | /** | ||
243 | * ili922x_write - write a controller register | ||
244 | * @spi: struct spi_device * | ||
245 | * @reg: offset of the register to be written | ||
246 | * @value: value to be written | ||
247 | */ | ||
248 | static int ili922x_write(struct spi_device *spi, u8 reg, u16 value) | ||
249 | { | ||
250 | struct spi_message msg; | ||
251 | struct spi_transfer xfer_regindex, xfer_regvalue; | ||
252 | unsigned char tbuf[CMD_BUFSIZE]; | ||
253 | unsigned char rbuf[CMD_BUFSIZE]; | ||
254 | int ret, len = 0; | ||
255 | |||
256 | memset(&xfer_regindex, 0, sizeof(struct spi_transfer)); | ||
257 | memset(&xfer_regvalue, 0, sizeof(struct spi_transfer)); | ||
258 | |||
259 | spi_message_init(&msg); | ||
260 | xfer_regindex.tx_buf = tbuf; | ||
261 | xfer_regindex.rx_buf = rbuf; | ||
262 | xfer_regindex.cs_change = 1; | ||
263 | CHECK_FREQ_REG(spi, &xfer_regindex); | ||
264 | |||
265 | tbuf[0] = set_tx_byte(START_BYTE(ili922x_id, START_RS_INDEX, | ||
266 | START_RW_WRITE)); | ||
267 | tbuf[1] = set_tx_byte(0); | ||
268 | tbuf[2] = set_tx_byte(reg); | ||
269 | xfer_regindex.bits_per_word = 8; | ||
270 | xfer_regindex.len = 3; | ||
271 | spi_message_add_tail(&xfer_regindex, &msg); | ||
272 | |||
273 | ret = spi_sync(spi, &msg); | ||
274 | |||
275 | spi_message_init(&msg); | ||
276 | len = 0; | ||
277 | tbuf[0] = set_tx_byte(START_BYTE(ili922x_id, START_RS_REG, | ||
278 | START_RW_WRITE)); | ||
279 | tbuf[1] = set_tx_byte((value & 0xFF00) >> 8); | ||
280 | tbuf[2] = set_tx_byte(value & 0x00FF); | ||
281 | |||
282 | xfer_regvalue.cs_change = 1; | ||
283 | xfer_regvalue.len = 3; | ||
284 | xfer_regvalue.tx_buf = tbuf; | ||
285 | xfer_regvalue.rx_buf = rbuf; | ||
286 | CHECK_FREQ_REG(spi, &xfer_regvalue); | ||
287 | |||
288 | spi_message_add_tail(&xfer_regvalue, &msg); | ||
289 | |||
290 | ret = spi_sync(spi, &msg); | ||
291 | if (ret < 0) { | ||
292 | dev_err(&spi->dev, "Error sending SPI message 0x%x", ret); | ||
293 | return ret; | ||
294 | } | ||
295 | return 0; | ||
296 | } | ||
297 | |||
298 | #ifdef DEBUG | ||
299 | /** | ||
300 | * ili922x_reg_dump - dump all registers | ||
301 | */ | ||
302 | static void ili922x_reg_dump(struct spi_device *spi) | ||
303 | { | ||
304 | u8 reg; | ||
305 | u16 rx; | ||
306 | |||
307 | dev_dbg(&spi->dev, "ILI922x configuration registers:\n"); | ||
308 | for (reg = REG_START_OSCILLATION; | ||
309 | reg <= REG_OTP_PROGRAMMING_ID_KEY; reg++) { | ||
310 | ili922x_read(spi, reg, &rx); | ||
311 | dev_dbg(&spi->dev, "reg @ 0x%02X: 0x%04X\n", reg, rx); | ||
312 | } | ||
313 | } | ||
314 | #else | ||
315 | static inline void ili922x_reg_dump(struct spi_device *spi) {} | ||
316 | #endif | ||
317 | |||
318 | /** | ||
319 | * set_write_to_gram_reg - initialize the display to write the GRAM | ||
320 | * @spi: spi device | ||
321 | */ | ||
322 | static void set_write_to_gram_reg(struct spi_device *spi) | ||
323 | { | ||
324 | struct spi_message msg; | ||
325 | struct spi_transfer xfer; | ||
326 | unsigned char tbuf[CMD_BUFSIZE]; | ||
327 | |||
328 | memset(&xfer, 0, sizeof(struct spi_transfer)); | ||
329 | |||
330 | spi_message_init(&msg); | ||
331 | xfer.tx_buf = tbuf; | ||
332 | xfer.rx_buf = NULL; | ||
333 | xfer.cs_change = 1; | ||
334 | |||
335 | tbuf[0] = START_BYTE(ili922x_id, START_RS_INDEX, START_RW_WRITE); | ||
336 | tbuf[1] = 0; | ||
337 | tbuf[2] = REG_WRITE_DATA_TO_GRAM; | ||
338 | |||
339 | xfer.bits_per_word = 8; | ||
340 | xfer.len = 3; | ||
341 | spi_message_add_tail(&xfer, &msg); | ||
342 | spi_sync(spi, &msg); | ||
343 | } | ||
344 | |||
345 | /** | ||
346 | * ili922x_poweron - turn the display on | ||
347 | * @spi: spi device | ||
348 | * | ||
349 | * The sequence to turn on the display is taken from | ||
350 | * the datasheet and/or the example code provided by the | ||
351 | * manufacturer. | ||
352 | */ | ||
353 | static int ili922x_poweron(struct spi_device *spi) | ||
354 | { | ||
355 | int ret; | ||
356 | |||
357 | /* Power on */ | ||
358 | ret = ili922x_write(spi, REG_POWER_CONTROL_1, 0x0000); | ||
359 | usleep_range(10000, 10500); | ||
360 | ret += ili922x_write(spi, REG_POWER_CONTROL_2, 0x0000); | ||
361 | ret += ili922x_write(spi, REG_POWER_CONTROL_3, 0x0000); | ||
362 | msleep(40); | ||
363 | ret += ili922x_write(spi, REG_POWER_CONTROL_4, 0x0000); | ||
364 | msleep(40); | ||
365 | /* register 0x56 is not documented in the datasheet */ | ||
366 | ret += ili922x_write(spi, 0x56, 0x080F); | ||
367 | ret += ili922x_write(spi, REG_POWER_CONTROL_1, 0x4240); | ||
368 | usleep_range(10000, 10500); | ||
369 | ret += ili922x_write(spi, REG_POWER_CONTROL_2, 0x0000); | ||
370 | ret += ili922x_write(spi, REG_POWER_CONTROL_3, 0x0014); | ||
371 | msleep(40); | ||
372 | ret += ili922x_write(spi, REG_POWER_CONTROL_4, 0x1319); | ||
373 | msleep(40); | ||
374 | |||
375 | return ret; | ||
376 | } | ||
377 | |||
378 | /** | ||
379 | * ili922x_poweroff - turn the display off | ||
380 | * @spi: spi device | ||
381 | */ | ||
382 | static int ili922x_poweroff(struct spi_device *spi) | ||
383 | { | ||
384 | int ret; | ||
385 | |||
386 | /* Power off */ | ||
387 | ret = ili922x_write(spi, REG_POWER_CONTROL_1, 0x0000); | ||
388 | usleep_range(10000, 10500); | ||
389 | ret += ili922x_write(spi, REG_POWER_CONTROL_2, 0x0000); | ||
390 | ret += ili922x_write(spi, REG_POWER_CONTROL_3, 0x0000); | ||
391 | msleep(40); | ||
392 | ret += ili922x_write(spi, REG_POWER_CONTROL_4, 0x0000); | ||
393 | msleep(40); | ||
394 | |||
395 | return ret; | ||
396 | } | ||
397 | |||
398 | /** | ||
399 | * ili922x_display_init - initialize the display by setting | ||
400 | * the configuration registers | ||
401 | * @spi: spi device | ||
402 | */ | ||
403 | static void ili922x_display_init(struct spi_device *spi) | ||
404 | { | ||
405 | ili922x_write(spi, REG_START_OSCILLATION, 1); | ||
406 | usleep_range(10000, 10500); | ||
407 | ili922x_write(spi, REG_DRIVER_OUTPUT_CONTROL, 0x691B); | ||
408 | ili922x_write(spi, REG_LCD_AC_DRIVEING_CONTROL, 0x0700); | ||
409 | ili922x_write(spi, REG_ENTRY_MODE, 0x1030); | ||
410 | ili922x_write(spi, REG_COMPARE_1, 0x0000); | ||
411 | ili922x_write(spi, REG_COMPARE_2, 0x0000); | ||
412 | ili922x_write(spi, REG_DISPLAY_CONTROL_1, 0x0037); | ||
413 | ili922x_write(spi, REG_DISPLAY_CONTROL_2, 0x0202); | ||
414 | ili922x_write(spi, REG_DISPLAY_CONTROL_3, 0x0000); | ||
415 | ili922x_write(spi, REG_FRAME_CYCLE_CONTROL, 0x0000); | ||
416 | |||
417 | /* Set RGB interface */ | ||
418 | ili922x_write(spi, REG_EXT_INTF_CONTROL, 0x0110); | ||
419 | |||
420 | ili922x_poweron(spi); | ||
421 | |||
422 | ili922x_write(spi, REG_GAMMA_CONTROL_1, 0x0302); | ||
423 | ili922x_write(spi, REG_GAMMA_CONTROL_2, 0x0407); | ||
424 | ili922x_write(spi, REG_GAMMA_CONTROL_3, 0x0304); | ||
425 | ili922x_write(spi, REG_GAMMA_CONTROL_4, 0x0203); | ||
426 | ili922x_write(spi, REG_GAMMA_CONTROL_5, 0x0706); | ||
427 | ili922x_write(spi, REG_GAMMA_CONTROL_6, 0x0407); | ||
428 | ili922x_write(spi, REG_GAMMA_CONTROL_7, 0x0706); | ||
429 | ili922x_write(spi, REG_GAMMA_CONTROL_8, 0x0000); | ||
430 | ili922x_write(spi, REG_GAMMA_CONTROL_9, 0x0C06); | ||
431 | ili922x_write(spi, REG_GAMMA_CONTROL_10, 0x0F00); | ||
432 | ili922x_write(spi, REG_RAM_ADDRESS_SET, 0x0000); | ||
433 | ili922x_write(spi, REG_GATE_SCAN_CONTROL, 0x0000); | ||
434 | ili922x_write(spi, REG_VERT_SCROLL_CONTROL, 0x0000); | ||
435 | ili922x_write(spi, REG_FIRST_SCREEN_DRIVE_POS, 0xDB00); | ||
436 | ili922x_write(spi, REG_SECOND_SCREEN_DRIVE_POS, 0xDB00); | ||
437 | ili922x_write(spi, REG_RAM_ADDR_POS_H, 0xAF00); | ||
438 | ili922x_write(spi, REG_RAM_ADDR_POS_V, 0xDB00); | ||
439 | ili922x_reg_dump(spi); | ||
440 | set_write_to_gram_reg(spi); | ||
441 | } | ||
442 | |||
443 | static int ili922x_lcd_power(struct ili922x *lcd, int power) | ||
444 | { | ||
445 | int ret = 0; | ||
446 | |||
447 | if (POWER_IS_ON(power) && !POWER_IS_ON(lcd->power)) | ||
448 | ret = ili922x_poweron(lcd->spi); | ||
449 | else if (!POWER_IS_ON(power) && POWER_IS_ON(lcd->power)) | ||
450 | ret = ili922x_poweroff(lcd->spi); | ||
451 | |||
452 | if (!ret) | ||
453 | lcd->power = power; | ||
454 | |||
455 | return ret; | ||
456 | } | ||
457 | |||
458 | static int ili922x_set_power(struct lcd_device *ld, int power) | ||
459 | { | ||
460 | struct ili922x *ili = lcd_get_data(ld); | ||
461 | |||
462 | return ili922x_lcd_power(ili, power); | ||
463 | } | ||
464 | |||
465 | static int ili922x_get_power(struct lcd_device *ld) | ||
466 | { | ||
467 | struct ili922x *ili = lcd_get_data(ld); | ||
468 | |||
469 | return ili->power; | ||
470 | } | ||
471 | |||
472 | static struct lcd_ops ili922x_ops = { | ||
473 | .get_power = ili922x_get_power, | ||
474 | .set_power = ili922x_set_power, | ||
475 | }; | ||
476 | |||
477 | static int ili922x_probe(struct spi_device *spi) | ||
478 | { | ||
479 | struct ili922x *ili; | ||
480 | struct lcd_device *lcd; | ||
481 | int ret; | ||
482 | u16 reg = 0; | ||
483 | |||
484 | ili = devm_kzalloc(&spi->dev, sizeof(*ili), GFP_KERNEL); | ||
485 | if (!ili) { | ||
486 | dev_err(&spi->dev, "cannot alloc priv data\n"); | ||
487 | return -ENOMEM; | ||
488 | } | ||
489 | |||
490 | ili->spi = spi; | ||
491 | spi_set_drvdata(spi, ili); | ||
492 | |||
493 | /* check if the device is connected */ | ||
494 | ret = ili922x_read(spi, REG_DRIVER_CODE_READ, ®); | ||
495 | if (ret || ((reg & ILITEK_DEVICE_ID_MASK) != ILITEK_DEVICE_ID)) { | ||
496 | dev_err(&spi->dev, | ||
497 | "no LCD found: Chip ID 0x%x, ret %d\n", | ||
498 | reg, ret); | ||
499 | return -ENODEV; | ||
500 | } else { | ||
501 | dev_info(&spi->dev, "ILI%x found, SPI freq %d, mode %d\n", | ||
502 | reg, spi->max_speed_hz, spi->mode); | ||
503 | } | ||
504 | |||
505 | ret = ili922x_read_status(spi, ®); | ||
506 | if (ret) { | ||
507 | dev_err(&spi->dev, "reading RS failed...\n"); | ||
508 | return ret; | ||
509 | } else | ||
510 | dev_dbg(&spi->dev, "status: 0x%x\n", reg); | ||
511 | |||
512 | ili922x_display_init(spi); | ||
513 | |||
514 | ili->power = FB_BLANK_POWERDOWN; | ||
515 | |||
516 | lcd = lcd_device_register("ili922xlcd", &spi->dev, ili, | ||
517 | &ili922x_ops); | ||
518 | if (IS_ERR(lcd)) { | ||
519 | dev_err(&spi->dev, "cannot register LCD\n"); | ||
520 | return PTR_ERR(lcd); | ||
521 | } | ||
522 | |||
523 | ili->ld = lcd; | ||
524 | spi_set_drvdata(spi, ili); | ||
525 | |||
526 | ili922x_lcd_power(ili, FB_BLANK_UNBLANK); | ||
527 | |||
528 | return 0; | ||
529 | } | ||
530 | |||
531 | static int ili922x_remove(struct spi_device *spi) | ||
532 | { | ||
533 | struct ili922x *ili = spi_get_drvdata(spi); | ||
534 | |||
535 | ili922x_poweroff(spi); | ||
536 | lcd_device_unregister(ili->ld); | ||
537 | return 0; | ||
538 | } | ||
539 | |||
540 | static struct spi_driver ili922x_driver = { | ||
541 | .driver = { | ||
542 | .name = "ili922x", | ||
543 | .owner = THIS_MODULE, | ||
544 | }, | ||
545 | .probe = ili922x_probe, | ||
546 | .remove = ili922x_remove, | ||
547 | }; | ||
548 | |||
549 | module_spi_driver(ili922x_driver); | ||
550 | |||
551 | MODULE_AUTHOR("Stefano Babic <sbabic@denx.de>"); | ||
552 | MODULE_DESCRIPTION("ILI9221/9222 LCD driver"); | ||
553 | MODULE_LICENSE("GPL"); | ||
554 | MODULE_PARM_DESC(ili922x_id, "set controller identifier (default=1)"); | ||
555 | MODULE_PARM_DESC(tx_invert, "invert bytes before sending"); | ||
diff --git a/drivers/video/backlight/ili9320.c b/drivers/video/backlight/ili9320.c index 1235bf9defc4..f8be90c5dedc 100644 --- a/drivers/video/backlight/ili9320.c +++ b/drivers/video/backlight/ili9320.c | |||
@@ -231,7 +231,7 @@ int ili9320_probe_spi(struct spi_device *spi, | |||
231 | ili->power = FB_BLANK_POWERDOWN; | 231 | ili->power = FB_BLANK_POWERDOWN; |
232 | ili->platdata = cfg; | 232 | ili->platdata = cfg; |
233 | 233 | ||
234 | dev_set_drvdata(&spi->dev, ili); | 234 | spi_set_drvdata(spi, ili); |
235 | 235 | ||
236 | ili9320_setup_spi(ili, spi); | 236 | ili9320_setup_spi(ili, spi); |
237 | 237 | ||
@@ -270,27 +270,21 @@ int ili9320_remove(struct ili9320 *ili) | |||
270 | } | 270 | } |
271 | EXPORT_SYMBOL_GPL(ili9320_remove); | 271 | EXPORT_SYMBOL_GPL(ili9320_remove); |
272 | 272 | ||
273 | #ifdef CONFIG_PM | 273 | #ifdef CONFIG_PM_SLEEP |
274 | int ili9320_suspend(struct ili9320 *lcd, pm_message_t state) | 274 | int ili9320_suspend(struct ili9320 *lcd) |
275 | { | 275 | { |
276 | int ret; | 276 | int ret; |
277 | 277 | ||
278 | dev_dbg(lcd->dev, "%s: event %d\n", __func__, state.event); | 278 | ret = ili9320_power(lcd, FB_BLANK_POWERDOWN); |
279 | 279 | ||
280 | if (state.event == PM_EVENT_SUSPEND) { | 280 | if (lcd->platdata->suspend == ILI9320_SUSPEND_DEEP) { |
281 | ret = ili9320_power(lcd, FB_BLANK_POWERDOWN); | 281 | ili9320_write(lcd, ILI9320_POWER1, lcd->power1 | |
282 | 282 | ILI9320_POWER1_SLP | | |
283 | if (lcd->platdata->suspend == ILI9320_SUSPEND_DEEP) { | 283 | ILI9320_POWER1_DSTB); |
284 | ili9320_write(lcd, ILI9320_POWER1, lcd->power1 | | 284 | lcd->initialised = 0; |
285 | ILI9320_POWER1_SLP | | ||
286 | ILI9320_POWER1_DSTB); | ||
287 | lcd->initialised = 0; | ||
288 | } | ||
289 | |||
290 | return ret; | ||
291 | } | 285 | } |
292 | 286 | ||
293 | return 0; | 287 | return ret; |
294 | } | 288 | } |
295 | EXPORT_SYMBOL_GPL(ili9320_suspend); | 289 | EXPORT_SYMBOL_GPL(ili9320_suspend); |
296 | 290 | ||
diff --git a/drivers/video/backlight/ili9320.h b/drivers/video/backlight/ili9320.h index e0db738f7bb9..42329e7aa9a8 100644 --- a/drivers/video/backlight/ili9320.h +++ b/drivers/video/backlight/ili9320.h | |||
@@ -76,5 +76,5 @@ extern void ili9320_shutdown(struct ili9320 *lcd); | |||
76 | 76 | ||
77 | /* PM */ | 77 | /* PM */ |
78 | 78 | ||
79 | extern int ili9320_suspend(struct ili9320 *lcd, pm_message_t state); | 79 | extern int ili9320_suspend(struct ili9320 *lcd); |
80 | extern int ili9320_resume(struct ili9320 *lcd); | 80 | extern int ili9320_resume(struct ili9320 *lcd); |
diff --git a/drivers/video/backlight/jornada720_bl.c b/drivers/video/backlight/jornada720_bl.c index fef6ce4fad71..3ccb89340f22 100644 --- a/drivers/video/backlight/jornada720_bl.c +++ b/drivers/video/backlight/jornada720_bl.c | |||
@@ -9,8 +9,6 @@ | |||
9 | * | 9 | * |
10 | */ | 10 | */ |
11 | 11 | ||
12 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
13 | |||
14 | #include <linux/backlight.h> | 12 | #include <linux/backlight.h> |
15 | #include <linux/device.h> | 13 | #include <linux/device.h> |
16 | #include <linux/fb.h> | 14 | #include <linux/fb.h> |
@@ -40,11 +38,13 @@ static int jornada_bl_get_brightness(struct backlight_device *bd) | |||
40 | ret = jornada_ssp_byte(GETBRIGHTNESS); | 38 | ret = jornada_ssp_byte(GETBRIGHTNESS); |
41 | 39 | ||
42 | if (jornada_ssp_byte(GETBRIGHTNESS) != TXDUMMY) { | 40 | if (jornada_ssp_byte(GETBRIGHTNESS) != TXDUMMY) { |
43 | pr_err("get brightness timeout\n"); | 41 | dev_err(&bd->dev, "get brightness timeout\n"); |
44 | jornada_ssp_end(); | 42 | jornada_ssp_end(); |
45 | return -ETIMEDOUT; | 43 | return -ETIMEDOUT; |
46 | } else /* exchange txdummy for value */ | 44 | } else { |
45 | /* exchange txdummy for value */ | ||
47 | ret = jornada_ssp_byte(TXDUMMY); | 46 | ret = jornada_ssp_byte(TXDUMMY); |
47 | } | ||
48 | 48 | ||
49 | jornada_ssp_end(); | 49 | jornada_ssp_end(); |
50 | 50 | ||
@@ -61,7 +61,7 @@ static int jornada_bl_update_status(struct backlight_device *bd) | |||
61 | if ((bd->props.power != FB_BLANK_UNBLANK) || (bd->props.fb_blank != FB_BLANK_UNBLANK)) { | 61 | if ((bd->props.power != FB_BLANK_UNBLANK) || (bd->props.fb_blank != FB_BLANK_UNBLANK)) { |
62 | ret = jornada_ssp_byte(BRIGHTNESSOFF); | 62 | ret = jornada_ssp_byte(BRIGHTNESSOFF); |
63 | if (ret != TXDUMMY) { | 63 | if (ret != TXDUMMY) { |
64 | pr_info("brightness off timeout\n"); | 64 | dev_info(&bd->dev, "brightness off timeout\n"); |
65 | /* turn off backlight */ | 65 | /* turn off backlight */ |
66 | PPSR &= ~PPC_LDD1; | 66 | PPSR &= ~PPC_LDD1; |
67 | PPDR |= PPC_LDD1; | 67 | PPDR |= PPC_LDD1; |
@@ -72,7 +72,7 @@ static int jornada_bl_update_status(struct backlight_device *bd) | |||
72 | 72 | ||
73 | /* send command to our mcu */ | 73 | /* send command to our mcu */ |
74 | if (jornada_ssp_byte(SETBRIGHTNESS) != TXDUMMY) { | 74 | if (jornada_ssp_byte(SETBRIGHTNESS) != TXDUMMY) { |
75 | pr_info("failed to set brightness\n"); | 75 | dev_info(&bd->dev, "failed to set brightness\n"); |
76 | ret = -ETIMEDOUT; | 76 | ret = -ETIMEDOUT; |
77 | goto out; | 77 | goto out; |
78 | } | 78 | } |
@@ -86,7 +86,7 @@ static int jornada_bl_update_status(struct backlight_device *bd) | |||
86 | */ | 86 | */ |
87 | if (jornada_ssp_byte(BL_MAX_BRIGHT - bd->props.brightness) | 87 | if (jornada_ssp_byte(BL_MAX_BRIGHT - bd->props.brightness) |
88 | != TXDUMMY) { | 88 | != TXDUMMY) { |
89 | pr_err("set brightness failed\n"); | 89 | dev_err(&bd->dev, "set brightness failed\n"); |
90 | ret = -ETIMEDOUT; | 90 | ret = -ETIMEDOUT; |
91 | } | 91 | } |
92 | 92 | ||
@@ -120,7 +120,7 @@ static int jornada_bl_probe(struct platform_device *pdev) | |||
120 | 120 | ||
121 | if (IS_ERR(bd)) { | 121 | if (IS_ERR(bd)) { |
122 | ret = PTR_ERR(bd); | 122 | ret = PTR_ERR(bd); |
123 | pr_err("failed to register device, err=%x\n", ret); | 123 | dev_err(&pdev->dev, "failed to register device, err=%x\n", ret); |
124 | return ret; | 124 | return ret; |
125 | } | 125 | } |
126 | 126 | ||
@@ -134,7 +134,7 @@ static int jornada_bl_probe(struct platform_device *pdev) | |||
134 | jornada_bl_update_status(bd); | 134 | jornada_bl_update_status(bd); |
135 | 135 | ||
136 | platform_set_drvdata(pdev, bd); | 136 | platform_set_drvdata(pdev, bd); |
137 | pr_info("HP Jornada 700 series backlight driver\n"); | 137 | dev_info(&pdev->dev, "HP Jornada 700 series backlight driver\n"); |
138 | 138 | ||
139 | return 0; | 139 | return 0; |
140 | } | 140 | } |
diff --git a/drivers/video/backlight/jornada720_lcd.c b/drivers/video/backlight/jornada720_lcd.c index 635b30523fd5..b061413f1a65 100644 --- a/drivers/video/backlight/jornada720_lcd.c +++ b/drivers/video/backlight/jornada720_lcd.c | |||
@@ -9,8 +9,6 @@ | |||
9 | * | 9 | * |
10 | */ | 10 | */ |
11 | 11 | ||
12 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
13 | |||
14 | #include <linux/device.h> | 12 | #include <linux/device.h> |
15 | #include <linux/fb.h> | 13 | #include <linux/fb.h> |
16 | #include <linux/kernel.h> | 14 | #include <linux/kernel.h> |
@@ -27,7 +25,7 @@ | |||
27 | #define LCD_MAX_CONTRAST 0xff | 25 | #define LCD_MAX_CONTRAST 0xff |
28 | #define LCD_DEF_CONTRAST 0x80 | 26 | #define LCD_DEF_CONTRAST 0x80 |
29 | 27 | ||
30 | static int jornada_lcd_get_power(struct lcd_device *dev) | 28 | static int jornada_lcd_get_power(struct lcd_device *ld) |
31 | { | 29 | { |
32 | /* LDD2 in PPC = LCD POWER */ | 30 | /* LDD2 in PPC = LCD POWER */ |
33 | if (PPSR & PPC_LDD2) | 31 | if (PPSR & PPC_LDD2) |
@@ -36,17 +34,17 @@ static int jornada_lcd_get_power(struct lcd_device *dev) | |||
36 | return FB_BLANK_POWERDOWN; /* PW OFF */ | 34 | return FB_BLANK_POWERDOWN; /* PW OFF */ |
37 | } | 35 | } |
38 | 36 | ||
39 | static int jornada_lcd_get_contrast(struct lcd_device *dev) | 37 | static int jornada_lcd_get_contrast(struct lcd_device *ld) |
40 | { | 38 | { |
41 | int ret; | 39 | int ret; |
42 | 40 | ||
43 | if (jornada_lcd_get_power(dev) != FB_BLANK_UNBLANK) | 41 | if (jornada_lcd_get_power(ld) != FB_BLANK_UNBLANK) |
44 | return 0; | 42 | return 0; |
45 | 43 | ||
46 | jornada_ssp_start(); | 44 | jornada_ssp_start(); |
47 | 45 | ||
48 | if (jornada_ssp_byte(GETCONTRAST) != TXDUMMY) { | 46 | if (jornada_ssp_byte(GETCONTRAST) != TXDUMMY) { |
49 | pr_err("get contrast failed\n"); | 47 | dev_err(&ld->dev, "get contrast failed\n"); |
50 | jornada_ssp_end(); | 48 | jornada_ssp_end(); |
51 | return -ETIMEDOUT; | 49 | return -ETIMEDOUT; |
52 | } else { | 50 | } else { |
@@ -56,7 +54,7 @@ static int jornada_lcd_get_contrast(struct lcd_device *dev) | |||
56 | } | 54 | } |
57 | } | 55 | } |
58 | 56 | ||
59 | static int jornada_lcd_set_contrast(struct lcd_device *dev, int value) | 57 | static int jornada_lcd_set_contrast(struct lcd_device *ld, int value) |
60 | { | 58 | { |
61 | int ret; | 59 | int ret; |
62 | 60 | ||
@@ -67,7 +65,7 @@ static int jornada_lcd_set_contrast(struct lcd_device *dev, int value) | |||
67 | 65 | ||
68 | /* push the new value */ | 66 | /* push the new value */ |
69 | if (jornada_ssp_byte(value) != TXDUMMY) { | 67 | if (jornada_ssp_byte(value) != TXDUMMY) { |
70 | pr_err("set contrast failed\n"); | 68 | dev_err(&ld->dev, "set contrast failed\n"); |
71 | jornada_ssp_end(); | 69 | jornada_ssp_end(); |
72 | return -ETIMEDOUT; | 70 | return -ETIMEDOUT; |
73 | } | 71 | } |
@@ -78,13 +76,14 @@ static int jornada_lcd_set_contrast(struct lcd_device *dev, int value) | |||
78 | return 0; | 76 | return 0; |
79 | } | 77 | } |
80 | 78 | ||
81 | static int jornada_lcd_set_power(struct lcd_device *dev, int power) | 79 | static int jornada_lcd_set_power(struct lcd_device *ld, int power) |
82 | { | 80 | { |
83 | if (power != FB_BLANK_UNBLANK) { | 81 | if (power != FB_BLANK_UNBLANK) { |
84 | PPSR &= ~PPC_LDD2; | 82 | PPSR &= ~PPC_LDD2; |
85 | PPDR |= PPC_LDD2; | 83 | PPDR |= PPC_LDD2; |
86 | } else | 84 | } else { |
87 | PPSR |= PPC_LDD2; | 85 | PPSR |= PPC_LDD2; |
86 | } | ||
88 | 87 | ||
89 | return 0; | 88 | return 0; |
90 | } | 89 | } |
@@ -105,7 +104,7 @@ static int jornada_lcd_probe(struct platform_device *pdev) | |||
105 | 104 | ||
106 | if (IS_ERR(lcd_device)) { | 105 | if (IS_ERR(lcd_device)) { |
107 | ret = PTR_ERR(lcd_device); | 106 | ret = PTR_ERR(lcd_device); |
108 | pr_err("failed to register device\n"); | 107 | dev_err(&pdev->dev, "failed to register device\n"); |
109 | return ret; | 108 | return ret; |
110 | } | 109 | } |
111 | 110 | ||
diff --git a/drivers/video/backlight/kb3886_bl.c b/drivers/video/backlight/kb3886_bl.c index 6c5ed6b242cc..bca6ccc74dfb 100644 --- a/drivers/video/backlight/kb3886_bl.c +++ b/drivers/video/backlight/kb3886_bl.c | |||
@@ -106,29 +106,28 @@ static int kb3886bl_send_intensity(struct backlight_device *bd) | |||
106 | return 0; | 106 | return 0; |
107 | } | 107 | } |
108 | 108 | ||
109 | #ifdef CONFIG_PM | 109 | #ifdef CONFIG_PM_SLEEP |
110 | static int kb3886bl_suspend(struct platform_device *pdev, pm_message_t state) | 110 | static int kb3886bl_suspend(struct device *dev) |
111 | { | 111 | { |
112 | struct backlight_device *bd = platform_get_drvdata(pdev); | 112 | struct backlight_device *bd = dev_get_drvdata(dev); |
113 | 113 | ||
114 | kb3886bl_flags |= KB3886BL_SUSPENDED; | 114 | kb3886bl_flags |= KB3886BL_SUSPENDED; |
115 | backlight_update_status(bd); | 115 | backlight_update_status(bd); |
116 | return 0; | 116 | return 0; |
117 | } | 117 | } |
118 | 118 | ||
119 | static int kb3886bl_resume(struct platform_device *pdev) | 119 | static int kb3886bl_resume(struct device *dev) |
120 | { | 120 | { |
121 | struct backlight_device *bd = platform_get_drvdata(pdev); | 121 | struct backlight_device *bd = dev_get_drvdata(dev); |
122 | 122 | ||
123 | kb3886bl_flags &= ~KB3886BL_SUSPENDED; | 123 | kb3886bl_flags &= ~KB3886BL_SUSPENDED; |
124 | backlight_update_status(bd); | 124 | backlight_update_status(bd); |
125 | return 0; | 125 | return 0; |
126 | } | 126 | } |
127 | #else | ||
128 | #define kb3886bl_suspend NULL | ||
129 | #define kb3886bl_resume NULL | ||
130 | #endif | 127 | #endif |
131 | 128 | ||
129 | static SIMPLE_DEV_PM_OPS(kb3886bl_pm_ops, kb3886bl_suspend, kb3886bl_resume); | ||
130 | |||
132 | static int kb3886bl_get_intensity(struct backlight_device *bd) | 131 | static int kb3886bl_get_intensity(struct backlight_device *bd) |
133 | { | 132 | { |
134 | return kb3886bl_intensity; | 133 | return kb3886bl_intensity; |
@@ -179,10 +178,9 @@ static int kb3886bl_remove(struct platform_device *pdev) | |||
179 | static struct platform_driver kb3886bl_driver = { | 178 | static struct platform_driver kb3886bl_driver = { |
180 | .probe = kb3886bl_probe, | 179 | .probe = kb3886bl_probe, |
181 | .remove = kb3886bl_remove, | 180 | .remove = kb3886bl_remove, |
182 | .suspend = kb3886bl_suspend, | ||
183 | .resume = kb3886bl_resume, | ||
184 | .driver = { | 181 | .driver = { |
185 | .name = "kb3886-bl", | 182 | .name = "kb3886-bl", |
183 | .pm = &kb3886bl_pm_ops, | ||
186 | }, | 184 | }, |
187 | }; | 185 | }; |
188 | 186 | ||
diff --git a/drivers/video/backlight/l4f00242t03.c b/drivers/video/backlight/l4f00242t03.c index fb6155771326..a35a38c709cf 100644 --- a/drivers/video/backlight/l4f00242t03.c +++ b/drivers/video/backlight/l4f00242t03.c | |||
@@ -51,14 +51,33 @@ static void l4f00242t03_lcd_init(struct spi_device *spi) | |||
51 | struct l4f00242t03_pdata *pdata = spi->dev.platform_data; | 51 | struct l4f00242t03_pdata *pdata = spi->dev.platform_data; |
52 | struct l4f00242t03_priv *priv = spi_get_drvdata(spi); | 52 | struct l4f00242t03_priv *priv = spi_get_drvdata(spi); |
53 | const u16 cmd[] = { 0x36, param(0), 0x3A, param(0x60) }; | 53 | const u16 cmd[] = { 0x36, param(0), 0x3A, param(0x60) }; |
54 | int ret; | ||
54 | 55 | ||
55 | dev_dbg(&spi->dev, "initializing LCD\n"); | 56 | dev_dbg(&spi->dev, "initializing LCD\n"); |
56 | 57 | ||
57 | regulator_set_voltage(priv->io_reg, 1800000, 1800000); | 58 | ret = regulator_set_voltage(priv->io_reg, 1800000, 1800000); |
58 | regulator_enable(priv->io_reg); | 59 | if (ret) { |
60 | dev_err(&spi->dev, "failed to set the IO regulator voltage.\n"); | ||
61 | return; | ||
62 | } | ||
63 | ret = regulator_enable(priv->io_reg); | ||
64 | if (ret) { | ||
65 | dev_err(&spi->dev, "failed to enable the IO regulator.\n"); | ||
66 | return; | ||
67 | } | ||
59 | 68 | ||
60 | regulator_set_voltage(priv->core_reg, 2800000, 2800000); | 69 | ret = regulator_set_voltage(priv->core_reg, 2800000, 2800000); |
61 | regulator_enable(priv->core_reg); | 70 | if (ret) { |
71 | dev_err(&spi->dev, "failed to set the core regulator voltage.\n"); | ||
72 | regulator_disable(priv->io_reg); | ||
73 | return; | ||
74 | } | ||
75 | ret = regulator_enable(priv->core_reg); | ||
76 | if (ret) { | ||
77 | dev_err(&spi->dev, "failed to enable the core regulator.\n"); | ||
78 | regulator_disable(priv->io_reg); | ||
79 | return; | ||
80 | } | ||
62 | 81 | ||
63 | l4f00242t03_reset(pdata->reset_gpio); | 82 | l4f00242t03_reset(pdata->reset_gpio); |
64 | 83 | ||
diff --git a/drivers/video/backlight/ld9040.c b/drivers/video/backlight/ld9040.c index 1b642f5f381a..1e0a3093ce50 100644 --- a/drivers/video/backlight/ld9040.c +++ b/drivers/video/backlight/ld9040.c | |||
@@ -775,12 +775,12 @@ static int ld9040_remove(struct spi_device *spi) | |||
775 | return 0; | 775 | return 0; |
776 | } | 776 | } |
777 | 777 | ||
778 | #if defined(CONFIG_PM) | 778 | #ifdef CONFIG_PM_SLEEP |
779 | static int ld9040_suspend(struct spi_device *spi, pm_message_t mesg) | 779 | static int ld9040_suspend(struct device *dev) |
780 | { | 780 | { |
781 | struct ld9040 *lcd = spi_get_drvdata(spi); | 781 | struct ld9040 *lcd = dev_get_drvdata(dev); |
782 | 782 | ||
783 | dev_dbg(&spi->dev, "lcd->power = %d\n", lcd->power); | 783 | dev_dbg(dev, "lcd->power = %d\n", lcd->power); |
784 | 784 | ||
785 | /* | 785 | /* |
786 | * when lcd panel is suspend, lcd panel becomes off | 786 | * when lcd panel is suspend, lcd panel becomes off |
@@ -789,19 +789,18 @@ static int ld9040_suspend(struct spi_device *spi, pm_message_t mesg) | |||
789 | return ld9040_power(lcd, FB_BLANK_POWERDOWN); | 789 | return ld9040_power(lcd, FB_BLANK_POWERDOWN); |
790 | } | 790 | } |
791 | 791 | ||
792 | static int ld9040_resume(struct spi_device *spi) | 792 | static int ld9040_resume(struct device *dev) |
793 | { | 793 | { |
794 | struct ld9040 *lcd = spi_get_drvdata(spi); | 794 | struct ld9040 *lcd = dev_get_drvdata(dev); |
795 | 795 | ||
796 | lcd->power = FB_BLANK_POWERDOWN; | 796 | lcd->power = FB_BLANK_POWERDOWN; |
797 | 797 | ||
798 | return ld9040_power(lcd, FB_BLANK_UNBLANK); | 798 | return ld9040_power(lcd, FB_BLANK_UNBLANK); |
799 | } | 799 | } |
800 | #else | ||
801 | #define ld9040_suspend NULL | ||
802 | #define ld9040_resume NULL | ||
803 | #endif | 800 | #endif |
804 | 801 | ||
802 | static SIMPLE_DEV_PM_OPS(ld9040_pm_ops, ld9040_suspend, ld9040_resume); | ||
803 | |||
805 | /* Power down all displays on reboot, poweroff or halt. */ | 804 | /* Power down all displays on reboot, poweroff or halt. */ |
806 | static void ld9040_shutdown(struct spi_device *spi) | 805 | static void ld9040_shutdown(struct spi_device *spi) |
807 | { | 806 | { |
@@ -814,12 +813,11 @@ static struct spi_driver ld9040_driver = { | |||
814 | .driver = { | 813 | .driver = { |
815 | .name = "ld9040", | 814 | .name = "ld9040", |
816 | .owner = THIS_MODULE, | 815 | .owner = THIS_MODULE, |
816 | .pm = &ld9040_pm_ops, | ||
817 | }, | 817 | }, |
818 | .probe = ld9040_probe, | 818 | .probe = ld9040_probe, |
819 | .remove = ld9040_remove, | 819 | .remove = ld9040_remove, |
820 | .shutdown = ld9040_shutdown, | 820 | .shutdown = ld9040_shutdown, |
821 | .suspend = ld9040_suspend, | ||
822 | .resume = ld9040_resume, | ||
823 | }; | 821 | }; |
824 | 822 | ||
825 | module_spi_driver(ld9040_driver); | 823 | module_spi_driver(ld9040_driver); |
diff --git a/drivers/video/backlight/lm3533_bl.c b/drivers/video/backlight/lm3533_bl.c index 5d18d4d7f470..1d1dbfb789e3 100644 --- a/drivers/video/backlight/lm3533_bl.c +++ b/drivers/video/backlight/lm3533_bl.c | |||
@@ -368,29 +368,28 @@ static int lm3533_bl_remove(struct platform_device *pdev) | |||
368 | return 0; | 368 | return 0; |
369 | } | 369 | } |
370 | 370 | ||
371 | #ifdef CONFIG_PM | 371 | #ifdef CONFIG_PM_SLEEP |
372 | static int lm3533_bl_suspend(struct platform_device *pdev, pm_message_t state) | 372 | static int lm3533_bl_suspend(struct device *dev) |
373 | { | 373 | { |
374 | struct lm3533_bl *bl = platform_get_drvdata(pdev); | 374 | struct lm3533_bl *bl = dev_get_drvdata(dev); |
375 | 375 | ||
376 | dev_dbg(&pdev->dev, "%s\n", __func__); | 376 | dev_dbg(dev, "%s\n", __func__); |
377 | 377 | ||
378 | return lm3533_ctrlbank_disable(&bl->cb); | 378 | return lm3533_ctrlbank_disable(&bl->cb); |
379 | } | 379 | } |
380 | 380 | ||
381 | static int lm3533_bl_resume(struct platform_device *pdev) | 381 | static int lm3533_bl_resume(struct device *dev) |
382 | { | 382 | { |
383 | struct lm3533_bl *bl = platform_get_drvdata(pdev); | 383 | struct lm3533_bl *bl = dev_get_drvdata(dev); |
384 | 384 | ||
385 | dev_dbg(&pdev->dev, "%s\n", __func__); | 385 | dev_dbg(dev, "%s\n", __func__); |
386 | 386 | ||
387 | return lm3533_ctrlbank_enable(&bl->cb); | 387 | return lm3533_ctrlbank_enable(&bl->cb); |
388 | } | 388 | } |
389 | #else | ||
390 | #define lm3533_bl_suspend NULL | ||
391 | #define lm3533_bl_resume NULL | ||
392 | #endif | 389 | #endif |
393 | 390 | ||
391 | static SIMPLE_DEV_PM_OPS(lm3533_bl_pm_ops, lm3533_bl_suspend, lm3533_bl_resume); | ||
392 | |||
394 | static void lm3533_bl_shutdown(struct platform_device *pdev) | 393 | static void lm3533_bl_shutdown(struct platform_device *pdev) |
395 | { | 394 | { |
396 | struct lm3533_bl *bl = platform_get_drvdata(pdev); | 395 | struct lm3533_bl *bl = platform_get_drvdata(pdev); |
@@ -404,12 +403,11 @@ static struct platform_driver lm3533_bl_driver = { | |||
404 | .driver = { | 403 | .driver = { |
405 | .name = "lm3533-backlight", | 404 | .name = "lm3533-backlight", |
406 | .owner = THIS_MODULE, | 405 | .owner = THIS_MODULE, |
406 | .pm = &lm3533_bl_pm_ops, | ||
407 | }, | 407 | }, |
408 | .probe = lm3533_bl_probe, | 408 | .probe = lm3533_bl_probe, |
409 | .remove = lm3533_bl_remove, | 409 | .remove = lm3533_bl_remove, |
410 | .shutdown = lm3533_bl_shutdown, | 410 | .shutdown = lm3533_bl_shutdown, |
411 | .suspend = lm3533_bl_suspend, | ||
412 | .resume = lm3533_bl_resume, | ||
413 | }; | 411 | }; |
414 | module_platform_driver(lm3533_bl_driver); | 412 | module_platform_driver(lm3533_bl_driver); |
415 | 413 | ||
diff --git a/drivers/video/backlight/lms501kf03.c b/drivers/video/backlight/lms501kf03.c index b43882abefaf..cf01b9ac8131 100644 --- a/drivers/video/backlight/lms501kf03.c +++ b/drivers/video/backlight/lms501kf03.c | |||
@@ -387,13 +387,12 @@ static int lms501kf03_remove(struct spi_device *spi) | |||
387 | return 0; | 387 | return 0; |
388 | } | 388 | } |
389 | 389 | ||
390 | #if defined(CONFIG_PM) | 390 | #ifdef CONFIG_PM_SLEEP |
391 | 391 | static int lms501kf03_suspend(struct device *dev) | |
392 | static int lms501kf03_suspend(struct spi_device *spi, pm_message_t mesg) | ||
393 | { | 392 | { |
394 | struct lms501kf03 *lcd = spi_get_drvdata(spi); | 393 | struct lms501kf03 *lcd = dev_get_drvdata(dev); |
395 | 394 | ||
396 | dev_dbg(&spi->dev, "lcd->power = %d\n", lcd->power); | 395 | dev_dbg(dev, "lcd->power = %d\n", lcd->power); |
397 | 396 | ||
398 | /* | 397 | /* |
399 | * when lcd panel is suspend, lcd panel becomes off | 398 | * when lcd panel is suspend, lcd panel becomes off |
@@ -402,19 +401,19 @@ static int lms501kf03_suspend(struct spi_device *spi, pm_message_t mesg) | |||
402 | return lms501kf03_power(lcd, FB_BLANK_POWERDOWN); | 401 | return lms501kf03_power(lcd, FB_BLANK_POWERDOWN); |
403 | } | 402 | } |
404 | 403 | ||
405 | static int lms501kf03_resume(struct spi_device *spi) | 404 | static int lms501kf03_resume(struct device *dev) |
406 | { | 405 | { |
407 | struct lms501kf03 *lcd = spi_get_drvdata(spi); | 406 | struct lms501kf03 *lcd = dev_get_drvdata(dev); |
408 | 407 | ||
409 | lcd->power = FB_BLANK_POWERDOWN; | 408 | lcd->power = FB_BLANK_POWERDOWN; |
410 | 409 | ||
411 | return lms501kf03_power(lcd, FB_BLANK_UNBLANK); | 410 | return lms501kf03_power(lcd, FB_BLANK_UNBLANK); |
412 | } | 411 | } |
413 | #else | ||
414 | #define lms501kf03_suspend NULL | ||
415 | #define lms501kf03_resume NULL | ||
416 | #endif | 412 | #endif |
417 | 413 | ||
414 | static SIMPLE_DEV_PM_OPS(lms501kf03_pm_ops, lms501kf03_suspend, | ||
415 | lms501kf03_resume); | ||
416 | |||
418 | static void lms501kf03_shutdown(struct spi_device *spi) | 417 | static void lms501kf03_shutdown(struct spi_device *spi) |
419 | { | 418 | { |
420 | struct lms501kf03 *lcd = spi_get_drvdata(spi); | 419 | struct lms501kf03 *lcd = spi_get_drvdata(spi); |
@@ -426,12 +425,11 @@ static struct spi_driver lms501kf03_driver = { | |||
426 | .driver = { | 425 | .driver = { |
427 | .name = "lms501kf03", | 426 | .name = "lms501kf03", |
428 | .owner = THIS_MODULE, | 427 | .owner = THIS_MODULE, |
428 | .pm = &lms501kf03_pm_ops, | ||
429 | }, | 429 | }, |
430 | .probe = lms501kf03_probe, | 430 | .probe = lms501kf03_probe, |
431 | .remove = lms501kf03_remove, | 431 | .remove = lms501kf03_remove, |
432 | .shutdown = lms501kf03_shutdown, | 432 | .shutdown = lms501kf03_shutdown, |
433 | .suspend = lms501kf03_suspend, | ||
434 | .resume = lms501kf03_resume, | ||
435 | }; | 433 | }; |
436 | 434 | ||
437 | module_spi_driver(lms501kf03_driver); | 435 | module_spi_driver(lms501kf03_driver); |
diff --git a/drivers/video/backlight/locomolcd.c b/drivers/video/backlight/locomolcd.c index 146fea8aa431..6c3ec4259a60 100644 --- a/drivers/video/backlight/locomolcd.c +++ b/drivers/video/backlight/locomolcd.c | |||
@@ -157,25 +157,24 @@ static const struct backlight_ops locomobl_data = { | |||
157 | .update_status = locomolcd_set_intensity, | 157 | .update_status = locomolcd_set_intensity, |
158 | }; | 158 | }; |
159 | 159 | ||
160 | #ifdef CONFIG_PM | 160 | #ifdef CONFIG_PM_SLEEP |
161 | static int locomolcd_suspend(struct locomo_dev *dev, pm_message_t state) | 161 | static int locomolcd_suspend(struct device *dev) |
162 | { | 162 | { |
163 | locomolcd_flags |= LOCOMOLCD_SUSPENDED; | 163 | locomolcd_flags |= LOCOMOLCD_SUSPENDED; |
164 | locomolcd_set_intensity(locomolcd_bl_device); | 164 | locomolcd_set_intensity(locomolcd_bl_device); |
165 | return 0; | 165 | return 0; |
166 | } | 166 | } |
167 | 167 | ||
168 | static int locomolcd_resume(struct locomo_dev *dev) | 168 | static int locomolcd_resume(struct device *dev) |
169 | { | 169 | { |
170 | locomolcd_flags &= ~LOCOMOLCD_SUSPENDED; | 170 | locomolcd_flags &= ~LOCOMOLCD_SUSPENDED; |
171 | locomolcd_set_intensity(locomolcd_bl_device); | 171 | locomolcd_set_intensity(locomolcd_bl_device); |
172 | return 0; | 172 | return 0; |
173 | } | 173 | } |
174 | #else | ||
175 | #define locomolcd_suspend NULL | ||
176 | #define locomolcd_resume NULL | ||
177 | #endif | 174 | #endif |
178 | 175 | ||
176 | static SIMPLE_DEV_PM_OPS(locomolcd_pm_ops, locomolcd_suspend, locomolcd_resume); | ||
177 | |||
179 | static int locomolcd_probe(struct locomo_dev *ldev) | 178 | static int locomolcd_probe(struct locomo_dev *ldev) |
180 | { | 179 | { |
181 | struct backlight_properties props; | 180 | struct backlight_properties props; |
@@ -230,13 +229,12 @@ static int locomolcd_remove(struct locomo_dev *dev) | |||
230 | 229 | ||
231 | static struct locomo_driver poodle_lcd_driver = { | 230 | static struct locomo_driver poodle_lcd_driver = { |
232 | .drv = { | 231 | .drv = { |
233 | .name = "locomo-backlight", | 232 | .name = "locomo-backlight", |
233 | .pm = &locomolcd_pm_ops, | ||
234 | }, | 234 | }, |
235 | .devid = LOCOMO_DEVID_BACKLIGHT, | 235 | .devid = LOCOMO_DEVID_BACKLIGHT, |
236 | .probe = locomolcd_probe, | 236 | .probe = locomolcd_probe, |
237 | .remove = locomolcd_remove, | 237 | .remove = locomolcd_remove, |
238 | .suspend = locomolcd_suspend, | ||
239 | .resume = locomolcd_resume, | ||
240 | }; | 238 | }; |
241 | 239 | ||
242 | static int __init locomolcd_init(void) | 240 | static int __init locomolcd_init(void) |
diff --git a/drivers/video/backlight/lp855x_bl.c b/drivers/video/backlight/lp855x_bl.c index 7ae9ae6f4655..a0e1e02bdc2e 100644 --- a/drivers/video/backlight/lp855x_bl.c +++ b/drivers/video/backlight/lp855x_bl.c | |||
@@ -14,6 +14,7 @@ | |||
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/of.h> | ||
17 | #include <linux/platform_data/lp855x.h> | 18 | #include <linux/platform_data/lp855x.h> |
18 | #include <linux/pwm.h> | 19 | #include <linux/pwm.h> |
19 | 20 | ||
@@ -35,10 +36,14 @@ | |||
35 | #define LP8557_EPROM_START 0x10 | 36 | #define LP8557_EPROM_START 0x10 |
36 | #define LP8557_EPROM_END 0x1E | 37 | #define LP8557_EPROM_END 0x1E |
37 | 38 | ||
38 | #define BUF_SIZE 20 | ||
39 | #define DEFAULT_BL_NAME "lcd-backlight" | 39 | #define DEFAULT_BL_NAME "lcd-backlight" |
40 | #define MAX_BRIGHTNESS 255 | 40 | #define MAX_BRIGHTNESS 255 |
41 | 41 | ||
42 | enum lp855x_brightness_ctrl_mode { | ||
43 | PWM_BASED = 1, | ||
44 | REGISTER_BASED, | ||
45 | }; | ||
46 | |||
42 | struct lp855x; | 47 | struct lp855x; |
43 | 48 | ||
44 | /* | 49 | /* |
@@ -58,6 +63,7 @@ struct lp855x_device_config { | |||
58 | struct lp855x { | 63 | struct lp855x { |
59 | const char *chipname; | 64 | const char *chipname; |
60 | enum lp855x_chip_id chip_id; | 65 | enum lp855x_chip_id chip_id; |
66 | enum lp855x_brightness_ctrl_mode mode; | ||
61 | struct lp855x_device_config *cfg; | 67 | struct lp855x_device_config *cfg; |
62 | struct i2c_client *client; | 68 | struct i2c_client *client; |
63 | struct backlight_device *bl; | 69 | struct backlight_device *bl; |
@@ -187,7 +193,7 @@ static int lp855x_configure(struct lp855x *lp) | |||
187 | if (ret) | 193 | if (ret) |
188 | goto err; | 194 | goto err; |
189 | 195 | ||
190 | if (pd->load_new_rom_data && pd->size_program) { | 196 | if (pd->size_program > 0) { |
191 | for (i = 0; i < pd->size_program; i++) { | 197 | for (i = 0; i < pd->size_program; i++) { |
192 | addr = pd->rom_data[i].addr; | 198 | addr = pd->rom_data[i].addr; |
193 | val = pd->rom_data[i].val; | 199 | val = pd->rom_data[i].val; |
@@ -239,18 +245,17 @@ static void lp855x_pwm_ctrl(struct lp855x *lp, int br, int max_br) | |||
239 | static int lp855x_bl_update_status(struct backlight_device *bl) | 245 | static int lp855x_bl_update_status(struct backlight_device *bl) |
240 | { | 246 | { |
241 | struct lp855x *lp = bl_get_data(bl); | 247 | struct lp855x *lp = bl_get_data(bl); |
242 | enum lp855x_brightness_ctrl_mode mode = lp->pdata->mode; | ||
243 | 248 | ||
244 | if (bl->props.state & BL_CORE_SUSPENDED) | 249 | if (bl->props.state & BL_CORE_SUSPENDED) |
245 | bl->props.brightness = 0; | 250 | bl->props.brightness = 0; |
246 | 251 | ||
247 | if (mode == PWM_BASED) { | 252 | if (lp->mode == PWM_BASED) { |
248 | int br = bl->props.brightness; | 253 | int br = bl->props.brightness; |
249 | int max_br = bl->props.max_brightness; | 254 | int max_br = bl->props.max_brightness; |
250 | 255 | ||
251 | lp855x_pwm_ctrl(lp, br, max_br); | 256 | lp855x_pwm_ctrl(lp, br, max_br); |
252 | 257 | ||
253 | } else if (mode == REGISTER_BASED) { | 258 | } else if (lp->mode == REGISTER_BASED) { |
254 | u8 val = bl->props.brightness; | 259 | u8 val = bl->props.brightness; |
255 | lp855x_write_byte(lp, lp->cfg->reg_brightness, val); | 260 | lp855x_write_byte(lp, lp->cfg->reg_brightness, val); |
256 | } | 261 | } |
@@ -274,7 +279,7 @@ static int lp855x_backlight_register(struct lp855x *lp) | |||
274 | struct backlight_device *bl; | 279 | struct backlight_device *bl; |
275 | struct backlight_properties props; | 280 | struct backlight_properties props; |
276 | struct lp855x_platform_data *pdata = lp->pdata; | 281 | struct lp855x_platform_data *pdata = lp->pdata; |
277 | char *name = pdata->name ? : DEFAULT_BL_NAME; | 282 | const char *name = pdata->name ? : DEFAULT_BL_NAME; |
278 | 283 | ||
279 | props.type = BACKLIGHT_PLATFORM; | 284 | props.type = BACKLIGHT_PLATFORM; |
280 | props.max_brightness = MAX_BRIGHTNESS; | 285 | props.max_brightness = MAX_BRIGHTNESS; |
@@ -304,22 +309,21 @@ static ssize_t lp855x_get_chip_id(struct device *dev, | |||
304 | struct device_attribute *attr, char *buf) | 309 | struct device_attribute *attr, char *buf) |
305 | { | 310 | { |
306 | struct lp855x *lp = dev_get_drvdata(dev); | 311 | struct lp855x *lp = dev_get_drvdata(dev); |
307 | return scnprintf(buf, BUF_SIZE, "%s\n", lp->chipname); | 312 | return scnprintf(buf, PAGE_SIZE, "%s\n", lp->chipname); |
308 | } | 313 | } |
309 | 314 | ||
310 | static ssize_t lp855x_get_bl_ctl_mode(struct device *dev, | 315 | static ssize_t lp855x_get_bl_ctl_mode(struct device *dev, |
311 | struct device_attribute *attr, char *buf) | 316 | struct device_attribute *attr, char *buf) |
312 | { | 317 | { |
313 | struct lp855x *lp = dev_get_drvdata(dev); | 318 | struct lp855x *lp = dev_get_drvdata(dev); |
314 | enum lp855x_brightness_ctrl_mode mode = lp->pdata->mode; | ||
315 | char *strmode = NULL; | 319 | char *strmode = NULL; |
316 | 320 | ||
317 | if (mode == PWM_BASED) | 321 | if (lp->mode == PWM_BASED) |
318 | strmode = "pwm based"; | 322 | strmode = "pwm based"; |
319 | else if (mode == REGISTER_BASED) | 323 | else if (lp->mode == REGISTER_BASED) |
320 | strmode = "register based"; | 324 | strmode = "register based"; |
321 | 325 | ||
322 | return scnprintf(buf, BUF_SIZE, "%s\n", strmode); | 326 | return scnprintf(buf, PAGE_SIZE, "%s\n", strmode); |
323 | } | 327 | } |
324 | 328 | ||
325 | static DEVICE_ATTR(chip_id, S_IRUGO, lp855x_get_chip_id, NULL); | 329 | static DEVICE_ATTR(chip_id, S_IRUGO, lp855x_get_chip_id, NULL); |
@@ -335,16 +339,71 @@ static const struct attribute_group lp855x_attr_group = { | |||
335 | .attrs = lp855x_attributes, | 339 | .attrs = lp855x_attributes, |
336 | }; | 340 | }; |
337 | 341 | ||
342 | #ifdef CONFIG_OF | ||
343 | static int lp855x_parse_dt(struct device *dev, struct device_node *node) | ||
344 | { | ||
345 | struct lp855x_platform_data *pdata; | ||
346 | int rom_length; | ||
347 | |||
348 | if (!node) { | ||
349 | dev_err(dev, "no platform data\n"); | ||
350 | return -EINVAL; | ||
351 | } | ||
352 | |||
353 | pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); | ||
354 | if (!pdata) | ||
355 | return -ENOMEM; | ||
356 | |||
357 | of_property_read_string(node, "bl-name", &pdata->name); | ||
358 | of_property_read_u8(node, "dev-ctrl", &pdata->device_control); | ||
359 | of_property_read_u8(node, "init-brt", &pdata->initial_brightness); | ||
360 | of_property_read_u32(node, "pwm-period", &pdata->period_ns); | ||
361 | |||
362 | /* Fill ROM platform data if defined */ | ||
363 | rom_length = of_get_child_count(node); | ||
364 | if (rom_length > 0) { | ||
365 | struct lp855x_rom_data *rom; | ||
366 | struct device_node *child; | ||
367 | int i = 0; | ||
368 | |||
369 | rom = devm_kzalloc(dev, sizeof(*rom) * rom_length, GFP_KERNEL); | ||
370 | if (!rom) | ||
371 | return -ENOMEM; | ||
372 | |||
373 | for_each_child_of_node(node, child) { | ||
374 | of_property_read_u8(child, "rom-addr", &rom[i].addr); | ||
375 | of_property_read_u8(child, "rom-val", &rom[i].val); | ||
376 | i++; | ||
377 | } | ||
378 | |||
379 | pdata->size_program = rom_length; | ||
380 | pdata->rom_data = &rom[0]; | ||
381 | } | ||
382 | |||
383 | dev->platform_data = pdata; | ||
384 | |||
385 | return 0; | ||
386 | } | ||
387 | #else | ||
388 | static int lp855x_parse_dt(struct device *dev, struct device_node *node) | ||
389 | { | ||
390 | return -EINVAL; | ||
391 | } | ||
392 | #endif | ||
393 | |||
338 | static int lp855x_probe(struct i2c_client *cl, const struct i2c_device_id *id) | 394 | static int lp855x_probe(struct i2c_client *cl, const struct i2c_device_id *id) |
339 | { | 395 | { |
340 | struct lp855x *lp; | 396 | struct lp855x *lp; |
341 | struct lp855x_platform_data *pdata = cl->dev.platform_data; | 397 | struct lp855x_platform_data *pdata = cl->dev.platform_data; |
342 | enum lp855x_brightness_ctrl_mode mode; | 398 | struct device_node *node = cl->dev.of_node; |
343 | int ret; | 399 | int ret; |
344 | 400 | ||
345 | if (!pdata) { | 401 | if (!pdata) { |
346 | dev_err(&cl->dev, "no platform data supplied\n"); | 402 | ret = lp855x_parse_dt(&cl->dev, node); |
347 | return -EINVAL; | 403 | if (ret < 0) |
404 | return ret; | ||
405 | |||
406 | pdata = cl->dev.platform_data; | ||
348 | } | 407 | } |
349 | 408 | ||
350 | if (!i2c_check_functionality(cl->adapter, I2C_FUNC_SMBUS_I2C_BLOCK)) | 409 | if (!i2c_check_functionality(cl->adapter, I2C_FUNC_SMBUS_I2C_BLOCK)) |
@@ -354,7 +413,11 @@ static int lp855x_probe(struct i2c_client *cl, const struct i2c_device_id *id) | |||
354 | if (!lp) | 413 | if (!lp) |
355 | return -ENOMEM; | 414 | return -ENOMEM; |
356 | 415 | ||
357 | mode = pdata->mode; | 416 | if (pdata->period_ns > 0) |
417 | lp->mode = PWM_BASED; | ||
418 | else | ||
419 | lp->mode = REGISTER_BASED; | ||
420 | |||
358 | lp->client = cl; | 421 | lp->client = cl; |
359 | lp->dev = &cl->dev; | 422 | lp->dev = &cl->dev; |
360 | lp->pdata = pdata; | 423 | lp->pdata = pdata; |
@@ -402,6 +465,17 @@ static int lp855x_remove(struct i2c_client *cl) | |||
402 | return 0; | 465 | return 0; |
403 | } | 466 | } |
404 | 467 | ||
468 | static const struct of_device_id lp855x_dt_ids[] = { | ||
469 | { .compatible = "ti,lp8550", }, | ||
470 | { .compatible = "ti,lp8551", }, | ||
471 | { .compatible = "ti,lp8552", }, | ||
472 | { .compatible = "ti,lp8553", }, | ||
473 | { .compatible = "ti,lp8556", }, | ||
474 | { .compatible = "ti,lp8557", }, | ||
475 | { } | ||
476 | }; | ||
477 | MODULE_DEVICE_TABLE(of, lp855x_dt_ids); | ||
478 | |||
405 | static const struct i2c_device_id lp855x_ids[] = { | 479 | static const struct i2c_device_id lp855x_ids[] = { |
406 | {"lp8550", LP8550}, | 480 | {"lp8550", LP8550}, |
407 | {"lp8551", LP8551}, | 481 | {"lp8551", LP8551}, |
@@ -416,6 +490,7 @@ MODULE_DEVICE_TABLE(i2c, lp855x_ids); | |||
416 | static struct i2c_driver lp855x_driver = { | 490 | static struct i2c_driver lp855x_driver = { |
417 | .driver = { | 491 | .driver = { |
418 | .name = "lp855x", | 492 | .name = "lp855x", |
493 | .of_match_table = of_match_ptr(lp855x_dt_ids), | ||
419 | }, | 494 | }, |
420 | .probe = lp855x_probe, | 495 | .probe = lp855x_probe, |
421 | .remove = lp855x_remove, | 496 | .remove = lp855x_remove, |
diff --git a/drivers/video/backlight/ltv350qv.c b/drivers/video/backlight/ltv350qv.c index c0b4b8f2de98..ed1b39268131 100644 --- a/drivers/video/backlight/ltv350qv.c +++ b/drivers/video/backlight/ltv350qv.c | |||
@@ -271,25 +271,24 @@ static int ltv350qv_remove(struct spi_device *spi) | |||
271 | return 0; | 271 | return 0; |
272 | } | 272 | } |
273 | 273 | ||
274 | #ifdef CONFIG_PM | 274 | #ifdef CONFIG_PM_SLEEP |
275 | static int ltv350qv_suspend(struct spi_device *spi, pm_message_t state) | 275 | static int ltv350qv_suspend(struct device *dev) |
276 | { | 276 | { |
277 | struct ltv350qv *lcd = spi_get_drvdata(spi); | 277 | struct ltv350qv *lcd = dev_get_drvdata(dev); |
278 | 278 | ||
279 | return ltv350qv_power(lcd, FB_BLANK_POWERDOWN); | 279 | return ltv350qv_power(lcd, FB_BLANK_POWERDOWN); |
280 | } | 280 | } |
281 | 281 | ||
282 | static int ltv350qv_resume(struct spi_device *spi) | 282 | static int ltv350qv_resume(struct device *dev) |
283 | { | 283 | { |
284 | struct ltv350qv *lcd = spi_get_drvdata(spi); | 284 | struct ltv350qv *lcd = dev_get_drvdata(dev); |
285 | 285 | ||
286 | return ltv350qv_power(lcd, FB_BLANK_UNBLANK); | 286 | return ltv350qv_power(lcd, FB_BLANK_UNBLANK); |
287 | } | 287 | } |
288 | #else | ||
289 | #define ltv350qv_suspend NULL | ||
290 | #define ltv350qv_resume NULL | ||
291 | #endif | 288 | #endif |
292 | 289 | ||
290 | static SIMPLE_DEV_PM_OPS(ltv350qv_pm_ops, ltv350qv_suspend, ltv350qv_resume); | ||
291 | |||
293 | /* Power down all displays on reboot, poweroff or halt */ | 292 | /* Power down all displays on reboot, poweroff or halt */ |
294 | static void ltv350qv_shutdown(struct spi_device *spi) | 293 | static void ltv350qv_shutdown(struct spi_device *spi) |
295 | { | 294 | { |
@@ -302,13 +301,12 @@ static struct spi_driver ltv350qv_driver = { | |||
302 | .driver = { | 301 | .driver = { |
303 | .name = "ltv350qv", | 302 | .name = "ltv350qv", |
304 | .owner = THIS_MODULE, | 303 | .owner = THIS_MODULE, |
304 | .pm = <v350qv_pm_ops, | ||
305 | }, | 305 | }, |
306 | 306 | ||
307 | .probe = ltv350qv_probe, | 307 | .probe = ltv350qv_probe, |
308 | .remove = ltv350qv_remove, | 308 | .remove = ltv350qv_remove, |
309 | .shutdown = ltv350qv_shutdown, | 309 | .shutdown = ltv350qv_shutdown, |
310 | .suspend = ltv350qv_suspend, | ||
311 | .resume = ltv350qv_resume, | ||
312 | }; | 310 | }; |
313 | 311 | ||
314 | module_spi_driver(ltv350qv_driver); | 312 | module_spi_driver(ltv350qv_driver); |
diff --git a/drivers/video/backlight/omap1_bl.c b/drivers/video/backlight/omap1_bl.c index 627110163067..812e22e35cab 100644 --- a/drivers/video/backlight/omap1_bl.c +++ b/drivers/video/backlight/omap1_bl.c | |||
@@ -18,8 +18,6 @@ | |||
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
22 | |||
23 | #include <linux/module.h> | 21 | #include <linux/module.h> |
24 | #include <linux/kernel.h> | 22 | #include <linux/kernel.h> |
25 | #include <linux/init.h> | 23 | #include <linux/init.h> |
@@ -73,27 +71,24 @@ static void omapbl_blank(struct omap_backlight *bl, int mode) | |||
73 | } | 71 | } |
74 | } | 72 | } |
75 | 73 | ||
76 | #ifdef CONFIG_PM | 74 | #ifdef CONFIG_PM_SLEEP |
77 | static int omapbl_suspend(struct platform_device *pdev, pm_message_t state) | 75 | static int omapbl_suspend(struct device *dev) |
78 | { | 76 | { |
79 | struct backlight_device *dev = platform_get_drvdata(pdev); | 77 | struct backlight_device *bl_dev = dev_get_drvdata(dev); |
80 | struct omap_backlight *bl = bl_get_data(dev); | 78 | struct omap_backlight *bl = bl_get_data(bl_dev); |
81 | 79 | ||
82 | omapbl_blank(bl, FB_BLANK_POWERDOWN); | 80 | omapbl_blank(bl, FB_BLANK_POWERDOWN); |
83 | return 0; | 81 | return 0; |
84 | } | 82 | } |
85 | 83 | ||
86 | static int omapbl_resume(struct platform_device *pdev) | 84 | static int omapbl_resume(struct device *dev) |
87 | { | 85 | { |
88 | struct backlight_device *dev = platform_get_drvdata(pdev); | 86 | struct backlight_device *bl_dev = dev_get_drvdata(dev); |
89 | struct omap_backlight *bl = bl_get_data(dev); | 87 | struct omap_backlight *bl = bl_get_data(bl_dev); |
90 | 88 | ||
91 | omapbl_blank(bl, bl->powermode); | 89 | omapbl_blank(bl, bl->powermode); |
92 | return 0; | 90 | return 0; |
93 | } | 91 | } |
94 | #else | ||
95 | #define omapbl_suspend NULL | ||
96 | #define omapbl_resume NULL | ||
97 | #endif | 92 | #endif |
98 | 93 | ||
99 | static int omapbl_set_power(struct backlight_device *dev, int state) | 94 | static int omapbl_set_power(struct backlight_device *dev, int state) |
@@ -170,7 +165,7 @@ static int omapbl_probe(struct platform_device *pdev) | |||
170 | dev->props.brightness = pdata->default_intensity; | 165 | dev->props.brightness = pdata->default_intensity; |
171 | omapbl_update_status(dev); | 166 | omapbl_update_status(dev); |
172 | 167 | ||
173 | pr_info("OMAP LCD backlight initialised\n"); | 168 | dev_info(&pdev->dev, "OMAP LCD backlight initialised\n"); |
174 | 169 | ||
175 | return 0; | 170 | return 0; |
176 | } | 171 | } |
@@ -184,13 +179,14 @@ static int omapbl_remove(struct platform_device *pdev) | |||
184 | return 0; | 179 | return 0; |
185 | } | 180 | } |
186 | 181 | ||
182 | static SIMPLE_DEV_PM_OPS(omapbl_pm_ops, omapbl_suspend, omapbl_resume); | ||
183 | |||
187 | static struct platform_driver omapbl_driver = { | 184 | static struct platform_driver omapbl_driver = { |
188 | .probe = omapbl_probe, | 185 | .probe = omapbl_probe, |
189 | .remove = omapbl_remove, | 186 | .remove = omapbl_remove, |
190 | .suspend = omapbl_suspend, | ||
191 | .resume = omapbl_resume, | ||
192 | .driver = { | 187 | .driver = { |
193 | .name = "omap-bl", | 188 | .name = "omap-bl", |
189 | .pm = &omapbl_pm_ops, | ||
194 | }, | 190 | }, |
195 | }; | 191 | }; |
196 | 192 | ||
diff --git a/drivers/video/backlight/platform_lcd.c b/drivers/video/backlight/platform_lcd.c index 17a6b83f97af..056836706708 100644 --- a/drivers/video/backlight/platform_lcd.c +++ b/drivers/video/backlight/platform_lcd.c | |||
@@ -86,6 +86,12 @@ static int platform_lcd_probe(struct platform_device *pdev) | |||
86 | return -EINVAL; | 86 | return -EINVAL; |
87 | } | 87 | } |
88 | 88 | ||
89 | if (pdata->probe) { | ||
90 | err = pdata->probe(pdata); | ||
91 | if (err) | ||
92 | return err; | ||
93 | } | ||
94 | |||
89 | plcd = devm_kzalloc(&pdev->dev, sizeof(struct platform_lcd), | 95 | plcd = devm_kzalloc(&pdev->dev, sizeof(struct platform_lcd), |
90 | GFP_KERNEL); | 96 | GFP_KERNEL); |
91 | if (!plcd) { | 97 | if (!plcd) { |
@@ -121,7 +127,7 @@ static int platform_lcd_remove(struct platform_device *pdev) | |||
121 | return 0; | 127 | return 0; |
122 | } | 128 | } |
123 | 129 | ||
124 | #ifdef CONFIG_PM | 130 | #ifdef CONFIG_PM_SLEEP |
125 | static int platform_lcd_suspend(struct device *dev) | 131 | static int platform_lcd_suspend(struct device *dev) |
126 | { | 132 | { |
127 | struct platform_lcd *plcd = dev_get_drvdata(dev); | 133 | struct platform_lcd *plcd = dev_get_drvdata(dev); |
@@ -141,10 +147,10 @@ static int platform_lcd_resume(struct device *dev) | |||
141 | 147 | ||
142 | return 0; | 148 | return 0; |
143 | } | 149 | } |
150 | #endif | ||
144 | 151 | ||
145 | static SIMPLE_DEV_PM_OPS(platform_lcd_pm_ops, platform_lcd_suspend, | 152 | static SIMPLE_DEV_PM_OPS(platform_lcd_pm_ops, platform_lcd_suspend, |
146 | platform_lcd_resume); | 153 | platform_lcd_resume); |
147 | #endif | ||
148 | 154 | ||
149 | #ifdef CONFIG_OF | 155 | #ifdef CONFIG_OF |
150 | static const struct of_device_id platform_lcd_of_match[] = { | 156 | static const struct of_device_id platform_lcd_of_match[] = { |
@@ -158,9 +164,7 @@ static struct platform_driver platform_lcd_driver = { | |||
158 | .driver = { | 164 | .driver = { |
159 | .name = "platform-lcd", | 165 | .name = "platform-lcd", |
160 | .owner = THIS_MODULE, | 166 | .owner = THIS_MODULE, |
161 | #ifdef CONFIG_PM | ||
162 | .pm = &platform_lcd_pm_ops, | 167 | .pm = &platform_lcd_pm_ops, |
163 | #endif | ||
164 | .of_match_table = of_match_ptr(platform_lcd_of_match), | 168 | .of_match_table = of_match_ptr(platform_lcd_of_match), |
165 | }, | 169 | }, |
166 | .probe = platform_lcd_probe, | 170 | .probe = platform_lcd_probe, |
diff --git a/drivers/video/backlight/s6e63m0.c b/drivers/video/backlight/s6e63m0.c index 9c2677f0ef7d..b37bb1854bf4 100644 --- a/drivers/video/backlight/s6e63m0.c +++ b/drivers/video/backlight/s6e63m0.c | |||
@@ -817,12 +817,12 @@ static int s6e63m0_remove(struct spi_device *spi) | |||
817 | return 0; | 817 | return 0; |
818 | } | 818 | } |
819 | 819 | ||
820 | #if defined(CONFIG_PM) | 820 | #ifdef CONFIG_PM_SLEEP |
821 | static int s6e63m0_suspend(struct spi_device *spi, pm_message_t mesg) | 821 | static int s6e63m0_suspend(struct device *dev) |
822 | { | 822 | { |
823 | struct s6e63m0 *lcd = spi_get_drvdata(spi); | 823 | struct s6e63m0 *lcd = dev_get_drvdata(dev); |
824 | 824 | ||
825 | dev_dbg(&spi->dev, "lcd->power = %d\n", lcd->power); | 825 | dev_dbg(dev, "lcd->power = %d\n", lcd->power); |
826 | 826 | ||
827 | /* | 827 | /* |
828 | * when lcd panel is suspend, lcd panel becomes off | 828 | * when lcd panel is suspend, lcd panel becomes off |
@@ -831,19 +831,18 @@ static int s6e63m0_suspend(struct spi_device *spi, pm_message_t mesg) | |||
831 | return s6e63m0_power(lcd, FB_BLANK_POWERDOWN); | 831 | return s6e63m0_power(lcd, FB_BLANK_POWERDOWN); |
832 | } | 832 | } |
833 | 833 | ||
834 | static int s6e63m0_resume(struct spi_device *spi) | 834 | static int s6e63m0_resume(struct device *dev) |
835 | { | 835 | { |
836 | struct s6e63m0 *lcd = spi_get_drvdata(spi); | 836 | struct s6e63m0 *lcd = dev_get_drvdata(dev); |
837 | 837 | ||
838 | lcd->power = FB_BLANK_POWERDOWN; | 838 | lcd->power = FB_BLANK_POWERDOWN; |
839 | 839 | ||
840 | return s6e63m0_power(lcd, FB_BLANK_UNBLANK); | 840 | return s6e63m0_power(lcd, FB_BLANK_UNBLANK); |
841 | } | 841 | } |
842 | #else | ||
843 | #define s6e63m0_suspend NULL | ||
844 | #define s6e63m0_resume NULL | ||
845 | #endif | 842 | #endif |
846 | 843 | ||
844 | static SIMPLE_DEV_PM_OPS(s6e63m0_pm_ops, s6e63m0_suspend, s6e63m0_resume); | ||
845 | |||
847 | /* Power down all displays on reboot, poweroff or halt. */ | 846 | /* Power down all displays on reboot, poweroff or halt. */ |
848 | static void s6e63m0_shutdown(struct spi_device *spi) | 847 | static void s6e63m0_shutdown(struct spi_device *spi) |
849 | { | 848 | { |
@@ -856,12 +855,11 @@ static struct spi_driver s6e63m0_driver = { | |||
856 | .driver = { | 855 | .driver = { |
857 | .name = "s6e63m0", | 856 | .name = "s6e63m0", |
858 | .owner = THIS_MODULE, | 857 | .owner = THIS_MODULE, |
858 | .pm = &s6e63m0_pm_ops, | ||
859 | }, | 859 | }, |
860 | .probe = s6e63m0_probe, | 860 | .probe = s6e63m0_probe, |
861 | .remove = s6e63m0_remove, | 861 | .remove = s6e63m0_remove, |
862 | .shutdown = s6e63m0_shutdown, | 862 | .shutdown = s6e63m0_shutdown, |
863 | .suspend = s6e63m0_suspend, | ||
864 | .resume = s6e63m0_resume, | ||
865 | }; | 863 | }; |
866 | 864 | ||
867 | module_spi_driver(s6e63m0_driver); | 865 | module_spi_driver(s6e63m0_driver); |
diff --git a/drivers/video/backlight/tdo24m.c b/drivers/video/backlight/tdo24m.c index 00162085eec0..18cdf466d50a 100644 --- a/drivers/video/backlight/tdo24m.c +++ b/drivers/video/backlight/tdo24m.c | |||
@@ -412,25 +412,24 @@ static int tdo24m_remove(struct spi_device *spi) | |||
412 | return 0; | 412 | return 0; |
413 | } | 413 | } |
414 | 414 | ||
415 | #ifdef CONFIG_PM | 415 | #ifdef CONFIG_PM_SLEEP |
416 | static int tdo24m_suspend(struct spi_device *spi, pm_message_t state) | 416 | static int tdo24m_suspend(struct device *dev) |
417 | { | 417 | { |
418 | struct tdo24m *lcd = spi_get_drvdata(spi); | 418 | struct tdo24m *lcd = dev_get_drvdata(dev); |
419 | 419 | ||
420 | return tdo24m_power(lcd, FB_BLANK_POWERDOWN); | 420 | return tdo24m_power(lcd, FB_BLANK_POWERDOWN); |
421 | } | 421 | } |
422 | 422 | ||
423 | static int tdo24m_resume(struct spi_device *spi) | 423 | static int tdo24m_resume(struct device *dev) |
424 | { | 424 | { |
425 | struct tdo24m *lcd = spi_get_drvdata(spi); | 425 | struct tdo24m *lcd = dev_get_drvdata(dev); |
426 | 426 | ||
427 | return tdo24m_power(lcd, FB_BLANK_UNBLANK); | 427 | return tdo24m_power(lcd, FB_BLANK_UNBLANK); |
428 | } | 428 | } |
429 | #else | ||
430 | #define tdo24m_suspend NULL | ||
431 | #define tdo24m_resume NULL | ||
432 | #endif | 429 | #endif |
433 | 430 | ||
431 | static SIMPLE_DEV_PM_OPS(tdo24m_pm_ops, tdo24m_suspend, tdo24m_resume); | ||
432 | |||
434 | /* Power down all displays on reboot, poweroff or halt */ | 433 | /* Power down all displays on reboot, poweroff or halt */ |
435 | static void tdo24m_shutdown(struct spi_device *spi) | 434 | static void tdo24m_shutdown(struct spi_device *spi) |
436 | { | 435 | { |
@@ -443,12 +442,11 @@ static struct spi_driver tdo24m_driver = { | |||
443 | .driver = { | 442 | .driver = { |
444 | .name = "tdo24m", | 443 | .name = "tdo24m", |
445 | .owner = THIS_MODULE, | 444 | .owner = THIS_MODULE, |
445 | .pm = &tdo24m_pm_ops, | ||
446 | }, | 446 | }, |
447 | .probe = tdo24m_probe, | 447 | .probe = tdo24m_probe, |
448 | .remove = tdo24m_remove, | 448 | .remove = tdo24m_remove, |
449 | .shutdown = tdo24m_shutdown, | 449 | .shutdown = tdo24m_shutdown, |
450 | .suspend = tdo24m_suspend, | ||
451 | .resume = tdo24m_resume, | ||
452 | }; | 450 | }; |
453 | 451 | ||
454 | module_spi_driver(tdo24m_driver); | 452 | module_spi_driver(tdo24m_driver); |
diff --git a/drivers/video/backlight/tosa_bl.c b/drivers/video/backlight/tosa_bl.c index 2326fa810c59..9df66ac68b34 100644 --- a/drivers/video/backlight/tosa_bl.c +++ b/drivers/video/backlight/tosa_bl.c | |||
@@ -134,28 +134,27 @@ static int tosa_bl_remove(struct i2c_client *client) | |||
134 | return 0; | 134 | return 0; |
135 | } | 135 | } |
136 | 136 | ||
137 | #ifdef CONFIG_PM | 137 | #ifdef CONFIG_PM_SLEEP |
138 | static int tosa_bl_suspend(struct i2c_client *client, pm_message_t pm) | 138 | static int tosa_bl_suspend(struct device *dev) |
139 | { | 139 | { |
140 | struct tosa_bl_data *data = i2c_get_clientdata(client); | 140 | struct tosa_bl_data *data = dev_get_drvdata(dev); |
141 | 141 | ||
142 | tosa_bl_set_backlight(data, 0); | 142 | tosa_bl_set_backlight(data, 0); |
143 | 143 | ||
144 | return 0; | 144 | return 0; |
145 | } | 145 | } |
146 | 146 | ||
147 | static int tosa_bl_resume(struct i2c_client *client) | 147 | static int tosa_bl_resume(struct device *dev) |
148 | { | 148 | { |
149 | struct tosa_bl_data *data = i2c_get_clientdata(client); | 149 | struct tosa_bl_data *data = dev_get_drvdata(dev); |
150 | 150 | ||
151 | backlight_update_status(data->bl); | 151 | backlight_update_status(data->bl); |
152 | return 0; | 152 | return 0; |
153 | } | 153 | } |
154 | #else | ||
155 | #define tosa_bl_suspend NULL | ||
156 | #define tosa_bl_resume NULL | ||
157 | #endif | 154 | #endif |
158 | 155 | ||
156 | static SIMPLE_DEV_PM_OPS(tosa_bl_pm_ops, tosa_bl_suspend, tosa_bl_resume); | ||
157 | |||
159 | static const struct i2c_device_id tosa_bl_id[] = { | 158 | static const struct i2c_device_id tosa_bl_id[] = { |
160 | { "tosa-bl", 0 }, | 159 | { "tosa-bl", 0 }, |
161 | { }, | 160 | { }, |
@@ -165,11 +164,10 @@ static struct i2c_driver tosa_bl_driver = { | |||
165 | .driver = { | 164 | .driver = { |
166 | .name = "tosa-bl", | 165 | .name = "tosa-bl", |
167 | .owner = THIS_MODULE, | 166 | .owner = THIS_MODULE, |
167 | .pm = &tosa_bl_pm_ops, | ||
168 | }, | 168 | }, |
169 | .probe = tosa_bl_probe, | 169 | .probe = tosa_bl_probe, |
170 | .remove = tosa_bl_remove, | 170 | .remove = tosa_bl_remove, |
171 | .suspend = tosa_bl_suspend, | ||
172 | .resume = tosa_bl_resume, | ||
173 | .id_table = tosa_bl_id, | 171 | .id_table = tosa_bl_id, |
174 | }; | 172 | }; |
175 | 173 | ||
diff --git a/drivers/video/backlight/tosa_lcd.c b/drivers/video/backlight/tosa_lcd.c index 666fe2593ea4..bf081573e5b5 100644 --- a/drivers/video/backlight/tosa_lcd.c +++ b/drivers/video/backlight/tosa_lcd.c | |||
@@ -240,19 +240,19 @@ static int tosa_lcd_remove(struct spi_device *spi) | |||
240 | return 0; | 240 | return 0; |
241 | } | 241 | } |
242 | 242 | ||
243 | #ifdef CONFIG_PM | 243 | #ifdef CONFIG_PM_SLEEP |
244 | static int tosa_lcd_suspend(struct spi_device *spi, pm_message_t state) | 244 | static int tosa_lcd_suspend(struct device *dev) |
245 | { | 245 | { |
246 | struct tosa_lcd_data *data = spi_get_drvdata(spi); | 246 | struct tosa_lcd_data *data = dev_get_drvdata(dev); |
247 | 247 | ||
248 | tosa_lcd_tg_off(data); | 248 | tosa_lcd_tg_off(data); |
249 | 249 | ||
250 | return 0; | 250 | return 0; |
251 | } | 251 | } |
252 | 252 | ||
253 | static int tosa_lcd_resume(struct spi_device *spi) | 253 | static int tosa_lcd_resume(struct device *dev) |
254 | { | 254 | { |
255 | struct tosa_lcd_data *data = spi_get_drvdata(spi); | 255 | struct tosa_lcd_data *data = dev_get_drvdata(dev); |
256 | 256 | ||
257 | tosa_lcd_tg_init(data); | 257 | tosa_lcd_tg_init(data); |
258 | if (POWER_IS_ON(data->lcd_power)) | 258 | if (POWER_IS_ON(data->lcd_power)) |
@@ -262,20 +262,18 @@ static int tosa_lcd_resume(struct spi_device *spi) | |||
262 | 262 | ||
263 | return 0; | 263 | return 0; |
264 | } | 264 | } |
265 | #else | ||
266 | #define tosa_lcd_suspend NULL | ||
267 | #define tosa_lcd_resume NULL | ||
268 | #endif | 265 | #endif |
269 | 266 | ||
267 | static SIMPLE_DEV_PM_OPS(tosa_lcd_pm_ops, tosa_lcd_suspend, tosa_lcd_resume); | ||
268 | |||
270 | static struct spi_driver tosa_lcd_driver = { | 269 | static struct spi_driver tosa_lcd_driver = { |
271 | .driver = { | 270 | .driver = { |
272 | .name = "tosa-lcd", | 271 | .name = "tosa-lcd", |
273 | .owner = THIS_MODULE, | 272 | .owner = THIS_MODULE, |
273 | .pm = &tosa_lcd_pm_ops, | ||
274 | }, | 274 | }, |
275 | .probe = tosa_lcd_probe, | 275 | .probe = tosa_lcd_probe, |
276 | .remove = tosa_lcd_remove, | 276 | .remove = tosa_lcd_remove, |
277 | .suspend = tosa_lcd_suspend, | ||
278 | .resume = tosa_lcd_resume, | ||
279 | }; | 277 | }; |
280 | 278 | ||
281 | module_spi_driver(tosa_lcd_driver); | 279 | module_spi_driver(tosa_lcd_driver); |
diff --git a/drivers/video/backlight/tps65217_bl.c b/drivers/video/backlight/tps65217_bl.c index 70881633b45a..05782312aeb3 100644 --- a/drivers/video/backlight/tps65217_bl.c +++ b/drivers/video/backlight/tps65217_bl.c | |||
@@ -245,6 +245,18 @@ tps65217_bl_parse_dt(struct platform_device *pdev) | |||
245 | } | 245 | } |
246 | } | 246 | } |
247 | 247 | ||
248 | if (!of_property_read_u32(node, "default-brightness", &val)) { | ||
249 | if (val < 0 || | ||
250 | val > 100) { | ||
251 | dev_err(&pdev->dev, | ||
252 | "invalid 'default-brightness' value in the device tree\n"); | ||
253 | err = ERR_PTR(-EINVAL); | ||
254 | goto err; | ||
255 | } | ||
256 | |||
257 | pdata->dft_brightness = val; | ||
258 | } | ||
259 | |||
248 | of_node_put(node); | 260 | of_node_put(node); |
249 | 261 | ||
250 | return pdata; | 262 | return pdata; |
@@ -311,7 +323,8 @@ static int tps65217_bl_probe(struct platform_device *pdev) | |||
311 | return PTR_ERR(tps65217_bl->bl); | 323 | return PTR_ERR(tps65217_bl->bl); |
312 | } | 324 | } |
313 | 325 | ||
314 | tps65217_bl->bl->props.brightness = 0; | 326 | tps65217_bl->bl->props.brightness = pdata->dft_brightness; |
327 | backlight_update_status(tps65217_bl->bl); | ||
315 | platform_set_drvdata(pdev, tps65217_bl); | 328 | platform_set_drvdata(pdev, tps65217_bl); |
316 | 329 | ||
317 | return 0; | 330 | return 0; |
diff --git a/drivers/video/backlight/vgg2432a4.c b/drivers/video/backlight/vgg2432a4.c index 84d582f591dc..d538947a67d3 100644 --- a/drivers/video/backlight/vgg2432a4.c +++ b/drivers/video/backlight/vgg2432a4.c | |||
@@ -205,18 +205,15 @@ static int vgg2432a4_lcd_init(struct ili9320 *lcd, | |||
205 | return ret; | 205 | return ret; |
206 | } | 206 | } |
207 | 207 | ||
208 | #ifdef CONFIG_PM | 208 | #ifdef CONFIG_PM_SLEEP |
209 | static int vgg2432a4_suspend(struct spi_device *spi, pm_message_t state) | 209 | static int vgg2432a4_suspend(struct device *dev) |
210 | { | 210 | { |
211 | return ili9320_suspend(spi_get_drvdata(spi), state); | 211 | return ili9320_suspend(dev_get_drvdata(dev)); |
212 | } | 212 | } |
213 | static int vgg2432a4_resume(struct spi_device *spi) | 213 | static int vgg2432a4_resume(struct device *dev) |
214 | { | 214 | { |
215 | return ili9320_resume(spi_get_drvdata(spi)); | 215 | return ili9320_resume(dev_get_drvdata(dev)); |
216 | } | 216 | } |
217 | #else | ||
218 | #define vgg2432a4_suspend NULL | ||
219 | #define vgg2432a4_resume NULL | ||
220 | #endif | 217 | #endif |
221 | 218 | ||
222 | static struct ili9320_client vgg2432a4_client = { | 219 | static struct ili9320_client vgg2432a4_client = { |
@@ -249,16 +246,17 @@ static void vgg2432a4_shutdown(struct spi_device *spi) | |||
249 | ili9320_shutdown(spi_get_drvdata(spi)); | 246 | ili9320_shutdown(spi_get_drvdata(spi)); |
250 | } | 247 | } |
251 | 248 | ||
249 | static SIMPLE_DEV_PM_OPS(vgg2432a4_pm_ops, vgg2432a4_suspend, vgg2432a4_resume); | ||
250 | |||
252 | static struct spi_driver vgg2432a4_driver = { | 251 | static struct spi_driver vgg2432a4_driver = { |
253 | .driver = { | 252 | .driver = { |
254 | .name = "VGG2432A4", | 253 | .name = "VGG2432A4", |
255 | .owner = THIS_MODULE, | 254 | .owner = THIS_MODULE, |
255 | .pm = &vgg2432a4_pm_ops, | ||
256 | }, | 256 | }, |
257 | .probe = vgg2432a4_probe, | 257 | .probe = vgg2432a4_probe, |
258 | .remove = vgg2432a4_remove, | 258 | .remove = vgg2432a4_remove, |
259 | .shutdown = vgg2432a4_shutdown, | 259 | .shutdown = vgg2432a4_shutdown, |
260 | .suspend = vgg2432a4_suspend, | ||
261 | .resume = vgg2432a4_resume, | ||
262 | }; | 260 | }; |
263 | 261 | ||
264 | module_spi_driver(vgg2432a4_driver); | 262 | module_spi_driver(vgg2432a4_driver); |
diff --git a/drivers/video/uvesafb.c b/drivers/video/uvesafb.c index d4284458377e..e328a61b64ba 100644 --- a/drivers/video/uvesafb.c +++ b/drivers/video/uvesafb.c | |||
@@ -166,7 +166,7 @@ static int uvesafb_exec(struct uvesafb_ktask *task) | |||
166 | memcpy(&m->id, &uvesafb_cn_id, sizeof(m->id)); | 166 | memcpy(&m->id, &uvesafb_cn_id, sizeof(m->id)); |
167 | m->seq = seq; | 167 | m->seq = seq; |
168 | m->len = len; | 168 | m->len = len; |
169 | m->ack = random32(); | 169 | m->ack = prandom_u32(); |
170 | 170 | ||
171 | /* uvesafb_task structure */ | 171 | /* uvesafb_task structure */ |
172 | memcpy(m + 1, &task->t, sizeof(task->t)); | 172 | memcpy(m + 1, &task->t, sizeof(task->t)); |
diff --git a/fs/fat/dir.c b/fs/fat/dir.c index 165012ef363a..7a6f02caf286 100644 --- a/fs/fat/dir.c +++ b/fs/fat/dir.c | |||
@@ -964,6 +964,29 @@ int fat_scan(struct inode *dir, const unsigned char *name, | |||
964 | } | 964 | } |
965 | EXPORT_SYMBOL_GPL(fat_scan); | 965 | EXPORT_SYMBOL_GPL(fat_scan); |
966 | 966 | ||
967 | /* | ||
968 | * Scans a directory for a given logstart. | ||
969 | * Returns an error code or zero. | ||
970 | */ | ||
971 | int fat_scan_logstart(struct inode *dir, int i_logstart, | ||
972 | struct fat_slot_info *sinfo) | ||
973 | { | ||
974 | struct super_block *sb = dir->i_sb; | ||
975 | |||
976 | sinfo->slot_off = 0; | ||
977 | sinfo->bh = NULL; | ||
978 | while (fat_get_short_entry(dir, &sinfo->slot_off, &sinfo->bh, | ||
979 | &sinfo->de) >= 0) { | ||
980 | if (fat_get_start(MSDOS_SB(sb), sinfo->de) == i_logstart) { | ||
981 | sinfo->slot_off -= sizeof(*sinfo->de); | ||
982 | sinfo->nr_slots = 1; | ||
983 | sinfo->i_pos = fat_make_i_pos(sb, sinfo->bh, sinfo->de); | ||
984 | return 0; | ||
985 | } | ||
986 | } | ||
987 | return -ENOENT; | ||
988 | } | ||
989 | |||
967 | static int __fat_remove_entries(struct inode *dir, loff_t pos, int nr_slots) | 990 | static int __fat_remove_entries(struct inode *dir, loff_t pos, int nr_slots) |
968 | { | 991 | { |
969 | struct super_block *sb = dir->i_sb; | 992 | struct super_block *sb = dir->i_sb; |
diff --git a/fs/fat/fat.h b/fs/fat/fat.h index e9cc3f0d58e2..21664fcf3616 100644 --- a/fs/fat/fat.h +++ b/fs/fat/fat.h | |||
@@ -23,6 +23,9 @@ | |||
23 | #define FAT_ERRORS_PANIC 2 /* panic on error */ | 23 | #define FAT_ERRORS_PANIC 2 /* panic on error */ |
24 | #define FAT_ERRORS_RO 3 /* remount r/o on error */ | 24 | #define FAT_ERRORS_RO 3 /* remount r/o on error */ |
25 | 25 | ||
26 | #define FAT_NFS_STALE_RW 1 /* NFS RW support, can cause ESTALE */ | ||
27 | #define FAT_NFS_NOSTALE_RO 2 /* NFS RO support, no ESTALE issue */ | ||
28 | |||
26 | struct fat_mount_options { | 29 | struct fat_mount_options { |
27 | kuid_t fs_uid; | 30 | kuid_t fs_uid; |
28 | kgid_t fs_gid; | 31 | kgid_t fs_gid; |
@@ -34,6 +37,7 @@ struct fat_mount_options { | |||
34 | unsigned short shortname; /* flags for shortname display/create rule */ | 37 | unsigned short shortname; /* flags for shortname display/create rule */ |
35 | unsigned char name_check; /* r = relaxed, n = normal, s = strict */ | 38 | unsigned char name_check; /* r = relaxed, n = normal, s = strict */ |
36 | unsigned char errors; /* On error: continue, panic, remount-ro */ | 39 | unsigned char errors; /* On error: continue, panic, remount-ro */ |
40 | unsigned char nfs; /* NFS support: nostale_ro, stale_rw */ | ||
37 | unsigned short allow_utime;/* permission for setting the [am]time */ | 41 | unsigned short allow_utime;/* permission for setting the [am]time */ |
38 | unsigned quiet:1, /* set = fake successful chmods and chowns */ | 42 | unsigned quiet:1, /* set = fake successful chmods and chowns */ |
39 | showexec:1, /* set = only set x bit for com/exe/bat */ | 43 | showexec:1, /* set = only set x bit for com/exe/bat */ |
@@ -48,8 +52,7 @@ struct fat_mount_options { | |||
48 | usefree:1, /* Use free_clusters for FAT32 */ | 52 | usefree:1, /* Use free_clusters for FAT32 */ |
49 | tz_set:1, /* Filesystem timestamps' offset set */ | 53 | tz_set:1, /* Filesystem timestamps' offset set */ |
50 | rodir:1, /* allow ATTR_RO for directory */ | 54 | rodir:1, /* allow ATTR_RO for directory */ |
51 | discard:1, /* Issue discard requests on deletions */ | 55 | discard:1; /* Issue discard requests on deletions */ |
52 | nfs:1; /* Do extra work needed for NFS export */ | ||
53 | }; | 56 | }; |
54 | 57 | ||
55 | #define FAT_HASH_BITS 8 | 58 | #define FAT_HASH_BITS 8 |
@@ -72,6 +75,7 @@ struct msdos_sb_info { | |||
72 | unsigned long root_cluster; /* first cluster of the root directory */ | 75 | unsigned long root_cluster; /* first cluster of the root directory */ |
73 | unsigned long fsinfo_sector; /* sector number of FAT32 fsinfo */ | 76 | unsigned long fsinfo_sector; /* sector number of FAT32 fsinfo */ |
74 | struct mutex fat_lock; | 77 | struct mutex fat_lock; |
78 | struct mutex nfs_build_inode_lock; | ||
75 | struct mutex s_lock; | 79 | struct mutex s_lock; |
76 | unsigned int prev_free; /* previously allocated cluster number */ | 80 | unsigned int prev_free; /* previously allocated cluster number */ |
77 | unsigned int free_clusters; /* -1 if undefined */ | 81 | unsigned int free_clusters; /* -1 if undefined */ |
@@ -215,6 +219,27 @@ static inline sector_t fat_clus_to_blknr(struct msdos_sb_info *sbi, int clus) | |||
215 | + sbi->data_start; | 219 | + sbi->data_start; |
216 | } | 220 | } |
217 | 221 | ||
222 | static inline void fat_get_blknr_offset(struct msdos_sb_info *sbi, | ||
223 | loff_t i_pos, sector_t *blknr, int *offset) | ||
224 | { | ||
225 | *blknr = i_pos >> sbi->dir_per_block_bits; | ||
226 | *offset = i_pos & (sbi->dir_per_block - 1); | ||
227 | } | ||
228 | |||
229 | static inline loff_t fat_i_pos_read(struct msdos_sb_info *sbi, | ||
230 | struct inode *inode) | ||
231 | { | ||
232 | loff_t i_pos; | ||
233 | #if BITS_PER_LONG == 32 | ||
234 | spin_lock(&sbi->inode_hash_lock); | ||
235 | #endif | ||
236 | i_pos = MSDOS_I(inode)->i_pos; | ||
237 | #if BITS_PER_LONG == 32 | ||
238 | spin_unlock(&sbi->inode_hash_lock); | ||
239 | #endif | ||
240 | return i_pos; | ||
241 | } | ||
242 | |||
218 | static inline void fat16_towchar(wchar_t *dst, const __u8 *src, size_t len) | 243 | static inline void fat16_towchar(wchar_t *dst, const __u8 *src, size_t len) |
219 | { | 244 | { |
220 | #ifdef __BIG_ENDIAN | 245 | #ifdef __BIG_ENDIAN |
@@ -271,6 +296,8 @@ extern int fat_dir_empty(struct inode *dir); | |||
271 | extern int fat_subdirs(struct inode *dir); | 296 | extern int fat_subdirs(struct inode *dir); |
272 | extern int fat_scan(struct inode *dir, const unsigned char *name, | 297 | extern int fat_scan(struct inode *dir, const unsigned char *name, |
273 | struct fat_slot_info *sinfo); | 298 | struct fat_slot_info *sinfo); |
299 | extern int fat_scan_logstart(struct inode *dir, int i_logstart, | ||
300 | struct fat_slot_info *sinfo); | ||
274 | extern int fat_get_dotdot_entry(struct inode *dir, struct buffer_head **bh, | 301 | extern int fat_get_dotdot_entry(struct inode *dir, struct buffer_head **bh, |
275 | struct msdos_dir_entry **de); | 302 | struct msdos_dir_entry **de); |
276 | extern int fat_alloc_new_dir(struct inode *dir, struct timespec *ts); | 303 | extern int fat_alloc_new_dir(struct inode *dir, struct timespec *ts); |
@@ -348,6 +375,7 @@ extern struct inode *fat_build_inode(struct super_block *sb, | |||
348 | extern int fat_sync_inode(struct inode *inode); | 375 | extern int fat_sync_inode(struct inode *inode); |
349 | extern int fat_fill_super(struct super_block *sb, void *data, int silent, | 376 | extern int fat_fill_super(struct super_block *sb, void *data, int silent, |
350 | int isvfat, void (*setup)(struct super_block *)); | 377 | int isvfat, void (*setup)(struct super_block *)); |
378 | extern int fat_fill_inode(struct inode *inode, struct msdos_dir_entry *de); | ||
351 | 379 | ||
352 | extern int fat_flush_inodes(struct super_block *sb, struct inode *i1, | 380 | extern int fat_flush_inodes(struct super_block *sb, struct inode *i1, |
353 | struct inode *i2); | 381 | struct inode *i2); |
@@ -382,12 +410,8 @@ int fat_cache_init(void); | |||
382 | void fat_cache_destroy(void); | 410 | void fat_cache_destroy(void); |
383 | 411 | ||
384 | /* fat/nfs.c */ | 412 | /* fat/nfs.c */ |
385 | struct fid; | 413 | extern const struct export_operations fat_export_ops; |
386 | extern struct dentry *fat_fh_to_dentry(struct super_block *sb, struct fid *fid, | 414 | extern const struct export_operations fat_export_ops_nostale; |
387 | int fh_len, int fh_type); | ||
388 | extern struct dentry *fat_fh_to_parent(struct super_block *sb, struct fid *fid, | ||
389 | int fh_len, int fh_type); | ||
390 | extern struct dentry *fat_get_parent(struct dentry *child_dir); | ||
391 | 415 | ||
392 | /* helper for printk */ | 416 | /* helper for printk */ |
393 | typedef unsigned long long llu; | 417 | typedef unsigned long long llu; |
diff --git a/fs/fat/file.c b/fs/fat/file.c index 3978f8ca1823..b0b632e50ddb 100644 --- a/fs/fat/file.c +++ b/fs/fat/file.c | |||
@@ -306,6 +306,11 @@ int fat_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat) | |||
306 | struct inode *inode = dentry->d_inode; | 306 | struct inode *inode = dentry->d_inode; |
307 | generic_fillattr(inode, stat); | 307 | generic_fillattr(inode, stat); |
308 | stat->blksize = MSDOS_SB(inode->i_sb)->cluster_size; | 308 | stat->blksize = MSDOS_SB(inode->i_sb)->cluster_size; |
309 | |||
310 | if (MSDOS_SB(inode->i_sb)->options.nfs == FAT_NFS_NOSTALE_RO) { | ||
311 | /* Use i_pos for ino. This is used as fileid of nfs. */ | ||
312 | stat->ino = fat_i_pos_read(MSDOS_SB(inode->i_sb), inode); | ||
313 | } | ||
309 | return 0; | 314 | return 0; |
310 | } | 315 | } |
311 | EXPORT_SYMBOL_GPL(fat_getattr); | 316 | EXPORT_SYMBOL_GPL(fat_getattr); |
diff --git a/fs/fat/inode.c b/fs/fat/inode.c index acf6e479b443..4ff901632b26 100644 --- a/fs/fat/inode.c +++ b/fs/fat/inode.c | |||
@@ -18,7 +18,6 @@ | |||
18 | #include <linux/pagemap.h> | 18 | #include <linux/pagemap.h> |
19 | #include <linux/mpage.h> | 19 | #include <linux/mpage.h> |
20 | #include <linux/buffer_head.h> | 20 | #include <linux/buffer_head.h> |
21 | #include <linux/exportfs.h> | ||
22 | #include <linux/mount.h> | 21 | #include <linux/mount.h> |
23 | #include <linux/vfs.h> | 22 | #include <linux/vfs.h> |
24 | #include <linux/parser.h> | 23 | #include <linux/parser.h> |
@@ -385,7 +384,7 @@ static int fat_calc_dir_size(struct inode *inode) | |||
385 | } | 384 | } |
386 | 385 | ||
387 | /* doesn't deal with root inode */ | 386 | /* doesn't deal with root inode */ |
388 | static int fat_fill_inode(struct inode *inode, struct msdos_dir_entry *de) | 387 | int fat_fill_inode(struct inode *inode, struct msdos_dir_entry *de) |
389 | { | 388 | { |
390 | struct msdos_sb_info *sbi = MSDOS_SB(inode->i_sb); | 389 | struct msdos_sb_info *sbi = MSDOS_SB(inode->i_sb); |
391 | int error; | 390 | int error; |
@@ -444,12 +443,25 @@ static int fat_fill_inode(struct inode *inode, struct msdos_dir_entry *de) | |||
444 | return 0; | 443 | return 0; |
445 | } | 444 | } |
446 | 445 | ||
446 | static inline void fat_lock_build_inode(struct msdos_sb_info *sbi) | ||
447 | { | ||
448 | if (sbi->options.nfs == FAT_NFS_NOSTALE_RO) | ||
449 | mutex_lock(&sbi->nfs_build_inode_lock); | ||
450 | } | ||
451 | |||
452 | static inline void fat_unlock_build_inode(struct msdos_sb_info *sbi) | ||
453 | { | ||
454 | if (sbi->options.nfs == FAT_NFS_NOSTALE_RO) | ||
455 | mutex_unlock(&sbi->nfs_build_inode_lock); | ||
456 | } | ||
457 | |||
447 | struct inode *fat_build_inode(struct super_block *sb, | 458 | struct inode *fat_build_inode(struct super_block *sb, |
448 | struct msdos_dir_entry *de, loff_t i_pos) | 459 | struct msdos_dir_entry *de, loff_t i_pos) |
449 | { | 460 | { |
450 | struct inode *inode; | 461 | struct inode *inode; |
451 | int err; | 462 | int err; |
452 | 463 | ||
464 | fat_lock_build_inode(MSDOS_SB(sb)); | ||
453 | inode = fat_iget(sb, i_pos); | 465 | inode = fat_iget(sb, i_pos); |
454 | if (inode) | 466 | if (inode) |
455 | goto out; | 467 | goto out; |
@@ -469,6 +481,7 @@ struct inode *fat_build_inode(struct super_block *sb, | |||
469 | fat_attach(inode, i_pos); | 481 | fat_attach(inode, i_pos); |
470 | insert_inode_hash(inode); | 482 | insert_inode_hash(inode); |
471 | out: | 483 | out: |
484 | fat_unlock_build_inode(MSDOS_SB(sb)); | ||
472 | return inode; | 485 | return inode; |
473 | } | 486 | } |
474 | 487 | ||
@@ -655,20 +668,6 @@ static int fat_statfs(struct dentry *dentry, struct kstatfs *buf) | |||
655 | return 0; | 668 | return 0; |
656 | } | 669 | } |
657 | 670 | ||
658 | static inline loff_t fat_i_pos_read(struct msdos_sb_info *sbi, | ||
659 | struct inode *inode) | ||
660 | { | ||
661 | loff_t i_pos; | ||
662 | #if BITS_PER_LONG == 32 | ||
663 | spin_lock(&sbi->inode_hash_lock); | ||
664 | #endif | ||
665 | i_pos = MSDOS_I(inode)->i_pos; | ||
666 | #if BITS_PER_LONG == 32 | ||
667 | spin_unlock(&sbi->inode_hash_lock); | ||
668 | #endif | ||
669 | return i_pos; | ||
670 | } | ||
671 | |||
672 | static int __fat_write_inode(struct inode *inode, int wait) | 671 | static int __fat_write_inode(struct inode *inode, int wait) |
673 | { | 672 | { |
674 | struct super_block *sb = inode->i_sb; | 673 | struct super_block *sb = inode->i_sb; |
@@ -676,7 +675,8 @@ static int __fat_write_inode(struct inode *inode, int wait) | |||
676 | struct buffer_head *bh; | 675 | struct buffer_head *bh; |
677 | struct msdos_dir_entry *raw_entry; | 676 | struct msdos_dir_entry *raw_entry; |
678 | loff_t i_pos; | 677 | loff_t i_pos; |
679 | int err; | 678 | sector_t blocknr; |
679 | int err, offset; | ||
680 | 680 | ||
681 | if (inode->i_ino == MSDOS_ROOT_INO) | 681 | if (inode->i_ino == MSDOS_ROOT_INO) |
682 | return 0; | 682 | return 0; |
@@ -686,7 +686,8 @@ retry: | |||
686 | if (!i_pos) | 686 | if (!i_pos) |
687 | return 0; | 687 | return 0; |
688 | 688 | ||
689 | bh = sb_bread(sb, i_pos >> sbi->dir_per_block_bits); | 689 | fat_get_blknr_offset(sbi, i_pos, &blocknr, &offset); |
690 | bh = sb_bread(sb, blocknr); | ||
690 | if (!bh) { | 691 | if (!bh) { |
691 | fat_msg(sb, KERN_ERR, "unable to read inode block " | 692 | fat_msg(sb, KERN_ERR, "unable to read inode block " |
692 | "for updating (i_pos %lld)", i_pos); | 693 | "for updating (i_pos %lld)", i_pos); |
@@ -699,8 +700,7 @@ retry: | |||
699 | goto retry; | 700 | goto retry; |
700 | } | 701 | } |
701 | 702 | ||
702 | raw_entry = &((struct msdos_dir_entry *) (bh->b_data)) | 703 | raw_entry = &((struct msdos_dir_entry *) (bh->b_data))[offset]; |
703 | [i_pos & (sbi->dir_per_block - 1)]; | ||
704 | if (S_ISDIR(inode->i_mode)) | 704 | if (S_ISDIR(inode->i_mode)) |
705 | raw_entry->size = 0; | 705 | raw_entry->size = 0; |
706 | else | 706 | else |
@@ -761,12 +761,6 @@ static const struct super_operations fat_sops = { | |||
761 | .show_options = fat_show_options, | 761 | .show_options = fat_show_options, |
762 | }; | 762 | }; |
763 | 763 | ||
764 | static const struct export_operations fat_export_ops = { | ||
765 | .fh_to_dentry = fat_fh_to_dentry, | ||
766 | .fh_to_parent = fat_fh_to_parent, | ||
767 | .get_parent = fat_get_parent, | ||
768 | }; | ||
769 | |||
770 | static int fat_show_options(struct seq_file *m, struct dentry *root) | 764 | static int fat_show_options(struct seq_file *m, struct dentry *root) |
771 | { | 765 | { |
772 | struct msdos_sb_info *sbi = MSDOS_SB(root->d_sb); | 766 | struct msdos_sb_info *sbi = MSDOS_SB(root->d_sb); |
@@ -814,8 +808,6 @@ static int fat_show_options(struct seq_file *m, struct dentry *root) | |||
814 | seq_puts(m, ",usefree"); | 808 | seq_puts(m, ",usefree"); |
815 | if (opts->quiet) | 809 | if (opts->quiet) |
816 | seq_puts(m, ",quiet"); | 810 | seq_puts(m, ",quiet"); |
817 | if (opts->nfs) | ||
818 | seq_puts(m, ",nfs"); | ||
819 | if (opts->showexec) | 811 | if (opts->showexec) |
820 | seq_puts(m, ",showexec"); | 812 | seq_puts(m, ",showexec"); |
821 | if (opts->sys_immutable) | 813 | if (opts->sys_immutable) |
@@ -849,6 +841,10 @@ static int fat_show_options(struct seq_file *m, struct dentry *root) | |||
849 | seq_puts(m, ",errors=panic"); | 841 | seq_puts(m, ",errors=panic"); |
850 | else | 842 | else |
851 | seq_puts(m, ",errors=remount-ro"); | 843 | seq_puts(m, ",errors=remount-ro"); |
844 | if (opts->nfs == FAT_NFS_NOSTALE_RO) | ||
845 | seq_puts(m, ",nfs=nostale_ro"); | ||
846 | else if (opts->nfs) | ||
847 | seq_puts(m, ",nfs=stale_rw"); | ||
852 | if (opts->discard) | 848 | if (opts->discard) |
853 | seq_puts(m, ",discard"); | 849 | seq_puts(m, ",discard"); |
854 | 850 | ||
@@ -865,7 +861,7 @@ enum { | |||
865 | Opt_uni_xl_no, Opt_uni_xl_yes, Opt_nonumtail_no, Opt_nonumtail_yes, | 861 | Opt_uni_xl_no, Opt_uni_xl_yes, Opt_nonumtail_no, Opt_nonumtail_yes, |
866 | Opt_obsolete, Opt_flush, Opt_tz_utc, Opt_rodir, Opt_err_cont, | 862 | Opt_obsolete, Opt_flush, Opt_tz_utc, Opt_rodir, Opt_err_cont, |
867 | Opt_err_panic, Opt_err_ro, Opt_discard, Opt_nfs, Opt_time_offset, | 863 | Opt_err_panic, Opt_err_ro, Opt_discard, Opt_nfs, Opt_time_offset, |
868 | Opt_err, | 864 | Opt_nfs_stale_rw, Opt_nfs_nostale_ro, Opt_err, |
869 | }; | 865 | }; |
870 | 866 | ||
871 | static const match_table_t fat_tokens = { | 867 | static const match_table_t fat_tokens = { |
@@ -895,7 +891,9 @@ static const match_table_t fat_tokens = { | |||
895 | {Opt_err_panic, "errors=panic"}, | 891 | {Opt_err_panic, "errors=panic"}, |
896 | {Opt_err_ro, "errors=remount-ro"}, | 892 | {Opt_err_ro, "errors=remount-ro"}, |
897 | {Opt_discard, "discard"}, | 893 | {Opt_discard, "discard"}, |
898 | {Opt_nfs, "nfs"}, | 894 | {Opt_nfs_stale_rw, "nfs"}, |
895 | {Opt_nfs_stale_rw, "nfs=stale_rw"}, | ||
896 | {Opt_nfs_nostale_ro, "nfs=nostale_ro"}, | ||
899 | {Opt_obsolete, "conv=binary"}, | 897 | {Opt_obsolete, "conv=binary"}, |
900 | {Opt_obsolete, "conv=text"}, | 898 | {Opt_obsolete, "conv=text"}, |
901 | {Opt_obsolete, "conv=auto"}, | 899 | {Opt_obsolete, "conv=auto"}, |
@@ -1092,6 +1090,12 @@ static int parse_options(struct super_block *sb, char *options, int is_vfat, | |||
1092 | case Opt_err_ro: | 1090 | case Opt_err_ro: |
1093 | opts->errors = FAT_ERRORS_RO; | 1091 | opts->errors = FAT_ERRORS_RO; |
1094 | break; | 1092 | break; |
1093 | case Opt_nfs_stale_rw: | ||
1094 | opts->nfs = FAT_NFS_STALE_RW; | ||
1095 | break; | ||
1096 | case Opt_nfs_nostale_ro: | ||
1097 | opts->nfs = FAT_NFS_NOSTALE_RO; | ||
1098 | break; | ||
1095 | 1099 | ||
1096 | /* msdos specific */ | 1100 | /* msdos specific */ |
1097 | case Opt_dots: | 1101 | case Opt_dots: |
@@ -1150,9 +1154,6 @@ static int parse_options(struct super_block *sb, char *options, int is_vfat, | |||
1150 | case Opt_discard: | 1154 | case Opt_discard: |
1151 | opts->discard = 1; | 1155 | opts->discard = 1; |
1152 | break; | 1156 | break; |
1153 | case Opt_nfs: | ||
1154 | opts->nfs = 1; | ||
1155 | break; | ||
1156 | 1157 | ||
1157 | /* obsolete mount options */ | 1158 | /* obsolete mount options */ |
1158 | case Opt_obsolete: | 1159 | case Opt_obsolete: |
@@ -1183,6 +1184,10 @@ out: | |||
1183 | opts->allow_utime = ~opts->fs_dmask & (S_IWGRP | S_IWOTH); | 1184 | opts->allow_utime = ~opts->fs_dmask & (S_IWGRP | S_IWOTH); |
1184 | if (opts->unicode_xlate) | 1185 | if (opts->unicode_xlate) |
1185 | opts->utf8 = 0; | 1186 | opts->utf8 = 0; |
1187 | if (opts->nfs == FAT_NFS_NOSTALE_RO) { | ||
1188 | sb->s_flags |= MS_RDONLY; | ||
1189 | sb->s_export_op = &fat_export_ops_nostale; | ||
1190 | } | ||
1186 | 1191 | ||
1187 | return 0; | 1192 | return 0; |
1188 | } | 1193 | } |
@@ -1193,7 +1198,7 @@ static int fat_read_root(struct inode *inode) | |||
1193 | struct msdos_sb_info *sbi = MSDOS_SB(sb); | 1198 | struct msdos_sb_info *sbi = MSDOS_SB(sb); |
1194 | int error; | 1199 | int error; |
1195 | 1200 | ||
1196 | MSDOS_I(inode)->i_pos = 0; | 1201 | MSDOS_I(inode)->i_pos = MSDOS_ROOT_INO; |
1197 | inode->i_uid = sbi->options.fs_uid; | 1202 | inode->i_uid = sbi->options.fs_uid; |
1198 | inode->i_gid = sbi->options.fs_gid; | 1203 | inode->i_gid = sbi->options.fs_gid; |
1199 | inode->i_version++; | 1204 | inode->i_version++; |
@@ -1256,6 +1261,7 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, int isvfat, | |||
1256 | sb->s_magic = MSDOS_SUPER_MAGIC; | 1261 | sb->s_magic = MSDOS_SUPER_MAGIC; |
1257 | sb->s_op = &fat_sops; | 1262 | sb->s_op = &fat_sops; |
1258 | sb->s_export_op = &fat_export_ops; | 1263 | sb->s_export_op = &fat_export_ops; |
1264 | mutex_init(&sbi->nfs_build_inode_lock); | ||
1259 | ratelimit_state_init(&sbi->ratelimit, DEFAULT_RATELIMIT_INTERVAL, | 1265 | ratelimit_state_init(&sbi->ratelimit, DEFAULT_RATELIMIT_INTERVAL, |
1260 | DEFAULT_RATELIMIT_BURST); | 1266 | DEFAULT_RATELIMIT_BURST); |
1261 | 1267 | ||
diff --git a/fs/fat/nfs.c b/fs/fat/nfs.c index 499c10438ca2..93e14933dcb6 100644 --- a/fs/fat/nfs.c +++ b/fs/fat/nfs.c | |||
@@ -14,6 +14,18 @@ | |||
14 | #include <linux/exportfs.h> | 14 | #include <linux/exportfs.h> |
15 | #include "fat.h" | 15 | #include "fat.h" |
16 | 16 | ||
17 | struct fat_fid { | ||
18 | u32 i_gen; | ||
19 | u32 i_pos_low; | ||
20 | u16 i_pos_hi; | ||
21 | u16 parent_i_pos_hi; | ||
22 | u32 parent_i_pos_low; | ||
23 | u32 parent_i_gen; | ||
24 | }; | ||
25 | |||
26 | #define FAT_FID_SIZE_WITHOUT_PARENT 3 | ||
27 | #define FAT_FID_SIZE_WITH_PARENT (sizeof(struct fat_fid)/sizeof(u32)) | ||
28 | |||
17 | /** | 29 | /** |
18 | * Look up a directory inode given its starting cluster. | 30 | * Look up a directory inode given its starting cluster. |
19 | */ | 31 | */ |
@@ -38,63 +50,252 @@ static struct inode *fat_dget(struct super_block *sb, int i_logstart) | |||
38 | return inode; | 50 | return inode; |
39 | } | 51 | } |
40 | 52 | ||
41 | static struct inode *fat_nfs_get_inode(struct super_block *sb, | 53 | static struct inode *fat_ilookup(struct super_block *sb, u64 ino, loff_t i_pos) |
42 | u64 ino, u32 generation) | ||
43 | { | 54 | { |
44 | struct inode *inode; | 55 | if (MSDOS_SB(sb)->options.nfs == FAT_NFS_NOSTALE_RO) |
56 | return fat_iget(sb, i_pos); | ||
45 | 57 | ||
46 | if ((ino < MSDOS_ROOT_INO) || (ino == MSDOS_FSINFO_INO)) | 58 | else { |
47 | return NULL; | 59 | if ((ino < MSDOS_ROOT_INO) || (ino == MSDOS_FSINFO_INO)) |
60 | return NULL; | ||
61 | return ilookup(sb, ino); | ||
62 | } | ||
63 | } | ||
64 | |||
65 | static struct inode *__fat_nfs_get_inode(struct super_block *sb, | ||
66 | u64 ino, u32 generation, loff_t i_pos) | ||
67 | { | ||
68 | struct inode *inode = fat_ilookup(sb, ino, i_pos); | ||
48 | 69 | ||
49 | inode = ilookup(sb, ino); | ||
50 | if (inode && generation && (inode->i_generation != generation)) { | 70 | if (inode && generation && (inode->i_generation != generation)) { |
51 | iput(inode); | 71 | iput(inode); |
52 | inode = NULL; | 72 | inode = NULL; |
53 | } | 73 | } |
74 | if (inode == NULL && MSDOS_SB(sb)->options.nfs == FAT_NFS_NOSTALE_RO) { | ||
75 | struct buffer_head *bh = NULL; | ||
76 | struct msdos_dir_entry *de ; | ||
77 | sector_t blocknr; | ||
78 | int offset; | ||
79 | fat_get_blknr_offset(MSDOS_SB(sb), i_pos, &blocknr, &offset); | ||
80 | bh = sb_bread(sb, blocknr); | ||
81 | if (!bh) { | ||
82 | fat_msg(sb, KERN_ERR, | ||
83 | "unable to read block(%llu) for building NFS inode", | ||
84 | (llu)blocknr); | ||
85 | return inode; | ||
86 | } | ||
87 | de = (struct msdos_dir_entry *)bh->b_data; | ||
88 | /* If a file is deleted on server and client is not updated | ||
89 | * yet, we must not build the inode upon a lookup call. | ||
90 | */ | ||
91 | if (IS_FREE(de[offset].name)) | ||
92 | inode = NULL; | ||
93 | else | ||
94 | inode = fat_build_inode(sb, &de[offset], i_pos); | ||
95 | brelse(bh); | ||
96 | } | ||
54 | 97 | ||
55 | return inode; | 98 | return inode; |
56 | } | 99 | } |
57 | 100 | ||
101 | static struct inode *fat_nfs_get_inode(struct super_block *sb, | ||
102 | u64 ino, u32 generation) | ||
103 | { | ||
104 | |||
105 | return __fat_nfs_get_inode(sb, ino, generation, 0); | ||
106 | } | ||
107 | |||
108 | static int | ||
109 | fat_encode_fh_nostale(struct inode *inode, __u32 *fh, int *lenp, | ||
110 | struct inode *parent) | ||
111 | { | ||
112 | int len = *lenp; | ||
113 | struct msdos_sb_info *sbi = MSDOS_SB(inode->i_sb); | ||
114 | struct fat_fid *fid = (struct fat_fid *) fh; | ||
115 | loff_t i_pos; | ||
116 | int type = FILEID_FAT_WITHOUT_PARENT; | ||
117 | |||
118 | if (parent) { | ||
119 | if (len < FAT_FID_SIZE_WITH_PARENT) { | ||
120 | *lenp = FAT_FID_SIZE_WITH_PARENT; | ||
121 | return FILEID_INVALID; | ||
122 | } | ||
123 | } else { | ||
124 | if (len < FAT_FID_SIZE_WITHOUT_PARENT) { | ||
125 | *lenp = FAT_FID_SIZE_WITHOUT_PARENT; | ||
126 | return FILEID_INVALID; | ||
127 | } | ||
128 | } | ||
129 | |||
130 | i_pos = fat_i_pos_read(sbi, inode); | ||
131 | *lenp = FAT_FID_SIZE_WITHOUT_PARENT; | ||
132 | fid->i_gen = inode->i_generation; | ||
133 | fid->i_pos_low = i_pos & 0xFFFFFFFF; | ||
134 | fid->i_pos_hi = (i_pos >> 32) & 0xFFFF; | ||
135 | if (parent) { | ||
136 | i_pos = fat_i_pos_read(sbi, parent); | ||
137 | fid->parent_i_pos_hi = (i_pos >> 32) & 0xFFFF; | ||
138 | fid->parent_i_pos_low = i_pos & 0xFFFFFFFF; | ||
139 | fid->parent_i_gen = parent->i_generation; | ||
140 | type = FILEID_FAT_WITH_PARENT; | ||
141 | *lenp = FAT_FID_SIZE_WITH_PARENT; | ||
142 | } | ||
143 | |||
144 | return type; | ||
145 | } | ||
146 | |||
58 | /** | 147 | /** |
59 | * Map a NFS file handle to a corresponding dentry. | 148 | * Map a NFS file handle to a corresponding dentry. |
60 | * The dentry may or may not be connected to the filesystem root. | 149 | * The dentry may or may not be connected to the filesystem root. |
61 | */ | 150 | */ |
62 | struct dentry *fat_fh_to_dentry(struct super_block *sb, struct fid *fid, | 151 | static struct dentry *fat_fh_to_dentry(struct super_block *sb, struct fid *fid, |
63 | int fh_len, int fh_type) | 152 | int fh_len, int fh_type) |
64 | { | 153 | { |
65 | return generic_fh_to_dentry(sb, fid, fh_len, fh_type, | 154 | return generic_fh_to_dentry(sb, fid, fh_len, fh_type, |
66 | fat_nfs_get_inode); | 155 | fat_nfs_get_inode); |
67 | } | 156 | } |
68 | 157 | ||
158 | static struct dentry *fat_fh_to_dentry_nostale(struct super_block *sb, | ||
159 | struct fid *fh, int fh_len, | ||
160 | int fh_type) | ||
161 | { | ||
162 | struct inode *inode = NULL; | ||
163 | struct fat_fid *fid = (struct fat_fid *)fh; | ||
164 | loff_t i_pos; | ||
165 | |||
166 | switch (fh_type) { | ||
167 | case FILEID_FAT_WITHOUT_PARENT: | ||
168 | if (fh_len < FAT_FID_SIZE_WITHOUT_PARENT) | ||
169 | return NULL; | ||
170 | break; | ||
171 | case FILEID_FAT_WITH_PARENT: | ||
172 | if (fh_len < FAT_FID_SIZE_WITH_PARENT) | ||
173 | return NULL; | ||
174 | break; | ||
175 | default: | ||
176 | return NULL; | ||
177 | } | ||
178 | i_pos = fid->i_pos_hi; | ||
179 | i_pos = (i_pos << 32) | (fid->i_pos_low); | ||
180 | inode = __fat_nfs_get_inode(sb, 0, fid->i_gen, i_pos); | ||
181 | |||
182 | return d_obtain_alias(inode); | ||
183 | } | ||
184 | |||
69 | /* | 185 | /* |
70 | * Find the parent for a file specified by NFS handle. | 186 | * Find the parent for a file specified by NFS handle. |
71 | * This requires that the handle contain the i_ino of the parent. | 187 | * This requires that the handle contain the i_ino of the parent. |
72 | */ | 188 | */ |
73 | struct dentry *fat_fh_to_parent(struct super_block *sb, struct fid *fid, | 189 | static struct dentry *fat_fh_to_parent(struct super_block *sb, struct fid *fid, |
74 | int fh_len, int fh_type) | 190 | int fh_len, int fh_type) |
75 | { | 191 | { |
76 | return generic_fh_to_parent(sb, fid, fh_len, fh_type, | 192 | return generic_fh_to_parent(sb, fid, fh_len, fh_type, |
77 | fat_nfs_get_inode); | 193 | fat_nfs_get_inode); |
78 | } | 194 | } |
79 | 195 | ||
196 | static struct dentry *fat_fh_to_parent_nostale(struct super_block *sb, | ||
197 | struct fid *fh, int fh_len, | ||
198 | int fh_type) | ||
199 | { | ||
200 | struct inode *inode = NULL; | ||
201 | struct fat_fid *fid = (struct fat_fid *)fh; | ||
202 | loff_t i_pos; | ||
203 | |||
204 | if (fh_len < FAT_FID_SIZE_WITH_PARENT) | ||
205 | return NULL; | ||
206 | |||
207 | switch (fh_type) { | ||
208 | case FILEID_FAT_WITH_PARENT: | ||
209 | i_pos = fid->parent_i_pos_hi; | ||
210 | i_pos = (i_pos << 32) | (fid->parent_i_pos_low); | ||
211 | inode = __fat_nfs_get_inode(sb, 0, fid->parent_i_gen, i_pos); | ||
212 | break; | ||
213 | } | ||
214 | |||
215 | return d_obtain_alias(inode); | ||
216 | } | ||
217 | |||
218 | /* | ||
219 | * Rebuild the parent for a directory that is not connected | ||
220 | * to the filesystem root | ||
221 | */ | ||
222 | static | ||
223 | struct inode *fat_rebuild_parent(struct super_block *sb, int parent_logstart) | ||
224 | { | ||
225 | int search_clus, clus_to_match; | ||
226 | struct msdos_dir_entry *de; | ||
227 | struct inode *parent = NULL; | ||
228 | struct inode *dummy_grand_parent = NULL; | ||
229 | struct fat_slot_info sinfo; | ||
230 | struct msdos_sb_info *sbi = MSDOS_SB(sb); | ||
231 | sector_t blknr = fat_clus_to_blknr(sbi, parent_logstart); | ||
232 | struct buffer_head *parent_bh = sb_bread(sb, blknr); | ||
233 | if (!parent_bh) { | ||
234 | fat_msg(sb, KERN_ERR, | ||
235 | "unable to read cluster of parent directory"); | ||
236 | return NULL; | ||
237 | } | ||
238 | |||
239 | de = (struct msdos_dir_entry *) parent_bh->b_data; | ||
240 | clus_to_match = fat_get_start(sbi, &de[0]); | ||
241 | search_clus = fat_get_start(sbi, &de[1]); | ||
242 | |||
243 | dummy_grand_parent = fat_dget(sb, search_clus); | ||
244 | if (!dummy_grand_parent) { | ||
245 | dummy_grand_parent = new_inode(sb); | ||
246 | if (!dummy_grand_parent) { | ||
247 | brelse(parent_bh); | ||
248 | return parent; | ||
249 | } | ||
250 | |||
251 | dummy_grand_parent->i_ino = iunique(sb, MSDOS_ROOT_INO); | ||
252 | fat_fill_inode(dummy_grand_parent, &de[1]); | ||
253 | MSDOS_I(dummy_grand_parent)->i_pos = -1; | ||
254 | } | ||
255 | |||
256 | if (!fat_scan_logstart(dummy_grand_parent, clus_to_match, &sinfo)) | ||
257 | parent = fat_build_inode(sb, sinfo.de, sinfo.i_pos); | ||
258 | |||
259 | brelse(parent_bh); | ||
260 | iput(dummy_grand_parent); | ||
261 | |||
262 | return parent; | ||
263 | } | ||
264 | |||
80 | /* | 265 | /* |
81 | * Find the parent for a directory that is not currently connected to | 266 | * Find the parent for a directory that is not currently connected to |
82 | * the filesystem root. | 267 | * the filesystem root. |
83 | * | 268 | * |
84 | * On entry, the caller holds child_dir->d_inode->i_mutex. | 269 | * On entry, the caller holds child_dir->d_inode->i_mutex. |
85 | */ | 270 | */ |
86 | struct dentry *fat_get_parent(struct dentry *child_dir) | 271 | static struct dentry *fat_get_parent(struct dentry *child_dir) |
87 | { | 272 | { |
88 | struct super_block *sb = child_dir->d_sb; | 273 | struct super_block *sb = child_dir->d_sb; |
89 | struct buffer_head *bh = NULL; | 274 | struct buffer_head *bh = NULL; |
90 | struct msdos_dir_entry *de; | 275 | struct msdos_dir_entry *de; |
91 | struct inode *parent_inode = NULL; | 276 | struct inode *parent_inode = NULL; |
277 | struct msdos_sb_info *sbi = MSDOS_SB(sb); | ||
92 | 278 | ||
93 | if (!fat_get_dotdot_entry(child_dir->d_inode, &bh, &de)) { | 279 | if (!fat_get_dotdot_entry(child_dir->d_inode, &bh, &de)) { |
94 | int parent_logstart = fat_get_start(MSDOS_SB(sb), de); | 280 | int parent_logstart = fat_get_start(sbi, de); |
95 | parent_inode = fat_dget(sb, parent_logstart); | 281 | parent_inode = fat_dget(sb, parent_logstart); |
282 | if (!parent_inode && sbi->options.nfs == FAT_NFS_NOSTALE_RO) | ||
283 | parent_inode = fat_rebuild_parent(sb, parent_logstart); | ||
96 | } | 284 | } |
97 | brelse(bh); | 285 | brelse(bh); |
98 | 286 | ||
99 | return d_obtain_alias(parent_inode); | 287 | return d_obtain_alias(parent_inode); |
100 | } | 288 | } |
289 | |||
290 | const struct export_operations fat_export_ops = { | ||
291 | .fh_to_dentry = fat_fh_to_dentry, | ||
292 | .fh_to_parent = fat_fh_to_parent, | ||
293 | .get_parent = fat_get_parent, | ||
294 | }; | ||
295 | |||
296 | const struct export_operations fat_export_ops_nostale = { | ||
297 | .encode_fh = fat_encode_fh_nostale, | ||
298 | .fh_to_dentry = fat_fh_to_dentry_nostale, | ||
299 | .fh_to_parent = fat_fh_to_parent_nostale, | ||
300 | .get_parent = fat_get_parent, | ||
301 | }; | ||
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 2e27430b9070..417c84877742 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c | |||
@@ -234,7 +234,6 @@ static struct nfs4_stid *nfs4_alloc_stid(struct nfs4_client *cl, struct | |||
234 | kmem_cache *slab) | 234 | kmem_cache *slab) |
235 | { | 235 | { |
236 | struct idr *stateids = &cl->cl_stateids; | 236 | struct idr *stateids = &cl->cl_stateids; |
237 | static int min_stateid = 0; | ||
238 | struct nfs4_stid *stid; | 237 | struct nfs4_stid *stid; |
239 | int new_id; | 238 | int new_id; |
240 | 239 | ||
@@ -242,7 +241,7 @@ kmem_cache *slab) | |||
242 | if (!stid) | 241 | if (!stid) |
243 | return NULL; | 242 | return NULL; |
244 | 243 | ||
245 | new_id = idr_alloc(stateids, stid, min_stateid, 0, GFP_KERNEL); | 244 | new_id = idr_alloc_cyclic(stateids, stid, 0, 0, GFP_KERNEL); |
246 | if (new_id < 0) | 245 | if (new_id < 0) |
247 | goto out_free; | 246 | goto out_free; |
248 | stid->sc_client = cl; | 247 | stid->sc_client = cl; |
@@ -261,10 +260,6 @@ kmem_cache *slab) | |||
261 | * amount of time until an id is reused, by ensuring they always | 260 | * amount of time until an id is reused, by ensuring they always |
262 | * "increase" (mod INT_MAX): | 261 | * "increase" (mod INT_MAX): |
263 | */ | 262 | */ |
264 | |||
265 | min_stateid = new_id+1; | ||
266 | if (min_stateid == INT_MAX) | ||
267 | min_stateid = 0; | ||
268 | return stid; | 263 | return stid; |
269 | out_free: | 264 | out_free: |
270 | kfree(stid); | 265 | kfree(stid); |
diff --git a/fs/notify/inotify/inotify_user.c b/fs/notify/inotify/inotify_user.c index e0f7c1241a6a..8562bd3af947 100644 --- a/fs/notify/inotify/inotify_user.c +++ b/fs/notify/inotify/inotify_user.c | |||
@@ -359,7 +359,6 @@ static int inotify_find_inode(const char __user *dirname, struct path *path, uns | |||
359 | } | 359 | } |
360 | 360 | ||
361 | static int inotify_add_to_idr(struct idr *idr, spinlock_t *idr_lock, | 361 | static int inotify_add_to_idr(struct idr *idr, spinlock_t *idr_lock, |
362 | int *last_wd, | ||
363 | struct inotify_inode_mark *i_mark) | 362 | struct inotify_inode_mark *i_mark) |
364 | { | 363 | { |
365 | int ret; | 364 | int ret; |
@@ -367,11 +366,10 @@ static int inotify_add_to_idr(struct idr *idr, spinlock_t *idr_lock, | |||
367 | idr_preload(GFP_KERNEL); | 366 | idr_preload(GFP_KERNEL); |
368 | spin_lock(idr_lock); | 367 | spin_lock(idr_lock); |
369 | 368 | ||
370 | ret = idr_alloc(idr, i_mark, *last_wd + 1, 0, GFP_NOWAIT); | 369 | ret = idr_alloc_cyclic(idr, i_mark, 1, 0, GFP_NOWAIT); |
371 | if (ret >= 0) { | 370 | if (ret >= 0) { |
372 | /* we added the mark to the idr, take a reference */ | 371 | /* we added the mark to the idr, take a reference */ |
373 | i_mark->wd = ret; | 372 | i_mark->wd = ret; |
374 | *last_wd = i_mark->wd; | ||
375 | fsnotify_get_mark(&i_mark->fsn_mark); | 373 | fsnotify_get_mark(&i_mark->fsn_mark); |
376 | } | 374 | } |
377 | 375 | ||
@@ -638,8 +636,7 @@ static int inotify_new_watch(struct fsnotify_group *group, | |||
638 | if (atomic_read(&group->inotify_data.user->inotify_watches) >= inotify_max_user_watches) | 636 | if (atomic_read(&group->inotify_data.user->inotify_watches) >= inotify_max_user_watches) |
639 | goto out_err; | 637 | goto out_err; |
640 | 638 | ||
641 | ret = inotify_add_to_idr(idr, idr_lock, &group->inotify_data.last_wd, | 639 | ret = inotify_add_to_idr(idr, idr_lock, tmp_i_mark); |
642 | tmp_i_mark); | ||
643 | if (ret) | 640 | if (ret) |
644 | goto out_err; | 641 | goto out_err; |
645 | 642 | ||
@@ -697,7 +694,6 @@ static struct fsnotify_group *inotify_new_group(unsigned int max_events) | |||
697 | 694 | ||
698 | spin_lock_init(&group->inotify_data.idr_lock); | 695 | spin_lock_init(&group->inotify_data.idr_lock); |
699 | idr_init(&group->inotify_data.idr); | 696 | idr_init(&group->inotify_data.idr); |
700 | group->inotify_data.last_wd = 0; | ||
701 | group->inotify_data.user = get_current_user(); | 697 | group->inotify_data.user = get_current_user(); |
702 | 698 | ||
703 | if (atomic_inc_return(&group->inotify_data.user->inotify_devs) > | 699 | if (atomic_inc_return(&group->inotify_data.user->inotify_devs) > |
diff --git a/include/linux/compiler-gcc4.h b/include/linux/compiler-gcc4.h index 68b162d92254..842de225055f 100644 --- a/include/linux/compiler-gcc4.h +++ b/include/linux/compiler-gcc4.h | |||
@@ -13,7 +13,7 @@ | |||
13 | #define __must_check __attribute__((warn_unused_result)) | 13 | #define __must_check __attribute__((warn_unused_result)) |
14 | #define __compiler_offsetof(a,b) __builtin_offsetof(a,b) | 14 | #define __compiler_offsetof(a,b) __builtin_offsetof(a,b) |
15 | 15 | ||
16 | #if GCC_VERSION >= 40100 | 16 | #if GCC_VERSION >= 40100 && GCC_VERSION < 40600 |
17 | # define __compiletime_object_size(obj) __builtin_object_size(obj, 0) | 17 | # define __compiletime_object_size(obj) __builtin_object_size(obj, 0) |
18 | #endif | 18 | #endif |
19 | 19 | ||
diff --git a/include/linux/console.h b/include/linux/console.h index 29680a8cda99..73bab0f58af5 100644 --- a/include/linux/console.h +++ b/include/linux/console.h | |||
@@ -141,6 +141,7 @@ struct console { | |||
141 | for (con = console_drivers; con != NULL; con = con->next) | 141 | for (con = console_drivers; con != NULL; con = con->next) |
142 | 142 | ||
143 | extern int console_set_on_cmdline; | 143 | extern int console_set_on_cmdline; |
144 | extern struct console *early_console; | ||
144 | 145 | ||
145 | extern int add_preferred_console(char *name, int idx, char *options); | 146 | extern int add_preferred_console(char *name, int idx, char *options); |
146 | extern int update_console_cmdline(char *name, int idx, char *name_new, int idx_new, char *options); | 147 | extern int update_console_cmdline(char *name, int idx, char *name_new, int idx_new, char *options); |
diff --git a/include/linux/ctype.h b/include/linux/ctype.h index 8acfe312f947..653589e3e30e 100644 --- a/include/linux/ctype.h +++ b/include/linux/ctype.h | |||
@@ -61,4 +61,10 @@ static inline char _tolower(const char c) | |||
61 | return c | 0x20; | 61 | return c | 0x20; |
62 | } | 62 | } |
63 | 63 | ||
64 | /* Fast check for octal digit */ | ||
65 | static inline int isodigit(const char c) | ||
66 | { | ||
67 | return c >= '0' && c <= '7'; | ||
68 | } | ||
69 | |||
64 | #endif | 70 | #endif |
diff --git a/include/linux/exportfs.h b/include/linux/exportfs.h index 5b9b5b317180..41b223a59a63 100644 --- a/include/linux/exportfs.h +++ b/include/linux/exportfs.h | |||
@@ -85,6 +85,17 @@ enum fid_type { | |||
85 | FILEID_NILFS_WITH_PARENT = 0x62, | 85 | FILEID_NILFS_WITH_PARENT = 0x62, |
86 | 86 | ||
87 | /* | 87 | /* |
88 | * 32 bit generation number, 40 bit i_pos. | ||
89 | */ | ||
90 | FILEID_FAT_WITHOUT_PARENT = 0x71, | ||
91 | |||
92 | /* | ||
93 | * 32 bit generation number, 40 bit i_pos, | ||
94 | * 32 bit parent generation number, 40 bit parent i_pos | ||
95 | */ | ||
96 | FILEID_FAT_WITH_PARENT = 0x72, | ||
97 | |||
98 | /* | ||
88 | * Filesystems must not use 0xff file ID. | 99 | * Filesystems must not use 0xff file ID. |
89 | */ | 100 | */ |
90 | FILEID_INVALID = 0xff, | 101 | FILEID_INVALID = 0xff, |
diff --git a/include/linux/fsnotify_backend.h b/include/linux/fsnotify_backend.h index d5b0910d4961..4b2ee8d12f5e 100644 --- a/include/linux/fsnotify_backend.h +++ b/include/linux/fsnotify_backend.h | |||
@@ -157,7 +157,6 @@ struct fsnotify_group { | |||
157 | struct inotify_group_private_data { | 157 | struct inotify_group_private_data { |
158 | spinlock_t idr_lock; | 158 | spinlock_t idr_lock; |
159 | struct idr idr; | 159 | struct idr idr; |
160 | u32 last_wd; | ||
161 | struct user_struct *user; | 160 | struct user_struct *user; |
162 | } inotify_data; | 161 | } inotify_data; |
163 | #endif | 162 | #endif |
diff --git a/include/linux/genalloc.h b/include/linux/genalloc.h index dd7c569aacad..661d374aeb2d 100644 --- a/include/linux/genalloc.h +++ b/include/linux/genalloc.h | |||
@@ -29,6 +29,10 @@ | |||
29 | 29 | ||
30 | #ifndef __GENALLOC_H__ | 30 | #ifndef __GENALLOC_H__ |
31 | #define __GENALLOC_H__ | 31 | #define __GENALLOC_H__ |
32 | |||
33 | struct device; | ||
34 | struct device_node; | ||
35 | |||
32 | /** | 36 | /** |
33 | * Allocation callback function type definition | 37 | * Allocation callback function type definition |
34 | * @map: Pointer to bitmap | 38 | * @map: Pointer to bitmap |
@@ -105,4 +109,18 @@ extern unsigned long gen_pool_first_fit(unsigned long *map, unsigned long size, | |||
105 | extern unsigned long gen_pool_best_fit(unsigned long *map, unsigned long size, | 109 | extern unsigned long gen_pool_best_fit(unsigned long *map, unsigned long size, |
106 | unsigned long start, unsigned int nr, void *data); | 110 | unsigned long start, unsigned int nr, void *data); |
107 | 111 | ||
112 | extern struct gen_pool *devm_gen_pool_create(struct device *dev, | ||
113 | int min_alloc_order, int nid); | ||
114 | extern struct gen_pool *dev_get_gen_pool(struct device *dev); | ||
115 | |||
116 | #ifdef CONFIG_OF | ||
117 | extern struct gen_pool *of_get_named_gen_pool(struct device_node *np, | ||
118 | const char *propname, int index); | ||
119 | #else | ||
120 | static inline struct gen_pool *of_get_named_gen_pool(struct device_node *np, | ||
121 | const char *propname, int index) | ||
122 | { | ||
123 | return NULL; | ||
124 | } | ||
125 | #endif | ||
108 | #endif /* __GENALLOC_H__ */ | 126 | #endif /* __GENALLOC_H__ */ |
diff --git a/include/linux/idr.h b/include/linux/idr.h index 2640c7e99e51..a470ac3ef49d 100644 --- a/include/linux/idr.h +++ b/include/linux/idr.h | |||
@@ -42,6 +42,7 @@ struct idr { | |||
42 | struct idr_layer *id_free; | 42 | struct idr_layer *id_free; |
43 | int layers; /* only valid w/o concurrent changes */ | 43 | int layers; /* only valid w/o concurrent changes */ |
44 | int id_free_cnt; | 44 | int id_free_cnt; |
45 | int cur; /* current pos for cyclic allocation */ | ||
45 | spinlock_t lock; | 46 | spinlock_t lock; |
46 | }; | 47 | }; |
47 | 48 | ||
@@ -75,6 +76,7 @@ struct idr { | |||
75 | void *idr_find_slowpath(struct idr *idp, int id); | 76 | void *idr_find_slowpath(struct idr *idp, int id); |
76 | void idr_preload(gfp_t gfp_mask); | 77 | void idr_preload(gfp_t gfp_mask); |
77 | int idr_alloc(struct idr *idp, void *ptr, int start, int end, gfp_t gfp_mask); | 78 | int idr_alloc(struct idr *idp, void *ptr, int start, int end, gfp_t gfp_mask); |
79 | int idr_alloc_cyclic(struct idr *idr, void *ptr, int start, int end, gfp_t gfp_mask); | ||
78 | int idr_for_each(struct idr *idp, | 80 | int idr_for_each(struct idr *idp, |
79 | int (*fn)(int id, void *p, void *data), void *data); | 81 | int (*fn)(int id, void *p, void *data), void *data); |
80 | void *idr_get_next(struct idr *idp, int *nextid); | 82 | void *idr_get_next(struct idr *idp, int *nextid); |
diff --git a/include/linux/mfd/tps65217.h b/include/linux/mfd/tps65217.h index 290762f93930..29eab2bd3dfa 100644 --- a/include/linux/mfd/tps65217.h +++ b/include/linux/mfd/tps65217.h | |||
@@ -228,6 +228,7 @@ enum tps65217_bl_fdim { | |||
228 | struct tps65217_bl_pdata { | 228 | struct tps65217_bl_pdata { |
229 | enum tps65217_bl_isel isel; | 229 | enum tps65217_bl_isel isel; |
230 | enum tps65217_bl_fdim fdim; | 230 | enum tps65217_bl_fdim fdim; |
231 | int dft_brightness; | ||
231 | }; | 232 | }; |
232 | 233 | ||
233 | /** | 234 | /** |
diff --git a/include/linux/net.h b/include/linux/net.h index aa1673160a45..99c9f0c103c2 100644 --- a/include/linux/net.h +++ b/include/linux/net.h | |||
@@ -240,8 +240,8 @@ do { \ | |||
240 | #define net_dbg_ratelimited(fmt, ...) \ | 240 | #define net_dbg_ratelimited(fmt, ...) \ |
241 | net_ratelimited_function(pr_debug, fmt, ##__VA_ARGS__) | 241 | net_ratelimited_function(pr_debug, fmt, ##__VA_ARGS__) |
242 | 242 | ||
243 | #define net_random() random32() | 243 | #define net_random() prandom_u32() |
244 | #define net_srandom(seed) srandom32((__force u32)seed) | 244 | #define net_srandom(seed) prandom_seed((__force u32)(seed)) |
245 | 245 | ||
246 | extern int kernel_sendmsg(struct socket *sock, struct msghdr *msg, | 246 | extern int kernel_sendmsg(struct socket *sock, struct msghdr *msg, |
247 | struct kvec *vec, size_t num, size_t len); | 247 | struct kvec *vec, size_t num, size_t len); |
diff --git a/include/linux/platform_data/coda.h b/include/linux/platform_data/coda.h new file mode 100644 index 000000000000..6ad4410d9e20 --- /dev/null +++ b/include/linux/platform_data/coda.h | |||
@@ -0,0 +1,18 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2013 Philipp Zabel, Pengutronix | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License as published by | ||
6 | * the Free Software Foundation; either version 2 of the License, or | ||
7 | * (at your option) any later version. | ||
8 | */ | ||
9 | #ifndef PLATFORM_CODA_H | ||
10 | #define PLATFORM_CODA_H | ||
11 | |||
12 | struct device; | ||
13 | |||
14 | struct coda_platform_data { | ||
15 | struct device *iram_dev; | ||
16 | }; | ||
17 | |||
18 | #endif | ||
diff --git a/include/linux/platform_data/lp855x.h b/include/linux/platform_data/lp855x.h index 20ee8b221dbd..ea3200527dd3 100644 --- a/include/linux/platform_data/lp855x.h +++ b/include/linux/platform_data/lp855x.h | |||
@@ -69,11 +69,6 @@ enum lp855x_chip_id { | |||
69 | LP8557, | 69 | LP8557, |
70 | }; | 70 | }; |
71 | 71 | ||
72 | enum lp855x_brightness_ctrl_mode { | ||
73 | PWM_BASED = 1, | ||
74 | REGISTER_BASED, | ||
75 | }; | ||
76 | |||
77 | enum lp8550_brighntess_source { | 72 | enum lp8550_brighntess_source { |
78 | LP8550_PWM_ONLY, | 73 | LP8550_PWM_ONLY, |
79 | LP8550_I2C_ONLY = 2, | 74 | LP8550_I2C_ONLY = 2, |
@@ -116,24 +111,18 @@ struct lp855x_rom_data { | |||
116 | /** | 111 | /** |
117 | * struct lp855x_platform_data | 112 | * struct lp855x_platform_data |
118 | * @name : Backlight driver name. If it is not defined, default name is set. | 113 | * @name : Backlight driver name. If it is not defined, default name is set. |
119 | * @mode : brightness control by pwm or lp855x register | ||
120 | * @device_control : value of DEVICE CONTROL register | 114 | * @device_control : value of DEVICE CONTROL register |
121 | * @initial_brightness : initial value of backlight brightness | 115 | * @initial_brightness : initial value of backlight brightness |
122 | * @period_ns : platform specific pwm period value. unit is nano. | 116 | * @period_ns : platform specific pwm period value. unit is nano. |
123 | Only valid when mode is PWM_BASED. | 117 | Only valid when mode is PWM_BASED. |
124 | * @load_new_rom_data : | ||
125 | 0 : use default configuration data | ||
126 | 1 : update values of eeprom or eprom registers on loading driver | ||
127 | * @size_program : total size of lp855x_rom_data | 118 | * @size_program : total size of lp855x_rom_data |
128 | * @rom_data : list of new eeprom/eprom registers | 119 | * @rom_data : list of new eeprom/eprom registers |
129 | */ | 120 | */ |
130 | struct lp855x_platform_data { | 121 | struct lp855x_platform_data { |
131 | char *name; | 122 | const char *name; |
132 | enum lp855x_brightness_ctrl_mode mode; | ||
133 | u8 device_control; | 123 | u8 device_control; |
134 | int initial_brightness; | 124 | u8 initial_brightness; |
135 | unsigned int period_ns; | 125 | unsigned int period_ns; |
136 | u8 load_new_rom_data; | ||
137 | int size_program; | 126 | int size_program; |
138 | struct lp855x_rom_data *rom_data; | 127 | struct lp855x_rom_data *rom_data; |
139 | }; | 128 | }; |
diff --git a/include/linux/printk.h b/include/linux/printk.h index 822171fcb1c8..4890fe62c011 100644 --- a/include/linux/printk.h +++ b/include/linux/printk.h | |||
@@ -1,6 +1,7 @@ | |||
1 | #ifndef __KERNEL_PRINTK__ | 1 | #ifndef __KERNEL_PRINTK__ |
2 | #define __KERNEL_PRINTK__ | 2 | #define __KERNEL_PRINTK__ |
3 | 3 | ||
4 | #include <stdarg.h> | ||
4 | #include <linux/init.h> | 5 | #include <linux/init.h> |
5 | #include <linux/kern_levels.h> | 6 | #include <linux/kern_levels.h> |
6 | 7 | ||
@@ -95,8 +96,14 @@ int no_printk(const char *fmt, ...) | |||
95 | return 0; | 96 | return 0; |
96 | } | 97 | } |
97 | 98 | ||
99 | #ifdef CONFIG_EARLY_PRINTK | ||
98 | extern asmlinkage __printf(1, 2) | 100 | extern asmlinkage __printf(1, 2) |
99 | void early_printk(const char *fmt, ...); | 101 | void early_printk(const char *fmt, ...); |
102 | void early_vprintk(const char *fmt, va_list ap); | ||
103 | #else | ||
104 | static inline __printf(1, 2) __cold | ||
105 | void early_printk(const char *s, ...) { } | ||
106 | #endif | ||
100 | 107 | ||
101 | #ifdef CONFIG_PRINTK | 108 | #ifdef CONFIG_PRINTK |
102 | asmlinkage __printf(5, 0) | 109 | asmlinkage __printf(5, 0) |
diff --git a/include/linux/rtc.h b/include/linux/rtc.h index 580b24c8b8ca..c2c28975293c 100644 --- a/include/linux/rtc.h +++ b/include/linux/rtc.h | |||
@@ -133,7 +133,13 @@ extern struct rtc_device *rtc_device_register(const char *name, | |||
133 | struct device *dev, | 133 | struct device *dev, |
134 | const struct rtc_class_ops *ops, | 134 | const struct rtc_class_ops *ops, |
135 | struct module *owner); | 135 | struct module *owner); |
136 | extern struct rtc_device *devm_rtc_device_register(struct device *dev, | ||
137 | const char *name, | ||
138 | const struct rtc_class_ops *ops, | ||
139 | struct module *owner); | ||
136 | extern void rtc_device_unregister(struct rtc_device *rtc); | 140 | extern void rtc_device_unregister(struct rtc_device *rtc); |
141 | extern void devm_rtc_device_unregister(struct device *dev, | ||
142 | struct rtc_device *rtc); | ||
137 | 143 | ||
138 | extern int rtc_read_time(struct rtc_device *rtc, struct rtc_time *tm); | 144 | extern int rtc_read_time(struct rtc_device *rtc, struct rtc_time *tm); |
139 | extern int rtc_set_time(struct rtc_device *rtc, struct rtc_time *tm); | 145 | extern int rtc_set_time(struct rtc_device *rtc, struct rtc_time *tm); |
diff --git a/include/trace/events/printk.h b/include/trace/events/printk.h index 94ec79cc011a..c008bc99f9fa 100644 --- a/include/trace/events/printk.h +++ b/include/trace/events/printk.h | |||
@@ -6,31 +6,18 @@ | |||
6 | 6 | ||
7 | #include <linux/tracepoint.h> | 7 | #include <linux/tracepoint.h> |
8 | 8 | ||
9 | TRACE_EVENT_CONDITION(console, | 9 | TRACE_EVENT(console, |
10 | TP_PROTO(const char *log_buf, unsigned start, unsigned end, | 10 | TP_PROTO(const char *text, size_t len), |
11 | unsigned log_buf_len), | ||
12 | 11 | ||
13 | TP_ARGS(log_buf, start, end, log_buf_len), | 12 | TP_ARGS(text, len), |
14 | |||
15 | TP_CONDITION(start != end), | ||
16 | 13 | ||
17 | TP_STRUCT__entry( | 14 | TP_STRUCT__entry( |
18 | __dynamic_array(char, msg, end - start + 1) | 15 | __dynamic_array(char, msg, len + 1) |
19 | ), | 16 | ), |
20 | 17 | ||
21 | TP_fast_assign( | 18 | TP_fast_assign( |
22 | if ((start & (log_buf_len - 1)) > (end & (log_buf_len - 1))) { | 19 | memcpy(__get_dynamic_array(msg), text, len); |
23 | memcpy(__get_dynamic_array(msg), | 20 | ((char *)__get_dynamic_array(msg))[len] = 0; |
24 | log_buf + (start & (log_buf_len - 1)), | ||
25 | log_buf_len - (start & (log_buf_len - 1))); | ||
26 | memcpy((char *)__get_dynamic_array(msg) + | ||
27 | log_buf_len - (start & (log_buf_len - 1)), | ||
28 | log_buf, end & (log_buf_len - 1)); | ||
29 | } else | ||
30 | memcpy(__get_dynamic_array(msg), | ||
31 | log_buf + (start & (log_buf_len - 1)), | ||
32 | end - start); | ||
33 | ((char *)__get_dynamic_array(msg))[end - start] = 0; | ||
34 | ), | 21 | ), |
35 | 22 | ||
36 | TP_printk("%s", __get_str(msg)) | 23 | TP_printk("%s", __get_str(msg)) |
diff --git a/include/video/platform_lcd.h b/include/video/platform_lcd.h index ad3bdfe743b2..23864b284147 100644 --- a/include/video/platform_lcd.h +++ b/include/video/platform_lcd.h | |||
@@ -15,6 +15,7 @@ struct plat_lcd_data; | |||
15 | struct fb_info; | 15 | struct fb_info; |
16 | 16 | ||
17 | struct plat_lcd_data { | 17 | struct plat_lcd_data { |
18 | int (*probe)(struct plat_lcd_data *); | ||
18 | void (*set_power)(struct plat_lcd_data *, unsigned int power); | 19 | void (*set_power)(struct plat_lcd_data *, unsigned int power); |
19 | int (*match_fb)(struct plat_lcd_data *, struct fb_info *); | 20 | int (*match_fb)(struct plat_lcd_data *, struct fb_info *); |
20 | }; | 21 | }; |
diff --git a/init/main.c b/init/main.c index 63534a141b4e..ea73e1eb361c 100644 --- a/init/main.c +++ b/init/main.c | |||
@@ -9,6 +9,8 @@ | |||
9 | * Simplified starting of init: Michael A. Griffith <grif@acm.org> | 9 | * Simplified starting of init: Michael A. Griffith <grif@acm.org> |
10 | */ | 10 | */ |
11 | 11 | ||
12 | #define DEBUG /* Enable initcall_debug */ | ||
13 | |||
12 | #include <linux/types.h> | 14 | #include <linux/types.h> |
13 | #include <linux/module.h> | 15 | #include <linux/module.h> |
14 | #include <linux/proc_fs.h> | 16 | #include <linux/proc_fs.h> |
@@ -174,8 +176,8 @@ static int __init obsolete_checksetup(char *line) | |||
174 | if (line[n] == '\0' || line[n] == '=') | 176 | if (line[n] == '\0' || line[n] == '=') |
175 | had_early_param = 1; | 177 | had_early_param = 1; |
176 | } else if (!p->setup_func) { | 178 | } else if (!p->setup_func) { |
177 | printk(KERN_WARNING "Parameter %s is obsolete," | 179 | pr_warn("Parameter %s is obsolete, ignored\n", |
178 | " ignored\n", p->str); | 180 | p->str); |
179 | return 1; | 181 | return 1; |
180 | } else if (p->setup_func(line + n)) | 182 | } else if (p->setup_func(line + n)) |
181 | return 1; | 183 | return 1; |
@@ -398,8 +400,7 @@ static int __init do_early_param(char *param, char *val, const char *unused) | |||
398 | strcmp(p->str, "earlycon") == 0) | 400 | strcmp(p->str, "earlycon") == 0) |
399 | ) { | 401 | ) { |
400 | if (p->setup_func(val) != 0) | 402 | if (p->setup_func(val) != 0) |
401 | printk(KERN_WARNING | 403 | pr_warn("Malformed early option '%s'\n", param); |
402 | "Malformed early option '%s'\n", param); | ||
403 | } | 404 | } |
404 | } | 405 | } |
405 | /* We accept everything at this stage. */ | 406 | /* We accept everything at this stage. */ |
@@ -497,7 +498,7 @@ asmlinkage void __init start_kernel(void) | |||
497 | tick_init(); | 498 | tick_init(); |
498 | boot_cpu_init(); | 499 | boot_cpu_init(); |
499 | page_address_init(); | 500 | page_address_init(); |
500 | printk(KERN_NOTICE "%s", linux_banner); | 501 | pr_notice("%s", linux_banner); |
501 | setup_arch(&command_line); | 502 | setup_arch(&command_line); |
502 | mm_init_owner(&init_mm, &init_task); | 503 | mm_init_owner(&init_mm, &init_task); |
503 | mm_init_cpumask(&init_mm); | 504 | mm_init_cpumask(&init_mm); |
@@ -509,7 +510,7 @@ asmlinkage void __init start_kernel(void) | |||
509 | build_all_zonelists(NULL, NULL); | 510 | build_all_zonelists(NULL, NULL); |
510 | page_alloc_init(); | 511 | page_alloc_init(); |
511 | 512 | ||
512 | printk(KERN_NOTICE "Kernel command line: %s\n", boot_command_line); | 513 | pr_notice("Kernel command line: %s\n", boot_command_line); |
513 | parse_early_param(); | 514 | parse_early_param(); |
514 | parse_args("Booting kernel", static_command_line, __start___param, | 515 | parse_args("Booting kernel", static_command_line, __start___param, |
515 | __stop___param - __start___param, | 516 | __stop___param - __start___param, |
@@ -539,11 +540,8 @@ asmlinkage void __init start_kernel(void) | |||
539 | * fragile until we cpu_idle() for the first time. | 540 | * fragile until we cpu_idle() for the first time. |
540 | */ | 541 | */ |
541 | preempt_disable(); | 542 | preempt_disable(); |
542 | if (!irqs_disabled()) { | 543 | if (WARN(!irqs_disabled(), "Interrupts were enabled *very* early, fixing it\n")) |
543 | printk(KERN_WARNING "start_kernel(): bug: interrupts were " | ||
544 | "enabled *very* early, fixing it\n"); | ||
545 | local_irq_disable(); | 544 | local_irq_disable(); |
546 | } | ||
547 | idr_init_cache(); | 545 | idr_init_cache(); |
548 | perf_event_init(); | 546 | perf_event_init(); |
549 | rcu_init(); | 547 | rcu_init(); |
@@ -558,9 +556,7 @@ asmlinkage void __init start_kernel(void) | |||
558 | time_init(); | 556 | time_init(); |
559 | profile_init(); | 557 | profile_init(); |
560 | call_function_init(); | 558 | call_function_init(); |
561 | if (!irqs_disabled()) | 559 | WARN(!irqs_disabled(), "Interrupts were enabled early\n"); |
562 | printk(KERN_CRIT "start_kernel(): bug: interrupts were " | ||
563 | "enabled early\n"); | ||
564 | early_boot_irqs_disabled = false; | 560 | early_boot_irqs_disabled = false; |
565 | local_irq_enable(); | 561 | local_irq_enable(); |
566 | 562 | ||
@@ -587,8 +583,7 @@ asmlinkage void __init start_kernel(void) | |||
587 | #ifdef CONFIG_BLK_DEV_INITRD | 583 | #ifdef CONFIG_BLK_DEV_INITRD |
588 | if (initrd_start && !initrd_below_start_ok && | 584 | if (initrd_start && !initrd_below_start_ok && |
589 | page_to_pfn(virt_to_page((void *)initrd_start)) < min_low_pfn) { | 585 | page_to_pfn(virt_to_page((void *)initrd_start)) < min_low_pfn) { |
590 | printk(KERN_CRIT "initrd overwritten (0x%08lx < 0x%08lx) - " | 586 | pr_crit("initrd overwritten (0x%08lx < 0x%08lx) - disabling it.\n", |
591 | "disabling it.\n", | ||
592 | page_to_pfn(virt_to_page((void *)initrd_start)), | 587 | page_to_pfn(virt_to_page((void *)initrd_start)), |
593 | min_low_pfn); | 588 | min_low_pfn); |
594 | initrd_start = 0; | 589 | initrd_start = 0; |
@@ -667,14 +662,14 @@ static int __init_or_module do_one_initcall_debug(initcall_t fn) | |||
667 | unsigned long long duration; | 662 | unsigned long long duration; |
668 | int ret; | 663 | int ret; |
669 | 664 | ||
670 | printk(KERN_DEBUG "calling %pF @ %i\n", fn, task_pid_nr(current)); | 665 | pr_debug("calling %pF @ %i\n", fn, task_pid_nr(current)); |
671 | calltime = ktime_get(); | 666 | calltime = ktime_get(); |
672 | ret = fn(); | 667 | ret = fn(); |
673 | rettime = ktime_get(); | 668 | rettime = ktime_get(); |
674 | delta = ktime_sub(rettime, calltime); | 669 | delta = ktime_sub(rettime, calltime); |
675 | duration = (unsigned long long) ktime_to_ns(delta) >> 10; | 670 | duration = (unsigned long long) ktime_to_ns(delta) >> 10; |
676 | printk(KERN_DEBUG "initcall %pF returned %d after %lld usecs\n", fn, | 671 | pr_debug("initcall %pF returned %d after %lld usecs\n", |
677 | ret, duration); | 672 | fn, ret, duration); |
678 | 673 | ||
679 | return ret; | 674 | return ret; |
680 | } | 675 | } |
@@ -702,9 +697,7 @@ int __init_or_module do_one_initcall(initcall_t fn) | |||
702 | strlcat(msgbuf, "disabled interrupts ", sizeof(msgbuf)); | 697 | strlcat(msgbuf, "disabled interrupts ", sizeof(msgbuf)); |
703 | local_irq_enable(); | 698 | local_irq_enable(); |
704 | } | 699 | } |
705 | if (msgbuf[0]) { | 700 | WARN(msgbuf[0], "initcall %pF returned with %s\n", fn, msgbuf); |
706 | printk("initcall %pF returned with %s\n", fn, msgbuf); | ||
707 | } | ||
708 | 701 | ||
709 | return ret; | 702 | return ret; |
710 | } | 703 | } |
@@ -832,8 +825,7 @@ static int __ref kernel_init(void *unused) | |||
832 | if (ramdisk_execute_command) { | 825 | if (ramdisk_execute_command) { |
833 | if (!run_init_process(ramdisk_execute_command)) | 826 | if (!run_init_process(ramdisk_execute_command)) |
834 | return 0; | 827 | return 0; |
835 | printk(KERN_WARNING "Failed to execute %s\n", | 828 | pr_err("Failed to execute %s\n", ramdisk_execute_command); |
836 | ramdisk_execute_command); | ||
837 | } | 829 | } |
838 | 830 | ||
839 | /* | 831 | /* |
@@ -845,8 +837,8 @@ static int __ref kernel_init(void *unused) | |||
845 | if (execute_command) { | 837 | if (execute_command) { |
846 | if (!run_init_process(execute_command)) | 838 | if (!run_init_process(execute_command)) |
847 | return 0; | 839 | return 0; |
848 | printk(KERN_WARNING "Failed to execute %s. Attempting " | 840 | pr_err("Failed to execute %s. Attempting defaults...\n", |
849 | "defaults...\n", execute_command); | 841 | execute_command); |
850 | } | 842 | } |
851 | if (!run_init_process("/sbin/init") || | 843 | if (!run_init_process("/sbin/init") || |
852 | !run_init_process("/etc/init") || | 844 | !run_init_process("/etc/init") || |
@@ -891,7 +883,7 @@ static noinline void __init kernel_init_freeable(void) | |||
891 | 883 | ||
892 | /* Open the /dev/console on the rootfs, this should never fail */ | 884 | /* Open the /dev/console on the rootfs, this should never fail */ |
893 | if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0) | 885 | if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0) |
894 | printk(KERN_WARNING "Warning: unable to open an initial console.\n"); | 886 | pr_err("Warning: unable to open an initial console.\n"); |
895 | 887 | ||
896 | (void) sys_dup(0); | 888 | (void) sys_dup(0); |
897 | (void) sys_dup(0); | 889 | (void) sys_dup(0); |
diff --git a/kernel/printk.c b/kernel/printk.c index abbdd9e2ac82..376914e2869d 100644 --- a/kernel/printk.c +++ b/kernel/printk.c | |||
@@ -49,13 +49,6 @@ | |||
49 | #define CREATE_TRACE_POINTS | 49 | #define CREATE_TRACE_POINTS |
50 | #include <trace/events/printk.h> | 50 | #include <trace/events/printk.h> |
51 | 51 | ||
52 | /* | ||
53 | * Architectures can override it: | ||
54 | */ | ||
55 | void asmlinkage __attribute__((weak)) early_printk(const char *fmt, ...) | ||
56 | { | ||
57 | } | ||
58 | |||
59 | /* printk's without a loglevel use this.. */ | 52 | /* printk's without a loglevel use this.. */ |
60 | #define DEFAULT_MESSAGE_LOGLEVEL CONFIG_DEFAULT_MESSAGE_LOGLEVEL | 53 | #define DEFAULT_MESSAGE_LOGLEVEL CONFIG_DEFAULT_MESSAGE_LOGLEVEL |
61 | 54 | ||
@@ -608,7 +601,8 @@ static unsigned int devkmsg_poll(struct file *file, poll_table *wait) | |||
608 | /* return error when data has vanished underneath us */ | 601 | /* return error when data has vanished underneath us */ |
609 | if (user->seq < log_first_seq) | 602 | if (user->seq < log_first_seq) |
610 | ret = POLLIN|POLLRDNORM|POLLERR|POLLPRI; | 603 | ret = POLLIN|POLLRDNORM|POLLERR|POLLPRI; |
611 | ret = POLLIN|POLLRDNORM; | 604 | else |
605 | ret = POLLIN|POLLRDNORM; | ||
612 | } | 606 | } |
613 | raw_spin_unlock_irq(&logbuf_lock); | 607 | raw_spin_unlock_irq(&logbuf_lock); |
614 | 608 | ||
@@ -1265,7 +1259,7 @@ static void call_console_drivers(int level, const char *text, size_t len) | |||
1265 | { | 1259 | { |
1266 | struct console *con; | 1260 | struct console *con; |
1267 | 1261 | ||
1268 | trace_console(text, 0, len, len); | 1262 | trace_console(text, len); |
1269 | 1263 | ||
1270 | if (level >= console_loglevel && !ignore_loglevel) | 1264 | if (level >= console_loglevel && !ignore_loglevel) |
1271 | return; | 1265 | return; |
@@ -1723,6 +1717,29 @@ static size_t cont_print_text(char *text, size_t size) { return 0; } | |||
1723 | 1717 | ||
1724 | #endif /* CONFIG_PRINTK */ | 1718 | #endif /* CONFIG_PRINTK */ |
1725 | 1719 | ||
1720 | #ifdef CONFIG_EARLY_PRINTK | ||
1721 | struct console *early_console; | ||
1722 | |||
1723 | void early_vprintk(const char *fmt, va_list ap) | ||
1724 | { | ||
1725 | if (early_console) { | ||
1726 | char buf[512]; | ||
1727 | int n = vscnprintf(buf, sizeof(buf), fmt, ap); | ||
1728 | |||
1729 | early_console->write(early_console, buf, n); | ||
1730 | } | ||
1731 | } | ||
1732 | |||
1733 | asmlinkage void early_printk(const char *fmt, ...) | ||
1734 | { | ||
1735 | va_list ap; | ||
1736 | |||
1737 | va_start(ap, fmt); | ||
1738 | early_vprintk(fmt, ap); | ||
1739 | va_end(ap); | ||
1740 | } | ||
1741 | #endif | ||
1742 | |||
1726 | static int __add_preferred_console(char *name, int idx, char *options, | 1743 | static int __add_preferred_console(char *name, int idx, char *options, |
1727 | char *brl_options) | 1744 | char *brl_options) |
1728 | { | 1745 | { |
diff --git a/kernel/rcutree.c b/kernel/rcutree.c index 5b8ad827fd86..2f8530bc4b17 100644 --- a/kernel/rcutree.c +++ b/kernel/rcutree.c | |||
@@ -1319,7 +1319,7 @@ static int rcu_gp_init(struct rcu_state *rsp) | |||
1319 | rnp->grphi, rnp->qsmask); | 1319 | rnp->grphi, rnp->qsmask); |
1320 | raw_spin_unlock_irq(&rnp->lock); | 1320 | raw_spin_unlock_irq(&rnp->lock); |
1321 | #ifdef CONFIG_PROVE_RCU_DELAY | 1321 | #ifdef CONFIG_PROVE_RCU_DELAY |
1322 | if ((random32() % (rcu_num_nodes * 8)) == 0) | 1322 | if ((prandom_u32() % (rcu_num_nodes * 8)) == 0) |
1323 | schedule_timeout_uninterruptible(2); | 1323 | schedule_timeout_uninterruptible(2); |
1324 | #endif /* #ifdef CONFIG_PROVE_RCU_DELAY */ | 1324 | #endif /* #ifdef CONFIG_PROVE_RCU_DELAY */ |
1325 | cond_resched(); | 1325 | cond_resched(); |
diff --git a/kernel/test_kprobes.c b/kernel/test_kprobes.c index f8b11a283171..12d6ebbfdd83 100644 --- a/kernel/test_kprobes.c +++ b/kernel/test_kprobes.c | |||
@@ -365,7 +365,7 @@ int init_test_probes(void) | |||
365 | target2 = kprobe_target2; | 365 | target2 = kprobe_target2; |
366 | 366 | ||
367 | do { | 367 | do { |
368 | rand1 = random32(); | 368 | rand1 = prandom_u32(); |
369 | } while (rand1 <= div_factor); | 369 | } while (rand1 <= div_factor); |
370 | 370 | ||
371 | printk(KERN_INFO "Kprobe smoke test started\n"); | 371 | printk(KERN_INFO "Kprobe smoke test started\n"); |
diff --git a/lib/argv_split.c b/lib/argv_split.c index 1e9a6cbc3689..e927ed0e18a8 100644 --- a/lib/argv_split.c +++ b/lib/argv_split.c | |||
@@ -8,23 +8,17 @@ | |||
8 | #include <linux/slab.h> | 8 | #include <linux/slab.h> |
9 | #include <linux/export.h> | 9 | #include <linux/export.h> |
10 | 10 | ||
11 | static const char *skip_arg(const char *cp) | ||
12 | { | ||
13 | while (*cp && !isspace(*cp)) | ||
14 | cp++; | ||
15 | |||
16 | return cp; | ||
17 | } | ||
18 | |||
19 | static int count_argc(const char *str) | 11 | static int count_argc(const char *str) |
20 | { | 12 | { |
21 | int count = 0; | 13 | int count = 0; |
14 | bool was_space; | ||
22 | 15 | ||
23 | while (*str) { | 16 | for (was_space = true; *str; str++) { |
24 | str = skip_spaces(str); | 17 | if (isspace(*str)) { |
25 | if (*str) { | 18 | was_space = true; |
19 | } else if (was_space) { | ||
20 | was_space = false; | ||
26 | count++; | 21 | count++; |
27 | str = skip_arg(str); | ||
28 | } | 22 | } |
29 | } | 23 | } |
30 | 24 | ||
@@ -39,10 +33,8 @@ static int count_argc(const char *str) | |||
39 | */ | 33 | */ |
40 | void argv_free(char **argv) | 34 | void argv_free(char **argv) |
41 | { | 35 | { |
42 | char **p; | 36 | argv--; |
43 | for (p = argv; *p; p++) | 37 | kfree(argv[0]); |
44 | kfree(*p); | ||
45 | |||
46 | kfree(argv); | 38 | kfree(argv); |
47 | } | 39 | } |
48 | EXPORT_SYMBOL(argv_free); | 40 | EXPORT_SYMBOL(argv_free); |
@@ -59,43 +51,44 @@ EXPORT_SYMBOL(argv_free); | |||
59 | * considered to be a single argument separator. The returned array | 51 | * considered to be a single argument separator. The returned array |
60 | * is always NULL-terminated. Returns NULL on memory allocation | 52 | * is always NULL-terminated. Returns NULL on memory allocation |
61 | * failure. | 53 | * failure. |
54 | * | ||
55 | * The source string at `str' may be undergoing concurrent alteration via | ||
56 | * userspace sysctl activity (at least). The argv_split() implementation | ||
57 | * attempts to handle this gracefully by taking a local copy to work on. | ||
62 | */ | 58 | */ |
63 | char **argv_split(gfp_t gfp, const char *str, int *argcp) | 59 | char **argv_split(gfp_t gfp, const char *str, int *argcp) |
64 | { | 60 | { |
65 | int argc = count_argc(str); | 61 | char *argv_str; |
66 | char **argv = kzalloc(sizeof(*argv) * (argc+1), gfp); | 62 | bool was_space; |
67 | char **argvp; | 63 | char **argv, **argv_ret; |
68 | 64 | int argc; | |
69 | if (argv == NULL) | 65 | |
70 | goto out; | 66 | argv_str = kstrndup(str, KMALLOC_MAX_SIZE - 1, gfp); |
71 | 67 | if (!argv_str) | |
72 | if (argcp) | 68 | return NULL; |
73 | *argcp = argc; | 69 | |
74 | 70 | argc = count_argc(argv_str); | |
75 | argvp = argv; | 71 | argv = kmalloc(sizeof(*argv) * (argc + 2), gfp); |
76 | 72 | if (!argv) { | |
77 | while (*str) { | 73 | kfree(argv_str); |
78 | str = skip_spaces(str); | 74 | return NULL; |
79 | 75 | } | |
80 | if (*str) { | ||
81 | const char *p = str; | ||
82 | char *t; | ||
83 | |||
84 | str = skip_arg(str); | ||
85 | 76 | ||
86 | t = kstrndup(p, str-p, gfp); | 77 | *argv = argv_str; |
87 | if (t == NULL) | 78 | argv_ret = ++argv; |
88 | goto fail; | 79 | for (was_space = true; *argv_str; argv_str++) { |
89 | *argvp++ = t; | 80 | if (isspace(*argv_str)) { |
81 | was_space = true; | ||
82 | *argv_str = 0; | ||
83 | } else if (was_space) { | ||
84 | was_space = false; | ||
85 | *argv++ = argv_str; | ||
90 | } | 86 | } |
91 | } | 87 | } |
92 | *argvp = NULL; | 88 | *argv = NULL; |
93 | |||
94 | out: | ||
95 | return argv; | ||
96 | 89 | ||
97 | fail: | 90 | if (argcp) |
98 | argv_free(argv); | 91 | *argcp = argc; |
99 | return NULL; | 92 | return argv_ret; |
100 | } | 93 | } |
101 | EXPORT_SYMBOL(argv_split); | 94 | EXPORT_SYMBOL(argv_split); |
diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 5276b99ca650..46032453abd5 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c | |||
@@ -281,7 +281,6 @@ static inline int parse_lineno(const char *str, unsigned int *val) | |||
281 | * allow the user to express a query which matches a format | 281 | * allow the user to express a query which matches a format |
282 | * containing embedded spaces. | 282 | * containing embedded spaces. |
283 | */ | 283 | */ |
284 | #define isodigit(c) ((c) >= '0' && (c) <= '7') | ||
285 | static char *unescape(char *str) | 284 | static char *unescape(char *str) |
286 | { | 285 | { |
287 | char *in = str; | 286 | char *in = str; |
diff --git a/lib/fault-inject.c b/lib/fault-inject.c index f7210ad6cffd..c5c7a762b850 100644 --- a/lib/fault-inject.c +++ b/lib/fault-inject.c | |||
@@ -122,7 +122,7 @@ bool should_fail(struct fault_attr *attr, ssize_t size) | |||
122 | return false; | 122 | return false; |
123 | } | 123 | } |
124 | 124 | ||
125 | if (attr->probability <= random32() % 100) | 125 | if (attr->probability <= prandom_u32() % 100) |
126 | return false; | 126 | return false; |
127 | 127 | ||
128 | if (!fail_stacktrace(attr)) | 128 | if (!fail_stacktrace(attr)) |
diff --git a/lib/genalloc.c b/lib/genalloc.c index 54920433705a..b35cfa9bc3d4 100644 --- a/lib/genalloc.c +++ b/lib/genalloc.c | |||
@@ -34,6 +34,8 @@ | |||
34 | #include <linux/rculist.h> | 34 | #include <linux/rculist.h> |
35 | #include <linux/interrupt.h> | 35 | #include <linux/interrupt.h> |
36 | #include <linux/genalloc.h> | 36 | #include <linux/genalloc.h> |
37 | #include <linux/of_address.h> | ||
38 | #include <linux/of_device.h> | ||
37 | 39 | ||
38 | static int set_bits_ll(unsigned long *addr, unsigned long mask_to_set) | 40 | static int set_bits_ll(unsigned long *addr, unsigned long mask_to_set) |
39 | { | 41 | { |
@@ -480,3 +482,82 @@ unsigned long gen_pool_best_fit(unsigned long *map, unsigned long size, | |||
480 | return start_bit; | 482 | return start_bit; |
481 | } | 483 | } |
482 | EXPORT_SYMBOL(gen_pool_best_fit); | 484 | EXPORT_SYMBOL(gen_pool_best_fit); |
485 | |||
486 | static void devm_gen_pool_release(struct device *dev, void *res) | ||
487 | { | ||
488 | gen_pool_destroy(*(struct gen_pool **)res); | ||
489 | } | ||
490 | |||
491 | /** | ||
492 | * devm_gen_pool_create - managed gen_pool_create | ||
493 | * @dev: device that provides the gen_pool | ||
494 | * @min_alloc_order: log base 2 of number of bytes each bitmap bit represents | ||
495 | * @nid: node id of the node the pool structure should be allocated on, or -1 | ||
496 | * | ||
497 | * Create a new special memory pool that can be used to manage special purpose | ||
498 | * memory not managed by the regular kmalloc/kfree interface. The pool will be | ||
499 | * automatically destroyed by the device management code. | ||
500 | */ | ||
501 | struct gen_pool *devm_gen_pool_create(struct device *dev, int min_alloc_order, | ||
502 | int nid) | ||
503 | { | ||
504 | struct gen_pool **ptr, *pool; | ||
505 | |||
506 | ptr = devres_alloc(devm_gen_pool_release, sizeof(*ptr), GFP_KERNEL); | ||
507 | |||
508 | pool = gen_pool_create(min_alloc_order, nid); | ||
509 | if (pool) { | ||
510 | *ptr = pool; | ||
511 | devres_add(dev, ptr); | ||
512 | } else { | ||
513 | devres_free(ptr); | ||
514 | } | ||
515 | |||
516 | return pool; | ||
517 | } | ||
518 | |||
519 | /** | ||
520 | * dev_get_gen_pool - Obtain the gen_pool (if any) for a device | ||
521 | * @dev: device to retrieve the gen_pool from | ||
522 | * @name: Optional name for the gen_pool, usually NULL | ||
523 | * | ||
524 | * Returns the gen_pool for the device if one is present, or NULL. | ||
525 | */ | ||
526 | struct gen_pool *dev_get_gen_pool(struct device *dev) | ||
527 | { | ||
528 | struct gen_pool **p = devres_find(dev, devm_gen_pool_release, NULL, | ||
529 | NULL); | ||
530 | |||
531 | if (!p) | ||
532 | return NULL; | ||
533 | return *p; | ||
534 | } | ||
535 | EXPORT_SYMBOL_GPL(dev_get_gen_pool); | ||
536 | |||
537 | #ifdef CONFIG_OF | ||
538 | /** | ||
539 | * of_get_named_gen_pool - find a pool by phandle property | ||
540 | * @np: device node | ||
541 | * @propname: property name containing phandle(s) | ||
542 | * @index: index into the phandle array | ||
543 | * | ||
544 | * Returns the pool that contains the chunk starting at the physical | ||
545 | * address of the device tree node pointed at by the phandle property, | ||
546 | * or NULL if not found. | ||
547 | */ | ||
548 | struct gen_pool *of_get_named_gen_pool(struct device_node *np, | ||
549 | const char *propname, int index) | ||
550 | { | ||
551 | struct platform_device *pdev; | ||
552 | struct device_node *np_pool; | ||
553 | |||
554 | np_pool = of_parse_phandle(np, propname, index); | ||
555 | if (!np_pool) | ||
556 | return NULL; | ||
557 | pdev = of_find_device_by_node(np_pool); | ||
558 | if (!pdev) | ||
559 | return NULL; | ||
560 | return dev_get_gen_pool(&pdev->dev); | ||
561 | } | ||
562 | EXPORT_SYMBOL_GPL(of_get_named_gen_pool); | ||
563 | #endif /* CONFIG_OF */ | ||
@@ -495,6 +495,33 @@ int idr_alloc(struct idr *idr, void *ptr, int start, int end, gfp_t gfp_mask) | |||
495 | } | 495 | } |
496 | EXPORT_SYMBOL_GPL(idr_alloc); | 496 | EXPORT_SYMBOL_GPL(idr_alloc); |
497 | 497 | ||
498 | /** | ||
499 | * idr_alloc_cyclic - allocate new idr entry in a cyclical fashion | ||
500 | * @idr: the (initialized) idr | ||
501 | * @ptr: pointer to be associated with the new id | ||
502 | * @start: the minimum id (inclusive) | ||
503 | * @end: the maximum id (exclusive, <= 0 for max) | ||
504 | * @gfp_mask: memory allocation flags | ||
505 | * | ||
506 | * Essentially the same as idr_alloc, but prefers to allocate progressively | ||
507 | * higher ids if it can. If the "cur" counter wraps, then it will start again | ||
508 | * at the "start" end of the range and allocate one that has already been used. | ||
509 | */ | ||
510 | int idr_alloc_cyclic(struct idr *idr, void *ptr, int start, int end, | ||
511 | gfp_t gfp_mask) | ||
512 | { | ||
513 | int id; | ||
514 | |||
515 | id = idr_alloc(idr, ptr, max(start, idr->cur), end, gfp_mask); | ||
516 | if (id == -ENOSPC) | ||
517 | id = idr_alloc(idr, ptr, start, end, gfp_mask); | ||
518 | |||
519 | if (likely(id >= 0)) | ||
520 | idr->cur = id + 1; | ||
521 | return id; | ||
522 | } | ||
523 | EXPORT_SYMBOL(idr_alloc_cyclic); | ||
524 | |||
498 | static void idr_remove_warning(int id) | 525 | static void idr_remove_warning(int id) |
499 | { | 526 | { |
500 | printk(KERN_WARNING | 527 | printk(KERN_WARNING |
diff --git a/lib/int_sqrt.c b/lib/int_sqrt.c index fc2eeb7cb2ea..1ef4cc344977 100644 --- a/lib/int_sqrt.c +++ b/lib/int_sqrt.c | |||
@@ -1,3 +1,9 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2013 Davidlohr Bueso <davidlohr.bueso@hp.com> | ||
3 | * | ||
4 | * Based on the shift-and-subtract algorithm for computing integer | ||
5 | * square root from Guy L. Steele. | ||
6 | */ | ||
1 | 7 | ||
2 | #include <linux/kernel.h> | 8 | #include <linux/kernel.h> |
3 | #include <linux/export.h> | 9 | #include <linux/export.h> |
@@ -10,23 +16,23 @@ | |||
10 | */ | 16 | */ |
11 | unsigned long int_sqrt(unsigned long x) | 17 | unsigned long int_sqrt(unsigned long x) |
12 | { | 18 | { |
13 | unsigned long op, res, one; | 19 | unsigned long b, m, y = 0; |
14 | 20 | ||
15 | op = x; | 21 | if (x <= 1) |
16 | res = 0; | 22 | return x; |
17 | 23 | ||
18 | one = 1UL << (BITS_PER_LONG - 2); | 24 | m = 1UL << (BITS_PER_LONG - 2); |
19 | while (one > op) | 25 | while (m != 0) { |
20 | one >>= 2; | 26 | b = y + m; |
27 | y >>= 1; | ||
21 | 28 | ||
22 | while (one != 0) { | 29 | if (x >= b) { |
23 | if (op >= res + one) { | 30 | x -= b; |
24 | op = op - (res + one); | 31 | y += m; |
25 | res = res + 2 * one; | ||
26 | } | 32 | } |
27 | res /= 2; | 33 | m >>= 2; |
28 | one /= 4; | ||
29 | } | 34 | } |
30 | return res; | 35 | |
36 | return y; | ||
31 | } | 37 | } |
32 | EXPORT_SYMBOL(int_sqrt); | 38 | EXPORT_SYMBOL(int_sqrt); |
diff --git a/lib/list_sort.c b/lib/list_sort.c index d7325c6b103f..1183fa70a44d 100644 --- a/lib/list_sort.c +++ b/lib/list_sort.c | |||
@@ -229,7 +229,7 @@ static int __init list_sort_test(void) | |||
229 | goto exit; | 229 | goto exit; |
230 | } | 230 | } |
231 | /* force some equivalencies */ | 231 | /* force some equivalencies */ |
232 | el->value = random32() % (TEST_LIST_LEN/3); | 232 | el->value = prandom_u32() % (TEST_LIST_LEN / 3); |
233 | el->serial = i; | 233 | el->serial = i; |
234 | el->poison1 = TEST_POISON1; | 234 | el->poison1 = TEST_POISON1; |
235 | el->poison2 = TEST_POISON2; | 235 | el->poison2 = TEST_POISON2; |
diff --git a/lib/uuid.c b/lib/uuid.c index 52a6fe6387de..398821e4dce1 100644 --- a/lib/uuid.c +++ b/lib/uuid.c | |||
@@ -25,13 +25,7 @@ | |||
25 | 25 | ||
26 | static void __uuid_gen_common(__u8 b[16]) | 26 | static void __uuid_gen_common(__u8 b[16]) |
27 | { | 27 | { |
28 | int i; | 28 | prandom_bytes(b, 16); |
29 | u32 r; | ||
30 | |||
31 | for (i = 0; i < 4; i++) { | ||
32 | r = random32(); | ||
33 | memcpy(b + i * 4, &r, 4); | ||
34 | } | ||
35 | /* reversion 0b10 */ | 29 | /* reversion 0b10 */ |
36 | b[8] = (b[8] & 0x3F) | 0x80; | 30 | b[8] = (b[8] & 0x3F) | 0x80; |
37 | } | 31 | } |
diff --git a/mm/swapfile.c b/mm/swapfile.c index a1f7772a01fc..d417efddfe74 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c | |||
@@ -2120,7 +2120,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags) | |||
2120 | if (p->bdev) { | 2120 | if (p->bdev) { |
2121 | if (blk_queue_nonrot(bdev_get_queue(p->bdev))) { | 2121 | if (blk_queue_nonrot(bdev_get_queue(p->bdev))) { |
2122 | p->flags |= SWP_SOLIDSTATE; | 2122 | p->flags |= SWP_SOLIDSTATE; |
2123 | p->cluster_next = 1 + (random32() % p->highest_bit); | 2123 | p->cluster_next = 1 + (prandom_u32() % p->highest_bit); |
2124 | } | 2124 | } |
2125 | if ((swap_flags & SWAP_FLAG_DISCARD) && discard_swap(p) == 0) | 2125 | if ((swap_flags & SWAP_FLAG_DISCARD) && discard_swap(p) == 0) |
2126 | p->flags |= SWP_DISCARDABLE; | 2126 | p->flags |= SWP_DISCARDABLE; |
diff --git a/net/core/pktgen.c b/net/core/pktgen.c index 6048fc1da1c2..5c217427a669 100644 --- a/net/core/pktgen.c +++ b/net/core/pktgen.c | |||
@@ -2198,7 +2198,7 @@ static inline int f_pick(struct pktgen_dev *pkt_dev) | |||
2198 | pkt_dev->curfl = 0; /*reset */ | 2198 | pkt_dev->curfl = 0; /*reset */ |
2199 | } | 2199 | } |
2200 | } else { | 2200 | } else { |
2201 | flow = random32() % pkt_dev->cflows; | 2201 | flow = prandom_u32() % pkt_dev->cflows; |
2202 | pkt_dev->curfl = flow; | 2202 | pkt_dev->curfl = flow; |
2203 | 2203 | ||
2204 | if (pkt_dev->flows[flow].count > pkt_dev->lflow) { | 2204 | if (pkt_dev->flows[flow].count > pkt_dev->lflow) { |
@@ -2246,7 +2246,7 @@ static void set_cur_queue_map(struct pktgen_dev *pkt_dev) | |||
2246 | else if (pkt_dev->queue_map_min <= pkt_dev->queue_map_max) { | 2246 | else if (pkt_dev->queue_map_min <= pkt_dev->queue_map_max) { |
2247 | __u16 t; | 2247 | __u16 t; |
2248 | if (pkt_dev->flags & F_QUEUE_MAP_RND) { | 2248 | if (pkt_dev->flags & F_QUEUE_MAP_RND) { |
2249 | t = random32() % | 2249 | t = prandom_u32() % |
2250 | (pkt_dev->queue_map_max - | 2250 | (pkt_dev->queue_map_max - |
2251 | pkt_dev->queue_map_min + 1) | 2251 | pkt_dev->queue_map_min + 1) |
2252 | + pkt_dev->queue_map_min; | 2252 | + pkt_dev->queue_map_min; |
@@ -2278,7 +2278,7 @@ static void mod_cur_headers(struct pktgen_dev *pkt_dev) | |||
2278 | __u32 tmp; | 2278 | __u32 tmp; |
2279 | 2279 | ||
2280 | if (pkt_dev->flags & F_MACSRC_RND) | 2280 | if (pkt_dev->flags & F_MACSRC_RND) |
2281 | mc = random32() % pkt_dev->src_mac_count; | 2281 | mc = prandom_u32() % pkt_dev->src_mac_count; |
2282 | else { | 2282 | else { |
2283 | mc = pkt_dev->cur_src_mac_offset++; | 2283 | mc = pkt_dev->cur_src_mac_offset++; |
2284 | if (pkt_dev->cur_src_mac_offset >= | 2284 | if (pkt_dev->cur_src_mac_offset >= |
@@ -2304,7 +2304,7 @@ static void mod_cur_headers(struct pktgen_dev *pkt_dev) | |||
2304 | __u32 tmp; | 2304 | __u32 tmp; |
2305 | 2305 | ||
2306 | if (pkt_dev->flags & F_MACDST_RND) | 2306 | if (pkt_dev->flags & F_MACDST_RND) |
2307 | mc = random32() % pkt_dev->dst_mac_count; | 2307 | mc = prandom_u32() % pkt_dev->dst_mac_count; |
2308 | 2308 | ||
2309 | else { | 2309 | else { |
2310 | mc = pkt_dev->cur_dst_mac_offset++; | 2310 | mc = pkt_dev->cur_dst_mac_offset++; |
@@ -2331,21 +2331,21 @@ static void mod_cur_headers(struct pktgen_dev *pkt_dev) | |||
2331 | for (i = 0; i < pkt_dev->nr_labels; i++) | 2331 | for (i = 0; i < pkt_dev->nr_labels; i++) |
2332 | if (pkt_dev->labels[i] & MPLS_STACK_BOTTOM) | 2332 | if (pkt_dev->labels[i] & MPLS_STACK_BOTTOM) |
2333 | pkt_dev->labels[i] = MPLS_STACK_BOTTOM | | 2333 | pkt_dev->labels[i] = MPLS_STACK_BOTTOM | |
2334 | ((__force __be32)random32() & | 2334 | ((__force __be32)prandom_u32() & |
2335 | htonl(0x000fffff)); | 2335 | htonl(0x000fffff)); |
2336 | } | 2336 | } |
2337 | 2337 | ||
2338 | if ((pkt_dev->flags & F_VID_RND) && (pkt_dev->vlan_id != 0xffff)) { | 2338 | if ((pkt_dev->flags & F_VID_RND) && (pkt_dev->vlan_id != 0xffff)) { |
2339 | pkt_dev->vlan_id = random32() & (4096-1); | 2339 | pkt_dev->vlan_id = prandom_u32() & (4096 - 1); |
2340 | } | 2340 | } |
2341 | 2341 | ||
2342 | if ((pkt_dev->flags & F_SVID_RND) && (pkt_dev->svlan_id != 0xffff)) { | 2342 | if ((pkt_dev->flags & F_SVID_RND) && (pkt_dev->svlan_id != 0xffff)) { |
2343 | pkt_dev->svlan_id = random32() & (4096 - 1); | 2343 | pkt_dev->svlan_id = prandom_u32() & (4096 - 1); |
2344 | } | 2344 | } |
2345 | 2345 | ||
2346 | if (pkt_dev->udp_src_min < pkt_dev->udp_src_max) { | 2346 | if (pkt_dev->udp_src_min < pkt_dev->udp_src_max) { |
2347 | if (pkt_dev->flags & F_UDPSRC_RND) | 2347 | if (pkt_dev->flags & F_UDPSRC_RND) |
2348 | pkt_dev->cur_udp_src = random32() % | 2348 | pkt_dev->cur_udp_src = prandom_u32() % |
2349 | (pkt_dev->udp_src_max - pkt_dev->udp_src_min) | 2349 | (pkt_dev->udp_src_max - pkt_dev->udp_src_min) |
2350 | + pkt_dev->udp_src_min; | 2350 | + pkt_dev->udp_src_min; |
2351 | 2351 | ||
@@ -2358,7 +2358,7 @@ static void mod_cur_headers(struct pktgen_dev *pkt_dev) | |||
2358 | 2358 | ||
2359 | if (pkt_dev->udp_dst_min < pkt_dev->udp_dst_max) { | 2359 | if (pkt_dev->udp_dst_min < pkt_dev->udp_dst_max) { |
2360 | if (pkt_dev->flags & F_UDPDST_RND) { | 2360 | if (pkt_dev->flags & F_UDPDST_RND) { |
2361 | pkt_dev->cur_udp_dst = random32() % | 2361 | pkt_dev->cur_udp_dst = prandom_u32() % |
2362 | (pkt_dev->udp_dst_max - pkt_dev->udp_dst_min) | 2362 | (pkt_dev->udp_dst_max - pkt_dev->udp_dst_min) |
2363 | + pkt_dev->udp_dst_min; | 2363 | + pkt_dev->udp_dst_min; |
2364 | } else { | 2364 | } else { |
@@ -2375,7 +2375,7 @@ static void mod_cur_headers(struct pktgen_dev *pkt_dev) | |||
2375 | if (imn < imx) { | 2375 | if (imn < imx) { |
2376 | __u32 t; | 2376 | __u32 t; |
2377 | if (pkt_dev->flags & F_IPSRC_RND) | 2377 | if (pkt_dev->flags & F_IPSRC_RND) |
2378 | t = random32() % (imx - imn) + imn; | 2378 | t = prandom_u32() % (imx - imn) + imn; |
2379 | else { | 2379 | else { |
2380 | t = ntohl(pkt_dev->cur_saddr); | 2380 | t = ntohl(pkt_dev->cur_saddr); |
2381 | t++; | 2381 | t++; |
@@ -2396,17 +2396,15 @@ static void mod_cur_headers(struct pktgen_dev *pkt_dev) | |||
2396 | __be32 s; | 2396 | __be32 s; |
2397 | if (pkt_dev->flags & F_IPDST_RND) { | 2397 | if (pkt_dev->flags & F_IPDST_RND) { |
2398 | 2398 | ||
2399 | t = random32() % (imx - imn) + imn; | 2399 | do { |
2400 | s = htonl(t); | 2400 | t = prandom_u32() % |
2401 | 2401 | (imx - imn) + imn; | |
2402 | while (ipv4_is_loopback(s) || | ||
2403 | ipv4_is_multicast(s) || | ||
2404 | ipv4_is_lbcast(s) || | ||
2405 | ipv4_is_zeronet(s) || | ||
2406 | ipv4_is_local_multicast(s)) { | ||
2407 | t = random32() % (imx - imn) + imn; | ||
2408 | s = htonl(t); | 2402 | s = htonl(t); |
2409 | } | 2403 | } while (ipv4_is_loopback(s) || |
2404 | ipv4_is_multicast(s) || | ||
2405 | ipv4_is_lbcast(s) || | ||
2406 | ipv4_is_zeronet(s) || | ||
2407 | ipv4_is_local_multicast(s)); | ||
2410 | pkt_dev->cur_daddr = s; | 2408 | pkt_dev->cur_daddr = s; |
2411 | } else { | 2409 | } else { |
2412 | t = ntohl(pkt_dev->cur_daddr); | 2410 | t = ntohl(pkt_dev->cur_daddr); |
@@ -2437,7 +2435,7 @@ static void mod_cur_headers(struct pktgen_dev *pkt_dev) | |||
2437 | 2435 | ||
2438 | for (i = 0; i < 4; i++) { | 2436 | for (i = 0; i < 4; i++) { |
2439 | pkt_dev->cur_in6_daddr.s6_addr32[i] = | 2437 | pkt_dev->cur_in6_daddr.s6_addr32[i] = |
2440 | (((__force __be32)random32() | | 2438 | (((__force __be32)prandom_u32() | |
2441 | pkt_dev->min_in6_daddr.s6_addr32[i]) & | 2439 | pkt_dev->min_in6_daddr.s6_addr32[i]) & |
2442 | pkt_dev->max_in6_daddr.s6_addr32[i]); | 2440 | pkt_dev->max_in6_daddr.s6_addr32[i]); |
2443 | } | 2441 | } |
@@ -2447,7 +2445,7 @@ static void mod_cur_headers(struct pktgen_dev *pkt_dev) | |||
2447 | if (pkt_dev->min_pkt_size < pkt_dev->max_pkt_size) { | 2445 | if (pkt_dev->min_pkt_size < pkt_dev->max_pkt_size) { |
2448 | __u32 t; | 2446 | __u32 t; |
2449 | if (pkt_dev->flags & F_TXSIZE_RND) { | 2447 | if (pkt_dev->flags & F_TXSIZE_RND) { |
2450 | t = random32() % | 2448 | t = prandom_u32() % |
2451 | (pkt_dev->max_pkt_size - pkt_dev->min_pkt_size) | 2449 | (pkt_dev->max_pkt_size - pkt_dev->min_pkt_size) |
2452 | + pkt_dev->min_pkt_size; | 2450 | + pkt_dev->min_pkt_size; |
2453 | } else { | 2451 | } else { |
diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c index c8e001a9c45b..f84965af4a4e 100644 --- a/net/netfilter/nf_conntrack_core.c +++ b/net/netfilter/nf_conntrack_core.c | |||
@@ -264,7 +264,7 @@ static void death_by_event(unsigned long ul_conntrack) | |||
264 | if (nf_conntrack_event(IPCT_DESTROY, ct) < 0) { | 264 | if (nf_conntrack_event(IPCT_DESTROY, ct) < 0) { |
265 | /* bad luck, let's retry again */ | 265 | /* bad luck, let's retry again */ |
266 | ecache->timeout.expires = jiffies + | 266 | ecache->timeout.expires = jiffies + |
267 | (random32() % net->ct.sysctl_events_retry_timeout); | 267 | (prandom_u32() % net->ct.sysctl_events_retry_timeout); |
268 | add_timer(&ecache->timeout); | 268 | add_timer(&ecache->timeout); |
269 | return; | 269 | return; |
270 | } | 270 | } |
@@ -283,7 +283,7 @@ void nf_ct_dying_timeout(struct nf_conn *ct) | |||
283 | /* set a new timer to retry event delivery */ | 283 | /* set a new timer to retry event delivery */ |
284 | setup_timer(&ecache->timeout, death_by_event, (unsigned long)ct); | 284 | setup_timer(&ecache->timeout, death_by_event, (unsigned long)ct); |
285 | ecache->timeout.expires = jiffies + | 285 | ecache->timeout.expires = jiffies + |
286 | (random32() % net->ct.sysctl_events_retry_timeout); | 286 | (prandom_u32() % net->ct.sysctl_events_retry_timeout); |
287 | add_timer(&ecache->timeout); | 287 | add_timer(&ecache->timeout); |
288 | } | 288 | } |
289 | EXPORT_SYMBOL_GPL(nf_ct_dying_timeout); | 289 | EXPORT_SYMBOL_GPL(nf_ct_dying_timeout); |
diff --git a/net/sched/sch_choke.c b/net/sched/sch_choke.c index cc37dd52ecf9..ef53ab8d0aae 100644 --- a/net/sched/sch_choke.c +++ b/net/sched/sch_choke.c | |||
@@ -80,7 +80,7 @@ struct choke_sched_data { | |||
80 | /* deliver a random number between 0 and N - 1 */ | 80 | /* deliver a random number between 0 and N - 1 */ |
81 | static u32 random_N(unsigned int N) | 81 | static u32 random_N(unsigned int N) |
82 | { | 82 | { |
83 | return reciprocal_divide(random32(), N); | 83 | return reciprocal_divide(prandom_u32(), N); |
84 | } | 84 | } |
85 | 85 | ||
86 | /* number of elements in queue including holes */ | 86 | /* number of elements in queue including holes */ |
diff --git a/net/sctp/associola.c b/net/sctp/associola.c index d2709e2b7be6..fa261a3594c2 100644 --- a/net/sctp/associola.c +++ b/net/sctp/associola.c | |||
@@ -66,13 +66,6 @@ static void sctp_assoc_bh_rcv(struct work_struct *work); | |||
66 | static void sctp_assoc_free_asconf_acks(struct sctp_association *asoc); | 66 | static void sctp_assoc_free_asconf_acks(struct sctp_association *asoc); |
67 | static void sctp_assoc_free_asconf_queue(struct sctp_association *asoc); | 67 | static void sctp_assoc_free_asconf_queue(struct sctp_association *asoc); |
68 | 68 | ||
69 | /* Keep track of the new idr low so that we don't re-use association id | ||
70 | * numbers too fast. It is protected by they idr spin lock is in the | ||
71 | * range of 1 - INT_MAX. | ||
72 | */ | ||
73 | static u32 idr_low = 1; | ||
74 | |||
75 | |||
76 | /* 1st Level Abstractions. */ | 69 | /* 1st Level Abstractions. */ |
77 | 70 | ||
78 | /* Initialize a new association from provided memory. */ | 71 | /* Initialize a new association from provided memory. */ |
@@ -1601,13 +1594,8 @@ int sctp_assoc_set_id(struct sctp_association *asoc, gfp_t gfp) | |||
1601 | if (preload) | 1594 | if (preload) |
1602 | idr_preload(gfp); | 1595 | idr_preload(gfp); |
1603 | spin_lock_bh(&sctp_assocs_id_lock); | 1596 | spin_lock_bh(&sctp_assocs_id_lock); |
1604 | /* 0 is not a valid id, idr_low is always >= 1 */ | 1597 | /* 0 is not a valid assoc_id, must be >= 1 */ |
1605 | ret = idr_alloc(&sctp_assocs_id, asoc, idr_low, 0, GFP_NOWAIT); | 1598 | ret = idr_alloc_cyclic(&sctp_assocs_id, asoc, 1, 0, GFP_NOWAIT); |
1606 | if (ret >= 0) { | ||
1607 | idr_low = ret + 1; | ||
1608 | if (idr_low == INT_MAX) | ||
1609 | idr_low = 1; | ||
1610 | } | ||
1611 | spin_unlock_bh(&sctp_assocs_id_lock); | 1599 | spin_unlock_bh(&sctp_assocs_id_lock); |
1612 | if (preload) | 1600 | if (preload) |
1613 | idr_preload_end(); | 1601 | idr_preload_end(); |
diff --git a/net/sunrpc/auth_gss/gss_krb5_wrap.c b/net/sunrpc/auth_gss/gss_krb5_wrap.c index 88edec929d73..1da52d1406fc 100644 --- a/net/sunrpc/auth_gss/gss_krb5_wrap.c +++ b/net/sunrpc/auth_gss/gss_krb5_wrap.c | |||
@@ -130,8 +130,8 @@ gss_krb5_make_confounder(char *p, u32 conflen) | |||
130 | 130 | ||
131 | /* initialize to random value */ | 131 | /* initialize to random value */ |
132 | if (i == 0) { | 132 | if (i == 0) { |
133 | i = random32(); | 133 | i = prandom_u32(); |
134 | i = (i << 32) | random32(); | 134 | i = (i << 32) | prandom_u32(); |
135 | } | 135 | } |
136 | 136 | ||
137 | switch (conflen) { | 137 | switch (conflen) { |
diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c index 25d58e766014..ce2d180d05a4 100644 --- a/net/sunrpc/cache.c +++ b/net/sunrpc/cache.c | |||
@@ -1208,7 +1208,6 @@ EXPORT_SYMBOL_GPL(sunrpc_cache_pipe_upcall); | |||
1208 | * key and content are both parsed by cache | 1208 | * key and content are both parsed by cache |
1209 | */ | 1209 | */ |
1210 | 1210 | ||
1211 | #define isodigit(c) (isdigit(c) && c <= '7') | ||
1212 | int qword_get(char **bpp, char *dest, int bufsize) | 1211 | int qword_get(char **bpp, char *dest, int bufsize) |
1213 | { | 1212 | { |
1214 | /* return bytes copied, or -1 on error */ | 1213 | /* return bytes copied, or -1 on error */ |
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 4de4bc48493b..b954de58304f 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl | |||
@@ -281,6 +281,7 @@ our $signature_tags = qr{(?xi: | |||
281 | Tested-by:| | 281 | Tested-by:| |
282 | Reviewed-by:| | 282 | Reviewed-by:| |
283 | Reported-by:| | 283 | Reported-by:| |
284 | Suggested-by:| | ||
284 | To:| | 285 | To:| |
285 | Cc: | 286 | Cc: |
286 | )}; | 287 | )}; |
@@ -628,6 +629,13 @@ sub sanitise_line { | |||
628 | return $res; | 629 | return $res; |
629 | } | 630 | } |
630 | 631 | ||
632 | sub get_quoted_string { | ||
633 | my ($line, $rawline) = @_; | ||
634 | |||
635 | return "" if ($line !~ m/(\"[X]+\")/g); | ||
636 | return substr($rawline, $-[0], $+[0] - $-[0]); | ||
637 | } | ||
638 | |||
631 | sub ctx_statement_block { | 639 | sub ctx_statement_block { |
632 | my ($linenr, $remain, $off) = @_; | 640 | my ($linenr, $remain, $off) = @_; |
633 | my $line = $linenr - 1; | 641 | my $line = $linenr - 1; |
@@ -1576,7 +1584,8 @@ sub process { | |||
1576 | # Check for incorrect file permissions | 1584 | # Check for incorrect file permissions |
1577 | if ($line =~ /^new (file )?mode.*[7531]\d{0,2}$/) { | 1585 | if ($line =~ /^new (file )?mode.*[7531]\d{0,2}$/) { |
1578 | my $permhere = $here . "FILE: $realfile\n"; | 1586 | my $permhere = $here . "FILE: $realfile\n"; |
1579 | if ($realfile =~ /(Makefile|Kconfig|\.c|\.h|\.S|\.tmpl)$/) { | 1587 | if ($realfile !~ m@scripts/@ && |
1588 | $realfile !~ /\.(py|pl|awk|sh)$/) { | ||
1580 | ERROR("EXECUTE_PERMISSIONS", | 1589 | ERROR("EXECUTE_PERMISSIONS", |
1581 | "do not set execute permissions for source files\n" . $permhere); | 1590 | "do not set execute permissions for source files\n" . $permhere); |
1582 | } | 1591 | } |
@@ -2514,8 +2523,8 @@ sub process { | |||
2514 | 2523 | ||
2515 | # check for whitespace before a non-naked semicolon | 2524 | # check for whitespace before a non-naked semicolon |
2516 | if ($line =~ /^\+.*\S\s+;/) { | 2525 | if ($line =~ /^\+.*\S\s+;/) { |
2517 | CHK("SPACING", | 2526 | WARN("SPACING", |
2518 | "space prohibited before semicolon\n" . $herecurr); | 2527 | "space prohibited before semicolon\n" . $herecurr); |
2519 | } | 2528 | } |
2520 | 2529 | ||
2521 | # Check operator spacing. | 2530 | # Check operator spacing. |
@@ -3221,7 +3230,7 @@ sub process { | |||
3221 | } | 3230 | } |
3222 | 3231 | ||
3223 | # check for unnecessary blank lines around braces | 3232 | # check for unnecessary blank lines around braces |
3224 | if (($line =~ /^..*}\s*$/ && $prevline =~ /^.\s*$/)) { | 3233 | if (($line =~ /^.\s*}\s*$/ && $prevline =~ /^.\s*$/)) { |
3225 | CHK("BRACES", | 3234 | CHK("BRACES", |
3226 | "Blank lines aren't necessary before a close brace '}'\n" . $hereprev); | 3235 | "Blank lines aren't necessary before a close brace '}'\n" . $hereprev); |
3227 | } | 3236 | } |
@@ -3373,6 +3382,15 @@ sub process { | |||
3373 | "struct spinlock should be spinlock_t\n" . $herecurr); | 3382 | "struct spinlock should be spinlock_t\n" . $herecurr); |
3374 | } | 3383 | } |
3375 | 3384 | ||
3385 | # check for seq_printf uses that could be seq_puts | ||
3386 | if ($line =~ /\bseq_printf\s*\(/) { | ||
3387 | my $fmt = get_quoted_string($line, $rawline); | ||
3388 | if ($fmt !~ /[^\\]\%/) { | ||
3389 | WARN("PREFER_SEQ_PUTS", | ||
3390 | "Prefer seq_puts to seq_printf\n" . $herecurr); | ||
3391 | } | ||
3392 | } | ||
3393 | |||
3376 | # Check for misused memsets | 3394 | # Check for misused memsets |
3377 | if ($^V && $^V ge 5.10.0 && | 3395 | if ($^V && $^V ge 5.10.0 && |
3378 | defined $stat && | 3396 | defined $stat && |
@@ -3477,6 +3495,13 @@ sub process { | |||
3477 | "unnecessary cast may hide bugs, see http://c-faq.com/malloc/mallocnocast.html\n" . $herecurr); | 3495 | "unnecessary cast may hide bugs, see http://c-faq.com/malloc/mallocnocast.html\n" . $herecurr); |
3478 | } | 3496 | } |
3479 | 3497 | ||
3498 | # check for krealloc arg reuse | ||
3499 | if ($^V && $^V ge 5.10.0 && | ||
3500 | $line =~ /\b($Lval)\s*\=\s*(?:$balanced_parens)?\s*krealloc\s*\(\s*\1\s*,/) { | ||
3501 | WARN("KREALLOC_ARG_REUSE", | ||
3502 | "Reusing the krealloc arg is almost always a bug\n" . $herecurr); | ||
3503 | } | ||
3504 | |||
3480 | # check for alloc argument mismatch | 3505 | # check for alloc argument mismatch |
3481 | if ($line =~ /\b(kcalloc|kmalloc_array)\s*\(\s*sizeof\b/) { | 3506 | if ($line =~ /\b(kcalloc|kmalloc_array)\s*\(\s*sizeof\b/) { |
3482 | WARN("ALLOC_ARRAY_ARGS", | 3507 | WARN("ALLOC_ARRAY_ARGS", |
diff --git a/scripts/get_maintainer.pl b/scripts/get_maintainer.pl index ce4cc837b748..5e4fb144a04f 100755 --- a/scripts/get_maintainer.pl +++ b/scripts/get_maintainer.pl | |||
@@ -611,7 +611,7 @@ sub get_maintainers { | |||
611 | $hash{$tvi} = $value_pd; | 611 | $hash{$tvi} = $value_pd; |
612 | } | 612 | } |
613 | } | 613 | } |
614 | } elsif ($type eq 'K') { | 614 | } elsif ($type eq 'N') { |
615 | if ($file =~ m/$value/x) { | 615 | if ($file =~ m/$value/x) { |
616 | $hash{$tvi} = 0; | 616 | $hash{$tvi} = 0; |
617 | } | 617 | } |