diff options
204 files changed, 3595 insertions, 2651 deletions
diff --git a/Documentation/ABI/stable/sysfs-bus-usb b/Documentation/ABI/stable/sysfs-bus-usb index 2be603c52a24..a6b685724740 100644 --- a/Documentation/ABI/stable/sysfs-bus-usb +++ b/Documentation/ABI/stable/sysfs-bus-usb | |||
@@ -37,8 +37,8 @@ Description: | |||
37 | that the USB device has been connected to the machine. This | 37 | that the USB device has been connected to the machine. This |
38 | file is read-only. | 38 | file is read-only. |
39 | Users: | 39 | Users: |
40 | PowerTOP <power@bughost.org> | 40 | PowerTOP <powertop@lists.01.org> |
41 | http://www.lesswatts.org/projects/powertop/ | 41 | https://01.org/powertop/ |
42 | 42 | ||
43 | What: /sys/bus/usb/device/.../power/active_duration | 43 | What: /sys/bus/usb/device/.../power/active_duration |
44 | Date: January 2008 | 44 | Date: January 2008 |
@@ -57,8 +57,8 @@ Description: | |||
57 | will give an integer percentage. Note that this does not | 57 | will give an integer percentage. Note that this does not |
58 | account for counter wrap. | 58 | account for counter wrap. |
59 | Users: | 59 | Users: |
60 | PowerTOP <power@bughost.org> | 60 | PowerTOP <powertop@lists.01.org> |
61 | http://www.lesswatts.org/projects/powertop/ | 61 | https://01.org/powertop/ |
62 | 62 | ||
63 | What: /sys/bus/usb/devices/<busnum>-<port[.port]>...:<config num>-<interface num>/supports_autosuspend | 63 | What: /sys/bus/usb/devices/<busnum>-<port[.port]>...:<config num>-<interface num>/supports_autosuspend |
64 | Date: January 2008 | 64 | Date: January 2008 |
diff --git a/Documentation/ABI/testing/sysfs-devices-power b/Documentation/ABI/testing/sysfs-devices-power index 9d43e7670841..efe449bdf811 100644 --- a/Documentation/ABI/testing/sysfs-devices-power +++ b/Documentation/ABI/testing/sysfs-devices-power | |||
@@ -1,6 +1,6 @@ | |||
1 | What: /sys/devices/.../power/ | 1 | What: /sys/devices/.../power/ |
2 | Date: January 2009 | 2 | Date: January 2009 |
3 | Contact: Rafael J. Wysocki <rjw@sisk.pl> | 3 | Contact: Rafael J. Wysocki <rjw@rjwysocki.net> |
4 | Description: | 4 | Description: |
5 | The /sys/devices/.../power directory contains attributes | 5 | The /sys/devices/.../power directory contains attributes |
6 | allowing the user space to check and modify some power | 6 | allowing the user space to check and modify some power |
@@ -8,7 +8,7 @@ Description: | |||
8 | 8 | ||
9 | What: /sys/devices/.../power/wakeup | 9 | What: /sys/devices/.../power/wakeup |
10 | Date: January 2009 | 10 | Date: January 2009 |
11 | Contact: Rafael J. Wysocki <rjw@sisk.pl> | 11 | Contact: Rafael J. Wysocki <rjw@rjwysocki.net> |
12 | Description: | 12 | Description: |
13 | The /sys/devices/.../power/wakeup attribute allows the user | 13 | The /sys/devices/.../power/wakeup attribute allows the user |
14 | space to check if the device is enabled to wake up the system | 14 | space to check if the device is enabled to wake up the system |
@@ -34,7 +34,7 @@ Description: | |||
34 | 34 | ||
35 | What: /sys/devices/.../power/control | 35 | What: /sys/devices/.../power/control |
36 | Date: January 2009 | 36 | Date: January 2009 |
37 | Contact: Rafael J. Wysocki <rjw@sisk.pl> | 37 | Contact: Rafael J. Wysocki <rjw@rjwysocki.net> |
38 | Description: | 38 | Description: |
39 | The /sys/devices/.../power/control attribute allows the user | 39 | The /sys/devices/.../power/control attribute allows the user |
40 | space to control the run-time power management of the device. | 40 | space to control the run-time power management of the device. |
@@ -53,7 +53,7 @@ Description: | |||
53 | 53 | ||
54 | What: /sys/devices/.../power/async | 54 | What: /sys/devices/.../power/async |
55 | Date: January 2009 | 55 | Date: January 2009 |
56 | Contact: Rafael J. Wysocki <rjw@sisk.pl> | 56 | Contact: Rafael J. Wysocki <rjw@rjwysocki.net> |
57 | Description: | 57 | Description: |
58 | The /sys/devices/.../async attribute allows the user space to | 58 | The /sys/devices/.../async attribute allows the user space to |
59 | enable or diasble the device's suspend and resume callbacks to | 59 | enable or diasble the device's suspend and resume callbacks to |
@@ -79,7 +79,7 @@ Description: | |||
79 | 79 | ||
80 | What: /sys/devices/.../power/wakeup_count | 80 | What: /sys/devices/.../power/wakeup_count |
81 | Date: September 2010 | 81 | Date: September 2010 |
82 | Contact: Rafael J. Wysocki <rjw@sisk.pl> | 82 | Contact: Rafael J. Wysocki <rjw@rjwysocki.net> |
83 | Description: | 83 | Description: |
84 | The /sys/devices/.../wakeup_count attribute contains the number | 84 | The /sys/devices/.../wakeup_count attribute contains the number |
85 | of signaled wakeup events associated with the device. This | 85 | of signaled wakeup events associated with the device. This |
@@ -88,7 +88,7 @@ Description: | |||
88 | 88 | ||
89 | What: /sys/devices/.../power/wakeup_active_count | 89 | What: /sys/devices/.../power/wakeup_active_count |
90 | Date: September 2010 | 90 | Date: September 2010 |
91 | Contact: Rafael J. Wysocki <rjw@sisk.pl> | 91 | Contact: Rafael J. Wysocki <rjw@rjwysocki.net> |
92 | Description: | 92 | Description: |
93 | The /sys/devices/.../wakeup_active_count attribute contains the | 93 | The /sys/devices/.../wakeup_active_count attribute contains the |
94 | number of times the processing of wakeup events associated with | 94 | number of times the processing of wakeup events associated with |
@@ -98,7 +98,7 @@ Description: | |||
98 | 98 | ||
99 | What: /sys/devices/.../power/wakeup_abort_count | 99 | What: /sys/devices/.../power/wakeup_abort_count |
100 | Date: February 2012 | 100 | Date: February 2012 |
101 | Contact: Rafael J. Wysocki <rjw@sisk.pl> | 101 | Contact: Rafael J. Wysocki <rjw@rjwysocki.net> |
102 | Description: | 102 | Description: |
103 | The /sys/devices/.../wakeup_abort_count attribute contains the | 103 | The /sys/devices/.../wakeup_abort_count attribute contains the |
104 | number of times the processing of a wakeup event associated with | 104 | number of times the processing of a wakeup event associated with |
@@ -109,7 +109,7 @@ Description: | |||
109 | 109 | ||
110 | What: /sys/devices/.../power/wakeup_expire_count | 110 | What: /sys/devices/.../power/wakeup_expire_count |
111 | Date: February 2012 | 111 | Date: February 2012 |
112 | Contact: Rafael J. Wysocki <rjw@sisk.pl> | 112 | Contact: Rafael J. Wysocki <rjw@rjwysocki.net> |
113 | Description: | 113 | Description: |
114 | The /sys/devices/.../wakeup_expire_count attribute contains the | 114 | The /sys/devices/.../wakeup_expire_count attribute contains the |
115 | number of times a wakeup event associated with the device has | 115 | number of times a wakeup event associated with the device has |
@@ -119,7 +119,7 @@ Description: | |||
119 | 119 | ||
120 | What: /sys/devices/.../power/wakeup_active | 120 | What: /sys/devices/.../power/wakeup_active |
121 | Date: September 2010 | 121 | Date: September 2010 |
122 | Contact: Rafael J. Wysocki <rjw@sisk.pl> | 122 | Contact: Rafael J. Wysocki <rjw@rjwysocki.net> |
123 | Description: | 123 | Description: |
124 | The /sys/devices/.../wakeup_active attribute contains either 1, | 124 | The /sys/devices/.../wakeup_active attribute contains either 1, |
125 | or 0, depending on whether or not a wakeup event associated with | 125 | or 0, depending on whether or not a wakeup event associated with |
@@ -129,7 +129,7 @@ Description: | |||
129 | 129 | ||
130 | What: /sys/devices/.../power/wakeup_total_time_ms | 130 | What: /sys/devices/.../power/wakeup_total_time_ms |
131 | Date: September 2010 | 131 | Date: September 2010 |
132 | Contact: Rafael J. Wysocki <rjw@sisk.pl> | 132 | Contact: Rafael J. Wysocki <rjw@rjwysocki.net> |
133 | Description: | 133 | Description: |
134 | The /sys/devices/.../wakeup_total_time_ms attribute contains | 134 | The /sys/devices/.../wakeup_total_time_ms attribute contains |
135 | the total time of processing wakeup events associated with the | 135 | the total time of processing wakeup events associated with the |
@@ -139,7 +139,7 @@ Description: | |||
139 | 139 | ||
140 | What: /sys/devices/.../power/wakeup_max_time_ms | 140 | What: /sys/devices/.../power/wakeup_max_time_ms |
141 | Date: September 2010 | 141 | Date: September 2010 |
142 | Contact: Rafael J. Wysocki <rjw@sisk.pl> | 142 | Contact: Rafael J. Wysocki <rjw@rjwysocki.net> |
143 | Description: | 143 | Description: |
144 | The /sys/devices/.../wakeup_max_time_ms attribute contains | 144 | The /sys/devices/.../wakeup_max_time_ms attribute contains |
145 | the maximum time of processing a single wakeup event associated | 145 | the maximum time of processing a single wakeup event associated |
@@ -149,7 +149,7 @@ Description: | |||
149 | 149 | ||
150 | What: /sys/devices/.../power/wakeup_last_time_ms | 150 | What: /sys/devices/.../power/wakeup_last_time_ms |
151 | Date: September 2010 | 151 | Date: September 2010 |
152 | Contact: Rafael J. Wysocki <rjw@sisk.pl> | 152 | Contact: Rafael J. Wysocki <rjw@rjwysocki.net> |
153 | Description: | 153 | Description: |
154 | The /sys/devices/.../wakeup_last_time_ms attribute contains | 154 | The /sys/devices/.../wakeup_last_time_ms attribute contains |
155 | the value of the monotonic clock corresponding to the time of | 155 | the value of the monotonic clock corresponding to the time of |
@@ -160,7 +160,7 @@ Description: | |||
160 | 160 | ||
161 | What: /sys/devices/.../power/wakeup_prevent_sleep_time_ms | 161 | What: /sys/devices/.../power/wakeup_prevent_sleep_time_ms |
162 | Date: February 2012 | 162 | Date: February 2012 |
163 | Contact: Rafael J. Wysocki <rjw@sisk.pl> | 163 | Contact: Rafael J. Wysocki <rjw@rjwysocki.net> |
164 | Description: | 164 | Description: |
165 | The /sys/devices/.../wakeup_prevent_sleep_time_ms attribute | 165 | The /sys/devices/.../wakeup_prevent_sleep_time_ms attribute |
166 | contains the total time the device has been preventing | 166 | contains the total time the device has been preventing |
@@ -189,7 +189,7 @@ Description: | |||
189 | 189 | ||
190 | What: /sys/devices/.../power/pm_qos_latency_us | 190 | What: /sys/devices/.../power/pm_qos_latency_us |
191 | Date: March 2012 | 191 | Date: March 2012 |
192 | Contact: Rafael J. Wysocki <rjw@sisk.pl> | 192 | Contact: Rafael J. Wysocki <rjw@rjwysocki.net> |
193 | Description: | 193 | Description: |
194 | The /sys/devices/.../power/pm_qos_resume_latency_us attribute | 194 | The /sys/devices/.../power/pm_qos_resume_latency_us attribute |
195 | contains the PM QoS resume latency limit for the given device, | 195 | contains the PM QoS resume latency limit for the given device, |
@@ -207,7 +207,7 @@ Description: | |||
207 | 207 | ||
208 | What: /sys/devices/.../power/pm_qos_no_power_off | 208 | What: /sys/devices/.../power/pm_qos_no_power_off |
209 | Date: September 2012 | 209 | Date: September 2012 |
210 | Contact: Rafael J. Wysocki <rjw@sisk.pl> | 210 | Contact: Rafael J. Wysocki <rjw@rjwysocki.net> |
211 | Description: | 211 | Description: |
212 | The /sys/devices/.../power/pm_qos_no_power_off attribute | 212 | The /sys/devices/.../power/pm_qos_no_power_off attribute |
213 | is used for manipulating the PM QoS "no power off" flag. If | 213 | is used for manipulating the PM QoS "no power off" flag. If |
@@ -222,7 +222,7 @@ Description: | |||
222 | 222 | ||
223 | What: /sys/devices/.../power/pm_qos_remote_wakeup | 223 | What: /sys/devices/.../power/pm_qos_remote_wakeup |
224 | Date: September 2012 | 224 | Date: September 2012 |
225 | Contact: Rafael J. Wysocki <rjw@sisk.pl> | 225 | Contact: Rafael J. Wysocki <rjw@rjwysocki.net> |
226 | Description: | 226 | Description: |
227 | The /sys/devices/.../power/pm_qos_remote_wakeup attribute | 227 | The /sys/devices/.../power/pm_qos_remote_wakeup attribute |
228 | is used for manipulating the PM QoS "remote wakeup required" | 228 | is used for manipulating the PM QoS "remote wakeup required" |
diff --git a/Documentation/ABI/testing/sysfs-power b/Documentation/ABI/testing/sysfs-power index 217772615d02..205a73878441 100644 --- a/Documentation/ABI/testing/sysfs-power +++ b/Documentation/ABI/testing/sysfs-power | |||
@@ -1,6 +1,6 @@ | |||
1 | What: /sys/power/ | 1 | What: /sys/power/ |
2 | Date: August 2006 | 2 | Date: August 2006 |
3 | Contact: Rafael J. Wysocki <rjw@sisk.pl> | 3 | Contact: Rafael J. Wysocki <rjw@rjwysocki.net> |
4 | Description: | 4 | Description: |
5 | The /sys/power directory will contain files that will | 5 | The /sys/power directory will contain files that will |
6 | provide a unified interface to the power management | 6 | provide a unified interface to the power management |
@@ -8,7 +8,7 @@ Description: | |||
8 | 8 | ||
9 | What: /sys/power/state | 9 | What: /sys/power/state |
10 | Date: August 2006 | 10 | Date: August 2006 |
11 | Contact: Rafael J. Wysocki <rjw@sisk.pl> | 11 | Contact: Rafael J. Wysocki <rjw@rjwysocki.net> |
12 | Description: | 12 | Description: |
13 | The /sys/power/state file controls the system power state. | 13 | The /sys/power/state file controls the system power state. |
14 | Reading from this file returns what states are supported, | 14 | Reading from this file returns what states are supported, |
@@ -22,7 +22,7 @@ Description: | |||
22 | 22 | ||
23 | What: /sys/power/disk | 23 | What: /sys/power/disk |
24 | Date: September 2006 | 24 | Date: September 2006 |
25 | Contact: Rafael J. Wysocki <rjw@sisk.pl> | 25 | Contact: Rafael J. Wysocki <rjw@rjwysocki.net> |
26 | Description: | 26 | Description: |
27 | The /sys/power/disk file controls the operating mode of the | 27 | The /sys/power/disk file controls the operating mode of the |
28 | suspend-to-disk mechanism. Reading from this file returns | 28 | suspend-to-disk mechanism. Reading from this file returns |
@@ -67,7 +67,7 @@ Description: | |||
67 | 67 | ||
68 | What: /sys/power/image_size | 68 | What: /sys/power/image_size |
69 | Date: August 2006 | 69 | Date: August 2006 |
70 | Contact: Rafael J. Wysocki <rjw@sisk.pl> | 70 | Contact: Rafael J. Wysocki <rjw@rjwysocki.net> |
71 | Description: | 71 | Description: |
72 | The /sys/power/image_size file controls the size of the image | 72 | The /sys/power/image_size file controls the size of the image |
73 | created by the suspend-to-disk mechanism. It can be written a | 73 | created by the suspend-to-disk mechanism. It can be written a |
@@ -84,7 +84,7 @@ Description: | |||
84 | 84 | ||
85 | What: /sys/power/pm_trace | 85 | What: /sys/power/pm_trace |
86 | Date: August 2006 | 86 | Date: August 2006 |
87 | Contact: Rafael J. Wysocki <rjw@sisk.pl> | 87 | Contact: Rafael J. Wysocki <rjw@rjwysocki.net> |
88 | Description: | 88 | Description: |
89 | The /sys/power/pm_trace file controls the code which saves the | 89 | The /sys/power/pm_trace file controls the code which saves the |
90 | last PM event point in the RTC across reboots, so that you can | 90 | last PM event point in the RTC across reboots, so that you can |
@@ -133,7 +133,7 @@ Description: | |||
133 | 133 | ||
134 | What: /sys/power/pm_async | 134 | What: /sys/power/pm_async |
135 | Date: January 2009 | 135 | Date: January 2009 |
136 | Contact: Rafael J. Wysocki <rjw@sisk.pl> | 136 | Contact: Rafael J. Wysocki <rjw@rjwysocki.net> |
137 | Description: | 137 | Description: |
138 | The /sys/power/pm_async file controls the switch allowing the | 138 | The /sys/power/pm_async file controls the switch allowing the |
139 | user space to enable or disable asynchronous suspend and resume | 139 | user space to enable or disable asynchronous suspend and resume |
@@ -146,7 +146,7 @@ Description: | |||
146 | 146 | ||
147 | What: /sys/power/wakeup_count | 147 | What: /sys/power/wakeup_count |
148 | Date: July 2010 | 148 | Date: July 2010 |
149 | Contact: Rafael J. Wysocki <rjw@sisk.pl> | 149 | Contact: Rafael J. Wysocki <rjw@rjwysocki.net> |
150 | Description: | 150 | Description: |
151 | The /sys/power/wakeup_count file allows user space to put the | 151 | The /sys/power/wakeup_count file allows user space to put the |
152 | system into a sleep state while taking into account the | 152 | system into a sleep state while taking into account the |
@@ -161,7 +161,7 @@ Description: | |||
161 | 161 | ||
162 | What: /sys/power/reserved_size | 162 | What: /sys/power/reserved_size |
163 | Date: May 2011 | 163 | Date: May 2011 |
164 | Contact: Rafael J. Wysocki <rjw@sisk.pl> | 164 | Contact: Rafael J. Wysocki <rjw@rjwysocki.net> |
165 | Description: | 165 | Description: |
166 | The /sys/power/reserved_size file allows user space to control | 166 | The /sys/power/reserved_size file allows user space to control |
167 | the amount of memory reserved for allocations made by device | 167 | the amount of memory reserved for allocations made by device |
@@ -175,7 +175,7 @@ Description: | |||
175 | 175 | ||
176 | What: /sys/power/autosleep | 176 | What: /sys/power/autosleep |
177 | Date: April 2012 | 177 | Date: April 2012 |
178 | Contact: Rafael J. Wysocki <rjw@sisk.pl> | 178 | Contact: Rafael J. Wysocki <rjw@rjwysocki.net> |
179 | Description: | 179 | Description: |
180 | The /sys/power/autosleep file can be written one of the strings | 180 | The /sys/power/autosleep file can be written one of the strings |
181 | returned by reads from /sys/power/state. If that happens, a | 181 | returned by reads from /sys/power/state. If that happens, a |
@@ -192,7 +192,7 @@ Description: | |||
192 | 192 | ||
193 | What: /sys/power/wake_lock | 193 | What: /sys/power/wake_lock |
194 | Date: February 2012 | 194 | Date: February 2012 |
195 | Contact: Rafael J. Wysocki <rjw@sisk.pl> | 195 | Contact: Rafael J. Wysocki <rjw@rjwysocki.net> |
196 | Description: | 196 | Description: |
197 | The /sys/power/wake_lock file allows user space to create | 197 | The /sys/power/wake_lock file allows user space to create |
198 | wakeup source objects and activate them on demand (if one of | 198 | wakeup source objects and activate them on demand (if one of |
@@ -219,7 +219,7 @@ Description: | |||
219 | 219 | ||
220 | What: /sys/power/wake_unlock | 220 | What: /sys/power/wake_unlock |
221 | Date: February 2012 | 221 | Date: February 2012 |
222 | Contact: Rafael J. Wysocki <rjw@sisk.pl> | 222 | Contact: Rafael J. Wysocki <rjw@rjwysocki.net> |
223 | Description: | 223 | Description: |
224 | The /sys/power/wake_unlock file allows user space to deactivate | 224 | The /sys/power/wake_unlock file allows user space to deactivate |
225 | wakeup sources created with the help of /sys/power/wake_lock. | 225 | wakeup sources created with the help of /sys/power/wake_lock. |
diff --git a/Documentation/acpi/dsdt-override.txt b/Documentation/acpi/dsdt-override.txt index febbb1ba4d23..784841caa6e6 100644 --- a/Documentation/acpi/dsdt-override.txt +++ b/Documentation/acpi/dsdt-override.txt | |||
@@ -4,4 +4,4 @@ CONFIG_ACPI_CUSTOM_DSDT builds the image into the kernel. | |||
4 | 4 | ||
5 | When to use this method is described in detail on the | 5 | When to use this method is described in detail on the |
6 | Linux/ACPI home page: | 6 | Linux/ACPI home page: |
7 | http://www.lesswatts.org/projects/acpi/overridingDSDT.php | 7 | https://01.org/linux-acpi/documentation/overriding-dsdt |
diff --git a/Documentation/devicetree/bindings/memory.txt b/Documentation/devicetree/bindings/memory.txt deleted file mode 100644 index eb2469365593..000000000000 --- a/Documentation/devicetree/bindings/memory.txt +++ /dev/null | |||
@@ -1,168 +0,0 @@ | |||
1 | *** Memory binding *** | ||
2 | |||
3 | The /memory node provides basic information about the address and size | ||
4 | of the physical memory. This node is usually filled or updated by the | ||
5 | bootloader, depending on the actual memory configuration of the given | ||
6 | hardware. | ||
7 | |||
8 | The memory layout is described by the following node: | ||
9 | |||
10 | / { | ||
11 | #address-cells = <(n)>; | ||
12 | #size-cells = <(m)>; | ||
13 | memory { | ||
14 | device_type = "memory"; | ||
15 | reg = <(baseaddr1) (size1) | ||
16 | (baseaddr2) (size2) | ||
17 | ... | ||
18 | (baseaddrN) (sizeN)>; | ||
19 | }; | ||
20 | ... | ||
21 | }; | ||
22 | |||
23 | A memory node follows the typical device tree rules for "reg" property: | ||
24 | n: number of cells used to store base address value | ||
25 | m: number of cells used to store size value | ||
26 | baseaddrX: defines a base address of the defined memory bank | ||
27 | sizeX: the size of the defined memory bank | ||
28 | |||
29 | |||
30 | More than one memory bank can be defined. | ||
31 | |||
32 | |||
33 | *** Reserved memory regions *** | ||
34 | |||
35 | In /memory/reserved-memory node one can create child nodes describing | ||
36 | particular reserved (excluded from normal use) memory regions. Such | ||
37 | memory regions are usually designed for the special usage by various | ||
38 | device drivers. A good example are contiguous memory allocations or | ||
39 | memory sharing with other operating system on the same hardware board. | ||
40 | Those special memory regions might depend on the board configuration and | ||
41 | devices used on the target system. | ||
42 | |||
43 | Parameters for each memory region can be encoded into the device tree | ||
44 | with the following convention: | ||
45 | |||
46 | [(label):] (name) { | ||
47 | compatible = "linux,contiguous-memory-region", "reserved-memory-region"; | ||
48 | reg = <(address) (size)>; | ||
49 | (linux,default-contiguous-region); | ||
50 | }; | ||
51 | |||
52 | compatible: one or more of: | ||
53 | - "linux,contiguous-memory-region" - enables binding of this | ||
54 | region to Contiguous Memory Allocator (special region for | ||
55 | contiguous memory allocations, shared with movable system | ||
56 | memory, Linux kernel-specific). | ||
57 | - "reserved-memory-region" - compatibility is defined, given | ||
58 | region is assigned for exclusive usage for by the respective | ||
59 | devices. | ||
60 | |||
61 | reg: standard property defining the base address and size of | ||
62 | the memory region | ||
63 | |||
64 | linux,default-contiguous-region: property indicating that the region | ||
65 | is the default region for all contiguous memory | ||
66 | allocations, Linux specific (optional) | ||
67 | |||
68 | It is optional to specify the base address, so if one wants to use | ||
69 | autoconfiguration of the base address, '0' can be specified as a base | ||
70 | address in the 'reg' property. | ||
71 | |||
72 | The /memory/reserved-memory node must contain the same #address-cells | ||
73 | and #size-cells value as the root node. | ||
74 | |||
75 | |||
76 | *** Device node's properties *** | ||
77 | |||
78 | Once regions in the /memory/reserved-memory node have been defined, they | ||
79 | may be referenced by other device nodes. Bindings that wish to reference | ||
80 | memory regions should explicitly document their use of the following | ||
81 | property: | ||
82 | |||
83 | memory-region = <&phandle_to_defined_region>; | ||
84 | |||
85 | This property indicates that the device driver should use the memory | ||
86 | region pointed by the given phandle. | ||
87 | |||
88 | |||
89 | *** Example *** | ||
90 | |||
91 | This example defines a memory consisting of 4 memory banks. 3 contiguous | ||
92 | regions are defined for Linux kernel, one default of all device drivers | ||
93 | (named contig_mem, placed at 0x72000000, 64MiB), one dedicated to the | ||
94 | framebuffer device (labelled display_mem, placed at 0x78000000, 8MiB) | ||
95 | and one for multimedia processing (labelled multimedia_mem, placed at | ||
96 | 0x77000000, 64MiB). 'display_mem' region is then assigned to fb@12300000 | ||
97 | device for DMA memory allocations (Linux kernel drivers will use CMA is | ||
98 | available or dma-exclusive usage otherwise). 'multimedia_mem' is | ||
99 | assigned to scaler@12500000 and codec@12600000 devices for contiguous | ||
100 | memory allocations when CMA driver is enabled. | ||
101 | |||
102 | The reason for creating a separate region for framebuffer device is to | ||
103 | match the framebuffer base address to the one configured by bootloader, | ||
104 | so once Linux kernel drivers starts no glitches on the displayed boot | ||
105 | logo appears. Scaller and codec drivers should share the memory | ||
106 | allocations. | ||
107 | |||
108 | / { | ||
109 | #address-cells = <1>; | ||
110 | #size-cells = <1>; | ||
111 | |||
112 | /* ... */ | ||
113 | |||
114 | memory { | ||
115 | reg = <0x40000000 0x10000000 | ||
116 | 0x50000000 0x10000000 | ||
117 | 0x60000000 0x10000000 | ||
118 | 0x70000000 0x10000000>; | ||
119 | |||
120 | reserved-memory { | ||
121 | #address-cells = <1>; | ||
122 | #size-cells = <1>; | ||
123 | |||
124 | /* | ||
125 | * global autoconfigured region for contiguous allocations | ||
126 | * (used only with Contiguous Memory Allocator) | ||
127 | */ | ||
128 | contig_region@0 { | ||
129 | compatible = "linux,contiguous-memory-region"; | ||
130 | reg = <0x0 0x4000000>; | ||
131 | linux,default-contiguous-region; | ||
132 | }; | ||
133 | |||
134 | /* | ||
135 | * special region for framebuffer | ||
136 | */ | ||
137 | display_region: region@78000000 { | ||
138 | compatible = "linux,contiguous-memory-region", "reserved-memory-region"; | ||
139 | reg = <0x78000000 0x800000>; | ||
140 | }; | ||
141 | |||
142 | /* | ||
143 | * special region for multimedia processing devices | ||
144 | */ | ||
145 | multimedia_region: region@77000000 { | ||
146 | compatible = "linux,contiguous-memory-region"; | ||
147 | reg = <0x77000000 0x4000000>; | ||
148 | }; | ||
149 | }; | ||
150 | }; | ||
151 | |||
152 | /* ... */ | ||
153 | |||
154 | fb0: fb@12300000 { | ||
155 | status = "okay"; | ||
156 | memory-region = <&display_region>; | ||
157 | }; | ||
158 | |||
159 | scaler: scaler@12500000 { | ||
160 | status = "okay"; | ||
161 | memory-region = <&multimedia_region>; | ||
162 | }; | ||
163 | |||
164 | codec: codec@12600000 { | ||
165 | status = "okay"; | ||
166 | memory-region = <&multimedia_region>; | ||
167 | }; | ||
168 | }; | ||
diff --git a/Documentation/devicetree/bindings/regulator/as3722-regulator.txt b/Documentation/devicetree/bindings/regulator/as3722-regulator.txt new file mode 100644 index 000000000000..caad0c8a258d --- /dev/null +++ b/Documentation/devicetree/bindings/regulator/as3722-regulator.txt | |||
@@ -0,0 +1,91 @@ | |||
1 | Regulator of AMS AS3722 PMIC. | ||
2 | Name of the regulator subnode must be "regulators". | ||
3 | |||
4 | Optional properties: | ||
5 | -------------------- | ||
6 | The input supply of regulators are the optional properties on the | ||
7 | regulator node. The AS3722 is having 7 DCDC step-down regulators as | ||
8 | sd[0-6], 10 LDOs as ldo[0-7], ldo[9-11]. The input supply of these | ||
9 | regulators are provided through following properties: | ||
10 | vsup-sd2-supply: Input supply for SD2. | ||
11 | vsup-sd3-supply: Input supply for SD3. | ||
12 | vsup-sd4-supply: Input supply for SD4. | ||
13 | vsup-sd5-supply: Input supply for SD5. | ||
14 | vin-ldo0-supply: Input supply for LDO0. | ||
15 | vin-ldo1-6-supply: Input supply for LDO1 and LDO6. | ||
16 | vin-ldo2-5-7-supply: Input supply for LDO2, LDO5 and LDO7. | ||
17 | vin-ldo3-4-supply: Input supply for LDO3 and LDO4. | ||
18 | vin-ldo9-10-supply: Input supply for LDO9 and LDO10. | ||
19 | vin-ldo11-supply: Input supply for LDO11. | ||
20 | |||
21 | Optional nodes: | ||
22 | -------------- | ||
23 | - regulators : Must contain a sub-node per regulator from the list below. | ||
24 | Each sub-node should contain the constraints and initialization | ||
25 | information for that regulator. See regulator.txt for a | ||
26 | description of standard properties for these sub-nodes. | ||
27 | Additional custom properties are listed below. | ||
28 | sd[0-6], ldo[0-7], ldo[9-11]. | ||
29 | |||
30 | Optional sub-node properties: | ||
31 | ---------------------------- | ||
32 | ams,ext-control: External control of the rail. The option of | ||
33 | this properties will tell which external input is | ||
34 | controlling this rail. Valid values are 0, 1, 2 ad 3. | ||
35 | 0: There is no external control of this rail. | ||
36 | 1: Rail is controlled by ENABLE1 input pin. | ||
37 | 2: Rail is controlled by ENABLE2 input pin. | ||
38 | 3: Rail is controlled by ENABLE3 input pin. | ||
39 | ams,enable-tracking: Enable tracking with SD1, only supported | ||
40 | by LDO3. | ||
41 | |||
42 | Example: | ||
43 | ------- | ||
44 | ams3722: ams3722 { | ||
45 | compatible = "ams,as3722"; | ||
46 | reg = <0x40>; | ||
47 | ... | ||
48 | |||
49 | regulators { | ||
50 | vsup-sd2-supply = <...>; | ||
51 | ... | ||
52 | |||
53 | sd0 { | ||
54 | regulator-name = "vdd_cpu"; | ||
55 | regulator-min-microvolt = <700000>; | ||
56 | regulator-max-microvolt = <1400000>; | ||
57 | regulator-always-on; | ||
58 | ams,ext-control = <2>; | ||
59 | }; | ||
60 | |||
61 | sd1 { | ||
62 | regulator-name = "vdd_core"; | ||
63 | regulator-min-microvolt = <700000>; | ||
64 | regulator-max-microvolt = <1400000>; | ||
65 | regulator-always-on; | ||
66 | ams,ext-control = <1>; | ||
67 | }; | ||
68 | |||
69 | sd2 { | ||
70 | regulator-name = "vddio_ddr"; | ||
71 | regulator-min-microvolt = <1350000>; | ||
72 | regulator-max-microvolt = <1350000>; | ||
73 | regulator-always-on; | ||
74 | }; | ||
75 | |||
76 | sd4 { | ||
77 | regulator-name = "avdd-hdmi-pex"; | ||
78 | regulator-min-microvolt = <1050000>; | ||
79 | regulator-max-microvolt = <1050000>; | ||
80 | regulator-always-on; | ||
81 | }; | ||
82 | |||
83 | sd5 { | ||
84 | regulator-name = "vdd-1v8"; | ||
85 | regulator-min-microvolt = <1800000>; | ||
86 | regulator-max-microvolt = <1800000>; | ||
87 | regulator-always-on; | ||
88 | }; | ||
89 | .... | ||
90 | }; | ||
91 | }; | ||
diff --git a/Documentation/devicetree/bindings/regulator/da9210.txt b/Documentation/devicetree/bindings/regulator/da9210.txt new file mode 100644 index 000000000000..f120f229d67d --- /dev/null +++ b/Documentation/devicetree/bindings/regulator/da9210.txt | |||
@@ -0,0 +1,21 @@ | |||
1 | * Dialog Semiconductor DA9210 Voltage Regulator | ||
2 | |||
3 | Required properties: | ||
4 | |||
5 | - compatible: must be "diasemi,da9210" | ||
6 | - reg: the i2c slave address of the regulator. It should be 0x68. | ||
7 | |||
8 | Any standard regulator properties can be used to configure the single da9210 | ||
9 | DCDC. | ||
10 | |||
11 | Example: | ||
12 | |||
13 | da9210@68 { | ||
14 | compatible = "diasemi,da9210"; | ||
15 | reg = <0x68>; | ||
16 | |||
17 | regulator-min-microvolt = <900000>; | ||
18 | regulator-max-microvolt = <1000000>; | ||
19 | regulator-boot-on; | ||
20 | regulator-always-on; | ||
21 | }; | ||
diff --git a/Documentation/devicetree/bindings/regulator/palmas-pmic.txt b/Documentation/devicetree/bindings/regulator/palmas-pmic.txt index 875639ae0606..42e6b6bc48ff 100644 --- a/Documentation/devicetree/bindings/regulator/palmas-pmic.txt +++ b/Documentation/devicetree/bindings/regulator/palmas-pmic.txt | |||
@@ -26,11 +26,17 @@ Optional nodes: | |||
26 | 26 | ||
27 | For ti,palmas-pmic - smps12, smps123, smps3 depending on OTP, | 27 | For ti,palmas-pmic - smps12, smps123, smps3 depending on OTP, |
28 | smps45, smps457, smps7 depending on variant, smps6, smps[8-9], | 28 | smps45, smps457, smps7 depending on variant, smps6, smps[8-9], |
29 | smps10_out2, smps10_out1, do[1-9], ldoln, ldousb. | 29 | smps10_out2, smps10_out1, ldo[1-9], ldoln, ldousb. |
30 | 30 | ||
31 | Optional sub-node properties: | 31 | Optional sub-node properties: |
32 | ti,warm-reset - maintain voltage during warm reset(boolean) | 32 | ti,warm-reset - maintain voltage during warm reset(boolean) |
33 | ti,roof-floor - control voltage selection by pin(boolean) | 33 | ti,roof-floor - This takes as optional argument on platform supporting |
34 | the rail from desired external control. If there is no argument then | ||
35 | it will be assume that it is controlled by NSLEEP pin. | ||
36 | The valid value for external pins are: | ||
37 | ENABLE1 then 1, | ||
38 | ENABLE2 then 2 or | ||
39 | NSLEEP then 3. | ||
34 | ti,mode-sleep - mode to adopt in pmic sleep 0 - off, 1 - auto, | 40 | ti,mode-sleep - mode to adopt in pmic sleep 0 - off, 1 - auto, |
35 | 2 - eco, 3 - forced pwm | 41 | 2 - eco, 3 - forced pwm |
36 | ti,smps-range - OTP has the wrong range set for the hardware so override | 42 | ti,smps-range - OTP has the wrong range set for the hardware so override |
@@ -61,7 +67,7 @@ pmic { | |||
61 | regulator-always-on; | 67 | regulator-always-on; |
62 | regulator-boot-on; | 68 | regulator-boot-on; |
63 | ti,warm-reset; | 69 | ti,warm-reset; |
64 | ti,roof-floor; | 70 | ti,roof-floor = <1>; /* ENABLE1 control */ |
65 | ti,mode-sleep = <0>; | 71 | ti,mode-sleep = <0>; |
66 | ti,smps-range = <1>; | 72 | ti,smps-range = <1>; |
67 | }; | 73 | }; |
diff --git a/Documentation/devicetree/bindings/regulator/regulator.txt b/Documentation/devicetree/bindings/regulator/regulator.txt index 2bd8f0978765..e2c7f1e7251a 100644 --- a/Documentation/devicetree/bindings/regulator/regulator.txt +++ b/Documentation/devicetree/bindings/regulator/regulator.txt | |||
@@ -14,6 +14,11 @@ Optional properties: | |||
14 | - regulator-ramp-delay: ramp delay for regulator(in uV/uS) | 14 | - regulator-ramp-delay: ramp delay for regulator(in uV/uS) |
15 | For hardwares which support disabling ramp rate, it should be explicitly | 15 | For hardwares which support disabling ramp rate, it should be explicitly |
16 | intialised to zero (regulator-ramp-delay = <0>) for disabling ramp delay. | 16 | intialised to zero (regulator-ramp-delay = <0>) for disabling ramp delay. |
17 | - regulator-enable-ramp-delay: The time taken, in microseconds, for the supply | ||
18 | rail to reach the target voltage, plus/minus whatever tolerance the board | ||
19 | design requires. This property describes the total system ramp time | ||
20 | required due to the combination of internal ramping of the regulator itself, | ||
21 | and board design issues such as trace capacitance and load on the supply. | ||
17 | 22 | ||
18 | Deprecated properties: | 23 | Deprecated properties: |
19 | - regulator-compatible: If a regulator chip contains multiple | 24 | - regulator-compatible: If a regulator chip contains multiple |
diff --git a/Documentation/driver-model/devres.txt b/Documentation/driver-model/devres.txt index fcb34a5697ea..3d9c2a766230 100644 --- a/Documentation/driver-model/devres.txt +++ b/Documentation/driver-model/devres.txt | |||
@@ -283,6 +283,7 @@ REGULATOR | |||
283 | devm_regulator_get() | 283 | devm_regulator_get() |
284 | devm_regulator_put() | 284 | devm_regulator_put() |
285 | devm_regulator_bulk_get() | 285 | devm_regulator_bulk_get() |
286 | devm_regulator_register() | ||
286 | 287 | ||
287 | CLOCK | 288 | CLOCK |
288 | devm_clk_get() | 289 | devm_clk_get() |
diff --git a/MAINTAINERS b/MAINTAINERS index 8a0cbf3cf2c8..a7c34ef3509d 100644 --- a/MAINTAINERS +++ b/MAINTAINERS | |||
@@ -237,11 +237,11 @@ F: drivers/platform/x86/acer-wmi.c | |||
237 | 237 | ||
238 | ACPI | 238 | ACPI |
239 | M: Len Brown <lenb@kernel.org> | 239 | M: Len Brown <lenb@kernel.org> |
240 | M: Rafael J. Wysocki <rjw@sisk.pl> | 240 | M: Rafael J. Wysocki <rjw@rjwysocki.net> |
241 | L: linux-acpi@vger.kernel.org | 241 | L: linux-acpi@vger.kernel.org |
242 | W: http://www.lesswatts.org/projects/acpi/ | 242 | W: https://01.org/linux-acpi |
243 | Q: http://patchwork.kernel.org/project/linux-acpi/list/ | 243 | Q: https://patchwork.kernel.org/project/linux-acpi/list/ |
244 | T: git git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux | 244 | T: git git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm |
245 | S: Supported | 245 | S: Supported |
246 | F: drivers/acpi/ | 246 | F: drivers/acpi/ |
247 | F: drivers/pnp/pnpacpi/ | 247 | F: drivers/pnp/pnpacpi/ |
@@ -256,21 +256,21 @@ F: drivers/pci/*/*/*acpi* | |||
256 | ACPI FAN DRIVER | 256 | ACPI FAN DRIVER |
257 | M: Zhang Rui <rui.zhang@intel.com> | 257 | M: Zhang Rui <rui.zhang@intel.com> |
258 | L: linux-acpi@vger.kernel.org | 258 | L: linux-acpi@vger.kernel.org |
259 | W: http://www.lesswatts.org/projects/acpi/ | 259 | W: https://01.org/linux-acpi |
260 | S: Supported | 260 | S: Supported |
261 | F: drivers/acpi/fan.c | 261 | F: drivers/acpi/fan.c |
262 | 262 | ||
263 | ACPI THERMAL DRIVER | 263 | ACPI THERMAL DRIVER |
264 | M: Zhang Rui <rui.zhang@intel.com> | 264 | M: Zhang Rui <rui.zhang@intel.com> |
265 | L: linux-acpi@vger.kernel.org | 265 | L: linux-acpi@vger.kernel.org |
266 | W: http://www.lesswatts.org/projects/acpi/ | 266 | W: https://01.org/linux-acpi |
267 | S: Supported | 267 | S: Supported |
268 | F: drivers/acpi/*thermal* | 268 | F: drivers/acpi/*thermal* |
269 | 269 | ||
270 | ACPI VIDEO DRIVER | 270 | ACPI VIDEO DRIVER |
271 | M: Zhang Rui <rui.zhang@intel.com> | 271 | M: Zhang Rui <rui.zhang@intel.com> |
272 | L: linux-acpi@vger.kernel.org | 272 | L: linux-acpi@vger.kernel.org |
273 | W: http://www.lesswatts.org/projects/acpi/ | 273 | W: https://01.org/linux-acpi |
274 | S: Supported | 274 | S: Supported |
275 | F: drivers/acpi/video.c | 275 | F: drivers/acpi/video.c |
276 | 276 | ||
@@ -2300,7 +2300,7 @@ S: Maintained | |||
2300 | F: drivers/net/ethernet/ti/cpmac.c | 2300 | F: drivers/net/ethernet/ti/cpmac.c |
2301 | 2301 | ||
2302 | CPU FREQUENCY DRIVERS | 2302 | CPU FREQUENCY DRIVERS |
2303 | M: Rafael J. Wysocki <rjw@sisk.pl> | 2303 | M: Rafael J. Wysocki <rjw@rjwysocki.net> |
2304 | M: Viresh Kumar <viresh.kumar@linaro.org> | 2304 | M: Viresh Kumar <viresh.kumar@linaro.org> |
2305 | L: cpufreq@vger.kernel.org | 2305 | L: cpufreq@vger.kernel.org |
2306 | L: linux-pm@vger.kernel.org | 2306 | L: linux-pm@vger.kernel.org |
@@ -2331,7 +2331,7 @@ S: Maintained | |||
2331 | F: drivers/cpuidle/cpuidle-big_little.c | 2331 | F: drivers/cpuidle/cpuidle-big_little.c |
2332 | 2332 | ||
2333 | CPUIDLE DRIVERS | 2333 | CPUIDLE DRIVERS |
2334 | M: Rafael J. Wysocki <rjw@sisk.pl> | 2334 | M: Rafael J. Wysocki <rjw@rjwysocki.net> |
2335 | M: Daniel Lezcano <daniel.lezcano@linaro.org> | 2335 | M: Daniel Lezcano <daniel.lezcano@linaro.org> |
2336 | L: linux-pm@vger.kernel.org | 2336 | L: linux-pm@vger.kernel.org |
2337 | S: Maintained | 2337 | S: Maintained |
@@ -3553,7 +3553,7 @@ F: fs/freevxfs/ | |||
3553 | 3553 | ||
3554 | FREEZER | 3554 | FREEZER |
3555 | M: Pavel Machek <pavel@ucw.cz> | 3555 | M: Pavel Machek <pavel@ucw.cz> |
3556 | M: "Rafael J. Wysocki" <rjw@sisk.pl> | 3556 | M: "Rafael J. Wysocki" <rjw@rjwysocki.net> |
3557 | L: linux-pm@vger.kernel.org | 3557 | L: linux-pm@vger.kernel.org |
3558 | S: Supported | 3558 | S: Supported |
3559 | F: Documentation/power/freezing-of-tasks.txt | 3559 | F: Documentation/power/freezing-of-tasks.txt |
@@ -3624,6 +3624,12 @@ L: linux-scsi@vger.kernel.org | |||
3624 | S: Odd Fixes (e.g., new signatures) | 3624 | S: Odd Fixes (e.g., new signatures) |
3625 | F: drivers/scsi/fdomain.* | 3625 | F: drivers/scsi/fdomain.* |
3626 | 3626 | ||
3627 | GCOV BASED KERNEL PROFILING | ||
3628 | M: Peter Oberparleiter <oberpar@linux.vnet.ibm.com> | ||
3629 | S: Maintained | ||
3630 | F: kernel/gcov/ | ||
3631 | F: Documentation/gcov.txt | ||
3632 | |||
3627 | GDT SCSI DISK ARRAY CONTROLLER DRIVER | 3633 | GDT SCSI DISK ARRAY CONTROLLER DRIVER |
3628 | M: Achim Leubner <achim_leubner@adaptec.com> | 3634 | M: Achim Leubner <achim_leubner@adaptec.com> |
3629 | L: linux-scsi@vger.kernel.org | 3635 | L: linux-scsi@vger.kernel.org |
@@ -3889,7 +3895,7 @@ F: drivers/video/hgafb.c | |||
3889 | 3895 | ||
3890 | HIBERNATION (aka Software Suspend, aka swsusp) | 3896 | HIBERNATION (aka Software Suspend, aka swsusp) |
3891 | M: Pavel Machek <pavel@ucw.cz> | 3897 | M: Pavel Machek <pavel@ucw.cz> |
3892 | M: "Rafael J. Wysocki" <rjw@sisk.pl> | 3898 | M: "Rafael J. Wysocki" <rjw@rjwysocki.net> |
3893 | L: linux-pm@vger.kernel.org | 3899 | L: linux-pm@vger.kernel.org |
3894 | S: Supported | 3900 | S: Supported |
3895 | F: arch/x86/power/ | 3901 | F: arch/x86/power/ |
@@ -4339,7 +4345,7 @@ F: drivers/video/i810/ | |||
4339 | INTEL MENLOW THERMAL DRIVER | 4345 | INTEL MENLOW THERMAL DRIVER |
4340 | M: Sujith Thomas <sujith.thomas@intel.com> | 4346 | M: Sujith Thomas <sujith.thomas@intel.com> |
4341 | L: platform-driver-x86@vger.kernel.org | 4347 | L: platform-driver-x86@vger.kernel.org |
4342 | W: http://www.lesswatts.org/projects/acpi/ | 4348 | W: https://01.org/linux-acpi |
4343 | S: Supported | 4349 | S: Supported |
4344 | F: drivers/platform/x86/intel_menlow.c | 4350 | F: drivers/platform/x86/intel_menlow.c |
4345 | 4351 | ||
@@ -8095,7 +8101,7 @@ F: drivers/sh/ | |||
8095 | SUSPEND TO RAM | 8101 | SUSPEND TO RAM |
8096 | M: Len Brown <len.brown@intel.com> | 8102 | M: Len Brown <len.brown@intel.com> |
8097 | M: Pavel Machek <pavel@ucw.cz> | 8103 | M: Pavel Machek <pavel@ucw.cz> |
8098 | M: "Rafael J. Wysocki" <rjw@sisk.pl> | 8104 | M: "Rafael J. Wysocki" <rjw@rjwysocki.net> |
8099 | L: linux-pm@vger.kernel.org | 8105 | L: linux-pm@vger.kernel.org |
8100 | S: Supported | 8106 | S: Supported |
8101 | F: Documentation/power/ | 8107 | F: Documentation/power/ |
@@ -1,7 +1,7 @@ | |||
1 | VERSION = 3 | 1 | VERSION = 3 |
2 | PATCHLEVEL = 12 | 2 | PATCHLEVEL = 12 |
3 | SUBLEVEL = 0 | 3 | SUBLEVEL = 0 |
4 | EXTRAVERSION = -rc5 | 4 | EXTRAVERSION = -rc6 |
5 | NAME = One Giant Leap for Frogkind | 5 | NAME = One Giant Leap for Frogkind |
6 | 6 | ||
7 | # *DOCUMENTATION* | 7 | # *DOCUMENTATION* |
diff --git a/arch/arm/common/mcpm_entry.c b/arch/arm/common/mcpm_entry.c index 370236dd1a03..990250965f2c 100644 --- a/arch/arm/common/mcpm_entry.c +++ b/arch/arm/common/mcpm_entry.c | |||
@@ -51,7 +51,8 @@ void mcpm_cpu_power_down(void) | |||
51 | { | 51 | { |
52 | phys_reset_t phys_reset; | 52 | phys_reset_t phys_reset; |
53 | 53 | ||
54 | BUG_ON(!platform_ops); | 54 | if (WARN_ON_ONCE(!platform_ops || !platform_ops->power_down)) |
55 | return; | ||
55 | BUG_ON(!irqs_disabled()); | 56 | BUG_ON(!irqs_disabled()); |
56 | 57 | ||
57 | /* | 58 | /* |
@@ -93,7 +94,8 @@ void mcpm_cpu_suspend(u64 expected_residency) | |||
93 | { | 94 | { |
94 | phys_reset_t phys_reset; | 95 | phys_reset_t phys_reset; |
95 | 96 | ||
96 | BUG_ON(!platform_ops); | 97 | if (WARN_ON_ONCE(!platform_ops || !platform_ops->suspend)) |
98 | return; | ||
97 | BUG_ON(!irqs_disabled()); | 99 | BUG_ON(!irqs_disabled()); |
98 | 100 | ||
99 | /* Very similar to mcpm_cpu_power_down() */ | 101 | /* Very similar to mcpm_cpu_power_down() */ |
diff --git a/arch/arm/common/sharpsl_param.c b/arch/arm/common/sharpsl_param.c index d56c932580eb..025f6ce38596 100644 --- a/arch/arm/common/sharpsl_param.c +++ b/arch/arm/common/sharpsl_param.c | |||
@@ -15,6 +15,7 @@ | |||
15 | #include <linux/module.h> | 15 | #include <linux/module.h> |
16 | #include <linux/string.h> | 16 | #include <linux/string.h> |
17 | #include <asm/mach/sharpsl_param.h> | 17 | #include <asm/mach/sharpsl_param.h> |
18 | #include <asm/memory.h> | ||
18 | 19 | ||
19 | /* | 20 | /* |
20 | * Certain hardware parameters determined at the time of device manufacture, | 21 | * Certain hardware parameters determined at the time of device manufacture, |
@@ -25,8 +26,10 @@ | |||
25 | */ | 26 | */ |
26 | #ifdef CONFIG_ARCH_SA1100 | 27 | #ifdef CONFIG_ARCH_SA1100 |
27 | #define PARAM_BASE 0xe8ffc000 | 28 | #define PARAM_BASE 0xe8ffc000 |
29 | #define param_start(x) (void *)(x) | ||
28 | #else | 30 | #else |
29 | #define PARAM_BASE 0xa0000a00 | 31 | #define PARAM_BASE 0xa0000a00 |
32 | #define param_start(x) __va(x) | ||
30 | #endif | 33 | #endif |
31 | #define MAGIC_CHG(a,b,c,d) ( ( d << 24 ) | ( c << 16 ) | ( b << 8 ) | a ) | 34 | #define MAGIC_CHG(a,b,c,d) ( ( d << 24 ) | ( c << 16 ) | ( b << 8 ) | a ) |
32 | 35 | ||
@@ -41,7 +44,7 @@ EXPORT_SYMBOL(sharpsl_param); | |||
41 | 44 | ||
42 | void sharpsl_save_param(void) | 45 | void sharpsl_save_param(void) |
43 | { | 46 | { |
44 | memcpy(&sharpsl_param, (void *)PARAM_BASE, sizeof(struct sharpsl_param_info)); | 47 | memcpy(&sharpsl_param, param_start(PARAM_BASE), sizeof(struct sharpsl_param_info)); |
45 | 48 | ||
46 | if (sharpsl_param.comadj_keyword != COMADJ_MAGIC) | 49 | if (sharpsl_param.comadj_keyword != COMADJ_MAGIC) |
47 | sharpsl_param.comadj=-1; | 50 | sharpsl_param.comadj=-1; |
diff --git a/arch/arm/include/asm/Kbuild b/arch/arm/include/asm/Kbuild index d3db39860b9c..59ceae8f3c95 100644 --- a/arch/arm/include/asm/Kbuild +++ b/arch/arm/include/asm/Kbuild | |||
@@ -31,5 +31,4 @@ generic-y += termbits.h | |||
31 | generic-y += termios.h | 31 | generic-y += termios.h |
32 | generic-y += timex.h | 32 | generic-y += timex.h |
33 | generic-y += trace_clock.h | 33 | generic-y += trace_clock.h |
34 | generic-y += types.h | ||
35 | generic-y += unaligned.h | 34 | generic-y += unaligned.h |
diff --git a/arch/arm/include/asm/mcpm.h b/arch/arm/include/asm/mcpm.h index 0f7b7620e9a5..fc82a88f5b69 100644 --- a/arch/arm/include/asm/mcpm.h +++ b/arch/arm/include/asm/mcpm.h | |||
@@ -76,8 +76,11 @@ int mcpm_cpu_power_up(unsigned int cpu, unsigned int cluster); | |||
76 | * | 76 | * |
77 | * This must be called with interrupts disabled. | 77 | * This must be called with interrupts disabled. |
78 | * | 78 | * |
79 | * This does not return. Re-entry in the kernel is expected via | 79 | * On success this does not return. Re-entry in the kernel is expected |
80 | * mcpm_entry_point. | 80 | * via mcpm_entry_point. |
81 | * | ||
82 | * This will return if mcpm_platform_register() has not been called | ||
83 | * previously in which case the caller should take appropriate action. | ||
81 | */ | 84 | */ |
82 | void mcpm_cpu_power_down(void); | 85 | void mcpm_cpu_power_down(void); |
83 | 86 | ||
@@ -98,8 +101,11 @@ void mcpm_cpu_power_down(void); | |||
98 | * | 101 | * |
99 | * This must be called with interrupts disabled. | 102 | * This must be called with interrupts disabled. |
100 | * | 103 | * |
101 | * This does not return. Re-entry in the kernel is expected via | 104 | * On success this does not return. Re-entry in the kernel is expected |
102 | * mcpm_entry_point. | 105 | * via mcpm_entry_point. |
106 | * | ||
107 | * This will return if mcpm_platform_register() has not been called | ||
108 | * previously in which case the caller should take appropriate action. | ||
103 | */ | 109 | */ |
104 | void mcpm_cpu_suspend(u64 expected_residency); | 110 | void mcpm_cpu_suspend(u64 expected_residency); |
105 | 111 | ||
diff --git a/arch/arm/include/asm/syscall.h b/arch/arm/include/asm/syscall.h index f1d96d4e8092..73ddd7239b33 100644 --- a/arch/arm/include/asm/syscall.h +++ b/arch/arm/include/asm/syscall.h | |||
@@ -57,6 +57,9 @@ static inline void syscall_get_arguments(struct task_struct *task, | |||
57 | unsigned int i, unsigned int n, | 57 | unsigned int i, unsigned int n, |
58 | unsigned long *args) | 58 | unsigned long *args) |
59 | { | 59 | { |
60 | if (n == 0) | ||
61 | return; | ||
62 | |||
60 | if (i + n > SYSCALL_MAX_ARGS) { | 63 | if (i + n > SYSCALL_MAX_ARGS) { |
61 | unsigned long *args_bad = args + SYSCALL_MAX_ARGS - i; | 64 | unsigned long *args_bad = args + SYSCALL_MAX_ARGS - i; |
62 | unsigned int n_bad = n + i - SYSCALL_MAX_ARGS; | 65 | unsigned int n_bad = n + i - SYSCALL_MAX_ARGS; |
@@ -81,6 +84,9 @@ static inline void syscall_set_arguments(struct task_struct *task, | |||
81 | unsigned int i, unsigned int n, | 84 | unsigned int i, unsigned int n, |
82 | const unsigned long *args) | 85 | const unsigned long *args) |
83 | { | 86 | { |
87 | if (n == 0) | ||
88 | return; | ||
89 | |||
84 | if (i + n > SYSCALL_MAX_ARGS) { | 90 | if (i + n > SYSCALL_MAX_ARGS) { |
85 | pr_warning("%s called with max args %d, handling only %d\n", | 91 | pr_warning("%s called with max args %d, handling only %d\n", |
86 | __func__, i + n, SYSCALL_MAX_ARGS); | 92 | __func__, i + n, SYSCALL_MAX_ARGS); |
diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S index 2c7cc1e03473..476de57dcef2 100644 --- a/arch/arm/kernel/head.S +++ b/arch/arm/kernel/head.S | |||
@@ -487,7 +487,26 @@ __fixup_smp: | |||
487 | mrc p15, 0, r0, c0, c0, 5 @ read MPIDR | 487 | mrc p15, 0, r0, c0, c0, 5 @ read MPIDR |
488 | and r0, r0, #0xc0000000 @ multiprocessing extensions and | 488 | and r0, r0, #0xc0000000 @ multiprocessing extensions and |
489 | teq r0, #0x80000000 @ not part of a uniprocessor system? | 489 | teq r0, #0x80000000 @ not part of a uniprocessor system? |
490 | moveq pc, lr @ yes, assume SMP | 490 | bne __fixup_smp_on_up @ no, assume UP |
491 | |||
492 | @ Core indicates it is SMP. Check for Aegis SOC where a single | ||
493 | @ Cortex-A9 CPU is present but SMP operations fault. | ||
494 | mov r4, #0x41000000 | ||
495 | orr r4, r4, #0x0000c000 | ||
496 | orr r4, r4, #0x00000090 | ||
497 | teq r3, r4 @ Check for ARM Cortex-A9 | ||
498 | movne pc, lr @ Not ARM Cortex-A9, | ||
499 | |||
500 | @ If a future SoC *does* use 0x0 as the PERIPH_BASE, then the | ||
501 | @ below address check will need to be #ifdef'd or equivalent | ||
502 | @ for the Aegis platform. | ||
503 | mrc p15, 4, r0, c15, c0 @ get SCU base address | ||
504 | teq r0, #0x0 @ '0' on actual UP A9 hardware | ||
505 | beq __fixup_smp_on_up @ So its an A9 UP | ||
506 | ldr r0, [r0, #4] @ read SCU Config | ||
507 | and r0, r0, #0x3 @ number of CPUs | ||
508 | teq r0, #0x0 @ is 1? | ||
509 | movne pc, lr | ||
491 | 510 | ||
492 | __fixup_smp_on_up: | 511 | __fixup_smp_on_up: |
493 | adr r0, 1f | 512 | adr r0, 1f |
diff --git a/arch/arm/mach-s3c64xx/mach-crag6410.c b/arch/arm/mach-s3c64xx/mach-crag6410.c index eb8e5a1aca42..f27ca3b89f4c 100644 --- a/arch/arm/mach-s3c64xx/mach-crag6410.c +++ b/arch/arm/mach-s3c64xx/mach-crag6410.c | |||
@@ -310,10 +310,6 @@ static struct regulator_consumer_supply wallvdd_consumers[] = { | |||
310 | 310 | ||
311 | REGULATOR_SUPPLY("SPKVDDL", "spi0.1"), | 311 | REGULATOR_SUPPLY("SPKVDDL", "spi0.1"), |
312 | REGULATOR_SUPPLY("SPKVDDR", "spi0.1"), | 312 | REGULATOR_SUPPLY("SPKVDDR", "spi0.1"), |
313 | REGULATOR_SUPPLY("SPKVDDL", "wm5102-codec"), | ||
314 | REGULATOR_SUPPLY("SPKVDDR", "wm5102-codec"), | ||
315 | REGULATOR_SUPPLY("SPKVDDL", "wm5110-codec"), | ||
316 | REGULATOR_SUPPLY("SPKVDDR", "wm5110-codec"), | ||
317 | 313 | ||
318 | REGULATOR_SUPPLY("DC1VDD", "0-0034"), | 314 | REGULATOR_SUPPLY("DC1VDD", "0-0034"), |
319 | REGULATOR_SUPPLY("DC2VDD", "0-0034"), | 315 | REGULATOR_SUPPLY("DC2VDD", "0-0034"), |
@@ -653,14 +649,6 @@ static struct regulator_consumer_supply pvdd_1v8_consumers[] = { | |||
653 | REGULATOR_SUPPLY("DBVDD3", "spi0.1"), | 649 | REGULATOR_SUPPLY("DBVDD3", "spi0.1"), |
654 | REGULATOR_SUPPLY("LDOVDD", "spi0.1"), | 650 | REGULATOR_SUPPLY("LDOVDD", "spi0.1"), |
655 | REGULATOR_SUPPLY("CPVDD", "spi0.1"), | 651 | REGULATOR_SUPPLY("CPVDD", "spi0.1"), |
656 | |||
657 | REGULATOR_SUPPLY("DBVDD2", "wm5102-codec"), | ||
658 | REGULATOR_SUPPLY("DBVDD3", "wm5102-codec"), | ||
659 | REGULATOR_SUPPLY("CPVDD", "wm5102-codec"), | ||
660 | |||
661 | REGULATOR_SUPPLY("DBVDD2", "wm5110-codec"), | ||
662 | REGULATOR_SUPPLY("DBVDD3", "wm5110-codec"), | ||
663 | REGULATOR_SUPPLY("CPVDD", "wm5110-codec"), | ||
664 | }; | 652 | }; |
665 | 653 | ||
666 | static struct regulator_init_data pvdd_1v8 = { | 654 | static struct regulator_init_data pvdd_1v8 = { |
diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c index f5e1a8471714..1272ed202dde 100644 --- a/arch/arm/mm/dma-mapping.c +++ b/arch/arm/mm/dma-mapping.c | |||
@@ -1232,7 +1232,8 @@ __iommu_create_mapping(struct device *dev, struct page **pages, size_t size) | |||
1232 | break; | 1232 | break; |
1233 | 1233 | ||
1234 | len = (j - i) << PAGE_SHIFT; | 1234 | len = (j - i) << PAGE_SHIFT; |
1235 | ret = iommu_map(mapping->domain, iova, phys, len, 0); | 1235 | ret = iommu_map(mapping->domain, iova, phys, len, |
1236 | IOMMU_READ|IOMMU_WRITE); | ||
1236 | if (ret < 0) | 1237 | if (ret < 0) |
1237 | goto fail; | 1238 | goto fail; |
1238 | iova += len; | 1239 | iova += len; |
@@ -1431,6 +1432,27 @@ static int arm_iommu_get_sgtable(struct device *dev, struct sg_table *sgt, | |||
1431 | GFP_KERNEL); | 1432 | GFP_KERNEL); |
1432 | } | 1433 | } |
1433 | 1434 | ||
1435 | static int __dma_direction_to_prot(enum dma_data_direction dir) | ||
1436 | { | ||
1437 | int prot; | ||
1438 | |||
1439 | switch (dir) { | ||
1440 | case DMA_BIDIRECTIONAL: | ||
1441 | prot = IOMMU_READ | IOMMU_WRITE; | ||
1442 | break; | ||
1443 | case DMA_TO_DEVICE: | ||
1444 | prot = IOMMU_READ; | ||
1445 | break; | ||
1446 | case DMA_FROM_DEVICE: | ||
1447 | prot = IOMMU_WRITE; | ||
1448 | break; | ||
1449 | default: | ||
1450 | prot = 0; | ||
1451 | } | ||
1452 | |||
1453 | return prot; | ||
1454 | } | ||
1455 | |||
1434 | /* | 1456 | /* |
1435 | * Map a part of the scatter-gather list into contiguous io address space | 1457 | * Map a part of the scatter-gather list into contiguous io address space |
1436 | */ | 1458 | */ |
@@ -1444,6 +1466,7 @@ static int __map_sg_chunk(struct device *dev, struct scatterlist *sg, | |||
1444 | int ret = 0; | 1466 | int ret = 0; |
1445 | unsigned int count; | 1467 | unsigned int count; |
1446 | struct scatterlist *s; | 1468 | struct scatterlist *s; |
1469 | int prot; | ||
1447 | 1470 | ||
1448 | size = PAGE_ALIGN(size); | 1471 | size = PAGE_ALIGN(size); |
1449 | *handle = DMA_ERROR_CODE; | 1472 | *handle = DMA_ERROR_CODE; |
@@ -1460,7 +1483,9 @@ static int __map_sg_chunk(struct device *dev, struct scatterlist *sg, | |||
1460 | !dma_get_attr(DMA_ATTR_SKIP_CPU_SYNC, attrs)) | 1483 | !dma_get_attr(DMA_ATTR_SKIP_CPU_SYNC, attrs)) |
1461 | __dma_page_cpu_to_dev(sg_page(s), s->offset, s->length, dir); | 1484 | __dma_page_cpu_to_dev(sg_page(s), s->offset, s->length, dir); |
1462 | 1485 | ||
1463 | ret = iommu_map(mapping->domain, iova, phys, len, 0); | 1486 | prot = __dma_direction_to_prot(dir); |
1487 | |||
1488 | ret = iommu_map(mapping->domain, iova, phys, len, prot); | ||
1464 | if (ret < 0) | 1489 | if (ret < 0) |
1465 | goto fail; | 1490 | goto fail; |
1466 | count += len >> PAGE_SHIFT; | 1491 | count += len >> PAGE_SHIFT; |
@@ -1665,19 +1690,7 @@ static dma_addr_t arm_coherent_iommu_map_page(struct device *dev, struct page *p | |||
1665 | if (dma_addr == DMA_ERROR_CODE) | 1690 | if (dma_addr == DMA_ERROR_CODE) |
1666 | return dma_addr; | 1691 | return dma_addr; |
1667 | 1692 | ||
1668 | switch (dir) { | 1693 | prot = __dma_direction_to_prot(dir); |
1669 | case DMA_BIDIRECTIONAL: | ||
1670 | prot = IOMMU_READ | IOMMU_WRITE; | ||
1671 | break; | ||
1672 | case DMA_TO_DEVICE: | ||
1673 | prot = IOMMU_READ; | ||
1674 | break; | ||
1675 | case DMA_FROM_DEVICE: | ||
1676 | prot = IOMMU_WRITE; | ||
1677 | break; | ||
1678 | default: | ||
1679 | prot = 0; | ||
1680 | } | ||
1681 | 1694 | ||
1682 | ret = iommu_map(mapping->domain, dma_addr, page_to_phys(page), len, prot); | 1695 | ret = iommu_map(mapping->domain, dma_addr, page_to_phys(page), len, prot); |
1683 | if (ret < 0) | 1696 | if (ret < 0) |
diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c index febaee7ca57b..18ec4c504abf 100644 --- a/arch/arm/mm/init.c +++ b/arch/arm/mm/init.c | |||
@@ -17,7 +17,6 @@ | |||
17 | #include <linux/nodemask.h> | 17 | #include <linux/nodemask.h> |
18 | #include <linux/initrd.h> | 18 | #include <linux/initrd.h> |
19 | #include <linux/of_fdt.h> | 19 | #include <linux/of_fdt.h> |
20 | #include <linux/of_reserved_mem.h> | ||
21 | #include <linux/highmem.h> | 20 | #include <linux/highmem.h> |
22 | #include <linux/gfp.h> | 21 | #include <linux/gfp.h> |
23 | #include <linux/memblock.h> | 22 | #include <linux/memblock.h> |
@@ -379,8 +378,6 @@ void __init arm_memblock_init(struct meminfo *mi, | |||
379 | if (mdesc->reserve) | 378 | if (mdesc->reserve) |
380 | mdesc->reserve(); | 379 | mdesc->reserve(); |
381 | 380 | ||
382 | early_init_dt_scan_reserved_mem(); | ||
383 | |||
384 | /* | 381 | /* |
385 | * reserve memory for DMA contigouos allocations, | 382 | * reserve memory for DMA contigouos allocations, |
386 | * must come from DMA area inside low memory | 383 | * must come from DMA area inside low memory |
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 145d703227bf..f67e839f06c8 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig | |||
@@ -1033,6 +1033,7 @@ config X86_REBOOTFIXUPS | |||
1033 | 1033 | ||
1034 | config MICROCODE | 1034 | config MICROCODE |
1035 | tristate "CPU microcode loading support" | 1035 | tristate "CPU microcode loading support" |
1036 | depends on CPU_SUP_AMD || CPU_SUP_INTEL | ||
1036 | select FW_LOADER | 1037 | select FW_LOADER |
1037 | ---help--- | 1038 | ---help--- |
1038 | 1039 | ||
diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c index 1191ac1c9d25..a419814cea57 100644 --- a/arch/x86/kernel/apic/x2apic_uv_x.c +++ b/arch/x86/kernel/apic/x2apic_uv_x.c | |||
@@ -113,7 +113,7 @@ static int __init early_get_pnodeid(void) | |||
113 | break; | 113 | break; |
114 | case UV3_HUB_PART_NUMBER: | 114 | case UV3_HUB_PART_NUMBER: |
115 | case UV3_HUB_PART_NUMBER_X: | 115 | case UV3_HUB_PART_NUMBER_X: |
116 | uv_min_hub_revision_id += UV3_HUB_REVISION_BASE - 1; | 116 | uv_min_hub_revision_id += UV3_HUB_REVISION_BASE; |
117 | break; | 117 | break; |
118 | } | 118 | } |
119 | 119 | ||
diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c index 697b93af02dd..a0e2a8a80c94 100644 --- a/arch/x86/kernel/kvm.c +++ b/arch/x86/kernel/kvm.c | |||
@@ -775,11 +775,22 @@ void __init kvm_spinlock_init(void) | |||
775 | if (!kvm_para_has_feature(KVM_FEATURE_PV_UNHALT)) | 775 | if (!kvm_para_has_feature(KVM_FEATURE_PV_UNHALT)) |
776 | return; | 776 | return; |
777 | 777 | ||
778 | printk(KERN_INFO "KVM setup paravirtual spinlock\n"); | 778 | pv_lock_ops.lock_spinning = PV_CALLEE_SAVE(kvm_lock_spinning); |
779 | pv_lock_ops.unlock_kick = kvm_unlock_kick; | ||
780 | } | ||
781 | |||
782 | static __init int kvm_spinlock_init_jump(void) | ||
783 | { | ||
784 | if (!kvm_para_available()) | ||
785 | return 0; | ||
786 | if (!kvm_para_has_feature(KVM_FEATURE_PV_UNHALT)) | ||
787 | return 0; | ||
779 | 788 | ||
780 | static_key_slow_inc(¶virt_ticketlocks_enabled); | 789 | static_key_slow_inc(¶virt_ticketlocks_enabled); |
790 | printk(KERN_INFO "KVM setup paravirtual spinlock\n"); | ||
781 | 791 | ||
782 | pv_lock_ops.lock_spinning = PV_CALLEE_SAVE(kvm_lock_spinning); | 792 | return 0; |
783 | pv_lock_ops.unlock_kick = kvm_unlock_kick; | ||
784 | } | 793 | } |
794 | early_initcall(kvm_spinlock_init_jump); | ||
795 | |||
785 | #endif /* CONFIG_PARAVIRT_SPINLOCKS */ | 796 | #endif /* CONFIG_PARAVIRT_SPINLOCKS */ |
diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c index d1e4777b4e75..31d04758b76f 100644 --- a/arch/x86/xen/smp.c +++ b/arch/x86/xen/smp.c | |||
@@ -278,6 +278,15 @@ static void __init xen_smp_prepare_boot_cpu(void) | |||
278 | old memory can be recycled */ | 278 | old memory can be recycled */ |
279 | make_lowmem_page_readwrite(xen_initial_gdt); | 279 | make_lowmem_page_readwrite(xen_initial_gdt); |
280 | 280 | ||
281 | #ifdef CONFIG_X86_32 | ||
282 | /* | ||
283 | * Xen starts us with XEN_FLAT_RING1_DS, but linux code | ||
284 | * expects __USER_DS | ||
285 | */ | ||
286 | loadsegment(ds, __USER_DS); | ||
287 | loadsegment(es, __USER_DS); | ||
288 | #endif | ||
289 | |||
281 | xen_filter_cpu_maps(); | 290 | xen_filter_cpu_maps(); |
282 | xen_setup_vcpu_info_placement(); | 291 | xen_setup_vcpu_info_placement(); |
283 | } | 292 | } |
diff --git a/block/partitions/efi.c b/block/partitions/efi.c index 1eb09ee5311b..a8287b49d062 100644 --- a/block/partitions/efi.c +++ b/block/partitions/efi.c | |||
@@ -222,11 +222,16 @@ check_hybrid: | |||
222 | * the disk size. | 222 | * the disk size. |
223 | * | 223 | * |
224 | * Hybrid MBRs do not necessarily comply with this. | 224 | * Hybrid MBRs do not necessarily comply with this. |
225 | * | ||
226 | * Consider a bad value here to be a warning to support dd'ing | ||
227 | * an image from a smaller disk to a larger disk. | ||
225 | */ | 228 | */ |
226 | if (ret == GPT_MBR_PROTECTIVE) { | 229 | if (ret == GPT_MBR_PROTECTIVE) { |
227 | sz = le32_to_cpu(mbr->partition_record[part].size_in_lba); | 230 | sz = le32_to_cpu(mbr->partition_record[part].size_in_lba); |
228 | if (sz != (uint32_t) total_sectors - 1 && sz != 0xFFFFFFFF) | 231 | if (sz != (uint32_t) total_sectors - 1 && sz != 0xFFFFFFFF) |
229 | ret = 0; | 232 | pr_debug("GPT: mbr size in lba (%u) different than whole disk (%u).\n", |
233 | sz, min_t(uint32_t, | ||
234 | total_sectors - 1, 0xFFFFFFFF)); | ||
230 | } | 235 | } |
231 | done: | 236 | done: |
232 | return ret; | 237 | return ret; |
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index 22327e6a7236..6efe2ac6902f 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig | |||
@@ -24,7 +24,7 @@ menuconfig ACPI | |||
24 | are configured, ACPI is used. | 24 | are configured, ACPI is used. |
25 | 25 | ||
26 | The project home page for the Linux ACPI subsystem is here: | 26 | The project home page for the Linux ACPI subsystem is here: |
27 | <http://www.lesswatts.org/projects/acpi/> | 27 | <https://01.org/linux-acpi> |
28 | 28 | ||
29 | Linux support for ACPI is based on Intel Corporation's ACPI | 29 | Linux support for ACPI is based on Intel Corporation's ACPI |
30 | Component Architecture (ACPI CA). For more information on the | 30 | Component Architecture (ACPI CA). For more information on the |
@@ -123,9 +123,9 @@ config ACPI_BUTTON | |||
123 | default y | 123 | default y |
124 | help | 124 | help |
125 | This driver handles events on the power, sleep, and lid buttons. | 125 | This driver handles events on the power, sleep, and lid buttons. |
126 | A daemon reads /proc/acpi/event and perform user-defined actions | 126 | A daemon reads events from input devices or via netlink and |
127 | such as shutting down the system. This is necessary for | 127 | performs user-defined actions such as shutting down the system. |
128 | software-controlled poweroff. | 128 | This is necessary for software-controlled poweroff. |
129 | 129 | ||
130 | To compile this driver as a module, choose M here: | 130 | To compile this driver as a module, choose M here: |
131 | the module will be called button. | 131 | the module will be called button. |
diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c index 59d3202f6b36..a94383d1f350 100644 --- a/drivers/acpi/device_pm.c +++ b/drivers/acpi/device_pm.c | |||
@@ -1025,60 +1025,4 @@ void acpi_dev_pm_detach(struct device *dev, bool power_off) | |||
1025 | } | 1025 | } |
1026 | } | 1026 | } |
1027 | EXPORT_SYMBOL_GPL(acpi_dev_pm_detach); | 1027 | EXPORT_SYMBOL_GPL(acpi_dev_pm_detach); |
1028 | |||
1029 | /** | ||
1030 | * acpi_dev_pm_add_dependent - Add physical device depending for PM. | ||
1031 | * @handle: Handle of ACPI device node. | ||
1032 | * @depdev: Device depending on that node for PM. | ||
1033 | */ | ||
1034 | void acpi_dev_pm_add_dependent(acpi_handle handle, struct device *depdev) | ||
1035 | { | ||
1036 | struct acpi_device_physical_node *dep; | ||
1037 | struct acpi_device *adev; | ||
1038 | |||
1039 | if (!depdev || acpi_bus_get_device(handle, &adev)) | ||
1040 | return; | ||
1041 | |||
1042 | mutex_lock(&adev->physical_node_lock); | ||
1043 | |||
1044 | list_for_each_entry(dep, &adev->power_dependent, node) | ||
1045 | if (dep->dev == depdev) | ||
1046 | goto out; | ||
1047 | |||
1048 | dep = kzalloc(sizeof(*dep), GFP_KERNEL); | ||
1049 | if (dep) { | ||
1050 | dep->dev = depdev; | ||
1051 | list_add_tail(&dep->node, &adev->power_dependent); | ||
1052 | } | ||
1053 | |||
1054 | out: | ||
1055 | mutex_unlock(&adev->physical_node_lock); | ||
1056 | } | ||
1057 | EXPORT_SYMBOL_GPL(acpi_dev_pm_add_dependent); | ||
1058 | |||
1059 | /** | ||
1060 | * acpi_dev_pm_remove_dependent - Remove physical device depending for PM. | ||
1061 | * @handle: Handle of ACPI device node. | ||
1062 | * @depdev: Device depending on that node for PM. | ||
1063 | */ | ||
1064 | void acpi_dev_pm_remove_dependent(acpi_handle handle, struct device *depdev) | ||
1065 | { | ||
1066 | struct acpi_device_physical_node *dep; | ||
1067 | struct acpi_device *adev; | ||
1068 | |||
1069 | if (!depdev || acpi_bus_get_device(handle, &adev)) | ||
1070 | return; | ||
1071 | |||
1072 | mutex_lock(&adev->physical_node_lock); | ||
1073 | |||
1074 | list_for_each_entry(dep, &adev->power_dependent, node) | ||
1075 | if (dep->dev == depdev) { | ||
1076 | list_del(&dep->node); | ||
1077 | kfree(dep); | ||
1078 | break; | ||
1079 | } | ||
1080 | |||
1081 | mutex_unlock(&adev->physical_node_lock); | ||
1082 | } | ||
1083 | EXPORT_SYMBOL_GPL(acpi_dev_pm_remove_dependent); | ||
1084 | #endif /* CONFIG_PM */ | 1028 | #endif /* CONFIG_PM */ |
diff --git a/drivers/acpi/power.c b/drivers/acpi/power.c index 0dbe5cdf3396..c2ad391d8041 100644 --- a/drivers/acpi/power.c +++ b/drivers/acpi/power.c | |||
@@ -59,16 +59,9 @@ ACPI_MODULE_NAME("power"); | |||
59 | #define ACPI_POWER_RESOURCE_STATE_ON 0x01 | 59 | #define ACPI_POWER_RESOURCE_STATE_ON 0x01 |
60 | #define ACPI_POWER_RESOURCE_STATE_UNKNOWN 0xFF | 60 | #define ACPI_POWER_RESOURCE_STATE_UNKNOWN 0xFF |
61 | 61 | ||
62 | struct acpi_power_dependent_device { | ||
63 | struct list_head node; | ||
64 | struct acpi_device *adev; | ||
65 | struct work_struct work; | ||
66 | }; | ||
67 | |||
68 | struct acpi_power_resource { | 62 | struct acpi_power_resource { |
69 | struct acpi_device device; | 63 | struct acpi_device device; |
70 | struct list_head list_node; | 64 | struct list_head list_node; |
71 | struct list_head dependent; | ||
72 | char *name; | 65 | char *name; |
73 | u32 system_level; | 66 | u32 system_level; |
74 | u32 order; | 67 | u32 order; |
@@ -233,32 +226,6 @@ static int acpi_power_get_list_state(struct list_head *list, int *state) | |||
233 | return 0; | 226 | return 0; |
234 | } | 227 | } |
235 | 228 | ||
236 | static void acpi_power_resume_dependent(struct work_struct *work) | ||
237 | { | ||
238 | struct acpi_power_dependent_device *dep; | ||
239 | struct acpi_device_physical_node *pn; | ||
240 | struct acpi_device *adev; | ||
241 | int state; | ||
242 | |||
243 | dep = container_of(work, struct acpi_power_dependent_device, work); | ||
244 | adev = dep->adev; | ||
245 | if (acpi_power_get_inferred_state(adev, &state)) | ||
246 | return; | ||
247 | |||
248 | if (state > ACPI_STATE_D0) | ||
249 | return; | ||
250 | |||
251 | mutex_lock(&adev->physical_node_lock); | ||
252 | |||
253 | list_for_each_entry(pn, &adev->physical_node_list, node) | ||
254 | pm_request_resume(pn->dev); | ||
255 | |||
256 | list_for_each_entry(pn, &adev->power_dependent, node) | ||
257 | pm_request_resume(pn->dev); | ||
258 | |||
259 | mutex_unlock(&adev->physical_node_lock); | ||
260 | } | ||
261 | |||
262 | static int __acpi_power_on(struct acpi_power_resource *resource) | 229 | static int __acpi_power_on(struct acpi_power_resource *resource) |
263 | { | 230 | { |
264 | acpi_status status = AE_OK; | 231 | acpi_status status = AE_OK; |
@@ -283,14 +250,8 @@ static int acpi_power_on_unlocked(struct acpi_power_resource *resource) | |||
283 | resource->name)); | 250 | resource->name)); |
284 | } else { | 251 | } else { |
285 | result = __acpi_power_on(resource); | 252 | result = __acpi_power_on(resource); |
286 | if (result) { | 253 | if (result) |
287 | resource->ref_count--; | 254 | resource->ref_count--; |
288 | } else { | ||
289 | struct acpi_power_dependent_device *dep; | ||
290 | |||
291 | list_for_each_entry(dep, &resource->dependent, node) | ||
292 | schedule_work(&dep->work); | ||
293 | } | ||
294 | } | 255 | } |
295 | return result; | 256 | return result; |
296 | } | 257 | } |
@@ -390,52 +351,6 @@ static int acpi_power_on_list(struct list_head *list) | |||
390 | return result; | 351 | return result; |
391 | } | 352 | } |
392 | 353 | ||
393 | static void acpi_power_add_dependent(struct acpi_power_resource *resource, | ||
394 | struct acpi_device *adev) | ||
395 | { | ||
396 | struct acpi_power_dependent_device *dep; | ||
397 | |||
398 | mutex_lock(&resource->resource_lock); | ||
399 | |||
400 | list_for_each_entry(dep, &resource->dependent, node) | ||
401 | if (dep->adev == adev) | ||
402 | goto out; | ||
403 | |||
404 | dep = kzalloc(sizeof(*dep), GFP_KERNEL); | ||
405 | if (!dep) | ||
406 | goto out; | ||
407 | |||
408 | dep->adev = adev; | ||
409 | INIT_WORK(&dep->work, acpi_power_resume_dependent); | ||
410 | list_add_tail(&dep->node, &resource->dependent); | ||
411 | |||
412 | out: | ||
413 | mutex_unlock(&resource->resource_lock); | ||
414 | } | ||
415 | |||
416 | static void acpi_power_remove_dependent(struct acpi_power_resource *resource, | ||
417 | struct acpi_device *adev) | ||
418 | { | ||
419 | struct acpi_power_dependent_device *dep; | ||
420 | struct work_struct *work = NULL; | ||
421 | |||
422 | mutex_lock(&resource->resource_lock); | ||
423 | |||
424 | list_for_each_entry(dep, &resource->dependent, node) | ||
425 | if (dep->adev == adev) { | ||
426 | list_del(&dep->node); | ||
427 | work = &dep->work; | ||
428 | break; | ||
429 | } | ||
430 | |||
431 | mutex_unlock(&resource->resource_lock); | ||
432 | |||
433 | if (work) { | ||
434 | cancel_work_sync(work); | ||
435 | kfree(dep); | ||
436 | } | ||
437 | } | ||
438 | |||
439 | static struct attribute *attrs[] = { | 354 | static struct attribute *attrs[] = { |
440 | NULL, | 355 | NULL, |
441 | }; | 356 | }; |
@@ -524,8 +439,6 @@ static void acpi_power_expose_hide(struct acpi_device *adev, | |||
524 | 439 | ||
525 | void acpi_power_add_remove_device(struct acpi_device *adev, bool add) | 440 | void acpi_power_add_remove_device(struct acpi_device *adev, bool add) |
526 | { | 441 | { |
527 | struct acpi_device_power_state *ps; | ||
528 | struct acpi_power_resource_entry *entry; | ||
529 | int state; | 442 | int state; |
530 | 443 | ||
531 | if (adev->wakeup.flags.valid) | 444 | if (adev->wakeup.flags.valid) |
@@ -535,16 +448,6 @@ void acpi_power_add_remove_device(struct acpi_device *adev, bool add) | |||
535 | if (!adev->power.flags.power_resources) | 448 | if (!adev->power.flags.power_resources) |
536 | return; | 449 | return; |
537 | 450 | ||
538 | ps = &adev->power.states[ACPI_STATE_D0]; | ||
539 | list_for_each_entry(entry, &ps->resources, node) { | ||
540 | struct acpi_power_resource *resource = entry->resource; | ||
541 | |||
542 | if (add) | ||
543 | acpi_power_add_dependent(resource, adev); | ||
544 | else | ||
545 | acpi_power_remove_dependent(resource, adev); | ||
546 | } | ||
547 | |||
548 | for (state = ACPI_STATE_D0; state <= ACPI_STATE_D3_HOT; state++) | 451 | for (state = ACPI_STATE_D0; state <= ACPI_STATE_D3_HOT; state++) |
549 | acpi_power_expose_hide(adev, | 452 | acpi_power_expose_hide(adev, |
550 | &adev->power.states[state].resources, | 453 | &adev->power.states[state].resources, |
@@ -882,7 +785,6 @@ int acpi_add_power_resource(acpi_handle handle) | |||
882 | acpi_init_device_object(device, handle, ACPI_BUS_TYPE_POWER, | 785 | acpi_init_device_object(device, handle, ACPI_BUS_TYPE_POWER, |
883 | ACPI_STA_DEFAULT); | 786 | ACPI_STA_DEFAULT); |
884 | mutex_init(&resource->resource_lock); | 787 | mutex_init(&resource->resource_lock); |
885 | INIT_LIST_HEAD(&resource->dependent); | ||
886 | INIT_LIST_HEAD(&resource->list_node); | 788 | INIT_LIST_HEAD(&resource->list_node); |
887 | resource->name = device->pnp.bus_id; | 789 | resource->name = device->pnp.bus_id; |
888 | strcpy(acpi_device_name(device), ACPI_POWER_DEVICE_NAME); | 790 | strcpy(acpi_device_name(device), ACPI_POWER_DEVICE_NAME); |
@@ -936,8 +838,10 @@ void acpi_resume_power_resources(void) | |||
936 | mutex_lock(&resource->resource_lock); | 838 | mutex_lock(&resource->resource_lock); |
937 | 839 | ||
938 | result = acpi_power_get_state(resource->device.handle, &state); | 840 | result = acpi_power_get_state(resource->device.handle, &state); |
939 | if (result) | 841 | if (result) { |
842 | mutex_unlock(&resource->resource_lock); | ||
940 | continue; | 843 | continue; |
844 | } | ||
941 | 845 | ||
942 | if (state == ACPI_POWER_RESOURCE_STATE_OFF | 846 | if (state == ACPI_POWER_RESOURCE_STATE_OFF |
943 | && resource->ref_count) { | 847 | && resource->ref_count) { |
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 407ad13cac2f..fee8a297c7d9 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c | |||
@@ -999,7 +999,6 @@ int acpi_device_add(struct acpi_device *device, | |||
999 | INIT_LIST_HEAD(&device->wakeup_list); | 999 | INIT_LIST_HEAD(&device->wakeup_list); |
1000 | INIT_LIST_HEAD(&device->physical_node_list); | 1000 | INIT_LIST_HEAD(&device->physical_node_list); |
1001 | mutex_init(&device->physical_node_lock); | 1001 | mutex_init(&device->physical_node_lock); |
1002 | INIT_LIST_HEAD(&device->power_dependent); | ||
1003 | 1002 | ||
1004 | new_bus_id = kzalloc(sizeof(struct acpi_device_bus_id), GFP_KERNEL); | 1003 | new_bus_id = kzalloc(sizeof(struct acpi_device_bus_id), GFP_KERNEL); |
1005 | if (!new_bus_id) { | 1004 | if (!new_bus_id) { |
diff --git a/drivers/ata/libata-acpi.c b/drivers/ata/libata-acpi.c index 4ba8b0405572..ab714d2ad978 100644 --- a/drivers/ata/libata-acpi.c +++ b/drivers/ata/libata-acpi.c | |||
@@ -1035,17 +1035,3 @@ void ata_acpi_on_disable(struct ata_device *dev) | |||
1035 | { | 1035 | { |
1036 | ata_acpi_clear_gtf(dev); | 1036 | ata_acpi_clear_gtf(dev); |
1037 | } | 1037 | } |
1038 | |||
1039 | void ata_scsi_acpi_bind(struct ata_device *dev) | ||
1040 | { | ||
1041 | acpi_handle handle = ata_dev_acpi_handle(dev); | ||
1042 | if (handle) | ||
1043 | acpi_dev_pm_add_dependent(handle, &dev->sdev->sdev_gendev); | ||
1044 | } | ||
1045 | |||
1046 | void ata_scsi_acpi_unbind(struct ata_device *dev) | ||
1047 | { | ||
1048 | acpi_handle handle = ata_dev_acpi_handle(dev); | ||
1049 | if (handle) | ||
1050 | acpi_dev_pm_remove_dependent(handle, &dev->sdev->sdev_gendev); | ||
1051 | } | ||
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index 97a0cef12959..db6dfcfa3e2e 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c | |||
@@ -3679,7 +3679,6 @@ void ata_scsi_scan_host(struct ata_port *ap, int sync) | |||
3679 | if (!IS_ERR(sdev)) { | 3679 | if (!IS_ERR(sdev)) { |
3680 | dev->sdev = sdev; | 3680 | dev->sdev = sdev; |
3681 | scsi_device_put(sdev); | 3681 | scsi_device_put(sdev); |
3682 | ata_scsi_acpi_bind(dev); | ||
3683 | } else { | 3682 | } else { |
3684 | dev->sdev = NULL; | 3683 | dev->sdev = NULL; |
3685 | } | 3684 | } |
@@ -3767,8 +3766,6 @@ static void ata_scsi_remove_dev(struct ata_device *dev) | |||
3767 | struct scsi_device *sdev; | 3766 | struct scsi_device *sdev; |
3768 | unsigned long flags; | 3767 | unsigned long flags; |
3769 | 3768 | ||
3770 | ata_scsi_acpi_unbind(dev); | ||
3771 | |||
3772 | /* Alas, we need to grab scan_mutex to ensure SCSI device | 3769 | /* Alas, we need to grab scan_mutex to ensure SCSI device |
3773 | * state doesn't change underneath us and thus | 3770 | * state doesn't change underneath us and thus |
3774 | * scsi_device_get() always succeeds. The mutex locking can | 3771 | * scsi_device_get() always succeeds. The mutex locking can |
diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h index eeeb77845d48..45b5ab3a95d5 100644 --- a/drivers/ata/libata.h +++ b/drivers/ata/libata.h | |||
@@ -121,8 +121,6 @@ extern void ata_acpi_set_state(struct ata_port *ap, pm_message_t state); | |||
121 | extern void ata_acpi_bind_port(struct ata_port *ap); | 121 | extern void ata_acpi_bind_port(struct ata_port *ap); |
122 | extern void ata_acpi_bind_dev(struct ata_device *dev); | 122 | extern void ata_acpi_bind_dev(struct ata_device *dev); |
123 | extern acpi_handle ata_dev_acpi_handle(struct ata_device *dev); | 123 | extern acpi_handle ata_dev_acpi_handle(struct ata_device *dev); |
124 | extern void ata_scsi_acpi_bind(struct ata_device *dev); | ||
125 | extern void ata_scsi_acpi_unbind(struct ata_device *dev); | ||
126 | #else | 124 | #else |
127 | static inline void ata_acpi_dissociate(struct ata_host *host) { } | 125 | static inline void ata_acpi_dissociate(struct ata_host *host) { } |
128 | static inline int ata_acpi_on_suspend(struct ata_port *ap) { return 0; } | 126 | static inline int ata_acpi_on_suspend(struct ata_port *ap) { return 0; } |
@@ -133,8 +131,6 @@ static inline void ata_acpi_set_state(struct ata_port *ap, | |||
133 | pm_message_t state) { } | 131 | pm_message_t state) { } |
134 | static inline void ata_acpi_bind_port(struct ata_port *ap) {} | 132 | static inline void ata_acpi_bind_port(struct ata_port *ap) {} |
135 | static inline void ata_acpi_bind_dev(struct ata_device *dev) {} | 133 | static inline void ata_acpi_bind_dev(struct ata_device *dev) {} |
136 | static inline void ata_scsi_acpi_bind(struct ata_device *dev) {} | ||
137 | static inline void ata_scsi_acpi_unbind(struct ata_device *dev) {} | ||
138 | #endif | 134 | #endif |
139 | 135 | ||
140 | /* libata-scsi.c */ | 136 | /* libata-scsi.c */ |
diff --git a/drivers/base/memory.c b/drivers/base/memory.c index 9e59f6535c44..bece691cb5d9 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c | |||
@@ -333,8 +333,10 @@ store_mem_state(struct device *dev, | |||
333 | online_type = ONLINE_KEEP; | 333 | online_type = ONLINE_KEEP; |
334 | else if (!strncmp(buf, "offline", min_t(int, count, 7))) | 334 | else if (!strncmp(buf, "offline", min_t(int, count, 7))) |
335 | online_type = -1; | 335 | online_type = -1; |
336 | else | 336 | else { |
337 | return -EINVAL; | 337 | ret = -EINVAL; |
338 | goto err; | ||
339 | } | ||
338 | 340 | ||
339 | switch (online_type) { | 341 | switch (online_type) { |
340 | case ONLINE_KERNEL: | 342 | case ONLINE_KERNEL: |
@@ -357,6 +359,7 @@ store_mem_state(struct device *dev, | |||
357 | ret = -EINVAL; /* should never happen */ | 359 | ret = -EINVAL; /* should never happen */ |
358 | } | 360 | } |
359 | 361 | ||
362 | err: | ||
360 | unlock_device_hotplug(); | 363 | unlock_device_hotplug(); |
361 | 364 | ||
362 | if (ret) | 365 | if (ret) |
diff --git a/drivers/char/tpm/xen-tpmfront.c b/drivers/char/tpm/xen-tpmfront.c index 06189e55b4e5..94c280d36e8b 100644 --- a/drivers/char/tpm/xen-tpmfront.c +++ b/drivers/char/tpm/xen-tpmfront.c | |||
@@ -10,6 +10,7 @@ | |||
10 | #include <linux/errno.h> | 10 | #include <linux/errno.h> |
11 | #include <linux/err.h> | 11 | #include <linux/err.h> |
12 | #include <linux/interrupt.h> | 12 | #include <linux/interrupt.h> |
13 | #include <xen/xen.h> | ||
13 | #include <xen/events.h> | 14 | #include <xen/events.h> |
14 | #include <xen/interface/io/tpmif.h> | 15 | #include <xen/interface/io/tpmif.h> |
15 | #include <xen/grant_table.h> | 16 | #include <xen/grant_table.h> |
diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c index 32b3479a2405..badf6206b2b2 100644 --- a/drivers/cpufreq/intel_pstate.c +++ b/drivers/cpufreq/intel_pstate.c | |||
@@ -383,6 +383,7 @@ static void intel_pstate_get_min_max(struct cpudata *cpu, int *min, int *max) | |||
383 | static void intel_pstate_set_pstate(struct cpudata *cpu, int pstate) | 383 | static void intel_pstate_set_pstate(struct cpudata *cpu, int pstate) |
384 | { | 384 | { |
385 | int max_perf, min_perf; | 385 | int max_perf, min_perf; |
386 | u64 val; | ||
386 | 387 | ||
387 | intel_pstate_get_min_max(cpu, &min_perf, &max_perf); | 388 | intel_pstate_get_min_max(cpu, &min_perf, &max_perf); |
388 | 389 | ||
@@ -394,11 +395,11 @@ static void intel_pstate_set_pstate(struct cpudata *cpu, int pstate) | |||
394 | trace_cpu_frequency(pstate * 100000, cpu->cpu); | 395 | trace_cpu_frequency(pstate * 100000, cpu->cpu); |
395 | 396 | ||
396 | cpu->pstate.current_pstate = pstate; | 397 | cpu->pstate.current_pstate = pstate; |
398 | val = pstate << 8; | ||
397 | if (limits.no_turbo) | 399 | if (limits.no_turbo) |
398 | wrmsrl(MSR_IA32_PERF_CTL, BIT(32) | (pstate << 8)); | 400 | val |= (u64)1 << 32; |
399 | else | ||
400 | wrmsrl(MSR_IA32_PERF_CTL, pstate << 8); | ||
401 | 401 | ||
402 | wrmsrl(MSR_IA32_PERF_CTL, val); | ||
402 | } | 403 | } |
403 | 404 | ||
404 | static inline void intel_pstate_pstate_increase(struct cpudata *cpu, int steps) | 405 | static inline void intel_pstate_pstate_increase(struct cpudata *cpu, int steps) |
@@ -637,8 +638,8 @@ static int intel_pstate_cpu_exit(struct cpufreq_policy *policy) | |||
637 | 638 | ||
638 | static int intel_pstate_cpu_init(struct cpufreq_policy *policy) | 639 | static int intel_pstate_cpu_init(struct cpufreq_policy *policy) |
639 | { | 640 | { |
640 | int rc, min_pstate, max_pstate; | ||
641 | struct cpudata *cpu; | 641 | struct cpudata *cpu; |
642 | int rc; | ||
642 | 643 | ||
643 | rc = intel_pstate_init_cpu(policy->cpu); | 644 | rc = intel_pstate_init_cpu(policy->cpu); |
644 | if (rc) | 645 | if (rc) |
@@ -652,9 +653,8 @@ static int intel_pstate_cpu_init(struct cpufreq_policy *policy) | |||
652 | else | 653 | else |
653 | policy->policy = CPUFREQ_POLICY_POWERSAVE; | 654 | policy->policy = CPUFREQ_POLICY_POWERSAVE; |
654 | 655 | ||
655 | intel_pstate_get_min_max(cpu, &min_pstate, &max_pstate); | 656 | policy->min = cpu->pstate.min_pstate * 100000; |
656 | policy->min = min_pstate * 100000; | 657 | policy->max = cpu->pstate.turbo_pstate * 100000; |
657 | policy->max = max_pstate * 100000; | ||
658 | 658 | ||
659 | /* cpuinfo and default policy values */ | 659 | /* cpuinfo and default policy values */ |
660 | policy->cpuinfo.min_freq = cpu->pstate.min_pstate * 100000; | 660 | policy->cpuinfo.min_freq = cpu->pstate.min_pstate * 100000; |
diff --git a/drivers/cpufreq/s3c64xx-cpufreq.c b/drivers/cpufreq/s3c64xx-cpufreq.c index 8a72b0c555f8..15631f92ab7d 100644 --- a/drivers/cpufreq/s3c64xx-cpufreq.c +++ b/drivers/cpufreq/s3c64xx-cpufreq.c | |||
@@ -166,7 +166,7 @@ static void __init s3c64xx_cpufreq_config_regulator(void) | |||
166 | if (freq->frequency == CPUFREQ_ENTRY_INVALID) | 166 | if (freq->frequency == CPUFREQ_ENTRY_INVALID) |
167 | continue; | 167 | continue; |
168 | 168 | ||
169 | dvfs = &s3c64xx_dvfs_table[freq->index]; | 169 | dvfs = &s3c64xx_dvfs_table[freq->driver_data]; |
170 | found = 0; | 170 | found = 0; |
171 | 171 | ||
172 | for (i = 0; i < count; i++) { | 172 | for (i = 0; i < count; i++) { |
diff --git a/drivers/gpio/gpio-lynxpoint.c b/drivers/gpio/gpio-lynxpoint.c index 2d9ca6055e5e..41b5913ddabe 100644 --- a/drivers/gpio/gpio-lynxpoint.c +++ b/drivers/gpio/gpio-lynxpoint.c | |||
@@ -248,14 +248,15 @@ static void lp_gpio_irq_handler(unsigned irq, struct irq_desc *desc) | |||
248 | struct lp_gpio *lg = irq_data_get_irq_handler_data(data); | 248 | struct lp_gpio *lg = irq_data_get_irq_handler_data(data); |
249 | struct irq_chip *chip = irq_data_get_irq_chip(data); | 249 | struct irq_chip *chip = irq_data_get_irq_chip(data); |
250 | u32 base, pin, mask; | 250 | u32 base, pin, mask; |
251 | unsigned long reg, pending; | 251 | unsigned long reg, ena, pending; |
252 | unsigned virq; | 252 | unsigned virq; |
253 | 253 | ||
254 | /* check from GPIO controller which pin triggered the interrupt */ | 254 | /* check from GPIO controller which pin triggered the interrupt */ |
255 | for (base = 0; base < lg->chip.ngpio; base += 32) { | 255 | for (base = 0; base < lg->chip.ngpio; base += 32) { |
256 | reg = lp_gpio_reg(&lg->chip, base, LP_INT_STAT); | 256 | reg = lp_gpio_reg(&lg->chip, base, LP_INT_STAT); |
257 | ena = lp_gpio_reg(&lg->chip, base, LP_INT_ENABLE); | ||
257 | 258 | ||
258 | while ((pending = inl(reg))) { | 259 | while ((pending = (inl(reg) & inl(ena)))) { |
259 | pin = __ffs(pending); | 260 | pin = __ffs(pending); |
260 | mask = BIT(pin); | 261 | mask = BIT(pin); |
261 | /* Clear before handling so we don't lose an edge */ | 262 | /* Clear before handling so we don't lose an edge */ |
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 86ef3461ec06..0dee0e0c247a 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c | |||
@@ -136,7 +136,7 @@ static struct gpio_desc *gpio_to_desc(unsigned gpio) | |||
136 | */ | 136 | */ |
137 | static int desc_to_gpio(const struct gpio_desc *desc) | 137 | static int desc_to_gpio(const struct gpio_desc *desc) |
138 | { | 138 | { |
139 | return desc->chip->base + gpio_chip_hwgpio(desc); | 139 | return desc - &gpio_desc[0]; |
140 | } | 140 | } |
141 | 141 | ||
142 | 142 | ||
@@ -1398,7 +1398,7 @@ static int gpiod_request(struct gpio_desc *desc, const char *label) | |||
1398 | int status = -EPROBE_DEFER; | 1398 | int status = -EPROBE_DEFER; |
1399 | unsigned long flags; | 1399 | unsigned long flags; |
1400 | 1400 | ||
1401 | if (!desc || !desc->chip) { | 1401 | if (!desc) { |
1402 | pr_warn("%s: invalid GPIO\n", __func__); | 1402 | pr_warn("%s: invalid GPIO\n", __func__); |
1403 | return -EINVAL; | 1403 | return -EINVAL; |
1404 | } | 1404 | } |
@@ -1406,6 +1406,8 @@ static int gpiod_request(struct gpio_desc *desc, const char *label) | |||
1406 | spin_lock_irqsave(&gpio_lock, flags); | 1406 | spin_lock_irqsave(&gpio_lock, flags); |
1407 | 1407 | ||
1408 | chip = desc->chip; | 1408 | chip = desc->chip; |
1409 | if (chip == NULL) | ||
1410 | goto done; | ||
1409 | 1411 | ||
1410 | if (!try_module_get(chip->owner)) | 1412 | if (!try_module_get(chip->owner)) |
1411 | goto done; | 1413 | goto done; |
diff --git a/drivers/iio/frequency/adf4350.c b/drivers/iio/frequency/adf4350.c index a7b30be86ae0..52605c0ea3a6 100644 --- a/drivers/iio/frequency/adf4350.c +++ b/drivers/iio/frequency/adf4350.c | |||
@@ -525,8 +525,10 @@ static int adf4350_probe(struct spi_device *spi) | |||
525 | } | 525 | } |
526 | 526 | ||
527 | indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); | 527 | indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); |
528 | if (indio_dev == NULL) | 528 | if (indio_dev == NULL) { |
529 | return -ENOMEM; | 529 | ret = -ENOMEM; |
530 | goto error_disable_clk; | ||
531 | } | ||
530 | 532 | ||
531 | st = iio_priv(indio_dev); | 533 | st = iio_priv(indio_dev); |
532 | 534 | ||
diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c index 2710f7245c3b..2db7dcd826b9 100644 --- a/drivers/iio/industrialio-buffer.c +++ b/drivers/iio/industrialio-buffer.c | |||
@@ -477,6 +477,9 @@ void iio_disable_all_buffers(struct iio_dev *indio_dev) | |||
477 | indio_dev->currentmode = INDIO_DIRECT_MODE; | 477 | indio_dev->currentmode = INDIO_DIRECT_MODE; |
478 | if (indio_dev->setup_ops->postdisable) | 478 | if (indio_dev->setup_ops->postdisable) |
479 | indio_dev->setup_ops->postdisable(indio_dev); | 479 | indio_dev->setup_ops->postdisable(indio_dev); |
480 | |||
481 | if (indio_dev->available_scan_masks == NULL) | ||
482 | kfree(indio_dev->active_scan_mask); | ||
480 | } | 483 | } |
481 | 484 | ||
482 | int iio_update_buffers(struct iio_dev *indio_dev, | 485 | int iio_update_buffers(struct iio_dev *indio_dev, |
diff --git a/drivers/infiniband/hw/amso1100/c2_ae.c b/drivers/infiniband/hw/amso1100/c2_ae.c index d5d1929753e4..cedda25232be 100644 --- a/drivers/infiniband/hw/amso1100/c2_ae.c +++ b/drivers/infiniband/hw/amso1100/c2_ae.c | |||
@@ -141,7 +141,7 @@ static const char *to_qp_state_str(int state) | |||
141 | return "C2_QP_STATE_ERROR"; | 141 | return "C2_QP_STATE_ERROR"; |
142 | default: | 142 | default: |
143 | return "<invalid QP state>"; | 143 | return "<invalid QP state>"; |
144 | }; | 144 | } |
145 | } | 145 | } |
146 | 146 | ||
147 | void c2_ae_event(struct c2_dev *c2dev, u32 mq_index) | 147 | void c2_ae_event(struct c2_dev *c2dev, u32 mq_index) |
diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c index 3f831de9a4d8..b1a6cb3a2809 100644 --- a/drivers/infiniband/hw/mlx5/main.c +++ b/drivers/infiniband/hw/mlx5/main.c | |||
@@ -164,6 +164,7 @@ int mlx5_vector2eqn(struct mlx5_ib_dev *dev, int vector, int *eqn, int *irqn) | |||
164 | static int alloc_comp_eqs(struct mlx5_ib_dev *dev) | 164 | static int alloc_comp_eqs(struct mlx5_ib_dev *dev) |
165 | { | 165 | { |
166 | struct mlx5_eq_table *table = &dev->mdev.priv.eq_table; | 166 | struct mlx5_eq_table *table = &dev->mdev.priv.eq_table; |
167 | char name[MLX5_MAX_EQ_NAME]; | ||
167 | struct mlx5_eq *eq, *n; | 168 | struct mlx5_eq *eq, *n; |
168 | int ncomp_vec; | 169 | int ncomp_vec; |
169 | int nent; | 170 | int nent; |
@@ -180,11 +181,10 @@ static int alloc_comp_eqs(struct mlx5_ib_dev *dev) | |||
180 | goto clean; | 181 | goto clean; |
181 | } | 182 | } |
182 | 183 | ||
183 | snprintf(eq->name, MLX5_MAX_EQ_NAME, "mlx5_comp%d", i); | 184 | snprintf(name, MLX5_MAX_EQ_NAME, "mlx5_comp%d", i); |
184 | err = mlx5_create_map_eq(&dev->mdev, eq, | 185 | err = mlx5_create_map_eq(&dev->mdev, eq, |
185 | i + MLX5_EQ_VEC_COMP_BASE, nent, 0, | 186 | i + MLX5_EQ_VEC_COMP_BASE, nent, 0, |
186 | eq->name, | 187 | name, &dev->mdev.priv.uuari.uars[0]); |
187 | &dev->mdev.priv.uuari.uars[0]); | ||
188 | if (err) { | 188 | if (err) { |
189 | kfree(eq); | 189 | kfree(eq); |
190 | goto clean; | 190 | goto clean; |
@@ -301,9 +301,8 @@ static int mlx5_ib_query_device(struct ib_device *ibdev, | |||
301 | props->max_srq_sge = max_rq_sg - 1; | 301 | props->max_srq_sge = max_rq_sg - 1; |
302 | props->max_fast_reg_page_list_len = (unsigned int)-1; | 302 | props->max_fast_reg_page_list_len = (unsigned int)-1; |
303 | props->local_ca_ack_delay = dev->mdev.caps.local_ca_ack_delay; | 303 | props->local_ca_ack_delay = dev->mdev.caps.local_ca_ack_delay; |
304 | props->atomic_cap = dev->mdev.caps.flags & MLX5_DEV_CAP_FLAG_ATOMIC ? | 304 | props->atomic_cap = IB_ATOMIC_NONE; |
305 | IB_ATOMIC_HCA : IB_ATOMIC_NONE; | 305 | props->masked_atomic_cap = IB_ATOMIC_NONE; |
306 | props->masked_atomic_cap = IB_ATOMIC_HCA; | ||
307 | props->max_pkeys = be16_to_cpup((__be16 *)(out_mad->data + 28)); | 306 | props->max_pkeys = be16_to_cpup((__be16 *)(out_mad->data + 28)); |
308 | props->max_mcast_grp = 1 << dev->mdev.caps.log_max_mcg; | 307 | props->max_mcast_grp = 1 << dev->mdev.caps.log_max_mcg; |
309 | props->max_mcast_qp_attach = dev->mdev.caps.max_qp_mcg; | 308 | props->max_mcast_qp_attach = dev->mdev.caps.max_qp_mcg; |
@@ -1006,6 +1005,11 @@ static void mlx5_ib_event(struct mlx5_core_dev *dev, enum mlx5_dev_event event, | |||
1006 | ibev.device = &ibdev->ib_dev; | 1005 | ibev.device = &ibdev->ib_dev; |
1007 | ibev.element.port_num = port; | 1006 | ibev.element.port_num = port; |
1008 | 1007 | ||
1008 | if (port < 1 || port > ibdev->num_ports) { | ||
1009 | mlx5_ib_warn(ibdev, "warning: event on port %d\n", port); | ||
1010 | return; | ||
1011 | } | ||
1012 | |||
1009 | if (ibdev->ib_active) | 1013 | if (ibdev->ib_active) |
1010 | ib_dispatch_event(&ibev); | 1014 | ib_dispatch_event(&ibev); |
1011 | } | 1015 | } |
diff --git a/drivers/infiniband/hw/mlx5/mr.c b/drivers/infiniband/hw/mlx5/mr.c index bd41df95b6f0..3453580b1eb2 100644 --- a/drivers/infiniband/hw/mlx5/mr.c +++ b/drivers/infiniband/hw/mlx5/mr.c | |||
@@ -42,6 +42,10 @@ enum { | |||
42 | DEF_CACHE_SIZE = 10, | 42 | DEF_CACHE_SIZE = 10, |
43 | }; | 43 | }; |
44 | 44 | ||
45 | enum { | ||
46 | MLX5_UMR_ALIGN = 2048 | ||
47 | }; | ||
48 | |||
45 | static __be64 *mr_align(__be64 *ptr, int align) | 49 | static __be64 *mr_align(__be64 *ptr, int align) |
46 | { | 50 | { |
47 | unsigned long mask = align - 1; | 51 | unsigned long mask = align - 1; |
@@ -61,13 +65,11 @@ static int order2idx(struct mlx5_ib_dev *dev, int order) | |||
61 | 65 | ||
62 | static int add_keys(struct mlx5_ib_dev *dev, int c, int num) | 66 | static int add_keys(struct mlx5_ib_dev *dev, int c, int num) |
63 | { | 67 | { |
64 | struct device *ddev = dev->ib_dev.dma_device; | ||
65 | struct mlx5_mr_cache *cache = &dev->cache; | 68 | struct mlx5_mr_cache *cache = &dev->cache; |
66 | struct mlx5_cache_ent *ent = &cache->ent[c]; | 69 | struct mlx5_cache_ent *ent = &cache->ent[c]; |
67 | struct mlx5_create_mkey_mbox_in *in; | 70 | struct mlx5_create_mkey_mbox_in *in; |
68 | struct mlx5_ib_mr *mr; | 71 | struct mlx5_ib_mr *mr; |
69 | int npages = 1 << ent->order; | 72 | int npages = 1 << ent->order; |
70 | int size = sizeof(u64) * npages; | ||
71 | int err = 0; | 73 | int err = 0; |
72 | int i; | 74 | int i; |
73 | 75 | ||
@@ -83,21 +85,6 @@ static int add_keys(struct mlx5_ib_dev *dev, int c, int num) | |||
83 | } | 85 | } |
84 | mr->order = ent->order; | 86 | mr->order = ent->order; |
85 | mr->umred = 1; | 87 | mr->umred = 1; |
86 | mr->pas = kmalloc(size + 0x3f, GFP_KERNEL); | ||
87 | if (!mr->pas) { | ||
88 | kfree(mr); | ||
89 | err = -ENOMEM; | ||
90 | goto out; | ||
91 | } | ||
92 | mr->dma = dma_map_single(ddev, mr_align(mr->pas, 0x40), size, | ||
93 | DMA_TO_DEVICE); | ||
94 | if (dma_mapping_error(ddev, mr->dma)) { | ||
95 | kfree(mr->pas); | ||
96 | kfree(mr); | ||
97 | err = -ENOMEM; | ||
98 | goto out; | ||
99 | } | ||
100 | |||
101 | in->seg.status = 1 << 6; | 88 | in->seg.status = 1 << 6; |
102 | in->seg.xlt_oct_size = cpu_to_be32((npages + 1) / 2); | 89 | in->seg.xlt_oct_size = cpu_to_be32((npages + 1) / 2); |
103 | in->seg.qpn_mkey7_0 = cpu_to_be32(0xffffff << 8); | 90 | in->seg.qpn_mkey7_0 = cpu_to_be32(0xffffff << 8); |
@@ -108,8 +95,6 @@ static int add_keys(struct mlx5_ib_dev *dev, int c, int num) | |||
108 | sizeof(*in)); | 95 | sizeof(*in)); |
109 | if (err) { | 96 | if (err) { |
110 | mlx5_ib_warn(dev, "create mkey failed %d\n", err); | 97 | mlx5_ib_warn(dev, "create mkey failed %d\n", err); |
111 | dma_unmap_single(ddev, mr->dma, size, DMA_TO_DEVICE); | ||
112 | kfree(mr->pas); | ||
113 | kfree(mr); | 98 | kfree(mr); |
114 | goto out; | 99 | goto out; |
115 | } | 100 | } |
@@ -129,11 +114,9 @@ out: | |||
129 | 114 | ||
130 | static void remove_keys(struct mlx5_ib_dev *dev, int c, int num) | 115 | static void remove_keys(struct mlx5_ib_dev *dev, int c, int num) |
131 | { | 116 | { |
132 | struct device *ddev = dev->ib_dev.dma_device; | ||
133 | struct mlx5_mr_cache *cache = &dev->cache; | 117 | struct mlx5_mr_cache *cache = &dev->cache; |
134 | struct mlx5_cache_ent *ent = &cache->ent[c]; | 118 | struct mlx5_cache_ent *ent = &cache->ent[c]; |
135 | struct mlx5_ib_mr *mr; | 119 | struct mlx5_ib_mr *mr; |
136 | int size; | ||
137 | int err; | 120 | int err; |
138 | int i; | 121 | int i; |
139 | 122 | ||
@@ -149,14 +132,10 @@ static void remove_keys(struct mlx5_ib_dev *dev, int c, int num) | |||
149 | ent->size--; | 132 | ent->size--; |
150 | spin_unlock(&ent->lock); | 133 | spin_unlock(&ent->lock); |
151 | err = mlx5_core_destroy_mkey(&dev->mdev, &mr->mmr); | 134 | err = mlx5_core_destroy_mkey(&dev->mdev, &mr->mmr); |
152 | if (err) { | 135 | if (err) |
153 | mlx5_ib_warn(dev, "failed destroy mkey\n"); | 136 | mlx5_ib_warn(dev, "failed destroy mkey\n"); |
154 | } else { | 137 | else |
155 | size = ALIGN(sizeof(u64) * (1 << mr->order), 0x40); | ||
156 | dma_unmap_single(ddev, mr->dma, size, DMA_TO_DEVICE); | ||
157 | kfree(mr->pas); | ||
158 | kfree(mr); | 138 | kfree(mr); |
159 | } | ||
160 | } | 139 | } |
161 | } | 140 | } |
162 | 141 | ||
@@ -408,13 +387,12 @@ static void free_cached_mr(struct mlx5_ib_dev *dev, struct mlx5_ib_mr *mr) | |||
408 | 387 | ||
409 | static void clean_keys(struct mlx5_ib_dev *dev, int c) | 388 | static void clean_keys(struct mlx5_ib_dev *dev, int c) |
410 | { | 389 | { |
411 | struct device *ddev = dev->ib_dev.dma_device; | ||
412 | struct mlx5_mr_cache *cache = &dev->cache; | 390 | struct mlx5_mr_cache *cache = &dev->cache; |
413 | struct mlx5_cache_ent *ent = &cache->ent[c]; | 391 | struct mlx5_cache_ent *ent = &cache->ent[c]; |
414 | struct mlx5_ib_mr *mr; | 392 | struct mlx5_ib_mr *mr; |
415 | int size; | ||
416 | int err; | 393 | int err; |
417 | 394 | ||
395 | cancel_delayed_work(&ent->dwork); | ||
418 | while (1) { | 396 | while (1) { |
419 | spin_lock(&ent->lock); | 397 | spin_lock(&ent->lock); |
420 | if (list_empty(&ent->head)) { | 398 | if (list_empty(&ent->head)) { |
@@ -427,14 +405,10 @@ static void clean_keys(struct mlx5_ib_dev *dev, int c) | |||
427 | ent->size--; | 405 | ent->size--; |
428 | spin_unlock(&ent->lock); | 406 | spin_unlock(&ent->lock); |
429 | err = mlx5_core_destroy_mkey(&dev->mdev, &mr->mmr); | 407 | err = mlx5_core_destroy_mkey(&dev->mdev, &mr->mmr); |
430 | if (err) { | 408 | if (err) |
431 | mlx5_ib_warn(dev, "failed destroy mkey\n"); | 409 | mlx5_ib_warn(dev, "failed destroy mkey\n"); |
432 | } else { | 410 | else |
433 | size = ALIGN(sizeof(u64) * (1 << mr->order), 0x40); | ||
434 | dma_unmap_single(ddev, mr->dma, size, DMA_TO_DEVICE); | ||
435 | kfree(mr->pas); | ||
436 | kfree(mr); | 411 | kfree(mr); |
437 | } | ||
438 | } | 412 | } |
439 | } | 413 | } |
440 | 414 | ||
@@ -540,13 +514,15 @@ int mlx5_mr_cache_cleanup(struct mlx5_ib_dev *dev) | |||
540 | int i; | 514 | int i; |
541 | 515 | ||
542 | dev->cache.stopped = 1; | 516 | dev->cache.stopped = 1; |
543 | destroy_workqueue(dev->cache.wq); | 517 | flush_workqueue(dev->cache.wq); |
544 | 518 | ||
545 | mlx5_mr_cache_debugfs_cleanup(dev); | 519 | mlx5_mr_cache_debugfs_cleanup(dev); |
546 | 520 | ||
547 | for (i = 0; i < MAX_MR_CACHE_ENTRIES; i++) | 521 | for (i = 0; i < MAX_MR_CACHE_ENTRIES; i++) |
548 | clean_keys(dev, i); | 522 | clean_keys(dev, i); |
549 | 523 | ||
524 | destroy_workqueue(dev->cache.wq); | ||
525 | |||
550 | return 0; | 526 | return 0; |
551 | } | 527 | } |
552 | 528 | ||
@@ -675,10 +651,12 @@ static struct mlx5_ib_mr *reg_umr(struct ib_pd *pd, struct ib_umem *umem, | |||
675 | int page_shift, int order, int access_flags) | 651 | int page_shift, int order, int access_flags) |
676 | { | 652 | { |
677 | struct mlx5_ib_dev *dev = to_mdev(pd->device); | 653 | struct mlx5_ib_dev *dev = to_mdev(pd->device); |
654 | struct device *ddev = dev->ib_dev.dma_device; | ||
678 | struct umr_common *umrc = &dev->umrc; | 655 | struct umr_common *umrc = &dev->umrc; |
679 | struct ib_send_wr wr, *bad; | 656 | struct ib_send_wr wr, *bad; |
680 | struct mlx5_ib_mr *mr; | 657 | struct mlx5_ib_mr *mr; |
681 | struct ib_sge sg; | 658 | struct ib_sge sg; |
659 | int size = sizeof(u64) * npages; | ||
682 | int err; | 660 | int err; |
683 | int i; | 661 | int i; |
684 | 662 | ||
@@ -697,7 +675,22 @@ static struct mlx5_ib_mr *reg_umr(struct ib_pd *pd, struct ib_umem *umem, | |||
697 | if (!mr) | 675 | if (!mr) |
698 | return ERR_PTR(-EAGAIN); | 676 | return ERR_PTR(-EAGAIN); |
699 | 677 | ||
700 | mlx5_ib_populate_pas(dev, umem, page_shift, mr_align(mr->pas, 0x40), 1); | 678 | mr->pas = kmalloc(size + MLX5_UMR_ALIGN - 1, GFP_KERNEL); |
679 | if (!mr->pas) { | ||
680 | err = -ENOMEM; | ||
681 | goto error; | ||
682 | } | ||
683 | |||
684 | mlx5_ib_populate_pas(dev, umem, page_shift, | ||
685 | mr_align(mr->pas, MLX5_UMR_ALIGN), 1); | ||
686 | |||
687 | mr->dma = dma_map_single(ddev, mr_align(mr->pas, MLX5_UMR_ALIGN), size, | ||
688 | DMA_TO_DEVICE); | ||
689 | if (dma_mapping_error(ddev, mr->dma)) { | ||
690 | kfree(mr->pas); | ||
691 | err = -ENOMEM; | ||
692 | goto error; | ||
693 | } | ||
701 | 694 | ||
702 | memset(&wr, 0, sizeof(wr)); | 695 | memset(&wr, 0, sizeof(wr)); |
703 | wr.wr_id = (u64)(unsigned long)mr; | 696 | wr.wr_id = (u64)(unsigned long)mr; |
@@ -718,6 +711,9 @@ static struct mlx5_ib_mr *reg_umr(struct ib_pd *pd, struct ib_umem *umem, | |||
718 | wait_for_completion(&mr->done); | 711 | wait_for_completion(&mr->done); |
719 | up(&umrc->sem); | 712 | up(&umrc->sem); |
720 | 713 | ||
714 | dma_unmap_single(ddev, mr->dma, size, DMA_TO_DEVICE); | ||
715 | kfree(mr->pas); | ||
716 | |||
721 | if (mr->status != IB_WC_SUCCESS) { | 717 | if (mr->status != IB_WC_SUCCESS) { |
722 | mlx5_ib_warn(dev, "reg umr failed\n"); | 718 | mlx5_ib_warn(dev, "reg umr failed\n"); |
723 | err = -EFAULT; | 719 | err = -EFAULT; |
diff --git a/drivers/infiniband/hw/mlx5/qp.c b/drivers/infiniband/hw/mlx5/qp.c index 045f8cdbd303..5659ea880741 100644 --- a/drivers/infiniband/hw/mlx5/qp.c +++ b/drivers/infiniband/hw/mlx5/qp.c | |||
@@ -203,7 +203,7 @@ static int sq_overhead(enum ib_qp_type qp_type) | |||
203 | 203 | ||
204 | switch (qp_type) { | 204 | switch (qp_type) { |
205 | case IB_QPT_XRC_INI: | 205 | case IB_QPT_XRC_INI: |
206 | size = sizeof(struct mlx5_wqe_xrc_seg); | 206 | size += sizeof(struct mlx5_wqe_xrc_seg); |
207 | /* fall through */ | 207 | /* fall through */ |
208 | case IB_QPT_RC: | 208 | case IB_QPT_RC: |
209 | size += sizeof(struct mlx5_wqe_ctrl_seg) + | 209 | size += sizeof(struct mlx5_wqe_ctrl_seg) + |
@@ -211,20 +211,23 @@ static int sq_overhead(enum ib_qp_type qp_type) | |||
211 | sizeof(struct mlx5_wqe_raddr_seg); | 211 | sizeof(struct mlx5_wqe_raddr_seg); |
212 | break; | 212 | break; |
213 | 213 | ||
214 | case IB_QPT_XRC_TGT: | ||
215 | return 0; | ||
216 | |||
214 | case IB_QPT_UC: | 217 | case IB_QPT_UC: |
215 | size = sizeof(struct mlx5_wqe_ctrl_seg) + | 218 | size += sizeof(struct mlx5_wqe_ctrl_seg) + |
216 | sizeof(struct mlx5_wqe_raddr_seg); | 219 | sizeof(struct mlx5_wqe_raddr_seg); |
217 | break; | 220 | break; |
218 | 221 | ||
219 | case IB_QPT_UD: | 222 | case IB_QPT_UD: |
220 | case IB_QPT_SMI: | 223 | case IB_QPT_SMI: |
221 | case IB_QPT_GSI: | 224 | case IB_QPT_GSI: |
222 | size = sizeof(struct mlx5_wqe_ctrl_seg) + | 225 | size += sizeof(struct mlx5_wqe_ctrl_seg) + |
223 | sizeof(struct mlx5_wqe_datagram_seg); | 226 | sizeof(struct mlx5_wqe_datagram_seg); |
224 | break; | 227 | break; |
225 | 228 | ||
226 | case MLX5_IB_QPT_REG_UMR: | 229 | case MLX5_IB_QPT_REG_UMR: |
227 | size = sizeof(struct mlx5_wqe_ctrl_seg) + | 230 | size += sizeof(struct mlx5_wqe_ctrl_seg) + |
228 | sizeof(struct mlx5_wqe_umr_ctrl_seg) + | 231 | sizeof(struct mlx5_wqe_umr_ctrl_seg) + |
229 | sizeof(struct mlx5_mkey_seg); | 232 | sizeof(struct mlx5_mkey_seg); |
230 | break; | 233 | break; |
@@ -270,7 +273,8 @@ static int calc_sq_size(struct mlx5_ib_dev *dev, struct ib_qp_init_attr *attr, | |||
270 | return wqe_size; | 273 | return wqe_size; |
271 | 274 | ||
272 | if (wqe_size > dev->mdev.caps.max_sq_desc_sz) { | 275 | if (wqe_size > dev->mdev.caps.max_sq_desc_sz) { |
273 | mlx5_ib_dbg(dev, "\n"); | 276 | mlx5_ib_dbg(dev, "wqe_size(%d) > max_sq_desc_sz(%d)\n", |
277 | wqe_size, dev->mdev.caps.max_sq_desc_sz); | ||
274 | return -EINVAL; | 278 | return -EINVAL; |
275 | } | 279 | } |
276 | 280 | ||
@@ -280,9 +284,15 @@ static int calc_sq_size(struct mlx5_ib_dev *dev, struct ib_qp_init_attr *attr, | |||
280 | 284 | ||
281 | wq_size = roundup_pow_of_two(attr->cap.max_send_wr * wqe_size); | 285 | wq_size = roundup_pow_of_two(attr->cap.max_send_wr * wqe_size); |
282 | qp->sq.wqe_cnt = wq_size / MLX5_SEND_WQE_BB; | 286 | qp->sq.wqe_cnt = wq_size / MLX5_SEND_WQE_BB; |
287 | if (qp->sq.wqe_cnt > dev->mdev.caps.max_wqes) { | ||
288 | mlx5_ib_dbg(dev, "wqe count(%d) exceeds limits(%d)\n", | ||
289 | qp->sq.wqe_cnt, dev->mdev.caps.max_wqes); | ||
290 | return -ENOMEM; | ||
291 | } | ||
283 | qp->sq.wqe_shift = ilog2(MLX5_SEND_WQE_BB); | 292 | qp->sq.wqe_shift = ilog2(MLX5_SEND_WQE_BB); |
284 | qp->sq.max_gs = attr->cap.max_send_sge; | 293 | qp->sq.max_gs = attr->cap.max_send_sge; |
285 | qp->sq.max_post = 1 << ilog2(wq_size / wqe_size); | 294 | qp->sq.max_post = wq_size / wqe_size; |
295 | attr->cap.max_send_wr = qp->sq.max_post; | ||
286 | 296 | ||
287 | return wq_size; | 297 | return wq_size; |
288 | } | 298 | } |
@@ -1280,6 +1290,11 @@ static enum mlx5_qp_optpar opt_mask[MLX5_QP_NUM_STATE][MLX5_QP_NUM_STATE][MLX5_Q | |||
1280 | MLX5_QP_OPTPAR_Q_KEY, | 1290 | MLX5_QP_OPTPAR_Q_KEY, |
1281 | [MLX5_QP_ST_MLX] = MLX5_QP_OPTPAR_PKEY_INDEX | | 1291 | [MLX5_QP_ST_MLX] = MLX5_QP_OPTPAR_PKEY_INDEX | |
1282 | MLX5_QP_OPTPAR_Q_KEY, | 1292 | MLX5_QP_OPTPAR_Q_KEY, |
1293 | [MLX5_QP_ST_XRC] = MLX5_QP_OPTPAR_ALT_ADDR_PATH | | ||
1294 | MLX5_QP_OPTPAR_RRE | | ||
1295 | MLX5_QP_OPTPAR_RAE | | ||
1296 | MLX5_QP_OPTPAR_RWE | | ||
1297 | MLX5_QP_OPTPAR_PKEY_INDEX, | ||
1283 | }, | 1298 | }, |
1284 | }, | 1299 | }, |
1285 | [MLX5_QP_STATE_RTR] = { | 1300 | [MLX5_QP_STATE_RTR] = { |
@@ -1314,6 +1329,11 @@ static enum mlx5_qp_optpar opt_mask[MLX5_QP_NUM_STATE][MLX5_QP_NUM_STATE][MLX5_Q | |||
1314 | [MLX5_QP_STATE_RTS] = { | 1329 | [MLX5_QP_STATE_RTS] = { |
1315 | [MLX5_QP_ST_UD] = MLX5_QP_OPTPAR_Q_KEY, | 1330 | [MLX5_QP_ST_UD] = MLX5_QP_OPTPAR_Q_KEY, |
1316 | [MLX5_QP_ST_MLX] = MLX5_QP_OPTPAR_Q_KEY, | 1331 | [MLX5_QP_ST_MLX] = MLX5_QP_OPTPAR_Q_KEY, |
1332 | [MLX5_QP_ST_UC] = MLX5_QP_OPTPAR_RWE, | ||
1333 | [MLX5_QP_ST_RC] = MLX5_QP_OPTPAR_RNR_TIMEOUT | | ||
1334 | MLX5_QP_OPTPAR_RWE | | ||
1335 | MLX5_QP_OPTPAR_RAE | | ||
1336 | MLX5_QP_OPTPAR_RRE, | ||
1317 | }, | 1337 | }, |
1318 | }, | 1338 | }, |
1319 | }; | 1339 | }; |
@@ -1651,29 +1671,6 @@ static __always_inline void set_raddr_seg(struct mlx5_wqe_raddr_seg *rseg, | |||
1651 | rseg->reserved = 0; | 1671 | rseg->reserved = 0; |
1652 | } | 1672 | } |
1653 | 1673 | ||
1654 | static void set_atomic_seg(struct mlx5_wqe_atomic_seg *aseg, struct ib_send_wr *wr) | ||
1655 | { | ||
1656 | if (wr->opcode == IB_WR_ATOMIC_CMP_AND_SWP) { | ||
1657 | aseg->swap_add = cpu_to_be64(wr->wr.atomic.swap); | ||
1658 | aseg->compare = cpu_to_be64(wr->wr.atomic.compare_add); | ||
1659 | } else if (wr->opcode == IB_WR_MASKED_ATOMIC_FETCH_AND_ADD) { | ||
1660 | aseg->swap_add = cpu_to_be64(wr->wr.atomic.compare_add); | ||
1661 | aseg->compare = cpu_to_be64(wr->wr.atomic.compare_add_mask); | ||
1662 | } else { | ||
1663 | aseg->swap_add = cpu_to_be64(wr->wr.atomic.compare_add); | ||
1664 | aseg->compare = 0; | ||
1665 | } | ||
1666 | } | ||
1667 | |||
1668 | static void set_masked_atomic_seg(struct mlx5_wqe_masked_atomic_seg *aseg, | ||
1669 | struct ib_send_wr *wr) | ||
1670 | { | ||
1671 | aseg->swap_add = cpu_to_be64(wr->wr.atomic.swap); | ||
1672 | aseg->swap_add_mask = cpu_to_be64(wr->wr.atomic.swap_mask); | ||
1673 | aseg->compare = cpu_to_be64(wr->wr.atomic.compare_add); | ||
1674 | aseg->compare_mask = cpu_to_be64(wr->wr.atomic.compare_add_mask); | ||
1675 | } | ||
1676 | |||
1677 | static void set_datagram_seg(struct mlx5_wqe_datagram_seg *dseg, | 1674 | static void set_datagram_seg(struct mlx5_wqe_datagram_seg *dseg, |
1678 | struct ib_send_wr *wr) | 1675 | struct ib_send_wr *wr) |
1679 | { | 1676 | { |
@@ -2063,28 +2060,11 @@ int mlx5_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr, | |||
2063 | 2060 | ||
2064 | case IB_WR_ATOMIC_CMP_AND_SWP: | 2061 | case IB_WR_ATOMIC_CMP_AND_SWP: |
2065 | case IB_WR_ATOMIC_FETCH_AND_ADD: | 2062 | case IB_WR_ATOMIC_FETCH_AND_ADD: |
2066 | set_raddr_seg(seg, wr->wr.atomic.remote_addr, | ||
2067 | wr->wr.atomic.rkey); | ||
2068 | seg += sizeof(struct mlx5_wqe_raddr_seg); | ||
2069 | |||
2070 | set_atomic_seg(seg, wr); | ||
2071 | seg += sizeof(struct mlx5_wqe_atomic_seg); | ||
2072 | |||
2073 | size += (sizeof(struct mlx5_wqe_raddr_seg) + | ||
2074 | sizeof(struct mlx5_wqe_atomic_seg)) / 16; | ||
2075 | break; | ||
2076 | |||
2077 | case IB_WR_MASKED_ATOMIC_CMP_AND_SWP: | 2063 | case IB_WR_MASKED_ATOMIC_CMP_AND_SWP: |
2078 | set_raddr_seg(seg, wr->wr.atomic.remote_addr, | 2064 | mlx5_ib_warn(dev, "Atomic operations are not supported yet\n"); |
2079 | wr->wr.atomic.rkey); | 2065 | err = -ENOSYS; |
2080 | seg += sizeof(struct mlx5_wqe_raddr_seg); | 2066 | *bad_wr = wr; |
2081 | 2067 | goto out; | |
2082 | set_masked_atomic_seg(seg, wr); | ||
2083 | seg += sizeof(struct mlx5_wqe_masked_atomic_seg); | ||
2084 | |||
2085 | size += (sizeof(struct mlx5_wqe_raddr_seg) + | ||
2086 | sizeof(struct mlx5_wqe_masked_atomic_seg)) / 16; | ||
2087 | break; | ||
2088 | 2068 | ||
2089 | case IB_WR_LOCAL_INV: | 2069 | case IB_WR_LOCAL_INV: |
2090 | next_fence = MLX5_FENCE_MODE_INITIATOR_SMALL; | 2070 | next_fence = MLX5_FENCE_MODE_INITIATOR_SMALL; |
diff --git a/drivers/infiniband/hw/mlx5/srq.c b/drivers/infiniband/hw/mlx5/srq.c index 84d297afd6a9..0aa478bc291a 100644 --- a/drivers/infiniband/hw/mlx5/srq.c +++ b/drivers/infiniband/hw/mlx5/srq.c | |||
@@ -295,7 +295,7 @@ struct ib_srq *mlx5_ib_create_srq(struct ib_pd *pd, | |||
295 | mlx5_vfree(in); | 295 | mlx5_vfree(in); |
296 | if (err) { | 296 | if (err) { |
297 | mlx5_ib_dbg(dev, "create SRQ failed, err %d\n", err); | 297 | mlx5_ib_dbg(dev, "create SRQ failed, err %d\n", err); |
298 | goto err_srq; | 298 | goto err_usr_kern_srq; |
299 | } | 299 | } |
300 | 300 | ||
301 | mlx5_ib_dbg(dev, "create SRQ with srqn 0x%x\n", srq->msrq.srqn); | 301 | mlx5_ib_dbg(dev, "create SRQ with srqn 0x%x\n", srq->msrq.srqn); |
@@ -316,6 +316,8 @@ struct ib_srq *mlx5_ib_create_srq(struct ib_pd *pd, | |||
316 | 316 | ||
317 | err_core: | 317 | err_core: |
318 | mlx5_core_destroy_srq(&dev->mdev, &srq->msrq); | 318 | mlx5_core_destroy_srq(&dev->mdev, &srq->msrq); |
319 | |||
320 | err_usr_kern_srq: | ||
319 | if (pd->uobject) | 321 | if (pd->uobject) |
320 | destroy_srq_user(pd, srq); | 322 | destroy_srq_user(pd, srq); |
321 | else | 323 | else |
diff --git a/drivers/infiniband/hw/mthca/mthca_eq.c b/drivers/infiniband/hw/mthca/mthca_eq.c index 7c9d35f39d75..690201738993 100644 --- a/drivers/infiniband/hw/mthca/mthca_eq.c +++ b/drivers/infiniband/hw/mthca/mthca_eq.c | |||
@@ -357,7 +357,7 @@ static int mthca_eq_int(struct mthca_dev *dev, struct mthca_eq *eq) | |||
357 | mthca_warn(dev, "Unhandled event %02x(%02x) on EQ %d\n", | 357 | mthca_warn(dev, "Unhandled event %02x(%02x) on EQ %d\n", |
358 | eqe->type, eqe->subtype, eq->eqn); | 358 | eqe->type, eqe->subtype, eq->eqn); |
359 | break; | 359 | break; |
360 | }; | 360 | } |
361 | 361 | ||
362 | set_eqe_hw(eqe); | 362 | set_eqe_hw(eqe); |
363 | ++eq->cons_index; | 363 | ++eq->cons_index; |
diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_hw.c b/drivers/infiniband/hw/ocrdma/ocrdma_hw.c index 4ed8235d2d36..50219ab2279d 100644 --- a/drivers/infiniband/hw/ocrdma/ocrdma_hw.c +++ b/drivers/infiniband/hw/ocrdma/ocrdma_hw.c | |||
@@ -150,7 +150,7 @@ enum ib_qp_state get_ibqp_state(enum ocrdma_qp_state qps) | |||
150 | return IB_QPS_SQE; | 150 | return IB_QPS_SQE; |
151 | case OCRDMA_QPS_ERR: | 151 | case OCRDMA_QPS_ERR: |
152 | return IB_QPS_ERR; | 152 | return IB_QPS_ERR; |
153 | }; | 153 | } |
154 | return IB_QPS_ERR; | 154 | return IB_QPS_ERR; |
155 | } | 155 | } |
156 | 156 | ||
@@ -171,7 +171,7 @@ static enum ocrdma_qp_state get_ocrdma_qp_state(enum ib_qp_state qps) | |||
171 | return OCRDMA_QPS_SQE; | 171 | return OCRDMA_QPS_SQE; |
172 | case IB_QPS_ERR: | 172 | case IB_QPS_ERR: |
173 | return OCRDMA_QPS_ERR; | 173 | return OCRDMA_QPS_ERR; |
174 | }; | 174 | } |
175 | return OCRDMA_QPS_ERR; | 175 | return OCRDMA_QPS_ERR; |
176 | } | 176 | } |
177 | 177 | ||
@@ -1982,7 +1982,7 @@ int ocrdma_mbx_create_qp(struct ocrdma_qp *qp, struct ib_qp_init_attr *attrs, | |||
1982 | break; | 1982 | break; |
1983 | default: | 1983 | default: |
1984 | return -EINVAL; | 1984 | return -EINVAL; |
1985 | }; | 1985 | } |
1986 | 1986 | ||
1987 | cmd = ocrdma_init_emb_mqe(OCRDMA_CMD_CREATE_QP, sizeof(*cmd)); | 1987 | cmd = ocrdma_init_emb_mqe(OCRDMA_CMD_CREATE_QP, sizeof(*cmd)); |
1988 | if (!cmd) | 1988 | if (!cmd) |
diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_main.c b/drivers/infiniband/hw/ocrdma/ocrdma_main.c index 56e004940f18..0ce7674621ea 100644 --- a/drivers/infiniband/hw/ocrdma/ocrdma_main.c +++ b/drivers/infiniband/hw/ocrdma/ocrdma_main.c | |||
@@ -531,7 +531,7 @@ static void ocrdma_event_handler(struct ocrdma_dev *dev, u32 event) | |||
531 | case BE_DEV_DOWN: | 531 | case BE_DEV_DOWN: |
532 | ocrdma_close(dev); | 532 | ocrdma_close(dev); |
533 | break; | 533 | break; |
534 | }; | 534 | } |
535 | } | 535 | } |
536 | 536 | ||
537 | static struct ocrdma_driver ocrdma_drv = { | 537 | static struct ocrdma_driver ocrdma_drv = { |
diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c index 6e982bb43c31..69f1d1221a6b 100644 --- a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +++ b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | |||
@@ -141,7 +141,7 @@ static inline void get_link_speed_and_width(struct ocrdma_dev *dev, | |||
141 | /* Unsupported */ | 141 | /* Unsupported */ |
142 | *ib_speed = IB_SPEED_SDR; | 142 | *ib_speed = IB_SPEED_SDR; |
143 | *ib_width = IB_WIDTH_1X; | 143 | *ib_width = IB_WIDTH_1X; |
144 | }; | 144 | } |
145 | } | 145 | } |
146 | 146 | ||
147 | 147 | ||
@@ -2331,7 +2331,7 @@ static enum ib_wc_status ocrdma_to_ibwc_err(u16 status) | |||
2331 | default: | 2331 | default: |
2332 | ibwc_status = IB_WC_GENERAL_ERR; | 2332 | ibwc_status = IB_WC_GENERAL_ERR; |
2333 | break; | 2333 | break; |
2334 | }; | 2334 | } |
2335 | return ibwc_status; | 2335 | return ibwc_status; |
2336 | } | 2336 | } |
2337 | 2337 | ||
@@ -2370,7 +2370,7 @@ static void ocrdma_update_wc(struct ocrdma_qp *qp, struct ib_wc *ibwc, | |||
2370 | pr_err("%s() invalid opcode received = 0x%x\n", | 2370 | pr_err("%s() invalid opcode received = 0x%x\n", |
2371 | __func__, hdr->cw & OCRDMA_WQE_OPCODE_MASK); | 2371 | __func__, hdr->cw & OCRDMA_WQE_OPCODE_MASK); |
2372 | break; | 2372 | break; |
2373 | }; | 2373 | } |
2374 | } | 2374 | } |
2375 | 2375 | ||
2376 | static void ocrdma_set_cqe_status_flushed(struct ocrdma_qp *qp, | 2376 | static void ocrdma_set_cqe_status_flushed(struct ocrdma_qp *qp, |
diff --git a/drivers/md/dm-snap-persistent.c b/drivers/md/dm-snap-persistent.c index 4caa8e6d59d7..2d2b1b7588d7 100644 --- a/drivers/md/dm-snap-persistent.c +++ b/drivers/md/dm-snap-persistent.c | |||
@@ -269,6 +269,14 @@ static chunk_t area_location(struct pstore *ps, chunk_t area) | |||
269 | return NUM_SNAPSHOT_HDR_CHUNKS + ((ps->exceptions_per_area + 1) * area); | 269 | return NUM_SNAPSHOT_HDR_CHUNKS + ((ps->exceptions_per_area + 1) * area); |
270 | } | 270 | } |
271 | 271 | ||
272 | static void skip_metadata(struct pstore *ps) | ||
273 | { | ||
274 | uint32_t stride = ps->exceptions_per_area + 1; | ||
275 | chunk_t next_free = ps->next_free; | ||
276 | if (sector_div(next_free, stride) == NUM_SNAPSHOT_HDR_CHUNKS) | ||
277 | ps->next_free++; | ||
278 | } | ||
279 | |||
272 | /* | 280 | /* |
273 | * Read or write a metadata area. Remembering to skip the first | 281 | * Read or write a metadata area. Remembering to skip the first |
274 | * chunk which holds the header. | 282 | * chunk which holds the header. |
@@ -502,6 +510,8 @@ static int read_exceptions(struct pstore *ps, | |||
502 | 510 | ||
503 | ps->current_area--; | 511 | ps->current_area--; |
504 | 512 | ||
513 | skip_metadata(ps); | ||
514 | |||
505 | return 0; | 515 | return 0; |
506 | } | 516 | } |
507 | 517 | ||
@@ -616,8 +626,6 @@ static int persistent_prepare_exception(struct dm_exception_store *store, | |||
616 | struct dm_exception *e) | 626 | struct dm_exception *e) |
617 | { | 627 | { |
618 | struct pstore *ps = get_info(store); | 628 | struct pstore *ps = get_info(store); |
619 | uint32_t stride; | ||
620 | chunk_t next_free; | ||
621 | sector_t size = get_dev_size(dm_snap_cow(store->snap)->bdev); | 629 | sector_t size = get_dev_size(dm_snap_cow(store->snap)->bdev); |
622 | 630 | ||
623 | /* Is there enough room ? */ | 631 | /* Is there enough room ? */ |
@@ -630,10 +638,8 @@ static int persistent_prepare_exception(struct dm_exception_store *store, | |||
630 | * Move onto the next free pending, making sure to take | 638 | * Move onto the next free pending, making sure to take |
631 | * into account the location of the metadata chunks. | 639 | * into account the location of the metadata chunks. |
632 | */ | 640 | */ |
633 | stride = (ps->exceptions_per_area + 1); | 641 | ps->next_free++; |
634 | next_free = ++ps->next_free; | 642 | skip_metadata(ps); |
635 | if (sector_div(next_free, stride) == 1) | ||
636 | ps->next_free++; | ||
637 | 643 | ||
638 | atomic_inc(&ps->pending_count); | 644 | atomic_inc(&ps->pending_count); |
639 | return 0; | 645 | return 0; |
diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c index 5ac3aa48473b..022b1863d36c 100644 --- a/drivers/mfd/arizona-core.c +++ b/drivers/mfd/arizona-core.c | |||
@@ -569,13 +569,25 @@ static struct mfd_cell early_devs[] = { | |||
569 | { .name = "arizona-ldo1" }, | 569 | { .name = "arizona-ldo1" }, |
570 | }; | 570 | }; |
571 | 571 | ||
572 | static const char *wm5102_supplies[] = { | ||
573 | "DBVDD2", | ||
574 | "DBVDD3", | ||
575 | "CPVDD", | ||
576 | "SPKVDDL", | ||
577 | "SPKVDDR", | ||
578 | }; | ||
579 | |||
572 | static struct mfd_cell wm5102_devs[] = { | 580 | static struct mfd_cell wm5102_devs[] = { |
573 | { .name = "arizona-micsupp" }, | 581 | { .name = "arizona-micsupp" }, |
574 | { .name = "arizona-extcon" }, | 582 | { .name = "arizona-extcon" }, |
575 | { .name = "arizona-gpio" }, | 583 | { .name = "arizona-gpio" }, |
576 | { .name = "arizona-haptics" }, | 584 | { .name = "arizona-haptics" }, |
577 | { .name = "arizona-pwm" }, | 585 | { .name = "arizona-pwm" }, |
578 | { .name = "wm5102-codec" }, | 586 | { |
587 | .name = "wm5102-codec", | ||
588 | .parent_supplies = wm5102_supplies, | ||
589 | .num_parent_supplies = ARRAY_SIZE(wm5102_supplies), | ||
590 | }, | ||
579 | }; | 591 | }; |
580 | 592 | ||
581 | static struct mfd_cell wm5110_devs[] = { | 593 | static struct mfd_cell wm5110_devs[] = { |
@@ -584,7 +596,17 @@ static struct mfd_cell wm5110_devs[] = { | |||
584 | { .name = "arizona-gpio" }, | 596 | { .name = "arizona-gpio" }, |
585 | { .name = "arizona-haptics" }, | 597 | { .name = "arizona-haptics" }, |
586 | { .name = "arizona-pwm" }, | 598 | { .name = "arizona-pwm" }, |
587 | { .name = "wm5110-codec" }, | 599 | { |
600 | .name = "wm5110-codec", | ||
601 | .parent_supplies = wm5102_supplies, | ||
602 | .num_parent_supplies = ARRAY_SIZE(wm5102_supplies), | ||
603 | }, | ||
604 | }; | ||
605 | |||
606 | static const char *wm8997_supplies[] = { | ||
607 | "DBVDD2", | ||
608 | "CPVDD", | ||
609 | "SPKVDD", | ||
588 | }; | 610 | }; |
589 | 611 | ||
590 | static struct mfd_cell wm8997_devs[] = { | 612 | static struct mfd_cell wm8997_devs[] = { |
@@ -593,7 +615,11 @@ static struct mfd_cell wm8997_devs[] = { | |||
593 | { .name = "arizona-gpio" }, | 615 | { .name = "arizona-gpio" }, |
594 | { .name = "arizona-haptics" }, | 616 | { .name = "arizona-haptics" }, |
595 | { .name = "arizona-pwm" }, | 617 | { .name = "arizona-pwm" }, |
596 | { .name = "wm8997-codec" }, | 618 | { |
619 | .name = "wm8997-codec", | ||
620 | .parent_supplies = wm8997_supplies, | ||
621 | .num_parent_supplies = ARRAY_SIZE(wm8997_supplies), | ||
622 | }, | ||
597 | }; | 623 | }; |
598 | 624 | ||
599 | int arizona_dev_init(struct arizona *arizona) | 625 | int arizona_dev_init(struct arizona *arizona) |
diff --git a/drivers/mfd/mfd-core.c b/drivers/mfd/mfd-core.c index f421586f29fb..adc8ea36e7c4 100644 --- a/drivers/mfd/mfd-core.c +++ b/drivers/mfd/mfd-core.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <linux/module.h> | 20 | #include <linux/module.h> |
21 | #include <linux/irqdomain.h> | 21 | #include <linux/irqdomain.h> |
22 | #include <linux/of.h> | 22 | #include <linux/of.h> |
23 | #include <linux/regulator/consumer.h> | ||
23 | 24 | ||
24 | static struct device_type mfd_dev_type = { | 25 | static struct device_type mfd_dev_type = { |
25 | .name = "mfd_device", | 26 | .name = "mfd_device", |
@@ -99,6 +100,13 @@ static int mfd_add_device(struct device *parent, int id, | |||
99 | pdev->dev.dma_mask = parent->dma_mask; | 100 | pdev->dev.dma_mask = parent->dma_mask; |
100 | pdev->dev.dma_parms = parent->dma_parms; | 101 | pdev->dev.dma_parms = parent->dma_parms; |
101 | 102 | ||
103 | ret = devm_regulator_bulk_register_supply_alias( | ||
104 | &pdev->dev, cell->parent_supplies, | ||
105 | parent, cell->parent_supplies, | ||
106 | cell->num_parent_supplies); | ||
107 | if (ret < 0) | ||
108 | goto fail_res; | ||
109 | |||
102 | if (parent->of_node && cell->of_compatible) { | 110 | if (parent->of_node && cell->of_compatible) { |
103 | for_each_child_of_node(parent->of_node, np) { | 111 | for_each_child_of_node(parent->of_node, np) { |
104 | if (of_device_is_compatible(np, cell->of_compatible)) { | 112 | if (of_device_is_compatible(np, cell->of_compatible)) { |
@@ -112,12 +120,12 @@ static int mfd_add_device(struct device *parent, int id, | |||
112 | ret = platform_device_add_data(pdev, | 120 | ret = platform_device_add_data(pdev, |
113 | cell->platform_data, cell->pdata_size); | 121 | cell->platform_data, cell->pdata_size); |
114 | if (ret) | 122 | if (ret) |
115 | goto fail_res; | 123 | goto fail_alias; |
116 | } | 124 | } |
117 | 125 | ||
118 | ret = mfd_platform_add_cell(pdev, cell); | 126 | ret = mfd_platform_add_cell(pdev, cell); |
119 | if (ret) | 127 | if (ret) |
120 | goto fail_res; | 128 | goto fail_alias; |
121 | 129 | ||
122 | for (r = 0; r < cell->num_resources; r++) { | 130 | for (r = 0; r < cell->num_resources; r++) { |
123 | res[r].name = cell->resources[r].name; | 131 | res[r].name = cell->resources[r].name; |
@@ -152,17 +160,17 @@ static int mfd_add_device(struct device *parent, int id, | |||
152 | if (!cell->ignore_resource_conflicts) { | 160 | if (!cell->ignore_resource_conflicts) { |
153 | ret = acpi_check_resource_conflict(&res[r]); | 161 | ret = acpi_check_resource_conflict(&res[r]); |
154 | if (ret) | 162 | if (ret) |
155 | goto fail_res; | 163 | goto fail_alias; |
156 | } | 164 | } |
157 | } | 165 | } |
158 | 166 | ||
159 | ret = platform_device_add_resources(pdev, res, cell->num_resources); | 167 | ret = platform_device_add_resources(pdev, res, cell->num_resources); |
160 | if (ret) | 168 | if (ret) |
161 | goto fail_res; | 169 | goto fail_alias; |
162 | 170 | ||
163 | ret = platform_device_add(pdev); | 171 | ret = platform_device_add(pdev); |
164 | if (ret) | 172 | if (ret) |
165 | goto fail_res; | 173 | goto fail_alias; |
166 | 174 | ||
167 | if (cell->pm_runtime_no_callbacks) | 175 | if (cell->pm_runtime_no_callbacks) |
168 | pm_runtime_no_callbacks(&pdev->dev); | 176 | pm_runtime_no_callbacks(&pdev->dev); |
@@ -171,6 +179,10 @@ static int mfd_add_device(struct device *parent, int id, | |||
171 | 179 | ||
172 | return 0; | 180 | return 0; |
173 | 181 | ||
182 | fail_alias: | ||
183 | devm_regulator_bulk_unregister_supply_alias(&pdev->dev, | ||
184 | cell->parent_supplies, | ||
185 | cell->num_parent_supplies); | ||
174 | fail_res: | 186 | fail_res: |
175 | kfree(res); | 187 | kfree(res); |
176 | fail_device: | 188 | fail_device: |
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c index 5472cbd34028..6ca30739625f 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c | |||
@@ -180,28 +180,32 @@ static int verify_block_sig(struct mlx5_cmd_prot_block *block) | |||
180 | return 0; | 180 | return 0; |
181 | } | 181 | } |
182 | 182 | ||
183 | static void calc_block_sig(struct mlx5_cmd_prot_block *block, u8 token) | 183 | static void calc_block_sig(struct mlx5_cmd_prot_block *block, u8 token, |
184 | int csum) | ||
184 | { | 185 | { |
185 | block->token = token; | 186 | block->token = token; |
186 | block->ctrl_sig = ~xor8_buf(block->rsvd0, sizeof(*block) - sizeof(block->data) - 2); | 187 | if (csum) { |
187 | block->sig = ~xor8_buf(block, sizeof(*block) - 1); | 188 | block->ctrl_sig = ~xor8_buf(block->rsvd0, sizeof(*block) - |
189 | sizeof(block->data) - 2); | ||
190 | block->sig = ~xor8_buf(block, sizeof(*block) - 1); | ||
191 | } | ||
188 | } | 192 | } |
189 | 193 | ||
190 | static void calc_chain_sig(struct mlx5_cmd_msg *msg, u8 token) | 194 | static void calc_chain_sig(struct mlx5_cmd_msg *msg, u8 token, int csum) |
191 | { | 195 | { |
192 | struct mlx5_cmd_mailbox *next = msg->next; | 196 | struct mlx5_cmd_mailbox *next = msg->next; |
193 | 197 | ||
194 | while (next) { | 198 | while (next) { |
195 | calc_block_sig(next->buf, token); | 199 | calc_block_sig(next->buf, token, csum); |
196 | next = next->next; | 200 | next = next->next; |
197 | } | 201 | } |
198 | } | 202 | } |
199 | 203 | ||
200 | static void set_signature(struct mlx5_cmd_work_ent *ent) | 204 | static void set_signature(struct mlx5_cmd_work_ent *ent, int csum) |
201 | { | 205 | { |
202 | ent->lay->sig = ~xor8_buf(ent->lay, sizeof(*ent->lay)); | 206 | ent->lay->sig = ~xor8_buf(ent->lay, sizeof(*ent->lay)); |
203 | calc_chain_sig(ent->in, ent->token); | 207 | calc_chain_sig(ent->in, ent->token, csum); |
204 | calc_chain_sig(ent->out, ent->token); | 208 | calc_chain_sig(ent->out, ent->token, csum); |
205 | } | 209 | } |
206 | 210 | ||
207 | static void poll_timeout(struct mlx5_cmd_work_ent *ent) | 211 | static void poll_timeout(struct mlx5_cmd_work_ent *ent) |
@@ -539,8 +543,7 @@ static void cmd_work_handler(struct work_struct *work) | |||
539 | lay->type = MLX5_PCI_CMD_XPORT; | 543 | lay->type = MLX5_PCI_CMD_XPORT; |
540 | lay->token = ent->token; | 544 | lay->token = ent->token; |
541 | lay->status_own = CMD_OWNER_HW; | 545 | lay->status_own = CMD_OWNER_HW; |
542 | if (!cmd->checksum_disabled) | 546 | set_signature(ent, !cmd->checksum_disabled); |
543 | set_signature(ent); | ||
544 | dump_command(dev, ent, 1); | 547 | dump_command(dev, ent, 1); |
545 | ktime_get_ts(&ent->ts1); | 548 | ktime_get_ts(&ent->ts1); |
546 | 549 | ||
@@ -773,8 +776,6 @@ static int mlx5_copy_from_msg(void *to, struct mlx5_cmd_msg *from, int size) | |||
773 | 776 | ||
774 | copy = min_t(int, size, MLX5_CMD_DATA_BLOCK_SIZE); | 777 | copy = min_t(int, size, MLX5_CMD_DATA_BLOCK_SIZE); |
775 | block = next->buf; | 778 | block = next->buf; |
776 | if (xor8_buf(block, sizeof(*block)) != 0xff) | ||
777 | return -EINVAL; | ||
778 | 779 | ||
779 | memcpy(to, block->data, copy); | 780 | memcpy(to, block->data, copy); |
780 | to += copy; | 781 | to += copy; |
@@ -1361,6 +1362,7 @@ int mlx5_cmd_init(struct mlx5_core_dev *dev) | |||
1361 | goto err_map; | 1362 | goto err_map; |
1362 | } | 1363 | } |
1363 | 1364 | ||
1365 | cmd->checksum_disabled = 1; | ||
1364 | cmd->max_reg_cmds = (1 << cmd->log_sz) - 1; | 1366 | cmd->max_reg_cmds = (1 << cmd->log_sz) - 1; |
1365 | cmd->bitmask = (1 << cmd->max_reg_cmds) - 1; | 1367 | cmd->bitmask = (1 << cmd->max_reg_cmds) - 1; |
1366 | 1368 | ||
@@ -1510,7 +1512,7 @@ int mlx5_cmd_status_to_err(struct mlx5_outbox_hdr *hdr) | |||
1510 | case MLX5_CMD_STAT_BAD_SYS_STATE_ERR: return -EIO; | 1512 | case MLX5_CMD_STAT_BAD_SYS_STATE_ERR: return -EIO; |
1511 | case MLX5_CMD_STAT_BAD_RES_ERR: return -EINVAL; | 1513 | case MLX5_CMD_STAT_BAD_RES_ERR: return -EINVAL; |
1512 | case MLX5_CMD_STAT_RES_BUSY: return -EBUSY; | 1514 | case MLX5_CMD_STAT_RES_BUSY: return -EBUSY; |
1513 | case MLX5_CMD_STAT_LIM_ERR: return -EINVAL; | 1515 | case MLX5_CMD_STAT_LIM_ERR: return -ENOMEM; |
1514 | case MLX5_CMD_STAT_BAD_RES_STATE_ERR: return -EINVAL; | 1516 | case MLX5_CMD_STAT_BAD_RES_STATE_ERR: return -EINVAL; |
1515 | case MLX5_CMD_STAT_IX_ERR: return -EINVAL; | 1517 | case MLX5_CMD_STAT_IX_ERR: return -EINVAL; |
1516 | case MLX5_CMD_STAT_NO_RES_ERR: return -EAGAIN; | 1518 | case MLX5_CMD_STAT_NO_RES_ERR: return -EAGAIN; |
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eq.c b/drivers/net/ethernet/mellanox/mlx5/core/eq.c index 443cc4d7b024..2231d93cc7ad 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/eq.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/eq.c | |||
@@ -366,9 +366,11 @@ int mlx5_create_map_eq(struct mlx5_core_dev *dev, struct mlx5_eq *eq, u8 vecidx, | |||
366 | goto err_in; | 366 | goto err_in; |
367 | } | 367 | } |
368 | 368 | ||
369 | snprintf(eq->name, MLX5_MAX_EQ_NAME, "%s@pci:%s", | ||
370 | name, pci_name(dev->pdev)); | ||
369 | eq->eqn = out.eq_number; | 371 | eq->eqn = out.eq_number; |
370 | err = request_irq(table->msix_arr[vecidx].vector, mlx5_msix_handler, 0, | 372 | err = request_irq(table->msix_arr[vecidx].vector, mlx5_msix_handler, 0, |
371 | name, eq); | 373 | eq->name, eq); |
372 | if (err) | 374 | if (err) |
373 | goto err_eq; | 375 | goto err_eq; |
374 | 376 | ||
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/main.c b/drivers/net/ethernet/mellanox/mlx5/core/main.c index b47739b0b5f6..bc0f5fb66e24 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/main.c | |||
@@ -165,9 +165,7 @@ static int handle_hca_cap(struct mlx5_core_dev *dev) | |||
165 | struct mlx5_cmd_set_hca_cap_mbox_in *set_ctx = NULL; | 165 | struct mlx5_cmd_set_hca_cap_mbox_in *set_ctx = NULL; |
166 | struct mlx5_cmd_query_hca_cap_mbox_in query_ctx; | 166 | struct mlx5_cmd_query_hca_cap_mbox_in query_ctx; |
167 | struct mlx5_cmd_set_hca_cap_mbox_out set_out; | 167 | struct mlx5_cmd_set_hca_cap_mbox_out set_out; |
168 | struct mlx5_profile *prof = dev->profile; | ||
169 | u64 flags; | 168 | u64 flags; |
170 | int csum = 1; | ||
171 | int err; | 169 | int err; |
172 | 170 | ||
173 | memset(&query_ctx, 0, sizeof(query_ctx)); | 171 | memset(&query_ctx, 0, sizeof(query_ctx)); |
@@ -197,20 +195,14 @@ static int handle_hca_cap(struct mlx5_core_dev *dev) | |||
197 | memcpy(&set_ctx->hca_cap, &query_out->hca_cap, | 195 | memcpy(&set_ctx->hca_cap, &query_out->hca_cap, |
198 | sizeof(set_ctx->hca_cap)); | 196 | sizeof(set_ctx->hca_cap)); |
199 | 197 | ||
200 | if (prof->mask & MLX5_PROF_MASK_CMDIF_CSUM) { | ||
201 | csum = !!prof->cmdif_csum; | ||
202 | flags = be64_to_cpu(set_ctx->hca_cap.flags); | ||
203 | if (csum) | ||
204 | flags |= MLX5_DEV_CAP_FLAG_CMDIF_CSUM; | ||
205 | else | ||
206 | flags &= ~MLX5_DEV_CAP_FLAG_CMDIF_CSUM; | ||
207 | |||
208 | set_ctx->hca_cap.flags = cpu_to_be64(flags); | ||
209 | } | ||
210 | |||
211 | if (dev->profile->mask & MLX5_PROF_MASK_QP_SIZE) | 198 | if (dev->profile->mask & MLX5_PROF_MASK_QP_SIZE) |
212 | set_ctx->hca_cap.log_max_qp = dev->profile->log_max_qp; | 199 | set_ctx->hca_cap.log_max_qp = dev->profile->log_max_qp; |
213 | 200 | ||
201 | flags = be64_to_cpu(query_out->hca_cap.flags); | ||
202 | /* disable checksum */ | ||
203 | flags &= ~MLX5_DEV_CAP_FLAG_CMDIF_CSUM; | ||
204 | |||
205 | set_ctx->hca_cap.flags = cpu_to_be64(flags); | ||
214 | memset(&set_out, 0, sizeof(set_out)); | 206 | memset(&set_out, 0, sizeof(set_out)); |
215 | set_ctx->hca_cap.log_uar_page_sz = cpu_to_be16(PAGE_SHIFT - 12); | 207 | set_ctx->hca_cap.log_uar_page_sz = cpu_to_be16(PAGE_SHIFT - 12); |
216 | set_ctx->hdr.opcode = cpu_to_be16(MLX5_CMD_OP_SET_HCA_CAP); | 208 | set_ctx->hdr.opcode = cpu_to_be16(MLX5_CMD_OP_SET_HCA_CAP); |
@@ -225,9 +217,6 @@ static int handle_hca_cap(struct mlx5_core_dev *dev) | |||
225 | if (err) | 217 | if (err) |
226 | goto query_ex; | 218 | goto query_ex; |
227 | 219 | ||
228 | if (!csum) | ||
229 | dev->cmd.checksum_disabled = 1; | ||
230 | |||
231 | query_ex: | 220 | query_ex: |
232 | kfree(query_out); | 221 | kfree(query_out); |
233 | kfree(set_ctx); | 222 | kfree(set_ctx); |
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c b/drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c index 3a2408d44820..7b12acf210f8 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c | |||
@@ -90,6 +90,10 @@ struct mlx5_manage_pages_outbox { | |||
90 | __be64 pas[0]; | 90 | __be64 pas[0]; |
91 | }; | 91 | }; |
92 | 92 | ||
93 | enum { | ||
94 | MAX_RECLAIM_TIME_MSECS = 5000, | ||
95 | }; | ||
96 | |||
93 | static int insert_page(struct mlx5_core_dev *dev, u64 addr, struct page *page, u16 func_id) | 97 | static int insert_page(struct mlx5_core_dev *dev, u64 addr, struct page *page, u16 func_id) |
94 | { | 98 | { |
95 | struct rb_root *root = &dev->priv.page_root; | 99 | struct rb_root *root = &dev->priv.page_root; |
@@ -279,6 +283,9 @@ static int reclaim_pages(struct mlx5_core_dev *dev, u32 func_id, int npages, | |||
279 | int err; | 283 | int err; |
280 | int i; | 284 | int i; |
281 | 285 | ||
286 | if (nclaimed) | ||
287 | *nclaimed = 0; | ||
288 | |||
282 | memset(&in, 0, sizeof(in)); | 289 | memset(&in, 0, sizeof(in)); |
283 | outlen = sizeof(*out) + npages * sizeof(out->pas[0]); | 290 | outlen = sizeof(*out) + npages * sizeof(out->pas[0]); |
284 | out = mlx5_vzalloc(outlen); | 291 | out = mlx5_vzalloc(outlen); |
@@ -388,20 +395,25 @@ static int optimal_reclaimed_pages(void) | |||
388 | 395 | ||
389 | int mlx5_reclaim_startup_pages(struct mlx5_core_dev *dev) | 396 | int mlx5_reclaim_startup_pages(struct mlx5_core_dev *dev) |
390 | { | 397 | { |
391 | unsigned long end = jiffies + msecs_to_jiffies(5000); | 398 | unsigned long end = jiffies + msecs_to_jiffies(MAX_RECLAIM_TIME_MSECS); |
392 | struct fw_page *fwp; | 399 | struct fw_page *fwp; |
393 | struct rb_node *p; | 400 | struct rb_node *p; |
401 | int nclaimed = 0; | ||
394 | int err; | 402 | int err; |
395 | 403 | ||
396 | do { | 404 | do { |
397 | p = rb_first(&dev->priv.page_root); | 405 | p = rb_first(&dev->priv.page_root); |
398 | if (p) { | 406 | if (p) { |
399 | fwp = rb_entry(p, struct fw_page, rb_node); | 407 | fwp = rb_entry(p, struct fw_page, rb_node); |
400 | err = reclaim_pages(dev, fwp->func_id, optimal_reclaimed_pages(), NULL); | 408 | err = reclaim_pages(dev, fwp->func_id, |
409 | optimal_reclaimed_pages(), | ||
410 | &nclaimed); | ||
401 | if (err) { | 411 | if (err) { |
402 | mlx5_core_warn(dev, "failed reclaiming pages (%d)\n", err); | 412 | mlx5_core_warn(dev, "failed reclaiming pages (%d)\n", err); |
403 | return err; | 413 | return err; |
404 | } | 414 | } |
415 | if (nclaimed) | ||
416 | end = jiffies + msecs_to_jiffies(MAX_RECLAIM_TIME_MSECS); | ||
405 | } | 417 | } |
406 | if (time_after(jiffies, end)) { | 418 | if (time_after(jiffies, end)) { |
407 | mlx5_core_warn(dev, "FW did not return all pages. giving up...\n"); | 419 | mlx5_core_warn(dev, "FW did not return all pages. giving up...\n"); |
diff --git a/drivers/of/Kconfig b/drivers/of/Kconfig index 9d2009a9004d..78cc76053328 100644 --- a/drivers/of/Kconfig +++ b/drivers/of/Kconfig | |||
@@ -74,10 +74,4 @@ config OF_MTD | |||
74 | depends on MTD | 74 | depends on MTD |
75 | def_bool y | 75 | def_bool y |
76 | 76 | ||
77 | config OF_RESERVED_MEM | ||
78 | depends on OF_FLATTREE && (DMA_CMA || (HAVE_GENERIC_DMA_COHERENT && HAVE_MEMBLOCK)) | ||
79 | def_bool y | ||
80 | help | ||
81 | Initialization code for DMA reserved memory | ||
82 | |||
83 | endmenu # OF | 77 | endmenu # OF |
diff --git a/drivers/of/Makefile b/drivers/of/Makefile index ed9660adad77..efd05102c405 100644 --- a/drivers/of/Makefile +++ b/drivers/of/Makefile | |||
@@ -9,4 +9,3 @@ obj-$(CONFIG_OF_MDIO) += of_mdio.o | |||
9 | obj-$(CONFIG_OF_PCI) += of_pci.o | 9 | obj-$(CONFIG_OF_PCI) += of_pci.o |
10 | obj-$(CONFIG_OF_PCI_IRQ) += of_pci_irq.o | 10 | obj-$(CONFIG_OF_PCI_IRQ) += of_pci_irq.o |
11 | obj-$(CONFIG_OF_MTD) += of_mtd.o | 11 | obj-$(CONFIG_OF_MTD) += of_mtd.o |
12 | obj-$(CONFIG_OF_RESERVED_MEM) += of_reserved_mem.o | ||
diff --git a/drivers/of/base.c b/drivers/of/base.c index 865d3f66c86b..7d4c70f859e3 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c | |||
@@ -303,10 +303,8 @@ struct device_node *of_get_cpu_node(int cpu, unsigned int *thread) | |||
303 | struct device_node *cpun, *cpus; | 303 | struct device_node *cpun, *cpus; |
304 | 304 | ||
305 | cpus = of_find_node_by_path("/cpus"); | 305 | cpus = of_find_node_by_path("/cpus"); |
306 | if (!cpus) { | 306 | if (!cpus) |
307 | pr_warn("Missing cpus node, bailing out\n"); | ||
308 | return NULL; | 307 | return NULL; |
309 | } | ||
310 | 308 | ||
311 | for_each_child_of_node(cpus, cpun) { | 309 | for_each_child_of_node(cpus, cpun) { |
312 | if (of_node_cmp(cpun->type, "cpu")) | 310 | if (of_node_cmp(cpun->type, "cpu")) |
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index 229dd9d69e18..a4fa9ad31b8f 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c | |||
@@ -18,7 +18,6 @@ | |||
18 | #include <linux/string.h> | 18 | #include <linux/string.h> |
19 | #include <linux/errno.h> | 19 | #include <linux/errno.h> |
20 | #include <linux/slab.h> | 20 | #include <linux/slab.h> |
21 | #include <linux/random.h> | ||
22 | 21 | ||
23 | #include <asm/setup.h> /* for COMMAND_LINE_SIZE */ | 22 | #include <asm/setup.h> /* for COMMAND_LINE_SIZE */ |
24 | #ifdef CONFIG_PPC | 23 | #ifdef CONFIG_PPC |
@@ -803,14 +802,3 @@ void __init unflatten_device_tree(void) | |||
803 | } | 802 | } |
804 | 803 | ||
805 | #endif /* CONFIG_OF_EARLY_FLATTREE */ | 804 | #endif /* CONFIG_OF_EARLY_FLATTREE */ |
806 | |||
807 | /* Feed entire flattened device tree into the random pool */ | ||
808 | static int __init add_fdt_randomness(void) | ||
809 | { | ||
810 | if (initial_boot_params) | ||
811 | add_device_randomness(initial_boot_params, | ||
812 | be32_to_cpu(initial_boot_params->totalsize)); | ||
813 | |||
814 | return 0; | ||
815 | } | ||
816 | core_initcall(add_fdt_randomness); | ||
diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c deleted file mode 100644 index 0fe40c7d6904..000000000000 --- a/drivers/of/of_reserved_mem.c +++ /dev/null | |||
@@ -1,173 +0,0 @@ | |||
1 | /* | ||
2 | * Device tree based initialization code for reserved memory. | ||
3 | * | ||
4 | * Copyright (c) 2013 Samsung Electronics Co., Ltd. | ||
5 | * http://www.samsung.com | ||
6 | * Author: Marek Szyprowski <m.szyprowski@samsung.com> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or | ||
9 | * modify it under the terms of the GNU General Public License as | ||
10 | * published by the Free Software Foundation; either version 2 of the | ||
11 | * License or (at your optional) any later version of the license. | ||
12 | */ | ||
13 | |||
14 | #include <linux/memblock.h> | ||
15 | #include <linux/err.h> | ||
16 | #include <linux/of.h> | ||
17 | #include <linux/of_fdt.h> | ||
18 | #include <linux/of_platform.h> | ||
19 | #include <linux/mm.h> | ||
20 | #include <linux/sizes.h> | ||
21 | #include <linux/mm_types.h> | ||
22 | #include <linux/dma-contiguous.h> | ||
23 | #include <linux/dma-mapping.h> | ||
24 | #include <linux/of_reserved_mem.h> | ||
25 | |||
26 | #define MAX_RESERVED_REGIONS 16 | ||
27 | struct reserved_mem { | ||
28 | phys_addr_t base; | ||
29 | unsigned long size; | ||
30 | struct cma *cma; | ||
31 | char name[32]; | ||
32 | }; | ||
33 | static struct reserved_mem reserved_mem[MAX_RESERVED_REGIONS]; | ||
34 | static int reserved_mem_count; | ||
35 | |||
36 | static int __init fdt_scan_reserved_mem(unsigned long node, const char *uname, | ||
37 | int depth, void *data) | ||
38 | { | ||
39 | struct reserved_mem *rmem = &reserved_mem[reserved_mem_count]; | ||
40 | phys_addr_t base, size; | ||
41 | int is_cma, is_reserved; | ||
42 | unsigned long len; | ||
43 | const char *status; | ||
44 | __be32 *prop; | ||
45 | |||
46 | is_cma = IS_ENABLED(CONFIG_DMA_CMA) && | ||
47 | of_flat_dt_is_compatible(node, "linux,contiguous-memory-region"); | ||
48 | is_reserved = of_flat_dt_is_compatible(node, "reserved-memory-region"); | ||
49 | |||
50 | if (!is_reserved && !is_cma) { | ||
51 | /* ignore node and scan next one */ | ||
52 | return 0; | ||
53 | } | ||
54 | |||
55 | status = of_get_flat_dt_prop(node, "status", &len); | ||
56 | if (status && strcmp(status, "okay") != 0) { | ||
57 | /* ignore disabled node nad scan next one */ | ||
58 | return 0; | ||
59 | } | ||
60 | |||
61 | prop = of_get_flat_dt_prop(node, "reg", &len); | ||
62 | if (!prop || (len < (dt_root_size_cells + dt_root_addr_cells) * | ||
63 | sizeof(__be32))) { | ||
64 | pr_err("Reserved mem: node %s, incorrect \"reg\" property\n", | ||
65 | uname); | ||
66 | /* ignore node and scan next one */ | ||
67 | return 0; | ||
68 | } | ||
69 | base = dt_mem_next_cell(dt_root_addr_cells, &prop); | ||
70 | size = dt_mem_next_cell(dt_root_size_cells, &prop); | ||
71 | |||
72 | if (!size) { | ||
73 | /* ignore node and scan next one */ | ||
74 | return 0; | ||
75 | } | ||
76 | |||
77 | pr_info("Reserved mem: found %s, memory base %lx, size %ld MiB\n", | ||
78 | uname, (unsigned long)base, (unsigned long)size / SZ_1M); | ||
79 | |||
80 | if (reserved_mem_count == ARRAY_SIZE(reserved_mem)) | ||
81 | return -ENOSPC; | ||
82 | |||
83 | rmem->base = base; | ||
84 | rmem->size = size; | ||
85 | strlcpy(rmem->name, uname, sizeof(rmem->name)); | ||
86 | |||
87 | if (is_cma) { | ||
88 | struct cma *cma; | ||
89 | if (dma_contiguous_reserve_area(size, base, 0, &cma) == 0) { | ||
90 | rmem->cma = cma; | ||
91 | reserved_mem_count++; | ||
92 | if (of_get_flat_dt_prop(node, | ||
93 | "linux,default-contiguous-region", | ||
94 | NULL)) | ||
95 | dma_contiguous_set_default(cma); | ||
96 | } | ||
97 | } else if (is_reserved) { | ||
98 | if (memblock_remove(base, size) == 0) | ||
99 | reserved_mem_count++; | ||
100 | else | ||
101 | pr_err("Failed to reserve memory for %s\n", uname); | ||
102 | } | ||
103 | |||
104 | return 0; | ||
105 | } | ||
106 | |||
107 | static struct reserved_mem *get_dma_memory_region(struct device *dev) | ||
108 | { | ||
109 | struct device_node *node; | ||
110 | const char *name; | ||
111 | int i; | ||
112 | |||
113 | node = of_parse_phandle(dev->of_node, "memory-region", 0); | ||
114 | if (!node) | ||
115 | return NULL; | ||
116 | |||
117 | name = kbasename(node->full_name); | ||
118 | for (i = 0; i < reserved_mem_count; i++) | ||
119 | if (strcmp(name, reserved_mem[i].name) == 0) | ||
120 | return &reserved_mem[i]; | ||
121 | return NULL; | ||
122 | } | ||
123 | |||
124 | /** | ||
125 | * of_reserved_mem_device_init() - assign reserved memory region to given device | ||
126 | * | ||
127 | * This function assign memory region pointed by "memory-region" device tree | ||
128 | * property to the given device. | ||
129 | */ | ||
130 | void of_reserved_mem_device_init(struct device *dev) | ||
131 | { | ||
132 | struct reserved_mem *region = get_dma_memory_region(dev); | ||
133 | if (!region) | ||
134 | return; | ||
135 | |||
136 | if (region->cma) { | ||
137 | dev_set_cma_area(dev, region->cma); | ||
138 | pr_info("Assigned CMA %s to %s device\n", region->name, | ||
139 | dev_name(dev)); | ||
140 | } else { | ||
141 | if (dma_declare_coherent_memory(dev, region->base, region->base, | ||
142 | region->size, DMA_MEMORY_MAP | DMA_MEMORY_EXCLUSIVE) != 0) | ||
143 | pr_info("Declared reserved memory %s to %s device\n", | ||
144 | region->name, dev_name(dev)); | ||
145 | } | ||
146 | } | ||
147 | |||
148 | /** | ||
149 | * of_reserved_mem_device_release() - release reserved memory device structures | ||
150 | * | ||
151 | * This function releases structures allocated for memory region handling for | ||
152 | * the given device. | ||
153 | */ | ||
154 | void of_reserved_mem_device_release(struct device *dev) | ||
155 | { | ||
156 | struct reserved_mem *region = get_dma_memory_region(dev); | ||
157 | if (!region && !region->cma) | ||
158 | dma_release_declared_memory(dev); | ||
159 | } | ||
160 | |||
161 | /** | ||
162 | * early_init_dt_scan_reserved_mem() - create reserved memory regions | ||
163 | * | ||
164 | * This function grabs memory from early allocator for device exclusive use | ||
165 | * defined in device tree structures. It should be called by arch specific code | ||
166 | * once the early allocator (memblock) has been activated and all other | ||
167 | * subsystems have already allocated/reserved memory. | ||
168 | */ | ||
169 | void __init early_init_dt_scan_reserved_mem(void) | ||
170 | { | ||
171 | of_scan_flat_dt_by_path("/memory/reserved-memory", | ||
172 | fdt_scan_reserved_mem, NULL); | ||
173 | } | ||
diff --git a/drivers/of/platform.c b/drivers/of/platform.c index 9b439ac63d8e..f6dcde220821 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c | |||
@@ -21,7 +21,6 @@ | |||
21 | #include <linux/of_device.h> | 21 | #include <linux/of_device.h> |
22 | #include <linux/of_irq.h> | 22 | #include <linux/of_irq.h> |
23 | #include <linux/of_platform.h> | 23 | #include <linux/of_platform.h> |
24 | #include <linux/of_reserved_mem.h> | ||
25 | #include <linux/platform_device.h> | 24 | #include <linux/platform_device.h> |
26 | 25 | ||
27 | const struct of_device_id of_default_bus_match_table[] = { | 26 | const struct of_device_id of_default_bus_match_table[] = { |
@@ -219,8 +218,6 @@ static struct platform_device *of_platform_device_create_pdata( | |||
219 | dev->dev.bus = &platform_bus_type; | 218 | dev->dev.bus = &platform_bus_type; |
220 | dev->dev.platform_data = platform_data; | 219 | dev->dev.platform_data = platform_data; |
221 | 220 | ||
222 | of_reserved_mem_device_init(&dev->dev); | ||
223 | |||
224 | /* We do not fill the DMA ops for platform devices by default. | 221 | /* We do not fill the DMA ops for platform devices by default. |
225 | * This is currently the responsibility of the platform code | 222 | * This is currently the responsibility of the platform code |
226 | * to do such, possibly using a device notifier | 223 | * to do such, possibly using a device notifier |
@@ -228,7 +225,6 @@ static struct platform_device *of_platform_device_create_pdata( | |||
228 | 225 | ||
229 | if (of_device_add(dev) != 0) { | 226 | if (of_device_add(dev) != 0) { |
230 | platform_device_put(dev); | 227 | platform_device_put(dev); |
231 | of_reserved_mem_device_release(&dev->dev); | ||
232 | return NULL; | 228 | return NULL; |
233 | } | 229 | } |
234 | 230 | ||
diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c index 0b7d23b4ad95..be12fbfcae10 100644 --- a/drivers/pci/hotplug/acpiphp_glue.c +++ b/drivers/pci/hotplug/acpiphp_glue.c | |||
@@ -994,14 +994,16 @@ void acpiphp_enumerate_slots(struct pci_bus *bus) | |||
994 | 994 | ||
995 | /* | 995 | /* |
996 | * This bridge should have been registered as a hotplug function | 996 | * This bridge should have been registered as a hotplug function |
997 | * under its parent, so the context has to be there. If not, we | 997 | * under its parent, so the context should be there, unless the |
998 | * are in deep goo. | 998 | * parent is going to be handled by pciehp, in which case this |
999 | * bridge is not interesting to us either. | ||
999 | */ | 1000 | */ |
1000 | mutex_lock(&acpiphp_context_lock); | 1001 | mutex_lock(&acpiphp_context_lock); |
1001 | context = acpiphp_get_context(handle); | 1002 | context = acpiphp_get_context(handle); |
1002 | if (WARN_ON(!context)) { | 1003 | if (!context) { |
1003 | mutex_unlock(&acpiphp_context_lock); | 1004 | mutex_unlock(&acpiphp_context_lock); |
1004 | put_device(&bus->dev); | 1005 | put_device(&bus->dev); |
1006 | pci_dev_put(bridge->pci_dev); | ||
1005 | kfree(bridge); | 1007 | kfree(bridge); |
1006 | return; | 1008 | return; |
1007 | } | 1009 | } |
diff --git a/drivers/regulator/88pm800.c b/drivers/regulator/88pm800.c index 3459f60dcfd1..d333f7eac106 100644 --- a/drivers/regulator/88pm800.c +++ b/drivers/regulator/88pm800.c | |||
@@ -141,18 +141,14 @@ struct pm800_regulators { | |||
141 | 141 | ||
142 | /* Ranges are sorted in ascending order. */ | 142 | /* Ranges are sorted in ascending order. */ |
143 | static const struct regulator_linear_range buck1_volt_range[] = { | 143 | static const struct regulator_linear_range buck1_volt_range[] = { |
144 | { .min_uV = 600000, .max_uV = 1587500, .min_sel = 0, .max_sel = 0x4f, | 144 | REGULATOR_LINEAR_RANGE(600000, 0, 0x4f, 12500), |
145 | .uV_step = 12500 }, | 145 | REGULATOR_LINEAR_RANGE(1600000, 0x50, 0x54, 50000), |
146 | { .min_uV = 1600000, .max_uV = 1800000, .min_sel = 0x50, | ||
147 | .max_sel = 0x54, .uV_step = 50000 }, | ||
148 | }; | 146 | }; |
149 | 147 | ||
150 | /* BUCK 2~5 have same ranges. */ | 148 | /* BUCK 2~5 have same ranges. */ |
151 | static const struct regulator_linear_range buck2_5_volt_range[] = { | 149 | static const struct regulator_linear_range buck2_5_volt_range[] = { |
152 | { .min_uV = 600000, .max_uV = 1587500, .min_sel = 0, .max_sel = 0x4f, | 150 | REGULATOR_LINEAR_RANGE(600000, 0, 0x4f, 12500), |
153 | .uV_step = 12500 }, | 151 | REGULATOR_LINEAR_RANGE(1600000, 0x50, 0x72, 50000), |
154 | { .min_uV = 1600000, .max_uV = 3300000, .min_sel = 0x50, | ||
155 | .max_sel = 0x72, .uV_step = 50000 }, | ||
156 | }; | 152 | }; |
157 | 153 | ||
158 | static const unsigned int ldo1_volt_table[] = { | 154 | static const unsigned int ldo1_volt_table[] = { |
diff --git a/drivers/regulator/88pm8607.c b/drivers/regulator/88pm8607.c index 70230974468c..f704d83c93c4 100644 --- a/drivers/regulator/88pm8607.c +++ b/drivers/regulator/88pm8607.c | |||
@@ -391,7 +391,8 @@ static int pm8607_regulator_probe(struct platform_device *pdev) | |||
391 | else | 391 | else |
392 | config.regmap = chip->regmap_companion; | 392 | config.regmap = chip->regmap_companion; |
393 | 393 | ||
394 | info->regulator = regulator_register(&info->desc, &config); | 394 | info->regulator = devm_regulator_register(&pdev->dev, &info->desc, |
395 | &config); | ||
395 | if (IS_ERR(info->regulator)) { | 396 | if (IS_ERR(info->regulator)) { |
396 | dev_err(&pdev->dev, "failed to register regulator %s\n", | 397 | dev_err(&pdev->dev, "failed to register regulator %s\n", |
397 | info->desc.name); | 398 | info->desc.name); |
@@ -402,14 +403,6 @@ static int pm8607_regulator_probe(struct platform_device *pdev) | |||
402 | return 0; | 403 | return 0; |
403 | } | 404 | } |
404 | 405 | ||
405 | static int pm8607_regulator_remove(struct platform_device *pdev) | ||
406 | { | ||
407 | struct pm8607_regulator_info *info = platform_get_drvdata(pdev); | ||
408 | |||
409 | regulator_unregister(info->regulator); | ||
410 | return 0; | ||
411 | } | ||
412 | |||
413 | static struct platform_device_id pm8607_regulator_driver_ids[] = { | 406 | static struct platform_device_id pm8607_regulator_driver_ids[] = { |
414 | { | 407 | { |
415 | .name = "88pm860x-regulator", | 408 | .name = "88pm860x-regulator", |
@@ -428,7 +421,6 @@ static struct platform_driver pm8607_regulator_driver = { | |||
428 | .owner = THIS_MODULE, | 421 | .owner = THIS_MODULE, |
429 | }, | 422 | }, |
430 | .probe = pm8607_regulator_probe, | 423 | .probe = pm8607_regulator_probe, |
431 | .remove = pm8607_regulator_remove, | ||
432 | .id_table = pm8607_regulator_driver_ids, | 424 | .id_table = pm8607_regulator_driver_ids, |
433 | }; | 425 | }; |
434 | 426 | ||
diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig index dfe58096b374..ce785f481281 100644 --- a/drivers/regulator/Kconfig +++ b/drivers/regulator/Kconfig | |||
@@ -28,16 +28,6 @@ config REGULATOR_DEBUG | |||
28 | help | 28 | help |
29 | Say yes here to enable debugging support. | 29 | Say yes here to enable debugging support. |
30 | 30 | ||
31 | config REGULATOR_DUMMY | ||
32 | bool "Provide a dummy regulator if regulator lookups fail" | ||
33 | help | ||
34 | If this option is enabled then when a regulator lookup fails | ||
35 | and the board has not specified that it has provided full | ||
36 | constraints the regulator core will provide an always | ||
37 | enabled dummy regulator, allowing consumer drivers to continue. | ||
38 | |||
39 | A warning will be generated when this substitution is done. | ||
40 | |||
41 | config REGULATOR_FIXED_VOLTAGE | 31 | config REGULATOR_FIXED_VOLTAGE |
42 | tristate "Fixed voltage regulator support" | 32 | tristate "Fixed voltage regulator support" |
43 | help | 33 | help |
@@ -133,6 +123,14 @@ config REGULATOR_AS3711 | |||
133 | This driver provides support for the voltage regulators on the | 123 | This driver provides support for the voltage regulators on the |
134 | AS3711 PMIC | 124 | AS3711 PMIC |
135 | 125 | ||
126 | config REGULATOR_AS3722 | ||
127 | tristate "AMS AS3722 PMIC Regulators" | ||
128 | depends on MFD_AS3722 | ||
129 | help | ||
130 | This driver provides support for the voltage regulators on the | ||
131 | AS3722 PMIC. This will enable support for all the software | ||
132 | controllable DCDC/LDO regulators. | ||
133 | |||
136 | config REGULATOR_DA903X | 134 | config REGULATOR_DA903X |
137 | tristate "Dialog Semiconductor DA9030/DA9034 regulators" | 135 | tristate "Dialog Semiconductor DA9030/DA9034 regulators" |
138 | depends on PMIC_DA903X | 136 | depends on PMIC_DA903X |
@@ -429,6 +427,14 @@ config REGULATOR_TI_ABB | |||
429 | on TI SoCs may be unstable without enabling this as it provides | 427 | on TI SoCs may be unstable without enabling this as it provides |
430 | device specific optimized bias to allow/optimize functionality. | 428 | device specific optimized bias to allow/optimize functionality. |
431 | 429 | ||
430 | config REGULATOR_STW481X_VMMC | ||
431 | bool "ST Microelectronics STW481X VMMC regulator" | ||
432 | depends on MFD_STW481X | ||
433 | default y if MFD_STW481X | ||
434 | help | ||
435 | This driver supports the internal VMMC regulator in the STw481x | ||
436 | PMIC chips. | ||
437 | |||
432 | config REGULATOR_TPS51632 | 438 | config REGULATOR_TPS51632 |
433 | tristate "TI TPS51632 Power Regulator" | 439 | tristate "TI TPS51632 Power Regulator" |
434 | depends on I2C | 440 | depends on I2C |
diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile index 185cce246022..01c597ea1744 100644 --- a/drivers/regulator/Makefile +++ b/drivers/regulator/Makefile | |||
@@ -3,7 +3,7 @@ | |||
3 | # | 3 | # |
4 | 4 | ||
5 | 5 | ||
6 | obj-$(CONFIG_REGULATOR) += core.o dummy.o fixed-helper.o helpers.o | 6 | obj-$(CONFIG_REGULATOR) += core.o dummy.o fixed-helper.o helpers.o devres.o |
7 | obj-$(CONFIG_OF) += of_regulator.o | 7 | obj-$(CONFIG_OF) += of_regulator.o |
8 | obj-$(CONFIG_REGULATOR_FIXED_VOLTAGE) += fixed.o | 8 | obj-$(CONFIG_REGULATOR_FIXED_VOLTAGE) += fixed.o |
9 | obj-$(CONFIG_REGULATOR_VIRTUAL_CONSUMER) += virtual.o | 9 | obj-$(CONFIG_REGULATOR_VIRTUAL_CONSUMER) += virtual.o |
@@ -18,6 +18,7 @@ obj-$(CONFIG_REGULATOR_AD5398) += ad5398.o | |||
18 | obj-$(CONFIG_REGULATOR_ANATOP) += anatop-regulator.o | 18 | obj-$(CONFIG_REGULATOR_ANATOP) += anatop-regulator.o |
19 | obj-$(CONFIG_REGULATOR_ARIZONA) += arizona-micsupp.o arizona-ldo1.o | 19 | obj-$(CONFIG_REGULATOR_ARIZONA) += arizona-micsupp.o arizona-ldo1.o |
20 | obj-$(CONFIG_REGULATOR_AS3711) += as3711-regulator.o | 20 | obj-$(CONFIG_REGULATOR_AS3711) += as3711-regulator.o |
21 | obj-$(CONFIG_REGULATOR_AS3722) += as3722-regulator.o | ||
21 | obj-$(CONFIG_REGULATOR_DA903X) += da903x.o | 22 | obj-$(CONFIG_REGULATOR_DA903X) += da903x.o |
22 | obj-$(CONFIG_REGULATOR_DA9052) += da9052-regulator.o | 23 | obj-$(CONFIG_REGULATOR_DA9052) += da9052-regulator.o |
23 | obj-$(CONFIG_REGULATOR_DA9055) += da9055-regulator.o | 24 | obj-$(CONFIG_REGULATOR_DA9055) += da9055-regulator.o |
@@ -56,6 +57,7 @@ obj-$(CONFIG_REGULATOR_PCF50633) += pcf50633-regulator.o | |||
56 | obj-$(CONFIG_REGULATOR_RC5T583) += rc5t583-regulator.o | 57 | obj-$(CONFIG_REGULATOR_RC5T583) += rc5t583-regulator.o |
57 | obj-$(CONFIG_REGULATOR_S2MPS11) += s2mps11.o | 58 | obj-$(CONFIG_REGULATOR_S2MPS11) += s2mps11.o |
58 | obj-$(CONFIG_REGULATOR_S5M8767) += s5m8767.o | 59 | obj-$(CONFIG_REGULATOR_S5M8767) += s5m8767.o |
60 | obj-$(CONFIG_REGULATOR_STW481X_VMMC) += stw481x-vmmc.o | ||
59 | obj-$(CONFIG_REGULATOR_TI_ABB) += ti-abb-regulator.o | 61 | obj-$(CONFIG_REGULATOR_TI_ABB) += ti-abb-regulator.o |
60 | obj-$(CONFIG_REGULATOR_TPS6105X) += tps6105x-regulator.o | 62 | obj-$(CONFIG_REGULATOR_TPS6105X) += tps6105x-regulator.o |
61 | obj-$(CONFIG_REGULATOR_TPS62360) += tps62360-regulator.o | 63 | obj-$(CONFIG_REGULATOR_TPS62360) += tps62360-regulator.o |
diff --git a/drivers/regulator/aat2870-regulator.c b/drivers/regulator/aat2870-regulator.c index 881159dfcb5e..f70a9bfa5ff2 100644 --- a/drivers/regulator/aat2870-regulator.c +++ b/drivers/regulator/aat2870-regulator.c | |||
@@ -176,7 +176,7 @@ static int aat2870_regulator_probe(struct platform_device *pdev) | |||
176 | config.driver_data = ri; | 176 | config.driver_data = ri; |
177 | config.init_data = dev_get_platdata(&pdev->dev); | 177 | config.init_data = dev_get_platdata(&pdev->dev); |
178 | 178 | ||
179 | rdev = regulator_register(&ri->desc, &config); | 179 | rdev = devm_regulator_register(&pdev->dev, &ri->desc, &config); |
180 | if (IS_ERR(rdev)) { | 180 | if (IS_ERR(rdev)) { |
181 | dev_err(&pdev->dev, "Failed to register regulator %s\n", | 181 | dev_err(&pdev->dev, "Failed to register regulator %s\n", |
182 | ri->desc.name); | 182 | ri->desc.name); |
@@ -187,21 +187,12 @@ static int aat2870_regulator_probe(struct platform_device *pdev) | |||
187 | return 0; | 187 | return 0; |
188 | } | 188 | } |
189 | 189 | ||
190 | static int aat2870_regulator_remove(struct platform_device *pdev) | ||
191 | { | ||
192 | struct regulator_dev *rdev = platform_get_drvdata(pdev); | ||
193 | |||
194 | regulator_unregister(rdev); | ||
195 | return 0; | ||
196 | } | ||
197 | |||
198 | static struct platform_driver aat2870_regulator_driver = { | 190 | static struct platform_driver aat2870_regulator_driver = { |
199 | .driver = { | 191 | .driver = { |
200 | .name = "aat2870-regulator", | 192 | .name = "aat2870-regulator", |
201 | .owner = THIS_MODULE, | 193 | .owner = THIS_MODULE, |
202 | }, | 194 | }, |
203 | .probe = aat2870_regulator_probe, | 195 | .probe = aat2870_regulator_probe, |
204 | .remove = aat2870_regulator_remove, | ||
205 | }; | 196 | }; |
206 | 197 | ||
207 | static int __init aat2870_regulator_init(void) | 198 | static int __init aat2870_regulator_init(void) |
diff --git a/drivers/regulator/ab3100.c b/drivers/regulator/ab3100.c index 7d5eaa874b2d..77b46d0b37a6 100644 --- a/drivers/regulator/ab3100.c +++ b/drivers/regulator/ab3100.c | |||
@@ -535,7 +535,7 @@ static int ab3100_regulator_register(struct platform_device *pdev, | |||
535 | config.dev = &pdev->dev; | 535 | config.dev = &pdev->dev; |
536 | config.driver_data = reg; | 536 | config.driver_data = reg; |
537 | 537 | ||
538 | rdev = regulator_register(desc, &config); | 538 | rdev = devm_regulator_register(&pdev->dev, desc, &config); |
539 | if (IS_ERR(rdev)) { | 539 | if (IS_ERR(rdev)) { |
540 | err = PTR_ERR(rdev); | 540 | err = PTR_ERR(rdev); |
541 | dev_err(&pdev->dev, | 541 | dev_err(&pdev->dev, |
@@ -616,7 +616,6 @@ static int ab3100_regulators_remove(struct platform_device *pdev) | |||
616 | for (i = 0; i < AB3100_NUM_REGULATORS; i++) { | 616 | for (i = 0; i < AB3100_NUM_REGULATORS; i++) { |
617 | struct ab3100_regulator *reg = &ab3100_regulators[i]; | 617 | struct ab3100_regulator *reg = &ab3100_regulators[i]; |
618 | 618 | ||
619 | regulator_unregister(reg->rdev); | ||
620 | reg->rdev = NULL; | 619 | reg->rdev = NULL; |
621 | } | 620 | } |
622 | return 0; | 621 | return 0; |
diff --git a/drivers/regulator/ab8500-ext.c b/drivers/regulator/ab8500-ext.c index 02ff691cdb8b..29c0faaf8eba 100644 --- a/drivers/regulator/ab8500-ext.c +++ b/drivers/regulator/ab8500-ext.c | |||
@@ -413,16 +413,12 @@ static int ab8500_ext_regulator_probe(struct platform_device *pdev) | |||
413 | &pdata->ext_regulator[i]; | 413 | &pdata->ext_regulator[i]; |
414 | 414 | ||
415 | /* register regulator with framework */ | 415 | /* register regulator with framework */ |
416 | info->rdev = regulator_register(&info->desc, &config); | 416 | info->rdev = devm_regulator_register(&pdev->dev, &info->desc, |
417 | &config); | ||
417 | if (IS_ERR(info->rdev)) { | 418 | if (IS_ERR(info->rdev)) { |
418 | err = PTR_ERR(info->rdev); | 419 | err = PTR_ERR(info->rdev); |
419 | dev_err(&pdev->dev, "failed to register regulator %s\n", | 420 | dev_err(&pdev->dev, "failed to register regulator %s\n", |
420 | info->desc.name); | 421 | info->desc.name); |
421 | /* when we fail, un-register all earlier regulators */ | ||
422 | while (--i >= 0) { | ||
423 | info = &ab8500_ext_regulator_info[i]; | ||
424 | regulator_unregister(info->rdev); | ||
425 | } | ||
426 | return err; | 422 | return err; |
427 | } | 423 | } |
428 | 424 | ||
@@ -433,26 +429,8 @@ static int ab8500_ext_regulator_probe(struct platform_device *pdev) | |||
433 | return 0; | 429 | return 0; |
434 | } | 430 | } |
435 | 431 | ||
436 | static int ab8500_ext_regulator_remove(struct platform_device *pdev) | ||
437 | { | ||
438 | int i; | ||
439 | |||
440 | for (i = 0; i < ARRAY_SIZE(ab8500_ext_regulator_info); i++) { | ||
441 | struct ab8500_ext_regulator_info *info = NULL; | ||
442 | info = &ab8500_ext_regulator_info[i]; | ||
443 | |||
444 | dev_vdbg(rdev_get_dev(info->rdev), | ||
445 | "%s-remove\n", info->desc.name); | ||
446 | |||
447 | regulator_unregister(info->rdev); | ||
448 | } | ||
449 | |||
450 | return 0; | ||
451 | } | ||
452 | |||
453 | static struct platform_driver ab8500_ext_regulator_driver = { | 432 | static struct platform_driver ab8500_ext_regulator_driver = { |
454 | .probe = ab8500_ext_regulator_probe, | 433 | .probe = ab8500_ext_regulator_probe, |
455 | .remove = ab8500_ext_regulator_remove, | ||
456 | .driver = { | 434 | .driver = { |
457 | .name = "ab8500-ext-regulator", | 435 | .name = "ab8500-ext-regulator", |
458 | .owner = THIS_MODULE, | 436 | .owner = THIS_MODULE, |
diff --git a/drivers/regulator/ad5398.c b/drivers/regulator/ad5398.c index b2b203cb6b2f..48016a050d5f 100644 --- a/drivers/regulator/ad5398.c +++ b/drivers/regulator/ad5398.c | |||
@@ -219,7 +219,6 @@ static int ad5398_probe(struct i2c_client *client, | |||
219 | struct ad5398_chip_info *chip; | 219 | struct ad5398_chip_info *chip; |
220 | const struct ad5398_current_data_format *df = | 220 | const struct ad5398_current_data_format *df = |
221 | (struct ad5398_current_data_format *)id->driver_data; | 221 | (struct ad5398_current_data_format *)id->driver_data; |
222 | int ret; | ||
223 | 222 | ||
224 | if (!init_data) | 223 | if (!init_data) |
225 | return -EINVAL; | 224 | return -EINVAL; |
@@ -240,33 +239,21 @@ static int ad5398_probe(struct i2c_client *client, | |||
240 | chip->current_offset = df->current_offset; | 239 | chip->current_offset = df->current_offset; |
241 | chip->current_mask = (chip->current_level - 1) << chip->current_offset; | 240 | chip->current_mask = (chip->current_level - 1) << chip->current_offset; |
242 | 241 | ||
243 | chip->rdev = regulator_register(&ad5398_reg, &config); | 242 | chip->rdev = devm_regulator_register(&client->dev, &ad5398_reg, |
243 | &config); | ||
244 | if (IS_ERR(chip->rdev)) { | 244 | if (IS_ERR(chip->rdev)) { |
245 | ret = PTR_ERR(chip->rdev); | ||
246 | dev_err(&client->dev, "failed to register %s %s\n", | 245 | dev_err(&client->dev, "failed to register %s %s\n", |
247 | id->name, ad5398_reg.name); | 246 | id->name, ad5398_reg.name); |
248 | goto err; | 247 | return PTR_ERR(chip->rdev); |
249 | } | 248 | } |
250 | 249 | ||
251 | i2c_set_clientdata(client, chip); | 250 | i2c_set_clientdata(client, chip); |
252 | dev_dbg(&client->dev, "%s regulator driver is registered.\n", id->name); | 251 | dev_dbg(&client->dev, "%s regulator driver is registered.\n", id->name); |
253 | return 0; | 252 | return 0; |
254 | |||
255 | err: | ||
256 | return ret; | ||
257 | } | ||
258 | |||
259 | static int ad5398_remove(struct i2c_client *client) | ||
260 | { | ||
261 | struct ad5398_chip_info *chip = i2c_get_clientdata(client); | ||
262 | |||
263 | regulator_unregister(chip->rdev); | ||
264 | return 0; | ||
265 | } | 253 | } |
266 | 254 | ||
267 | static struct i2c_driver ad5398_driver = { | 255 | static struct i2c_driver ad5398_driver = { |
268 | .probe = ad5398_probe, | 256 | .probe = ad5398_probe, |
269 | .remove = ad5398_remove, | ||
270 | .driver = { | 257 | .driver = { |
271 | .name = "ad5398", | 258 | .name = "ad5398", |
272 | }, | 259 | }, |
diff --git a/drivers/regulator/anatop-regulator.c b/drivers/regulator/anatop-regulator.c index 0d4a8ccbb536..c734d0980826 100644 --- a/drivers/regulator/anatop-regulator.c +++ b/drivers/regulator/anatop-regulator.c | |||
@@ -200,7 +200,7 @@ static int anatop_regulator_probe(struct platform_device *pdev) | |||
200 | config.regmap = sreg->anatop; | 200 | config.regmap = sreg->anatop; |
201 | 201 | ||
202 | /* register regulator */ | 202 | /* register regulator */ |
203 | rdev = regulator_register(rdesc, &config); | 203 | rdev = devm_regulator_register(dev, rdesc, &config); |
204 | if (IS_ERR(rdev)) { | 204 | if (IS_ERR(rdev)) { |
205 | dev_err(dev, "failed to register %s\n", | 205 | dev_err(dev, "failed to register %s\n", |
206 | rdesc->name); | 206 | rdesc->name); |
@@ -223,7 +223,6 @@ static int anatop_regulator_remove(struct platform_device *pdev) | |||
223 | struct anatop_regulator *sreg = rdev_get_drvdata(rdev); | 223 | struct anatop_regulator *sreg = rdev_get_drvdata(rdev); |
224 | const char *name = sreg->name; | 224 | const char *name = sreg->name; |
225 | 225 | ||
226 | regulator_unregister(rdev); | ||
227 | kfree(name); | 226 | kfree(name); |
228 | 227 | ||
229 | return 0; | 228 | return 0; |
@@ -256,7 +255,7 @@ static void __exit anatop_regulator_exit(void) | |||
256 | } | 255 | } |
257 | module_exit(anatop_regulator_exit); | 256 | module_exit(anatop_regulator_exit); |
258 | 257 | ||
259 | MODULE_AUTHOR("Nancy Chen <Nancy.Chen@freescale.com>, " | 258 | MODULE_AUTHOR("Nancy Chen <Nancy.Chen@freescale.com>"); |
260 | "Ying-Chun Liu (PaulLiu) <paul.liu@linaro.org>"); | 259 | MODULE_AUTHOR("Ying-Chun Liu (PaulLiu) <paul.liu@linaro.org>"); |
261 | MODULE_DESCRIPTION("ANATOP Regulator driver"); | 260 | MODULE_DESCRIPTION("ANATOP Regulator driver"); |
262 | MODULE_LICENSE("GPL v2"); | 261 | MODULE_LICENSE("GPL v2"); |
diff --git a/drivers/regulator/arizona-ldo1.c b/drivers/regulator/arizona-ldo1.c index 81d8681c3195..4f6c2055f6b2 100644 --- a/drivers/regulator/arizona-ldo1.c +++ b/drivers/regulator/arizona-ldo1.c | |||
@@ -226,7 +226,7 @@ static int arizona_ldo1_probe(struct platform_device *pdev) | |||
226 | else | 226 | else |
227 | config.init_data = &ldo1->init_data; | 227 | config.init_data = &ldo1->init_data; |
228 | 228 | ||
229 | ldo1->regulator = regulator_register(desc, &config); | 229 | ldo1->regulator = devm_regulator_register(&pdev->dev, desc, &config); |
230 | if (IS_ERR(ldo1->regulator)) { | 230 | if (IS_ERR(ldo1->regulator)) { |
231 | ret = PTR_ERR(ldo1->regulator); | 231 | ret = PTR_ERR(ldo1->regulator); |
232 | dev_err(arizona->dev, "Failed to register LDO1 supply: %d\n", | 232 | dev_err(arizona->dev, "Failed to register LDO1 supply: %d\n", |
@@ -239,18 +239,8 @@ static int arizona_ldo1_probe(struct platform_device *pdev) | |||
239 | return 0; | 239 | return 0; |
240 | } | 240 | } |
241 | 241 | ||
242 | static int arizona_ldo1_remove(struct platform_device *pdev) | ||
243 | { | ||
244 | struct arizona_ldo1 *ldo1 = platform_get_drvdata(pdev); | ||
245 | |||
246 | regulator_unregister(ldo1->regulator); | ||
247 | |||
248 | return 0; | ||
249 | } | ||
250 | |||
251 | static struct platform_driver arizona_ldo1_driver = { | 242 | static struct platform_driver arizona_ldo1_driver = { |
252 | .probe = arizona_ldo1_probe, | 243 | .probe = arizona_ldo1_probe, |
253 | .remove = arizona_ldo1_remove, | ||
254 | .driver = { | 244 | .driver = { |
255 | .name = "arizona-ldo1", | 245 | .name = "arizona-ldo1", |
256 | .owner = THIS_MODULE, | 246 | .owner = THIS_MODULE, |
diff --git a/drivers/regulator/arizona-micsupp.c b/drivers/regulator/arizona-micsupp.c index e87536bf0bed..724706a97dc4 100644 --- a/drivers/regulator/arizona-micsupp.c +++ b/drivers/regulator/arizona-micsupp.c | |||
@@ -225,7 +225,9 @@ static int arizona_micsupp_probe(struct platform_device *pdev) | |||
225 | regmap_update_bits(arizona->regmap, ARIZONA_MIC_CHARGE_PUMP_1, | 225 | regmap_update_bits(arizona->regmap, ARIZONA_MIC_CHARGE_PUMP_1, |
226 | ARIZONA_CPMIC_BYPASS, 0); | 226 | ARIZONA_CPMIC_BYPASS, 0); |
227 | 227 | ||
228 | micsupp->regulator = regulator_register(&arizona_micsupp, &config); | 228 | micsupp->regulator = devm_regulator_register(&pdev->dev, |
229 | &arizona_micsupp, | ||
230 | &config); | ||
229 | if (IS_ERR(micsupp->regulator)) { | 231 | if (IS_ERR(micsupp->regulator)) { |
230 | ret = PTR_ERR(micsupp->regulator); | 232 | ret = PTR_ERR(micsupp->regulator); |
231 | dev_err(arizona->dev, "Failed to register mic supply: %d\n", | 233 | dev_err(arizona->dev, "Failed to register mic supply: %d\n", |
@@ -238,18 +240,8 @@ static int arizona_micsupp_probe(struct platform_device *pdev) | |||
238 | return 0; | 240 | return 0; |
239 | } | 241 | } |
240 | 242 | ||
241 | static int arizona_micsupp_remove(struct platform_device *pdev) | ||
242 | { | ||
243 | struct arizona_micsupp *micsupp = platform_get_drvdata(pdev); | ||
244 | |||
245 | regulator_unregister(micsupp->regulator); | ||
246 | |||
247 | return 0; | ||
248 | } | ||
249 | |||
250 | static struct platform_driver arizona_micsupp_driver = { | 243 | static struct platform_driver arizona_micsupp_driver = { |
251 | .probe = arizona_micsupp_probe, | 244 | .probe = arizona_micsupp_probe, |
252 | .remove = arizona_micsupp_remove, | ||
253 | .driver = { | 245 | .driver = { |
254 | .name = "arizona-micsupp", | 246 | .name = "arizona-micsupp", |
255 | .owner = THIS_MODULE, | 247 | .owner = THIS_MODULE, |
diff --git a/drivers/regulator/as3711-regulator.c b/drivers/regulator/as3711-regulator.c index 8406cd745da2..c77a58478cca 100644 --- a/drivers/regulator/as3711-regulator.c +++ b/drivers/regulator/as3711-regulator.c | |||
@@ -117,26 +117,19 @@ static struct regulator_ops as3711_dldo_ops = { | |||
117 | }; | 117 | }; |
118 | 118 | ||
119 | static const struct regulator_linear_range as3711_sd_ranges[] = { | 119 | static const struct regulator_linear_range as3711_sd_ranges[] = { |
120 | { .min_uV = 612500, .max_uV = 1400000, | 120 | REGULATOR_LINEAR_RANGE(612500, 0x1, 0x40, 12500), |
121 | .min_sel = 0x1, .max_sel = 0x40, .uV_step = 12500 }, | 121 | REGULATOR_LINEAR_RANGE(1425000, 0x41, 0x70, 25000), |
122 | { .min_uV = 1425000, .max_uV = 2600000, | 122 | REGULATOR_LINEAR_RANGE(2650000, 0x71, 0x7f, 50000), |
123 | .min_sel = 0x41, .max_sel = 0x70, .uV_step = 25000 }, | ||
124 | { .min_uV = 2650000, .max_uV = 3350000, | ||
125 | .min_sel = 0x71, .max_sel = 0x7f, .uV_step = 50000 }, | ||
126 | }; | 123 | }; |
127 | 124 | ||
128 | static const struct regulator_linear_range as3711_aldo_ranges[] = { | 125 | static const struct regulator_linear_range as3711_aldo_ranges[] = { |
129 | { .min_uV = 1200000, .max_uV = 1950000, | 126 | REGULATOR_LINEAR_RANGE(1200000, 0, 0xf, 50000), |
130 | .min_sel = 0, .max_sel = 0xf, .uV_step = 50000 }, | 127 | REGULATOR_LINEAR_RANGE(1800000, 0x10, 0x1f, 100000), |
131 | { .min_uV = 1800000, .max_uV = 3300000, | ||
132 | .min_sel = 0x10, .max_sel = 0x1f, .uV_step = 100000 }, | ||
133 | }; | 128 | }; |
134 | 129 | ||
135 | static const struct regulator_linear_range as3711_dldo_ranges[] = { | 130 | static const struct regulator_linear_range as3711_dldo_ranges[] = { |
136 | { .min_uV = 900000, .max_uV = 1700000, | 131 | REGULATOR_LINEAR_RANGE(900000, 0, 0x10, 50000), |
137 | .min_sel = 0, .max_sel = 0x10, .uV_step = 50000 }, | 132 | REGULATOR_LINEAR_RANGE(1750000, 0x20, 0x3f, 50000), |
138 | { .min_uV = 1750000, .max_uV = 3300000, | ||
139 | .min_sel = 0x20, .max_sel = 0x3f, .uV_step = 50000 }, | ||
140 | }; | 133 | }; |
141 | 134 | ||
142 | #define AS3711_REG(_id, _en_reg, _en_bit, _vmask, _vshift, _min_uV, _max_uV, _sfx) \ | 135 | #define AS3711_REG(_id, _en_reg, _en_bit, _vmask, _vshift, _min_uV, _max_uV, _sfx) \ |
@@ -273,33 +266,16 @@ static int as3711_regulator_probe(struct platform_device *pdev) | |||
273 | config.regmap = as3711->regmap; | 266 | config.regmap = as3711->regmap; |
274 | config.of_node = of_node[id]; | 267 | config.of_node = of_node[id]; |
275 | 268 | ||
276 | rdev = regulator_register(&ri->desc, &config); | 269 | rdev = devm_regulator_register(&pdev->dev, &ri->desc, &config); |
277 | if (IS_ERR(rdev)) { | 270 | if (IS_ERR(rdev)) { |
278 | dev_err(&pdev->dev, "Failed to register regulator %s\n", | 271 | dev_err(&pdev->dev, "Failed to register regulator %s\n", |
279 | ri->desc.name); | 272 | ri->desc.name); |
280 | ret = PTR_ERR(rdev); | 273 | return PTR_ERR(rdev); |
281 | goto eregreg; | ||
282 | } | 274 | } |
283 | reg->rdev = rdev; | 275 | reg->rdev = rdev; |
284 | } | 276 | } |
285 | platform_set_drvdata(pdev, regs); | 277 | platform_set_drvdata(pdev, regs); |
286 | return 0; | 278 | return 0; |
287 | |||
288 | eregreg: | ||
289 | while (--id >= 0) | ||
290 | regulator_unregister(regs[id].rdev); | ||
291 | |||
292 | return ret; | ||
293 | } | ||
294 | |||
295 | static int as3711_regulator_remove(struct platform_device *pdev) | ||
296 | { | ||
297 | struct as3711_regulator *regs = platform_get_drvdata(pdev); | ||
298 | int id; | ||
299 | |||
300 | for (id = 0; id < AS3711_REGULATOR_NUM; ++id) | ||
301 | regulator_unregister(regs[id].rdev); | ||
302 | return 0; | ||
303 | } | 279 | } |
304 | 280 | ||
305 | static struct platform_driver as3711_regulator_driver = { | 281 | static struct platform_driver as3711_regulator_driver = { |
@@ -308,7 +284,6 @@ static struct platform_driver as3711_regulator_driver = { | |||
308 | .owner = THIS_MODULE, | 284 | .owner = THIS_MODULE, |
309 | }, | 285 | }, |
310 | .probe = as3711_regulator_probe, | 286 | .probe = as3711_regulator_probe, |
311 | .remove = as3711_regulator_remove, | ||
312 | }; | 287 | }; |
313 | 288 | ||
314 | static int __init as3711_regulator_init(void) | 289 | static int __init as3711_regulator_init(void) |
diff --git a/drivers/regulator/as3722-regulator.c b/drivers/regulator/as3722-regulator.c new file mode 100644 index 000000000000..5917fe3dc983 --- /dev/null +++ b/drivers/regulator/as3722-regulator.c | |||
@@ -0,0 +1,908 @@ | |||
1 | /* | ||
2 | * Voltage regulator support for AMS AS3722 PMIC | ||
3 | * | ||
4 | * Copyright (C) 2013 ams | ||
5 | * | ||
6 | * Author: Florian Lobmaier <florian.lobmaier@ams.com> | ||
7 | * Author: Laxman Dewangan <ldewangan@nvidia.com> | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License as published by | ||
11 | * the Free Software Foundation; either version 2 of the License, or | ||
12 | * (at your option) any later version. | ||
13 | * | ||
14 | * This program is distributed in the hope that it will be useful, | ||
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | * GNU General Public License for more details. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License | ||
20 | * along with this program; if not, write to the Free Software | ||
21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
22 | * | ||
23 | */ | ||
24 | |||
25 | #include <linux/err.h> | ||
26 | #include <linux/kernel.h> | ||
27 | #include <linux/module.h> | ||
28 | #include <linux/mfd/as3722.h> | ||
29 | #include <linux/of.h> | ||
30 | #include <linux/of_platform.h> | ||
31 | #include <linux/platform_device.h> | ||
32 | #include <linux/regulator/driver.h> | ||
33 | #include <linux/regulator/machine.h> | ||
34 | #include <linux/regulator/of_regulator.h> | ||
35 | #include <linux/slab.h> | ||
36 | |||
37 | /* Regulator IDs */ | ||
38 | enum as3722_regulators_id { | ||
39 | AS3722_REGULATOR_ID_SD0, | ||
40 | AS3722_REGULATOR_ID_SD1, | ||
41 | AS3722_REGULATOR_ID_SD2, | ||
42 | AS3722_REGULATOR_ID_SD3, | ||
43 | AS3722_REGULATOR_ID_SD4, | ||
44 | AS3722_REGULATOR_ID_SD5, | ||
45 | AS3722_REGULATOR_ID_SD6, | ||
46 | AS3722_REGULATOR_ID_LDO0, | ||
47 | AS3722_REGULATOR_ID_LDO1, | ||
48 | AS3722_REGULATOR_ID_LDO2, | ||
49 | AS3722_REGULATOR_ID_LDO3, | ||
50 | AS3722_REGULATOR_ID_LDO4, | ||
51 | AS3722_REGULATOR_ID_LDO5, | ||
52 | AS3722_REGULATOR_ID_LDO6, | ||
53 | AS3722_REGULATOR_ID_LDO7, | ||
54 | AS3722_REGULATOR_ID_LDO9, | ||
55 | AS3722_REGULATOR_ID_LDO10, | ||
56 | AS3722_REGULATOR_ID_LDO11, | ||
57 | AS3722_REGULATOR_ID_MAX, | ||
58 | }; | ||
59 | |||
60 | struct as3722_register_mapping { | ||
61 | u8 regulator_id; | ||
62 | const char *name; | ||
63 | const char *sname; | ||
64 | u8 vsel_reg; | ||
65 | u8 vsel_mask; | ||
66 | int n_voltages; | ||
67 | u32 enable_reg; | ||
68 | u8 enable_mask; | ||
69 | u32 control_reg; | ||
70 | u8 mode_mask; | ||
71 | u32 sleep_ctrl_reg; | ||
72 | u8 sleep_ctrl_mask; | ||
73 | }; | ||
74 | |||
75 | struct as3722_regulator_config_data { | ||
76 | struct regulator_init_data *reg_init; | ||
77 | bool enable_tracking; | ||
78 | int ext_control; | ||
79 | }; | ||
80 | |||
81 | struct as3722_regulators { | ||
82 | struct device *dev; | ||
83 | struct as3722 *as3722; | ||
84 | struct regulator_dev *rdevs[AS3722_REGULATOR_ID_MAX]; | ||
85 | struct regulator_desc desc[AS3722_REGULATOR_ID_MAX]; | ||
86 | struct as3722_regulator_config_data | ||
87 | reg_config_data[AS3722_REGULATOR_ID_MAX]; | ||
88 | }; | ||
89 | |||
90 | static const struct as3722_register_mapping as3722_reg_lookup[] = { | ||
91 | { | ||
92 | .regulator_id = AS3722_REGULATOR_ID_SD0, | ||
93 | .name = "as3722-sd0", | ||
94 | .vsel_reg = AS3722_SD0_VOLTAGE_REG, | ||
95 | .vsel_mask = AS3722_SD_VSEL_MASK, | ||
96 | .enable_reg = AS3722_SD_CONTROL_REG, | ||
97 | .enable_mask = AS3722_SDn_CTRL(0), | ||
98 | .sleep_ctrl_reg = AS3722_ENABLE_CTRL1_REG, | ||
99 | .sleep_ctrl_mask = AS3722_SD0_EXT_ENABLE_MASK, | ||
100 | .control_reg = AS3722_SD0_CONTROL_REG, | ||
101 | .mode_mask = AS3722_SD0_MODE_FAST, | ||
102 | .n_voltages = AS3722_SD0_VSEL_MAX + 1, | ||
103 | }, | ||
104 | { | ||
105 | .regulator_id = AS3722_REGULATOR_ID_SD1, | ||
106 | .name = "as3722-sd1", | ||
107 | .vsel_reg = AS3722_SD1_VOLTAGE_REG, | ||
108 | .vsel_mask = AS3722_SD_VSEL_MASK, | ||
109 | .enable_reg = AS3722_SD_CONTROL_REG, | ||
110 | .enable_mask = AS3722_SDn_CTRL(1), | ||
111 | .sleep_ctrl_reg = AS3722_ENABLE_CTRL1_REG, | ||
112 | .sleep_ctrl_mask = AS3722_SD1_EXT_ENABLE_MASK, | ||
113 | .control_reg = AS3722_SD1_CONTROL_REG, | ||
114 | .mode_mask = AS3722_SD1_MODE_FAST, | ||
115 | .n_voltages = AS3722_SD0_VSEL_MAX + 1, | ||
116 | }, | ||
117 | { | ||
118 | .regulator_id = AS3722_REGULATOR_ID_SD2, | ||
119 | .name = "as3722-sd2", | ||
120 | .sname = "vsup-sd2", | ||
121 | .vsel_reg = AS3722_SD2_VOLTAGE_REG, | ||
122 | .vsel_mask = AS3722_SD_VSEL_MASK, | ||
123 | .enable_reg = AS3722_SD_CONTROL_REG, | ||
124 | .enable_mask = AS3722_SDn_CTRL(2), | ||
125 | .sleep_ctrl_reg = AS3722_ENABLE_CTRL1_REG, | ||
126 | .sleep_ctrl_mask = AS3722_SD2_EXT_ENABLE_MASK, | ||
127 | .control_reg = AS3722_SD23_CONTROL_REG, | ||
128 | .mode_mask = AS3722_SD2_MODE_FAST, | ||
129 | .n_voltages = AS3722_SD2_VSEL_MAX + 1, | ||
130 | }, | ||
131 | { | ||
132 | .regulator_id = AS3722_REGULATOR_ID_SD3, | ||
133 | .name = "as3722-sd3", | ||
134 | .sname = "vsup-sd3", | ||
135 | .vsel_reg = AS3722_SD3_VOLTAGE_REG, | ||
136 | .vsel_mask = AS3722_SD_VSEL_MASK, | ||
137 | .enable_reg = AS3722_SD_CONTROL_REG, | ||
138 | .enable_mask = AS3722_SDn_CTRL(3), | ||
139 | .sleep_ctrl_reg = AS3722_ENABLE_CTRL1_REG, | ||
140 | .sleep_ctrl_mask = AS3722_SD3_EXT_ENABLE_MASK, | ||
141 | .control_reg = AS3722_SD23_CONTROL_REG, | ||
142 | .mode_mask = AS3722_SD3_MODE_FAST, | ||
143 | .n_voltages = AS3722_SD2_VSEL_MAX + 1, | ||
144 | }, | ||
145 | { | ||
146 | .regulator_id = AS3722_REGULATOR_ID_SD4, | ||
147 | .name = "as3722-sd4", | ||
148 | .sname = "vsup-sd4", | ||
149 | .vsel_reg = AS3722_SD4_VOLTAGE_REG, | ||
150 | .vsel_mask = AS3722_SD_VSEL_MASK, | ||
151 | .enable_reg = AS3722_SD_CONTROL_REG, | ||
152 | .enable_mask = AS3722_SDn_CTRL(4), | ||
153 | .sleep_ctrl_reg = AS3722_ENABLE_CTRL2_REG, | ||
154 | .sleep_ctrl_mask = AS3722_SD4_EXT_ENABLE_MASK, | ||
155 | .control_reg = AS3722_SD4_CONTROL_REG, | ||
156 | .mode_mask = AS3722_SD4_MODE_FAST, | ||
157 | .n_voltages = AS3722_SD2_VSEL_MAX + 1, | ||
158 | }, | ||
159 | { | ||
160 | .regulator_id = AS3722_REGULATOR_ID_SD5, | ||
161 | .name = "as3722-sd5", | ||
162 | .sname = "vsup-sd5", | ||
163 | .vsel_reg = AS3722_SD5_VOLTAGE_REG, | ||
164 | .vsel_mask = AS3722_SD_VSEL_MASK, | ||
165 | .enable_reg = AS3722_SD_CONTROL_REG, | ||
166 | .enable_mask = AS3722_SDn_CTRL(5), | ||
167 | .sleep_ctrl_reg = AS3722_ENABLE_CTRL2_REG, | ||
168 | .sleep_ctrl_mask = AS3722_SD5_EXT_ENABLE_MASK, | ||
169 | .control_reg = AS3722_SD5_CONTROL_REG, | ||
170 | .mode_mask = AS3722_SD5_MODE_FAST, | ||
171 | .n_voltages = AS3722_SD2_VSEL_MAX + 1, | ||
172 | }, | ||
173 | { | ||
174 | .regulator_id = AS3722_REGULATOR_ID_SD6, | ||
175 | .name = "as3722-sd6", | ||
176 | .vsel_reg = AS3722_SD6_VOLTAGE_REG, | ||
177 | .vsel_mask = AS3722_SD_VSEL_MASK, | ||
178 | .enable_reg = AS3722_SD_CONTROL_REG, | ||
179 | .enable_mask = AS3722_SDn_CTRL(6), | ||
180 | .sleep_ctrl_reg = AS3722_ENABLE_CTRL2_REG, | ||
181 | .sleep_ctrl_mask = AS3722_SD6_EXT_ENABLE_MASK, | ||
182 | .control_reg = AS3722_SD6_CONTROL_REG, | ||
183 | .mode_mask = AS3722_SD6_MODE_FAST, | ||
184 | .n_voltages = AS3722_SD0_VSEL_MAX + 1, | ||
185 | }, | ||
186 | { | ||
187 | .regulator_id = AS3722_REGULATOR_ID_LDO0, | ||
188 | .name = "as3722-ldo0", | ||
189 | .sname = "vin-ldo0", | ||
190 | .vsel_reg = AS3722_LDO0_VOLTAGE_REG, | ||
191 | .vsel_mask = AS3722_LDO0_VSEL_MASK, | ||
192 | .enable_reg = AS3722_LDOCONTROL0_REG, | ||
193 | .enable_mask = AS3722_LDO0_CTRL, | ||
194 | .sleep_ctrl_reg = AS3722_ENABLE_CTRL3_REG, | ||
195 | .sleep_ctrl_mask = AS3722_LDO0_EXT_ENABLE_MASK, | ||
196 | .n_voltages = AS3722_LDO0_NUM_VOLT, | ||
197 | }, | ||
198 | { | ||
199 | .regulator_id = AS3722_REGULATOR_ID_LDO1, | ||
200 | .name = "as3722-ldo1", | ||
201 | .sname = "vin-ldo1-6", | ||
202 | .vsel_reg = AS3722_LDO1_VOLTAGE_REG, | ||
203 | .vsel_mask = AS3722_LDO_VSEL_MASK, | ||
204 | .enable_reg = AS3722_LDOCONTROL0_REG, | ||
205 | .enable_mask = AS3722_LDO1_CTRL, | ||
206 | .sleep_ctrl_reg = AS3722_ENABLE_CTRL3_REG, | ||
207 | .sleep_ctrl_mask = AS3722_LDO1_EXT_ENABLE_MASK, | ||
208 | .n_voltages = AS3722_LDO_NUM_VOLT, | ||
209 | }, | ||
210 | { | ||
211 | .regulator_id = AS3722_REGULATOR_ID_LDO2, | ||
212 | .name = "as3722-ldo2", | ||
213 | .sname = "vin-ldo2-5-7", | ||
214 | .vsel_reg = AS3722_LDO2_VOLTAGE_REG, | ||
215 | .vsel_mask = AS3722_LDO_VSEL_MASK, | ||
216 | .enable_reg = AS3722_LDOCONTROL0_REG, | ||
217 | .enable_mask = AS3722_LDO2_CTRL, | ||
218 | .sleep_ctrl_reg = AS3722_ENABLE_CTRL3_REG, | ||
219 | .sleep_ctrl_mask = AS3722_LDO2_EXT_ENABLE_MASK, | ||
220 | .n_voltages = AS3722_LDO_NUM_VOLT, | ||
221 | }, | ||
222 | { | ||
223 | .regulator_id = AS3722_REGULATOR_ID_LDO3, | ||
224 | .name = "as3722-ldo3", | ||
225 | .name = "vin-ldo3-4", | ||
226 | .vsel_reg = AS3722_LDO3_VOLTAGE_REG, | ||
227 | .vsel_mask = AS3722_LDO3_VSEL_MASK, | ||
228 | .enable_reg = AS3722_LDOCONTROL0_REG, | ||
229 | .enable_mask = AS3722_LDO3_CTRL, | ||
230 | .sleep_ctrl_reg = AS3722_ENABLE_CTRL3_REG, | ||
231 | .sleep_ctrl_mask = AS3722_LDO3_EXT_ENABLE_MASK, | ||
232 | .n_voltages = AS3722_LDO3_NUM_VOLT, | ||
233 | }, | ||
234 | { | ||
235 | .regulator_id = AS3722_REGULATOR_ID_LDO4, | ||
236 | .name = "as3722-ldo4", | ||
237 | .name = "vin-ldo3-4", | ||
238 | .vsel_reg = AS3722_LDO4_VOLTAGE_REG, | ||
239 | .vsel_mask = AS3722_LDO_VSEL_MASK, | ||
240 | .enable_reg = AS3722_LDOCONTROL0_REG, | ||
241 | .enable_mask = AS3722_LDO4_CTRL, | ||
242 | .sleep_ctrl_reg = AS3722_ENABLE_CTRL4_REG, | ||
243 | .sleep_ctrl_mask = AS3722_LDO4_EXT_ENABLE_MASK, | ||
244 | .n_voltages = AS3722_LDO_NUM_VOLT, | ||
245 | }, | ||
246 | { | ||
247 | .regulator_id = AS3722_REGULATOR_ID_LDO5, | ||
248 | .name = "as3722-ldo5", | ||
249 | .sname = "vin-ldo2-5-7", | ||
250 | .vsel_reg = AS3722_LDO5_VOLTAGE_REG, | ||
251 | .vsel_mask = AS3722_LDO_VSEL_MASK, | ||
252 | .enable_reg = AS3722_LDOCONTROL0_REG, | ||
253 | .enable_mask = AS3722_LDO5_CTRL, | ||
254 | .sleep_ctrl_reg = AS3722_ENABLE_CTRL4_REG, | ||
255 | .sleep_ctrl_mask = AS3722_LDO5_EXT_ENABLE_MASK, | ||
256 | .n_voltages = AS3722_LDO_NUM_VOLT, | ||
257 | }, | ||
258 | { | ||
259 | .regulator_id = AS3722_REGULATOR_ID_LDO6, | ||
260 | .name = "as3722-ldo6", | ||
261 | .sname = "vin-ldo1-6", | ||
262 | .vsel_reg = AS3722_LDO6_VOLTAGE_REG, | ||
263 | .vsel_mask = AS3722_LDO_VSEL_MASK, | ||
264 | .enable_reg = AS3722_LDOCONTROL0_REG, | ||
265 | .enable_mask = AS3722_LDO6_CTRL, | ||
266 | .sleep_ctrl_reg = AS3722_ENABLE_CTRL4_REG, | ||
267 | .sleep_ctrl_mask = AS3722_LDO6_EXT_ENABLE_MASK, | ||
268 | .n_voltages = AS3722_LDO_NUM_VOLT, | ||
269 | }, | ||
270 | { | ||
271 | .regulator_id = AS3722_REGULATOR_ID_LDO7, | ||
272 | .name = "as3722-ldo7", | ||
273 | .sname = "vin-ldo2-5-7", | ||
274 | .vsel_reg = AS3722_LDO7_VOLTAGE_REG, | ||
275 | .vsel_mask = AS3722_LDO_VSEL_MASK, | ||
276 | .enable_reg = AS3722_LDOCONTROL0_REG, | ||
277 | .enable_mask = AS3722_LDO7_CTRL, | ||
278 | .sleep_ctrl_reg = AS3722_ENABLE_CTRL4_REG, | ||
279 | .sleep_ctrl_mask = AS3722_LDO7_EXT_ENABLE_MASK, | ||
280 | .n_voltages = AS3722_LDO_NUM_VOLT, | ||
281 | }, | ||
282 | { | ||
283 | .regulator_id = AS3722_REGULATOR_ID_LDO9, | ||
284 | .name = "as3722-ldo9", | ||
285 | .sname = "vin-ldo9-10", | ||
286 | .vsel_reg = AS3722_LDO9_VOLTAGE_REG, | ||
287 | .vsel_mask = AS3722_LDO_VSEL_MASK, | ||
288 | .enable_reg = AS3722_LDOCONTROL1_REG, | ||
289 | .enable_mask = AS3722_LDO9_CTRL, | ||
290 | .sleep_ctrl_reg = AS3722_ENABLE_CTRL5_REG, | ||
291 | .sleep_ctrl_mask = AS3722_LDO9_EXT_ENABLE_MASK, | ||
292 | .n_voltages = AS3722_LDO_NUM_VOLT, | ||
293 | }, | ||
294 | { | ||
295 | .regulator_id = AS3722_REGULATOR_ID_LDO10, | ||
296 | .name = "as3722-ldo10", | ||
297 | .sname = "vin-ldo9-10", | ||
298 | .vsel_reg = AS3722_LDO10_VOLTAGE_REG, | ||
299 | .vsel_mask = AS3722_LDO_VSEL_MASK, | ||
300 | .enable_reg = AS3722_LDOCONTROL1_REG, | ||
301 | .enable_mask = AS3722_LDO10_CTRL, | ||
302 | .sleep_ctrl_reg = AS3722_ENABLE_CTRL5_REG, | ||
303 | .sleep_ctrl_mask = AS3722_LDO10_EXT_ENABLE_MASK, | ||
304 | .n_voltages = AS3722_LDO_NUM_VOLT, | ||
305 | }, | ||
306 | { | ||
307 | .regulator_id = AS3722_REGULATOR_ID_LDO11, | ||
308 | .name = "as3722-ldo11", | ||
309 | .sname = "vin-ldo11", | ||
310 | .vsel_reg = AS3722_LDO11_VOLTAGE_REG, | ||
311 | .vsel_mask = AS3722_LDO_VSEL_MASK, | ||
312 | .enable_reg = AS3722_LDOCONTROL1_REG, | ||
313 | .enable_mask = AS3722_LDO11_CTRL, | ||
314 | .sleep_ctrl_reg = AS3722_ENABLE_CTRL5_REG, | ||
315 | .sleep_ctrl_mask = AS3722_LDO11_EXT_ENABLE_MASK, | ||
316 | .n_voltages = AS3722_LDO_NUM_VOLT, | ||
317 | }, | ||
318 | }; | ||
319 | |||
320 | |||
321 | static const int as3722_ldo_current[] = { 150000, 300000 }; | ||
322 | static const int as3722_sd016_current[] = { 2500000, 3000000, 3500000 }; | ||
323 | |||
324 | static int as3722_current_to_index(int min_uA, int max_uA, | ||
325 | const int *curr_table, int n_currents) | ||
326 | { | ||
327 | int i; | ||
328 | |||
329 | for (i = n_currents - 1; i >= 0; i--) { | ||
330 | if ((min_uA <= curr_table[i]) && (curr_table[i] <= max_uA)) | ||
331 | return i; | ||
332 | } | ||
333 | return -EINVAL; | ||
334 | } | ||
335 | |||
336 | static int as3722_ldo_get_current_limit(struct regulator_dev *rdev) | ||
337 | { | ||
338 | struct as3722_regulators *as3722_regs = rdev_get_drvdata(rdev); | ||
339 | struct as3722 *as3722 = as3722_regs->as3722; | ||
340 | int id = rdev_get_id(rdev); | ||
341 | u32 val; | ||
342 | int ret; | ||
343 | |||
344 | ret = as3722_read(as3722, as3722_reg_lookup[id].vsel_reg, &val); | ||
345 | if (ret < 0) { | ||
346 | dev_err(as3722_regs->dev, "Reg 0x%02x read failed: %d\n", | ||
347 | as3722_reg_lookup[id].vsel_reg, ret); | ||
348 | return ret; | ||
349 | } | ||
350 | if (val & AS3722_LDO_ILIMIT_MASK) | ||
351 | return 300000; | ||
352 | return 150000; | ||
353 | } | ||
354 | |||
355 | static int as3722_ldo_set_current_limit(struct regulator_dev *rdev, | ||
356 | int min_uA, int max_uA) | ||
357 | { | ||
358 | struct as3722_regulators *as3722_regs = rdev_get_drvdata(rdev); | ||
359 | struct as3722 *as3722 = as3722_regs->as3722; | ||
360 | int id = rdev_get_id(rdev); | ||
361 | int ret; | ||
362 | u32 reg = 0; | ||
363 | |||
364 | ret = as3722_current_to_index(min_uA, max_uA, as3722_ldo_current, | ||
365 | ARRAY_SIZE(as3722_ldo_current)); | ||
366 | if (ret < 0) { | ||
367 | dev_err(as3722_regs->dev, | ||
368 | "Current range min:max = %d:%d does not support\n", | ||
369 | min_uA, max_uA); | ||
370 | return ret; | ||
371 | } | ||
372 | if (ret) | ||
373 | reg = AS3722_LDO_ILIMIT_BIT; | ||
374 | return as3722_update_bits(as3722, as3722_reg_lookup[id].vsel_reg, | ||
375 | AS3722_LDO_ILIMIT_MASK, reg); | ||
376 | } | ||
377 | |||
378 | static struct regulator_ops as3722_ldo0_ops = { | ||
379 | .is_enabled = regulator_is_enabled_regmap, | ||
380 | .enable = regulator_enable_regmap, | ||
381 | .disable = regulator_disable_regmap, | ||
382 | .list_voltage = regulator_list_voltage_linear, | ||
383 | .get_voltage_sel = regulator_get_voltage_sel_regmap, | ||
384 | .set_voltage_sel = regulator_set_voltage_sel_regmap, | ||
385 | .get_current_limit = as3722_ldo_get_current_limit, | ||
386 | .set_current_limit = as3722_ldo_set_current_limit, | ||
387 | }; | ||
388 | |||
389 | static struct regulator_ops as3722_ldo0_extcntrl_ops = { | ||
390 | .list_voltage = regulator_list_voltage_linear, | ||
391 | .get_voltage_sel = regulator_get_voltage_sel_regmap, | ||
392 | .set_voltage_sel = regulator_set_voltage_sel_regmap, | ||
393 | .get_current_limit = as3722_ldo_get_current_limit, | ||
394 | .set_current_limit = as3722_ldo_set_current_limit, | ||
395 | }; | ||
396 | |||
397 | static int as3722_ldo3_set_tracking_mode(struct as3722_regulators *as3722_reg, | ||
398 | int id, u8 mode) | ||
399 | { | ||
400 | struct as3722 *as3722 = as3722_reg->as3722; | ||
401 | |||
402 | switch (mode) { | ||
403 | case AS3722_LDO3_MODE_PMOS: | ||
404 | case AS3722_LDO3_MODE_PMOS_TRACKING: | ||
405 | case AS3722_LDO3_MODE_NMOS: | ||
406 | case AS3722_LDO3_MODE_SWITCH: | ||
407 | return as3722_update_bits(as3722, | ||
408 | as3722_reg_lookup[id].vsel_reg, | ||
409 | AS3722_LDO3_MODE_MASK, mode); | ||
410 | |||
411 | default: | ||
412 | return -EINVAL; | ||
413 | } | ||
414 | } | ||
415 | |||
416 | static int as3722_ldo3_get_current_limit(struct regulator_dev *rdev) | ||
417 | { | ||
418 | return 150000; | ||
419 | } | ||
420 | |||
421 | static struct regulator_ops as3722_ldo3_ops = { | ||
422 | .is_enabled = regulator_is_enabled_regmap, | ||
423 | .enable = regulator_enable_regmap, | ||
424 | .disable = regulator_disable_regmap, | ||
425 | .list_voltage = regulator_list_voltage_linear, | ||
426 | .get_voltage_sel = regulator_get_voltage_sel_regmap, | ||
427 | .set_voltage_sel = regulator_set_voltage_sel_regmap, | ||
428 | .get_current_limit = as3722_ldo3_get_current_limit, | ||
429 | }; | ||
430 | |||
431 | static struct regulator_ops as3722_ldo3_extcntrl_ops = { | ||
432 | .list_voltage = regulator_list_voltage_linear, | ||
433 | .get_voltage_sel = regulator_get_voltage_sel_regmap, | ||
434 | .set_voltage_sel = regulator_set_voltage_sel_regmap, | ||
435 | .get_current_limit = as3722_ldo3_get_current_limit, | ||
436 | }; | ||
437 | |||
438 | static const struct regulator_linear_range as3722_ldo_ranges[] = { | ||
439 | REGULATOR_LINEAR_RANGE(825000, 0x01, 0x24, 25000), | ||
440 | REGULATOR_LINEAR_RANGE(1725000, 0x40, 0x7F, 25000), | ||
441 | }; | ||
442 | |||
443 | static struct regulator_ops as3722_ldo_ops = { | ||
444 | .is_enabled = regulator_is_enabled_regmap, | ||
445 | .enable = regulator_enable_regmap, | ||
446 | .disable = regulator_disable_regmap, | ||
447 | .map_voltage = regulator_map_voltage_linear_range, | ||
448 | .set_voltage_sel = regulator_set_voltage_sel_regmap, | ||
449 | .get_voltage_sel = regulator_get_voltage_sel_regmap, | ||
450 | .list_voltage = regulator_list_voltage_linear_range, | ||
451 | .get_current_limit = as3722_ldo_get_current_limit, | ||
452 | .set_current_limit = as3722_ldo_set_current_limit, | ||
453 | }; | ||
454 | |||
455 | static struct regulator_ops as3722_ldo_extcntrl_ops = { | ||
456 | .map_voltage = regulator_map_voltage_linear_range, | ||
457 | .set_voltage_sel = regulator_set_voltage_sel_regmap, | ||
458 | .get_voltage_sel = regulator_get_voltage_sel_regmap, | ||
459 | .list_voltage = regulator_list_voltage_linear_range, | ||
460 | .get_current_limit = as3722_ldo_get_current_limit, | ||
461 | .set_current_limit = as3722_ldo_set_current_limit, | ||
462 | }; | ||
463 | |||
464 | static unsigned int as3722_sd_get_mode(struct regulator_dev *rdev) | ||
465 | { | ||
466 | struct as3722_regulators *as3722_regs = rdev_get_drvdata(rdev); | ||
467 | struct as3722 *as3722 = as3722_regs->as3722; | ||
468 | int id = rdev_get_id(rdev); | ||
469 | u32 val; | ||
470 | int ret; | ||
471 | |||
472 | if (!as3722_reg_lookup[id].control_reg) | ||
473 | return -ENOTSUPP; | ||
474 | |||
475 | ret = as3722_read(as3722, as3722_reg_lookup[id].control_reg, &val); | ||
476 | if (ret < 0) { | ||
477 | dev_err(as3722_regs->dev, "Reg 0x%02x read failed: %d\n", | ||
478 | as3722_reg_lookup[id].control_reg, ret); | ||
479 | return ret; | ||
480 | } | ||
481 | |||
482 | if (val & as3722_reg_lookup[id].mode_mask) | ||
483 | return REGULATOR_MODE_FAST; | ||
484 | else | ||
485 | return REGULATOR_MODE_NORMAL; | ||
486 | } | ||
487 | |||
488 | static int as3722_sd_set_mode(struct regulator_dev *rdev, | ||
489 | unsigned int mode) | ||
490 | { | ||
491 | struct as3722_regulators *as3722_regs = rdev_get_drvdata(rdev); | ||
492 | struct as3722 *as3722 = as3722_regs->as3722; | ||
493 | u8 id = rdev_get_id(rdev); | ||
494 | u8 val = 0; | ||
495 | int ret; | ||
496 | |||
497 | if (!as3722_reg_lookup[id].control_reg) | ||
498 | return -ERANGE; | ||
499 | |||
500 | switch (mode) { | ||
501 | case REGULATOR_MODE_FAST: | ||
502 | val = as3722_reg_lookup[id].mode_mask; | ||
503 | case REGULATOR_MODE_NORMAL: /* fall down */ | ||
504 | break; | ||
505 | default: | ||
506 | return -EINVAL; | ||
507 | } | ||
508 | |||
509 | ret = as3722_update_bits(as3722, as3722_reg_lookup[id].control_reg, | ||
510 | as3722_reg_lookup[id].mode_mask, val); | ||
511 | if (ret < 0) { | ||
512 | dev_err(as3722_regs->dev, "Reg 0x%02x update failed: %d\n", | ||
513 | as3722_reg_lookup[id].control_reg, ret); | ||
514 | return ret; | ||
515 | } | ||
516 | return ret; | ||
517 | } | ||
518 | |||
519 | static int as3722_sd016_get_current_limit(struct regulator_dev *rdev) | ||
520 | { | ||
521 | struct as3722_regulators *as3722_regs = rdev_get_drvdata(rdev); | ||
522 | struct as3722 *as3722 = as3722_regs->as3722; | ||
523 | int id = rdev_get_id(rdev); | ||
524 | u32 val, reg; | ||
525 | int mask; | ||
526 | int ret; | ||
527 | |||
528 | switch (id) { | ||
529 | case AS3722_REGULATOR_ID_SD0: | ||
530 | reg = AS3722_OVCURRENT_REG; | ||
531 | mask = AS3722_OVCURRENT_SD0_TRIP_MASK; | ||
532 | break; | ||
533 | case AS3722_REGULATOR_ID_SD1: | ||
534 | reg = AS3722_OVCURRENT_REG; | ||
535 | mask = AS3722_OVCURRENT_SD1_TRIP_MASK; | ||
536 | break; | ||
537 | case AS3722_REGULATOR_ID_SD6: | ||
538 | reg = AS3722_OVCURRENT_DEB_REG; | ||
539 | mask = AS3722_OVCURRENT_SD6_TRIP_MASK; | ||
540 | break; | ||
541 | default: | ||
542 | return -EINVAL; | ||
543 | } | ||
544 | ret = as3722_read(as3722, reg, &val); | ||
545 | if (ret < 0) { | ||
546 | dev_err(as3722_regs->dev, "Reg 0x%02x read failed: %d\n", | ||
547 | reg, ret); | ||
548 | return ret; | ||
549 | } | ||
550 | val &= mask; | ||
551 | val >>= ffs(mask) - 1; | ||
552 | if (val == 3) | ||
553 | return -EINVAL; | ||
554 | return as3722_sd016_current[val]; | ||
555 | } | ||
556 | |||
557 | static int as3722_sd016_set_current_limit(struct regulator_dev *rdev, | ||
558 | int min_uA, int max_uA) | ||
559 | { | ||
560 | struct as3722_regulators *as3722_regs = rdev_get_drvdata(rdev); | ||
561 | struct as3722 *as3722 = as3722_regs->as3722; | ||
562 | int id = rdev_get_id(rdev); | ||
563 | int ret; | ||
564 | int val; | ||
565 | int mask; | ||
566 | u32 reg; | ||
567 | |||
568 | ret = as3722_current_to_index(min_uA, max_uA, as3722_sd016_current, | ||
569 | ARRAY_SIZE(as3722_sd016_current)); | ||
570 | if (ret < 0) { | ||
571 | dev_err(as3722_regs->dev, | ||
572 | "Current range min:max = %d:%d does not support\n", | ||
573 | min_uA, max_uA); | ||
574 | return ret; | ||
575 | } | ||
576 | |||
577 | switch (id) { | ||
578 | case AS3722_REGULATOR_ID_SD0: | ||
579 | reg = AS3722_OVCURRENT_REG; | ||
580 | mask = AS3722_OVCURRENT_SD0_TRIP_MASK; | ||
581 | break; | ||
582 | case AS3722_REGULATOR_ID_SD1: | ||
583 | reg = AS3722_OVCURRENT_REG; | ||
584 | mask = AS3722_OVCURRENT_SD1_TRIP_MASK; | ||
585 | break; | ||
586 | case AS3722_REGULATOR_ID_SD6: | ||
587 | reg = AS3722_OVCURRENT_DEB_REG; | ||
588 | mask = AS3722_OVCURRENT_SD6_TRIP_MASK; | ||
589 | break; | ||
590 | default: | ||
591 | return -EINVAL; | ||
592 | } | ||
593 | val = ret & mask; | ||
594 | val <<= ffs(mask) - 1; | ||
595 | return as3722_update_bits(as3722, reg, mask, val); | ||
596 | } | ||
597 | |||
598 | static const struct regulator_linear_range as3722_sd2345_ranges[] = { | ||
599 | REGULATOR_LINEAR_RANGE(612500, 0x01, 0x40, 12500), | ||
600 | REGULATOR_LINEAR_RANGE(1425000, 0x41, 0x70, 25000), | ||
601 | REGULATOR_LINEAR_RANGE(2650000, 0x71, 0x7F, 50000), | ||
602 | }; | ||
603 | |||
604 | static struct regulator_ops as3722_sd016_ops = { | ||
605 | .is_enabled = regulator_is_enabled_regmap, | ||
606 | .enable = regulator_enable_regmap, | ||
607 | .disable = regulator_disable_regmap, | ||
608 | .list_voltage = regulator_list_voltage_linear, | ||
609 | .map_voltage = regulator_map_voltage_linear, | ||
610 | .get_voltage_sel = regulator_get_voltage_sel_regmap, | ||
611 | .set_voltage_sel = regulator_set_voltage_sel_regmap, | ||
612 | .get_current_limit = as3722_sd016_get_current_limit, | ||
613 | .set_current_limit = as3722_sd016_set_current_limit, | ||
614 | .get_mode = as3722_sd_get_mode, | ||
615 | .set_mode = as3722_sd_set_mode, | ||
616 | }; | ||
617 | |||
618 | static struct regulator_ops as3722_sd016_extcntrl_ops = { | ||
619 | .list_voltage = regulator_list_voltage_linear, | ||
620 | .map_voltage = regulator_map_voltage_linear, | ||
621 | .get_voltage_sel = regulator_get_voltage_sel_regmap, | ||
622 | .set_voltage_sel = regulator_set_voltage_sel_regmap, | ||
623 | .get_current_limit = as3722_sd016_get_current_limit, | ||
624 | .set_current_limit = as3722_sd016_set_current_limit, | ||
625 | .get_mode = as3722_sd_get_mode, | ||
626 | .set_mode = as3722_sd_set_mode, | ||
627 | }; | ||
628 | |||
629 | static struct regulator_ops as3722_sd2345_ops = { | ||
630 | .is_enabled = regulator_is_enabled_regmap, | ||
631 | .enable = regulator_enable_regmap, | ||
632 | .disable = regulator_disable_regmap, | ||
633 | .list_voltage = regulator_list_voltage_linear_range, | ||
634 | .map_voltage = regulator_map_voltage_linear_range, | ||
635 | .set_voltage_sel = regulator_set_voltage_sel_regmap, | ||
636 | .get_voltage_sel = regulator_get_voltage_sel_regmap, | ||
637 | .get_mode = as3722_sd_get_mode, | ||
638 | .set_mode = as3722_sd_set_mode, | ||
639 | }; | ||
640 | |||
641 | static struct regulator_ops as3722_sd2345_extcntrl_ops = { | ||
642 | .list_voltage = regulator_list_voltage_linear_range, | ||
643 | .map_voltage = regulator_map_voltage_linear_range, | ||
644 | .set_voltage_sel = regulator_set_voltage_sel_regmap, | ||
645 | .get_voltage_sel = regulator_get_voltage_sel_regmap, | ||
646 | .get_mode = as3722_sd_get_mode, | ||
647 | .set_mode = as3722_sd_set_mode, | ||
648 | }; | ||
649 | |||
650 | static int as3722_extreg_init(struct as3722_regulators *as3722_regs, int id, | ||
651 | int ext_pwr_ctrl) | ||
652 | { | ||
653 | int ret; | ||
654 | unsigned int val; | ||
655 | |||
656 | if ((ext_pwr_ctrl < AS3722_EXT_CONTROL_ENABLE1) || | ||
657 | (ext_pwr_ctrl > AS3722_EXT_CONTROL_ENABLE3)) | ||
658 | return -EINVAL; | ||
659 | |||
660 | val = ext_pwr_ctrl << (ffs(as3722_reg_lookup[id].sleep_ctrl_mask) - 1); | ||
661 | ret = as3722_update_bits(as3722_regs->as3722, | ||
662 | as3722_reg_lookup[id].sleep_ctrl_reg, | ||
663 | as3722_reg_lookup[id].sleep_ctrl_mask, val); | ||
664 | if (ret < 0) | ||
665 | dev_err(as3722_regs->dev, "Reg 0x%02x update failed: %d\n", | ||
666 | as3722_reg_lookup[id].sleep_ctrl_reg, ret); | ||
667 | return ret; | ||
668 | } | ||
669 | |||
670 | static struct of_regulator_match as3722_regulator_matches[] = { | ||
671 | { .name = "sd0", }, | ||
672 | { .name = "sd1", }, | ||
673 | { .name = "sd2", }, | ||
674 | { .name = "sd3", }, | ||
675 | { .name = "sd4", }, | ||
676 | { .name = "sd5", }, | ||
677 | { .name = "sd6", }, | ||
678 | { .name = "ldo0", }, | ||
679 | { .name = "ldo1", }, | ||
680 | { .name = "ldo2", }, | ||
681 | { .name = "ldo3", }, | ||
682 | { .name = "ldo4", }, | ||
683 | { .name = "ldo5", }, | ||
684 | { .name = "ldo6", }, | ||
685 | { .name = "ldo7", }, | ||
686 | { .name = "ldo9", }, | ||
687 | { .name = "ldo10", }, | ||
688 | { .name = "ldo11", }, | ||
689 | }; | ||
690 | |||
691 | static int as3722_get_regulator_dt_data(struct platform_device *pdev, | ||
692 | struct as3722_regulators *as3722_regs) | ||
693 | { | ||
694 | struct device_node *np; | ||
695 | struct as3722_regulator_config_data *reg_config; | ||
696 | u32 prop; | ||
697 | int id; | ||
698 | int ret; | ||
699 | |||
700 | np = of_get_child_by_name(pdev->dev.parent->of_node, "regulators"); | ||
701 | if (!np) { | ||
702 | dev_err(&pdev->dev, "Device is not having regulators node\n"); | ||
703 | return -ENODEV; | ||
704 | } | ||
705 | pdev->dev.of_node = np; | ||
706 | |||
707 | ret = of_regulator_match(&pdev->dev, np, as3722_regulator_matches, | ||
708 | ARRAY_SIZE(as3722_regulator_matches)); | ||
709 | if (ret < 0) { | ||
710 | dev_err(&pdev->dev, "Parsing of regulator node failed: %d\n", | ||
711 | ret); | ||
712 | return ret; | ||
713 | } | ||
714 | |||
715 | for (id = 0; id < ARRAY_SIZE(as3722_regulator_matches); ++id) { | ||
716 | struct device_node *reg_node; | ||
717 | |||
718 | reg_config = &as3722_regs->reg_config_data[id]; | ||
719 | reg_config->reg_init = as3722_regulator_matches[id].init_data; | ||
720 | reg_node = as3722_regulator_matches[id].of_node; | ||
721 | |||
722 | if (!reg_config->reg_init || !reg_node) | ||
723 | continue; | ||
724 | |||
725 | ret = of_property_read_u32(reg_node, "ams,ext-control", &prop); | ||
726 | if (!ret) { | ||
727 | if (prop < 3) | ||
728 | reg_config->ext_control = prop; | ||
729 | else | ||
730 | dev_warn(&pdev->dev, | ||
731 | "ext-control have invalid option: %u\n", | ||
732 | prop); | ||
733 | } | ||
734 | reg_config->enable_tracking = | ||
735 | of_property_read_bool(reg_node, "ams,enable-tracking"); | ||
736 | } | ||
737 | return 0; | ||
738 | } | ||
739 | |||
740 | static int as3722_regulator_probe(struct platform_device *pdev) | ||
741 | { | ||
742 | struct as3722 *as3722 = dev_get_drvdata(pdev->dev.parent); | ||
743 | struct as3722_regulators *as3722_regs; | ||
744 | struct as3722_regulator_config_data *reg_config; | ||
745 | struct regulator_dev *rdev; | ||
746 | struct regulator_config config = { }; | ||
747 | struct regulator_ops *ops; | ||
748 | int id; | ||
749 | int ret; | ||
750 | |||
751 | as3722_regs = devm_kzalloc(&pdev->dev, sizeof(*as3722_regs), | ||
752 | GFP_KERNEL); | ||
753 | if (!as3722_regs) | ||
754 | return -ENOMEM; | ||
755 | |||
756 | as3722_regs->dev = &pdev->dev; | ||
757 | as3722_regs->as3722 = as3722; | ||
758 | platform_set_drvdata(pdev, as3722_regs); | ||
759 | |||
760 | ret = as3722_get_regulator_dt_data(pdev, as3722_regs); | ||
761 | if (ret < 0) | ||
762 | return ret; | ||
763 | |||
764 | config.dev = &pdev->dev; | ||
765 | config.driver_data = as3722_regs; | ||
766 | config.regmap = as3722->regmap; | ||
767 | |||
768 | for (id = 0; id < AS3722_REGULATOR_ID_MAX; id++) { | ||
769 | reg_config = &as3722_regs->reg_config_data[id]; | ||
770 | |||
771 | as3722_regs->desc[id].name = as3722_reg_lookup[id].name; | ||
772 | as3722_regs->desc[id].supply_name = as3722_reg_lookup[id].sname; | ||
773 | as3722_regs->desc[id].id = as3722_reg_lookup[id].regulator_id; | ||
774 | as3722_regs->desc[id].n_voltages = | ||
775 | as3722_reg_lookup[id].n_voltages; | ||
776 | as3722_regs->desc[id].type = REGULATOR_VOLTAGE; | ||
777 | as3722_regs->desc[id].owner = THIS_MODULE; | ||
778 | as3722_regs->desc[id].enable_reg = | ||
779 | as3722_reg_lookup[id].enable_reg; | ||
780 | as3722_regs->desc[id].enable_mask = | ||
781 | as3722_reg_lookup[id].enable_mask; | ||
782 | as3722_regs->desc[id].vsel_reg = as3722_reg_lookup[id].vsel_reg; | ||
783 | as3722_regs->desc[id].vsel_mask = | ||
784 | as3722_reg_lookup[id].vsel_mask; | ||
785 | switch (id) { | ||
786 | case AS3722_REGULATOR_ID_LDO0: | ||
787 | if (reg_config->ext_control) | ||
788 | ops = &as3722_ldo0_extcntrl_ops; | ||
789 | else | ||
790 | ops = &as3722_ldo0_ops; | ||
791 | as3722_regs->desc[id].min_uV = 825000; | ||
792 | as3722_regs->desc[id].uV_step = 25000; | ||
793 | as3722_regs->desc[id].linear_min_sel = 1; | ||
794 | as3722_regs->desc[id].enable_time = 500; | ||
795 | break; | ||
796 | case AS3722_REGULATOR_ID_LDO3: | ||
797 | if (reg_config->ext_control) | ||
798 | ops = &as3722_ldo3_extcntrl_ops; | ||
799 | else | ||
800 | ops = &as3722_ldo3_ops; | ||
801 | as3722_regs->desc[id].min_uV = 620000; | ||
802 | as3722_regs->desc[id].uV_step = 20000; | ||
803 | as3722_regs->desc[id].linear_min_sel = 1; | ||
804 | as3722_regs->desc[id].enable_time = 500; | ||
805 | if (reg_config->enable_tracking) { | ||
806 | ret = as3722_ldo3_set_tracking_mode(as3722_regs, | ||
807 | id, AS3722_LDO3_MODE_PMOS_TRACKING); | ||
808 | if (ret < 0) { | ||
809 | dev_err(&pdev->dev, | ||
810 | "LDO3 tracking failed: %d\n", | ||
811 | ret); | ||
812 | return ret; | ||
813 | } | ||
814 | } | ||
815 | break; | ||
816 | case AS3722_REGULATOR_ID_SD0: | ||
817 | case AS3722_REGULATOR_ID_SD1: | ||
818 | case AS3722_REGULATOR_ID_SD6: | ||
819 | if (reg_config->ext_control) | ||
820 | ops = &as3722_sd016_extcntrl_ops; | ||
821 | else | ||
822 | ops = &as3722_sd016_ops; | ||
823 | as3722_regs->desc[id].min_uV = 610000; | ||
824 | as3722_regs->desc[id].uV_step = 10000; | ||
825 | as3722_regs->desc[id].linear_min_sel = 1; | ||
826 | break; | ||
827 | case AS3722_REGULATOR_ID_SD2: | ||
828 | case AS3722_REGULATOR_ID_SD3: | ||
829 | case AS3722_REGULATOR_ID_SD4: | ||
830 | case AS3722_REGULATOR_ID_SD5: | ||
831 | if (reg_config->ext_control) | ||
832 | ops = &as3722_sd2345_extcntrl_ops; | ||
833 | else | ||
834 | ops = &as3722_sd2345_ops; | ||
835 | as3722_regs->desc[id].linear_ranges = | ||
836 | as3722_sd2345_ranges; | ||
837 | as3722_regs->desc[id].n_linear_ranges = | ||
838 | ARRAY_SIZE(as3722_sd2345_ranges); | ||
839 | break; | ||
840 | default: | ||
841 | if (reg_config->ext_control) | ||
842 | ops = &as3722_ldo_extcntrl_ops; | ||
843 | else | ||
844 | ops = &as3722_ldo_ops; | ||
845 | as3722_regs->desc[id].min_uV = 825000; | ||
846 | as3722_regs->desc[id].uV_step = 25000; | ||
847 | as3722_regs->desc[id].linear_min_sel = 1; | ||
848 | as3722_regs->desc[id].enable_time = 500; | ||
849 | as3722_regs->desc[id].linear_ranges = as3722_ldo_ranges; | ||
850 | as3722_regs->desc[id].n_linear_ranges = | ||
851 | ARRAY_SIZE(as3722_ldo_ranges); | ||
852 | break; | ||
853 | } | ||
854 | as3722_regs->desc[id].ops = ops; | ||
855 | config.init_data = reg_config->reg_init; | ||
856 | config.of_node = as3722_regulator_matches[id].of_node; | ||
857 | rdev = devm_regulator_register(&pdev->dev, | ||
858 | &as3722_regs->desc[id], &config); | ||
859 | if (IS_ERR(rdev)) { | ||
860 | ret = PTR_ERR(rdev); | ||
861 | dev_err(&pdev->dev, "regulator %d register failed %d\n", | ||
862 | id, ret); | ||
863 | return ret; | ||
864 | } | ||
865 | |||
866 | as3722_regs->rdevs[id] = rdev; | ||
867 | if (reg_config->ext_control) { | ||
868 | ret = regulator_enable_regmap(rdev); | ||
869 | if (ret < 0) { | ||
870 | dev_err(&pdev->dev, | ||
871 | "Regulator %d enable failed: %d\n", | ||
872 | id, ret); | ||
873 | return ret; | ||
874 | } | ||
875 | ret = as3722_extreg_init(as3722_regs, id, | ||
876 | reg_config->ext_control); | ||
877 | if (ret < 0) { | ||
878 | dev_err(&pdev->dev, | ||
879 | "AS3722 ext control failed: %d", ret); | ||
880 | return ret; | ||
881 | } | ||
882 | } | ||
883 | } | ||
884 | return 0; | ||
885 | } | ||
886 | |||
887 | static const struct of_device_id of_as3722_regulator_match[] = { | ||
888 | { .compatible = "ams,as3722-regulator", }, | ||
889 | {}, | ||
890 | }; | ||
891 | MODULE_DEVICE_TABLE(of, of_as3722_regulator_match); | ||
892 | |||
893 | static struct platform_driver as3722_regulator_driver = { | ||
894 | .driver = { | ||
895 | .name = "as3722-regulator", | ||
896 | .owner = THIS_MODULE, | ||
897 | .of_match_table = of_as3722_regulator_match, | ||
898 | }, | ||
899 | .probe = as3722_regulator_probe, | ||
900 | }; | ||
901 | |||
902 | module_platform_driver(as3722_regulator_driver); | ||
903 | |||
904 | MODULE_ALIAS("platform:as3722-regulator"); | ||
905 | MODULE_DESCRIPTION("AS3722 regulator driver"); | ||
906 | MODULE_AUTHOR("Florian Lobmaier <florian.lobmaier@ams.com>"); | ||
907 | MODULE_AUTHOR("Laxman Dewangan <ldewangan@nvidia.com>"); | ||
908 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index a01b8b3b70ca..6382f0af353b 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c | |||
@@ -36,6 +36,7 @@ | |||
36 | #include <trace/events/regulator.h> | 36 | #include <trace/events/regulator.h> |
37 | 37 | ||
38 | #include "dummy.h" | 38 | #include "dummy.h" |
39 | #include "internal.h" | ||
39 | 40 | ||
40 | #define rdev_crit(rdev, fmt, ...) \ | 41 | #define rdev_crit(rdev, fmt, ...) \ |
41 | pr_crit("%s: " fmt, rdev_get_name(rdev), ##__VA_ARGS__) | 42 | pr_crit("%s: " fmt, rdev_get_name(rdev), ##__VA_ARGS__) |
@@ -52,8 +53,8 @@ static DEFINE_MUTEX(regulator_list_mutex); | |||
52 | static LIST_HEAD(regulator_list); | 53 | static LIST_HEAD(regulator_list); |
53 | static LIST_HEAD(regulator_map_list); | 54 | static LIST_HEAD(regulator_map_list); |
54 | static LIST_HEAD(regulator_ena_gpio_list); | 55 | static LIST_HEAD(regulator_ena_gpio_list); |
56 | static LIST_HEAD(regulator_supply_alias_list); | ||
55 | static bool has_full_constraints; | 57 | static bool has_full_constraints; |
56 | static bool board_wants_dummy_regulator; | ||
57 | 58 | ||
58 | static struct dentry *debugfs_root; | 59 | static struct dentry *debugfs_root; |
59 | 60 | ||
@@ -83,22 +84,16 @@ struct regulator_enable_gpio { | |||
83 | }; | 84 | }; |
84 | 85 | ||
85 | /* | 86 | /* |
86 | * struct regulator | 87 | * struct regulator_supply_alias |
87 | * | 88 | * |
88 | * One for each consumer device. | 89 | * Used to map lookups for a supply onto an alternative device. |
89 | */ | 90 | */ |
90 | struct regulator { | 91 | struct regulator_supply_alias { |
91 | struct device *dev; | ||
92 | struct list_head list; | 92 | struct list_head list; |
93 | unsigned int always_on:1; | 93 | struct device *src_dev; |
94 | unsigned int bypass:1; | 94 | const char *src_supply; |
95 | int uA_load; | 95 | struct device *alias_dev; |
96 | int min_uV; | 96 | const char *alias_supply; |
97 | int max_uV; | ||
98 | char *supply_name; | ||
99 | struct device_attribute dev_attr; | ||
100 | struct regulator_dev *rdev; | ||
101 | struct dentry *debugfs; | ||
102 | }; | 97 | }; |
103 | 98 | ||
104 | static int _regulator_is_enabled(struct regulator_dev *rdev); | 99 | static int _regulator_is_enabled(struct regulator_dev *rdev); |
@@ -923,6 +918,36 @@ static int machine_constraints_voltage(struct regulator_dev *rdev, | |||
923 | return 0; | 918 | return 0; |
924 | } | 919 | } |
925 | 920 | ||
921 | static int machine_constraints_current(struct regulator_dev *rdev, | ||
922 | struct regulation_constraints *constraints) | ||
923 | { | ||
924 | struct regulator_ops *ops = rdev->desc->ops; | ||
925 | int ret; | ||
926 | |||
927 | if (!constraints->min_uA && !constraints->max_uA) | ||
928 | return 0; | ||
929 | |||
930 | if (constraints->min_uA > constraints->max_uA) { | ||
931 | rdev_err(rdev, "Invalid current constraints\n"); | ||
932 | return -EINVAL; | ||
933 | } | ||
934 | |||
935 | if (!ops->set_current_limit || !ops->get_current_limit) { | ||
936 | rdev_warn(rdev, "Operation of current configuration missing\n"); | ||
937 | return 0; | ||
938 | } | ||
939 | |||
940 | /* Set regulator current in constraints range */ | ||
941 | ret = ops->set_current_limit(rdev, constraints->min_uA, | ||
942 | constraints->max_uA); | ||
943 | if (ret < 0) { | ||
944 | rdev_err(rdev, "Failed to set current constraint, %d\n", ret); | ||
945 | return ret; | ||
946 | } | ||
947 | |||
948 | return 0; | ||
949 | } | ||
950 | |||
926 | /** | 951 | /** |
927 | * set_machine_constraints - sets regulator constraints | 952 | * set_machine_constraints - sets regulator constraints |
928 | * @rdev: regulator source | 953 | * @rdev: regulator source |
@@ -953,6 +978,10 @@ static int set_machine_constraints(struct regulator_dev *rdev, | |||
953 | if (ret != 0) | 978 | if (ret != 0) |
954 | goto out; | 979 | goto out; |
955 | 980 | ||
981 | ret = machine_constraints_current(rdev, rdev->constraints); | ||
982 | if (ret != 0) | ||
983 | goto out; | ||
984 | |||
956 | /* do we need to setup our suspend state */ | 985 | /* do we need to setup our suspend state */ |
957 | if (rdev->constraints->initial_state) { | 986 | if (rdev->constraints->initial_state) { |
958 | ret = suspend_prepare(rdev, rdev->constraints->initial_state); | 987 | ret = suspend_prepare(rdev, rdev->constraints->initial_state); |
@@ -1186,11 +1215,39 @@ overflow_err: | |||
1186 | 1215 | ||
1187 | static int _regulator_get_enable_time(struct regulator_dev *rdev) | 1216 | static int _regulator_get_enable_time(struct regulator_dev *rdev) |
1188 | { | 1217 | { |
1218 | if (rdev->constraints && rdev->constraints->enable_time) | ||
1219 | return rdev->constraints->enable_time; | ||
1189 | if (!rdev->desc->ops->enable_time) | 1220 | if (!rdev->desc->ops->enable_time) |
1190 | return rdev->desc->enable_time; | 1221 | return rdev->desc->enable_time; |
1191 | return rdev->desc->ops->enable_time(rdev); | 1222 | return rdev->desc->ops->enable_time(rdev); |
1192 | } | 1223 | } |
1193 | 1224 | ||
1225 | static struct regulator_supply_alias *regulator_find_supply_alias( | ||
1226 | struct device *dev, const char *supply) | ||
1227 | { | ||
1228 | struct regulator_supply_alias *map; | ||
1229 | |||
1230 | list_for_each_entry(map, ®ulator_supply_alias_list, list) | ||
1231 | if (map->src_dev == dev && strcmp(map->src_supply, supply) == 0) | ||
1232 | return map; | ||
1233 | |||
1234 | return NULL; | ||
1235 | } | ||
1236 | |||
1237 | static void regulator_supply_alias(struct device **dev, const char **supply) | ||
1238 | { | ||
1239 | struct regulator_supply_alias *map; | ||
1240 | |||
1241 | map = regulator_find_supply_alias(*dev, *supply); | ||
1242 | if (map) { | ||
1243 | dev_dbg(*dev, "Mapping supply %s to %s,%s\n", | ||
1244 | *supply, map->alias_supply, | ||
1245 | dev_name(map->alias_dev)); | ||
1246 | *dev = map->alias_dev; | ||
1247 | *supply = map->alias_supply; | ||
1248 | } | ||
1249 | } | ||
1250 | |||
1194 | static struct regulator_dev *regulator_dev_lookup(struct device *dev, | 1251 | static struct regulator_dev *regulator_dev_lookup(struct device *dev, |
1195 | const char *supply, | 1252 | const char *supply, |
1196 | int *ret) | 1253 | int *ret) |
@@ -1200,6 +1257,8 @@ static struct regulator_dev *regulator_dev_lookup(struct device *dev, | |||
1200 | struct regulator_map *map; | 1257 | struct regulator_map *map; |
1201 | const char *devname = NULL; | 1258 | const char *devname = NULL; |
1202 | 1259 | ||
1260 | regulator_supply_alias(&dev, &supply); | ||
1261 | |||
1203 | /* first do a dt based lookup */ | 1262 | /* first do a dt based lookup */ |
1204 | if (dev && dev->of_node) { | 1263 | if (dev && dev->of_node) { |
1205 | node = of_get_regulator(dev, supply); | 1264 | node = of_get_regulator(dev, supply); |
@@ -1243,16 +1302,16 @@ static struct regulator_dev *regulator_dev_lookup(struct device *dev, | |||
1243 | 1302 | ||
1244 | /* Internal regulator request function */ | 1303 | /* Internal regulator request function */ |
1245 | static struct regulator *_regulator_get(struct device *dev, const char *id, | 1304 | static struct regulator *_regulator_get(struct device *dev, const char *id, |
1246 | bool exclusive) | 1305 | bool exclusive, bool allow_dummy) |
1247 | { | 1306 | { |
1248 | struct regulator_dev *rdev; | 1307 | struct regulator_dev *rdev; |
1249 | struct regulator *regulator = ERR_PTR(-EPROBE_DEFER); | 1308 | struct regulator *regulator = ERR_PTR(-EPROBE_DEFER); |
1250 | const char *devname = NULL; | 1309 | const char *devname = NULL; |
1251 | int ret = 0; | 1310 | int ret = -EPROBE_DEFER; |
1252 | 1311 | ||
1253 | if (id == NULL) { | 1312 | if (id == NULL) { |
1254 | pr_err("get() with no identifier\n"); | 1313 | pr_err("get() with no identifier\n"); |
1255 | return regulator; | 1314 | return ERR_PTR(-EINVAL); |
1256 | } | 1315 | } |
1257 | 1316 | ||
1258 | if (dev) | 1317 | if (dev) |
@@ -1264,34 +1323,32 @@ static struct regulator *_regulator_get(struct device *dev, const char *id, | |||
1264 | if (rdev) | 1323 | if (rdev) |
1265 | goto found; | 1324 | goto found; |
1266 | 1325 | ||
1326 | regulator = ERR_PTR(ret); | ||
1327 | |||
1267 | /* | 1328 | /* |
1268 | * If we have return value from dev_lookup fail, we do not expect to | 1329 | * If we have return value from dev_lookup fail, we do not expect to |
1269 | * succeed, so, quit with appropriate error value | 1330 | * succeed, so, quit with appropriate error value |
1270 | */ | 1331 | */ |
1271 | if (ret) { | 1332 | if (ret && ret != -ENODEV) { |
1272 | regulator = ERR_PTR(ret); | ||
1273 | goto out; | 1333 | goto out; |
1274 | } | 1334 | } |
1275 | 1335 | ||
1276 | if (board_wants_dummy_regulator) { | ||
1277 | rdev = dummy_regulator_rdev; | ||
1278 | goto found; | ||
1279 | } | ||
1280 | |||
1281 | #ifdef CONFIG_REGULATOR_DUMMY | ||
1282 | if (!devname) | 1336 | if (!devname) |
1283 | devname = "deviceless"; | 1337 | devname = "deviceless"; |
1284 | 1338 | ||
1285 | /* If the board didn't flag that it was fully constrained then | 1339 | /* |
1286 | * substitute in a dummy regulator so consumers can continue. | 1340 | * Assume that a regulator is physically present and enabled |
1341 | * even if it isn't hooked up and just provide a dummy. | ||
1287 | */ | 1342 | */ |
1288 | if (!has_full_constraints) { | 1343 | if (has_full_constraints && allow_dummy) { |
1289 | pr_warn("%s supply %s not found, using dummy regulator\n", | 1344 | pr_warn("%s supply %s not found, using dummy regulator\n", |
1290 | devname, id); | 1345 | devname, id); |
1346 | |||
1291 | rdev = dummy_regulator_rdev; | 1347 | rdev = dummy_regulator_rdev; |
1292 | goto found; | 1348 | goto found; |
1349 | } else { | ||
1350 | dev_err(dev, "dummy supplies not allowed\n"); | ||
1293 | } | 1351 | } |
1294 | #endif | ||
1295 | 1352 | ||
1296 | mutex_unlock(®ulator_list_mutex); | 1353 | mutex_unlock(®ulator_list_mutex); |
1297 | return regulator; | 1354 | return regulator; |
@@ -1349,44 +1406,10 @@ out: | |||
1349 | */ | 1406 | */ |
1350 | struct regulator *regulator_get(struct device *dev, const char *id) | 1407 | struct regulator *regulator_get(struct device *dev, const char *id) |
1351 | { | 1408 | { |
1352 | return _regulator_get(dev, id, false); | 1409 | return _regulator_get(dev, id, false, true); |
1353 | } | 1410 | } |
1354 | EXPORT_SYMBOL_GPL(regulator_get); | 1411 | EXPORT_SYMBOL_GPL(regulator_get); |
1355 | 1412 | ||
1356 | static void devm_regulator_release(struct device *dev, void *res) | ||
1357 | { | ||
1358 | regulator_put(*(struct regulator **)res); | ||
1359 | } | ||
1360 | |||
1361 | /** | ||
1362 | * devm_regulator_get - Resource managed regulator_get() | ||
1363 | * @dev: device for regulator "consumer" | ||
1364 | * @id: Supply name or regulator ID. | ||
1365 | * | ||
1366 | * Managed regulator_get(). Regulators returned from this function are | ||
1367 | * automatically regulator_put() on driver detach. See regulator_get() for more | ||
1368 | * information. | ||
1369 | */ | ||
1370 | struct regulator *devm_regulator_get(struct device *dev, const char *id) | ||
1371 | { | ||
1372 | struct regulator **ptr, *regulator; | ||
1373 | |||
1374 | ptr = devres_alloc(devm_regulator_release, sizeof(*ptr), GFP_KERNEL); | ||
1375 | if (!ptr) | ||
1376 | return ERR_PTR(-ENOMEM); | ||
1377 | |||
1378 | regulator = regulator_get(dev, id); | ||
1379 | if (!IS_ERR(regulator)) { | ||
1380 | *ptr = regulator; | ||
1381 | devres_add(dev, ptr); | ||
1382 | } else { | ||
1383 | devres_free(ptr); | ||
1384 | } | ||
1385 | |||
1386 | return regulator; | ||
1387 | } | ||
1388 | EXPORT_SYMBOL_GPL(devm_regulator_get); | ||
1389 | |||
1390 | /** | 1413 | /** |
1391 | * regulator_get_exclusive - obtain exclusive access to a regulator. | 1414 | * regulator_get_exclusive - obtain exclusive access to a regulator. |
1392 | * @dev: device for regulator "consumer" | 1415 | * @dev: device for regulator "consumer" |
@@ -1410,7 +1433,7 @@ EXPORT_SYMBOL_GPL(devm_regulator_get); | |||
1410 | */ | 1433 | */ |
1411 | struct regulator *regulator_get_exclusive(struct device *dev, const char *id) | 1434 | struct regulator *regulator_get_exclusive(struct device *dev, const char *id) |
1412 | { | 1435 | { |
1413 | return _regulator_get(dev, id, true); | 1436 | return _regulator_get(dev, id, true, false); |
1414 | } | 1437 | } |
1415 | EXPORT_SYMBOL_GPL(regulator_get_exclusive); | 1438 | EXPORT_SYMBOL_GPL(regulator_get_exclusive); |
1416 | 1439 | ||
@@ -1439,40 +1462,10 @@ EXPORT_SYMBOL_GPL(regulator_get_exclusive); | |||
1439 | */ | 1462 | */ |
1440 | struct regulator *regulator_get_optional(struct device *dev, const char *id) | 1463 | struct regulator *regulator_get_optional(struct device *dev, const char *id) |
1441 | { | 1464 | { |
1442 | return _regulator_get(dev, id, 0); | 1465 | return _regulator_get(dev, id, false, false); |
1443 | } | 1466 | } |
1444 | EXPORT_SYMBOL_GPL(regulator_get_optional); | 1467 | EXPORT_SYMBOL_GPL(regulator_get_optional); |
1445 | 1468 | ||
1446 | /** | ||
1447 | * devm_regulator_get_optional - Resource managed regulator_get_optional() | ||
1448 | * @dev: device for regulator "consumer" | ||
1449 | * @id: Supply name or regulator ID. | ||
1450 | * | ||
1451 | * Managed regulator_get_optional(). Regulators returned from this | ||
1452 | * function are automatically regulator_put() on driver detach. See | ||
1453 | * regulator_get_optional() for more information. | ||
1454 | */ | ||
1455 | struct regulator *devm_regulator_get_optional(struct device *dev, | ||
1456 | const char *id) | ||
1457 | { | ||
1458 | struct regulator **ptr, *regulator; | ||
1459 | |||
1460 | ptr = devres_alloc(devm_regulator_release, sizeof(*ptr), GFP_KERNEL); | ||
1461 | if (!ptr) | ||
1462 | return ERR_PTR(-ENOMEM); | ||
1463 | |||
1464 | regulator = regulator_get_optional(dev, id); | ||
1465 | if (!IS_ERR(regulator)) { | ||
1466 | *ptr = regulator; | ||
1467 | devres_add(dev, ptr); | ||
1468 | } else { | ||
1469 | devres_free(ptr); | ||
1470 | } | ||
1471 | |||
1472 | return regulator; | ||
1473 | } | ||
1474 | EXPORT_SYMBOL_GPL(devm_regulator_get_optional); | ||
1475 | |||
1476 | /* Locks held by regulator_put() */ | 1469 | /* Locks held by regulator_put() */ |
1477 | static void _regulator_put(struct regulator *regulator) | 1470 | static void _regulator_put(struct regulator *regulator) |
1478 | { | 1471 | { |
@@ -1499,36 +1492,6 @@ static void _regulator_put(struct regulator *regulator) | |||
1499 | } | 1492 | } |
1500 | 1493 | ||
1501 | /** | 1494 | /** |
1502 | * devm_regulator_get_exclusive - Resource managed regulator_get_exclusive() | ||
1503 | * @dev: device for regulator "consumer" | ||
1504 | * @id: Supply name or regulator ID. | ||
1505 | * | ||
1506 | * Managed regulator_get_exclusive(). Regulators returned from this function | ||
1507 | * are automatically regulator_put() on driver detach. See regulator_get() for | ||
1508 | * more information. | ||
1509 | */ | ||
1510 | struct regulator *devm_regulator_get_exclusive(struct device *dev, | ||
1511 | const char *id) | ||
1512 | { | ||
1513 | struct regulator **ptr, *regulator; | ||
1514 | |||
1515 | ptr = devres_alloc(devm_regulator_release, sizeof(*ptr), GFP_KERNEL); | ||
1516 | if (!ptr) | ||
1517 | return ERR_PTR(-ENOMEM); | ||
1518 | |||
1519 | regulator = _regulator_get(dev, id, 1); | ||
1520 | if (!IS_ERR(regulator)) { | ||
1521 | *ptr = regulator; | ||
1522 | devres_add(dev, ptr); | ||
1523 | } else { | ||
1524 | devres_free(ptr); | ||
1525 | } | ||
1526 | |||
1527 | return regulator; | ||
1528 | } | ||
1529 | EXPORT_SYMBOL_GPL(devm_regulator_get_exclusive); | ||
1530 | |||
1531 | /** | ||
1532 | * regulator_put - "free" the regulator source | 1495 | * regulator_put - "free" the regulator source |
1533 | * @regulator: regulator source | 1496 | * @regulator: regulator source |
1534 | * | 1497 | * |
@@ -1544,34 +1507,133 @@ void regulator_put(struct regulator *regulator) | |||
1544 | } | 1507 | } |
1545 | EXPORT_SYMBOL_GPL(regulator_put); | 1508 | EXPORT_SYMBOL_GPL(regulator_put); |
1546 | 1509 | ||
1547 | static int devm_regulator_match(struct device *dev, void *res, void *data) | 1510 | /** |
1511 | * regulator_register_supply_alias - Provide device alias for supply lookup | ||
1512 | * | ||
1513 | * @dev: device that will be given as the regulator "consumer" | ||
1514 | * @id: Supply name or regulator ID | ||
1515 | * @alias_dev: device that should be used to lookup the supply | ||
1516 | * @alias_id: Supply name or regulator ID that should be used to lookup the | ||
1517 | * supply | ||
1518 | * | ||
1519 | * All lookups for id on dev will instead be conducted for alias_id on | ||
1520 | * alias_dev. | ||
1521 | */ | ||
1522 | int regulator_register_supply_alias(struct device *dev, const char *id, | ||
1523 | struct device *alias_dev, | ||
1524 | const char *alias_id) | ||
1525 | { | ||
1526 | struct regulator_supply_alias *map; | ||
1527 | |||
1528 | map = regulator_find_supply_alias(dev, id); | ||
1529 | if (map) | ||
1530 | return -EEXIST; | ||
1531 | |||
1532 | map = kzalloc(sizeof(struct regulator_supply_alias), GFP_KERNEL); | ||
1533 | if (!map) | ||
1534 | return -ENOMEM; | ||
1535 | |||
1536 | map->src_dev = dev; | ||
1537 | map->src_supply = id; | ||
1538 | map->alias_dev = alias_dev; | ||
1539 | map->alias_supply = alias_id; | ||
1540 | |||
1541 | list_add(&map->list, ®ulator_supply_alias_list); | ||
1542 | |||
1543 | pr_info("Adding alias for supply %s,%s -> %s,%s\n", | ||
1544 | id, dev_name(dev), alias_id, dev_name(alias_dev)); | ||
1545 | |||
1546 | return 0; | ||
1547 | } | ||
1548 | EXPORT_SYMBOL_GPL(regulator_register_supply_alias); | ||
1549 | |||
1550 | /** | ||
1551 | * regulator_unregister_supply_alias - Remove device alias | ||
1552 | * | ||
1553 | * @dev: device that will be given as the regulator "consumer" | ||
1554 | * @id: Supply name or regulator ID | ||
1555 | * | ||
1556 | * Remove a lookup alias if one exists for id on dev. | ||
1557 | */ | ||
1558 | void regulator_unregister_supply_alias(struct device *dev, const char *id) | ||
1548 | { | 1559 | { |
1549 | struct regulator **r = res; | 1560 | struct regulator_supply_alias *map; |
1550 | if (!r || !*r) { | 1561 | |
1551 | WARN_ON(!r || !*r); | 1562 | map = regulator_find_supply_alias(dev, id); |
1552 | return 0; | 1563 | if (map) { |
1564 | list_del(&map->list); | ||
1565 | kfree(map); | ||
1553 | } | 1566 | } |
1554 | return *r == data; | ||
1555 | } | 1567 | } |
1568 | EXPORT_SYMBOL_GPL(regulator_unregister_supply_alias); | ||
1556 | 1569 | ||
1557 | /** | 1570 | /** |
1558 | * devm_regulator_put - Resource managed regulator_put() | 1571 | * regulator_bulk_register_supply_alias - register multiple aliases |
1559 | * @regulator: regulator to free | 1572 | * |
1573 | * @dev: device that will be given as the regulator "consumer" | ||
1574 | * @id: List of supply names or regulator IDs | ||
1575 | * @alias_dev: device that should be used to lookup the supply | ||
1576 | * @alias_id: List of supply names or regulator IDs that should be used to | ||
1577 | * lookup the supply | ||
1578 | * @num_id: Number of aliases to register | ||
1579 | * | ||
1580 | * @return 0 on success, an errno on failure. | ||
1560 | * | 1581 | * |
1561 | * Deallocate a regulator allocated with devm_regulator_get(). Normally | 1582 | * This helper function allows drivers to register several supply |
1562 | * this function will not need to be called and the resource management | 1583 | * aliases in one operation. If any of the aliases cannot be |
1563 | * code will ensure that the resource is freed. | 1584 | * registered any aliases that were registered will be removed |
1585 | * before returning to the caller. | ||
1564 | */ | 1586 | */ |
1565 | void devm_regulator_put(struct regulator *regulator) | 1587 | int regulator_bulk_register_supply_alias(struct device *dev, const char **id, |
1588 | struct device *alias_dev, | ||
1589 | const char **alias_id, | ||
1590 | int num_id) | ||
1566 | { | 1591 | { |
1567 | int rc; | 1592 | int i; |
1593 | int ret; | ||
1594 | |||
1595 | for (i = 0; i < num_id; ++i) { | ||
1596 | ret = regulator_register_supply_alias(dev, id[i], alias_dev, | ||
1597 | alias_id[i]); | ||
1598 | if (ret < 0) | ||
1599 | goto err; | ||
1600 | } | ||
1601 | |||
1602 | return 0; | ||
1603 | |||
1604 | err: | ||
1605 | dev_err(dev, | ||
1606 | "Failed to create supply alias %s,%s -> %s,%s\n", | ||
1607 | id[i], dev_name(dev), alias_id[i], dev_name(alias_dev)); | ||
1608 | |||
1609 | while (--i >= 0) | ||
1610 | regulator_unregister_supply_alias(dev, id[i]); | ||
1611 | |||
1612 | return ret; | ||
1613 | } | ||
1614 | EXPORT_SYMBOL_GPL(regulator_bulk_register_supply_alias); | ||
1615 | |||
1616 | /** | ||
1617 | * regulator_bulk_unregister_supply_alias - unregister multiple aliases | ||
1618 | * | ||
1619 | * @dev: device that will be given as the regulator "consumer" | ||
1620 | * @id: List of supply names or regulator IDs | ||
1621 | * @num_id: Number of aliases to unregister | ||
1622 | * | ||
1623 | * This helper function allows drivers to unregister several supply | ||
1624 | * aliases in one operation. | ||
1625 | */ | ||
1626 | void regulator_bulk_unregister_supply_alias(struct device *dev, | ||
1627 | const char **id, | ||
1628 | int num_id) | ||
1629 | { | ||
1630 | int i; | ||
1568 | 1631 | ||
1569 | rc = devres_release(regulator->dev, devm_regulator_release, | 1632 | for (i = 0; i < num_id; ++i) |
1570 | devm_regulator_match, regulator); | 1633 | regulator_unregister_supply_alias(dev, id[i]); |
1571 | if (rc != 0) | ||
1572 | WARN_ON(rc); | ||
1573 | } | 1634 | } |
1574 | EXPORT_SYMBOL_GPL(devm_regulator_put); | 1635 | EXPORT_SYMBOL_GPL(regulator_bulk_unregister_supply_alias); |
1636 | |||
1575 | 1637 | ||
1576 | /* Manage enable GPIO list. Same GPIO pin can be shared among regulators */ | 1638 | /* Manage enable GPIO list. Same GPIO pin can be shared among regulators */ |
1577 | static int regulator_ena_gpio_request(struct regulator_dev *rdev, | 1639 | static int regulator_ena_gpio_request(struct regulator_dev *rdev, |
@@ -1704,11 +1766,39 @@ static int _regulator_do_enable(struct regulator_dev *rdev) | |||
1704 | * together. */ | 1766 | * together. */ |
1705 | trace_regulator_enable_delay(rdev_get_name(rdev)); | 1767 | trace_regulator_enable_delay(rdev_get_name(rdev)); |
1706 | 1768 | ||
1707 | if (delay >= 1000) { | 1769 | /* |
1708 | mdelay(delay / 1000); | 1770 | * Delay for the requested amount of time as per the guidelines in: |
1709 | udelay(delay % 1000); | 1771 | * |
1710 | } else if (delay) { | 1772 | * Documentation/timers/timers-howto.txt |
1711 | udelay(delay); | 1773 | * |
1774 | * The assumption here is that regulators will never be enabled in | ||
1775 | * atomic context and therefore sleeping functions can be used. | ||
1776 | */ | ||
1777 | if (delay) { | ||
1778 | unsigned int ms = delay / 1000; | ||
1779 | unsigned int us = delay % 1000; | ||
1780 | |||
1781 | if (ms > 0) { | ||
1782 | /* | ||
1783 | * For small enough values, handle super-millisecond | ||
1784 | * delays in the usleep_range() call below. | ||
1785 | */ | ||
1786 | if (ms < 20) | ||
1787 | us += ms * 1000; | ||
1788 | else | ||
1789 | msleep(ms); | ||
1790 | } | ||
1791 | |||
1792 | /* | ||
1793 | * Give the scheduler some room to coalesce with any other | ||
1794 | * wakeup sources. For delays shorter than 10 us, don't even | ||
1795 | * bother setting up high-resolution timers and just busy- | ||
1796 | * loop. | ||
1797 | */ | ||
1798 | if (us >= 10) | ||
1799 | usleep_range(us, us + 100); | ||
1800 | else | ||
1801 | udelay(us); | ||
1712 | } | 1802 | } |
1713 | 1803 | ||
1714 | trace_regulator_enable_complete(rdev_get_name(rdev)); | 1804 | trace_regulator_enable_complete(rdev_get_name(rdev)); |
@@ -2489,6 +2579,8 @@ static int _regulator_get_voltage(struct regulator_dev *rdev) | |||
2489 | ret = rdev->desc->ops->get_voltage(rdev); | 2579 | ret = rdev->desc->ops->get_voltage(rdev); |
2490 | } else if (rdev->desc->ops->list_voltage) { | 2580 | } else if (rdev->desc->ops->list_voltage) { |
2491 | ret = rdev->desc->ops->list_voltage(rdev, 0); | 2581 | ret = rdev->desc->ops->list_voltage(rdev, 0); |
2582 | } else if (rdev->desc->fixed_uV && (rdev->desc->n_voltages == 1)) { | ||
2583 | ret = rdev->desc->fixed_uV; | ||
2492 | } else { | 2584 | } else { |
2493 | return -EINVAL; | 2585 | return -EINVAL; |
2494 | } | 2586 | } |
@@ -2912,52 +3004,6 @@ err: | |||
2912 | } | 3004 | } |
2913 | EXPORT_SYMBOL_GPL(regulator_bulk_get); | 3005 | EXPORT_SYMBOL_GPL(regulator_bulk_get); |
2914 | 3006 | ||
2915 | /** | ||
2916 | * devm_regulator_bulk_get - managed get multiple regulator consumers | ||
2917 | * | ||
2918 | * @dev: Device to supply | ||
2919 | * @num_consumers: Number of consumers to register | ||
2920 | * @consumers: Configuration of consumers; clients are stored here. | ||
2921 | * | ||
2922 | * @return 0 on success, an errno on failure. | ||
2923 | * | ||
2924 | * This helper function allows drivers to get several regulator | ||
2925 | * consumers in one operation with management, the regulators will | ||
2926 | * automatically be freed when the device is unbound. If any of the | ||
2927 | * regulators cannot be acquired then any regulators that were | ||
2928 | * allocated will be freed before returning to the caller. | ||
2929 | */ | ||
2930 | int devm_regulator_bulk_get(struct device *dev, int num_consumers, | ||
2931 | struct regulator_bulk_data *consumers) | ||
2932 | { | ||
2933 | int i; | ||
2934 | int ret; | ||
2935 | |||
2936 | for (i = 0; i < num_consumers; i++) | ||
2937 | consumers[i].consumer = NULL; | ||
2938 | |||
2939 | for (i = 0; i < num_consumers; i++) { | ||
2940 | consumers[i].consumer = devm_regulator_get(dev, | ||
2941 | consumers[i].supply); | ||
2942 | if (IS_ERR(consumers[i].consumer)) { | ||
2943 | ret = PTR_ERR(consumers[i].consumer); | ||
2944 | dev_err(dev, "Failed to get supply '%s': %d\n", | ||
2945 | consumers[i].supply, ret); | ||
2946 | consumers[i].consumer = NULL; | ||
2947 | goto err; | ||
2948 | } | ||
2949 | } | ||
2950 | |||
2951 | return 0; | ||
2952 | |||
2953 | err: | ||
2954 | for (i = 0; i < num_consumers && consumers[i].consumer; i++) | ||
2955 | devm_regulator_put(consumers[i].consumer); | ||
2956 | |||
2957 | return ret; | ||
2958 | } | ||
2959 | EXPORT_SYMBOL_GPL(devm_regulator_bulk_get); | ||
2960 | |||
2961 | static void regulator_bulk_enable_async(void *data, async_cookie_t cookie) | 3007 | static void regulator_bulk_enable_async(void *data, async_cookie_t cookie) |
2962 | { | 3008 | { |
2963 | struct regulator_bulk_data *bulk = data; | 3009 | struct regulator_bulk_data *bulk = data; |
@@ -3170,7 +3216,8 @@ static int add_regulator_attributes(struct regulator_dev *rdev) | |||
3170 | /* some attributes need specific methods to be displayed */ | 3216 | /* some attributes need specific methods to be displayed */ |
3171 | if ((ops->get_voltage && ops->get_voltage(rdev) >= 0) || | 3217 | if ((ops->get_voltage && ops->get_voltage(rdev) >= 0) || |
3172 | (ops->get_voltage_sel && ops->get_voltage_sel(rdev) >= 0) || | 3218 | (ops->get_voltage_sel && ops->get_voltage_sel(rdev) >= 0) || |
3173 | (ops->list_voltage && ops->list_voltage(rdev, 0) >= 0)) { | 3219 | (ops->list_voltage && ops->list_voltage(rdev, 0) >= 0) || |
3220 | (rdev->desc->fixed_uV && (rdev->desc->n_voltages == 1))) { | ||
3174 | status = device_create_file(dev, &dev_attr_microvolts); | 3221 | status = device_create_file(dev, &dev_attr_microvolts); |
3175 | if (status < 0) | 3222 | if (status < 0) |
3176 | return status; | 3223 | return status; |
@@ -3614,22 +3661,6 @@ void regulator_has_full_constraints(void) | |||
3614 | EXPORT_SYMBOL_GPL(regulator_has_full_constraints); | 3661 | EXPORT_SYMBOL_GPL(regulator_has_full_constraints); |
3615 | 3662 | ||
3616 | /** | 3663 | /** |
3617 | * regulator_use_dummy_regulator - Provide a dummy regulator when none is found | ||
3618 | * | ||
3619 | * Calling this function will cause the regulator API to provide a | ||
3620 | * dummy regulator to consumers if no physical regulator is found, | ||
3621 | * allowing most consumers to proceed as though a regulator were | ||
3622 | * configured. This allows systems such as those with software | ||
3623 | * controllable regulators for the CPU core only to be brought up more | ||
3624 | * readily. | ||
3625 | */ | ||
3626 | void regulator_use_dummy_regulator(void) | ||
3627 | { | ||
3628 | board_wants_dummy_regulator = true; | ||
3629 | } | ||
3630 | EXPORT_SYMBOL_GPL(regulator_use_dummy_regulator); | ||
3631 | |||
3632 | /** | ||
3633 | * rdev_get_drvdata - get rdev regulator driver data | 3664 | * rdev_get_drvdata - get rdev regulator driver data |
3634 | * @rdev: regulator | 3665 | * @rdev: regulator |
3635 | * | 3666 | * |
diff --git a/drivers/regulator/da903x.c b/drivers/regulator/da903x.c index f06854cf8cf5..b431ae357fcd 100644 --- a/drivers/regulator/da903x.c +++ b/drivers/regulator/da903x.c | |||
@@ -253,10 +253,8 @@ static int da9034_set_dvc_voltage_sel(struct regulator_dev *rdev, | |||
253 | } | 253 | } |
254 | 254 | ||
255 | static const struct regulator_linear_range da9034_ldo12_ranges[] = { | 255 | static const struct regulator_linear_range da9034_ldo12_ranges[] = { |
256 | { .min_uV = 1700000, .max_uV = 2050000, .min_sel = 0, .max_sel = 7, | 256 | REGULATOR_LINEAR_RANGE(1700000, 0, 7, 50000), |
257 | .uV_step = 50000 }, | 257 | REGULATOR_LINEAR_RANGE(2700000, 8, 15, 50000), |
258 | { .min_uV = 2700000, .max_uV = 3050000, .min_sel = 8, .max_sel = 15, | ||
259 | .uV_step = 50000 }, | ||
260 | }; | 258 | }; |
261 | 259 | ||
262 | static struct regulator_ops da903x_regulator_ldo_ops = { | 260 | static struct regulator_ops da903x_regulator_ldo_ops = { |
@@ -463,7 +461,7 @@ static int da903x_regulator_probe(struct platform_device *pdev) | |||
463 | config.init_data = dev_get_platdata(&pdev->dev); | 461 | config.init_data = dev_get_platdata(&pdev->dev); |
464 | config.driver_data = ri; | 462 | config.driver_data = ri; |
465 | 463 | ||
466 | rdev = regulator_register(&ri->desc, &config); | 464 | rdev = devm_regulator_register(&pdev->dev, &ri->desc, &config); |
467 | if (IS_ERR(rdev)) { | 465 | if (IS_ERR(rdev)) { |
468 | dev_err(&pdev->dev, "failed to register regulator %s\n", | 466 | dev_err(&pdev->dev, "failed to register regulator %s\n", |
469 | ri->desc.name); | 467 | ri->desc.name); |
@@ -474,21 +472,12 @@ static int da903x_regulator_probe(struct platform_device *pdev) | |||
474 | return 0; | 472 | return 0; |
475 | } | 473 | } |
476 | 474 | ||
477 | static int da903x_regulator_remove(struct platform_device *pdev) | ||
478 | { | ||
479 | struct regulator_dev *rdev = platform_get_drvdata(pdev); | ||
480 | |||
481 | regulator_unregister(rdev); | ||
482 | return 0; | ||
483 | } | ||
484 | |||
485 | static struct platform_driver da903x_regulator_driver = { | 475 | static struct platform_driver da903x_regulator_driver = { |
486 | .driver = { | 476 | .driver = { |
487 | .name = "da903x-regulator", | 477 | .name = "da903x-regulator", |
488 | .owner = THIS_MODULE, | 478 | .owner = THIS_MODULE, |
489 | }, | 479 | }, |
490 | .probe = da903x_regulator_probe, | 480 | .probe = da903x_regulator_probe, |
491 | .remove = da903x_regulator_remove, | ||
492 | }; | 481 | }; |
493 | 482 | ||
494 | static int __init da903x_regulator_init(void) | 483 | static int __init da903x_regulator_init(void) |
diff --git a/drivers/regulator/da9052-regulator.c b/drivers/regulator/da9052-regulator.c index 1e4d483f6163..3adeaeffc485 100644 --- a/drivers/regulator/da9052-regulator.c +++ b/drivers/regulator/da9052-regulator.c | |||
@@ -70,6 +70,7 @@ struct da9052_regulator_info { | |||
70 | int step_uV; | 70 | int step_uV; |
71 | int min_uV; | 71 | int min_uV; |
72 | int max_uV; | 72 | int max_uV; |
73 | unsigned char activate_bit; | ||
73 | }; | 74 | }; |
74 | 75 | ||
75 | struct da9052_regulator { | 76 | struct da9052_regulator { |
@@ -209,6 +210,36 @@ static int da9052_map_voltage(struct regulator_dev *rdev, | |||
209 | return sel; | 210 | return sel; |
210 | } | 211 | } |
211 | 212 | ||
213 | static int da9052_regulator_set_voltage_sel(struct regulator_dev *rdev, | ||
214 | unsigned int selector) | ||
215 | { | ||
216 | struct da9052_regulator *regulator = rdev_get_drvdata(rdev); | ||
217 | struct da9052_regulator_info *info = regulator->info; | ||
218 | int id = rdev_get_id(rdev); | ||
219 | int ret; | ||
220 | |||
221 | ret = da9052_reg_update(regulator->da9052, rdev->desc->vsel_reg, | ||
222 | rdev->desc->vsel_mask, selector); | ||
223 | if (ret < 0) | ||
224 | return ret; | ||
225 | |||
226 | /* Some LDOs and DCDCs are DVC controlled which requires enabling of | ||
227 | * the activate bit to implment the changes on the output. | ||
228 | */ | ||
229 | switch (id) { | ||
230 | case DA9052_ID_BUCK1: | ||
231 | case DA9052_ID_BUCK2: | ||
232 | case DA9052_ID_BUCK3: | ||
233 | case DA9052_ID_LDO2: | ||
234 | case DA9052_ID_LDO3: | ||
235 | ret = da9052_reg_update(regulator->da9052, DA9052_SUPPLY_REG, | ||
236 | info->activate_bit, info->activate_bit); | ||
237 | break; | ||
238 | } | ||
239 | |||
240 | return ret; | ||
241 | } | ||
242 | |||
212 | static struct regulator_ops da9052_dcdc_ops = { | 243 | static struct regulator_ops da9052_dcdc_ops = { |
213 | .get_current_limit = da9052_dcdc_get_current_limit, | 244 | .get_current_limit = da9052_dcdc_get_current_limit, |
214 | .set_current_limit = da9052_dcdc_set_current_limit, | 245 | .set_current_limit = da9052_dcdc_set_current_limit, |
@@ -216,7 +247,7 @@ static struct regulator_ops da9052_dcdc_ops = { | |||
216 | .list_voltage = da9052_list_voltage, | 247 | .list_voltage = da9052_list_voltage, |
217 | .map_voltage = da9052_map_voltage, | 248 | .map_voltage = da9052_map_voltage, |
218 | .get_voltage_sel = regulator_get_voltage_sel_regmap, | 249 | .get_voltage_sel = regulator_get_voltage_sel_regmap, |
219 | .set_voltage_sel = regulator_set_voltage_sel_regmap, | 250 | .set_voltage_sel = da9052_regulator_set_voltage_sel, |
220 | .is_enabled = regulator_is_enabled_regmap, | 251 | .is_enabled = regulator_is_enabled_regmap, |
221 | .enable = regulator_enable_regmap, | 252 | .enable = regulator_enable_regmap, |
222 | .disable = regulator_disable_regmap, | 253 | .disable = regulator_disable_regmap, |
@@ -226,7 +257,7 @@ static struct regulator_ops da9052_ldo_ops = { | |||
226 | .list_voltage = da9052_list_voltage, | 257 | .list_voltage = da9052_list_voltage, |
227 | .map_voltage = da9052_map_voltage, | 258 | .map_voltage = da9052_map_voltage, |
228 | .get_voltage_sel = regulator_get_voltage_sel_regmap, | 259 | .get_voltage_sel = regulator_get_voltage_sel_regmap, |
229 | .set_voltage_sel = regulator_set_voltage_sel_regmap, | 260 | .set_voltage_sel = da9052_regulator_set_voltage_sel, |
230 | .is_enabled = regulator_is_enabled_regmap, | 261 | .is_enabled = regulator_is_enabled_regmap, |
231 | .enable = regulator_enable_regmap, | 262 | .enable = regulator_enable_regmap, |
232 | .disable = regulator_disable_regmap, | 263 | .disable = regulator_disable_regmap, |
@@ -243,14 +274,13 @@ static struct regulator_ops da9052_ldo_ops = { | |||
243 | .owner = THIS_MODULE,\ | 274 | .owner = THIS_MODULE,\ |
244 | .vsel_reg = DA9052_BUCKCORE_REG + DA9052_ID_##_id, \ | 275 | .vsel_reg = DA9052_BUCKCORE_REG + DA9052_ID_##_id, \ |
245 | .vsel_mask = (1 << (sbits)) - 1,\ | 276 | .vsel_mask = (1 << (sbits)) - 1,\ |
246 | .apply_reg = DA9052_SUPPLY_REG, \ | ||
247 | .apply_bit = (abits), \ | ||
248 | .enable_reg = DA9052_BUCKCORE_REG + DA9052_ID_##_id, \ | 277 | .enable_reg = DA9052_BUCKCORE_REG + DA9052_ID_##_id, \ |
249 | .enable_mask = 1 << (ebits),\ | 278 | .enable_mask = 1 << (ebits),\ |
250 | },\ | 279 | },\ |
251 | .min_uV = (min) * 1000,\ | 280 | .min_uV = (min) * 1000,\ |
252 | .max_uV = (max) * 1000,\ | 281 | .max_uV = (max) * 1000,\ |
253 | .step_uV = (step) * 1000,\ | 282 | .step_uV = (step) * 1000,\ |
283 | .activate_bit = (abits),\ | ||
254 | } | 284 | } |
255 | 285 | ||
256 | #define DA9052_DCDC(_id, step, min, max, sbits, ebits, abits) \ | 286 | #define DA9052_DCDC(_id, step, min, max, sbits, ebits, abits) \ |
@@ -264,14 +294,13 @@ static struct regulator_ops da9052_ldo_ops = { | |||
264 | .owner = THIS_MODULE,\ | 294 | .owner = THIS_MODULE,\ |
265 | .vsel_reg = DA9052_BUCKCORE_REG + DA9052_ID_##_id, \ | 295 | .vsel_reg = DA9052_BUCKCORE_REG + DA9052_ID_##_id, \ |
266 | .vsel_mask = (1 << (sbits)) - 1,\ | 296 | .vsel_mask = (1 << (sbits)) - 1,\ |
267 | .apply_reg = DA9052_SUPPLY_REG, \ | ||
268 | .apply_bit = (abits), \ | ||
269 | .enable_reg = DA9052_BUCKCORE_REG + DA9052_ID_##_id, \ | 297 | .enable_reg = DA9052_BUCKCORE_REG + DA9052_ID_##_id, \ |
270 | .enable_mask = 1 << (ebits),\ | 298 | .enable_mask = 1 << (ebits),\ |
271 | },\ | 299 | },\ |
272 | .min_uV = (min) * 1000,\ | 300 | .min_uV = (min) * 1000,\ |
273 | .max_uV = (max) * 1000,\ | 301 | .max_uV = (max) * 1000,\ |
274 | .step_uV = (step) * 1000,\ | 302 | .step_uV = (step) * 1000,\ |
303 | .activate_bit = (abits),\ | ||
275 | } | 304 | } |
276 | 305 | ||
277 | static struct da9052_regulator_info da9052_regulator_info[] = { | 306 | static struct da9052_regulator_info da9052_regulator_info[] = { |
@@ -389,8 +418,9 @@ static int da9052_regulator_probe(struct platform_device *pdev) | |||
389 | #endif | 418 | #endif |
390 | } | 419 | } |
391 | 420 | ||
392 | regulator->rdev = regulator_register(®ulator->info->reg_desc, | 421 | regulator->rdev = devm_regulator_register(&pdev->dev, |
393 | &config); | 422 | ®ulator->info->reg_desc, |
423 | &config); | ||
394 | if (IS_ERR(regulator->rdev)) { | 424 | if (IS_ERR(regulator->rdev)) { |
395 | dev_err(&pdev->dev, "failed to register regulator %s\n", | 425 | dev_err(&pdev->dev, "failed to register regulator %s\n", |
396 | regulator->info->reg_desc.name); | 426 | regulator->info->reg_desc.name); |
@@ -402,17 +432,8 @@ static int da9052_regulator_probe(struct platform_device *pdev) | |||
402 | return 0; | 432 | return 0; |
403 | } | 433 | } |
404 | 434 | ||
405 | static int da9052_regulator_remove(struct platform_device *pdev) | ||
406 | { | ||
407 | struct da9052_regulator *regulator = platform_get_drvdata(pdev); | ||
408 | |||
409 | regulator_unregister(regulator->rdev); | ||
410 | return 0; | ||
411 | } | ||
412 | |||
413 | static struct platform_driver da9052_regulator_driver = { | 435 | static struct platform_driver da9052_regulator_driver = { |
414 | .probe = da9052_regulator_probe, | 436 | .probe = da9052_regulator_probe, |
415 | .remove = da9052_regulator_remove, | ||
416 | .driver = { | 437 | .driver = { |
417 | .name = "da9052-regulator", | 438 | .name = "da9052-regulator", |
418 | .owner = THIS_MODULE, | 439 | .owner = THIS_MODULE, |
diff --git a/drivers/regulator/da9055-regulator.c b/drivers/regulator/da9055-regulator.c index 77b53e5a231c..7f340206d329 100644 --- a/drivers/regulator/da9055-regulator.c +++ b/drivers/regulator/da9055-regulator.c | |||
@@ -564,13 +564,13 @@ static int da9055_regulator_probe(struct platform_device *pdev) | |||
564 | if (ret < 0) | 564 | if (ret < 0) |
565 | return ret; | 565 | return ret; |
566 | 566 | ||
567 | regulator->rdev = regulator_register(®ulator->info->reg_desc, | 567 | regulator->rdev = devm_regulator_register(&pdev->dev, |
568 | &config); | 568 | ®ulator->info->reg_desc, |
569 | &config); | ||
569 | if (IS_ERR(regulator->rdev)) { | 570 | if (IS_ERR(regulator->rdev)) { |
570 | dev_err(&pdev->dev, "Failed to register regulator %s\n", | 571 | dev_err(&pdev->dev, "Failed to register regulator %s\n", |
571 | regulator->info->reg_desc.name); | 572 | regulator->info->reg_desc.name); |
572 | ret = PTR_ERR(regulator->rdev); | 573 | return PTR_ERR(regulator->rdev); |
573 | return ret; | ||
574 | } | 574 | } |
575 | 575 | ||
576 | /* Only LDO 5 and 6 has got the over current interrupt */ | 576 | /* Only LDO 5 and 6 has got the over current interrupt */ |
@@ -588,7 +588,7 @@ static int da9055_regulator_probe(struct platform_device *pdev) | |||
588 | dev_err(&pdev->dev, | 588 | dev_err(&pdev->dev, |
589 | "Failed to request Regulator IRQ %d: %d\n", | 589 | "Failed to request Regulator IRQ %d: %d\n", |
590 | irq, ret); | 590 | irq, ret); |
591 | goto err_regulator; | 591 | return ret; |
592 | } | 592 | } |
593 | } | 593 | } |
594 | } | 594 | } |
@@ -596,24 +596,10 @@ static int da9055_regulator_probe(struct platform_device *pdev) | |||
596 | platform_set_drvdata(pdev, regulator); | 596 | platform_set_drvdata(pdev, regulator); |
597 | 597 | ||
598 | return 0; | 598 | return 0; |
599 | |||
600 | err_regulator: | ||
601 | regulator_unregister(regulator->rdev); | ||
602 | return ret; | ||
603 | } | ||
604 | |||
605 | static int da9055_regulator_remove(struct platform_device *pdev) | ||
606 | { | ||
607 | struct da9055_regulator *regulator = platform_get_drvdata(pdev); | ||
608 | |||
609 | regulator_unregister(regulator->rdev); | ||
610 | |||
611 | return 0; | ||
612 | } | 599 | } |
613 | 600 | ||
614 | static struct platform_driver da9055_regulator_driver = { | 601 | static struct platform_driver da9055_regulator_driver = { |
615 | .probe = da9055_regulator_probe, | 602 | .probe = da9055_regulator_probe, |
616 | .remove = da9055_regulator_remove, | ||
617 | .driver = { | 603 | .driver = { |
618 | .name = "da9055-regulator", | 604 | .name = "da9055-regulator", |
619 | .owner = THIS_MODULE, | 605 | .owner = THIS_MODULE, |
diff --git a/drivers/regulator/da9063-regulator.c b/drivers/regulator/da9063-regulator.c index b9f2653e4ef9..56727eb745df 100644 --- a/drivers/regulator/da9063-regulator.c +++ b/drivers/regulator/da9063-regulator.c | |||
@@ -717,7 +717,7 @@ static int da9063_regulator_probe(struct platform_device *pdev) | |||
717 | { | 717 | { |
718 | struct da9063 *da9063 = dev_get_drvdata(pdev->dev.parent); | 718 | struct da9063 *da9063 = dev_get_drvdata(pdev->dev.parent); |
719 | struct da9063_pdata *da9063_pdata = dev_get_platdata(da9063->dev); | 719 | struct da9063_pdata *da9063_pdata = dev_get_platdata(da9063->dev); |
720 | struct of_regulator_match *da9063_reg_matches; | 720 | struct of_regulator_match *da9063_reg_matches = NULL; |
721 | struct da9063_regulators_pdata *regl_pdata; | 721 | struct da9063_regulators_pdata *regl_pdata; |
722 | const struct da9063_dev_model *model; | 722 | const struct da9063_dev_model *model; |
723 | struct da9063_regulators *regulators; | 723 | struct da9063_regulators *regulators; |
@@ -847,13 +847,13 @@ static int da9063_regulator_probe(struct platform_device *pdev) | |||
847 | if (da9063_reg_matches) | 847 | if (da9063_reg_matches) |
848 | config.of_node = da9063_reg_matches[id].of_node; | 848 | config.of_node = da9063_reg_matches[id].of_node; |
849 | config.regmap = da9063->regmap; | 849 | config.regmap = da9063->regmap; |
850 | regl->rdev = regulator_register(®l->desc, &config); | 850 | regl->rdev = devm_regulator_register(&pdev->dev, ®l->desc, |
851 | &config); | ||
851 | if (IS_ERR(regl->rdev)) { | 852 | if (IS_ERR(regl->rdev)) { |
852 | dev_err(&pdev->dev, | 853 | dev_err(&pdev->dev, |
853 | "Failed to register %s regulator\n", | 854 | "Failed to register %s regulator\n", |
854 | regl->desc.name); | 855 | regl->desc.name); |
855 | ret = PTR_ERR(regl->rdev); | 856 | return PTR_ERR(regl->rdev); |
856 | goto err; | ||
857 | } | 857 | } |
858 | id++; | 858 | id++; |
859 | n++; | 859 | n++; |
@@ -862,9 +862,8 @@ static int da9063_regulator_probe(struct platform_device *pdev) | |||
862 | /* LDOs overcurrent event support */ | 862 | /* LDOs overcurrent event support */ |
863 | irq = platform_get_irq_byname(pdev, "LDO_LIM"); | 863 | irq = platform_get_irq_byname(pdev, "LDO_LIM"); |
864 | if (irq < 0) { | 864 | if (irq < 0) { |
865 | ret = irq; | ||
866 | dev_err(&pdev->dev, "Failed to get IRQ.\n"); | 865 | dev_err(&pdev->dev, "Failed to get IRQ.\n"); |
867 | goto err; | 866 | return irq; |
868 | } | 867 | } |
869 | 868 | ||
870 | regulators->irq_ldo_lim = regmap_irq_get_virq(da9063->regmap_irq, irq); | 869 | regulators->irq_ldo_lim = regmap_irq_get_virq(da9063->regmap_irq, irq); |
@@ -881,27 +880,15 @@ static int da9063_regulator_probe(struct platform_device *pdev) | |||
881 | } | 880 | } |
882 | 881 | ||
883 | return 0; | 882 | return 0; |
884 | |||
885 | err: | ||
886 | /* Wind back regulators registeration */ | ||
887 | while (--n >= 0) | ||
888 | regulator_unregister(regulators->regulator[n].rdev); | ||
889 | |||
890 | return ret; | ||
891 | } | 883 | } |
892 | 884 | ||
893 | static int da9063_regulator_remove(struct platform_device *pdev) | 885 | static int da9063_regulator_remove(struct platform_device *pdev) |
894 | { | 886 | { |
895 | struct da9063_regulators *regulators = platform_get_drvdata(pdev); | 887 | struct da9063_regulators *regulators = platform_get_drvdata(pdev); |
896 | struct da9063_regulator *regl; | ||
897 | 888 | ||
898 | free_irq(regulators->irq_ldo_lim, regulators); | 889 | free_irq(regulators->irq_ldo_lim, regulators); |
899 | free_irq(regulators->irq_uvov, regulators); | 890 | free_irq(regulators->irq_uvov, regulators); |
900 | 891 | ||
901 | for (regl = ®ulators->regulator[regulators->n_regulators - 1]; | ||
902 | regl >= ®ulators->regulator[0]; regl--) | ||
903 | regulator_unregister(regl->rdev); | ||
904 | |||
905 | return 0; | 892 | return 0; |
906 | } | 893 | } |
907 | 894 | ||
diff --git a/drivers/regulator/da9210-regulator.c b/drivers/regulator/da9210-regulator.c index f0fe54b38977..6f5ecbe1132e 100644 --- a/drivers/regulator/da9210-regulator.c +++ b/drivers/regulator/da9210-regulator.c | |||
@@ -25,6 +25,7 @@ | |||
25 | #include <linux/slab.h> | 25 | #include <linux/slab.h> |
26 | #include <linux/regulator/driver.h> | 26 | #include <linux/regulator/driver.h> |
27 | #include <linux/regulator/machine.h> | 27 | #include <linux/regulator/machine.h> |
28 | #include <linux/regulator/of_regulator.h> | ||
28 | #include <linux/regmap.h> | 29 | #include <linux/regmap.h> |
29 | 30 | ||
30 | #include "da9210-regulator.h" | 31 | #include "da9210-regulator.h" |
@@ -126,7 +127,8 @@ static int da9210_i2c_probe(struct i2c_client *i2c, | |||
126 | const struct i2c_device_id *id) | 127 | const struct i2c_device_id *id) |
127 | { | 128 | { |
128 | struct da9210 *chip; | 129 | struct da9210 *chip; |
129 | struct da9210_pdata *pdata = i2c->dev.platform_data; | 130 | struct device *dev = &i2c->dev; |
131 | struct da9210_pdata *pdata = dev_get_platdata(dev); | ||
130 | struct regulator_dev *rdev = NULL; | 132 | struct regulator_dev *rdev = NULL; |
131 | struct regulator_config config = { }; | 133 | struct regulator_config config = { }; |
132 | int error; | 134 | int error; |
@@ -147,12 +149,13 @@ static int da9210_i2c_probe(struct i2c_client *i2c, | |||
147 | } | 149 | } |
148 | 150 | ||
149 | config.dev = &i2c->dev; | 151 | config.dev = &i2c->dev; |
150 | if (pdata) | 152 | config.init_data = pdata ? &pdata->da9210_constraints : |
151 | config.init_data = &pdata->da9210_constraints; | 153 | of_get_regulator_init_data(dev, dev->of_node); |
152 | config.driver_data = chip; | 154 | config.driver_data = chip; |
153 | config.regmap = chip->regmap; | 155 | config.regmap = chip->regmap; |
156 | config.of_node = dev->of_node; | ||
154 | 157 | ||
155 | rdev = regulator_register(&da9210_reg, &config); | 158 | rdev = devm_regulator_register(&i2c->dev, &da9210_reg, &config); |
156 | if (IS_ERR(rdev)) { | 159 | if (IS_ERR(rdev)) { |
157 | dev_err(&i2c->dev, "Failed to register DA9210 regulator\n"); | 160 | dev_err(&i2c->dev, "Failed to register DA9210 regulator\n"); |
158 | return PTR_ERR(rdev); | 161 | return PTR_ERR(rdev); |
@@ -165,13 +168,6 @@ static int da9210_i2c_probe(struct i2c_client *i2c, | |||
165 | return 0; | 168 | return 0; |
166 | } | 169 | } |
167 | 170 | ||
168 | static int da9210_i2c_remove(struct i2c_client *i2c) | ||
169 | { | ||
170 | struct da9210 *chip = i2c_get_clientdata(i2c); | ||
171 | regulator_unregister(chip->rdev); | ||
172 | return 0; | ||
173 | } | ||
174 | |||
175 | static const struct i2c_device_id da9210_i2c_id[] = { | 171 | static const struct i2c_device_id da9210_i2c_id[] = { |
176 | {"da9210", 0}, | 172 | {"da9210", 0}, |
177 | {}, | 173 | {}, |
@@ -185,7 +181,6 @@ static struct i2c_driver da9210_regulator_driver = { | |||
185 | .owner = THIS_MODULE, | 181 | .owner = THIS_MODULE, |
186 | }, | 182 | }, |
187 | .probe = da9210_i2c_probe, | 183 | .probe = da9210_i2c_probe, |
188 | .remove = da9210_i2c_remove, | ||
189 | .id_table = da9210_i2c_id, | 184 | .id_table = da9210_i2c_id, |
190 | }; | 185 | }; |
191 | 186 | ||
diff --git a/drivers/regulator/devres.c b/drivers/regulator/devres.c new file mode 100644 index 000000000000..f44818b838dc --- /dev/null +++ b/drivers/regulator/devres.c | |||
@@ -0,0 +1,415 @@ | |||
1 | /* | ||
2 | * devres.c -- Voltage/Current Regulator framework devres implementation. | ||
3 | * | ||
4 | * Copyright 2013 Linaro Ltd | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify it | ||
7 | * under the terms of the GNU General Public License as published by the | ||
8 | * Free Software Foundation; either version 2 of the License, or (at your | ||
9 | * option) any later version. | ||
10 | * | ||
11 | */ | ||
12 | |||
13 | #include <linux/kernel.h> | ||
14 | #include <linux/err.h> | ||
15 | #include <linux/regmap.h> | ||
16 | #include <linux/regulator/consumer.h> | ||
17 | #include <linux/regulator/driver.h> | ||
18 | #include <linux/module.h> | ||
19 | |||
20 | #include "internal.h" | ||
21 | |||
22 | enum { | ||
23 | NORMAL_GET, | ||
24 | EXCLUSIVE_GET, | ||
25 | OPTIONAL_GET, | ||
26 | }; | ||
27 | |||
28 | static void devm_regulator_release(struct device *dev, void *res) | ||
29 | { | ||
30 | regulator_put(*(struct regulator **)res); | ||
31 | } | ||
32 | |||
33 | static struct regulator *_devm_regulator_get(struct device *dev, const char *id, | ||
34 | int get_type) | ||
35 | { | ||
36 | struct regulator **ptr, *regulator; | ||
37 | |||
38 | ptr = devres_alloc(devm_regulator_release, sizeof(*ptr), GFP_KERNEL); | ||
39 | if (!ptr) | ||
40 | return ERR_PTR(-ENOMEM); | ||
41 | |||
42 | switch (get_type) { | ||
43 | case NORMAL_GET: | ||
44 | regulator = regulator_get(dev, id); | ||
45 | break; | ||
46 | case EXCLUSIVE_GET: | ||
47 | regulator = regulator_get_exclusive(dev, id); | ||
48 | break; | ||
49 | case OPTIONAL_GET: | ||
50 | regulator = regulator_get_optional(dev, id); | ||
51 | break; | ||
52 | default: | ||
53 | regulator = ERR_PTR(-EINVAL); | ||
54 | } | ||
55 | |||
56 | if (!IS_ERR(regulator)) { | ||
57 | *ptr = regulator; | ||
58 | devres_add(dev, ptr); | ||
59 | } else { | ||
60 | devres_free(ptr); | ||
61 | } | ||
62 | |||
63 | return regulator; | ||
64 | } | ||
65 | |||
66 | /** | ||
67 | * devm_regulator_get - Resource managed regulator_get() | ||
68 | * @dev: device for regulator "consumer" | ||
69 | * @id: Supply name or regulator ID. | ||
70 | * | ||
71 | * Managed regulator_get(). Regulators returned from this function are | ||
72 | * automatically regulator_put() on driver detach. See regulator_get() for more | ||
73 | * information. | ||
74 | */ | ||
75 | struct regulator *devm_regulator_get(struct device *dev, const char *id) | ||
76 | { | ||
77 | return _devm_regulator_get(dev, id, NORMAL_GET); | ||
78 | } | ||
79 | EXPORT_SYMBOL_GPL(devm_regulator_get); | ||
80 | |||
81 | /** | ||
82 | * devm_regulator_get_exclusive - Resource managed regulator_get_exclusive() | ||
83 | * @dev: device for regulator "consumer" | ||
84 | * @id: Supply name or regulator ID. | ||
85 | * | ||
86 | * Managed regulator_get_exclusive(). Regulators returned from this function | ||
87 | * are automatically regulator_put() on driver detach. See regulator_get() for | ||
88 | * more information. | ||
89 | */ | ||
90 | struct regulator *devm_regulator_get_exclusive(struct device *dev, | ||
91 | const char *id) | ||
92 | { | ||
93 | return _devm_regulator_get(dev, id, EXCLUSIVE_GET); | ||
94 | } | ||
95 | EXPORT_SYMBOL_GPL(devm_regulator_get_exclusive); | ||
96 | |||
97 | /** | ||
98 | * devm_regulator_get_optional - Resource managed regulator_get_optional() | ||
99 | * @dev: device for regulator "consumer" | ||
100 | * @id: Supply name or regulator ID. | ||
101 | * | ||
102 | * Managed regulator_get_optional(). Regulators returned from this | ||
103 | * function are automatically regulator_put() on driver detach. See | ||
104 | * regulator_get_optional() for more information. | ||
105 | */ | ||
106 | struct regulator *devm_regulator_get_optional(struct device *dev, | ||
107 | const char *id) | ||
108 | { | ||
109 | return _devm_regulator_get(dev, id, OPTIONAL_GET); | ||
110 | } | ||
111 | EXPORT_SYMBOL_GPL(devm_regulator_get_optional); | ||
112 | |||
113 | static int devm_regulator_match(struct device *dev, void *res, void *data) | ||
114 | { | ||
115 | struct regulator **r = res; | ||
116 | if (!r || !*r) { | ||
117 | WARN_ON(!r || !*r); | ||
118 | return 0; | ||
119 | } | ||
120 | return *r == data; | ||
121 | } | ||
122 | |||
123 | /** | ||
124 | * devm_regulator_put - Resource managed regulator_put() | ||
125 | * @regulator: regulator to free | ||
126 | * | ||
127 | * Deallocate a regulator allocated with devm_regulator_get(). Normally | ||
128 | * this function will not need to be called and the resource management | ||
129 | * code will ensure that the resource is freed. | ||
130 | */ | ||
131 | void devm_regulator_put(struct regulator *regulator) | ||
132 | { | ||
133 | int rc; | ||
134 | |||
135 | rc = devres_release(regulator->dev, devm_regulator_release, | ||
136 | devm_regulator_match, regulator); | ||
137 | if (rc != 0) | ||
138 | WARN_ON(rc); | ||
139 | } | ||
140 | EXPORT_SYMBOL_GPL(devm_regulator_put); | ||
141 | |||
142 | /** | ||
143 | * devm_regulator_bulk_get - managed get multiple regulator consumers | ||
144 | * | ||
145 | * @dev: Device to supply | ||
146 | * @num_consumers: Number of consumers to register | ||
147 | * @consumers: Configuration of consumers; clients are stored here. | ||
148 | * | ||
149 | * @return 0 on success, an errno on failure. | ||
150 | * | ||
151 | * This helper function allows drivers to get several regulator | ||
152 | * consumers in one operation with management, the regulators will | ||
153 | * automatically be freed when the device is unbound. If any of the | ||
154 | * regulators cannot be acquired then any regulators that were | ||
155 | * allocated will be freed before returning to the caller. | ||
156 | */ | ||
157 | int devm_regulator_bulk_get(struct device *dev, int num_consumers, | ||
158 | struct regulator_bulk_data *consumers) | ||
159 | { | ||
160 | int i; | ||
161 | int ret; | ||
162 | |||
163 | for (i = 0; i < num_consumers; i++) | ||
164 | consumers[i].consumer = NULL; | ||
165 | |||
166 | for (i = 0; i < num_consumers; i++) { | ||
167 | consumers[i].consumer = devm_regulator_get(dev, | ||
168 | consumers[i].supply); | ||
169 | if (IS_ERR(consumers[i].consumer)) { | ||
170 | ret = PTR_ERR(consumers[i].consumer); | ||
171 | dev_err(dev, "Failed to get supply '%s': %d\n", | ||
172 | consumers[i].supply, ret); | ||
173 | consumers[i].consumer = NULL; | ||
174 | goto err; | ||
175 | } | ||
176 | } | ||
177 | |||
178 | return 0; | ||
179 | |||
180 | err: | ||
181 | for (i = 0; i < num_consumers && consumers[i].consumer; i++) | ||
182 | devm_regulator_put(consumers[i].consumer); | ||
183 | |||
184 | return ret; | ||
185 | } | ||
186 | EXPORT_SYMBOL_GPL(devm_regulator_bulk_get); | ||
187 | |||
188 | static void devm_rdev_release(struct device *dev, void *res) | ||
189 | { | ||
190 | regulator_unregister(*(struct regulator_dev **)res); | ||
191 | } | ||
192 | |||
193 | /** | ||
194 | * devm_regulator_register - Resource managed regulator_register() | ||
195 | * @regulator_desc: regulator to register | ||
196 | * @config: runtime configuration for regulator | ||
197 | * | ||
198 | * Called by regulator drivers to register a regulator. Returns a | ||
199 | * valid pointer to struct regulator_dev on success or an ERR_PTR() on | ||
200 | * error. The regulator will automatically be released when the device | ||
201 | * is unbound. | ||
202 | */ | ||
203 | struct regulator_dev *devm_regulator_register(struct device *dev, | ||
204 | const struct regulator_desc *regulator_desc, | ||
205 | const struct regulator_config *config) | ||
206 | { | ||
207 | struct regulator_dev **ptr, *rdev; | ||
208 | |||
209 | ptr = devres_alloc(devm_rdev_release, sizeof(*ptr), | ||
210 | GFP_KERNEL); | ||
211 | if (!ptr) | ||
212 | return ERR_PTR(-ENOMEM); | ||
213 | |||
214 | rdev = regulator_register(regulator_desc, config); | ||
215 | if (!IS_ERR(rdev)) { | ||
216 | *ptr = rdev; | ||
217 | devres_add(dev, ptr); | ||
218 | } else { | ||
219 | devres_free(ptr); | ||
220 | } | ||
221 | |||
222 | return rdev; | ||
223 | } | ||
224 | EXPORT_SYMBOL_GPL(devm_regulator_register); | ||
225 | |||
226 | static int devm_rdev_match(struct device *dev, void *res, void *data) | ||
227 | { | ||
228 | struct regulator_dev **r = res; | ||
229 | if (!r || !*r) { | ||
230 | WARN_ON(!r || !*r); | ||
231 | return 0; | ||
232 | } | ||
233 | return *r == data; | ||
234 | } | ||
235 | |||
236 | /** | ||
237 | * devm_regulator_unregister - Resource managed regulator_unregister() | ||
238 | * @regulator: regulator to free | ||
239 | * | ||
240 | * Unregister a regulator registered with devm_regulator_register(). | ||
241 | * Normally this function will not need to be called and the resource | ||
242 | * management code will ensure that the resource is freed. | ||
243 | */ | ||
244 | void devm_regulator_unregister(struct device *dev, struct regulator_dev *rdev) | ||
245 | { | ||
246 | int rc; | ||
247 | |||
248 | rc = devres_release(dev, devm_rdev_release, devm_rdev_match, rdev); | ||
249 | if (rc != 0) | ||
250 | WARN_ON(rc); | ||
251 | } | ||
252 | EXPORT_SYMBOL_GPL(devm_regulator_unregister); | ||
253 | |||
254 | struct regulator_supply_alias_match { | ||
255 | struct device *dev; | ||
256 | const char *id; | ||
257 | }; | ||
258 | |||
259 | static int devm_regulator_match_supply_alias(struct device *dev, void *res, | ||
260 | void *data) | ||
261 | { | ||
262 | struct regulator_supply_alias_match *match = res; | ||
263 | struct regulator_supply_alias_match *target = data; | ||
264 | |||
265 | return match->dev == target->dev && strcmp(match->id, target->id) == 0; | ||
266 | } | ||
267 | |||
268 | static void devm_regulator_destroy_supply_alias(struct device *dev, void *res) | ||
269 | { | ||
270 | struct regulator_supply_alias_match *match = res; | ||
271 | |||
272 | regulator_unregister_supply_alias(match->dev, match->id); | ||
273 | } | ||
274 | |||
275 | /** | ||
276 | * devm_regulator_register_supply_alias - Resource managed | ||
277 | * regulator_register_supply_alias() | ||
278 | * | ||
279 | * @dev: device that will be given as the regulator "consumer" | ||
280 | * @id: Supply name or regulator ID | ||
281 | * @alias_dev: device that should be used to lookup the supply | ||
282 | * @alias_id: Supply name or regulator ID that should be used to lookup the | ||
283 | * supply | ||
284 | * | ||
285 | * The supply alias will automatically be unregistered when the source | ||
286 | * device is unbound. | ||
287 | */ | ||
288 | int devm_regulator_register_supply_alias(struct device *dev, const char *id, | ||
289 | struct device *alias_dev, | ||
290 | const char *alias_id) | ||
291 | { | ||
292 | struct regulator_supply_alias_match *match; | ||
293 | int ret; | ||
294 | |||
295 | match = devres_alloc(devm_regulator_destroy_supply_alias, | ||
296 | sizeof(struct regulator_supply_alias_match), | ||
297 | GFP_KERNEL); | ||
298 | if (!match) | ||
299 | return -ENOMEM; | ||
300 | |||
301 | match->dev = dev; | ||
302 | match->id = id; | ||
303 | |||
304 | ret = regulator_register_supply_alias(dev, id, alias_dev, alias_id); | ||
305 | if (ret < 0) { | ||
306 | devres_free(match); | ||
307 | return ret; | ||
308 | } | ||
309 | |||
310 | devres_add(dev, match); | ||
311 | |||
312 | return 0; | ||
313 | } | ||
314 | EXPORT_SYMBOL_GPL(devm_regulator_register_supply_alias); | ||
315 | |||
316 | /** | ||
317 | * devm_regulator_unregister_supply_alias - Resource managed | ||
318 | * regulator_unregister_supply_alias() | ||
319 | * | ||
320 | * @dev: device that will be given as the regulator "consumer" | ||
321 | * @id: Supply name or regulator ID | ||
322 | * | ||
323 | * Unregister an alias registered with | ||
324 | * devm_regulator_register_supply_alias(). Normally this function | ||
325 | * will not need to be called and the resource management code | ||
326 | * will ensure that the resource is freed. | ||
327 | */ | ||
328 | void devm_regulator_unregister_supply_alias(struct device *dev, const char *id) | ||
329 | { | ||
330 | struct regulator_supply_alias_match match; | ||
331 | int rc; | ||
332 | |||
333 | match.dev = dev; | ||
334 | match.id = id; | ||
335 | |||
336 | rc = devres_release(dev, devm_regulator_destroy_supply_alias, | ||
337 | devm_regulator_match_supply_alias, &match); | ||
338 | if (rc != 0) | ||
339 | WARN_ON(rc); | ||
340 | } | ||
341 | EXPORT_SYMBOL_GPL(devm_regulator_unregister_supply_alias); | ||
342 | |||
343 | /** | ||
344 | * devm_regulator_bulk_register_supply_alias - Managed register | ||
345 | * multiple aliases | ||
346 | * | ||
347 | * @dev: device that will be given as the regulator "consumer" | ||
348 | * @id: List of supply names or regulator IDs | ||
349 | * @alias_dev: device that should be used to lookup the supply | ||
350 | * @alias_id: List of supply names or regulator IDs that should be used to | ||
351 | * lookup the supply | ||
352 | * @num_id: Number of aliases to register | ||
353 | * | ||
354 | * @return 0 on success, an errno on failure. | ||
355 | * | ||
356 | * This helper function allows drivers to register several supply | ||
357 | * aliases in one operation, the aliases will be automatically | ||
358 | * unregisters when the source device is unbound. If any of the | ||
359 | * aliases cannot be registered any aliases that were registered | ||
360 | * will be removed before returning to the caller. | ||
361 | */ | ||
362 | int devm_regulator_bulk_register_supply_alias(struct device *dev, | ||
363 | const char **id, | ||
364 | struct device *alias_dev, | ||
365 | const char **alias_id, | ||
366 | int num_id) | ||
367 | { | ||
368 | int i; | ||
369 | int ret; | ||
370 | |||
371 | for (i = 0; i < num_id; ++i) { | ||
372 | ret = devm_regulator_register_supply_alias(dev, id[i], | ||
373 | alias_dev, | ||
374 | alias_id[i]); | ||
375 | if (ret < 0) | ||
376 | goto err; | ||
377 | } | ||
378 | |||
379 | return 0; | ||
380 | |||
381 | err: | ||
382 | dev_err(dev, | ||
383 | "Failed to create supply alias %s,%s -> %s,%s\n", | ||
384 | id[i], dev_name(dev), alias_id[i], dev_name(alias_dev)); | ||
385 | |||
386 | while (--i >= 0) | ||
387 | devm_regulator_unregister_supply_alias(dev, id[i]); | ||
388 | |||
389 | return ret; | ||
390 | } | ||
391 | EXPORT_SYMBOL_GPL(devm_regulator_bulk_register_supply_alias); | ||
392 | |||
393 | /** | ||
394 | * devm_regulator_bulk_unregister_supply_alias - Managed unregister | ||
395 | * multiple aliases | ||
396 | * | ||
397 | * @dev: device that will be given as the regulator "consumer" | ||
398 | * @id: List of supply names or regulator IDs | ||
399 | * @num_id: Number of aliases to unregister | ||
400 | * | ||
401 | * Unregister aliases registered with | ||
402 | * devm_regulator_bulk_register_supply_alias(). Normally this function | ||
403 | * will not need to be called and the resource management code | ||
404 | * will ensure that the resource is freed. | ||
405 | */ | ||
406 | void devm_regulator_bulk_unregister_supply_alias(struct device *dev, | ||
407 | const char **id, | ||
408 | int num_id) | ||
409 | { | ||
410 | int i; | ||
411 | |||
412 | for (i = 0; i < num_id; ++i) | ||
413 | devm_regulator_unregister_supply_alias(dev, id[i]); | ||
414 | } | ||
415 | EXPORT_SYMBOL_GPL(devm_regulator_bulk_unregister_supply_alias); | ||
diff --git a/drivers/regulator/fan53555.c b/drivers/regulator/fan53555.c index 70b7220c587f..7ca3d9e3b0fe 100644 --- a/drivers/regulator/fan53555.c +++ b/drivers/regulator/fan53555.c | |||
@@ -218,9 +218,8 @@ static int fan53555_regulator_register(struct fan53555_device_info *di, | |||
218 | rdesc->vsel_mask = VSEL_NSEL_MASK; | 218 | rdesc->vsel_mask = VSEL_NSEL_MASK; |
219 | rdesc->owner = THIS_MODULE; | 219 | rdesc->owner = THIS_MODULE; |
220 | 220 | ||
221 | di->rdev = regulator_register(&di->desc, config); | 221 | di->rdev = devm_regulator_register(di->dev, &di->desc, config); |
222 | return PTR_ERR_OR_ZERO(di->rdev); | 222 | return PTR_ERR_OR_ZERO(di->rdev); |
223 | |||
224 | } | 223 | } |
225 | 224 | ||
226 | static struct regmap_config fan53555_regmap_config = { | 225 | static struct regmap_config fan53555_regmap_config = { |
@@ -291,14 +290,6 @@ static int fan53555_regulator_probe(struct i2c_client *client, | |||
291 | 290 | ||
292 | } | 291 | } |
293 | 292 | ||
294 | static int fan53555_regulator_remove(struct i2c_client *client) | ||
295 | { | ||
296 | struct fan53555_device_info *di = i2c_get_clientdata(client); | ||
297 | |||
298 | regulator_unregister(di->rdev); | ||
299 | return 0; | ||
300 | } | ||
301 | |||
302 | static const struct i2c_device_id fan53555_id[] = { | 293 | static const struct i2c_device_id fan53555_id[] = { |
303 | {"fan53555", -1}, | 294 | {"fan53555", -1}, |
304 | { }, | 295 | { }, |
@@ -309,7 +300,6 @@ static struct i2c_driver fan53555_regulator_driver = { | |||
309 | .name = "fan53555-regulator", | 300 | .name = "fan53555-regulator", |
310 | }, | 301 | }, |
311 | .probe = fan53555_regulator_probe, | 302 | .probe = fan53555_regulator_probe, |
312 | .remove = fan53555_regulator_remove, | ||
313 | .id_table = fan53555_id, | 303 | .id_table = fan53555_id, |
314 | }; | 304 | }; |
315 | 305 | ||
diff --git a/drivers/regulator/fixed.c b/drivers/regulator/fixed.c index 7610920014d7..5ea64b94341c 100644 --- a/drivers/regulator/fixed.c +++ b/drivers/regulator/fixed.c | |||
@@ -34,7 +34,6 @@ | |||
34 | struct fixed_voltage_data { | 34 | struct fixed_voltage_data { |
35 | struct regulator_desc desc; | 35 | struct regulator_desc desc; |
36 | struct regulator_dev *dev; | 36 | struct regulator_dev *dev; |
37 | int microvolts; | ||
38 | }; | 37 | }; |
39 | 38 | ||
40 | 39 | ||
@@ -108,30 +107,7 @@ of_get_fixed_voltage_config(struct device *dev) | |||
108 | return config; | 107 | return config; |
109 | } | 108 | } |
110 | 109 | ||
111 | static int fixed_voltage_get_voltage(struct regulator_dev *dev) | ||
112 | { | ||
113 | struct fixed_voltage_data *data = rdev_get_drvdata(dev); | ||
114 | |||
115 | if (data->microvolts) | ||
116 | return data->microvolts; | ||
117 | else | ||
118 | return -EINVAL; | ||
119 | } | ||
120 | |||
121 | static int fixed_voltage_list_voltage(struct regulator_dev *dev, | ||
122 | unsigned selector) | ||
123 | { | ||
124 | struct fixed_voltage_data *data = rdev_get_drvdata(dev); | ||
125 | |||
126 | if (selector != 0) | ||
127 | return -EINVAL; | ||
128 | |||
129 | return data->microvolts; | ||
130 | } | ||
131 | |||
132 | static struct regulator_ops fixed_voltage_ops = { | 110 | static struct regulator_ops fixed_voltage_ops = { |
133 | .get_voltage = fixed_voltage_get_voltage, | ||
134 | .list_voltage = fixed_voltage_list_voltage, | ||
135 | }; | 111 | }; |
136 | 112 | ||
137 | static int reg_fixed_voltage_probe(struct platform_device *pdev) | 113 | static int reg_fixed_voltage_probe(struct platform_device *pdev) |
@@ -186,23 +162,21 @@ static int reg_fixed_voltage_probe(struct platform_device *pdev) | |||
186 | if (config->microvolts) | 162 | if (config->microvolts) |
187 | drvdata->desc.n_voltages = 1; | 163 | drvdata->desc.n_voltages = 1; |
188 | 164 | ||
189 | drvdata->microvolts = config->microvolts; | 165 | drvdata->desc.fixed_uV = config->microvolts; |
190 | 166 | ||
191 | if (config->gpio >= 0) | 167 | if (config->gpio >= 0) |
192 | cfg.ena_gpio = config->gpio; | 168 | cfg.ena_gpio = config->gpio; |
193 | cfg.ena_gpio_invert = !config->enable_high; | 169 | cfg.ena_gpio_invert = !config->enable_high; |
194 | if (config->enabled_at_boot) { | 170 | if (config->enabled_at_boot) { |
195 | if (config->enable_high) { | 171 | if (config->enable_high) |
196 | cfg.ena_gpio_flags |= GPIOF_OUT_INIT_HIGH; | 172 | cfg.ena_gpio_flags |= GPIOF_OUT_INIT_HIGH; |
197 | } else { | 173 | else |
198 | cfg.ena_gpio_flags |= GPIOF_OUT_INIT_LOW; | 174 | cfg.ena_gpio_flags |= GPIOF_OUT_INIT_LOW; |
199 | } | ||
200 | } else { | 175 | } else { |
201 | if (config->enable_high) { | 176 | if (config->enable_high) |
202 | cfg.ena_gpio_flags |= GPIOF_OUT_INIT_LOW; | 177 | cfg.ena_gpio_flags |= GPIOF_OUT_INIT_LOW; |
203 | } else { | 178 | else |
204 | cfg.ena_gpio_flags |= GPIOF_OUT_INIT_HIGH; | 179 | cfg.ena_gpio_flags |= GPIOF_OUT_INIT_HIGH; |
205 | } | ||
206 | } | 180 | } |
207 | if (config->gpio_is_open_drain) | 181 | if (config->gpio_is_open_drain) |
208 | cfg.ena_gpio_flags |= GPIOF_OPEN_DRAIN; | 182 | cfg.ena_gpio_flags |= GPIOF_OPEN_DRAIN; |
@@ -222,7 +196,7 @@ static int reg_fixed_voltage_probe(struct platform_device *pdev) | |||
222 | platform_set_drvdata(pdev, drvdata); | 196 | platform_set_drvdata(pdev, drvdata); |
223 | 197 | ||
224 | dev_dbg(&pdev->dev, "%s supplying %duV\n", drvdata->desc.name, | 198 | dev_dbg(&pdev->dev, "%s supplying %duV\n", drvdata->desc.name, |
225 | drvdata->microvolts); | 199 | drvdata->desc.fixed_uV); |
226 | 200 | ||
227 | return 0; | 201 | return 0; |
228 | 202 | ||
diff --git a/drivers/regulator/gpio-regulator.c b/drivers/regulator/gpio-regulator.c index 98a98ffa7fe0..04406a918c04 100644 --- a/drivers/regulator/gpio-regulator.c +++ b/drivers/regulator/gpio-regulator.c | |||
@@ -283,7 +283,6 @@ static int gpio_regulator_probe(struct platform_device *pdev) | |||
283 | dev_err(&pdev->dev, "No regulator type set\n"); | 283 | dev_err(&pdev->dev, "No regulator type set\n"); |
284 | ret = -EINVAL; | 284 | ret = -EINVAL; |
285 | goto err_memgpio; | 285 | goto err_memgpio; |
286 | break; | ||
287 | } | 286 | } |
288 | 287 | ||
289 | drvdata->nr_gpios = config->nr_gpios; | 288 | drvdata->nr_gpios = config->nr_gpios; |
diff --git a/drivers/regulator/helpers.c b/drivers/regulator/helpers.c index 6e30df14714b..e221a271ba56 100644 --- a/drivers/regulator/helpers.c +++ b/drivers/regulator/helpers.c | |||
@@ -284,9 +284,13 @@ int regulator_map_voltage_linear_range(struct regulator_dev *rdev, | |||
284 | } | 284 | } |
285 | 285 | ||
286 | for (i = 0; i < rdev->desc->n_linear_ranges; i++) { | 286 | for (i = 0; i < rdev->desc->n_linear_ranges; i++) { |
287 | int linear_max_uV; | ||
288 | |||
287 | range = &rdev->desc->linear_ranges[i]; | 289 | range = &rdev->desc->linear_ranges[i]; |
290 | linear_max_uV = range->min_uV + | ||
291 | (range->max_sel - range->min_sel) * range->uV_step; | ||
288 | 292 | ||
289 | if (!(min_uV <= range->max_uV && max_uV >= range->min_uV)) | 293 | if (!(min_uV <= linear_max_uV && max_uV >= range->min_uV)) |
290 | continue; | 294 | continue; |
291 | 295 | ||
292 | if (min_uV <= range->min_uV) | 296 | if (min_uV <= range->min_uV) |
diff --git a/drivers/regulator/internal.h b/drivers/regulator/internal.h new file mode 100644 index 000000000000..84bbda10c396 --- /dev/null +++ b/drivers/regulator/internal.h | |||
@@ -0,0 +1,38 @@ | |||
1 | /* | ||
2 | * internal.h -- Voltage/Current Regulator framework internal code | ||
3 | * | ||
4 | * Copyright 2007, 2008 Wolfson Microelectronics PLC. | ||
5 | * Copyright 2008 SlimLogic Ltd. | ||
6 | * | ||
7 | * Author: Liam Girdwood <lrg@slimlogic.co.uk> | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify it | ||
10 | * under the terms of the GNU General Public License as published by the | ||
11 | * Free Software Foundation; either version 2 of the License, or (at your | ||
12 | * option) any later version. | ||
13 | * | ||
14 | */ | ||
15 | |||
16 | #ifndef __REGULATOR_INTERNAL_H | ||
17 | #define __REGULATOR_INTERNAL_H | ||
18 | |||
19 | /* | ||
20 | * struct regulator | ||
21 | * | ||
22 | * One for each consumer device. | ||
23 | */ | ||
24 | struct regulator { | ||
25 | struct device *dev; | ||
26 | struct list_head list; | ||
27 | unsigned int always_on:1; | ||
28 | unsigned int bypass:1; | ||
29 | int uA_load; | ||
30 | int min_uV; | ||
31 | int max_uV; | ||
32 | char *supply_name; | ||
33 | struct device_attribute dev_attr; | ||
34 | struct regulator_dev *rdev; | ||
35 | struct dentry *debugfs; | ||
36 | }; | ||
37 | |||
38 | #endif | ||
diff --git a/drivers/regulator/isl6271a-regulator.c b/drivers/regulator/isl6271a-regulator.c index 88c1a3acf563..6e5da95fa025 100644 --- a/drivers/regulator/isl6271a-regulator.c +++ b/drivers/regulator/isl6271a-regulator.c | |||
@@ -112,7 +112,7 @@ static int isl6271a_probe(struct i2c_client *i2c, | |||
112 | struct regulator_config config = { }; | 112 | struct regulator_config config = { }; |
113 | struct regulator_init_data *init_data = dev_get_platdata(&i2c->dev); | 113 | struct regulator_init_data *init_data = dev_get_platdata(&i2c->dev); |
114 | struct isl_pmic *pmic; | 114 | struct isl_pmic *pmic; |
115 | int err, i; | 115 | int i; |
116 | 116 | ||
117 | if (!i2c_check_functionality(i2c->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | 117 | if (!i2c_check_functionality(i2c->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
118 | return -EIO; | 118 | return -EIO; |
@@ -133,32 +133,17 @@ static int isl6271a_probe(struct i2c_client *i2c, | |||
133 | config.init_data = NULL; | 133 | config.init_data = NULL; |
134 | config.driver_data = pmic; | 134 | config.driver_data = pmic; |
135 | 135 | ||
136 | pmic->rdev[i] = regulator_register(&isl_rd[i], &config); | 136 | pmic->rdev[i] = devm_regulator_register(&i2c->dev, &isl_rd[i], |
137 | &config); | ||
137 | if (IS_ERR(pmic->rdev[i])) { | 138 | if (IS_ERR(pmic->rdev[i])) { |
138 | dev_err(&i2c->dev, "failed to register %s\n", id->name); | 139 | dev_err(&i2c->dev, "failed to register %s\n", id->name); |
139 | err = PTR_ERR(pmic->rdev[i]); | 140 | return PTR_ERR(pmic->rdev[i]); |
140 | goto error; | ||
141 | } | 141 | } |
142 | } | 142 | } |
143 | 143 | ||
144 | i2c_set_clientdata(i2c, pmic); | 144 | i2c_set_clientdata(i2c, pmic); |
145 | 145 | ||
146 | return 0; | 146 | return 0; |
147 | |||
148 | error: | ||
149 | while (--i >= 0) | ||
150 | regulator_unregister(pmic->rdev[i]); | ||
151 | return err; | ||
152 | } | ||
153 | |||
154 | static int isl6271a_remove(struct i2c_client *i2c) | ||
155 | { | ||
156 | struct isl_pmic *pmic = i2c_get_clientdata(i2c); | ||
157 | int i; | ||
158 | |||
159 | for (i = 0; i < 3; i++) | ||
160 | regulator_unregister(pmic->rdev[i]); | ||
161 | return 0; | ||
162 | } | 147 | } |
163 | 148 | ||
164 | static const struct i2c_device_id isl6271a_id[] = { | 149 | static const struct i2c_device_id isl6271a_id[] = { |
@@ -174,7 +159,6 @@ static struct i2c_driver isl6271a_i2c_driver = { | |||
174 | .owner = THIS_MODULE, | 159 | .owner = THIS_MODULE, |
175 | }, | 160 | }, |
176 | .probe = isl6271a_probe, | 161 | .probe = isl6271a_probe, |
177 | .remove = isl6271a_remove, | ||
178 | .id_table = isl6271a_id, | 162 | .id_table = isl6271a_id, |
179 | }; | 163 | }; |
180 | 164 | ||
diff --git a/drivers/regulator/lp3971.c b/drivers/regulator/lp3971.c index 5a4604ee5ea5..947c05ffe0ab 100644 --- a/drivers/regulator/lp3971.c +++ b/drivers/regulator/lp3971.c | |||
@@ -474,8 +474,8 @@ static int lp3971_i2c_remove(struct i2c_client *i2c) | |||
474 | } | 474 | } |
475 | 475 | ||
476 | static const struct i2c_device_id lp3971_i2c_id[] = { | 476 | static const struct i2c_device_id lp3971_i2c_id[] = { |
477 | { "lp3971", 0 }, | 477 | { "lp3971", 0 }, |
478 | { } | 478 | { } |
479 | }; | 479 | }; |
480 | MODULE_DEVICE_TABLE(i2c, lp3971_i2c_id); | 480 | MODULE_DEVICE_TABLE(i2c, lp3971_i2c_id); |
481 | 481 | ||
diff --git a/drivers/regulator/lp872x.c b/drivers/regulator/lp872x.c index 2b84b727a3c4..2e4734ff79fc 100644 --- a/drivers/regulator/lp872x.c +++ b/drivers/regulator/lp872x.c | |||
@@ -785,7 +785,7 @@ static int lp872x_regulator_register(struct lp872x *lp) | |||
785 | struct regulator_desc *desc; | 785 | struct regulator_desc *desc; |
786 | struct regulator_config cfg = { }; | 786 | struct regulator_config cfg = { }; |
787 | struct regulator_dev *rdev; | 787 | struct regulator_dev *rdev; |
788 | int i, ret; | 788 | int i; |
789 | 789 | ||
790 | for (i = 0; i < lp->num_regulators; i++) { | 790 | for (i = 0; i < lp->num_regulators; i++) { |
791 | desc = (lp->chipid == LP8720) ? &lp8720_regulator_desc[i] : | 791 | desc = (lp->chipid == LP8720) ? &lp8720_regulator_desc[i] : |
@@ -796,34 +796,16 @@ static int lp872x_regulator_register(struct lp872x *lp) | |||
796 | cfg.driver_data = lp; | 796 | cfg.driver_data = lp; |
797 | cfg.regmap = lp->regmap; | 797 | cfg.regmap = lp->regmap; |
798 | 798 | ||
799 | rdev = regulator_register(desc, &cfg); | 799 | rdev = devm_regulator_register(lp->dev, desc, &cfg); |
800 | if (IS_ERR(rdev)) { | 800 | if (IS_ERR(rdev)) { |
801 | dev_err(lp->dev, "regulator register err"); | 801 | dev_err(lp->dev, "regulator register err"); |
802 | ret = PTR_ERR(rdev); | 802 | return PTR_ERR(rdev); |
803 | goto err; | ||
804 | } | 803 | } |
805 | 804 | ||
806 | *(lp->regulators + i) = rdev; | 805 | *(lp->regulators + i) = rdev; |
807 | } | 806 | } |
808 | 807 | ||
809 | return 0; | 808 | return 0; |
810 | err: | ||
811 | while (--i >= 0) { | ||
812 | rdev = *(lp->regulators + i); | ||
813 | regulator_unregister(rdev); | ||
814 | } | ||
815 | return ret; | ||
816 | } | ||
817 | |||
818 | static void lp872x_regulator_unregister(struct lp872x *lp) | ||
819 | { | ||
820 | struct regulator_dev *rdev; | ||
821 | int i; | ||
822 | |||
823 | for (i = 0; i < lp->num_regulators; i++) { | ||
824 | rdev = *(lp->regulators + i); | ||
825 | regulator_unregister(rdev); | ||
826 | } | ||
827 | } | 809 | } |
828 | 810 | ||
829 | static const struct regmap_config lp872x_regmap_config = { | 811 | static const struct regmap_config lp872x_regmap_config = { |
@@ -979,14 +961,6 @@ err_dev: | |||
979 | return ret; | 961 | return ret; |
980 | } | 962 | } |
981 | 963 | ||
982 | static int lp872x_remove(struct i2c_client *cl) | ||
983 | { | ||
984 | struct lp872x *lp = i2c_get_clientdata(cl); | ||
985 | |||
986 | lp872x_regulator_unregister(lp); | ||
987 | return 0; | ||
988 | } | ||
989 | |||
990 | static const struct of_device_id lp872x_dt_ids[] = { | 964 | static const struct of_device_id lp872x_dt_ids[] = { |
991 | { .compatible = "ti,lp8720", }, | 965 | { .compatible = "ti,lp8720", }, |
992 | { .compatible = "ti,lp8725", }, | 966 | { .compatible = "ti,lp8725", }, |
@@ -1008,7 +982,6 @@ static struct i2c_driver lp872x_driver = { | |||
1008 | .of_match_table = of_match_ptr(lp872x_dt_ids), | 982 | .of_match_table = of_match_ptr(lp872x_dt_ids), |
1009 | }, | 983 | }, |
1010 | .probe = lp872x_probe, | 984 | .probe = lp872x_probe, |
1011 | .remove = lp872x_remove, | ||
1012 | .id_table = lp872x_ids, | 985 | .id_table = lp872x_ids, |
1013 | }; | 986 | }; |
1014 | 987 | ||
diff --git a/drivers/regulator/lp8788-buck.c b/drivers/regulator/lp8788-buck.c index 0b015f2a7fd9..948afc249e29 100644 --- a/drivers/regulator/lp8788-buck.c +++ b/drivers/regulator/lp8788-buck.c | |||
@@ -515,7 +515,7 @@ static int lp8788_buck_probe(struct platform_device *pdev) | |||
515 | cfg.driver_data = buck; | 515 | cfg.driver_data = buck; |
516 | cfg.regmap = lp->regmap; | 516 | cfg.regmap = lp->regmap; |
517 | 517 | ||
518 | rdev = regulator_register(&lp8788_buck_desc[id], &cfg); | 518 | rdev = devm_regulator_register(&pdev->dev, &lp8788_buck_desc[id], &cfg); |
519 | if (IS_ERR(rdev)) { | 519 | if (IS_ERR(rdev)) { |
520 | ret = PTR_ERR(rdev); | 520 | ret = PTR_ERR(rdev); |
521 | dev_err(&pdev->dev, "BUCK%d regulator register err = %d\n", | 521 | dev_err(&pdev->dev, "BUCK%d regulator register err = %d\n", |
@@ -529,18 +529,8 @@ static int lp8788_buck_probe(struct platform_device *pdev) | |||
529 | return 0; | 529 | return 0; |
530 | } | 530 | } |
531 | 531 | ||
532 | static int lp8788_buck_remove(struct platform_device *pdev) | ||
533 | { | ||
534 | struct lp8788_buck *buck = platform_get_drvdata(pdev); | ||
535 | |||
536 | regulator_unregister(buck->regulator); | ||
537 | |||
538 | return 0; | ||
539 | } | ||
540 | |||
541 | static struct platform_driver lp8788_buck_driver = { | 532 | static struct platform_driver lp8788_buck_driver = { |
542 | .probe = lp8788_buck_probe, | 533 | .probe = lp8788_buck_probe, |
543 | .remove = lp8788_buck_remove, | ||
544 | .driver = { | 534 | .driver = { |
545 | .name = LP8788_DEV_BUCK, | 535 | .name = LP8788_DEV_BUCK, |
546 | .owner = THIS_MODULE, | 536 | .owner = THIS_MODULE, |
diff --git a/drivers/regulator/lp8788-ldo.c b/drivers/regulator/lp8788-ldo.c index 0527d87c6dd5..b9a29a29933f 100644 --- a/drivers/regulator/lp8788-ldo.c +++ b/drivers/regulator/lp8788-ldo.c | |||
@@ -543,7 +543,7 @@ static int lp8788_dldo_probe(struct platform_device *pdev) | |||
543 | cfg.driver_data = ldo; | 543 | cfg.driver_data = ldo; |
544 | cfg.regmap = lp->regmap; | 544 | cfg.regmap = lp->regmap; |
545 | 545 | ||
546 | rdev = regulator_register(&lp8788_dldo_desc[id], &cfg); | 546 | rdev = devm_regulator_register(&pdev->dev, &lp8788_dldo_desc[id], &cfg); |
547 | if (IS_ERR(rdev)) { | 547 | if (IS_ERR(rdev)) { |
548 | ret = PTR_ERR(rdev); | 548 | ret = PTR_ERR(rdev); |
549 | dev_err(&pdev->dev, "DLDO%d regulator register err = %d\n", | 549 | dev_err(&pdev->dev, "DLDO%d regulator register err = %d\n", |
@@ -557,18 +557,8 @@ static int lp8788_dldo_probe(struct platform_device *pdev) | |||
557 | return 0; | 557 | return 0; |
558 | } | 558 | } |
559 | 559 | ||
560 | static int lp8788_dldo_remove(struct platform_device *pdev) | ||
561 | { | ||
562 | struct lp8788_ldo *ldo = platform_get_drvdata(pdev); | ||
563 | |||
564 | regulator_unregister(ldo->regulator); | ||
565 | |||
566 | return 0; | ||
567 | } | ||
568 | |||
569 | static struct platform_driver lp8788_dldo_driver = { | 560 | static struct platform_driver lp8788_dldo_driver = { |
570 | .probe = lp8788_dldo_probe, | 561 | .probe = lp8788_dldo_probe, |
571 | .remove = lp8788_dldo_remove, | ||
572 | .driver = { | 562 | .driver = { |
573 | .name = LP8788_DEV_DLDO, | 563 | .name = LP8788_DEV_DLDO, |
574 | .owner = THIS_MODULE, | 564 | .owner = THIS_MODULE, |
@@ -603,7 +593,7 @@ static int lp8788_aldo_probe(struct platform_device *pdev) | |||
603 | cfg.driver_data = ldo; | 593 | cfg.driver_data = ldo; |
604 | cfg.regmap = lp->regmap; | 594 | cfg.regmap = lp->regmap; |
605 | 595 | ||
606 | rdev = regulator_register(&lp8788_aldo_desc[id], &cfg); | 596 | rdev = devm_regulator_register(&pdev->dev, &lp8788_aldo_desc[id], &cfg); |
607 | if (IS_ERR(rdev)) { | 597 | if (IS_ERR(rdev)) { |
608 | ret = PTR_ERR(rdev); | 598 | ret = PTR_ERR(rdev); |
609 | dev_err(&pdev->dev, "ALDO%d regulator register err = %d\n", | 599 | dev_err(&pdev->dev, "ALDO%d regulator register err = %d\n", |
@@ -617,18 +607,8 @@ static int lp8788_aldo_probe(struct platform_device *pdev) | |||
617 | return 0; | 607 | return 0; |
618 | } | 608 | } |
619 | 609 | ||
620 | static int lp8788_aldo_remove(struct platform_device *pdev) | ||
621 | { | ||
622 | struct lp8788_ldo *ldo = platform_get_drvdata(pdev); | ||
623 | |||
624 | regulator_unregister(ldo->regulator); | ||
625 | |||
626 | return 0; | ||
627 | } | ||
628 | |||
629 | static struct platform_driver lp8788_aldo_driver = { | 610 | static struct platform_driver lp8788_aldo_driver = { |
630 | .probe = lp8788_aldo_probe, | 611 | .probe = lp8788_aldo_probe, |
631 | .remove = lp8788_aldo_remove, | ||
632 | .driver = { | 612 | .driver = { |
633 | .name = LP8788_DEV_ALDO, | 613 | .name = LP8788_DEV_ALDO, |
634 | .owner = THIS_MODULE, | 614 | .owner = THIS_MODULE, |
diff --git a/drivers/regulator/max1586.c b/drivers/regulator/max1586.c index 3a599ee0a456..e242dd316d36 100644 --- a/drivers/regulator/max1586.c +++ b/drivers/regulator/max1586.c | |||
@@ -166,7 +166,7 @@ static int max1586_pmic_probe(struct i2c_client *client, | |||
166 | struct max1586_platform_data *pdata = dev_get_platdata(&client->dev); | 166 | struct max1586_platform_data *pdata = dev_get_platdata(&client->dev); |
167 | struct regulator_config config = { }; | 167 | struct regulator_config config = { }; |
168 | struct max1586_data *max1586; | 168 | struct max1586_data *max1586; |
169 | int i, id, ret = -ENOMEM; | 169 | int i, id; |
170 | 170 | ||
171 | max1586 = devm_kzalloc(&client->dev, sizeof(struct max1586_data) + | 171 | max1586 = devm_kzalloc(&client->dev, sizeof(struct max1586_data) + |
172 | sizeof(struct regulator_dev *) * (MAX1586_V6 + 1), | 172 | sizeof(struct regulator_dev *) * (MAX1586_V6 + 1), |
@@ -193,7 +193,7 @@ static int max1586_pmic_probe(struct i2c_client *client, | |||
193 | continue; | 193 | continue; |
194 | if (id < MAX1586_V3 || id > MAX1586_V6) { | 194 | if (id < MAX1586_V3 || id > MAX1586_V6) { |
195 | dev_err(&client->dev, "invalid regulator id %d\n", id); | 195 | dev_err(&client->dev, "invalid regulator id %d\n", id); |
196 | goto err; | 196 | return -EINVAL; |
197 | } | 197 | } |
198 | 198 | ||
199 | if (id == MAX1586_V3) { | 199 | if (id == MAX1586_V3) { |
@@ -207,33 +207,18 @@ static int max1586_pmic_probe(struct i2c_client *client, | |||
207 | config.init_data = pdata->subdevs[i].platform_data; | 207 | config.init_data = pdata->subdevs[i].platform_data; |
208 | config.driver_data = max1586; | 208 | config.driver_data = max1586; |
209 | 209 | ||
210 | rdev[i] = regulator_register(&max1586_reg[id], &config); | 210 | rdev[i] = devm_regulator_register(&client->dev, |
211 | &max1586_reg[id], &config); | ||
211 | if (IS_ERR(rdev[i])) { | 212 | if (IS_ERR(rdev[i])) { |
212 | ret = PTR_ERR(rdev[i]); | ||
213 | dev_err(&client->dev, "failed to register %s\n", | 213 | dev_err(&client->dev, "failed to register %s\n", |
214 | max1586_reg[id].name); | 214 | max1586_reg[id].name); |
215 | goto err; | 215 | return PTR_ERR(rdev[i]); |
216 | } | 216 | } |
217 | } | 217 | } |
218 | 218 | ||
219 | i2c_set_clientdata(client, max1586); | 219 | i2c_set_clientdata(client, max1586); |
220 | dev_info(&client->dev, "Maxim 1586 regulator driver loaded\n"); | 220 | dev_info(&client->dev, "Maxim 1586 regulator driver loaded\n"); |
221 | return 0; | 221 | return 0; |
222 | |||
223 | err: | ||
224 | while (--i >= 0) | ||
225 | regulator_unregister(rdev[i]); | ||
226 | return ret; | ||
227 | } | ||
228 | |||
229 | static int max1586_pmic_remove(struct i2c_client *client) | ||
230 | { | ||
231 | struct max1586_data *max1586 = i2c_get_clientdata(client); | ||
232 | int i; | ||
233 | |||
234 | for (i = 0; i <= MAX1586_V6; i++) | ||
235 | regulator_unregister(max1586->rdev[i]); | ||
236 | return 0; | ||
237 | } | 222 | } |
238 | 223 | ||
239 | static const struct i2c_device_id max1586_id[] = { | 224 | static const struct i2c_device_id max1586_id[] = { |
@@ -244,7 +229,6 @@ MODULE_DEVICE_TABLE(i2c, max1586_id); | |||
244 | 229 | ||
245 | static struct i2c_driver max1586_pmic_driver = { | 230 | static struct i2c_driver max1586_pmic_driver = { |
246 | .probe = max1586_pmic_probe, | 231 | .probe = max1586_pmic_probe, |
247 | .remove = max1586_pmic_remove, | ||
248 | .driver = { | 232 | .driver = { |
249 | .name = "max1586", | 233 | .name = "max1586", |
250 | .owner = THIS_MODULE, | 234 | .owner = THIS_MODULE, |
diff --git a/drivers/regulator/max77686.c b/drivers/regulator/max77686.c index f563057e5690..ae001ccf26f4 100644 --- a/drivers/regulator/max77686.c +++ b/drivers/regulator/max77686.c | |||
@@ -478,32 +478,16 @@ static int max77686_pmic_probe(struct platform_device *pdev) | |||
478 | config.of_node = pdata->regulators[i].of_node; | 478 | config.of_node = pdata->regulators[i].of_node; |
479 | 479 | ||
480 | max77686->opmode[i] = regulators[i].enable_mask; | 480 | max77686->opmode[i] = regulators[i].enable_mask; |
481 | max77686->rdev[i] = regulator_register(®ulators[i], &config); | 481 | max77686->rdev[i] = devm_regulator_register(&pdev->dev, |
482 | ®ulators[i], &config); | ||
482 | if (IS_ERR(max77686->rdev[i])) { | 483 | if (IS_ERR(max77686->rdev[i])) { |
483 | ret = PTR_ERR(max77686->rdev[i]); | ||
484 | dev_err(&pdev->dev, | 484 | dev_err(&pdev->dev, |
485 | "regulator init failed for %d\n", i); | 485 | "regulator init failed for %d\n", i); |
486 | max77686->rdev[i] = NULL; | 486 | return PTR_ERR(max77686->rdev[i]); |
487 | goto err; | ||
488 | } | 487 | } |
489 | } | 488 | } |
490 | 489 | ||
491 | return 0; | 490 | return 0; |
492 | err: | ||
493 | while (--i >= 0) | ||
494 | regulator_unregister(max77686->rdev[i]); | ||
495 | return ret; | ||
496 | } | ||
497 | |||
498 | static int max77686_pmic_remove(struct platform_device *pdev) | ||
499 | { | ||
500 | struct max77686_data *max77686 = platform_get_drvdata(pdev); | ||
501 | int i; | ||
502 | |||
503 | for (i = 0; i < MAX77686_REGULATORS; i++) | ||
504 | regulator_unregister(max77686->rdev[i]); | ||
505 | |||
506 | return 0; | ||
507 | } | 491 | } |
508 | 492 | ||
509 | static const struct platform_device_id max77686_pmic_id[] = { | 493 | static const struct platform_device_id max77686_pmic_id[] = { |
@@ -518,7 +502,6 @@ static struct platform_driver max77686_pmic_driver = { | |||
518 | .owner = THIS_MODULE, | 502 | .owner = THIS_MODULE, |
519 | }, | 503 | }, |
520 | .probe = max77686_pmic_probe, | 504 | .probe = max77686_pmic_probe, |
521 | .remove = max77686_pmic_remove, | ||
522 | .id_table = max77686_pmic_id, | 505 | .id_table = max77686_pmic_id, |
523 | }; | 506 | }; |
524 | 507 | ||
diff --git a/drivers/regulator/max77693.c b/drivers/regulator/max77693.c index ce4b96c15eba..feb20bf4ccab 100644 --- a/drivers/regulator/max77693.c +++ b/drivers/regulator/max77693.c | |||
@@ -230,7 +230,7 @@ static int max77693_pmic_probe(struct platform_device *pdev) | |||
230 | struct max77693_dev *iodev = dev_get_drvdata(pdev->dev.parent); | 230 | struct max77693_dev *iodev = dev_get_drvdata(pdev->dev.parent); |
231 | struct max77693_pmic_dev *max77693_pmic; | 231 | struct max77693_pmic_dev *max77693_pmic; |
232 | struct max77693_regulator_data *rdata = NULL; | 232 | struct max77693_regulator_data *rdata = NULL; |
233 | int num_rdata, i, ret; | 233 | int num_rdata, i; |
234 | struct regulator_config config; | 234 | struct regulator_config config; |
235 | 235 | ||
236 | num_rdata = max77693_pmic_init_rdata(&pdev->dev, &rdata); | 236 | num_rdata = max77693_pmic_init_rdata(&pdev->dev, &rdata); |
@@ -266,36 +266,16 @@ static int max77693_pmic_probe(struct platform_device *pdev) | |||
266 | config.init_data = rdata[i].initdata; | 266 | config.init_data = rdata[i].initdata; |
267 | config.of_node = rdata[i].of_node; | 267 | config.of_node = rdata[i].of_node; |
268 | 268 | ||
269 | max77693_pmic->rdev[i] = regulator_register(®ulators[id], | 269 | max77693_pmic->rdev[i] = devm_regulator_register(&pdev->dev, |
270 | &config); | 270 | ®ulators[id], &config); |
271 | if (IS_ERR(max77693_pmic->rdev[i])) { | 271 | if (IS_ERR(max77693_pmic->rdev[i])) { |
272 | ret = PTR_ERR(max77693_pmic->rdev[i]); | ||
273 | dev_err(max77693_pmic->dev, | 272 | dev_err(max77693_pmic->dev, |
274 | "Failed to initialize regulator-%d\n", id); | 273 | "Failed to initialize regulator-%d\n", id); |
275 | max77693_pmic->rdev[i] = NULL; | 274 | return PTR_ERR(max77693_pmic->rdev[i]); |
276 | goto err; | ||
277 | } | 275 | } |
278 | } | 276 | } |
279 | 277 | ||
280 | return 0; | 278 | return 0; |
281 | err: | ||
282 | while (--i >= 0) | ||
283 | regulator_unregister(max77693_pmic->rdev[i]); | ||
284 | |||
285 | return ret; | ||
286 | } | ||
287 | |||
288 | static int max77693_pmic_remove(struct platform_device *pdev) | ||
289 | { | ||
290 | struct max77693_pmic_dev *max77693_pmic = platform_get_drvdata(pdev); | ||
291 | struct regulator_dev **rdev = max77693_pmic->rdev; | ||
292 | int i; | ||
293 | |||
294 | for (i = 0; i < max77693_pmic->num_regulators; i++) | ||
295 | if (rdev[i]) | ||
296 | regulator_unregister(rdev[i]); | ||
297 | |||
298 | return 0; | ||
299 | } | 279 | } |
300 | 280 | ||
301 | static const struct platform_device_id max77693_pmic_id[] = { | 281 | static const struct platform_device_id max77693_pmic_id[] = { |
@@ -311,7 +291,6 @@ static struct platform_driver max77693_pmic_driver = { | |||
311 | .owner = THIS_MODULE, | 291 | .owner = THIS_MODULE, |
312 | }, | 292 | }, |
313 | .probe = max77693_pmic_probe, | 293 | .probe = max77693_pmic_probe, |
314 | .remove = max77693_pmic_remove, | ||
315 | .id_table = max77693_pmic_id, | 294 | .id_table = max77693_pmic_id, |
316 | }; | 295 | }; |
317 | 296 | ||
diff --git a/drivers/regulator/max8649.c b/drivers/regulator/max8649.c index 19c6f08eafd5..7f049c92ee52 100644 --- a/drivers/regulator/max8649.c +++ b/drivers/regulator/max8649.c | |||
@@ -234,7 +234,8 @@ static int max8649_regulator_probe(struct i2c_client *client, | |||
234 | config.driver_data = info; | 234 | config.driver_data = info; |
235 | config.regmap = info->regmap; | 235 | config.regmap = info->regmap; |
236 | 236 | ||
237 | info->regulator = regulator_register(&dcdc_desc, &config); | 237 | info->regulator = devm_regulator_register(&client->dev, &dcdc_desc, |
238 | &config); | ||
238 | if (IS_ERR(info->regulator)) { | 239 | if (IS_ERR(info->regulator)) { |
239 | dev_err(info->dev, "failed to register regulator %s\n", | 240 | dev_err(info->dev, "failed to register regulator %s\n", |
240 | dcdc_desc.name); | 241 | dcdc_desc.name); |
@@ -244,16 +245,6 @@ static int max8649_regulator_probe(struct i2c_client *client, | |||
244 | return 0; | 245 | return 0; |
245 | } | 246 | } |
246 | 247 | ||
247 | static int max8649_regulator_remove(struct i2c_client *client) | ||
248 | { | ||
249 | struct max8649_regulator_info *info = i2c_get_clientdata(client); | ||
250 | |||
251 | if (info) | ||
252 | regulator_unregister(info->regulator); | ||
253 | |||
254 | return 0; | ||
255 | } | ||
256 | |||
257 | static const struct i2c_device_id max8649_id[] = { | 248 | static const struct i2c_device_id max8649_id[] = { |
258 | { "max8649", 0 }, | 249 | { "max8649", 0 }, |
259 | { } | 250 | { } |
@@ -262,7 +253,6 @@ MODULE_DEVICE_TABLE(i2c, max8649_id); | |||
262 | 253 | ||
263 | static struct i2c_driver max8649_driver = { | 254 | static struct i2c_driver max8649_driver = { |
264 | .probe = max8649_regulator_probe, | 255 | .probe = max8649_regulator_probe, |
265 | .remove = max8649_regulator_remove, | ||
266 | .driver = { | 256 | .driver = { |
267 | .name = "max8649", | 257 | .name = "max8649", |
268 | }, | 258 | }, |
diff --git a/drivers/regulator/max8660.c b/drivers/regulator/max8660.c index 144bcacd734d..8d94d3d7f97f 100644 --- a/drivers/regulator/max8660.c +++ b/drivers/regulator/max8660.c | |||
@@ -439,7 +439,7 @@ static int max8660_probe(struct i2c_client *client, | |||
439 | for (i = 0; i < pdata->num_subdevs; i++) { | 439 | for (i = 0; i < pdata->num_subdevs; i++) { |
440 | 440 | ||
441 | if (!pdata->subdevs[i].platform_data) | 441 | if (!pdata->subdevs[i].platform_data) |
442 | goto err_out; | 442 | return ret; |
443 | 443 | ||
444 | boot_on = pdata->subdevs[i].platform_data->constraints.boot_on; | 444 | boot_on = pdata->subdevs[i].platform_data->constraints.boot_on; |
445 | 445 | ||
@@ -465,7 +465,7 @@ static int max8660_probe(struct i2c_client *client, | |||
465 | case MAX8660_V7: | 465 | case MAX8660_V7: |
466 | if (type == MAX8661) { | 466 | if (type == MAX8661) { |
467 | dev_err(dev, "Regulator not on this chip!\n"); | 467 | dev_err(dev, "Regulator not on this chip!\n"); |
468 | goto err_out; | 468 | return -EINVAL; |
469 | } | 469 | } |
470 | 470 | ||
471 | if (boot_on) | 471 | if (boot_on) |
@@ -475,7 +475,7 @@ static int max8660_probe(struct i2c_client *client, | |||
475 | default: | 475 | default: |
476 | dev_err(dev, "invalid regulator %s\n", | 476 | dev_err(dev, "invalid regulator %s\n", |
477 | pdata->subdevs[i].name); | 477 | pdata->subdevs[i].name); |
478 | goto err_out; | 478 | return ret; |
479 | } | 479 | } |
480 | } | 480 | } |
481 | 481 | ||
@@ -489,33 +489,18 @@ static int max8660_probe(struct i2c_client *client, | |||
489 | config.of_node = of_node[i]; | 489 | config.of_node = of_node[i]; |
490 | config.driver_data = max8660; | 490 | config.driver_data = max8660; |
491 | 491 | ||
492 | rdev[i] = regulator_register(&max8660_reg[id], &config); | 492 | rdev[i] = devm_regulator_register(&client->dev, |
493 | &max8660_reg[id], &config); | ||
493 | if (IS_ERR(rdev[i])) { | 494 | if (IS_ERR(rdev[i])) { |
494 | ret = PTR_ERR(rdev[i]); | 495 | ret = PTR_ERR(rdev[i]); |
495 | dev_err(dev, "failed to register %s\n", | 496 | dev_err(&client->dev, "failed to register %s\n", |
496 | max8660_reg[id].name); | 497 | max8660_reg[id].name); |
497 | goto err_unregister; | 498 | return PTR_ERR(rdev[i]); |
498 | } | 499 | } |
499 | } | 500 | } |
500 | 501 | ||
501 | i2c_set_clientdata(client, max8660); | 502 | i2c_set_clientdata(client, max8660); |
502 | return 0; | 503 | return 0; |
503 | |||
504 | err_unregister: | ||
505 | while (--i >= 0) | ||
506 | regulator_unregister(rdev[i]); | ||
507 | err_out: | ||
508 | return ret; | ||
509 | } | ||
510 | |||
511 | static int max8660_remove(struct i2c_client *client) | ||
512 | { | ||
513 | struct max8660 *max8660 = i2c_get_clientdata(client); | ||
514 | int i; | ||
515 | |||
516 | for (i = 0; i < MAX8660_V_END; i++) | ||
517 | regulator_unregister(max8660->rdev[i]); | ||
518 | return 0; | ||
519 | } | 504 | } |
520 | 505 | ||
521 | static const struct i2c_device_id max8660_id[] = { | 506 | static const struct i2c_device_id max8660_id[] = { |
@@ -527,7 +512,6 @@ MODULE_DEVICE_TABLE(i2c, max8660_id); | |||
527 | 512 | ||
528 | static struct i2c_driver max8660_driver = { | 513 | static struct i2c_driver max8660_driver = { |
529 | .probe = max8660_probe, | 514 | .probe = max8660_probe, |
530 | .remove = max8660_remove, | ||
531 | .driver = { | 515 | .driver = { |
532 | .name = "max8660", | 516 | .name = "max8660", |
533 | .owner = THIS_MODULE, | 517 | .owner = THIS_MODULE, |
diff --git a/drivers/regulator/max8907-regulator.c b/drivers/regulator/max8907-regulator.c index 4568c15fa78d..0c5fe6c6ac26 100644 --- a/drivers/regulator/max8907-regulator.c +++ b/drivers/regulator/max8907-regulator.c | |||
@@ -350,33 +350,17 @@ static int max8907_regulator_probe(struct platform_device *pdev) | |||
350 | pmic->desc[i].ops = &max8907_out5v_hwctl_ops; | 350 | pmic->desc[i].ops = &max8907_out5v_hwctl_ops; |
351 | } | 351 | } |
352 | 352 | ||
353 | pmic->rdev[i] = regulator_register(&pmic->desc[i], &config); | 353 | pmic->rdev[i] = devm_regulator_register(&pdev->dev, |
354 | &pmic->desc[i], &config); | ||
354 | if (IS_ERR(pmic->rdev[i])) { | 355 | if (IS_ERR(pmic->rdev[i])) { |
355 | dev_err(&pdev->dev, | 356 | dev_err(&pdev->dev, |
356 | "failed to register %s regulator\n", | 357 | "failed to register %s regulator\n", |
357 | pmic->desc[i].name); | 358 | pmic->desc[i].name); |
358 | ret = PTR_ERR(pmic->rdev[i]); | 359 | return PTR_ERR(pmic->rdev[i]); |
359 | goto err_unregister_regulator; | ||
360 | } | 360 | } |
361 | } | 361 | } |
362 | 362 | ||
363 | return 0; | 363 | return 0; |
364 | |||
365 | err_unregister_regulator: | ||
366 | while (--i >= 0) | ||
367 | regulator_unregister(pmic->rdev[i]); | ||
368 | return ret; | ||
369 | } | ||
370 | |||
371 | static int max8907_regulator_remove(struct platform_device *pdev) | ||
372 | { | ||
373 | struct max8907_regulator *pmic = platform_get_drvdata(pdev); | ||
374 | int i; | ||
375 | |||
376 | for (i = 0; i < MAX8907_NUM_REGULATORS; i++) | ||
377 | regulator_unregister(pmic->rdev[i]); | ||
378 | |||
379 | return 0; | ||
380 | } | 364 | } |
381 | 365 | ||
382 | static struct platform_driver max8907_regulator_driver = { | 366 | static struct platform_driver max8907_regulator_driver = { |
@@ -385,7 +369,6 @@ static struct platform_driver max8907_regulator_driver = { | |||
385 | .owner = THIS_MODULE, | 369 | .owner = THIS_MODULE, |
386 | }, | 370 | }, |
387 | .probe = max8907_regulator_probe, | 371 | .probe = max8907_regulator_probe, |
388 | .remove = max8907_regulator_remove, | ||
389 | }; | 372 | }; |
390 | 373 | ||
391 | static int __init max8907_regulator_init(void) | 374 | static int __init max8907_regulator_init(void) |
diff --git a/drivers/regulator/max8925-regulator.c b/drivers/regulator/max8925-regulator.c index d80b5fa758ae..759510789e71 100644 --- a/drivers/regulator/max8925-regulator.c +++ b/drivers/regulator/max8925-regulator.c | |||
@@ -312,7 +312,7 @@ static int max8925_regulator_probe(struct platform_device *pdev) | |||
312 | if (pdata) | 312 | if (pdata) |
313 | config.init_data = pdata; | 313 | config.init_data = pdata; |
314 | 314 | ||
315 | rdev = regulator_register(&ri->desc, &config); | 315 | rdev = devm_regulator_register(&pdev->dev, &ri->desc, &config); |
316 | if (IS_ERR(rdev)) { | 316 | if (IS_ERR(rdev)) { |
317 | dev_err(&pdev->dev, "failed to register regulator %s\n", | 317 | dev_err(&pdev->dev, "failed to register regulator %s\n", |
318 | ri->desc.name); | 318 | ri->desc.name); |
@@ -323,22 +323,12 @@ static int max8925_regulator_probe(struct platform_device *pdev) | |||
323 | return 0; | 323 | return 0; |
324 | } | 324 | } |
325 | 325 | ||
326 | static int max8925_regulator_remove(struct platform_device *pdev) | ||
327 | { | ||
328 | struct regulator_dev *rdev = platform_get_drvdata(pdev); | ||
329 | |||
330 | regulator_unregister(rdev); | ||
331 | |||
332 | return 0; | ||
333 | } | ||
334 | |||
335 | static struct platform_driver max8925_regulator_driver = { | 326 | static struct platform_driver max8925_regulator_driver = { |
336 | .driver = { | 327 | .driver = { |
337 | .name = "max8925-regulator", | 328 | .name = "max8925-regulator", |
338 | .owner = THIS_MODULE, | 329 | .owner = THIS_MODULE, |
339 | }, | 330 | }, |
340 | .probe = max8925_regulator_probe, | 331 | .probe = max8925_regulator_probe, |
341 | .remove = max8925_regulator_remove, | ||
342 | }; | 332 | }; |
343 | 333 | ||
344 | static int __init max8925_regulator_init(void) | 334 | static int __init max8925_regulator_init(void) |
diff --git a/drivers/regulator/max8973-regulator.c b/drivers/regulator/max8973-regulator.c index 5b77ab7762e4..892aa1e5b96c 100644 --- a/drivers/regulator/max8973-regulator.c +++ b/drivers/regulator/max8973-regulator.c | |||
@@ -467,7 +467,7 @@ static int max8973_probe(struct i2c_client *client, | |||
467 | config.regmap = max->regmap; | 467 | config.regmap = max->regmap; |
468 | 468 | ||
469 | /* Register the regulators */ | 469 | /* Register the regulators */ |
470 | rdev = regulator_register(&max->desc, &config); | 470 | rdev = devm_regulator_register(&client->dev, &max->desc, &config); |
471 | if (IS_ERR(rdev)) { | 471 | if (IS_ERR(rdev)) { |
472 | ret = PTR_ERR(rdev); | 472 | ret = PTR_ERR(rdev); |
473 | dev_err(max->dev, "regulator register failed, err %d\n", ret); | 473 | dev_err(max->dev, "regulator register failed, err %d\n", ret); |
@@ -478,14 +478,6 @@ static int max8973_probe(struct i2c_client *client, | |||
478 | return 0; | 478 | return 0; |
479 | } | 479 | } |
480 | 480 | ||
481 | static int max8973_remove(struct i2c_client *client) | ||
482 | { | ||
483 | struct max8973_chip *max = i2c_get_clientdata(client); | ||
484 | |||
485 | regulator_unregister(max->rdev); | ||
486 | return 0; | ||
487 | } | ||
488 | |||
489 | static const struct i2c_device_id max8973_id[] = { | 481 | static const struct i2c_device_id max8973_id[] = { |
490 | {.name = "max8973",}, | 482 | {.name = "max8973",}, |
491 | {}, | 483 | {}, |
@@ -499,7 +491,6 @@ static struct i2c_driver max8973_i2c_driver = { | |||
499 | .owner = THIS_MODULE, | 491 | .owner = THIS_MODULE, |
500 | }, | 492 | }, |
501 | .probe = max8973_probe, | 493 | .probe = max8973_probe, |
502 | .remove = max8973_remove, | ||
503 | .id_table = max8973_id, | 494 | .id_table = max8973_id, |
504 | }; | 495 | }; |
505 | 496 | ||
diff --git a/drivers/regulator/max8997.c b/drivers/regulator/max8997.c index df20069f0537..2d618fc9c1af 100644 --- a/drivers/regulator/max8997.c +++ b/drivers/regulator/max8997.c | |||
@@ -690,8 +690,9 @@ static int max8997_set_voltage_buck(struct regulator_dev *rdev, | |||
690 | if (max8997->ignore_gpiodvs_side_effect == false) | 690 | if (max8997->ignore_gpiodvs_side_effect == false) |
691 | return -EINVAL; | 691 | return -EINVAL; |
692 | 692 | ||
693 | dev_warn(&rdev->dev, "MAX8997 GPIO-DVS Side Effect Warning: GPIO SET:" | 693 | dev_warn(&rdev->dev, |
694 | " %d -> %d\n", max8997->buck125_gpioindex, tmp_idx); | 694 | "MAX8997 GPIO-DVS Side Effect Warning: GPIO SET: %d -> %d\n", |
695 | max8997->buck125_gpioindex, tmp_idx); | ||
695 | 696 | ||
696 | out: | 697 | out: |
697 | if (new_idx < 0 || new_val < 0) | 698 | if (new_idx < 0 || new_val < 0) |
@@ -1081,7 +1082,7 @@ static int max8997_pmic_probe(struct platform_device *pdev) | |||
1081 | pdata->buck1_voltage[i] + | 1082 | pdata->buck1_voltage[i] + |
1082 | buck1245_voltage_map_desc.step); | 1083 | buck1245_voltage_map_desc.step); |
1083 | if (ret < 0) | 1084 | if (ret < 0) |
1084 | goto err_out; | 1085 | return ret; |
1085 | 1086 | ||
1086 | max8997->buck2_vol[i] = ret = | 1087 | max8997->buck2_vol[i] = ret = |
1087 | max8997_get_voltage_proper_val( | 1088 | max8997_get_voltage_proper_val( |
@@ -1090,7 +1091,7 @@ static int max8997_pmic_probe(struct platform_device *pdev) | |||
1090 | pdata->buck2_voltage[i] + | 1091 | pdata->buck2_voltage[i] + |
1091 | buck1245_voltage_map_desc.step); | 1092 | buck1245_voltage_map_desc.step); |
1092 | if (ret < 0) | 1093 | if (ret < 0) |
1093 | goto err_out; | 1094 | return ret; |
1094 | 1095 | ||
1095 | max8997->buck5_vol[i] = ret = | 1096 | max8997->buck5_vol[i] = ret = |
1096 | max8997_get_voltage_proper_val( | 1097 | max8997_get_voltage_proper_val( |
@@ -1099,7 +1100,7 @@ static int max8997_pmic_probe(struct platform_device *pdev) | |||
1099 | pdata->buck5_voltage[i] + | 1100 | pdata->buck5_voltage[i] + |
1100 | buck1245_voltage_map_desc.step); | 1101 | buck1245_voltage_map_desc.step); |
1101 | if (ret < 0) | 1102 | if (ret < 0) |
1102 | goto err_out; | 1103 | return ret; |
1103 | 1104 | ||
1104 | if (max_buck1 < max8997->buck1_vol[i]) | 1105 | if (max_buck1 < max8997->buck1_vol[i]) |
1105 | max_buck1 = max8997->buck1_vol[i]; | 1106 | max_buck1 = max8997->buck1_vol[i]; |
@@ -1143,24 +1144,23 @@ static int max8997_pmic_probe(struct platform_device *pdev) | |||
1143 | !gpio_is_valid(pdata->buck125_gpios[1]) || | 1144 | !gpio_is_valid(pdata->buck125_gpios[1]) || |
1144 | !gpio_is_valid(pdata->buck125_gpios[2])) { | 1145 | !gpio_is_valid(pdata->buck125_gpios[2])) { |
1145 | dev_err(&pdev->dev, "GPIO NOT VALID\n"); | 1146 | dev_err(&pdev->dev, "GPIO NOT VALID\n"); |
1146 | ret = -EINVAL; | 1147 | return -EINVAL; |
1147 | goto err_out; | ||
1148 | } | 1148 | } |
1149 | 1149 | ||
1150 | ret = devm_gpio_request(&pdev->dev, pdata->buck125_gpios[0], | 1150 | ret = devm_gpio_request(&pdev->dev, pdata->buck125_gpios[0], |
1151 | "MAX8997 SET1"); | 1151 | "MAX8997 SET1"); |
1152 | if (ret) | 1152 | if (ret) |
1153 | goto err_out; | 1153 | return ret; |
1154 | 1154 | ||
1155 | ret = devm_gpio_request(&pdev->dev, pdata->buck125_gpios[1], | 1155 | ret = devm_gpio_request(&pdev->dev, pdata->buck125_gpios[1], |
1156 | "MAX8997 SET2"); | 1156 | "MAX8997 SET2"); |
1157 | if (ret) | 1157 | if (ret) |
1158 | goto err_out; | 1158 | return ret; |
1159 | 1159 | ||
1160 | ret = devm_gpio_request(&pdev->dev, pdata->buck125_gpios[2], | 1160 | ret = devm_gpio_request(&pdev->dev, pdata->buck125_gpios[2], |
1161 | "MAX8997 SET3"); | 1161 | "MAX8997 SET3"); |
1162 | if (ret) | 1162 | if (ret) |
1163 | goto err_out; | 1163 | return ret; |
1164 | 1164 | ||
1165 | gpio_direction_output(pdata->buck125_gpios[0], | 1165 | gpio_direction_output(pdata->buck125_gpios[0], |
1166 | (max8997->buck125_gpioindex >> 2) | 1166 | (max8997->buck125_gpioindex >> 2) |
@@ -1205,33 +1205,16 @@ static int max8997_pmic_probe(struct platform_device *pdev) | |||
1205 | config.driver_data = max8997; | 1205 | config.driver_data = max8997; |
1206 | config.of_node = pdata->regulators[i].reg_node; | 1206 | config.of_node = pdata->regulators[i].reg_node; |
1207 | 1207 | ||
1208 | rdev[i] = regulator_register(®ulators[id], &config); | 1208 | rdev[i] = devm_regulator_register(&pdev->dev, ®ulators[id], |
1209 | &config); | ||
1209 | if (IS_ERR(rdev[i])) { | 1210 | if (IS_ERR(rdev[i])) { |
1210 | ret = PTR_ERR(rdev[i]); | ||
1211 | dev_err(max8997->dev, "regulator init failed for %d\n", | 1211 | dev_err(max8997->dev, "regulator init failed for %d\n", |
1212 | id); | 1212 | id); |
1213 | rdev[i] = NULL; | 1213 | return PTR_ERR(rdev[i]); |
1214 | goto err; | ||
1215 | } | 1214 | } |
1216 | } | 1215 | } |
1217 | 1216 | ||
1218 | return 0; | 1217 | return 0; |
1219 | err: | ||
1220 | while (--i >= 0) | ||
1221 | regulator_unregister(rdev[i]); | ||
1222 | err_out: | ||
1223 | return ret; | ||
1224 | } | ||
1225 | |||
1226 | static int max8997_pmic_remove(struct platform_device *pdev) | ||
1227 | { | ||
1228 | struct max8997_data *max8997 = platform_get_drvdata(pdev); | ||
1229 | struct regulator_dev **rdev = max8997->rdev; | ||
1230 | int i; | ||
1231 | |||
1232 | for (i = 0; i < max8997->num_regulators; i++) | ||
1233 | regulator_unregister(rdev[i]); | ||
1234 | return 0; | ||
1235 | } | 1218 | } |
1236 | 1219 | ||
1237 | static const struct platform_device_id max8997_pmic_id[] = { | 1220 | static const struct platform_device_id max8997_pmic_id[] = { |
@@ -1246,7 +1229,6 @@ static struct platform_driver max8997_pmic_driver = { | |||
1246 | .owner = THIS_MODULE, | 1229 | .owner = THIS_MODULE, |
1247 | }, | 1230 | }, |
1248 | .probe = max8997_pmic_probe, | 1231 | .probe = max8997_pmic_probe, |
1249 | .remove = max8997_pmic_remove, | ||
1250 | .id_table = max8997_pmic_id, | 1232 | .id_table = max8997_pmic_id, |
1251 | }; | 1233 | }; |
1252 | 1234 | ||
diff --git a/drivers/regulator/max8998.c b/drivers/regulator/max8998.c index a4c53b2d1aaf..ae3f0656feb0 100644 --- a/drivers/regulator/max8998.c +++ b/drivers/regulator/max8998.c | |||
@@ -790,16 +790,14 @@ static int max8998_pmic_probe(struct platform_device *pdev) | |||
790 | dev_err(&pdev->dev, | 790 | dev_err(&pdev->dev, |
791 | "MAX8998 SET1 GPIO defined as 0 !\n"); | 791 | "MAX8998 SET1 GPIO defined as 0 !\n"); |
792 | WARN_ON(!pdata->buck1_set1); | 792 | WARN_ON(!pdata->buck1_set1); |
793 | ret = -EIO; | 793 | return -EIO; |
794 | goto err_out; | ||
795 | } | 794 | } |
796 | /* Check if SET2 is not equal to 0 */ | 795 | /* Check if SET2 is not equal to 0 */ |
797 | if (!pdata->buck1_set2) { | 796 | if (!pdata->buck1_set2) { |
798 | dev_err(&pdev->dev, | 797 | dev_err(&pdev->dev, |
799 | "MAX8998 SET2 GPIO defined as 0 !\n"); | 798 | "MAX8998 SET2 GPIO defined as 0 !\n"); |
800 | WARN_ON(!pdata->buck1_set2); | 799 | WARN_ON(!pdata->buck1_set2); |
801 | ret = -EIO; | 800 | return -EIO; |
802 | goto err_out; | ||
803 | } | 801 | } |
804 | 802 | ||
805 | gpio_request(pdata->buck1_set1, "MAX8998 BUCK1_SET1"); | 803 | gpio_request(pdata->buck1_set1, "MAX8998 BUCK1_SET1"); |
@@ -823,7 +821,7 @@ static int max8998_pmic_probe(struct platform_device *pdev) | |||
823 | ret = max8998_write_reg(i2c, | 821 | ret = max8998_write_reg(i2c, |
824 | MAX8998_REG_BUCK1_VOLTAGE1 + v, i); | 822 | MAX8998_REG_BUCK1_VOLTAGE1 + v, i); |
825 | if (ret) | 823 | if (ret) |
826 | goto err_out; | 824 | return ret; |
827 | } | 825 | } |
828 | } | 826 | } |
829 | 827 | ||
@@ -833,8 +831,7 @@ static int max8998_pmic_probe(struct platform_device *pdev) | |||
833 | dev_err(&pdev->dev, | 831 | dev_err(&pdev->dev, |
834 | "MAX8998 SET3 GPIO defined as 0 !\n"); | 832 | "MAX8998 SET3 GPIO defined as 0 !\n"); |
835 | WARN_ON(!pdata->buck2_set3); | 833 | WARN_ON(!pdata->buck2_set3); |
836 | ret = -EIO; | 834 | return -EIO; |
837 | goto err_out; | ||
838 | } | 835 | } |
839 | gpio_request(pdata->buck2_set3, "MAX8998 BUCK2_SET3"); | 836 | gpio_request(pdata->buck2_set3, "MAX8998 BUCK2_SET3"); |
840 | gpio_direction_output(pdata->buck2_set3, | 837 | gpio_direction_output(pdata->buck2_set3, |
@@ -852,7 +849,7 @@ static int max8998_pmic_probe(struct platform_device *pdev) | |||
852 | ret = max8998_write_reg(i2c, | 849 | ret = max8998_write_reg(i2c, |
853 | MAX8998_REG_BUCK2_VOLTAGE1 + v, i); | 850 | MAX8998_REG_BUCK2_VOLTAGE1 + v, i); |
854 | if (ret) | 851 | if (ret) |
855 | goto err_out; | 852 | return ret; |
856 | } | 853 | } |
857 | } | 854 | } |
858 | 855 | ||
@@ -875,34 +872,19 @@ static int max8998_pmic_probe(struct platform_device *pdev) | |||
875 | config.init_data = pdata->regulators[i].initdata; | 872 | config.init_data = pdata->regulators[i].initdata; |
876 | config.driver_data = max8998; | 873 | config.driver_data = max8998; |
877 | 874 | ||
878 | rdev[i] = regulator_register(®ulators[index], &config); | 875 | rdev[i] = devm_regulator_register(&pdev->dev, |
876 | ®ulators[index], &config); | ||
879 | if (IS_ERR(rdev[i])) { | 877 | if (IS_ERR(rdev[i])) { |
880 | ret = PTR_ERR(rdev[i]); | 878 | ret = PTR_ERR(rdev[i]); |
881 | dev_err(max8998->dev, "regulator %s init failed (%d)\n", | 879 | dev_err(max8998->dev, "regulator %s init failed (%d)\n", |
882 | regulators[index].name, ret); | 880 | regulators[index].name, ret); |
883 | rdev[i] = NULL; | 881 | rdev[i] = NULL; |
884 | goto err; | 882 | return ret; |
885 | } | 883 | } |
886 | } | 884 | } |
887 | 885 | ||
888 | 886 | ||
889 | return 0; | 887 | return 0; |
890 | err: | ||
891 | while (--i >= 0) | ||
892 | regulator_unregister(rdev[i]); | ||
893 | err_out: | ||
894 | return ret; | ||
895 | } | ||
896 | |||
897 | static int max8998_pmic_remove(struct platform_device *pdev) | ||
898 | { | ||
899 | struct max8998_data *max8998 = platform_get_drvdata(pdev); | ||
900 | struct regulator_dev **rdev = max8998->rdev; | ||
901 | int i; | ||
902 | |||
903 | for (i = 0; i < max8998->num_regulators; i++) | ||
904 | regulator_unregister(rdev[i]); | ||
905 | return 0; | ||
906 | } | 888 | } |
907 | 889 | ||
908 | static const struct platform_device_id max8998_pmic_id[] = { | 890 | static const struct platform_device_id max8998_pmic_id[] = { |
@@ -918,7 +900,6 @@ static struct platform_driver max8998_pmic_driver = { | |||
918 | .owner = THIS_MODULE, | 900 | .owner = THIS_MODULE, |
919 | }, | 901 | }, |
920 | .probe = max8998_pmic_probe, | 902 | .probe = max8998_pmic_probe, |
921 | .remove = max8998_pmic_remove, | ||
922 | .id_table = max8998_pmic_id, | 903 | .id_table = max8998_pmic_id, |
923 | }; | 904 | }; |
924 | 905 | ||
diff --git a/drivers/regulator/mc13783-regulator.c b/drivers/regulator/mc13783-regulator.c index 5ff99d2703db..7f4a67edf780 100644 --- a/drivers/regulator/mc13783-regulator.c +++ b/drivers/regulator/mc13783-regulator.c | |||
@@ -258,34 +258,34 @@ static struct mc13xxx_regulator mc13783_regulators[] = { | |||
258 | 258 | ||
259 | MC13783_FIXED_DEFINE(REG, VAUDIO, REGULATORMODE0, mc13783_vaudio_val), | 259 | MC13783_FIXED_DEFINE(REG, VAUDIO, REGULATORMODE0, mc13783_vaudio_val), |
260 | MC13783_FIXED_DEFINE(REG, VIOHI, REGULATORMODE0, mc13783_viohi_val), | 260 | MC13783_FIXED_DEFINE(REG, VIOHI, REGULATORMODE0, mc13783_viohi_val), |
261 | MC13783_DEFINE_REGU(VIOLO, REGULATORMODE0, REGULATORSETTING0, \ | 261 | MC13783_DEFINE_REGU(VIOLO, REGULATORMODE0, REGULATORSETTING0, |
262 | mc13783_violo_val), | 262 | mc13783_violo_val), |
263 | MC13783_DEFINE_REGU(VDIG, REGULATORMODE0, REGULATORSETTING0, \ | 263 | MC13783_DEFINE_REGU(VDIG, REGULATORMODE0, REGULATORSETTING0, |
264 | mc13783_vdig_val), | 264 | mc13783_vdig_val), |
265 | MC13783_DEFINE_REGU(VGEN, REGULATORMODE0, REGULATORSETTING0, \ | 265 | MC13783_DEFINE_REGU(VGEN, REGULATORMODE0, REGULATORSETTING0, |
266 | mc13783_vgen_val), | 266 | mc13783_vgen_val), |
267 | MC13783_DEFINE_REGU(VRFDIG, REGULATORMODE0, REGULATORSETTING0, \ | 267 | MC13783_DEFINE_REGU(VRFDIG, REGULATORMODE0, REGULATORSETTING0, |
268 | mc13783_vrfdig_val), | 268 | mc13783_vrfdig_val), |
269 | MC13783_DEFINE_REGU(VRFREF, REGULATORMODE0, REGULATORSETTING0, \ | 269 | MC13783_DEFINE_REGU(VRFREF, REGULATORMODE0, REGULATORSETTING0, |
270 | mc13783_vrfref_val), | 270 | mc13783_vrfref_val), |
271 | MC13783_DEFINE_REGU(VRFCP, REGULATORMODE0, REGULATORSETTING0, \ | 271 | MC13783_DEFINE_REGU(VRFCP, REGULATORMODE0, REGULATORSETTING0, |
272 | mc13783_vrfcp_val), | 272 | mc13783_vrfcp_val), |
273 | MC13783_DEFINE_REGU(VSIM, REGULATORMODE1, REGULATORSETTING0, \ | 273 | MC13783_DEFINE_REGU(VSIM, REGULATORMODE1, REGULATORSETTING0, |
274 | mc13783_vsim_val), | 274 | mc13783_vsim_val), |
275 | MC13783_DEFINE_REGU(VESIM, REGULATORMODE1, REGULATORSETTING0, \ | 275 | MC13783_DEFINE_REGU(VESIM, REGULATORMODE1, REGULATORSETTING0, |
276 | mc13783_vesim_val), | 276 | mc13783_vesim_val), |
277 | MC13783_DEFINE_REGU(VCAM, REGULATORMODE1, REGULATORSETTING0, \ | 277 | MC13783_DEFINE_REGU(VCAM, REGULATORMODE1, REGULATORSETTING0, |
278 | mc13783_vcam_val), | 278 | mc13783_vcam_val), |
279 | MC13783_FIXED_DEFINE(REG, VRFBG, REGULATORMODE1, mc13783_vrfbg_val), | 279 | MC13783_FIXED_DEFINE(REG, VRFBG, REGULATORMODE1, mc13783_vrfbg_val), |
280 | MC13783_DEFINE_REGU(VVIB, REGULATORMODE1, REGULATORSETTING1, \ | 280 | MC13783_DEFINE_REGU(VVIB, REGULATORMODE1, REGULATORSETTING1, |
281 | mc13783_vvib_val), | 281 | mc13783_vvib_val), |
282 | MC13783_DEFINE_REGU(VRF1, REGULATORMODE1, REGULATORSETTING1, \ | 282 | MC13783_DEFINE_REGU(VRF1, REGULATORMODE1, REGULATORSETTING1, |
283 | mc13783_vrf_val), | 283 | mc13783_vrf_val), |
284 | MC13783_DEFINE_REGU(VRF2, REGULATORMODE1, REGULATORSETTING1, \ | 284 | MC13783_DEFINE_REGU(VRF2, REGULATORMODE1, REGULATORSETTING1, |
285 | mc13783_vrf_val), | 285 | mc13783_vrf_val), |
286 | MC13783_DEFINE_REGU(VMMC1, REGULATORMODE1, REGULATORSETTING1, \ | 286 | MC13783_DEFINE_REGU(VMMC1, REGULATORMODE1, REGULATORSETTING1, |
287 | mc13783_vmmc_val), | 287 | mc13783_vmmc_val), |
288 | MC13783_DEFINE_REGU(VMMC2, REGULATORMODE1, REGULATORSETTING1, \ | 288 | MC13783_DEFINE_REGU(VMMC2, REGULATORMODE1, REGULATORSETTING1, |
289 | mc13783_vmmc_val), | 289 | mc13783_vmmc_val), |
290 | MC13783_GPO_DEFINE(REG, GPO1, POWERMISC, mc13783_gpo_val), | 290 | MC13783_GPO_DEFINE(REG, GPO1, POWERMISC, mc13783_gpo_val), |
291 | MC13783_GPO_DEFINE(REG, GPO2, POWERMISC, mc13783_gpo_val), | 291 | MC13783_GPO_DEFINE(REG, GPO2, POWERMISC, mc13783_gpo_val), |
@@ -400,7 +400,7 @@ static int mc13783_regulator_probe(struct platform_device *pdev) | |||
400 | dev_get_platdata(&pdev->dev); | 400 | dev_get_platdata(&pdev->dev); |
401 | struct mc13xxx_regulator_init_data *mc13xxx_data; | 401 | struct mc13xxx_regulator_init_data *mc13xxx_data; |
402 | struct regulator_config config = { }; | 402 | struct regulator_config config = { }; |
403 | int i, ret, num_regulators; | 403 | int i, num_regulators; |
404 | 404 | ||
405 | num_regulators = mc13xxx_get_num_regulators_dt(pdev); | 405 | num_regulators = mc13xxx_get_num_regulators_dt(pdev); |
406 | 406 | ||
@@ -444,32 +444,16 @@ static int mc13783_regulator_probe(struct platform_device *pdev) | |||
444 | config.driver_data = priv; | 444 | config.driver_data = priv; |
445 | config.of_node = node; | 445 | config.of_node = node; |
446 | 446 | ||
447 | priv->regulators[i] = regulator_register(desc, &config); | 447 | priv->regulators[i] = devm_regulator_register(&pdev->dev, desc, |
448 | &config); | ||
448 | if (IS_ERR(priv->regulators[i])) { | 449 | if (IS_ERR(priv->regulators[i])) { |
449 | dev_err(&pdev->dev, "failed to register regulator %s\n", | 450 | dev_err(&pdev->dev, "failed to register regulator %s\n", |
450 | mc13783_regulators[i].desc.name); | 451 | mc13783_regulators[i].desc.name); |
451 | ret = PTR_ERR(priv->regulators[i]); | 452 | return PTR_ERR(priv->regulators[i]); |
452 | goto err; | ||
453 | } | 453 | } |
454 | } | 454 | } |
455 | 455 | ||
456 | return 0; | 456 | return 0; |
457 | err: | ||
458 | while (--i >= 0) | ||
459 | regulator_unregister(priv->regulators[i]); | ||
460 | |||
461 | return ret; | ||
462 | } | ||
463 | |||
464 | static int mc13783_regulator_remove(struct platform_device *pdev) | ||
465 | { | ||
466 | struct mc13xxx_regulator_priv *priv = platform_get_drvdata(pdev); | ||
467 | int i; | ||
468 | |||
469 | for (i = 0; i < priv->num_regulators; i++) | ||
470 | regulator_unregister(priv->regulators[i]); | ||
471 | |||
472 | return 0; | ||
473 | } | 457 | } |
474 | 458 | ||
475 | static struct platform_driver mc13783_regulator_driver = { | 459 | static struct platform_driver mc13783_regulator_driver = { |
@@ -477,7 +461,6 @@ static struct platform_driver mc13783_regulator_driver = { | |||
477 | .name = "mc13783-regulator", | 461 | .name = "mc13783-regulator", |
478 | .owner = THIS_MODULE, | 462 | .owner = THIS_MODULE, |
479 | }, | 463 | }, |
480 | .remove = mc13783_regulator_remove, | ||
481 | .probe = mc13783_regulator_probe, | 464 | .probe = mc13783_regulator_probe, |
482 | }; | 465 | }; |
483 | 466 | ||
diff --git a/drivers/regulator/mc13892-regulator.c b/drivers/regulator/mc13892-regulator.c index 1037e07937cf..96c9f80d9550 100644 --- a/drivers/regulator/mc13892-regulator.c +++ b/drivers/regulator/mc13892-regulator.c | |||
@@ -611,43 +611,27 @@ static int mc13892_regulator_probe(struct platform_device *pdev) | |||
611 | config.driver_data = priv; | 611 | config.driver_data = priv; |
612 | config.of_node = node; | 612 | config.of_node = node; |
613 | 613 | ||
614 | priv->regulators[i] = regulator_register(desc, &config); | 614 | priv->regulators[i] = devm_regulator_register(&pdev->dev, desc, |
615 | &config); | ||
615 | if (IS_ERR(priv->regulators[i])) { | 616 | if (IS_ERR(priv->regulators[i])) { |
616 | dev_err(&pdev->dev, "failed to register regulator %s\n", | 617 | dev_err(&pdev->dev, "failed to register regulator %s\n", |
617 | mc13892_regulators[i].desc.name); | 618 | mc13892_regulators[i].desc.name); |
618 | ret = PTR_ERR(priv->regulators[i]); | 619 | return PTR_ERR(priv->regulators[i]); |
619 | goto err; | ||
620 | } | 620 | } |
621 | } | 621 | } |
622 | 622 | ||
623 | return 0; | 623 | return 0; |
624 | err: | ||
625 | while (--i >= 0) | ||
626 | regulator_unregister(priv->regulators[i]); | ||
627 | return ret; | ||
628 | 624 | ||
629 | err_unlock: | 625 | err_unlock: |
630 | mc13xxx_unlock(mc13892); | 626 | mc13xxx_unlock(mc13892); |
631 | return ret; | 627 | return ret; |
632 | } | 628 | } |
633 | 629 | ||
634 | static int mc13892_regulator_remove(struct platform_device *pdev) | ||
635 | { | ||
636 | struct mc13xxx_regulator_priv *priv = platform_get_drvdata(pdev); | ||
637 | int i; | ||
638 | |||
639 | for (i = 0; i < priv->num_regulators; i++) | ||
640 | regulator_unregister(priv->regulators[i]); | ||
641 | |||
642 | return 0; | ||
643 | } | ||
644 | |||
645 | static struct platform_driver mc13892_regulator_driver = { | 630 | static struct platform_driver mc13892_regulator_driver = { |
646 | .driver = { | 631 | .driver = { |
647 | .name = "mc13892-regulator", | 632 | .name = "mc13892-regulator", |
648 | .owner = THIS_MODULE, | 633 | .owner = THIS_MODULE, |
649 | }, | 634 | }, |
650 | .remove = mc13892_regulator_remove, | ||
651 | .probe = mc13892_regulator_probe, | 635 | .probe = mc13892_regulator_probe, |
652 | }; | 636 | }; |
653 | 637 | ||
diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c index 7827384680d6..ea4f36f2cbe2 100644 --- a/drivers/regulator/of_regulator.c +++ b/drivers/regulator/of_regulator.c | |||
@@ -23,6 +23,8 @@ static void of_get_regulation_constraints(struct device_node *np, | |||
23 | const __be32 *min_uA, *max_uA, *ramp_delay; | 23 | const __be32 *min_uA, *max_uA, *ramp_delay; |
24 | struct property *prop; | 24 | struct property *prop; |
25 | struct regulation_constraints *constraints = &(*init_data)->constraints; | 25 | struct regulation_constraints *constraints = &(*init_data)->constraints; |
26 | int ret; | ||
27 | u32 pval; | ||
26 | 28 | ||
27 | constraints->name = of_get_property(np, "regulator-name", NULL); | 29 | constraints->name = of_get_property(np, "regulator-name", NULL); |
28 | 30 | ||
@@ -73,6 +75,10 @@ static void of_get_regulation_constraints(struct device_node *np, | |||
73 | else | 75 | else |
74 | constraints->ramp_disable = true; | 76 | constraints->ramp_disable = true; |
75 | } | 77 | } |
78 | |||
79 | ret = of_property_read_u32(np, "regulator-enable-ramp-delay", &pval); | ||
80 | if (!ret) | ||
81 | constraints->enable_time = pval; | ||
76 | } | 82 | } |
77 | 83 | ||
78 | /** | 84 | /** |
diff --git a/drivers/regulator/palmas-regulator.c b/drivers/regulator/palmas-regulator.c index 7e2b165972e6..9c62b1d34685 100644 --- a/drivers/regulator/palmas-regulator.c +++ b/drivers/regulator/palmas-regulator.c | |||
@@ -33,6 +33,7 @@ struct regs_info { | |||
33 | u8 vsel_addr; | 33 | u8 vsel_addr; |
34 | u8 ctrl_addr; | 34 | u8 ctrl_addr; |
35 | u8 tstep_addr; | 35 | u8 tstep_addr; |
36 | int sleep_id; | ||
36 | }; | 37 | }; |
37 | 38 | ||
38 | static const struct regs_info palmas_regs_info[] = { | 39 | static const struct regs_info palmas_regs_info[] = { |
@@ -42,6 +43,7 @@ static const struct regs_info palmas_regs_info[] = { | |||
42 | .vsel_addr = PALMAS_SMPS12_VOLTAGE, | 43 | .vsel_addr = PALMAS_SMPS12_VOLTAGE, |
43 | .ctrl_addr = PALMAS_SMPS12_CTRL, | 44 | .ctrl_addr = PALMAS_SMPS12_CTRL, |
44 | .tstep_addr = PALMAS_SMPS12_TSTEP, | 45 | .tstep_addr = PALMAS_SMPS12_TSTEP, |
46 | .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_SMPS12, | ||
45 | }, | 47 | }, |
46 | { | 48 | { |
47 | .name = "SMPS123", | 49 | .name = "SMPS123", |
@@ -49,12 +51,14 @@ static const struct regs_info palmas_regs_info[] = { | |||
49 | .vsel_addr = PALMAS_SMPS12_VOLTAGE, | 51 | .vsel_addr = PALMAS_SMPS12_VOLTAGE, |
50 | .ctrl_addr = PALMAS_SMPS12_CTRL, | 52 | .ctrl_addr = PALMAS_SMPS12_CTRL, |
51 | .tstep_addr = PALMAS_SMPS12_TSTEP, | 53 | .tstep_addr = PALMAS_SMPS12_TSTEP, |
54 | .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_SMPS12, | ||
52 | }, | 55 | }, |
53 | { | 56 | { |
54 | .name = "SMPS3", | 57 | .name = "SMPS3", |
55 | .sname = "smps3-in", | 58 | .sname = "smps3-in", |
56 | .vsel_addr = PALMAS_SMPS3_VOLTAGE, | 59 | .vsel_addr = PALMAS_SMPS3_VOLTAGE, |
57 | .ctrl_addr = PALMAS_SMPS3_CTRL, | 60 | .ctrl_addr = PALMAS_SMPS3_CTRL, |
61 | .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_SMPS3, | ||
58 | }, | 62 | }, |
59 | { | 63 | { |
60 | .name = "SMPS45", | 64 | .name = "SMPS45", |
@@ -62,6 +66,7 @@ static const struct regs_info palmas_regs_info[] = { | |||
62 | .vsel_addr = PALMAS_SMPS45_VOLTAGE, | 66 | .vsel_addr = PALMAS_SMPS45_VOLTAGE, |
63 | .ctrl_addr = PALMAS_SMPS45_CTRL, | 67 | .ctrl_addr = PALMAS_SMPS45_CTRL, |
64 | .tstep_addr = PALMAS_SMPS45_TSTEP, | 68 | .tstep_addr = PALMAS_SMPS45_TSTEP, |
69 | .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_SMPS45, | ||
65 | }, | 70 | }, |
66 | { | 71 | { |
67 | .name = "SMPS457", | 72 | .name = "SMPS457", |
@@ -69,6 +74,7 @@ static const struct regs_info palmas_regs_info[] = { | |||
69 | .vsel_addr = PALMAS_SMPS45_VOLTAGE, | 74 | .vsel_addr = PALMAS_SMPS45_VOLTAGE, |
70 | .ctrl_addr = PALMAS_SMPS45_CTRL, | 75 | .ctrl_addr = PALMAS_SMPS45_CTRL, |
71 | .tstep_addr = PALMAS_SMPS45_TSTEP, | 76 | .tstep_addr = PALMAS_SMPS45_TSTEP, |
77 | .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_SMPS45, | ||
72 | }, | 78 | }, |
73 | { | 79 | { |
74 | .name = "SMPS6", | 80 | .name = "SMPS6", |
@@ -76,12 +82,14 @@ static const struct regs_info palmas_regs_info[] = { | |||
76 | .vsel_addr = PALMAS_SMPS6_VOLTAGE, | 82 | .vsel_addr = PALMAS_SMPS6_VOLTAGE, |
77 | .ctrl_addr = PALMAS_SMPS6_CTRL, | 83 | .ctrl_addr = PALMAS_SMPS6_CTRL, |
78 | .tstep_addr = PALMAS_SMPS6_TSTEP, | 84 | .tstep_addr = PALMAS_SMPS6_TSTEP, |
85 | .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_SMPS6, | ||
79 | }, | 86 | }, |
80 | { | 87 | { |
81 | .name = "SMPS7", | 88 | .name = "SMPS7", |
82 | .sname = "smps7-in", | 89 | .sname = "smps7-in", |
83 | .vsel_addr = PALMAS_SMPS7_VOLTAGE, | 90 | .vsel_addr = PALMAS_SMPS7_VOLTAGE, |
84 | .ctrl_addr = PALMAS_SMPS7_CTRL, | 91 | .ctrl_addr = PALMAS_SMPS7_CTRL, |
92 | .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_SMPS7, | ||
85 | }, | 93 | }, |
86 | { | 94 | { |
87 | .name = "SMPS8", | 95 | .name = "SMPS8", |
@@ -89,108 +97,128 @@ static const struct regs_info palmas_regs_info[] = { | |||
89 | .vsel_addr = PALMAS_SMPS8_VOLTAGE, | 97 | .vsel_addr = PALMAS_SMPS8_VOLTAGE, |
90 | .ctrl_addr = PALMAS_SMPS8_CTRL, | 98 | .ctrl_addr = PALMAS_SMPS8_CTRL, |
91 | .tstep_addr = PALMAS_SMPS8_TSTEP, | 99 | .tstep_addr = PALMAS_SMPS8_TSTEP, |
100 | .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_SMPS8, | ||
92 | }, | 101 | }, |
93 | { | 102 | { |
94 | .name = "SMPS9", | 103 | .name = "SMPS9", |
95 | .sname = "smps9-in", | 104 | .sname = "smps9-in", |
96 | .vsel_addr = PALMAS_SMPS9_VOLTAGE, | 105 | .vsel_addr = PALMAS_SMPS9_VOLTAGE, |
97 | .ctrl_addr = PALMAS_SMPS9_CTRL, | 106 | .ctrl_addr = PALMAS_SMPS9_CTRL, |
107 | .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_SMPS9, | ||
98 | }, | 108 | }, |
99 | { | 109 | { |
100 | .name = "SMPS10_OUT2", | 110 | .name = "SMPS10_OUT2", |
101 | .sname = "smps10-in", | 111 | .sname = "smps10-in", |
102 | .ctrl_addr = PALMAS_SMPS10_CTRL, | 112 | .ctrl_addr = PALMAS_SMPS10_CTRL, |
113 | .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_SMPS10, | ||
103 | }, | 114 | }, |
104 | { | 115 | { |
105 | .name = "SMPS10_OUT1", | 116 | .name = "SMPS10_OUT1", |
106 | .sname = "smps10-out2", | 117 | .sname = "smps10-out2", |
107 | .ctrl_addr = PALMAS_SMPS10_CTRL, | 118 | .ctrl_addr = PALMAS_SMPS10_CTRL, |
119 | .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_SMPS10, | ||
108 | }, | 120 | }, |
109 | { | 121 | { |
110 | .name = "LDO1", | 122 | .name = "LDO1", |
111 | .sname = "ldo1-in", | 123 | .sname = "ldo1-in", |
112 | .vsel_addr = PALMAS_LDO1_VOLTAGE, | 124 | .vsel_addr = PALMAS_LDO1_VOLTAGE, |
113 | .ctrl_addr = PALMAS_LDO1_CTRL, | 125 | .ctrl_addr = PALMAS_LDO1_CTRL, |
126 | .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_LDO1, | ||
114 | }, | 127 | }, |
115 | { | 128 | { |
116 | .name = "LDO2", | 129 | .name = "LDO2", |
117 | .sname = "ldo2-in", | 130 | .sname = "ldo2-in", |
118 | .vsel_addr = PALMAS_LDO2_VOLTAGE, | 131 | .vsel_addr = PALMAS_LDO2_VOLTAGE, |
119 | .ctrl_addr = PALMAS_LDO2_CTRL, | 132 | .ctrl_addr = PALMAS_LDO2_CTRL, |
133 | .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_LDO2, | ||
120 | }, | 134 | }, |
121 | { | 135 | { |
122 | .name = "LDO3", | 136 | .name = "LDO3", |
123 | .sname = "ldo3-in", | 137 | .sname = "ldo3-in", |
124 | .vsel_addr = PALMAS_LDO3_VOLTAGE, | 138 | .vsel_addr = PALMAS_LDO3_VOLTAGE, |
125 | .ctrl_addr = PALMAS_LDO3_CTRL, | 139 | .ctrl_addr = PALMAS_LDO3_CTRL, |
140 | .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_LDO3, | ||
126 | }, | 141 | }, |
127 | { | 142 | { |
128 | .name = "LDO4", | 143 | .name = "LDO4", |
129 | .sname = "ldo4-in", | 144 | .sname = "ldo4-in", |
130 | .vsel_addr = PALMAS_LDO4_VOLTAGE, | 145 | .vsel_addr = PALMAS_LDO4_VOLTAGE, |
131 | .ctrl_addr = PALMAS_LDO4_CTRL, | 146 | .ctrl_addr = PALMAS_LDO4_CTRL, |
147 | .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_LDO4, | ||
132 | }, | 148 | }, |
133 | { | 149 | { |
134 | .name = "LDO5", | 150 | .name = "LDO5", |
135 | .sname = "ldo5-in", | 151 | .sname = "ldo5-in", |
136 | .vsel_addr = PALMAS_LDO5_VOLTAGE, | 152 | .vsel_addr = PALMAS_LDO5_VOLTAGE, |
137 | .ctrl_addr = PALMAS_LDO5_CTRL, | 153 | .ctrl_addr = PALMAS_LDO5_CTRL, |
154 | .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_LDO5, | ||
138 | }, | 155 | }, |
139 | { | 156 | { |
140 | .name = "LDO6", | 157 | .name = "LDO6", |
141 | .sname = "ldo6-in", | 158 | .sname = "ldo6-in", |
142 | .vsel_addr = PALMAS_LDO6_VOLTAGE, | 159 | .vsel_addr = PALMAS_LDO6_VOLTAGE, |
143 | .ctrl_addr = PALMAS_LDO6_CTRL, | 160 | .ctrl_addr = PALMAS_LDO6_CTRL, |
161 | .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_LDO6, | ||
144 | }, | 162 | }, |
145 | { | 163 | { |
146 | .name = "LDO7", | 164 | .name = "LDO7", |
147 | .sname = "ldo7-in", | 165 | .sname = "ldo7-in", |
148 | .vsel_addr = PALMAS_LDO7_VOLTAGE, | 166 | .vsel_addr = PALMAS_LDO7_VOLTAGE, |
149 | .ctrl_addr = PALMAS_LDO7_CTRL, | 167 | .ctrl_addr = PALMAS_LDO7_CTRL, |
168 | .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_LDO7, | ||
150 | }, | 169 | }, |
151 | { | 170 | { |
152 | .name = "LDO8", | 171 | .name = "LDO8", |
153 | .sname = "ldo8-in", | 172 | .sname = "ldo8-in", |
154 | .vsel_addr = PALMAS_LDO8_VOLTAGE, | 173 | .vsel_addr = PALMAS_LDO8_VOLTAGE, |
155 | .ctrl_addr = PALMAS_LDO8_CTRL, | 174 | .ctrl_addr = PALMAS_LDO8_CTRL, |
175 | .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_LDO8, | ||
156 | }, | 176 | }, |
157 | { | 177 | { |
158 | .name = "LDO9", | 178 | .name = "LDO9", |
159 | .sname = "ldo9-in", | 179 | .sname = "ldo9-in", |
160 | .vsel_addr = PALMAS_LDO9_VOLTAGE, | 180 | .vsel_addr = PALMAS_LDO9_VOLTAGE, |
161 | .ctrl_addr = PALMAS_LDO9_CTRL, | 181 | .ctrl_addr = PALMAS_LDO9_CTRL, |
182 | .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_LDO9, | ||
162 | }, | 183 | }, |
163 | { | 184 | { |
164 | .name = "LDOLN", | 185 | .name = "LDOLN", |
165 | .sname = "ldoln-in", | 186 | .sname = "ldoln-in", |
166 | .vsel_addr = PALMAS_LDOLN_VOLTAGE, | 187 | .vsel_addr = PALMAS_LDOLN_VOLTAGE, |
167 | .ctrl_addr = PALMAS_LDOLN_CTRL, | 188 | .ctrl_addr = PALMAS_LDOLN_CTRL, |
189 | .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_LDOLN, | ||
168 | }, | 190 | }, |
169 | { | 191 | { |
170 | .name = "LDOUSB", | 192 | .name = "LDOUSB", |
171 | .sname = "ldousb-in", | 193 | .sname = "ldousb-in", |
172 | .vsel_addr = PALMAS_LDOUSB_VOLTAGE, | 194 | .vsel_addr = PALMAS_LDOUSB_VOLTAGE, |
173 | .ctrl_addr = PALMAS_LDOUSB_CTRL, | 195 | .ctrl_addr = PALMAS_LDOUSB_CTRL, |
196 | .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_LDOUSB, | ||
174 | }, | 197 | }, |
175 | { | 198 | { |
176 | .name = "REGEN1", | 199 | .name = "REGEN1", |
177 | .ctrl_addr = PALMAS_REGEN1_CTRL, | 200 | .ctrl_addr = PALMAS_REGEN1_CTRL, |
201 | .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_REGEN1, | ||
178 | }, | 202 | }, |
179 | { | 203 | { |
180 | .name = "REGEN2", | 204 | .name = "REGEN2", |
181 | .ctrl_addr = PALMAS_REGEN2_CTRL, | 205 | .ctrl_addr = PALMAS_REGEN2_CTRL, |
206 | .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_REGEN2, | ||
182 | }, | 207 | }, |
183 | { | 208 | { |
184 | .name = "REGEN3", | 209 | .name = "REGEN3", |
185 | .ctrl_addr = PALMAS_REGEN3_CTRL, | 210 | .ctrl_addr = PALMAS_REGEN3_CTRL, |
211 | .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_REGEN3, | ||
186 | }, | 212 | }, |
187 | { | 213 | { |
188 | .name = "SYSEN1", | 214 | .name = "SYSEN1", |
189 | .ctrl_addr = PALMAS_SYSEN1_CTRL, | 215 | .ctrl_addr = PALMAS_SYSEN1_CTRL, |
216 | .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_SYSEN1, | ||
190 | }, | 217 | }, |
191 | { | 218 | { |
192 | .name = "SYSEN2", | 219 | .name = "SYSEN2", |
193 | .ctrl_addr = PALMAS_SYSEN2_CTRL, | 220 | .ctrl_addr = PALMAS_SYSEN2_CTRL, |
221 | .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_SYSEN2, | ||
194 | }, | 222 | }, |
195 | }; | 223 | }; |
196 | 224 | ||
@@ -478,6 +506,17 @@ static struct regulator_ops palmas_ops_smps = { | |||
478 | .set_ramp_delay = palmas_smps_set_ramp_delay, | 506 | .set_ramp_delay = palmas_smps_set_ramp_delay, |
479 | }; | 507 | }; |
480 | 508 | ||
509 | static struct regulator_ops palmas_ops_ext_control_smps = { | ||
510 | .set_mode = palmas_set_mode_smps, | ||
511 | .get_mode = palmas_get_mode_smps, | ||
512 | .get_voltage_sel = regulator_get_voltage_sel_regmap, | ||
513 | .set_voltage_sel = regulator_set_voltage_sel_regmap, | ||
514 | .list_voltage = palmas_list_voltage_smps, | ||
515 | .map_voltage = palmas_map_voltage_smps, | ||
516 | .set_voltage_time_sel = palma_smps_set_voltage_smps_time_sel, | ||
517 | .set_ramp_delay = palmas_smps_set_ramp_delay, | ||
518 | }; | ||
519 | |||
481 | static struct regulator_ops palmas_ops_smps10 = { | 520 | static struct regulator_ops palmas_ops_smps10 = { |
482 | .is_enabled = regulator_is_enabled_regmap, | 521 | .is_enabled = regulator_is_enabled_regmap, |
483 | .enable = regulator_enable_regmap, | 522 | .enable = regulator_enable_regmap, |
@@ -513,12 +552,37 @@ static struct regulator_ops palmas_ops_ldo = { | |||
513 | .map_voltage = regulator_map_voltage_linear, | 552 | .map_voltage = regulator_map_voltage_linear, |
514 | }; | 553 | }; |
515 | 554 | ||
555 | static struct regulator_ops palmas_ops_ext_control_ldo = { | ||
556 | .get_voltage_sel = regulator_get_voltage_sel_regmap, | ||
557 | .set_voltage_sel = regulator_set_voltage_sel_regmap, | ||
558 | .list_voltage = regulator_list_voltage_linear, | ||
559 | .map_voltage = regulator_map_voltage_linear, | ||
560 | }; | ||
561 | |||
516 | static struct regulator_ops palmas_ops_extreg = { | 562 | static struct regulator_ops palmas_ops_extreg = { |
517 | .is_enabled = regulator_is_enabled_regmap, | 563 | .is_enabled = regulator_is_enabled_regmap, |
518 | .enable = regulator_enable_regmap, | 564 | .enable = regulator_enable_regmap, |
519 | .disable = regulator_disable_regmap, | 565 | .disable = regulator_disable_regmap, |
520 | }; | 566 | }; |
521 | 567 | ||
568 | static struct regulator_ops palmas_ops_ext_control_extreg = { | ||
569 | }; | ||
570 | |||
571 | static int palmas_regulator_config_external(struct palmas *palmas, int id, | ||
572 | struct palmas_reg_init *reg_init) | ||
573 | { | ||
574 | int sleep_id = palmas_regs_info[id].sleep_id; | ||
575 | int ret; | ||
576 | |||
577 | ret = palmas_ext_control_req_config(palmas, sleep_id, | ||
578 | reg_init->roof_floor, true); | ||
579 | if (ret < 0) | ||
580 | dev_err(palmas->dev, | ||
581 | "Ext control config for regulator %d failed %d\n", | ||
582 | id, ret); | ||
583 | return ret; | ||
584 | } | ||
585 | |||
522 | /* | 586 | /* |
523 | * setup the hardware based sleep configuration of the SMPS/LDO regulators | 587 | * setup the hardware based sleep configuration of the SMPS/LDO regulators |
524 | * from the platform data. This is different to the software based control | 588 | * from the platform data. This is different to the software based control |
@@ -577,7 +641,22 @@ static int palmas_smps_init(struct palmas *palmas, int id, | |||
577 | return ret; | 641 | return ret; |
578 | } | 642 | } |
579 | 643 | ||
644 | if (reg_init->roof_floor && (id != PALMAS_REG_SMPS10_OUT1) && | ||
645 | (id != PALMAS_REG_SMPS10_OUT2)) { | ||
646 | /* Enable externally controlled regulator */ | ||
647 | addr = palmas_regs_info[id].ctrl_addr; | ||
648 | ret = palmas_smps_read(palmas, addr, ®); | ||
649 | if (ret < 0) | ||
650 | return ret; | ||
580 | 651 | ||
652 | if (!(reg & PALMAS_SMPS12_CTRL_MODE_ACTIVE_MASK)) { | ||
653 | reg |= SMPS_CTRL_MODE_ON; | ||
654 | ret = palmas_smps_write(palmas, addr, reg); | ||
655 | if (ret < 0) | ||
656 | return ret; | ||
657 | } | ||
658 | return palmas_regulator_config_external(palmas, id, reg_init); | ||
659 | } | ||
581 | return 0; | 660 | return 0; |
582 | } | 661 | } |
583 | 662 | ||
@@ -608,6 +687,20 @@ static int palmas_ldo_init(struct palmas *palmas, int id, | |||
608 | if (ret) | 687 | if (ret) |
609 | return ret; | 688 | return ret; |
610 | 689 | ||
690 | if (reg_init->roof_floor) { | ||
691 | /* Enable externally controlled regulator */ | ||
692 | addr = palmas_regs_info[id].ctrl_addr; | ||
693 | ret = palmas_update_bits(palmas, PALMAS_LDO_BASE, | ||
694 | addr, PALMAS_LDO1_CTRL_MODE_ACTIVE, | ||
695 | PALMAS_LDO1_CTRL_MODE_ACTIVE); | ||
696 | if (ret < 0) { | ||
697 | dev_err(palmas->dev, | ||
698 | "LDO Register 0x%02x update failed %d\n", | ||
699 | addr, ret); | ||
700 | return ret; | ||
701 | } | ||
702 | return palmas_regulator_config_external(palmas, id, reg_init); | ||
703 | } | ||
611 | return 0; | 704 | return 0; |
612 | } | 705 | } |
613 | 706 | ||
@@ -630,6 +723,21 @@ static int palmas_extreg_init(struct palmas *palmas, int id, | |||
630 | addr, ret); | 723 | addr, ret); |
631 | return ret; | 724 | return ret; |
632 | } | 725 | } |
726 | |||
727 | if (reg_init->roof_floor) { | ||
728 | /* Enable externally controlled regulator */ | ||
729 | addr = palmas_regs_info[id].ctrl_addr; | ||
730 | ret = palmas_update_bits(palmas, PALMAS_RESOURCE_BASE, | ||
731 | addr, PALMAS_REGEN1_CTRL_MODE_ACTIVE, | ||
732 | PALMAS_REGEN1_CTRL_MODE_ACTIVE); | ||
733 | if (ret < 0) { | ||
734 | dev_err(palmas->dev, | ||
735 | "Resource Register 0x%02x update failed %d\n", | ||
736 | addr, ret); | ||
737 | return ret; | ||
738 | } | ||
739 | return palmas_regulator_config_external(palmas, id, reg_init); | ||
740 | } | ||
633 | return 0; | 741 | return 0; |
634 | } | 742 | } |
635 | 743 | ||
@@ -712,7 +820,7 @@ static void palmas_dt_to_pdata(struct device *dev, | |||
712 | int idx, ret; | 820 | int idx, ret; |
713 | 821 | ||
714 | node = of_node_get(node); | 822 | node = of_node_get(node); |
715 | regulators = of_find_node_by_name(node, "regulators"); | 823 | regulators = of_get_child_by_name(node, "regulators"); |
716 | if (!regulators) { | 824 | if (!regulators) { |
717 | dev_info(dev, "regulator node not found\n"); | 825 | dev_info(dev, "regulator node not found\n"); |
718 | return; | 826 | return; |
@@ -740,9 +848,35 @@ static void palmas_dt_to_pdata(struct device *dev, | |||
740 | of_property_read_bool(palmas_matches[idx].of_node, | 848 | of_property_read_bool(palmas_matches[idx].of_node, |
741 | "ti,warm-reset"); | 849 | "ti,warm-reset"); |
742 | 850 | ||
743 | pdata->reg_init[idx]->roof_floor = | 851 | ret = of_property_read_u32(palmas_matches[idx].of_node, |
744 | of_property_read_bool(palmas_matches[idx].of_node, | 852 | "ti,roof-floor", &prop); |
745 | "ti,roof-floor"); | 853 | /* EINVAL: Property not found */ |
854 | if (ret != -EINVAL) { | ||
855 | int econtrol; | ||
856 | |||
857 | /* use default value, when no value is specified */ | ||
858 | econtrol = PALMAS_EXT_CONTROL_NSLEEP; | ||
859 | if (!ret) { | ||
860 | switch (prop) { | ||
861 | case 1: | ||
862 | econtrol = PALMAS_EXT_CONTROL_ENABLE1; | ||
863 | break; | ||
864 | case 2: | ||
865 | econtrol = PALMAS_EXT_CONTROL_ENABLE2; | ||
866 | break; | ||
867 | case 3: | ||
868 | econtrol = PALMAS_EXT_CONTROL_NSLEEP; | ||
869 | break; | ||
870 | default: | ||
871 | WARN_ON(1); | ||
872 | dev_warn(dev, | ||
873 | "%s: Invalid roof-floor option: %u\n", | ||
874 | palmas_matches[idx].name, prop); | ||
875 | break; | ||
876 | } | ||
877 | } | ||
878 | pdata->reg_init[idx]->roof_floor = econtrol; | ||
879 | } | ||
746 | 880 | ||
747 | ret = of_property_read_u32(palmas_matches[idx].of_node, | 881 | ret = of_property_read_u32(palmas_matches[idx].of_node, |
748 | "ti,mode-sleep", &prop); | 882 | "ti,mode-sleep", &prop); |
@@ -856,7 +990,7 @@ static int palmas_regulators_probe(struct platform_device *pdev) | |||
856 | if (ret < 0) { | 990 | if (ret < 0) { |
857 | dev_err(&pdev->dev, | 991 | dev_err(&pdev->dev, |
858 | "reading TSTEP reg failed: %d\n", ret); | 992 | "reading TSTEP reg failed: %d\n", ret); |
859 | goto err_unregister_regulator; | 993 | return ret; |
860 | } | 994 | } |
861 | pmic->desc[id].ramp_delay = | 995 | pmic->desc[id].ramp_delay = |
862 | palmas_smps_ramp_delay[reg & 0x3]; | 996 | palmas_smps_ramp_delay[reg & 0x3]; |
@@ -868,7 +1002,9 @@ static int palmas_regulators_probe(struct platform_device *pdev) | |||
868 | reg_init = pdata->reg_init[id]; | 1002 | reg_init = pdata->reg_init[id]; |
869 | ret = palmas_smps_init(palmas, id, reg_init); | 1003 | ret = palmas_smps_init(palmas, id, reg_init); |
870 | if (ret) | 1004 | if (ret) |
871 | goto err_unregister_regulator; | 1005 | return ret; |
1006 | } else { | ||
1007 | reg_init = NULL; | ||
872 | } | 1008 | } |
873 | 1009 | ||
874 | /* Register the regulators */ | 1010 | /* Register the regulators */ |
@@ -909,11 +1045,15 @@ static int palmas_regulators_probe(struct platform_device *pdev) | |||
909 | 1045 | ||
910 | ret = palmas_smps_read(pmic->palmas, addr, ®); | 1046 | ret = palmas_smps_read(pmic->palmas, addr, ®); |
911 | if (ret) | 1047 | if (ret) |
912 | goto err_unregister_regulator; | 1048 | return ret; |
913 | if (reg & PALMAS_SMPS12_VOLTAGE_RANGE) | 1049 | if (reg & PALMAS_SMPS12_VOLTAGE_RANGE) |
914 | pmic->range[id] = 1; | 1050 | pmic->range[id] = 1; |
915 | 1051 | ||
916 | pmic->desc[id].ops = &palmas_ops_smps; | 1052 | if (reg_init && reg_init->roof_floor) |
1053 | pmic->desc[id].ops = | ||
1054 | &palmas_ops_ext_control_smps; | ||
1055 | else | ||
1056 | pmic->desc[id].ops = &palmas_ops_smps; | ||
917 | pmic->desc[id].n_voltages = PALMAS_SMPS_NUM_VOLTAGES; | 1057 | pmic->desc[id].n_voltages = PALMAS_SMPS_NUM_VOLTAGES; |
918 | pmic->desc[id].vsel_reg = | 1058 | pmic->desc[id].vsel_reg = |
919 | PALMAS_BASE_TO_REG(PALMAS_SMPS_BASE, | 1059 | PALMAS_BASE_TO_REG(PALMAS_SMPS_BASE, |
@@ -925,7 +1065,7 @@ static int palmas_regulators_probe(struct platform_device *pdev) | |||
925 | addr = palmas_regs_info[id].ctrl_addr; | 1065 | addr = palmas_regs_info[id].ctrl_addr; |
926 | ret = palmas_smps_read(pmic->palmas, addr, ®); | 1066 | ret = palmas_smps_read(pmic->palmas, addr, ®); |
927 | if (ret) | 1067 | if (ret) |
928 | goto err_unregister_regulator; | 1068 | return ret; |
929 | pmic->current_reg_mode[id] = reg & | 1069 | pmic->current_reg_mode[id] = reg & |
930 | PALMAS_SMPS12_CTRL_MODE_ACTIVE_MASK; | 1070 | PALMAS_SMPS12_CTRL_MODE_ACTIVE_MASK; |
931 | } | 1071 | } |
@@ -941,13 +1081,13 @@ static int palmas_regulators_probe(struct platform_device *pdev) | |||
941 | pmic->desc[id].supply_name = palmas_regs_info[id].sname; | 1081 | pmic->desc[id].supply_name = palmas_regs_info[id].sname; |
942 | config.of_node = palmas_matches[id].of_node; | 1082 | config.of_node = palmas_matches[id].of_node; |
943 | 1083 | ||
944 | rdev = regulator_register(&pmic->desc[id], &config); | 1084 | rdev = devm_regulator_register(&pdev->dev, &pmic->desc[id], |
1085 | &config); | ||
945 | if (IS_ERR(rdev)) { | 1086 | if (IS_ERR(rdev)) { |
946 | dev_err(&pdev->dev, | 1087 | dev_err(&pdev->dev, |
947 | "failed to register %s regulator\n", | 1088 | "failed to register %s regulator\n", |
948 | pdev->name); | 1089 | pdev->name); |
949 | ret = PTR_ERR(rdev); | 1090 | return PTR_ERR(rdev); |
950 | goto err_unregister_regulator; | ||
951 | } | 1091 | } |
952 | 1092 | ||
953 | /* Save regulator for cleanup */ | 1093 | /* Save regulator for cleanup */ |
@@ -956,6 +1096,10 @@ static int palmas_regulators_probe(struct platform_device *pdev) | |||
956 | 1096 | ||
957 | /* Start this loop from the id left from previous loop */ | 1097 | /* Start this loop from the id left from previous loop */ |
958 | for (; id < PALMAS_NUM_REGS; id++) { | 1098 | for (; id < PALMAS_NUM_REGS; id++) { |
1099 | if (pdata && pdata->reg_init[id]) | ||
1100 | reg_init = pdata->reg_init[id]; | ||
1101 | else | ||
1102 | reg_init = NULL; | ||
959 | 1103 | ||
960 | /* Miss out regulators which are not available due | 1104 | /* Miss out regulators which are not available due |
961 | * to alternate functions. | 1105 | * to alternate functions. |
@@ -969,7 +1113,11 @@ static int palmas_regulators_probe(struct platform_device *pdev) | |||
969 | 1113 | ||
970 | if (id < PALMAS_REG_REGEN1) { | 1114 | if (id < PALMAS_REG_REGEN1) { |
971 | pmic->desc[id].n_voltages = PALMAS_LDO_NUM_VOLTAGES; | 1115 | pmic->desc[id].n_voltages = PALMAS_LDO_NUM_VOLTAGES; |
972 | pmic->desc[id].ops = &palmas_ops_ldo; | 1116 | if (reg_init && reg_init->roof_floor) |
1117 | pmic->desc[id].ops = | ||
1118 | &palmas_ops_ext_control_ldo; | ||
1119 | else | ||
1120 | pmic->desc[id].ops = &palmas_ops_ldo; | ||
973 | pmic->desc[id].min_uV = 900000; | 1121 | pmic->desc[id].min_uV = 900000; |
974 | pmic->desc[id].uV_step = 50000; | 1122 | pmic->desc[id].uV_step = 50000; |
975 | pmic->desc[id].linear_min_sel = 1; | 1123 | pmic->desc[id].linear_min_sel = 1; |
@@ -999,7 +1147,11 @@ static int palmas_regulators_probe(struct platform_device *pdev) | |||
999 | pmic->desc[id].enable_time = 2000; | 1147 | pmic->desc[id].enable_time = 2000; |
1000 | } else { | 1148 | } else { |
1001 | pmic->desc[id].n_voltages = 1; | 1149 | pmic->desc[id].n_voltages = 1; |
1002 | pmic->desc[id].ops = &palmas_ops_extreg; | 1150 | if (reg_init && reg_init->roof_floor) |
1151 | pmic->desc[id].ops = | ||
1152 | &palmas_ops_ext_control_extreg; | ||
1153 | else | ||
1154 | pmic->desc[id].ops = &palmas_ops_extreg; | ||
1003 | pmic->desc[id].enable_reg = | 1155 | pmic->desc[id].enable_reg = |
1004 | PALMAS_BASE_TO_REG(PALMAS_RESOURCE_BASE, | 1156 | PALMAS_BASE_TO_REG(PALMAS_RESOURCE_BASE, |
1005 | palmas_regs_info[id].ctrl_addr); | 1157 | palmas_regs_info[id].ctrl_addr); |
@@ -1015,13 +1167,13 @@ static int palmas_regulators_probe(struct platform_device *pdev) | |||
1015 | pmic->desc[id].supply_name = palmas_regs_info[id].sname; | 1167 | pmic->desc[id].supply_name = palmas_regs_info[id].sname; |
1016 | config.of_node = palmas_matches[id].of_node; | 1168 | config.of_node = palmas_matches[id].of_node; |
1017 | 1169 | ||
1018 | rdev = regulator_register(&pmic->desc[id], &config); | 1170 | rdev = devm_regulator_register(&pdev->dev, &pmic->desc[id], |
1171 | &config); | ||
1019 | if (IS_ERR(rdev)) { | 1172 | if (IS_ERR(rdev)) { |
1020 | dev_err(&pdev->dev, | 1173 | dev_err(&pdev->dev, |
1021 | "failed to register %s regulator\n", | 1174 | "failed to register %s regulator\n", |
1022 | pdev->name); | 1175 | pdev->name); |
1023 | ret = PTR_ERR(rdev); | 1176 | return PTR_ERR(rdev); |
1024 | goto err_unregister_regulator; | ||
1025 | } | 1177 | } |
1026 | 1178 | ||
1027 | /* Save regulator for cleanup */ | 1179 | /* Save regulator for cleanup */ |
@@ -1037,31 +1189,14 @@ static int palmas_regulators_probe(struct platform_device *pdev) | |||
1037 | else | 1189 | else |
1038 | ret = palmas_extreg_init(palmas, | 1190 | ret = palmas_extreg_init(palmas, |
1039 | id, reg_init); | 1191 | id, reg_init); |
1040 | if (ret) { | 1192 | if (ret) |
1041 | regulator_unregister(pmic->rdev[id]); | 1193 | return ret; |
1042 | goto err_unregister_regulator; | ||
1043 | } | ||
1044 | } | 1194 | } |
1045 | } | 1195 | } |
1046 | } | 1196 | } |
1047 | 1197 | ||
1048 | 1198 | ||
1049 | return 0; | 1199 | return 0; |
1050 | |||
1051 | err_unregister_regulator: | ||
1052 | while (--id >= 0) | ||
1053 | regulator_unregister(pmic->rdev[id]); | ||
1054 | return ret; | ||
1055 | } | ||
1056 | |||
1057 | static int palmas_regulators_remove(struct platform_device *pdev) | ||
1058 | { | ||
1059 | struct palmas_pmic *pmic = platform_get_drvdata(pdev); | ||
1060 | int id; | ||
1061 | |||
1062 | for (id = 0; id < PALMAS_NUM_REGS; id++) | ||
1063 | regulator_unregister(pmic->rdev[id]); | ||
1064 | return 0; | ||
1065 | } | 1200 | } |
1066 | 1201 | ||
1067 | static struct of_device_id of_palmas_match_tbl[] = { | 1202 | static struct of_device_id of_palmas_match_tbl[] = { |
@@ -1083,7 +1218,6 @@ static struct platform_driver palmas_driver = { | |||
1083 | .owner = THIS_MODULE, | 1218 | .owner = THIS_MODULE, |
1084 | }, | 1219 | }, |
1085 | .probe = palmas_regulators_probe, | 1220 | .probe = palmas_regulators_probe, |
1086 | .remove = palmas_regulators_remove, | ||
1087 | }; | 1221 | }; |
1088 | 1222 | ||
1089 | static int __init palmas_init(void) | 1223 | static int __init palmas_init(void) |
diff --git a/drivers/regulator/pcap-regulator.c b/drivers/regulator/pcap-regulator.c index b49eaeedea84..3727b7d0e9ac 100644 --- a/drivers/regulator/pcap-regulator.c +++ b/drivers/regulator/pcap-regulator.c | |||
@@ -246,7 +246,8 @@ static int pcap_regulator_probe(struct platform_device *pdev) | |||
246 | config.init_data = dev_get_platdata(&pdev->dev); | 246 | config.init_data = dev_get_platdata(&pdev->dev); |
247 | config.driver_data = pcap; | 247 | config.driver_data = pcap; |
248 | 248 | ||
249 | rdev = regulator_register(&pcap_regulators[pdev->id], &config); | 249 | rdev = devm_regulator_register(&pdev->dev, &pcap_regulators[pdev->id], |
250 | &config); | ||
250 | if (IS_ERR(rdev)) | 251 | if (IS_ERR(rdev)) |
251 | return PTR_ERR(rdev); | 252 | return PTR_ERR(rdev); |
252 | 253 | ||
@@ -255,22 +256,12 @@ static int pcap_regulator_probe(struct platform_device *pdev) | |||
255 | return 0; | 256 | return 0; |
256 | } | 257 | } |
257 | 258 | ||
258 | static int pcap_regulator_remove(struct platform_device *pdev) | ||
259 | { | ||
260 | struct regulator_dev *rdev = platform_get_drvdata(pdev); | ||
261 | |||
262 | regulator_unregister(rdev); | ||
263 | |||
264 | return 0; | ||
265 | } | ||
266 | |||
267 | static struct platform_driver pcap_regulator_driver = { | 259 | static struct platform_driver pcap_regulator_driver = { |
268 | .driver = { | 260 | .driver = { |
269 | .name = "pcap-regulator", | 261 | .name = "pcap-regulator", |
270 | .owner = THIS_MODULE, | 262 | .owner = THIS_MODULE, |
271 | }, | 263 | }, |
272 | .probe = pcap_regulator_probe, | 264 | .probe = pcap_regulator_probe, |
273 | .remove = pcap_regulator_remove, | ||
274 | }; | 265 | }; |
275 | 266 | ||
276 | static int __init pcap_regulator_init(void) | 267 | static int __init pcap_regulator_init(void) |
diff --git a/drivers/regulator/pcf50633-regulator.c b/drivers/regulator/pcf50633-regulator.c index 0f3576d48abf..d7da1c15a6da 100644 --- a/drivers/regulator/pcf50633-regulator.c +++ b/drivers/regulator/pcf50633-regulator.c | |||
@@ -90,7 +90,8 @@ static int pcf50633_regulator_probe(struct platform_device *pdev) | |||
90 | config.driver_data = pcf; | 90 | config.driver_data = pcf; |
91 | config.regmap = pcf->regmap; | 91 | config.regmap = pcf->regmap; |
92 | 92 | ||
93 | rdev = regulator_register(®ulators[pdev->id], &config); | 93 | rdev = devm_regulator_register(&pdev->dev, ®ulators[pdev->id], |
94 | &config); | ||
94 | if (IS_ERR(rdev)) | 95 | if (IS_ERR(rdev)) |
95 | return PTR_ERR(rdev); | 96 | return PTR_ERR(rdev); |
96 | 97 | ||
@@ -102,21 +103,11 @@ static int pcf50633_regulator_probe(struct platform_device *pdev) | |||
102 | return 0; | 103 | return 0; |
103 | } | 104 | } |
104 | 105 | ||
105 | static int pcf50633_regulator_remove(struct platform_device *pdev) | ||
106 | { | ||
107 | struct regulator_dev *rdev = platform_get_drvdata(pdev); | ||
108 | |||
109 | regulator_unregister(rdev); | ||
110 | |||
111 | return 0; | ||
112 | } | ||
113 | |||
114 | static struct platform_driver pcf50633_regulator_driver = { | 106 | static struct platform_driver pcf50633_regulator_driver = { |
115 | .driver = { | 107 | .driver = { |
116 | .name = "pcf50633-regltr", | 108 | .name = "pcf50633-regltr", |
117 | }, | 109 | }, |
118 | .probe = pcf50633_regulator_probe, | 110 | .probe = pcf50633_regulator_probe, |
119 | .remove = pcf50633_regulator_remove, | ||
120 | }; | 111 | }; |
121 | 112 | ||
122 | static int __init pcf50633_regulator_init(void) | 113 | static int __init pcf50633_regulator_init(void) |
diff --git a/drivers/regulator/rc5t583-regulator.c b/drivers/regulator/rc5t583-regulator.c index 5885b4504596..b58affb33143 100644 --- a/drivers/regulator/rc5t583-regulator.c +++ b/drivers/regulator/rc5t583-regulator.c | |||
@@ -173,33 +173,16 @@ skip_ext_pwr_config: | |||
173 | config.driver_data = reg; | 173 | config.driver_data = reg; |
174 | config.regmap = rc5t583->regmap; | 174 | config.regmap = rc5t583->regmap; |
175 | 175 | ||
176 | rdev = regulator_register(&ri->desc, &config); | 176 | rdev = devm_regulator_register(&pdev->dev, &ri->desc, &config); |
177 | if (IS_ERR(rdev)) { | 177 | if (IS_ERR(rdev)) { |
178 | dev_err(&pdev->dev, "Failed to register regulator %s\n", | 178 | dev_err(&pdev->dev, "Failed to register regulator %s\n", |
179 | ri->desc.name); | 179 | ri->desc.name); |
180 | ret = PTR_ERR(rdev); | 180 | return PTR_ERR(rdev); |
181 | goto clean_exit; | ||
182 | } | 181 | } |
183 | reg->rdev = rdev; | 182 | reg->rdev = rdev; |
184 | } | 183 | } |
185 | platform_set_drvdata(pdev, regs); | 184 | platform_set_drvdata(pdev, regs); |
186 | return 0; | 185 | return 0; |
187 | |||
188 | clean_exit: | ||
189 | while (--id >= 0) | ||
190 | regulator_unregister(regs[id].rdev); | ||
191 | |||
192 | return ret; | ||
193 | } | ||
194 | |||
195 | static int rc5t583_regulator_remove(struct platform_device *pdev) | ||
196 | { | ||
197 | struct rc5t583_regulator *regs = platform_get_drvdata(pdev); | ||
198 | int id; | ||
199 | |||
200 | for (id = 0; id < RC5T583_REGULATOR_MAX; ++id) | ||
201 | regulator_unregister(regs[id].rdev); | ||
202 | return 0; | ||
203 | } | 186 | } |
204 | 187 | ||
205 | static struct platform_driver rc5t583_regulator_driver = { | 188 | static struct platform_driver rc5t583_regulator_driver = { |
@@ -208,7 +191,6 @@ static struct platform_driver rc5t583_regulator_driver = { | |||
208 | .owner = THIS_MODULE, | 191 | .owner = THIS_MODULE, |
209 | }, | 192 | }, |
210 | .probe = rc5t583_regulator_probe, | 193 | .probe = rc5t583_regulator_probe, |
211 | .remove = rc5t583_regulator_remove, | ||
212 | }; | 194 | }; |
213 | 195 | ||
214 | static int __init rc5t583_regulator_init(void) | 196 | static int __init rc5t583_regulator_init(void) |
diff --git a/drivers/regulator/s2mps11.c b/drivers/regulator/s2mps11.c index 5eba2ff8c0e8..333677d68d0e 100644 --- a/drivers/regulator/s2mps11.c +++ b/drivers/regulator/s2mps11.c | |||
@@ -448,33 +448,17 @@ common_reg: | |||
448 | config.of_node = rdata[i].of_node; | 448 | config.of_node = rdata[i].of_node; |
449 | } | 449 | } |
450 | 450 | ||
451 | s2mps11->rdev[i] = regulator_register(®ulators[i], &config); | 451 | s2mps11->rdev[i] = devm_regulator_register(&pdev->dev, |
452 | ®ulators[i], &config); | ||
452 | if (IS_ERR(s2mps11->rdev[i])) { | 453 | if (IS_ERR(s2mps11->rdev[i])) { |
453 | ret = PTR_ERR(s2mps11->rdev[i]); | 454 | ret = PTR_ERR(s2mps11->rdev[i]); |
454 | dev_err(&pdev->dev, "regulator init failed for %d\n", | 455 | dev_err(&pdev->dev, "regulator init failed for %d\n", |
455 | i); | 456 | i); |
456 | s2mps11->rdev[i] = NULL; | 457 | return ret; |
457 | goto err; | ||
458 | } | 458 | } |
459 | } | 459 | } |
460 | 460 | ||
461 | return 0; | 461 | return 0; |
462 | err: | ||
463 | for (i = 0; i < S2MPS11_REGULATOR_MAX; i++) | ||
464 | regulator_unregister(s2mps11->rdev[i]); | ||
465 | |||
466 | return ret; | ||
467 | } | ||
468 | |||
469 | static int s2mps11_pmic_remove(struct platform_device *pdev) | ||
470 | { | ||
471 | struct s2mps11_info *s2mps11 = platform_get_drvdata(pdev); | ||
472 | int i; | ||
473 | |||
474 | for (i = 0; i < S2MPS11_REGULATOR_MAX; i++) | ||
475 | regulator_unregister(s2mps11->rdev[i]); | ||
476 | |||
477 | return 0; | ||
478 | } | 462 | } |
479 | 463 | ||
480 | static const struct platform_device_id s2mps11_pmic_id[] = { | 464 | static const struct platform_device_id s2mps11_pmic_id[] = { |
@@ -489,7 +473,6 @@ static struct platform_driver s2mps11_pmic_driver = { | |||
489 | .owner = THIS_MODULE, | 473 | .owner = THIS_MODULE, |
490 | }, | 474 | }, |
491 | .probe = s2mps11_pmic_probe, | 475 | .probe = s2mps11_pmic_probe, |
492 | .remove = s2mps11_pmic_remove, | ||
493 | .id_table = s2mps11_pmic_id, | 476 | .id_table = s2mps11_pmic_id, |
494 | }; | 477 | }; |
495 | 478 | ||
diff --git a/drivers/regulator/s5m8767.c b/drivers/regulator/s5m8767.c index c24448bc43cf..cbf91e25cf7f 100644 --- a/drivers/regulator/s5m8767.c +++ b/drivers/regulator/s5m8767.c | |||
@@ -522,7 +522,7 @@ static int s5m8767_pmic_dt_parse_pdata(struct platform_device *pdev, | |||
522 | struct device_node *pmic_np, *regulators_np, *reg_np; | 522 | struct device_node *pmic_np, *regulators_np, *reg_np; |
523 | struct sec_regulator_data *rdata; | 523 | struct sec_regulator_data *rdata; |
524 | struct sec_opmode_data *rmode; | 524 | struct sec_opmode_data *rmode; |
525 | unsigned int i, dvs_voltage_nr = 1, ret; | 525 | unsigned int i, dvs_voltage_nr = 8, ret; |
526 | 526 | ||
527 | pmic_np = iodev->dev->of_node; | 527 | pmic_np = iodev->dev->of_node; |
528 | if (!pmic_np) { | 528 | if (!pmic_np) { |
@@ -586,15 +586,39 @@ static int s5m8767_pmic_dt_parse_pdata(struct platform_device *pdev, | |||
586 | rmode++; | 586 | rmode++; |
587 | } | 587 | } |
588 | 588 | ||
589 | if (of_get_property(pmic_np, "s5m8767,pmic-buck2-uses-gpio-dvs", NULL)) | 589 | if (of_get_property(pmic_np, "s5m8767,pmic-buck2-uses-gpio-dvs", NULL)) { |
590 | pdata->buck2_gpiodvs = true; | 590 | pdata->buck2_gpiodvs = true; |
591 | 591 | ||
592 | if (of_get_property(pmic_np, "s5m8767,pmic-buck3-uses-gpio-dvs", NULL)) | 592 | if (of_property_read_u32_array(pmic_np, |
593 | "s5m8767,pmic-buck2-dvs-voltage", | ||
594 | pdata->buck2_voltage, dvs_voltage_nr)) { | ||
595 | dev_err(iodev->dev, "buck2 voltages not specified\n"); | ||
596 | return -EINVAL; | ||
597 | } | ||
598 | } | ||
599 | |||
600 | if (of_get_property(pmic_np, "s5m8767,pmic-buck3-uses-gpio-dvs", NULL)) { | ||
593 | pdata->buck3_gpiodvs = true; | 601 | pdata->buck3_gpiodvs = true; |
594 | 602 | ||
595 | if (of_get_property(pmic_np, "s5m8767,pmic-buck4-uses-gpio-dvs", NULL)) | 603 | if (of_property_read_u32_array(pmic_np, |
604 | "s5m8767,pmic-buck3-dvs-voltage", | ||
605 | pdata->buck3_voltage, dvs_voltage_nr)) { | ||
606 | dev_err(iodev->dev, "buck3 voltages not specified\n"); | ||
607 | return -EINVAL; | ||
608 | } | ||
609 | } | ||
610 | |||
611 | if (of_get_property(pmic_np, "s5m8767,pmic-buck4-uses-gpio-dvs", NULL)) { | ||
596 | pdata->buck4_gpiodvs = true; | 612 | pdata->buck4_gpiodvs = true; |
597 | 613 | ||
614 | if (of_property_read_u32_array(pmic_np, | ||
615 | "s5m8767,pmic-buck4-dvs-voltage", | ||
616 | pdata->buck4_voltage, dvs_voltage_nr)) { | ||
617 | dev_err(iodev->dev, "buck4 voltages not specified\n"); | ||
618 | return -EINVAL; | ||
619 | } | ||
620 | } | ||
621 | |||
598 | if (pdata->buck2_gpiodvs || pdata->buck3_gpiodvs || | 622 | if (pdata->buck2_gpiodvs || pdata->buck3_gpiodvs || |
599 | pdata->buck4_gpiodvs) { | 623 | pdata->buck4_gpiodvs) { |
600 | ret = s5m8767_pmic_dt_parse_dvs_gpio(iodev, pdata, pmic_np); | 624 | ret = s5m8767_pmic_dt_parse_dvs_gpio(iodev, pdata, pmic_np); |
@@ -612,32 +636,26 @@ static int s5m8767_pmic_dt_parse_pdata(struct platform_device *pdev, | |||
612 | "invalid value for default dvs index, use 0\n"); | 636 | "invalid value for default dvs index, use 0\n"); |
613 | } | 637 | } |
614 | } | 638 | } |
615 | dvs_voltage_nr = 8; | ||
616 | } | 639 | } |
617 | 640 | ||
618 | ret = s5m8767_pmic_dt_parse_ds_gpio(iodev, pdata, pmic_np); | 641 | ret = s5m8767_pmic_dt_parse_ds_gpio(iodev, pdata, pmic_np); |
619 | if (ret) | 642 | if (ret) |
620 | return -EINVAL; | 643 | return -EINVAL; |
621 | 644 | ||
622 | if (of_property_read_u32_array(pmic_np, | 645 | if (of_get_property(pmic_np, "s5m8767,pmic-buck2-ramp-enable", NULL)) |
623 | "s5m8767,pmic-buck2-dvs-voltage", | 646 | pdata->buck2_ramp_enable = true; |
624 | pdata->buck2_voltage, dvs_voltage_nr)) { | ||
625 | dev_err(iodev->dev, "buck2 voltages not specified\n"); | ||
626 | return -EINVAL; | ||
627 | } | ||
628 | 647 | ||
629 | if (of_property_read_u32_array(pmic_np, | 648 | if (of_get_property(pmic_np, "s5m8767,pmic-buck3-ramp-enable", NULL)) |
630 | "s5m8767,pmic-buck3-dvs-voltage", | 649 | pdata->buck3_ramp_enable = true; |
631 | pdata->buck3_voltage, dvs_voltage_nr)) { | ||
632 | dev_err(iodev->dev, "buck3 voltages not specified\n"); | ||
633 | return -EINVAL; | ||
634 | } | ||
635 | 650 | ||
636 | if (of_property_read_u32_array(pmic_np, | 651 | if (of_get_property(pmic_np, "s5m8767,pmic-buck4-ramp-enable", NULL)) |
637 | "s5m8767,pmic-buck4-dvs-voltage", | 652 | pdata->buck4_ramp_enable = true; |
638 | pdata->buck4_voltage, dvs_voltage_nr)) { | 653 | |
639 | dev_err(iodev->dev, "buck4 voltages not specified\n"); | 654 | if (pdata->buck2_ramp_enable || pdata->buck3_ramp_enable |
640 | return -EINVAL; | 655 | || pdata->buck4_ramp_enable) { |
656 | if (of_property_read_u32(pmic_np, "s5m8767,pmic-buck-ramp-delay", | ||
657 | &pdata->buck_ramp_delay)) | ||
658 | pdata->buck_ramp_delay = 0; | ||
641 | } | 659 | } |
642 | 660 | ||
643 | return 0; | 661 | return 0; |
@@ -910,34 +928,17 @@ static int s5m8767_pmic_probe(struct platform_device *pdev) | |||
910 | config.regmap = iodev->regmap; | 928 | config.regmap = iodev->regmap; |
911 | config.of_node = pdata->regulators[i].reg_node; | 929 | config.of_node = pdata->regulators[i].reg_node; |
912 | 930 | ||
913 | rdev[i] = regulator_register(®ulators[id], &config); | 931 | rdev[i] = devm_regulator_register(&pdev->dev, ®ulators[id], |
932 | &config); | ||
914 | if (IS_ERR(rdev[i])) { | 933 | if (IS_ERR(rdev[i])) { |
915 | ret = PTR_ERR(rdev[i]); | 934 | ret = PTR_ERR(rdev[i]); |
916 | dev_err(s5m8767->dev, "regulator init failed for %d\n", | 935 | dev_err(s5m8767->dev, "regulator init failed for %d\n", |
917 | id); | 936 | id); |
918 | rdev[i] = NULL; | 937 | return ret; |
919 | goto err; | ||
920 | } | 938 | } |
921 | } | 939 | } |
922 | 940 | ||
923 | return 0; | 941 | return 0; |
924 | err: | ||
925 | for (i = 0; i < s5m8767->num_regulators; i++) | ||
926 | regulator_unregister(rdev[i]); | ||
927 | |||
928 | return ret; | ||
929 | } | ||
930 | |||
931 | static int s5m8767_pmic_remove(struct platform_device *pdev) | ||
932 | { | ||
933 | struct s5m8767_info *s5m8767 = platform_get_drvdata(pdev); | ||
934 | struct regulator_dev **rdev = s5m8767->rdev; | ||
935 | int i; | ||
936 | |||
937 | for (i = 0; i < s5m8767->num_regulators; i++) | ||
938 | regulator_unregister(rdev[i]); | ||
939 | |||
940 | return 0; | ||
941 | } | 942 | } |
942 | 943 | ||
943 | static const struct platform_device_id s5m8767_pmic_id[] = { | 944 | static const struct platform_device_id s5m8767_pmic_id[] = { |
@@ -952,7 +953,6 @@ static struct platform_driver s5m8767_pmic_driver = { | |||
952 | .owner = THIS_MODULE, | 953 | .owner = THIS_MODULE, |
953 | }, | 954 | }, |
954 | .probe = s5m8767_pmic_probe, | 955 | .probe = s5m8767_pmic_probe, |
955 | .remove = s5m8767_pmic_remove, | ||
956 | .id_table = s5m8767_pmic_id, | 956 | .id_table = s5m8767_pmic_id, |
957 | }; | 957 | }; |
958 | 958 | ||
diff --git a/drivers/regulator/stw481x-vmmc.c b/drivers/regulator/stw481x-vmmc.c new file mode 100644 index 000000000000..f78857bd6a15 --- /dev/null +++ b/drivers/regulator/stw481x-vmmc.c | |||
@@ -0,0 +1,111 @@ | |||
1 | /* | ||
2 | * Regulator driver for STw4810/STw4811 VMMC regulator. | ||
3 | * | ||
4 | * Copyright (C) 2013 ST-Ericsson SA | ||
5 | * Written on behalf of Linaro for ST-Ericsson | ||
6 | * | ||
7 | * Author: Linus Walleij <linus.walleij@linaro.org> | ||
8 | * | ||
9 | * License terms: GNU General Public License (GPL) version 2 | ||
10 | */ | ||
11 | |||
12 | #include <linux/err.h> | ||
13 | #include <linux/init.h> | ||
14 | #include <linux/mfd/stw481x.h> | ||
15 | #include <linux/module.h> | ||
16 | #include <linux/platform_device.h> | ||
17 | #include <linux/regulator/driver.h> | ||
18 | #include <linux/regulator/of_regulator.h> | ||
19 | |||
20 | static const unsigned int stw481x_vmmc_voltages[] = { | ||
21 | 1800000, | ||
22 | 1800000, | ||
23 | 2850000, | ||
24 | 3000000, | ||
25 | 1850000, | ||
26 | 2600000, | ||
27 | 2700000, | ||
28 | 3300000, | ||
29 | }; | ||
30 | |||
31 | static struct regulator_ops stw481x_vmmc_ops = { | ||
32 | .list_voltage = regulator_list_voltage_table, | ||
33 | .enable = regulator_enable_regmap, | ||
34 | .disable = regulator_disable_regmap, | ||
35 | .is_enabled = regulator_is_enabled_regmap, | ||
36 | .get_voltage_sel = regulator_get_voltage_sel_regmap, | ||
37 | .set_voltage_sel = regulator_set_voltage_sel_regmap, | ||
38 | }; | ||
39 | |||
40 | static struct regulator_desc vmmc_regulator = { | ||
41 | .name = "VMMC", | ||
42 | .id = 0, | ||
43 | .ops = &stw481x_vmmc_ops, | ||
44 | .type = REGULATOR_VOLTAGE, | ||
45 | .owner = THIS_MODULE, | ||
46 | .n_voltages = ARRAY_SIZE(stw481x_vmmc_voltages), | ||
47 | .volt_table = stw481x_vmmc_voltages, | ||
48 | .enable_time = 200, /* FIXME: look this up */ | ||
49 | .enable_reg = STW_CONF1, | ||
50 | .enable_mask = STW_CONF1_PDN_VMMC, | ||
51 | .vsel_reg = STW_CONF1, | ||
52 | .vsel_mask = STW_CONF1_VMMC_MASK, | ||
53 | }; | ||
54 | |||
55 | static int stw481x_vmmc_regulator_probe(struct platform_device *pdev) | ||
56 | { | ||
57 | struct stw481x *stw481x = dev_get_platdata(&pdev->dev); | ||
58 | struct regulator_config config = { }; | ||
59 | int ret; | ||
60 | |||
61 | /* First disable the external VMMC if it's active */ | ||
62 | ret = regmap_update_bits(stw481x->map, STW_CONF2, | ||
63 | STW_CONF2_VMMC_EXT, 0); | ||
64 | if (ret) { | ||
65 | dev_err(&pdev->dev, "could not disable external VMMC\n"); | ||
66 | return ret; | ||
67 | } | ||
68 | |||
69 | /* Register VMMC regulator */ | ||
70 | config.dev = &pdev->dev; | ||
71 | config.driver_data = stw481x; | ||
72 | config.regmap = stw481x->map; | ||
73 | config.of_node = pdev->dev.of_node; | ||
74 | config.init_data = of_get_regulator_init_data(&pdev->dev, | ||
75 | pdev->dev.of_node); | ||
76 | |||
77 | stw481x->vmmc_regulator = regulator_register(&vmmc_regulator, &config); | ||
78 | if (IS_ERR(stw481x->vmmc_regulator)) { | ||
79 | dev_err(&pdev->dev, | ||
80 | "error initializing STw481x VMMC regulator\n"); | ||
81 | return PTR_ERR(stw481x->vmmc_regulator); | ||
82 | } | ||
83 | |||
84 | dev_info(&pdev->dev, "initialized STw481x VMMC regulator\n"); | ||
85 | return 0; | ||
86 | } | ||
87 | |||
88 | static int stw481x_vmmc_regulator_remove(struct platform_device *pdev) | ||
89 | { | ||
90 | struct stw481x *stw481x = dev_get_platdata(&pdev->dev); | ||
91 | |||
92 | regulator_unregister(stw481x->vmmc_regulator); | ||
93 | return 0; | ||
94 | } | ||
95 | |||
96 | static const struct of_device_id stw481x_vmmc_match[] = { | ||
97 | { .compatible = "st,stw481x-vmmc", }, | ||
98 | {}, | ||
99 | }; | ||
100 | |||
101 | static struct platform_driver stw481x_vmmc_regulator_driver = { | ||
102 | .driver = { | ||
103 | .name = "stw481x-vmmc-regulator", | ||
104 | .owner = THIS_MODULE, | ||
105 | .of_match_table = stw481x_vmmc_match, | ||
106 | }, | ||
107 | .probe = stw481x_vmmc_regulator_probe, | ||
108 | .remove = stw481x_vmmc_regulator_remove, | ||
109 | }; | ||
110 | |||
111 | module_platform_driver(stw481x_vmmc_regulator_driver); | ||
diff --git a/drivers/regulator/ti-abb-regulator.c b/drivers/regulator/ti-abb-regulator.c index 20c271d49dcb..b187b6bba7ad 100644 --- a/drivers/regulator/ti-abb-regulator.c +++ b/drivers/regulator/ti-abb-regulator.c | |||
@@ -615,7 +615,7 @@ static int ti_abb_init_table(struct device *dev, struct ti_abb *abb, | |||
615 | pname, *volt_table, vset_mask); | 615 | pname, *volt_table, vset_mask); |
616 | continue; | 616 | continue; |
617 | } | 617 | } |
618 | info->vset = efuse_val & vset_mask >> __ffs(vset_mask); | 618 | info->vset = (efuse_val & vset_mask) >> __ffs(vset_mask); |
619 | dev_dbg(dev, "[%d]v=%d vset=%x\n", i, *volt_table, info->vset); | 619 | dev_dbg(dev, "[%d]v=%d vset=%x\n", i, *volt_table, info->vset); |
620 | check_abb: | 620 | check_abb: |
621 | switch (info->opp_sel) { | 621 | switch (info->opp_sel) { |
@@ -708,39 +708,31 @@ static int ti_abb_probe(struct platform_device *pdev) | |||
708 | match = of_match_device(ti_abb_of_match, dev); | 708 | match = of_match_device(ti_abb_of_match, dev); |
709 | if (!match) { | 709 | if (!match) { |
710 | /* We do not expect this to happen */ | 710 | /* We do not expect this to happen */ |
711 | ret = -ENODEV; | ||
712 | dev_err(dev, "%s: Unable to match device\n", __func__); | 711 | dev_err(dev, "%s: Unable to match device\n", __func__); |
713 | goto err; | 712 | return -ENODEV; |
714 | } | 713 | } |
715 | if (!match->data) { | 714 | if (!match->data) { |
716 | ret = -EINVAL; | ||
717 | dev_err(dev, "%s: Bad data in match\n", __func__); | 715 | dev_err(dev, "%s: Bad data in match\n", __func__); |
718 | goto err; | 716 | return -EINVAL; |
719 | } | 717 | } |
720 | 718 | ||
721 | abb = devm_kzalloc(dev, sizeof(struct ti_abb), GFP_KERNEL); | 719 | abb = devm_kzalloc(dev, sizeof(struct ti_abb), GFP_KERNEL); |
722 | if (!abb) { | 720 | if (!abb) |
723 | dev_err(dev, "%s: Unable to allocate ABB struct\n", __func__); | 721 | return -ENOMEM; |
724 | ret = -ENOMEM; | ||
725 | goto err; | ||
726 | } | ||
727 | abb->regs = match->data; | 722 | abb->regs = match->data; |
728 | 723 | ||
729 | /* Map ABB resources */ | 724 | /* Map ABB resources */ |
730 | pname = "base-address"; | 725 | pname = "base-address"; |
731 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, pname); | 726 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, pname); |
732 | abb->base = devm_ioremap_resource(dev, res); | 727 | abb->base = devm_ioremap_resource(dev, res); |
733 | if (IS_ERR(abb->base)) { | 728 | if (IS_ERR(abb->base)) |
734 | ret = PTR_ERR(abb->base); | 729 | return PTR_ERR(abb->base); |
735 | goto err; | ||
736 | } | ||
737 | 730 | ||
738 | pname = "int-address"; | 731 | pname = "int-address"; |
739 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, pname); | 732 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, pname); |
740 | if (!res) { | 733 | if (!res) { |
741 | dev_err(dev, "Missing '%s' IO resource\n", pname); | 734 | dev_err(dev, "Missing '%s' IO resource\n", pname); |
742 | ret = -ENODEV; | 735 | return -ENODEV; |
743 | goto err; | ||
744 | } | 736 | } |
745 | /* | 737 | /* |
746 | * We may have shared interrupt register offsets which are | 738 | * We may have shared interrupt register offsets which are |
@@ -750,8 +742,7 @@ static int ti_abb_probe(struct platform_device *pdev) | |||
750 | resource_size(res)); | 742 | resource_size(res)); |
751 | if (!abb->int_base) { | 743 | if (!abb->int_base) { |
752 | dev_err(dev, "Unable to map '%s'\n", pname); | 744 | dev_err(dev, "Unable to map '%s'\n", pname); |
753 | ret = -ENOMEM; | 745 | return -ENOMEM; |
754 | goto err; | ||
755 | } | 746 | } |
756 | 747 | ||
757 | /* Map Optional resources */ | 748 | /* Map Optional resources */ |
@@ -771,17 +762,19 @@ static int ti_abb_probe(struct platform_device *pdev) | |||
771 | resource_size(res)); | 762 | resource_size(res)); |
772 | if (!abb->efuse_base) { | 763 | if (!abb->efuse_base) { |
773 | dev_err(dev, "Unable to map '%s'\n", pname); | 764 | dev_err(dev, "Unable to map '%s'\n", pname); |
774 | ret = -ENOMEM; | 765 | return -ENOMEM; |
775 | goto err; | ||
776 | } | 766 | } |
777 | 767 | ||
778 | pname = "ldo-address"; | 768 | pname = "ldo-address"; |
779 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, pname); | 769 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, pname); |
780 | abb->ldo_base = devm_ioremap_resource(dev, res); | 770 | if (!res) { |
781 | if (IS_ERR(abb->ldo_base)) { | 771 | dev_dbg(dev, "Missing '%s' IO resource\n", pname); |
782 | ret = PTR_ERR(abb->ldo_base); | 772 | ret = -ENODEV; |
783 | goto err; | 773 | goto skip_opt; |
784 | } | 774 | } |
775 | abb->ldo_base = devm_ioremap_resource(dev, res); | ||
776 | if (IS_ERR(abb->ldo_base)) | ||
777 | return PTR_ERR(abb->ldo_base); | ||
785 | 778 | ||
786 | /* IF ldo_base is set, the following are mandatory */ | 779 | /* IF ldo_base is set, the following are mandatory */ |
787 | pname = "ti,ldovbb-override-mask"; | 780 | pname = "ti,ldovbb-override-mask"; |
@@ -790,12 +783,11 @@ static int ti_abb_probe(struct platform_device *pdev) | |||
790 | &abb->ldovbb_override_mask); | 783 | &abb->ldovbb_override_mask); |
791 | if (ret) { | 784 | if (ret) { |
792 | dev_err(dev, "Missing '%s' (%d)\n", pname, ret); | 785 | dev_err(dev, "Missing '%s' (%d)\n", pname, ret); |
793 | goto err; | 786 | return ret; |
794 | } | 787 | } |
795 | if (!abb->ldovbb_override_mask) { | 788 | if (!abb->ldovbb_override_mask) { |
796 | dev_err(dev, "Invalid property:'%s' set as 0!\n", pname); | 789 | dev_err(dev, "Invalid property:'%s' set as 0!\n", pname); |
797 | ret = -EINVAL; | 790 | return -EINVAL; |
798 | goto err; | ||
799 | } | 791 | } |
800 | 792 | ||
801 | pname = "ti,ldovbb-vset-mask"; | 793 | pname = "ti,ldovbb-vset-mask"; |
@@ -804,12 +796,11 @@ static int ti_abb_probe(struct platform_device *pdev) | |||
804 | &abb->ldovbb_vset_mask); | 796 | &abb->ldovbb_vset_mask); |
805 | if (ret) { | 797 | if (ret) { |
806 | dev_err(dev, "Missing '%s' (%d)\n", pname, ret); | 798 | dev_err(dev, "Missing '%s' (%d)\n", pname, ret); |
807 | goto err; | 799 | return ret; |
808 | } | 800 | } |
809 | if (!abb->ldovbb_vset_mask) { | 801 | if (!abb->ldovbb_vset_mask) { |
810 | dev_err(dev, "Invalid property:'%s' set as 0!\n", pname); | 802 | dev_err(dev, "Invalid property:'%s' set as 0!\n", pname); |
811 | ret = -EINVAL; | 803 | return -EINVAL; |
812 | goto err; | ||
813 | } | 804 | } |
814 | 805 | ||
815 | skip_opt: | 806 | skip_opt: |
@@ -819,31 +810,29 @@ skip_opt: | |||
819 | &abb->txdone_mask); | 810 | &abb->txdone_mask); |
820 | if (ret) { | 811 | if (ret) { |
821 | dev_err(dev, "Missing '%s' (%d)\n", pname, ret); | 812 | dev_err(dev, "Missing '%s' (%d)\n", pname, ret); |
822 | goto err; | 813 | return ret; |
823 | } | 814 | } |
824 | if (!abb->txdone_mask) { | 815 | if (!abb->txdone_mask) { |
825 | dev_err(dev, "Invalid property:'%s' set as 0!\n", pname); | 816 | dev_err(dev, "Invalid property:'%s' set as 0!\n", pname); |
826 | ret = -EINVAL; | 817 | return -EINVAL; |
827 | goto err; | ||
828 | } | 818 | } |
829 | 819 | ||
830 | initdata = of_get_regulator_init_data(dev, pdev->dev.of_node); | 820 | initdata = of_get_regulator_init_data(dev, pdev->dev.of_node); |
831 | if (!initdata) { | 821 | if (!initdata) { |
832 | ret = -ENOMEM; | ||
833 | dev_err(dev, "%s: Unable to alloc regulator init data\n", | 822 | dev_err(dev, "%s: Unable to alloc regulator init data\n", |
834 | __func__); | 823 | __func__); |
835 | goto err; | 824 | return -ENOMEM; |
836 | } | 825 | } |
837 | 826 | ||
838 | /* init ABB opp_sel table */ | 827 | /* init ABB opp_sel table */ |
839 | ret = ti_abb_init_table(dev, abb, initdata); | 828 | ret = ti_abb_init_table(dev, abb, initdata); |
840 | if (ret) | 829 | if (ret) |
841 | goto err; | 830 | return ret; |
842 | 831 | ||
843 | /* init ABB timing */ | 832 | /* init ABB timing */ |
844 | ret = ti_abb_init_timings(dev, abb); | 833 | ret = ti_abb_init_timings(dev, abb); |
845 | if (ret) | 834 | if (ret) |
846 | goto err; | 835 | return ret; |
847 | 836 | ||
848 | desc = &abb->rdesc; | 837 | desc = &abb->rdesc; |
849 | desc->name = dev_name(dev); | 838 | desc->name = dev_name(dev); |
@@ -861,12 +850,12 @@ skip_opt: | |||
861 | config.driver_data = abb; | 850 | config.driver_data = abb; |
862 | config.of_node = pdev->dev.of_node; | 851 | config.of_node = pdev->dev.of_node; |
863 | 852 | ||
864 | rdev = regulator_register(desc, &config); | 853 | rdev = devm_regulator_register(dev, desc, &config); |
865 | if (IS_ERR(rdev)) { | 854 | if (IS_ERR(rdev)) { |
866 | ret = PTR_ERR(rdev); | 855 | ret = PTR_ERR(rdev); |
867 | dev_err(dev, "%s: failed to register regulator(%d)\n", | 856 | dev_err(dev, "%s: failed to register regulator(%d)\n", |
868 | __func__, ret); | 857 | __func__, ret); |
869 | goto err; | 858 | return ret; |
870 | } | 859 | } |
871 | platform_set_drvdata(pdev, rdev); | 860 | platform_set_drvdata(pdev, rdev); |
872 | 861 | ||
@@ -874,31 +863,12 @@ skip_opt: | |||
874 | ti_abb_rmw(abb->regs->sr2_en_mask, 1, abb->regs->setup_reg, abb->base); | 863 | ti_abb_rmw(abb->regs->sr2_en_mask, 1, abb->regs->setup_reg, abb->base); |
875 | 864 | ||
876 | return 0; | 865 | return 0; |
877 | |||
878 | err: | ||
879 | dev_err(dev, "%s: Failed to initialize(%d)\n", __func__, ret); | ||
880 | return ret; | ||
881 | } | ||
882 | |||
883 | /** | ||
884 | * ti_abb_remove() - cleanups | ||
885 | * @pdev: ABB platform device | ||
886 | * | ||
887 | * Return: 0 | ||
888 | */ | ||
889 | static int ti_abb_remove(struct platform_device *pdev) | ||
890 | { | ||
891 | struct regulator_dev *rdev = platform_get_drvdata(pdev); | ||
892 | |||
893 | regulator_unregister(rdev); | ||
894 | return 0; | ||
895 | } | 866 | } |
896 | 867 | ||
897 | MODULE_ALIAS("platform:ti_abb"); | 868 | MODULE_ALIAS("platform:ti_abb"); |
898 | 869 | ||
899 | static struct platform_driver ti_abb_driver = { | 870 | static struct platform_driver ti_abb_driver = { |
900 | .probe = ti_abb_probe, | 871 | .probe = ti_abb_probe, |
901 | .remove = ti_abb_remove, | ||
902 | .driver = { | 872 | .driver = { |
903 | .name = "ti_abb", | 873 | .name = "ti_abb", |
904 | .owner = THIS_MODULE, | 874 | .owner = THIS_MODULE, |
diff --git a/drivers/regulator/tps51632-regulator.c b/drivers/regulator/tps51632-regulator.c index 9392a7ca3d2d..b0a3f0917a27 100644 --- a/drivers/regulator/tps51632-regulator.c +++ b/drivers/regulator/tps51632-regulator.c | |||
@@ -343,7 +343,7 @@ static int tps51632_probe(struct i2c_client *client, | |||
343 | config.regmap = tps->regmap; | 343 | config.regmap = tps->regmap; |
344 | config.of_node = client->dev.of_node; | 344 | config.of_node = client->dev.of_node; |
345 | 345 | ||
346 | rdev = regulator_register(&tps->desc, &config); | 346 | rdev = devm_regulator_register(&client->dev, &tps->desc, &config); |
347 | if (IS_ERR(rdev)) { | 347 | if (IS_ERR(rdev)) { |
348 | dev_err(tps->dev, "regulator register failed\n"); | 348 | dev_err(tps->dev, "regulator register failed\n"); |
349 | return PTR_ERR(rdev); | 349 | return PTR_ERR(rdev); |
@@ -353,14 +353,6 @@ static int tps51632_probe(struct i2c_client *client, | |||
353 | return 0; | 353 | return 0; |
354 | } | 354 | } |
355 | 355 | ||
356 | static int tps51632_remove(struct i2c_client *client) | ||
357 | { | ||
358 | struct tps51632_chip *tps = i2c_get_clientdata(client); | ||
359 | |||
360 | regulator_unregister(tps->rdev); | ||
361 | return 0; | ||
362 | } | ||
363 | |||
364 | static const struct i2c_device_id tps51632_id[] = { | 356 | static const struct i2c_device_id tps51632_id[] = { |
365 | {.name = "tps51632",}, | 357 | {.name = "tps51632",}, |
366 | {}, | 358 | {}, |
@@ -375,7 +367,6 @@ static struct i2c_driver tps51632_i2c_driver = { | |||
375 | .of_match_table = of_match_ptr(tps51632_of_match), | 367 | .of_match_table = of_match_ptr(tps51632_of_match), |
376 | }, | 368 | }, |
377 | .probe = tps51632_probe, | 369 | .probe = tps51632_probe, |
378 | .remove = tps51632_remove, | ||
379 | .id_table = tps51632_id, | 370 | .id_table = tps51632_id, |
380 | }; | 371 | }; |
381 | 372 | ||
diff --git a/drivers/regulator/tps6105x-regulator.c b/drivers/regulator/tps6105x-regulator.c index ec9453ffb77f..c1e33a3d397b 100644 --- a/drivers/regulator/tps6105x-regulator.c +++ b/drivers/regulator/tps6105x-regulator.c | |||
@@ -137,7 +137,7 @@ static int tps6105x_regulator_probe(struct platform_device *pdev) | |||
137 | /* This instance is not set for regulator mode so bail out */ | 137 | /* This instance is not set for regulator mode so bail out */ |
138 | if (pdata->mode != TPS6105X_MODE_VOLTAGE) { | 138 | if (pdata->mode != TPS6105X_MODE_VOLTAGE) { |
139 | dev_info(&pdev->dev, | 139 | dev_info(&pdev->dev, |
140 | "chip not in voltage mode mode, exit probe \n"); | 140 | "chip not in voltage mode mode, exit probe\n"); |
141 | return 0; | 141 | return 0; |
142 | } | 142 | } |
143 | 143 | ||
@@ -146,8 +146,9 @@ static int tps6105x_regulator_probe(struct platform_device *pdev) | |||
146 | config.driver_data = tps6105x; | 146 | config.driver_data = tps6105x; |
147 | 147 | ||
148 | /* Register regulator with framework */ | 148 | /* Register regulator with framework */ |
149 | tps6105x->regulator = regulator_register(&tps6105x_regulator_desc, | 149 | tps6105x->regulator = devm_regulator_register(&pdev->dev, |
150 | &config); | 150 | &tps6105x_regulator_desc, |
151 | &config); | ||
151 | if (IS_ERR(tps6105x->regulator)) { | 152 | if (IS_ERR(tps6105x->regulator)) { |
152 | ret = PTR_ERR(tps6105x->regulator); | 153 | ret = PTR_ERR(tps6105x->regulator); |
153 | dev_err(&tps6105x->client->dev, | 154 | dev_err(&tps6105x->client->dev, |
@@ -159,20 +160,12 @@ static int tps6105x_regulator_probe(struct platform_device *pdev) | |||
159 | return 0; | 160 | return 0; |
160 | } | 161 | } |
161 | 162 | ||
162 | static int tps6105x_regulator_remove(struct platform_device *pdev) | ||
163 | { | ||
164 | struct tps6105x *tps6105x = dev_get_platdata(&pdev->dev); | ||
165 | regulator_unregister(tps6105x->regulator); | ||
166 | return 0; | ||
167 | } | ||
168 | |||
169 | static struct platform_driver tps6105x_regulator_driver = { | 163 | static struct platform_driver tps6105x_regulator_driver = { |
170 | .driver = { | 164 | .driver = { |
171 | .name = "tps6105x-regulator", | 165 | .name = "tps6105x-regulator", |
172 | .owner = THIS_MODULE, | 166 | .owner = THIS_MODULE, |
173 | }, | 167 | }, |
174 | .probe = tps6105x_regulator_probe, | 168 | .probe = tps6105x_regulator_probe, |
175 | .remove = tps6105x_regulator_remove, | ||
176 | }; | 169 | }; |
177 | 170 | ||
178 | static __init int tps6105x_regulator_init(void) | 171 | static __init int tps6105x_regulator_init(void) |
diff --git a/drivers/regulator/tps62360-regulator.c b/drivers/regulator/tps62360-regulator.c index 0b7ebb1ebf85..c2c0185a2dcd 100644 --- a/drivers/regulator/tps62360-regulator.c +++ b/drivers/regulator/tps62360-regulator.c | |||
@@ -476,7 +476,7 @@ static int tps62360_probe(struct i2c_client *client, | |||
476 | config.of_node = client->dev.of_node; | 476 | config.of_node = client->dev.of_node; |
477 | 477 | ||
478 | /* Register the regulators */ | 478 | /* Register the regulators */ |
479 | rdev = regulator_register(&tps->desc, &config); | 479 | rdev = devm_regulator_register(&client->dev, &tps->desc, &config); |
480 | if (IS_ERR(rdev)) { | 480 | if (IS_ERR(rdev)) { |
481 | dev_err(tps->dev, | 481 | dev_err(tps->dev, |
482 | "%s(): regulator register failed with err %s\n", | 482 | "%s(): regulator register failed with err %s\n", |
@@ -488,20 +488,6 @@ static int tps62360_probe(struct i2c_client *client, | |||
488 | return 0; | 488 | return 0; |
489 | } | 489 | } |
490 | 490 | ||
491 | /** | ||
492 | * tps62360_remove - tps62360 driver i2c remove handler | ||
493 | * @client: i2c driver client device structure | ||
494 | * | ||
495 | * Unregister TPS driver as an i2c client device driver | ||
496 | */ | ||
497 | static int tps62360_remove(struct i2c_client *client) | ||
498 | { | ||
499 | struct tps62360_chip *tps = i2c_get_clientdata(client); | ||
500 | |||
501 | regulator_unregister(tps->rdev); | ||
502 | return 0; | ||
503 | } | ||
504 | |||
505 | static void tps62360_shutdown(struct i2c_client *client) | 491 | static void tps62360_shutdown(struct i2c_client *client) |
506 | { | 492 | { |
507 | struct tps62360_chip *tps = i2c_get_clientdata(client); | 493 | struct tps62360_chip *tps = i2c_get_clientdata(client); |
@@ -535,7 +521,6 @@ static struct i2c_driver tps62360_i2c_driver = { | |||
535 | .of_match_table = of_match_ptr(tps62360_of_match), | 521 | .of_match_table = of_match_ptr(tps62360_of_match), |
536 | }, | 522 | }, |
537 | .probe = tps62360_probe, | 523 | .probe = tps62360_probe, |
538 | .remove = tps62360_remove, | ||
539 | .shutdown = tps62360_shutdown, | 524 | .shutdown = tps62360_shutdown, |
540 | .id_table = tps62360_id, | 525 | .id_table = tps62360_id, |
541 | }; | 526 | }; |
diff --git a/drivers/regulator/tps65023-regulator.c b/drivers/regulator/tps65023-regulator.c index f6e398240686..3ef67a86115c 100644 --- a/drivers/regulator/tps65023-regulator.c +++ b/drivers/regulator/tps65023-regulator.c | |||
@@ -277,12 +277,12 @@ static int tps_65023_probe(struct i2c_client *client, | |||
277 | config.regmap = tps->regmap; | 277 | config.regmap = tps->regmap; |
278 | 278 | ||
279 | /* Register the regulators */ | 279 | /* Register the regulators */ |
280 | rdev = regulator_register(&tps->desc[i], &config); | 280 | rdev = devm_regulator_register(&client->dev, &tps->desc[i], |
281 | &config); | ||
281 | if (IS_ERR(rdev)) { | 282 | if (IS_ERR(rdev)) { |
282 | dev_err(&client->dev, "failed to register %s\n", | 283 | dev_err(&client->dev, "failed to register %s\n", |
283 | id->name); | 284 | id->name); |
284 | error = PTR_ERR(rdev); | 285 | return PTR_ERR(rdev); |
285 | goto fail; | ||
286 | } | 286 | } |
287 | 287 | ||
288 | /* Save regulator for cleanup */ | 288 | /* Save regulator for cleanup */ |
@@ -297,21 +297,6 @@ static int tps_65023_probe(struct i2c_client *client, | |||
297 | TPS65023_REG_CTRL2_CORE_ADJ); | 297 | TPS65023_REG_CTRL2_CORE_ADJ); |
298 | 298 | ||
299 | return 0; | 299 | return 0; |
300 | |||
301 | fail: | ||
302 | while (--i >= 0) | ||
303 | regulator_unregister(tps->rdev[i]); | ||
304 | return error; | ||
305 | } | ||
306 | |||
307 | static int tps_65023_remove(struct i2c_client *client) | ||
308 | { | ||
309 | struct tps_pmic *tps = i2c_get_clientdata(client); | ||
310 | int i; | ||
311 | |||
312 | for (i = 0; i < TPS65023_NUM_REGULATOR; i++) | ||
313 | regulator_unregister(tps->rdev[i]); | ||
314 | return 0; | ||
315 | } | 300 | } |
316 | 301 | ||
317 | static const struct tps_info tps65020_regs[] = { | 302 | static const struct tps_info tps65020_regs[] = { |
@@ -431,7 +416,6 @@ static struct i2c_driver tps_65023_i2c_driver = { | |||
431 | .owner = THIS_MODULE, | 416 | .owner = THIS_MODULE, |
432 | }, | 417 | }, |
433 | .probe = tps_65023_probe, | 418 | .probe = tps_65023_probe, |
434 | .remove = tps_65023_remove, | ||
435 | .id_table = tps_65023_id, | 419 | .id_table = tps_65023_id, |
436 | }; | 420 | }; |
437 | 421 | ||
diff --git a/drivers/regulator/tps6507x-regulator.c b/drivers/regulator/tps6507x-regulator.c index 4117ff52dba1..162a0fae20b3 100644 --- a/drivers/regulator/tps6507x-regulator.c +++ b/drivers/regulator/tps6507x-regulator.c | |||
@@ -508,13 +508,13 @@ static int tps6507x_pmic_probe(struct platform_device *pdev) | |||
508 | config.of_node = tps6507x_reg_matches[i].of_node; | 508 | config.of_node = tps6507x_reg_matches[i].of_node; |
509 | } | 509 | } |
510 | 510 | ||
511 | rdev = regulator_register(&tps->desc[i], &config); | 511 | rdev = devm_regulator_register(&pdev->dev, &tps->desc[i], |
512 | &config); | ||
512 | if (IS_ERR(rdev)) { | 513 | if (IS_ERR(rdev)) { |
513 | dev_err(tps6507x_dev->dev, | 514 | dev_err(tps6507x_dev->dev, |
514 | "failed to register %s regulator\n", | 515 | "failed to register %s regulator\n", |
515 | pdev->name); | 516 | pdev->name); |
516 | error = PTR_ERR(rdev); | 517 | return PTR_ERR(rdev); |
517 | goto fail; | ||
518 | } | 518 | } |
519 | 519 | ||
520 | /* Save regulator for cleanup */ | 520 | /* Save regulator for cleanup */ |
@@ -525,22 +525,6 @@ static int tps6507x_pmic_probe(struct platform_device *pdev) | |||
525 | platform_set_drvdata(pdev, tps6507x_dev); | 525 | platform_set_drvdata(pdev, tps6507x_dev); |
526 | 526 | ||
527 | return 0; | 527 | return 0; |
528 | |||
529 | fail: | ||
530 | while (--i >= 0) | ||
531 | regulator_unregister(tps->rdev[i]); | ||
532 | return error; | ||
533 | } | ||
534 | |||
535 | static int tps6507x_pmic_remove(struct platform_device *pdev) | ||
536 | { | ||
537 | struct tps6507x_dev *tps6507x_dev = platform_get_drvdata(pdev); | ||
538 | struct tps6507x_pmic *tps = tps6507x_dev->pmic; | ||
539 | int i; | ||
540 | |||
541 | for (i = 0; i < TPS6507X_NUM_REGULATOR; i++) | ||
542 | regulator_unregister(tps->rdev[i]); | ||
543 | return 0; | ||
544 | } | 528 | } |
545 | 529 | ||
546 | static struct platform_driver tps6507x_pmic_driver = { | 530 | static struct platform_driver tps6507x_pmic_driver = { |
@@ -549,7 +533,6 @@ static struct platform_driver tps6507x_pmic_driver = { | |||
549 | .owner = THIS_MODULE, | 533 | .owner = THIS_MODULE, |
550 | }, | 534 | }, |
551 | .probe = tps6507x_pmic_probe, | 535 | .probe = tps6507x_pmic_probe, |
552 | .remove = tps6507x_pmic_remove, | ||
553 | }; | 536 | }; |
554 | 537 | ||
555 | static int __init tps6507x_pmic_init(void) | 538 | static int __init tps6507x_pmic_init(void) |
diff --git a/drivers/regulator/tps65090-regulator.c b/drivers/regulator/tps65090-regulator.c index c8e70451df38..bd611cdf6e1c 100644 --- a/drivers/regulator/tps65090-regulator.c +++ b/drivers/regulator/tps65090-regulator.c | |||
@@ -279,7 +279,7 @@ static int tps65090_regulator_probe(struct platform_device *pdev) | |||
279 | if (ret < 0) { | 279 | if (ret < 0) { |
280 | dev_err(&pdev->dev, | 280 | dev_err(&pdev->dev, |
281 | "failed disable ext control\n"); | 281 | "failed disable ext control\n"); |
282 | goto scrub; | 282 | return ret; |
283 | } | 283 | } |
284 | } | 284 | } |
285 | } | 285 | } |
@@ -296,12 +296,11 @@ static int tps65090_regulator_probe(struct platform_device *pdev) | |||
296 | else | 296 | else |
297 | config.of_node = NULL; | 297 | config.of_node = NULL; |
298 | 298 | ||
299 | rdev = regulator_register(ri->desc, &config); | 299 | rdev = devm_regulator_register(&pdev->dev, ri->desc, &config); |
300 | if (IS_ERR(rdev)) { | 300 | if (IS_ERR(rdev)) { |
301 | dev_err(&pdev->dev, "failed to register regulator %s\n", | 301 | dev_err(&pdev->dev, "failed to register regulator %s\n", |
302 | ri->desc->name); | 302 | ri->desc->name); |
303 | ret = PTR_ERR(rdev); | 303 | return PTR_ERR(rdev); |
304 | goto scrub; | ||
305 | } | 304 | } |
306 | ri->rdev = rdev; | 305 | ri->rdev = rdev; |
307 | 306 | ||
@@ -309,36 +308,13 @@ static int tps65090_regulator_probe(struct platform_device *pdev) | |||
309 | if (tps_pdata && is_dcdc(num) && tps_pdata->reg_init_data && | 308 | if (tps_pdata && is_dcdc(num) && tps_pdata->reg_init_data && |
310 | tps_pdata->enable_ext_control) { | 309 | tps_pdata->enable_ext_control) { |
311 | ret = tps65090_config_ext_control(ri, true); | 310 | ret = tps65090_config_ext_control(ri, true); |
312 | if (ret < 0) { | 311 | if (ret < 0) |
313 | /* Increment num to get unregister rdev */ | 312 | return ret; |
314 | num++; | ||
315 | goto scrub; | ||
316 | } | ||
317 | } | 313 | } |
318 | } | 314 | } |
319 | 315 | ||
320 | platform_set_drvdata(pdev, pmic); | 316 | platform_set_drvdata(pdev, pmic); |
321 | return 0; | 317 | return 0; |
322 | |||
323 | scrub: | ||
324 | while (--num >= 0) { | ||
325 | ri = &pmic[num]; | ||
326 | regulator_unregister(ri->rdev); | ||
327 | } | ||
328 | return ret; | ||
329 | } | ||
330 | |||
331 | static int tps65090_regulator_remove(struct platform_device *pdev) | ||
332 | { | ||
333 | struct tps65090_regulator *pmic = platform_get_drvdata(pdev); | ||
334 | struct tps65090_regulator *ri; | ||
335 | int num; | ||
336 | |||
337 | for (num = 0; num < TPS65090_REGULATOR_MAX; ++num) { | ||
338 | ri = &pmic[num]; | ||
339 | regulator_unregister(ri->rdev); | ||
340 | } | ||
341 | return 0; | ||
342 | } | 318 | } |
343 | 319 | ||
344 | static struct platform_driver tps65090_regulator_driver = { | 320 | static struct platform_driver tps65090_regulator_driver = { |
@@ -347,7 +323,6 @@ static struct platform_driver tps65090_regulator_driver = { | |||
347 | .owner = THIS_MODULE, | 323 | .owner = THIS_MODULE, |
348 | }, | 324 | }, |
349 | .probe = tps65090_regulator_probe, | 325 | .probe = tps65090_regulator_probe, |
350 | .remove = tps65090_regulator_remove, | ||
351 | }; | 326 | }; |
352 | 327 | ||
353 | static int __init tps65090_regulator_init(void) | 328 | static int __init tps65090_regulator_init(void) |
diff --git a/drivers/regulator/tps65217-regulator.c b/drivers/regulator/tps65217-regulator.c index 90861d68a0b0..9ea1bf26bd13 100644 --- a/drivers/regulator/tps65217-regulator.c +++ b/drivers/regulator/tps65217-regulator.c | |||
@@ -52,25 +52,17 @@ static const unsigned int LDO1_VSEL_table[] = { | |||
52 | }; | 52 | }; |
53 | 53 | ||
54 | static const struct regulator_linear_range tps65217_uv1_ranges[] = { | 54 | static const struct regulator_linear_range tps65217_uv1_ranges[] = { |
55 | { .min_uV = 900000, .max_uV = 1500000, .min_sel = 0, .max_sel = 24, | 55 | REGULATOR_LINEAR_RANGE(900000, 0, 24, 25000), |
56 | .uV_step = 25000 }, | 56 | REGULATOR_LINEAR_RANGE(1550000, 25, 30, 50000), |
57 | { .min_uV = 1550000, .max_uV = 1800000, .min_sel = 25, .max_sel = 30, | 57 | REGULATOR_LINEAR_RANGE(1850000, 31, 52, 50000), |
58 | .uV_step = 50000 }, | 58 | REGULATOR_LINEAR_RANGE(3000000, 53, 55, 100000), |
59 | { .min_uV = 1850000, .max_uV = 2900000, .min_sel = 31, .max_sel = 52, | 59 | REGULATOR_LINEAR_RANGE(3300000, 56, 62, 0), |
60 | .uV_step = 50000 }, | ||
61 | { .min_uV = 3000000, .max_uV = 3200000, .min_sel = 53, .max_sel = 55, | ||
62 | .uV_step = 100000 }, | ||
63 | { .min_uV = 3300000, .max_uV = 3300000, .min_sel = 56, .max_sel = 62, | ||
64 | .uV_step = 0 }, | ||
65 | }; | 60 | }; |
66 | 61 | ||
67 | static const struct regulator_linear_range tps65217_uv2_ranges[] = { | 62 | static const struct regulator_linear_range tps65217_uv2_ranges[] = { |
68 | { .min_uV = 1500000, .max_uV = 1900000, .min_sel = 0, .max_sel = 8, | 63 | REGULATOR_LINEAR_RANGE(1500000, 0, 8, 50000), |
69 | .uV_step = 50000 }, | 64 | REGULATOR_LINEAR_RANGE(2000000, 9, 13, 100000), |
70 | { .min_uV = 2000000, .max_uV = 2400000, .min_sel = 9, .max_sel = 13, | 65 | REGULATOR_LINEAR_RANGE(2450000, 14, 31, 50000), |
71 | .uV_step = 100000 }, | ||
72 | { .min_uV = 2450000, .max_uV = 3300000, .min_sel = 14, .max_sel = 31, | ||
73 | .uV_step = 50000 }, | ||
74 | }; | 66 | }; |
75 | 67 | ||
76 | static int tps65217_pmic_enable(struct regulator_dev *dev) | 68 | static int tps65217_pmic_enable(struct regulator_dev *dev) |
@@ -233,7 +225,7 @@ static int tps65217_regulator_probe(struct platform_device *pdev) | |||
233 | struct regulator_init_data *reg_data; | 225 | struct regulator_init_data *reg_data; |
234 | struct regulator_dev *rdev; | 226 | struct regulator_dev *rdev; |
235 | struct regulator_config config = { }; | 227 | struct regulator_config config = { }; |
236 | int i, ret; | 228 | int i; |
237 | 229 | ||
238 | if (tps->dev->of_node) | 230 | if (tps->dev->of_node) |
239 | pdata = tps65217_parse_dt(pdev); | 231 | pdata = tps65217_parse_dt(pdev); |
@@ -269,35 +261,18 @@ static int tps65217_regulator_probe(struct platform_device *pdev) | |||
269 | if (tps->dev->of_node) | 261 | if (tps->dev->of_node) |
270 | config.of_node = pdata->of_node[i]; | 262 | config.of_node = pdata->of_node[i]; |
271 | 263 | ||
272 | rdev = regulator_register(®ulators[i], &config); | 264 | rdev = devm_regulator_register(&pdev->dev, ®ulators[i], |
265 | &config); | ||
273 | if (IS_ERR(rdev)) { | 266 | if (IS_ERR(rdev)) { |
274 | dev_err(tps->dev, "failed to register %s regulator\n", | 267 | dev_err(tps->dev, "failed to register %s regulator\n", |
275 | pdev->name); | 268 | pdev->name); |
276 | ret = PTR_ERR(rdev); | 269 | return PTR_ERR(rdev); |
277 | goto err_unregister_regulator; | ||
278 | } | 270 | } |
279 | 271 | ||
280 | /* Save regulator for cleanup */ | 272 | /* Save regulator for cleanup */ |
281 | tps->rdev[i] = rdev; | 273 | tps->rdev[i] = rdev; |
282 | } | 274 | } |
283 | return 0; | 275 | return 0; |
284 | |||
285 | err_unregister_regulator: | ||
286 | while (--i >= 0) | ||
287 | regulator_unregister(tps->rdev[i]); | ||
288 | |||
289 | return ret; | ||
290 | } | ||
291 | |||
292 | static int tps65217_regulator_remove(struct platform_device *pdev) | ||
293 | { | ||
294 | struct tps65217 *tps = platform_get_drvdata(pdev); | ||
295 | unsigned int i; | ||
296 | |||
297 | for (i = 0; i < TPS65217_NUM_REGULATOR; i++) | ||
298 | regulator_unregister(tps->rdev[i]); | ||
299 | |||
300 | return 0; | ||
301 | } | 276 | } |
302 | 277 | ||
303 | static struct platform_driver tps65217_regulator_driver = { | 278 | static struct platform_driver tps65217_regulator_driver = { |
@@ -305,7 +280,6 @@ static struct platform_driver tps65217_regulator_driver = { | |||
305 | .name = "tps65217-pmic", | 280 | .name = "tps65217-pmic", |
306 | }, | 281 | }, |
307 | .probe = tps65217_regulator_probe, | 282 | .probe = tps65217_regulator_probe, |
308 | .remove = tps65217_regulator_remove, | ||
309 | }; | 283 | }; |
310 | 284 | ||
311 | static int __init tps65217_regulator_init(void) | 285 | static int __init tps65217_regulator_init(void) |
diff --git a/drivers/regulator/tps6524x-regulator.c b/drivers/regulator/tps6524x-regulator.c index 62e8d28beabd..9f6bfda711b7 100644 --- a/drivers/regulator/tps6524x-regulator.c +++ b/drivers/regulator/tps6524x-regulator.c | |||
@@ -577,21 +577,6 @@ static struct regulator_ops regulator_ops = { | |||
577 | .get_current_limit = get_current_limit, | 577 | .get_current_limit = get_current_limit, |
578 | }; | 578 | }; |
579 | 579 | ||
580 | static int pmic_remove(struct spi_device *spi) | ||
581 | { | ||
582 | struct tps6524x *hw = spi_get_drvdata(spi); | ||
583 | int i; | ||
584 | |||
585 | if (!hw) | ||
586 | return 0; | ||
587 | for (i = 0; i < N_REGULATORS; i++) { | ||
588 | regulator_unregister(hw->rdev[i]); | ||
589 | hw->rdev[i] = NULL; | ||
590 | } | ||
591 | spi_set_drvdata(spi, NULL); | ||
592 | return 0; | ||
593 | } | ||
594 | |||
595 | static int pmic_probe(struct spi_device *spi) | 580 | static int pmic_probe(struct spi_device *spi) |
596 | { | 581 | { |
597 | struct tps6524x *hw; | 582 | struct tps6524x *hw; |
@@ -599,7 +584,7 @@ static int pmic_probe(struct spi_device *spi) | |||
599 | const struct supply_info *info = supply_info; | 584 | const struct supply_info *info = supply_info; |
600 | struct regulator_init_data *init_data; | 585 | struct regulator_init_data *init_data; |
601 | struct regulator_config config = { }; | 586 | struct regulator_config config = { }; |
602 | int ret = 0, i; | 587 | int i; |
603 | 588 | ||
604 | init_data = dev_get_platdata(dev); | 589 | init_data = dev_get_platdata(dev); |
605 | if (!init_data) { | 590 | if (!init_data) { |
@@ -632,24 +617,17 @@ static int pmic_probe(struct spi_device *spi) | |||
632 | config.init_data = init_data; | 617 | config.init_data = init_data; |
633 | config.driver_data = hw; | 618 | config.driver_data = hw; |
634 | 619 | ||
635 | hw->rdev[i] = regulator_register(&hw->desc[i], &config); | 620 | hw->rdev[i] = devm_regulator_register(dev, &hw->desc[i], |
636 | if (IS_ERR(hw->rdev[i])) { | 621 | &config); |
637 | ret = PTR_ERR(hw->rdev[i]); | 622 | if (IS_ERR(hw->rdev[i])) |
638 | hw->rdev[i] = NULL; | 623 | return PTR_ERR(hw->rdev[i]); |
639 | goto fail; | ||
640 | } | ||
641 | } | 624 | } |
642 | 625 | ||
643 | return 0; | 626 | return 0; |
644 | |||
645 | fail: | ||
646 | pmic_remove(spi); | ||
647 | return ret; | ||
648 | } | 627 | } |
649 | 628 | ||
650 | static struct spi_driver pmic_driver = { | 629 | static struct spi_driver pmic_driver = { |
651 | .probe = pmic_probe, | 630 | .probe = pmic_probe, |
652 | .remove = pmic_remove, | ||
653 | .driver = { | 631 | .driver = { |
654 | .name = "tps6524x", | 632 | .name = "tps6524x", |
655 | .owner = THIS_MODULE, | 633 | .owner = THIS_MODULE, |
diff --git a/drivers/regulator/tps6586x-regulator.c b/drivers/regulator/tps6586x-regulator.c index 2c9155b66f09..45e5d683d3f8 100644 --- a/drivers/regulator/tps6586x-regulator.c +++ b/drivers/regulator/tps6586x-regulator.c | |||
@@ -379,15 +379,14 @@ static int tps6586x_regulator_probe(struct platform_device *pdev) | |||
379 | ri = find_regulator_info(id); | 379 | ri = find_regulator_info(id); |
380 | if (!ri) { | 380 | if (!ri) { |
381 | dev_err(&pdev->dev, "invalid regulator ID specified\n"); | 381 | dev_err(&pdev->dev, "invalid regulator ID specified\n"); |
382 | err = -EINVAL; | 382 | return -EINVAL; |
383 | goto fail; | ||
384 | } | 383 | } |
385 | 384 | ||
386 | err = tps6586x_regulator_preinit(pdev->dev.parent, ri); | 385 | err = tps6586x_regulator_preinit(pdev->dev.parent, ri); |
387 | if (err) { | 386 | if (err) { |
388 | dev_err(&pdev->dev, | 387 | dev_err(&pdev->dev, |
389 | "regulator %d preinit failed, e %d\n", id, err); | 388 | "regulator %d preinit failed, e %d\n", id, err); |
390 | goto fail; | 389 | return err; |
391 | } | 390 | } |
392 | 391 | ||
393 | config.dev = pdev->dev.parent; | 392 | config.dev = pdev->dev.parent; |
@@ -397,12 +396,12 @@ static int tps6586x_regulator_probe(struct platform_device *pdev) | |||
397 | if (tps6586x_reg_matches) | 396 | if (tps6586x_reg_matches) |
398 | config.of_node = tps6586x_reg_matches[id].of_node; | 397 | config.of_node = tps6586x_reg_matches[id].of_node; |
399 | 398 | ||
400 | rdev[id] = regulator_register(&ri->desc, &config); | 399 | rdev[id] = devm_regulator_register(&pdev->dev, &ri->desc, |
400 | &config); | ||
401 | if (IS_ERR(rdev[id])) { | 401 | if (IS_ERR(rdev[id])) { |
402 | dev_err(&pdev->dev, "failed to register regulator %s\n", | 402 | dev_err(&pdev->dev, "failed to register regulator %s\n", |
403 | ri->desc.name); | 403 | ri->desc.name); |
404 | err = PTR_ERR(rdev[id]); | 404 | return PTR_ERR(rdev[id]); |
405 | goto fail; | ||
406 | } | 405 | } |
407 | 406 | ||
408 | if (reg_data) { | 407 | if (reg_data) { |
@@ -411,30 +410,13 @@ static int tps6586x_regulator_probe(struct platform_device *pdev) | |||
411 | if (err < 0) { | 410 | if (err < 0) { |
412 | dev_err(&pdev->dev, | 411 | dev_err(&pdev->dev, |
413 | "Slew rate config failed, e %d\n", err); | 412 | "Slew rate config failed, e %d\n", err); |
414 | regulator_unregister(rdev[id]); | 413 | return err; |
415 | goto fail; | ||
416 | } | 414 | } |
417 | } | 415 | } |
418 | } | 416 | } |
419 | 417 | ||
420 | platform_set_drvdata(pdev, rdev); | 418 | platform_set_drvdata(pdev, rdev); |
421 | return 0; | 419 | return 0; |
422 | |||
423 | fail: | ||
424 | while (--id >= 0) | ||
425 | regulator_unregister(rdev[id]); | ||
426 | return err; | ||
427 | } | ||
428 | |||
429 | static int tps6586x_regulator_remove(struct platform_device *pdev) | ||
430 | { | ||
431 | struct regulator_dev **rdev = platform_get_drvdata(pdev); | ||
432 | int id = TPS6586X_ID_MAX_REGULATOR; | ||
433 | |||
434 | while (--id >= 0) | ||
435 | regulator_unregister(rdev[id]); | ||
436 | |||
437 | return 0; | ||
438 | } | 420 | } |
439 | 421 | ||
440 | static struct platform_driver tps6586x_regulator_driver = { | 422 | static struct platform_driver tps6586x_regulator_driver = { |
@@ -443,7 +425,6 @@ static struct platform_driver tps6586x_regulator_driver = { | |||
443 | .owner = THIS_MODULE, | 425 | .owner = THIS_MODULE, |
444 | }, | 426 | }, |
445 | .probe = tps6586x_regulator_probe, | 427 | .probe = tps6586x_regulator_probe, |
446 | .remove = tps6586x_regulator_remove, | ||
447 | }; | 428 | }; |
448 | 429 | ||
449 | static int __init tps6586x_regulator_init(void) | 430 | static int __init tps6586x_regulator_init(void) |
diff --git a/drivers/regulator/tps65910-regulator.c b/drivers/regulator/tps65910-regulator.c index 45c16447744b..b8167df71170 100644 --- a/drivers/regulator/tps65910-regulator.c +++ b/drivers/regulator/tps65910-regulator.c | |||
@@ -1177,35 +1177,19 @@ static int tps65910_probe(struct platform_device *pdev) | |||
1177 | if (tps65910_reg_matches) | 1177 | if (tps65910_reg_matches) |
1178 | config.of_node = tps65910_reg_matches[i].of_node; | 1178 | config.of_node = tps65910_reg_matches[i].of_node; |
1179 | 1179 | ||
1180 | rdev = regulator_register(&pmic->desc[i], &config); | 1180 | rdev = devm_regulator_register(&pdev->dev, &pmic->desc[i], |
1181 | &config); | ||
1181 | if (IS_ERR(rdev)) { | 1182 | if (IS_ERR(rdev)) { |
1182 | dev_err(tps65910->dev, | 1183 | dev_err(tps65910->dev, |
1183 | "failed to register %s regulator\n", | 1184 | "failed to register %s regulator\n", |
1184 | pdev->name); | 1185 | pdev->name); |
1185 | err = PTR_ERR(rdev); | 1186 | return PTR_ERR(rdev); |
1186 | goto err_unregister_regulator; | ||
1187 | } | 1187 | } |
1188 | 1188 | ||
1189 | /* Save regulator for cleanup */ | 1189 | /* Save regulator for cleanup */ |
1190 | pmic->rdev[i] = rdev; | 1190 | pmic->rdev[i] = rdev; |
1191 | } | 1191 | } |
1192 | return 0; | 1192 | return 0; |
1193 | |||
1194 | err_unregister_regulator: | ||
1195 | while (--i >= 0) | ||
1196 | regulator_unregister(pmic->rdev[i]); | ||
1197 | return err; | ||
1198 | } | ||
1199 | |||
1200 | static int tps65910_remove(struct platform_device *pdev) | ||
1201 | { | ||
1202 | struct tps65910_reg *pmic = platform_get_drvdata(pdev); | ||
1203 | int i; | ||
1204 | |||
1205 | for (i = 0; i < pmic->num_regulators; i++) | ||
1206 | regulator_unregister(pmic->rdev[i]); | ||
1207 | |||
1208 | return 0; | ||
1209 | } | 1193 | } |
1210 | 1194 | ||
1211 | static void tps65910_shutdown(struct platform_device *pdev) | 1195 | static void tps65910_shutdown(struct platform_device *pdev) |
@@ -1244,7 +1228,6 @@ static struct platform_driver tps65910_driver = { | |||
1244 | .owner = THIS_MODULE, | 1228 | .owner = THIS_MODULE, |
1245 | }, | 1229 | }, |
1246 | .probe = tps65910_probe, | 1230 | .probe = tps65910_probe, |
1247 | .remove = tps65910_remove, | ||
1248 | .shutdown = tps65910_shutdown, | 1231 | .shutdown = tps65910_shutdown, |
1249 | }; | 1232 | }; |
1250 | 1233 | ||
diff --git a/drivers/regulator/tps65912-regulator.c b/drivers/regulator/tps65912-regulator.c index 281e52ac64ba..9cafaa0f9455 100644 --- a/drivers/regulator/tps65912-regulator.c +++ b/drivers/regulator/tps65912-regulator.c | |||
@@ -119,12 +119,9 @@ struct tps65912_reg { | |||
119 | }; | 119 | }; |
120 | 120 | ||
121 | static const struct regulator_linear_range tps65912_ldo_ranges[] = { | 121 | static const struct regulator_linear_range tps65912_ldo_ranges[] = { |
122 | { .min_uV = 800000, .max_uV = 1600000, .min_sel = 0, .max_sel = 32, | 122 | REGULATOR_LINEAR_RANGE(800000, 0, 32, 25000), |
123 | .uV_step = 25000 }, | 123 | REGULATOR_LINEAR_RANGE(1650000, 33, 60, 50000), |
124 | { .min_uV = 1650000, .max_uV = 3000000, .min_sel = 33, .max_sel = 60, | 124 | REGULATOR_LINEAR_RANGE(3100000, 61, 63, 100000), |
125 | .uV_step = 50000 }, | ||
126 | { .min_uV = 3100000, .max_uV = 3300000, .min_sel = 61, .max_sel = 63, | ||
127 | .uV_step = 100000 }, | ||
128 | }; | 125 | }; |
129 | 126 | ||
130 | static int tps65912_get_range(struct tps65912_reg *pmic, int id) | 127 | static int tps65912_get_range(struct tps65912_reg *pmic, int id) |
@@ -461,7 +458,7 @@ static int tps65912_probe(struct platform_device *pdev) | |||
461 | struct regulator_dev *rdev; | 458 | struct regulator_dev *rdev; |
462 | struct tps65912_reg *pmic; | 459 | struct tps65912_reg *pmic; |
463 | struct tps65912_board *pmic_plat_data; | 460 | struct tps65912_board *pmic_plat_data; |
464 | int i, err; | 461 | int i; |
465 | 462 | ||
466 | pmic_plat_data = dev_get_platdata(tps65912->dev); | 463 | pmic_plat_data = dev_get_platdata(tps65912->dev); |
467 | if (!pmic_plat_data) | 464 | if (!pmic_plat_data) |
@@ -504,34 +501,19 @@ static int tps65912_probe(struct platform_device *pdev) | |||
504 | config.init_data = reg_data; | 501 | config.init_data = reg_data; |
505 | config.driver_data = pmic; | 502 | config.driver_data = pmic; |
506 | 503 | ||
507 | rdev = regulator_register(&pmic->desc[i], &config); | 504 | rdev = devm_regulator_register(&pdev->dev, &pmic->desc[i], |
505 | &config); | ||
508 | if (IS_ERR(rdev)) { | 506 | if (IS_ERR(rdev)) { |
509 | dev_err(tps65912->dev, | 507 | dev_err(tps65912->dev, |
510 | "failed to register %s regulator\n", | 508 | "failed to register %s regulator\n", |
511 | pdev->name); | 509 | pdev->name); |
512 | err = PTR_ERR(rdev); | 510 | return PTR_ERR(rdev); |
513 | goto err; | ||
514 | } | 511 | } |
515 | 512 | ||
516 | /* Save regulator for cleanup */ | 513 | /* Save regulator for cleanup */ |
517 | pmic->rdev[i] = rdev; | 514 | pmic->rdev[i] = rdev; |
518 | } | 515 | } |
519 | return 0; | 516 | return 0; |
520 | |||
521 | err: | ||
522 | while (--i >= 0) | ||
523 | regulator_unregister(pmic->rdev[i]); | ||
524 | return err; | ||
525 | } | ||
526 | |||
527 | static int tps65912_remove(struct platform_device *pdev) | ||
528 | { | ||
529 | struct tps65912_reg *tps65912_reg = platform_get_drvdata(pdev); | ||
530 | int i; | ||
531 | |||
532 | for (i = 0; i < TPS65912_NUM_REGULATOR; i++) | ||
533 | regulator_unregister(tps65912_reg->rdev[i]); | ||
534 | return 0; | ||
535 | } | 517 | } |
536 | 518 | ||
537 | static struct platform_driver tps65912_driver = { | 519 | static struct platform_driver tps65912_driver = { |
@@ -540,7 +522,6 @@ static struct platform_driver tps65912_driver = { | |||
540 | .owner = THIS_MODULE, | 522 | .owner = THIS_MODULE, |
541 | }, | 523 | }, |
542 | .probe = tps65912_probe, | 524 | .probe = tps65912_probe, |
543 | .remove = tps65912_remove, | ||
544 | }; | 525 | }; |
545 | 526 | ||
546 | static int __init tps65912_init(void) | 527 | static int __init tps65912_init(void) |
diff --git a/drivers/regulator/tps80031-regulator.c b/drivers/regulator/tps80031-regulator.c index 6511d0bfd896..71f457a42623 100644 --- a/drivers/regulator/tps80031-regulator.c +++ b/drivers/regulator/tps80031-regulator.c | |||
@@ -719,7 +719,7 @@ static int tps80031_regulator_probe(struct platform_device *pdev) | |||
719 | if (ret < 0) { | 719 | if (ret < 0) { |
720 | dev_err(&pdev->dev, | 720 | dev_err(&pdev->dev, |
721 | "regulator config failed, e %d\n", ret); | 721 | "regulator config failed, e %d\n", ret); |
722 | goto fail; | 722 | return ret; |
723 | } | 723 | } |
724 | 724 | ||
725 | ret = tps80031_power_req_config(pdev->dev.parent, | 725 | ret = tps80031_power_req_config(pdev->dev.parent, |
@@ -727,41 +727,22 @@ static int tps80031_regulator_probe(struct platform_device *pdev) | |||
727 | if (ret < 0) { | 727 | if (ret < 0) { |
728 | dev_err(&pdev->dev, | 728 | dev_err(&pdev->dev, |
729 | "pwr_req config failed, err %d\n", ret); | 729 | "pwr_req config failed, err %d\n", ret); |
730 | goto fail; | 730 | return ret; |
731 | } | 731 | } |
732 | } | 732 | } |
733 | rdev = regulator_register(&ri->rinfo->desc, &config); | 733 | rdev = devm_regulator_register(&pdev->dev, &ri->rinfo->desc, |
734 | &config); | ||
734 | if (IS_ERR(rdev)) { | 735 | if (IS_ERR(rdev)) { |
735 | dev_err(&pdev->dev, | 736 | dev_err(&pdev->dev, |
736 | "register regulator failed %s\n", | 737 | "register regulator failed %s\n", |
737 | ri->rinfo->desc.name); | 738 | ri->rinfo->desc.name); |
738 | ret = PTR_ERR(rdev); | 739 | return PTR_ERR(rdev); |
739 | goto fail; | ||
740 | } | 740 | } |
741 | ri->rdev = rdev; | 741 | ri->rdev = rdev; |
742 | } | 742 | } |
743 | 743 | ||
744 | platform_set_drvdata(pdev, pmic); | 744 | platform_set_drvdata(pdev, pmic); |
745 | return 0; | 745 | return 0; |
746 | fail: | ||
747 | while (--num >= 0) { | ||
748 | ri = &pmic[num]; | ||
749 | regulator_unregister(ri->rdev); | ||
750 | } | ||
751 | return ret; | ||
752 | } | ||
753 | |||
754 | static int tps80031_regulator_remove(struct platform_device *pdev) | ||
755 | { | ||
756 | struct tps80031_regulator *pmic = platform_get_drvdata(pdev); | ||
757 | struct tps80031_regulator *ri = NULL; | ||
758 | int num; | ||
759 | |||
760 | for (num = 0; num < TPS80031_REGULATOR_MAX; ++num) { | ||
761 | ri = &pmic[num]; | ||
762 | regulator_unregister(ri->rdev); | ||
763 | } | ||
764 | return 0; | ||
765 | } | 746 | } |
766 | 747 | ||
767 | static struct platform_driver tps80031_regulator_driver = { | 748 | static struct platform_driver tps80031_regulator_driver = { |
@@ -770,7 +751,6 @@ static struct platform_driver tps80031_regulator_driver = { | |||
770 | .owner = THIS_MODULE, | 751 | .owner = THIS_MODULE, |
771 | }, | 752 | }, |
772 | .probe = tps80031_regulator_probe, | 753 | .probe = tps80031_regulator_probe, |
773 | .remove = tps80031_regulator_remove, | ||
774 | }; | 754 | }; |
775 | 755 | ||
776 | static int __init tps80031_regulator_init(void) | 756 | static int __init tps80031_regulator_init(void) |
diff --git a/drivers/regulator/twl-regulator.c b/drivers/regulator/twl-regulator.c index 78aae4cbb004..8ebd785485c7 100644 --- a/drivers/regulator/twl-regulator.c +++ b/drivers/regulator/twl-regulator.c | |||
@@ -1188,7 +1188,7 @@ static int twlreg_probe(struct platform_device *pdev) | |||
1188 | config.driver_data = info; | 1188 | config.driver_data = info; |
1189 | config.of_node = pdev->dev.of_node; | 1189 | config.of_node = pdev->dev.of_node; |
1190 | 1190 | ||
1191 | rdev = regulator_register(&info->desc, &config); | 1191 | rdev = devm_regulator_register(&pdev->dev, &info->desc, &config); |
1192 | if (IS_ERR(rdev)) { | 1192 | if (IS_ERR(rdev)) { |
1193 | dev_err(&pdev->dev, "can't register %s, %ld\n", | 1193 | dev_err(&pdev->dev, "can't register %s, %ld\n", |
1194 | info->desc.name, PTR_ERR(rdev)); | 1194 | info->desc.name, PTR_ERR(rdev)); |
@@ -1217,7 +1217,6 @@ static int twlreg_remove(struct platform_device *pdev) | |||
1217 | struct regulator_dev *rdev = platform_get_drvdata(pdev); | 1217 | struct regulator_dev *rdev = platform_get_drvdata(pdev); |
1218 | struct twlreg_info *info = rdev->reg_data; | 1218 | struct twlreg_info *info = rdev->reg_data; |
1219 | 1219 | ||
1220 | regulator_unregister(rdev); | ||
1221 | kfree(info); | 1220 | kfree(info); |
1222 | return 0; | 1221 | return 0; |
1223 | } | 1222 | } |
diff --git a/drivers/regulator/vexpress.c b/drivers/regulator/vexpress.c index 4668c7f8133d..f3ae28a7e663 100644 --- a/drivers/regulator/vexpress.c +++ b/drivers/regulator/vexpress.c | |||
@@ -96,7 +96,7 @@ static int vexpress_regulator_probe(struct platform_device *pdev) | |||
96 | config.driver_data = reg; | 96 | config.driver_data = reg; |
97 | config.of_node = pdev->dev.of_node; | 97 | config.of_node = pdev->dev.of_node; |
98 | 98 | ||
99 | reg->regdev = regulator_register(®->desc, &config); | 99 | reg->regdev = devm_regulator_register(&pdev->dev, ®->desc, &config); |
100 | if (IS_ERR(reg->regdev)) { | 100 | if (IS_ERR(reg->regdev)) { |
101 | err = PTR_ERR(reg->regdev); | 101 | err = PTR_ERR(reg->regdev); |
102 | goto error_regulator_register; | 102 | goto error_regulator_register; |
@@ -119,7 +119,6 @@ static int vexpress_regulator_remove(struct platform_device *pdev) | |||
119 | struct vexpress_regulator *reg = platform_get_drvdata(pdev); | 119 | struct vexpress_regulator *reg = platform_get_drvdata(pdev); |
120 | 120 | ||
121 | vexpress_config_func_put(reg->func); | 121 | vexpress_config_func_put(reg->func); |
122 | regulator_unregister(reg->regdev); | ||
123 | 122 | ||
124 | return 0; | 123 | return 0; |
125 | } | 124 | } |
diff --git a/drivers/regulator/wm831x-dcdc.c b/drivers/regulator/wm831x-dcdc.c index 11861cb861df..6823e6f2b88a 100644 --- a/drivers/regulator/wm831x-dcdc.c +++ b/drivers/regulator/wm831x-dcdc.c | |||
@@ -387,8 +387,9 @@ static struct regulator_ops wm831x_buckv_ops = { | |||
387 | * Set up DVS control. We just log errors since we can still run | 387 | * Set up DVS control. We just log errors since we can still run |
388 | * (with reduced performance) if we fail. | 388 | * (with reduced performance) if we fail. |
389 | */ | 389 | */ |
390 | static void wm831x_buckv_dvs_init(struct wm831x_dcdc *dcdc, | 390 | static void wm831x_buckv_dvs_init(struct platform_device *pdev, |
391 | struct wm831x_buckv_pdata *pdata) | 391 | struct wm831x_dcdc *dcdc, |
392 | struct wm831x_buckv_pdata *pdata) | ||
392 | { | 393 | { |
393 | struct wm831x *wm831x = dcdc->wm831x; | 394 | struct wm831x *wm831x = dcdc->wm831x; |
394 | int ret; | 395 | int ret; |
@@ -402,9 +403,9 @@ static void wm831x_buckv_dvs_init(struct wm831x_dcdc *dcdc, | |||
402 | */ | 403 | */ |
403 | dcdc->dvs_gpio_state = pdata->dvs_init_state; | 404 | dcdc->dvs_gpio_state = pdata->dvs_init_state; |
404 | 405 | ||
405 | ret = gpio_request_one(pdata->dvs_gpio, | 406 | ret = devm_gpio_request_one(&pdev->dev, pdata->dvs_gpio, |
406 | dcdc->dvs_gpio_state ? GPIOF_INIT_HIGH : 0, | 407 | dcdc->dvs_gpio_state ? GPIOF_INIT_HIGH : 0, |
407 | "DCDC DVS"); | 408 | "DCDC DVS"); |
408 | if (ret < 0) { | 409 | if (ret < 0) { |
409 | dev_err(wm831x->dev, "Failed to get %s DVS GPIO: %d\n", | 410 | dev_err(wm831x->dev, "Failed to get %s DVS GPIO: %d\n", |
410 | dcdc->name, ret); | 411 | dcdc->name, ret); |
@@ -513,7 +514,8 @@ static int wm831x_buckv_probe(struct platform_device *pdev) | |||
513 | dcdc->dvs_vsel = ret & WM831X_DC1_DVS_VSEL_MASK; | 514 | dcdc->dvs_vsel = ret & WM831X_DC1_DVS_VSEL_MASK; |
514 | 515 | ||
515 | if (pdata && pdata->dcdc[id]) | 516 | if (pdata && pdata->dcdc[id]) |
516 | wm831x_buckv_dvs_init(dcdc, pdata->dcdc[id]->driver_data); | 517 | wm831x_buckv_dvs_init(pdev, dcdc, |
518 | pdata->dcdc[id]->driver_data); | ||
517 | 519 | ||
518 | config.dev = pdev->dev.parent; | 520 | config.dev = pdev->dev.parent; |
519 | if (pdata) | 521 | if (pdata) |
@@ -521,7 +523,8 @@ static int wm831x_buckv_probe(struct platform_device *pdev) | |||
521 | config.driver_data = dcdc; | 523 | config.driver_data = dcdc; |
522 | config.regmap = wm831x->regmap; | 524 | config.regmap = wm831x->regmap; |
523 | 525 | ||
524 | dcdc->regulator = regulator_register(&dcdc->desc, &config); | 526 | dcdc->regulator = devm_regulator_register(&pdev->dev, &dcdc->desc, |
527 | &config); | ||
525 | if (IS_ERR(dcdc->regulator)) { | 528 | if (IS_ERR(dcdc->regulator)) { |
526 | ret = PTR_ERR(dcdc->regulator); | 529 | ret = PTR_ERR(dcdc->regulator); |
527 | dev_err(wm831x->dev, "Failed to register DCDC%d: %d\n", | 530 | dev_err(wm831x->dev, "Failed to register DCDC%d: %d\n", |
@@ -530,57 +533,35 @@ static int wm831x_buckv_probe(struct platform_device *pdev) | |||
530 | } | 533 | } |
531 | 534 | ||
532 | irq = wm831x_irq(wm831x, platform_get_irq_byname(pdev, "UV")); | 535 | irq = wm831x_irq(wm831x, platform_get_irq_byname(pdev, "UV")); |
533 | ret = request_threaded_irq(irq, NULL, wm831x_dcdc_uv_irq, | 536 | ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, |
534 | IRQF_TRIGGER_RISING, dcdc->name, dcdc); | 537 | wm831x_dcdc_uv_irq, |
538 | IRQF_TRIGGER_RISING, dcdc->name, dcdc); | ||
535 | if (ret != 0) { | 539 | if (ret != 0) { |
536 | dev_err(&pdev->dev, "Failed to request UV IRQ %d: %d\n", | 540 | dev_err(&pdev->dev, "Failed to request UV IRQ %d: %d\n", |
537 | irq, ret); | 541 | irq, ret); |
538 | goto err_regulator; | 542 | goto err; |
539 | } | 543 | } |
540 | 544 | ||
541 | irq = wm831x_irq(wm831x, platform_get_irq_byname(pdev, "HC")); | 545 | irq = wm831x_irq(wm831x, platform_get_irq_byname(pdev, "HC")); |
542 | ret = request_threaded_irq(irq, NULL, wm831x_dcdc_oc_irq, | 546 | ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, |
543 | IRQF_TRIGGER_RISING, dcdc->name, dcdc); | 547 | wm831x_dcdc_oc_irq, |
548 | IRQF_TRIGGER_RISING, dcdc->name, dcdc); | ||
544 | if (ret != 0) { | 549 | if (ret != 0) { |
545 | dev_err(&pdev->dev, "Failed to request HC IRQ %d: %d\n", | 550 | dev_err(&pdev->dev, "Failed to request HC IRQ %d: %d\n", |
546 | irq, ret); | 551 | irq, ret); |
547 | goto err_uv; | 552 | goto err; |
548 | } | 553 | } |
549 | 554 | ||
550 | platform_set_drvdata(pdev, dcdc); | 555 | platform_set_drvdata(pdev, dcdc); |
551 | 556 | ||
552 | return 0; | 557 | return 0; |
553 | 558 | ||
554 | err_uv: | ||
555 | free_irq(wm831x_irq(wm831x, platform_get_irq_byname(pdev, "UV")), | ||
556 | dcdc); | ||
557 | err_regulator: | ||
558 | regulator_unregister(dcdc->regulator); | ||
559 | err: | 559 | err: |
560 | if (dcdc->dvs_gpio) | ||
561 | gpio_free(dcdc->dvs_gpio); | ||
562 | return ret; | 560 | return ret; |
563 | } | 561 | } |
564 | 562 | ||
565 | static int wm831x_buckv_remove(struct platform_device *pdev) | ||
566 | { | ||
567 | struct wm831x_dcdc *dcdc = platform_get_drvdata(pdev); | ||
568 | struct wm831x *wm831x = dcdc->wm831x; | ||
569 | |||
570 | free_irq(wm831x_irq(wm831x, platform_get_irq_byname(pdev, "HC")), | ||
571 | dcdc); | ||
572 | free_irq(wm831x_irq(wm831x, platform_get_irq_byname(pdev, "UV")), | ||
573 | dcdc); | ||
574 | regulator_unregister(dcdc->regulator); | ||
575 | if (dcdc->dvs_gpio) | ||
576 | gpio_free(dcdc->dvs_gpio); | ||
577 | |||
578 | return 0; | ||
579 | } | ||
580 | |||
581 | static struct platform_driver wm831x_buckv_driver = { | 563 | static struct platform_driver wm831x_buckv_driver = { |
582 | .probe = wm831x_buckv_probe, | 564 | .probe = wm831x_buckv_probe, |
583 | .remove = wm831x_buckv_remove, | ||
584 | .driver = { | 565 | .driver = { |
585 | .name = "wm831x-buckv", | 566 | .name = "wm831x-buckv", |
586 | .owner = THIS_MODULE, | 567 | .owner = THIS_MODULE, |
@@ -681,7 +662,8 @@ static int wm831x_buckp_probe(struct platform_device *pdev) | |||
681 | config.driver_data = dcdc; | 662 | config.driver_data = dcdc; |
682 | config.regmap = wm831x->regmap; | 663 | config.regmap = wm831x->regmap; |
683 | 664 | ||
684 | dcdc->regulator = regulator_register(&dcdc->desc, &config); | 665 | dcdc->regulator = devm_regulator_register(&pdev->dev, &dcdc->desc, |
666 | &config); | ||
685 | if (IS_ERR(dcdc->regulator)) { | 667 | if (IS_ERR(dcdc->regulator)) { |
686 | ret = PTR_ERR(dcdc->regulator); | 668 | ret = PTR_ERR(dcdc->regulator); |
687 | dev_err(wm831x->dev, "Failed to register DCDC%d: %d\n", | 669 | dev_err(wm831x->dev, "Failed to register DCDC%d: %d\n", |
@@ -690,38 +672,25 @@ static int wm831x_buckp_probe(struct platform_device *pdev) | |||
690 | } | 672 | } |
691 | 673 | ||
692 | irq = wm831x_irq(wm831x, platform_get_irq_byname(pdev, "UV")); | 674 | irq = wm831x_irq(wm831x, platform_get_irq_byname(pdev, "UV")); |
693 | ret = request_threaded_irq(irq, NULL, wm831x_dcdc_uv_irq, | 675 | ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, |
694 | IRQF_TRIGGER_RISING, dcdc->name, dcdc); | 676 | wm831x_dcdc_uv_irq, |
677 | IRQF_TRIGGER_RISING, dcdc->name, dcdc); | ||
695 | if (ret != 0) { | 678 | if (ret != 0) { |
696 | dev_err(&pdev->dev, "Failed to request UV IRQ %d: %d\n", | 679 | dev_err(&pdev->dev, "Failed to request UV IRQ %d: %d\n", |
697 | irq, ret); | 680 | irq, ret); |
698 | goto err_regulator; | 681 | goto err; |
699 | } | 682 | } |
700 | 683 | ||
701 | platform_set_drvdata(pdev, dcdc); | 684 | platform_set_drvdata(pdev, dcdc); |
702 | 685 | ||
703 | return 0; | 686 | return 0; |
704 | 687 | ||
705 | err_regulator: | ||
706 | regulator_unregister(dcdc->regulator); | ||
707 | err: | 688 | err: |
708 | return ret; | 689 | return ret; |
709 | } | 690 | } |
710 | 691 | ||
711 | static int wm831x_buckp_remove(struct platform_device *pdev) | ||
712 | { | ||
713 | struct wm831x_dcdc *dcdc = platform_get_drvdata(pdev); | ||
714 | |||
715 | free_irq(wm831x_irq(dcdc->wm831x, platform_get_irq_byname(pdev, "UV")), | ||
716 | dcdc); | ||
717 | regulator_unregister(dcdc->regulator); | ||
718 | |||
719 | return 0; | ||
720 | } | ||
721 | |||
722 | static struct platform_driver wm831x_buckp_driver = { | 692 | static struct platform_driver wm831x_buckp_driver = { |
723 | .probe = wm831x_buckp_probe, | 693 | .probe = wm831x_buckp_probe, |
724 | .remove = wm831x_buckp_remove, | ||
725 | .driver = { | 694 | .driver = { |
726 | .name = "wm831x-buckp", | 695 | .name = "wm831x-buckp", |
727 | .owner = THIS_MODULE, | 696 | .owner = THIS_MODULE, |
@@ -813,7 +782,8 @@ static int wm831x_boostp_probe(struct platform_device *pdev) | |||
813 | config.driver_data = dcdc; | 782 | config.driver_data = dcdc; |
814 | config.regmap = wm831x->regmap; | 783 | config.regmap = wm831x->regmap; |
815 | 784 | ||
816 | dcdc->regulator = regulator_register(&dcdc->desc, &config); | 785 | dcdc->regulator = devm_regulator_register(&pdev->dev, &dcdc->desc, |
786 | &config); | ||
817 | if (IS_ERR(dcdc->regulator)) { | 787 | if (IS_ERR(dcdc->regulator)) { |
818 | ret = PTR_ERR(dcdc->regulator); | 788 | ret = PTR_ERR(dcdc->regulator); |
819 | dev_err(wm831x->dev, "Failed to register DCDC%d: %d\n", | 789 | dev_err(wm831x->dev, "Failed to register DCDC%d: %d\n", |
@@ -822,39 +792,26 @@ static int wm831x_boostp_probe(struct platform_device *pdev) | |||
822 | } | 792 | } |
823 | 793 | ||
824 | irq = wm831x_irq(wm831x, platform_get_irq_byname(pdev, "UV")); | 794 | irq = wm831x_irq(wm831x, platform_get_irq_byname(pdev, "UV")); |
825 | ret = request_threaded_irq(irq, NULL, wm831x_dcdc_uv_irq, | 795 | ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, |
826 | IRQF_TRIGGER_RISING, dcdc->name, | 796 | wm831x_dcdc_uv_irq, |
827 | dcdc); | 797 | IRQF_TRIGGER_RISING, dcdc->name, |
798 | dcdc); | ||
828 | if (ret != 0) { | 799 | if (ret != 0) { |
829 | dev_err(&pdev->dev, "Failed to request UV IRQ %d: %d\n", | 800 | dev_err(&pdev->dev, "Failed to request UV IRQ %d: %d\n", |
830 | irq, ret); | 801 | irq, ret); |
831 | goto err_regulator; | 802 | goto err; |
832 | } | 803 | } |
833 | 804 | ||
834 | platform_set_drvdata(pdev, dcdc); | 805 | platform_set_drvdata(pdev, dcdc); |
835 | 806 | ||
836 | return 0; | 807 | return 0; |
837 | 808 | ||
838 | err_regulator: | ||
839 | regulator_unregister(dcdc->regulator); | ||
840 | err: | 809 | err: |
841 | return ret; | 810 | return ret; |
842 | } | 811 | } |
843 | 812 | ||
844 | static int wm831x_boostp_remove(struct platform_device *pdev) | ||
845 | { | ||
846 | struct wm831x_dcdc *dcdc = platform_get_drvdata(pdev); | ||
847 | |||
848 | free_irq(wm831x_irq(dcdc->wm831x, platform_get_irq_byname(pdev, "UV")), | ||
849 | dcdc); | ||
850 | regulator_unregister(dcdc->regulator); | ||
851 | |||
852 | return 0; | ||
853 | } | ||
854 | |||
855 | static struct platform_driver wm831x_boostp_driver = { | 813 | static struct platform_driver wm831x_boostp_driver = { |
856 | .probe = wm831x_boostp_probe, | 814 | .probe = wm831x_boostp_probe, |
857 | .remove = wm831x_boostp_remove, | ||
858 | .driver = { | 815 | .driver = { |
859 | .name = "wm831x-boostp", | 816 | .name = "wm831x-boostp", |
860 | .owner = THIS_MODULE, | 817 | .owner = THIS_MODULE, |
@@ -914,7 +871,8 @@ static int wm831x_epe_probe(struct platform_device *pdev) | |||
914 | config.driver_data = dcdc; | 871 | config.driver_data = dcdc; |
915 | config.regmap = wm831x->regmap; | 872 | config.regmap = wm831x->regmap; |
916 | 873 | ||
917 | dcdc->regulator = regulator_register(&dcdc->desc, &config); | 874 | dcdc->regulator = devm_regulator_register(&pdev->dev, &dcdc->desc, |
875 | &config); | ||
918 | if (IS_ERR(dcdc->regulator)) { | 876 | if (IS_ERR(dcdc->regulator)) { |
919 | ret = PTR_ERR(dcdc->regulator); | 877 | ret = PTR_ERR(dcdc->regulator); |
920 | dev_err(wm831x->dev, "Failed to register EPE%d: %d\n", | 878 | dev_err(wm831x->dev, "Failed to register EPE%d: %d\n", |
@@ -930,18 +888,8 @@ err: | |||
930 | return ret; | 888 | return ret; |
931 | } | 889 | } |
932 | 890 | ||
933 | static int wm831x_epe_remove(struct platform_device *pdev) | ||
934 | { | ||
935 | struct wm831x_dcdc *dcdc = platform_get_drvdata(pdev); | ||
936 | |||
937 | regulator_unregister(dcdc->regulator); | ||
938 | |||
939 | return 0; | ||
940 | } | ||
941 | |||
942 | static struct platform_driver wm831x_epe_driver = { | 891 | static struct platform_driver wm831x_epe_driver = { |
943 | .probe = wm831x_epe_probe, | 892 | .probe = wm831x_epe_probe, |
944 | .remove = wm831x_epe_remove, | ||
945 | .driver = { | 893 | .driver = { |
946 | .name = "wm831x-epe", | 894 | .name = "wm831x-epe", |
947 | .owner = THIS_MODULE, | 895 | .owner = THIS_MODULE, |
diff --git a/drivers/regulator/wm831x-isink.c b/drivers/regulator/wm831x-isink.c index 4eb373de1fac..0339b886df5d 100644 --- a/drivers/regulator/wm831x-isink.c +++ b/drivers/regulator/wm831x-isink.c | |||
@@ -194,7 +194,8 @@ static int wm831x_isink_probe(struct platform_device *pdev) | |||
194 | config.init_data = pdata->isink[id]; | 194 | config.init_data = pdata->isink[id]; |
195 | config.driver_data = isink; | 195 | config.driver_data = isink; |
196 | 196 | ||
197 | isink->regulator = regulator_register(&isink->desc, &config); | 197 | isink->regulator = devm_regulator_register(&pdev->dev, &isink->desc, |
198 | &config); | ||
198 | if (IS_ERR(isink->regulator)) { | 199 | if (IS_ERR(isink->regulator)) { |
199 | ret = PTR_ERR(isink->regulator); | 200 | ret = PTR_ERR(isink->regulator); |
200 | dev_err(wm831x->dev, "Failed to register ISINK%d: %d\n", | 201 | dev_err(wm831x->dev, "Failed to register ISINK%d: %d\n", |
@@ -203,38 +204,26 @@ static int wm831x_isink_probe(struct platform_device *pdev) | |||
203 | } | 204 | } |
204 | 205 | ||
205 | irq = wm831x_irq(wm831x, platform_get_irq(pdev, 0)); | 206 | irq = wm831x_irq(wm831x, platform_get_irq(pdev, 0)); |
206 | ret = request_threaded_irq(irq, NULL, wm831x_isink_irq, | 207 | ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, |
207 | IRQF_TRIGGER_RISING, isink->name, isink); | 208 | wm831x_isink_irq, |
209 | IRQF_TRIGGER_RISING, isink->name, | ||
210 | isink); | ||
208 | if (ret != 0) { | 211 | if (ret != 0) { |
209 | dev_err(&pdev->dev, "Failed to request ISINK IRQ %d: %d\n", | 212 | dev_err(&pdev->dev, "Failed to request ISINK IRQ %d: %d\n", |
210 | irq, ret); | 213 | irq, ret); |
211 | goto err_regulator; | 214 | goto err; |
212 | } | 215 | } |
213 | 216 | ||
214 | platform_set_drvdata(pdev, isink); | 217 | platform_set_drvdata(pdev, isink); |
215 | 218 | ||
216 | return 0; | 219 | return 0; |
217 | 220 | ||
218 | err_regulator: | ||
219 | regulator_unregister(isink->regulator); | ||
220 | err: | 221 | err: |
221 | return ret; | 222 | return ret; |
222 | } | 223 | } |
223 | 224 | ||
224 | static int wm831x_isink_remove(struct platform_device *pdev) | ||
225 | { | ||
226 | struct wm831x_isink *isink = platform_get_drvdata(pdev); | ||
227 | |||
228 | free_irq(wm831x_irq(isink->wm831x, platform_get_irq(pdev, 0)), isink); | ||
229 | |||
230 | regulator_unregister(isink->regulator); | ||
231 | |||
232 | return 0; | ||
233 | } | ||
234 | |||
235 | static struct platform_driver wm831x_isink_driver = { | 225 | static struct platform_driver wm831x_isink_driver = { |
236 | .probe = wm831x_isink_probe, | 226 | .probe = wm831x_isink_probe, |
237 | .remove = wm831x_isink_remove, | ||
238 | .driver = { | 227 | .driver = { |
239 | .name = "wm831x-isink", | 228 | .name = "wm831x-isink", |
240 | .owner = THIS_MODULE, | 229 | .owner = THIS_MODULE, |
diff --git a/drivers/regulator/wm831x-ldo.c b/drivers/regulator/wm831x-ldo.c index 2205fbc2c37b..46d6700467b5 100644 --- a/drivers/regulator/wm831x-ldo.c +++ b/drivers/regulator/wm831x-ldo.c | |||
@@ -63,10 +63,8 @@ static irqreturn_t wm831x_ldo_uv_irq(int irq, void *data) | |||
63 | */ | 63 | */ |
64 | 64 | ||
65 | static const struct regulator_linear_range wm831x_gp_ldo_ranges[] = { | 65 | static const struct regulator_linear_range wm831x_gp_ldo_ranges[] = { |
66 | { .min_uV = 900000, .max_uV = 1600000, .min_sel = 0, .max_sel = 14, | 66 | REGULATOR_LINEAR_RANGE(900000, 0, 14, 50000), |
67 | .uV_step = 50000 }, | 67 | REGULATOR_LINEAR_RANGE(1700000, 15, 31, 100000), |
68 | { .min_uV = 1700000, .max_uV = 3300000, .min_sel = 15, .max_sel = 31, | ||
69 | .uV_step = 100000 }, | ||
70 | }; | 68 | }; |
71 | 69 | ||
72 | static int wm831x_gp_ldo_set_suspend_voltage(struct regulator_dev *rdev, | 70 | static int wm831x_gp_ldo_set_suspend_voltage(struct regulator_dev *rdev, |
@@ -279,7 +277,8 @@ static int wm831x_gp_ldo_probe(struct platform_device *pdev) | |||
279 | config.driver_data = ldo; | 277 | config.driver_data = ldo; |
280 | config.regmap = wm831x->regmap; | 278 | config.regmap = wm831x->regmap; |
281 | 279 | ||
282 | ldo->regulator = regulator_register(&ldo->desc, &config); | 280 | ldo->regulator = devm_regulator_register(&pdev->dev, &ldo->desc, |
281 | &config); | ||
283 | if (IS_ERR(ldo->regulator)) { | 282 | if (IS_ERR(ldo->regulator)) { |
284 | ret = PTR_ERR(ldo->regulator); | 283 | ret = PTR_ERR(ldo->regulator); |
285 | dev_err(wm831x->dev, "Failed to register LDO%d: %d\n", | 284 | dev_err(wm831x->dev, "Failed to register LDO%d: %d\n", |
@@ -288,39 +287,26 @@ static int wm831x_gp_ldo_probe(struct platform_device *pdev) | |||
288 | } | 287 | } |
289 | 288 | ||
290 | irq = wm831x_irq(wm831x, platform_get_irq_byname(pdev, "UV")); | 289 | irq = wm831x_irq(wm831x, platform_get_irq_byname(pdev, "UV")); |
291 | ret = request_threaded_irq(irq, NULL, wm831x_ldo_uv_irq, | 290 | ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, |
292 | IRQF_TRIGGER_RISING, ldo->name, | 291 | wm831x_ldo_uv_irq, |
293 | ldo); | 292 | IRQF_TRIGGER_RISING, ldo->name, |
293 | ldo); | ||
294 | if (ret != 0) { | 294 | if (ret != 0) { |
295 | dev_err(&pdev->dev, "Failed to request UV IRQ %d: %d\n", | 295 | dev_err(&pdev->dev, "Failed to request UV IRQ %d: %d\n", |
296 | irq, ret); | 296 | irq, ret); |
297 | goto err_regulator; | 297 | goto err; |
298 | } | 298 | } |
299 | 299 | ||
300 | platform_set_drvdata(pdev, ldo); | 300 | platform_set_drvdata(pdev, ldo); |
301 | 301 | ||
302 | return 0; | 302 | return 0; |
303 | 303 | ||
304 | err_regulator: | ||
305 | regulator_unregister(ldo->regulator); | ||
306 | err: | 304 | err: |
307 | return ret; | 305 | return ret; |
308 | } | 306 | } |
309 | 307 | ||
310 | static int wm831x_gp_ldo_remove(struct platform_device *pdev) | ||
311 | { | ||
312 | struct wm831x_ldo *ldo = platform_get_drvdata(pdev); | ||
313 | |||
314 | free_irq(wm831x_irq(ldo->wm831x, | ||
315 | platform_get_irq_byname(pdev, "UV")), ldo); | ||
316 | regulator_unregister(ldo->regulator); | ||
317 | |||
318 | return 0; | ||
319 | } | ||
320 | |||
321 | static struct platform_driver wm831x_gp_ldo_driver = { | 308 | static struct platform_driver wm831x_gp_ldo_driver = { |
322 | .probe = wm831x_gp_ldo_probe, | 309 | .probe = wm831x_gp_ldo_probe, |
323 | .remove = wm831x_gp_ldo_remove, | ||
324 | .driver = { | 310 | .driver = { |
325 | .name = "wm831x-ldo", | 311 | .name = "wm831x-ldo", |
326 | .owner = THIS_MODULE, | 312 | .owner = THIS_MODULE, |
@@ -332,10 +318,8 @@ static struct platform_driver wm831x_gp_ldo_driver = { | |||
332 | */ | 318 | */ |
333 | 319 | ||
334 | static const struct regulator_linear_range wm831x_aldo_ranges[] = { | 320 | static const struct regulator_linear_range wm831x_aldo_ranges[] = { |
335 | { .min_uV = 1000000, .max_uV = 1600000, .min_sel = 0, .max_sel = 12, | 321 | REGULATOR_LINEAR_RANGE(1000000, 0, 12, 50000), |
336 | .uV_step = 50000 }, | 322 | REGULATOR_LINEAR_RANGE(1700000, 13, 31, 100000), |
337 | { .min_uV = 1700000, .max_uV = 3500000, .min_sel = 13, .max_sel = 31, | ||
338 | .uV_step = 100000 }, | ||
339 | }; | 323 | }; |
340 | 324 | ||
341 | static int wm831x_aldo_set_suspend_voltage(struct regulator_dev *rdev, | 325 | static int wm831x_aldo_set_suspend_voltage(struct regulator_dev *rdev, |
@@ -505,7 +489,8 @@ static int wm831x_aldo_probe(struct platform_device *pdev) | |||
505 | config.driver_data = ldo; | 489 | config.driver_data = ldo; |
506 | config.regmap = wm831x->regmap; | 490 | config.regmap = wm831x->regmap; |
507 | 491 | ||
508 | ldo->regulator = regulator_register(&ldo->desc, &config); | 492 | ldo->regulator = devm_regulator_register(&pdev->dev, &ldo->desc, |
493 | &config); | ||
509 | if (IS_ERR(ldo->regulator)) { | 494 | if (IS_ERR(ldo->regulator)) { |
510 | ret = PTR_ERR(ldo->regulator); | 495 | ret = PTR_ERR(ldo->regulator); |
511 | dev_err(wm831x->dev, "Failed to register LDO%d: %d\n", | 496 | dev_err(wm831x->dev, "Failed to register LDO%d: %d\n", |
@@ -514,38 +499,25 @@ static int wm831x_aldo_probe(struct platform_device *pdev) | |||
514 | } | 499 | } |
515 | 500 | ||
516 | irq = wm831x_irq(wm831x, platform_get_irq_byname(pdev, "UV")); | 501 | irq = wm831x_irq(wm831x, platform_get_irq_byname(pdev, "UV")); |
517 | ret = request_threaded_irq(irq, NULL, wm831x_ldo_uv_irq, | 502 | ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, |
518 | IRQF_TRIGGER_RISING, ldo->name, ldo); | 503 | wm831x_ldo_uv_irq, |
504 | IRQF_TRIGGER_RISING, ldo->name, ldo); | ||
519 | if (ret != 0) { | 505 | if (ret != 0) { |
520 | dev_err(&pdev->dev, "Failed to request UV IRQ %d: %d\n", | 506 | dev_err(&pdev->dev, "Failed to request UV IRQ %d: %d\n", |
521 | irq, ret); | 507 | irq, ret); |
522 | goto err_regulator; | 508 | goto err; |
523 | } | 509 | } |
524 | 510 | ||
525 | platform_set_drvdata(pdev, ldo); | 511 | platform_set_drvdata(pdev, ldo); |
526 | 512 | ||
527 | return 0; | 513 | return 0; |
528 | 514 | ||
529 | err_regulator: | ||
530 | regulator_unregister(ldo->regulator); | ||
531 | err: | 515 | err: |
532 | return ret; | 516 | return ret; |
533 | } | 517 | } |
534 | 518 | ||
535 | static int wm831x_aldo_remove(struct platform_device *pdev) | ||
536 | { | ||
537 | struct wm831x_ldo *ldo = platform_get_drvdata(pdev); | ||
538 | |||
539 | free_irq(wm831x_irq(ldo->wm831x, platform_get_irq_byname(pdev, "UV")), | ||
540 | ldo); | ||
541 | regulator_unregister(ldo->regulator); | ||
542 | |||
543 | return 0; | ||
544 | } | ||
545 | |||
546 | static struct platform_driver wm831x_aldo_driver = { | 519 | static struct platform_driver wm831x_aldo_driver = { |
547 | .probe = wm831x_aldo_probe, | 520 | .probe = wm831x_aldo_probe, |
548 | .remove = wm831x_aldo_remove, | ||
549 | .driver = { | 521 | .driver = { |
550 | .name = "wm831x-aldo", | 522 | .name = "wm831x-aldo", |
551 | .owner = THIS_MODULE, | 523 | .owner = THIS_MODULE, |
@@ -663,7 +635,8 @@ static int wm831x_alive_ldo_probe(struct platform_device *pdev) | |||
663 | config.driver_data = ldo; | 635 | config.driver_data = ldo; |
664 | config.regmap = wm831x->regmap; | 636 | config.regmap = wm831x->regmap; |
665 | 637 | ||
666 | ldo->regulator = regulator_register(&ldo->desc, &config); | 638 | ldo->regulator = devm_regulator_register(&pdev->dev, &ldo->desc, |
639 | &config); | ||
667 | if (IS_ERR(ldo->regulator)) { | 640 | if (IS_ERR(ldo->regulator)) { |
668 | ret = PTR_ERR(ldo->regulator); | 641 | ret = PTR_ERR(ldo->regulator); |
669 | dev_err(wm831x->dev, "Failed to register LDO%d: %d\n", | 642 | dev_err(wm831x->dev, "Failed to register LDO%d: %d\n", |
@@ -679,18 +652,8 @@ err: | |||
679 | return ret; | 652 | return ret; |
680 | } | 653 | } |
681 | 654 | ||
682 | static int wm831x_alive_ldo_remove(struct platform_device *pdev) | ||
683 | { | ||
684 | struct wm831x_ldo *ldo = platform_get_drvdata(pdev); | ||
685 | |||
686 | regulator_unregister(ldo->regulator); | ||
687 | |||
688 | return 0; | ||
689 | } | ||
690 | |||
691 | static struct platform_driver wm831x_alive_ldo_driver = { | 655 | static struct platform_driver wm831x_alive_ldo_driver = { |
692 | .probe = wm831x_alive_ldo_probe, | 656 | .probe = wm831x_alive_ldo_probe, |
693 | .remove = wm831x_alive_ldo_remove, | ||
694 | .driver = { | 657 | .driver = { |
695 | .name = "wm831x-alive-ldo", | 658 | .name = "wm831x-alive-ldo", |
696 | .owner = THIS_MODULE, | 659 | .owner = THIS_MODULE, |
diff --git a/drivers/regulator/wm8350-regulator.c b/drivers/regulator/wm8350-regulator.c index 61ca9292a429..de7b9c73e3fa 100644 --- a/drivers/regulator/wm8350-regulator.c +++ b/drivers/regulator/wm8350-regulator.c | |||
@@ -543,10 +543,8 @@ static int wm8350_dcdc_set_suspend_mode(struct regulator_dev *rdev, | |||
543 | } | 543 | } |
544 | 544 | ||
545 | static const struct regulator_linear_range wm8350_ldo_ranges[] = { | 545 | static const struct regulator_linear_range wm8350_ldo_ranges[] = { |
546 | { .min_uV = 900000, .max_uV = 1650000, .min_sel = 0, .max_sel = 15, | 546 | REGULATOR_LINEAR_RANGE(900000, 0, 15, 50000), |
547 | .uV_step = 50000 }, | 547 | REGULATOR_LINEAR_RANGE(1800000, 16, 31, 100000), |
548 | { .min_uV = 1800000, .max_uV = 3300000, .min_sel = 16, .max_sel = 31, | ||
549 | .uV_step = 100000 }, | ||
550 | }; | 548 | }; |
551 | 549 | ||
552 | static int wm8350_ldo_set_suspend_voltage(struct regulator_dev *rdev, int uV) | 550 | static int wm8350_ldo_set_suspend_voltage(struct regulator_dev *rdev, int uV) |
@@ -1206,7 +1204,8 @@ static int wm8350_regulator_probe(struct platform_device *pdev) | |||
1206 | config.regmap = wm8350->regmap; | 1204 | config.regmap = wm8350->regmap; |
1207 | 1205 | ||
1208 | /* register regulator */ | 1206 | /* register regulator */ |
1209 | rdev = regulator_register(&wm8350_reg[pdev->id], &config); | 1207 | rdev = devm_regulator_register(&pdev->dev, &wm8350_reg[pdev->id], |
1208 | &config); | ||
1210 | if (IS_ERR(rdev)) { | 1209 | if (IS_ERR(rdev)) { |
1211 | dev_err(&pdev->dev, "failed to register %s\n", | 1210 | dev_err(&pdev->dev, "failed to register %s\n", |
1212 | wm8350_reg[pdev->id].name); | 1211 | wm8350_reg[pdev->id].name); |
@@ -1217,7 +1216,6 @@ static int wm8350_regulator_probe(struct platform_device *pdev) | |||
1217 | ret = wm8350_register_irq(wm8350, wm8350_reg[pdev->id].irq, | 1216 | ret = wm8350_register_irq(wm8350, wm8350_reg[pdev->id].irq, |
1218 | pmic_uv_handler, 0, "UV", rdev); | 1217 | pmic_uv_handler, 0, "UV", rdev); |
1219 | if (ret < 0) { | 1218 | if (ret < 0) { |
1220 | regulator_unregister(rdev); | ||
1221 | dev_err(&pdev->dev, "failed to register regulator %s IRQ\n", | 1219 | dev_err(&pdev->dev, "failed to register regulator %s IRQ\n", |
1222 | wm8350_reg[pdev->id].name); | 1220 | wm8350_reg[pdev->id].name); |
1223 | return ret; | 1221 | return ret; |
@@ -1233,8 +1231,6 @@ static int wm8350_regulator_remove(struct platform_device *pdev) | |||
1233 | 1231 | ||
1234 | wm8350_free_irq(wm8350, wm8350_reg[pdev->id].irq, rdev); | 1232 | wm8350_free_irq(wm8350, wm8350_reg[pdev->id].irq, rdev); |
1235 | 1233 | ||
1236 | regulator_unregister(rdev); | ||
1237 | |||
1238 | return 0; | 1234 | return 0; |
1239 | } | 1235 | } |
1240 | 1236 | ||
diff --git a/drivers/regulator/wm8400-regulator.c b/drivers/regulator/wm8400-regulator.c index 58f51bec13f2..82d829000851 100644 --- a/drivers/regulator/wm8400-regulator.c +++ b/drivers/regulator/wm8400-regulator.c | |||
@@ -20,10 +20,8 @@ | |||
20 | #include <linux/mfd/wm8400-private.h> | 20 | #include <linux/mfd/wm8400-private.h> |
21 | 21 | ||
22 | static const struct regulator_linear_range wm8400_ldo_ranges[] = { | 22 | static const struct regulator_linear_range wm8400_ldo_ranges[] = { |
23 | { .min_uV = 900000, .max_uV = 1600000, .min_sel = 0, .max_sel = 14, | 23 | REGULATOR_LINEAR_RANGE(900000, 0, 14, 50000), |
24 | .uV_step = 50000 }, | 24 | REGULATOR_LINEAR_RANGE(1700000, 15, 31, 100000), |
25 | { .min_uV = 1700000, .max_uV = 3300000, .min_sel = 15, .max_sel = 31, | ||
26 | .uV_step = 100000 }, | ||
27 | }; | 25 | }; |
28 | 26 | ||
29 | static struct regulator_ops wm8400_ldo_ops = { | 27 | static struct regulator_ops wm8400_ldo_ops = { |
@@ -219,7 +217,8 @@ static int wm8400_regulator_probe(struct platform_device *pdev) | |||
219 | config.driver_data = wm8400; | 217 | config.driver_data = wm8400; |
220 | config.regmap = wm8400->regmap; | 218 | config.regmap = wm8400->regmap; |
221 | 219 | ||
222 | rdev = regulator_register(®ulators[pdev->id], &config); | 220 | rdev = devm_regulator_register(&pdev->dev, ®ulators[pdev->id], |
221 | &config); | ||
223 | if (IS_ERR(rdev)) | 222 | if (IS_ERR(rdev)) |
224 | return PTR_ERR(rdev); | 223 | return PTR_ERR(rdev); |
225 | 224 | ||
@@ -228,21 +227,11 @@ static int wm8400_regulator_probe(struct platform_device *pdev) | |||
228 | return 0; | 227 | return 0; |
229 | } | 228 | } |
230 | 229 | ||
231 | static int wm8400_regulator_remove(struct platform_device *pdev) | ||
232 | { | ||
233 | struct regulator_dev *rdev = platform_get_drvdata(pdev); | ||
234 | |||
235 | regulator_unregister(rdev); | ||
236 | |||
237 | return 0; | ||
238 | } | ||
239 | |||
240 | static struct platform_driver wm8400_regulator_driver = { | 230 | static struct platform_driver wm8400_regulator_driver = { |
241 | .driver = { | 231 | .driver = { |
242 | .name = "wm8400-regulator", | 232 | .name = "wm8400-regulator", |
243 | }, | 233 | }, |
244 | .probe = wm8400_regulator_probe, | 234 | .probe = wm8400_regulator_probe, |
245 | .remove = wm8400_regulator_remove, | ||
246 | }; | 235 | }; |
247 | 236 | ||
248 | /** | 237 | /** |
diff --git a/drivers/regulator/wm8994-regulator.c b/drivers/regulator/wm8994-regulator.c index 5ee2a208457c..71c5911f2e71 100644 --- a/drivers/regulator/wm8994-regulator.c +++ b/drivers/regulator/wm8994-regulator.c | |||
@@ -165,7 +165,9 @@ static int wm8994_ldo_probe(struct platform_device *pdev) | |||
165 | ldo->init_data = *pdata->ldo[id].init_data; | 165 | ldo->init_data = *pdata->ldo[id].init_data; |
166 | } | 166 | } |
167 | 167 | ||
168 | ldo->regulator = regulator_register(&wm8994_ldo_desc[id], &config); | 168 | ldo->regulator = devm_regulator_register(&pdev->dev, |
169 | &wm8994_ldo_desc[id], | ||
170 | &config); | ||
169 | if (IS_ERR(ldo->regulator)) { | 171 | if (IS_ERR(ldo->regulator)) { |
170 | ret = PTR_ERR(ldo->regulator); | 172 | ret = PTR_ERR(ldo->regulator); |
171 | dev_err(wm8994->dev, "Failed to register LDO%d: %d\n", | 173 | dev_err(wm8994->dev, "Failed to register LDO%d: %d\n", |
@@ -181,18 +183,8 @@ err: | |||
181 | return ret; | 183 | return ret; |
182 | } | 184 | } |
183 | 185 | ||
184 | static int wm8994_ldo_remove(struct platform_device *pdev) | ||
185 | { | ||
186 | struct wm8994_ldo *ldo = platform_get_drvdata(pdev); | ||
187 | |||
188 | regulator_unregister(ldo->regulator); | ||
189 | |||
190 | return 0; | ||
191 | } | ||
192 | |||
193 | static struct platform_driver wm8994_ldo_driver = { | 186 | static struct platform_driver wm8994_ldo_driver = { |
194 | .probe = wm8994_ldo_probe, | 187 | .probe = wm8994_ldo_probe, |
195 | .remove = wm8994_ldo_remove, | ||
196 | .driver = { | 188 | .driver = { |
197 | .name = "wm8994-ldo", | 189 | .name = "wm8994-ldo", |
198 | .owner = THIS_MODULE, | 190 | .owner = THIS_MODULE, |
diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index a0ebbc9ce5cd..042aa077b5b3 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c | |||
@@ -1912,9 +1912,6 @@ static int serial_imx_probe_dt(struct imx_port *sport, | |||
1912 | 1912 | ||
1913 | sport->devdata = of_id->data; | 1913 | sport->devdata = of_id->data; |
1914 | 1914 | ||
1915 | if (of_device_is_stdout_path(np)) | ||
1916 | add_preferred_console(imx_reg.cons->name, sport->port.line, 0); | ||
1917 | |||
1918 | return 0; | 1915 | return 0; |
1919 | } | 1916 | } |
1920 | #else | 1917 | #else |
diff --git a/drivers/tty/serial/vt8500_serial.c b/drivers/tty/serial/vt8500_serial.c index 93b697a0de65..15ad6fcda88b 100644 --- a/drivers/tty/serial/vt8500_serial.c +++ b/drivers/tty/serial/vt8500_serial.c | |||
@@ -561,12 +561,13 @@ static int vt8500_serial_probe(struct platform_device *pdev) | |||
561 | if (!mmres || !irqres) | 561 | if (!mmres || !irqres) |
562 | return -ENODEV; | 562 | return -ENODEV; |
563 | 563 | ||
564 | if (np) | 564 | if (np) { |
565 | port = of_alias_get_id(np, "serial"); | 565 | port = of_alias_get_id(np, "serial"); |
566 | if (port >= VT8500_MAX_PORTS) | 566 | if (port >= VT8500_MAX_PORTS) |
567 | port = -1; | 567 | port = -1; |
568 | else | 568 | } else { |
569 | port = -1; | 569 | port = -1; |
570 | } | ||
570 | 571 | ||
571 | if (port < 0) { | 572 | if (port < 0) { |
572 | /* calculate the port id */ | 573 | /* calculate the port id */ |
diff --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c index 6f96795dd20c..64d7a6d9a1ad 100644 --- a/drivers/usb/chipidea/host.c +++ b/drivers/usb/chipidea/host.c | |||
@@ -100,8 +100,10 @@ static void host_stop(struct ci_hdrc *ci) | |||
100 | { | 100 | { |
101 | struct usb_hcd *hcd = ci->hcd; | 101 | struct usb_hcd *hcd = ci->hcd; |
102 | 102 | ||
103 | usb_remove_hcd(hcd); | 103 | if (hcd) { |
104 | usb_put_hcd(hcd); | 104 | usb_remove_hcd(hcd); |
105 | usb_put_hcd(hcd); | ||
106 | } | ||
105 | if (ci->platdata->reg_vbus) | 107 | if (ci->platdata->reg_vbus) |
106 | regulator_disable(ci->platdata->reg_vbus); | 108 | regulator_disable(ci->platdata->reg_vbus); |
107 | } | 109 | } |
diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c index 5b44cd47da5b..01fe36273f3b 100644 --- a/drivers/usb/core/quirks.c +++ b/drivers/usb/core/quirks.c | |||
@@ -97,6 +97,9 @@ static const struct usb_device_id usb_quirk_list[] = { | |||
97 | /* Alcor Micro Corp. Hub */ | 97 | /* Alcor Micro Corp. Hub */ |
98 | { USB_DEVICE(0x058f, 0x9254), .driver_info = USB_QUIRK_RESET_RESUME }, | 98 | { USB_DEVICE(0x058f, 0x9254), .driver_info = USB_QUIRK_RESET_RESUME }, |
99 | 99 | ||
100 | /* MicroTouch Systems touchscreen */ | ||
101 | { USB_DEVICE(0x0596, 0x051e), .driver_info = USB_QUIRK_RESET_RESUME }, | ||
102 | |||
100 | /* appletouch */ | 103 | /* appletouch */ |
101 | { USB_DEVICE(0x05ac, 0x021a), .driver_info = USB_QUIRK_RESET_RESUME }, | 104 | { USB_DEVICE(0x05ac, 0x021a), .driver_info = USB_QUIRK_RESET_RESUME }, |
102 | 105 | ||
@@ -130,6 +133,9 @@ static const struct usb_device_id usb_quirk_list[] = { | |||
130 | /* Broadcom BCM92035DGROM BT dongle */ | 133 | /* Broadcom BCM92035DGROM BT dongle */ |
131 | { USB_DEVICE(0x0a5c, 0x2021), .driver_info = USB_QUIRK_RESET_RESUME }, | 134 | { USB_DEVICE(0x0a5c, 0x2021), .driver_info = USB_QUIRK_RESET_RESUME }, |
132 | 135 | ||
136 | /* MAYA44USB sound device */ | ||
137 | { USB_DEVICE(0x0a92, 0x0091), .driver_info = USB_QUIRK_RESET_RESUME }, | ||
138 | |||
133 | /* Action Semiconductor flash disk */ | 139 | /* Action Semiconductor flash disk */ |
134 | { USB_DEVICE(0x10d6, 0x2200), .driver_info = | 140 | { USB_DEVICE(0x10d6, 0x2200), .driver_info = |
135 | USB_QUIRK_STRING_FETCH_255 }, | 141 | USB_QUIRK_STRING_FETCH_255 }, |
diff --git a/drivers/usb/host/pci-quirks.c b/drivers/usb/host/pci-quirks.c index 2c76ef1320ea..08ef2829a7e2 100644 --- a/drivers/usb/host/pci-quirks.c +++ b/drivers/usb/host/pci-quirks.c | |||
@@ -799,7 +799,7 @@ void usb_enable_intel_xhci_ports(struct pci_dev *xhci_pdev) | |||
799 | * switchable ports. | 799 | * switchable ports. |
800 | */ | 800 | */ |
801 | pci_write_config_dword(xhci_pdev, USB_INTEL_USB3_PSSEN, | 801 | pci_write_config_dword(xhci_pdev, USB_INTEL_USB3_PSSEN, |
802 | cpu_to_le32(ports_available)); | 802 | ports_available); |
803 | 803 | ||
804 | pci_read_config_dword(xhci_pdev, USB_INTEL_USB3_PSSEN, | 804 | pci_read_config_dword(xhci_pdev, USB_INTEL_USB3_PSSEN, |
805 | &ports_available); | 805 | &ports_available); |
@@ -821,7 +821,7 @@ void usb_enable_intel_xhci_ports(struct pci_dev *xhci_pdev) | |||
821 | * host. | 821 | * host. |
822 | */ | 822 | */ |
823 | pci_write_config_dword(xhci_pdev, USB_INTEL_XUSB2PR, | 823 | pci_write_config_dword(xhci_pdev, USB_INTEL_XUSB2PR, |
824 | cpu_to_le32(ports_available)); | 824 | ports_available); |
825 | 825 | ||
826 | pci_read_config_dword(xhci_pdev, USB_INTEL_XUSB2PR, | 826 | pci_read_config_dword(xhci_pdev, USB_INTEL_XUSB2PR, |
827 | &ports_available); | 827 | &ports_available); |
diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c index 773a6b28c4f1..e8b4c56dcf62 100644 --- a/drivers/usb/host/xhci-hub.c +++ b/drivers/usb/host/xhci-hub.c | |||
@@ -1157,18 +1157,6 @@ int xhci_bus_suspend(struct usb_hcd *hcd) | |||
1157 | t1 = xhci_port_state_to_neutral(t1); | 1157 | t1 = xhci_port_state_to_neutral(t1); |
1158 | if (t1 != t2) | 1158 | if (t1 != t2) |
1159 | xhci_writel(xhci, t2, port_array[port_index]); | 1159 | xhci_writel(xhci, t2, port_array[port_index]); |
1160 | |||
1161 | if (hcd->speed != HCD_USB3) { | ||
1162 | /* enable remote wake up for USB 2.0 */ | ||
1163 | __le32 __iomem *addr; | ||
1164 | u32 tmp; | ||
1165 | |||
1166 | /* Get the port power control register address. */ | ||
1167 | addr = port_array[port_index] + PORTPMSC; | ||
1168 | tmp = xhci_readl(xhci, addr); | ||
1169 | tmp |= PORT_RWE; | ||
1170 | xhci_writel(xhci, tmp, addr); | ||
1171 | } | ||
1172 | } | 1160 | } |
1173 | hcd->state = HC_STATE_SUSPENDED; | 1161 | hcd->state = HC_STATE_SUSPENDED; |
1174 | bus_state->next_statechange = jiffies + msecs_to_jiffies(10); | 1162 | bus_state->next_statechange = jiffies + msecs_to_jiffies(10); |
@@ -1247,20 +1235,6 @@ int xhci_bus_resume(struct usb_hcd *hcd) | |||
1247 | xhci_ring_device(xhci, slot_id); | 1235 | xhci_ring_device(xhci, slot_id); |
1248 | } else | 1236 | } else |
1249 | xhci_writel(xhci, temp, port_array[port_index]); | 1237 | xhci_writel(xhci, temp, port_array[port_index]); |
1250 | |||
1251 | if (hcd->speed != HCD_USB3) { | ||
1252 | /* disable remote wake up for USB 2.0 */ | ||
1253 | __le32 __iomem *addr; | ||
1254 | u32 tmp; | ||
1255 | |||
1256 | /* Add one to the port status register address to get | ||
1257 | * the port power control register address. | ||
1258 | */ | ||
1259 | addr = port_array[port_index] + PORTPMSC; | ||
1260 | tmp = xhci_readl(xhci, addr); | ||
1261 | tmp &= ~PORT_RWE; | ||
1262 | xhci_writel(xhci, tmp, addr); | ||
1263 | } | ||
1264 | } | 1238 | } |
1265 | 1239 | ||
1266 | (void) xhci_readl(xhci, &xhci->op_regs->command); | 1240 | (void) xhci_readl(xhci, &xhci->op_regs->command); |
diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c index 236c3aabe940..b8dffd59eb25 100644 --- a/drivers/usb/host/xhci-pci.c +++ b/drivers/usb/host/xhci-pci.c | |||
@@ -35,6 +35,9 @@ | |||
35 | #define PCI_VENDOR_ID_ETRON 0x1b6f | 35 | #define PCI_VENDOR_ID_ETRON 0x1b6f |
36 | #define PCI_DEVICE_ID_ASROCK_P67 0x7023 | 36 | #define PCI_DEVICE_ID_ASROCK_P67 0x7023 |
37 | 37 | ||
38 | #define PCI_DEVICE_ID_INTEL_LYNXPOINT_XHCI 0x8c31 | ||
39 | #define PCI_DEVICE_ID_INTEL_LYNXPOINT_LP_XHCI 0x9c31 | ||
40 | |||
38 | static const char hcd_name[] = "xhci_hcd"; | 41 | static const char hcd_name[] = "xhci_hcd"; |
39 | 42 | ||
40 | /* called after powerup, by probe or system-pm "wakeup" */ | 43 | /* called after powerup, by probe or system-pm "wakeup" */ |
@@ -69,6 +72,14 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci) | |||
69 | "QUIRK: Fresco Logic xHC needs configure" | 72 | "QUIRK: Fresco Logic xHC needs configure" |
70 | " endpoint cmd after reset endpoint"); | 73 | " endpoint cmd after reset endpoint"); |
71 | } | 74 | } |
75 | if (pdev->device == PCI_DEVICE_ID_FRESCO_LOGIC_PDK && | ||
76 | pdev->revision == 0x4) { | ||
77 | xhci->quirks |= XHCI_SLOW_SUSPEND; | ||
78 | xhci_dbg_trace(xhci, trace_xhci_dbg_quirks, | ||
79 | "QUIRK: Fresco Logic xHC revision %u" | ||
80 | "must be suspended extra slowly", | ||
81 | pdev->revision); | ||
82 | } | ||
72 | /* Fresco Logic confirms: all revisions of this chip do not | 83 | /* Fresco Logic confirms: all revisions of this chip do not |
73 | * support MSI, even though some of them claim to in their PCI | 84 | * support MSI, even though some of them claim to in their PCI |
74 | * capabilities. | 85 | * capabilities. |
@@ -110,6 +121,15 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci) | |||
110 | xhci->quirks |= XHCI_SPURIOUS_REBOOT; | 121 | xhci->quirks |= XHCI_SPURIOUS_REBOOT; |
111 | xhci->quirks |= XHCI_AVOID_BEI; | 122 | xhci->quirks |= XHCI_AVOID_BEI; |
112 | } | 123 | } |
124 | if (pdev->vendor == PCI_VENDOR_ID_INTEL && | ||
125 | (pdev->device == PCI_DEVICE_ID_INTEL_LYNXPOINT_XHCI || | ||
126 | pdev->device == PCI_DEVICE_ID_INTEL_LYNXPOINT_LP_XHCI)) { | ||
127 | /* Workaround for occasional spurious wakeups from S5 (or | ||
128 | * any other sleep) on Haswell machines with LPT and LPT-LP | ||
129 | * with the new Intel BIOS | ||
130 | */ | ||
131 | xhci->quirks |= XHCI_SPURIOUS_WAKEUP; | ||
132 | } | ||
113 | if (pdev->vendor == PCI_VENDOR_ID_ETRON && | 133 | if (pdev->vendor == PCI_VENDOR_ID_ETRON && |
114 | pdev->device == PCI_DEVICE_ID_ASROCK_P67) { | 134 | pdev->device == PCI_DEVICE_ID_ASROCK_P67) { |
115 | xhci->quirks |= XHCI_RESET_ON_RESUME; | 135 | xhci->quirks |= XHCI_RESET_ON_RESUME; |
@@ -217,6 +237,11 @@ static void xhci_pci_remove(struct pci_dev *dev) | |||
217 | usb_put_hcd(xhci->shared_hcd); | 237 | usb_put_hcd(xhci->shared_hcd); |
218 | } | 238 | } |
219 | usb_hcd_pci_remove(dev); | 239 | usb_hcd_pci_remove(dev); |
240 | |||
241 | /* Workaround for spurious wakeups at shutdown with HSW */ | ||
242 | if (xhci->quirks & XHCI_SPURIOUS_WAKEUP) | ||
243 | pci_set_power_state(dev, PCI_D3hot); | ||
244 | |||
220 | kfree(xhci); | 245 | kfree(xhci); |
221 | } | 246 | } |
222 | 247 | ||
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 1e36dbb48366..6e0d886bcce5 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c | |||
@@ -730,6 +730,9 @@ void xhci_shutdown(struct usb_hcd *hcd) | |||
730 | 730 | ||
731 | spin_lock_irq(&xhci->lock); | 731 | spin_lock_irq(&xhci->lock); |
732 | xhci_halt(xhci); | 732 | xhci_halt(xhci); |
733 | /* Workaround for spurious wakeups at shutdown with HSW */ | ||
734 | if (xhci->quirks & XHCI_SPURIOUS_WAKEUP) | ||
735 | xhci_reset(xhci); | ||
733 | spin_unlock_irq(&xhci->lock); | 736 | spin_unlock_irq(&xhci->lock); |
734 | 737 | ||
735 | xhci_cleanup_msix(xhci); | 738 | xhci_cleanup_msix(xhci); |
@@ -737,6 +740,10 @@ void xhci_shutdown(struct usb_hcd *hcd) | |||
737 | xhci_dbg_trace(xhci, trace_xhci_dbg_init, | 740 | xhci_dbg_trace(xhci, trace_xhci_dbg_init, |
738 | "xhci_shutdown completed - status = %x", | 741 | "xhci_shutdown completed - status = %x", |
739 | xhci_readl(xhci, &xhci->op_regs->status)); | 742 | xhci_readl(xhci, &xhci->op_regs->status)); |
743 | |||
744 | /* Yet another workaround for spurious wakeups at shutdown with HSW */ | ||
745 | if (xhci->quirks & XHCI_SPURIOUS_WAKEUP) | ||
746 | pci_set_power_state(to_pci_dev(hcd->self.controller), PCI_D3hot); | ||
740 | } | 747 | } |
741 | 748 | ||
742 | #ifdef CONFIG_PM | 749 | #ifdef CONFIG_PM |
@@ -839,6 +846,7 @@ static void xhci_clear_command_ring(struct xhci_hcd *xhci) | |||
839 | int xhci_suspend(struct xhci_hcd *xhci) | 846 | int xhci_suspend(struct xhci_hcd *xhci) |
840 | { | 847 | { |
841 | int rc = 0; | 848 | int rc = 0; |
849 | unsigned int delay = XHCI_MAX_HALT_USEC; | ||
842 | struct usb_hcd *hcd = xhci_to_hcd(xhci); | 850 | struct usb_hcd *hcd = xhci_to_hcd(xhci); |
843 | u32 command; | 851 | u32 command; |
844 | 852 | ||
@@ -861,8 +869,12 @@ int xhci_suspend(struct xhci_hcd *xhci) | |||
861 | command = xhci_readl(xhci, &xhci->op_regs->command); | 869 | command = xhci_readl(xhci, &xhci->op_regs->command); |
862 | command &= ~CMD_RUN; | 870 | command &= ~CMD_RUN; |
863 | xhci_writel(xhci, command, &xhci->op_regs->command); | 871 | xhci_writel(xhci, command, &xhci->op_regs->command); |
872 | |||
873 | /* Some chips from Fresco Logic need an extraordinary delay */ | ||
874 | delay *= (xhci->quirks & XHCI_SLOW_SUSPEND) ? 10 : 1; | ||
875 | |||
864 | if (xhci_handshake(xhci, &xhci->op_regs->status, | 876 | if (xhci_handshake(xhci, &xhci->op_regs->status, |
865 | STS_HALT, STS_HALT, XHCI_MAX_HALT_USEC)) { | 877 | STS_HALT, STS_HALT, delay)) { |
866 | xhci_warn(xhci, "WARN: xHC CMD_RUN timeout\n"); | 878 | xhci_warn(xhci, "WARN: xHC CMD_RUN timeout\n"); |
867 | spin_unlock_irq(&xhci->lock); | 879 | spin_unlock_irq(&xhci->lock); |
868 | return -ETIMEDOUT; | 880 | return -ETIMEDOUT; |
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index 289fbfbae746..941d5f59e4dc 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h | |||
@@ -1548,6 +1548,8 @@ struct xhci_hcd { | |||
1548 | #define XHCI_COMP_MODE_QUIRK (1 << 14) | 1548 | #define XHCI_COMP_MODE_QUIRK (1 << 14) |
1549 | #define XHCI_AVOID_BEI (1 << 15) | 1549 | #define XHCI_AVOID_BEI (1 << 15) |
1550 | #define XHCI_PLAT (1 << 16) | 1550 | #define XHCI_PLAT (1 << 16) |
1551 | #define XHCI_SLOW_SUSPEND (1 << 17) | ||
1552 | #define XHCI_SPURIOUS_WAKEUP (1 << 18) | ||
1551 | unsigned int num_active_eps; | 1553 | unsigned int num_active_eps; |
1552 | unsigned int limit_active_eps; | 1554 | unsigned int limit_active_eps; |
1553 | /* There are two roothubs to keep track of bus suspend info for */ | 1555 | /* There are two roothubs to keep track of bus suspend info for */ |
diff --git a/drivers/usb/misc/Kconfig b/drivers/usb/misc/Kconfig index e2b21c1d9c40..ba5f70f92888 100644 --- a/drivers/usb/misc/Kconfig +++ b/drivers/usb/misc/Kconfig | |||
@@ -246,6 +246,6 @@ config USB_EZUSB_FX2 | |||
246 | config USB_HSIC_USB3503 | 246 | config USB_HSIC_USB3503 |
247 | tristate "USB3503 HSIC to USB20 Driver" | 247 | tristate "USB3503 HSIC to USB20 Driver" |
248 | depends on I2C | 248 | depends on I2C |
249 | select REGMAP | 249 | select REGMAP_I2C |
250 | help | 250 | help |
251 | This option enables support for SMSC USB3503 HSIC to USB 2.0 Driver. | 251 | This option enables support for SMSC USB3503 HSIC to USB 2.0 Driver. |
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c index 18e877ffe7b7..cd70cc886171 100644 --- a/drivers/usb/musb/musb_core.c +++ b/drivers/usb/musb/musb_core.c | |||
@@ -922,6 +922,52 @@ static void musb_generic_disable(struct musb *musb) | |||
922 | } | 922 | } |
923 | 923 | ||
924 | /* | 924 | /* |
925 | * Program the HDRC to start (enable interrupts, dma, etc.). | ||
926 | */ | ||
927 | void musb_start(struct musb *musb) | ||
928 | { | ||
929 | void __iomem *regs = musb->mregs; | ||
930 | u8 devctl = musb_readb(regs, MUSB_DEVCTL); | ||
931 | |||
932 | dev_dbg(musb->controller, "<== devctl %02x\n", devctl); | ||
933 | |||
934 | /* Set INT enable registers, enable interrupts */ | ||
935 | musb->intrtxe = musb->epmask; | ||
936 | musb_writew(regs, MUSB_INTRTXE, musb->intrtxe); | ||
937 | musb->intrrxe = musb->epmask & 0xfffe; | ||
938 | musb_writew(regs, MUSB_INTRRXE, musb->intrrxe); | ||
939 | musb_writeb(regs, MUSB_INTRUSBE, 0xf7); | ||
940 | |||
941 | musb_writeb(regs, MUSB_TESTMODE, 0); | ||
942 | |||
943 | /* put into basic highspeed mode and start session */ | ||
944 | musb_writeb(regs, MUSB_POWER, MUSB_POWER_ISOUPDATE | ||
945 | | MUSB_POWER_HSENAB | ||
946 | /* ENSUSPEND wedges tusb */ | ||
947 | /* | MUSB_POWER_ENSUSPEND */ | ||
948 | ); | ||
949 | |||
950 | musb->is_active = 0; | ||
951 | devctl = musb_readb(regs, MUSB_DEVCTL); | ||
952 | devctl &= ~MUSB_DEVCTL_SESSION; | ||
953 | |||
954 | /* session started after: | ||
955 | * (a) ID-grounded irq, host mode; | ||
956 | * (b) vbus present/connect IRQ, peripheral mode; | ||
957 | * (c) peripheral initiates, using SRP | ||
958 | */ | ||
959 | if (musb->port_mode != MUSB_PORT_MODE_HOST && | ||
960 | (devctl & MUSB_DEVCTL_VBUS) == MUSB_DEVCTL_VBUS) { | ||
961 | musb->is_active = 1; | ||
962 | } else { | ||
963 | devctl |= MUSB_DEVCTL_SESSION; | ||
964 | } | ||
965 | |||
966 | musb_platform_enable(musb); | ||
967 | musb_writeb(regs, MUSB_DEVCTL, devctl); | ||
968 | } | ||
969 | |||
970 | /* | ||
925 | * Make the HDRC stop (disable interrupts, etc.); | 971 | * Make the HDRC stop (disable interrupts, etc.); |
926 | * reversible by musb_start | 972 | * reversible by musb_start |
927 | * called on gadget driver unregister | 973 | * called on gadget driver unregister |
diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h index 65f3917b4fc5..1c5bf75ee8ff 100644 --- a/drivers/usb/musb/musb_core.h +++ b/drivers/usb/musb/musb_core.h | |||
@@ -503,6 +503,7 @@ static inline void musb_configure_ep0(struct musb *musb) | |||
503 | extern const char musb_driver_name[]; | 503 | extern const char musb_driver_name[]; |
504 | 504 | ||
505 | extern void musb_stop(struct musb *musb); | 505 | extern void musb_stop(struct musb *musb); |
506 | extern void musb_start(struct musb *musb); | ||
506 | 507 | ||
507 | extern void musb_write_fifo(struct musb_hw_ep *ep, u16 len, const u8 *src); | 508 | extern void musb_write_fifo(struct musb_hw_ep *ep, u16 len, const u8 *src); |
508 | extern void musb_read_fifo(struct musb_hw_ep *ep, u16 len, u8 *dst); | 509 | extern void musb_read_fifo(struct musb_hw_ep *ep, u16 len, u8 *dst); |
diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c index b19ed213ab85..3671898a4535 100644 --- a/drivers/usb/musb/musb_gadget.c +++ b/drivers/usb/musb/musb_gadget.c | |||
@@ -1853,11 +1853,14 @@ static int musb_gadget_start(struct usb_gadget *g, | |||
1853 | musb->gadget_driver = driver; | 1853 | musb->gadget_driver = driver; |
1854 | 1854 | ||
1855 | spin_lock_irqsave(&musb->lock, flags); | 1855 | spin_lock_irqsave(&musb->lock, flags); |
1856 | musb->is_active = 1; | ||
1856 | 1857 | ||
1857 | otg_set_peripheral(otg, &musb->g); | 1858 | otg_set_peripheral(otg, &musb->g); |
1858 | musb->xceiv->state = OTG_STATE_B_IDLE; | 1859 | musb->xceiv->state = OTG_STATE_B_IDLE; |
1859 | spin_unlock_irqrestore(&musb->lock, flags); | 1860 | spin_unlock_irqrestore(&musb->lock, flags); |
1860 | 1861 | ||
1862 | musb_start(musb); | ||
1863 | |||
1861 | /* REVISIT: funcall to other code, which also | 1864 | /* REVISIT: funcall to other code, which also |
1862 | * handles power budgeting ... this way also | 1865 | * handles power budgeting ... this way also |
1863 | * ensures HdrcStart is indirectly called. | 1866 | * ensures HdrcStart is indirectly called. |
diff --git a/drivers/usb/musb/musb_virthub.c b/drivers/usb/musb/musb_virthub.c index a523950c2b32..d1d6b83aabca 100644 --- a/drivers/usb/musb/musb_virthub.c +++ b/drivers/usb/musb/musb_virthub.c | |||
@@ -44,52 +44,6 @@ | |||
44 | 44 | ||
45 | #include "musb_core.h" | 45 | #include "musb_core.h" |
46 | 46 | ||
47 | /* | ||
48 | * Program the HDRC to start (enable interrupts, dma, etc.). | ||
49 | */ | ||
50 | static void musb_start(struct musb *musb) | ||
51 | { | ||
52 | void __iomem *regs = musb->mregs; | ||
53 | u8 devctl = musb_readb(regs, MUSB_DEVCTL); | ||
54 | |||
55 | dev_dbg(musb->controller, "<== devctl %02x\n", devctl); | ||
56 | |||
57 | /* Set INT enable registers, enable interrupts */ | ||
58 | musb->intrtxe = musb->epmask; | ||
59 | musb_writew(regs, MUSB_INTRTXE, musb->intrtxe); | ||
60 | musb->intrrxe = musb->epmask & 0xfffe; | ||
61 | musb_writew(regs, MUSB_INTRRXE, musb->intrrxe); | ||
62 | musb_writeb(regs, MUSB_INTRUSBE, 0xf7); | ||
63 | |||
64 | musb_writeb(regs, MUSB_TESTMODE, 0); | ||
65 | |||
66 | /* put into basic highspeed mode and start session */ | ||
67 | musb_writeb(regs, MUSB_POWER, MUSB_POWER_ISOUPDATE | ||
68 | | MUSB_POWER_HSENAB | ||
69 | /* ENSUSPEND wedges tusb */ | ||
70 | /* | MUSB_POWER_ENSUSPEND */ | ||
71 | ); | ||
72 | |||
73 | musb->is_active = 0; | ||
74 | devctl = musb_readb(regs, MUSB_DEVCTL); | ||
75 | devctl &= ~MUSB_DEVCTL_SESSION; | ||
76 | |||
77 | /* session started after: | ||
78 | * (a) ID-grounded irq, host mode; | ||
79 | * (b) vbus present/connect IRQ, peripheral mode; | ||
80 | * (c) peripheral initiates, using SRP | ||
81 | */ | ||
82 | if (musb->port_mode != MUSB_PORT_MODE_HOST && | ||
83 | (devctl & MUSB_DEVCTL_VBUS) == MUSB_DEVCTL_VBUS) { | ||
84 | musb->is_active = 1; | ||
85 | } else { | ||
86 | devctl |= MUSB_DEVCTL_SESSION; | ||
87 | } | ||
88 | |||
89 | musb_platform_enable(musb); | ||
90 | musb_writeb(regs, MUSB_DEVCTL, devctl); | ||
91 | } | ||
92 | |||
93 | static void musb_port_suspend(struct musb *musb, bool do_suspend) | 47 | static void musb_port_suspend(struct musb *musb, bool do_suspend) |
94 | { | 48 | { |
95 | struct usb_otg *otg = musb->xceiv->otg; | 49 | struct usb_otg *otg = musb->xceiv->otg; |
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c index 80a7104d5ddb..acaee066b99a 100644 --- a/drivers/usb/serial/option.c +++ b/drivers/usb/serial/option.c | |||
@@ -451,6 +451,10 @@ static void option_instat_callback(struct urb *urb); | |||
451 | #define CHANGHONG_VENDOR_ID 0x2077 | 451 | #define CHANGHONG_VENDOR_ID 0x2077 |
452 | #define CHANGHONG_PRODUCT_CH690 0x7001 | 452 | #define CHANGHONG_PRODUCT_CH690 0x7001 |
453 | 453 | ||
454 | /* Inovia */ | ||
455 | #define INOVIA_VENDOR_ID 0x20a6 | ||
456 | #define INOVIA_SEW858 0x1105 | ||
457 | |||
454 | /* some devices interfaces need special handling due to a number of reasons */ | 458 | /* some devices interfaces need special handling due to a number of reasons */ |
455 | enum option_blacklist_reason { | 459 | enum option_blacklist_reason { |
456 | OPTION_BLACKLIST_NONE = 0, | 460 | OPTION_BLACKLIST_NONE = 0, |
@@ -689,6 +693,222 @@ static const struct usb_device_id option_ids[] = { | |||
689 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x7A) }, | 693 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x7A) }, |
690 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x7B) }, | 694 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x7B) }, |
691 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x7C) }, | 695 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x7C) }, |
696 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x01) }, | ||
697 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x02) }, | ||
698 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x03) }, | ||
699 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x04) }, | ||
700 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x05) }, | ||
701 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x06) }, | ||
702 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x0A) }, | ||
703 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x0B) }, | ||
704 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x0D) }, | ||
705 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x0E) }, | ||
706 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x0F) }, | ||
707 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x10) }, | ||
708 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x12) }, | ||
709 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x13) }, | ||
710 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x14) }, | ||
711 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x15) }, | ||
712 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x17) }, | ||
713 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x18) }, | ||
714 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x19) }, | ||
715 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x1A) }, | ||
716 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x1B) }, | ||
717 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x1C) }, | ||
718 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x31) }, | ||
719 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x32) }, | ||
720 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x33) }, | ||
721 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x34) }, | ||
722 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x35) }, | ||
723 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x36) }, | ||
724 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x3A) }, | ||
725 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x3B) }, | ||
726 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x3D) }, | ||
727 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x3E) }, | ||
728 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x3F) }, | ||
729 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x48) }, | ||
730 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x49) }, | ||
731 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x4A) }, | ||
732 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x4B) }, | ||
733 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x4C) }, | ||
734 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x61) }, | ||
735 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x62) }, | ||
736 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x63) }, | ||
737 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x64) }, | ||
738 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x65) }, | ||
739 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x66) }, | ||
740 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x6A) }, | ||
741 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x6B) }, | ||
742 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x6D) }, | ||
743 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x6E) }, | ||
744 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x6F) }, | ||
745 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x78) }, | ||
746 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x79) }, | ||
747 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x7A) }, | ||
748 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x7B) }, | ||
749 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x7C) }, | ||
750 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x01) }, | ||
751 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x02) }, | ||
752 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x03) }, | ||
753 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x04) }, | ||
754 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x05) }, | ||
755 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x06) }, | ||
756 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x0A) }, | ||
757 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x0B) }, | ||
758 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x0D) }, | ||
759 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x0E) }, | ||
760 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x0F) }, | ||
761 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x10) }, | ||
762 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x12) }, | ||
763 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x13) }, | ||
764 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x14) }, | ||
765 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x15) }, | ||
766 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x17) }, | ||
767 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x18) }, | ||
768 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x19) }, | ||
769 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x1A) }, | ||
770 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x1B) }, | ||
771 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x1C) }, | ||
772 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x31) }, | ||
773 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x32) }, | ||
774 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x33) }, | ||
775 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x34) }, | ||
776 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x35) }, | ||
777 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x36) }, | ||
778 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x3A) }, | ||
779 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x3B) }, | ||
780 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x3D) }, | ||
781 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x3E) }, | ||
782 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x3F) }, | ||
783 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x48) }, | ||
784 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x49) }, | ||
785 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x4A) }, | ||
786 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x4B) }, | ||
787 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x4C) }, | ||
788 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x61) }, | ||
789 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x62) }, | ||
790 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x63) }, | ||
791 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x64) }, | ||
792 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x65) }, | ||
793 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x66) }, | ||
794 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x6A) }, | ||
795 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x6B) }, | ||
796 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x6D) }, | ||
797 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x6E) }, | ||
798 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x6F) }, | ||
799 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x78) }, | ||
800 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x79) }, | ||
801 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x7A) }, | ||
802 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x7B) }, | ||
803 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x7C) }, | ||
804 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x01) }, | ||
805 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x02) }, | ||
806 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x03) }, | ||
807 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x04) }, | ||
808 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x05) }, | ||
809 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x06) }, | ||
810 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x0A) }, | ||
811 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x0B) }, | ||
812 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x0D) }, | ||
813 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x0E) }, | ||
814 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x0F) }, | ||
815 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x10) }, | ||
816 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x12) }, | ||
817 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x13) }, | ||
818 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x14) }, | ||
819 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x15) }, | ||
820 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x17) }, | ||
821 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x18) }, | ||
822 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x19) }, | ||
823 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x1A) }, | ||
824 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x1B) }, | ||
825 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x1C) }, | ||
826 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x31) }, | ||
827 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x32) }, | ||
828 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x33) }, | ||
829 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x34) }, | ||
830 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x35) }, | ||
831 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x36) }, | ||
832 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x3A) }, | ||
833 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x3B) }, | ||
834 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x3D) }, | ||
835 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x3E) }, | ||
836 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x3F) }, | ||
837 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x48) }, | ||
838 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x49) }, | ||
839 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x4A) }, | ||
840 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x4B) }, | ||
841 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x4C) }, | ||
842 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x61) }, | ||
843 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x62) }, | ||
844 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x63) }, | ||
845 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x64) }, | ||
846 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x65) }, | ||
847 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x66) }, | ||
848 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x6A) }, | ||
849 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x6B) }, | ||
850 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x6D) }, | ||
851 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x6E) }, | ||
852 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x6F) }, | ||
853 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x78) }, | ||
854 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x79) }, | ||
855 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x7A) }, | ||
856 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x7B) }, | ||
857 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x7C) }, | ||
858 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x01) }, | ||
859 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x02) }, | ||
860 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x03) }, | ||
861 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x04) }, | ||
862 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x05) }, | ||
863 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x06) }, | ||
864 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x0A) }, | ||
865 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x0B) }, | ||
866 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x0D) }, | ||
867 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x0E) }, | ||
868 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x0F) }, | ||
869 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x10) }, | ||
870 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x12) }, | ||
871 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x13) }, | ||
872 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x14) }, | ||
873 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x15) }, | ||
874 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x17) }, | ||
875 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x18) }, | ||
876 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x19) }, | ||
877 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x1A) }, | ||
878 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x1B) }, | ||
879 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x1C) }, | ||
880 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x31) }, | ||
881 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x32) }, | ||
882 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x33) }, | ||
883 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x34) }, | ||
884 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x35) }, | ||
885 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x36) }, | ||
886 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x3A) }, | ||
887 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x3B) }, | ||
888 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x3D) }, | ||
889 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x3E) }, | ||
890 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x3F) }, | ||
891 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x48) }, | ||
892 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x49) }, | ||
893 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x4A) }, | ||
894 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x4B) }, | ||
895 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x4C) }, | ||
896 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x61) }, | ||
897 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x62) }, | ||
898 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x63) }, | ||
899 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x64) }, | ||
900 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x65) }, | ||
901 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x66) }, | ||
902 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x6A) }, | ||
903 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x6B) }, | ||
904 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x6D) }, | ||
905 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x6E) }, | ||
906 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x6F) }, | ||
907 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x78) }, | ||
908 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x79) }, | ||
909 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x7A) }, | ||
910 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x7B) }, | ||
911 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x7C) }, | ||
692 | 912 | ||
693 | 913 | ||
694 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_V640) }, | 914 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_V640) }, |
@@ -1257,7 +1477,9 @@ static const struct usb_device_id option_ids[] = { | |||
1257 | 1477 | ||
1258 | { USB_DEVICE(OLIVETTI_VENDOR_ID, OLIVETTI_PRODUCT_OLICARD100) }, | 1478 | { USB_DEVICE(OLIVETTI_VENDOR_ID, OLIVETTI_PRODUCT_OLICARD100) }, |
1259 | { USB_DEVICE(OLIVETTI_VENDOR_ID, OLIVETTI_PRODUCT_OLICARD145) }, | 1479 | { USB_DEVICE(OLIVETTI_VENDOR_ID, OLIVETTI_PRODUCT_OLICARD145) }, |
1260 | { USB_DEVICE(OLIVETTI_VENDOR_ID, OLIVETTI_PRODUCT_OLICARD200) }, | 1480 | { USB_DEVICE(OLIVETTI_VENDOR_ID, OLIVETTI_PRODUCT_OLICARD200), |
1481 | .driver_info = (kernel_ulong_t)&net_intf6_blacklist | ||
1482 | }, | ||
1261 | { USB_DEVICE(CELOT_VENDOR_ID, CELOT_PRODUCT_CT680M) }, /* CT-650 CDMA 450 1xEVDO modem */ | 1483 | { USB_DEVICE(CELOT_VENDOR_ID, CELOT_PRODUCT_CT680M) }, /* CT-650 CDMA 450 1xEVDO modem */ |
1262 | { USB_DEVICE_AND_INTERFACE_INFO(SAMSUNG_VENDOR_ID, SAMSUNG_PRODUCT_GT_B3730, USB_CLASS_CDC_DATA, 0x00, 0x00) }, /* Samsung GT-B3730 LTE USB modem.*/ | 1484 | { USB_DEVICE_AND_INTERFACE_INFO(SAMSUNG_VENDOR_ID, SAMSUNG_PRODUCT_GT_B3730, USB_CLASS_CDC_DATA, 0x00, 0x00) }, /* Samsung GT-B3730 LTE USB modem.*/ |
1263 | { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CEM600) }, | 1485 | { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CEM600) }, |
@@ -1345,6 +1567,7 @@ static const struct usb_device_id option_ids[] = { | |||
1345 | { USB_DEVICE_AND_INTERFACE_INFO(0x2001, 0x7d03, 0xff, 0x00, 0x00) }, | 1567 | { USB_DEVICE_AND_INTERFACE_INFO(0x2001, 0x7d03, 0xff, 0x00, 0x00) }, |
1346 | { USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x3e01, 0xff, 0xff, 0xff) }, /* D-Link DWM-152/C1 */ | 1568 | { USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x3e01, 0xff, 0xff, 0xff) }, /* D-Link DWM-152/C1 */ |
1347 | { USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x3e02, 0xff, 0xff, 0xff) }, /* D-Link DWM-156/C1 */ | 1569 | { USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x3e02, 0xff, 0xff, 0xff) }, /* D-Link DWM-156/C1 */ |
1570 | { USB_DEVICE(INOVIA_VENDOR_ID, INOVIA_SEW858) }, | ||
1348 | { } /* Terminating entry */ | 1571 | { } /* Terminating entry */ |
1349 | }; | 1572 | }; |
1350 | MODULE_DEVICE_TABLE(usb, option_ids); | 1573 | MODULE_DEVICE_TABLE(usb, option_ids); |
diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c index 760b78560f67..c9a35697ebe9 100644 --- a/drivers/usb/serial/ti_usb_3410_5052.c +++ b/drivers/usb/serial/ti_usb_3410_5052.c | |||
@@ -190,6 +190,7 @@ static struct usb_device_id ti_id_table_combined[] = { | |||
190 | { USB_DEVICE(IBM_VENDOR_ID, IBM_454B_PRODUCT_ID) }, | 190 | { USB_DEVICE(IBM_VENDOR_ID, IBM_454B_PRODUCT_ID) }, |
191 | { USB_DEVICE(IBM_VENDOR_ID, IBM_454C_PRODUCT_ID) }, | 191 | { USB_DEVICE(IBM_VENDOR_ID, IBM_454C_PRODUCT_ID) }, |
192 | { USB_DEVICE(ABBOTT_VENDOR_ID, ABBOTT_PRODUCT_ID) }, | 192 | { USB_DEVICE(ABBOTT_VENDOR_ID, ABBOTT_PRODUCT_ID) }, |
193 | { USB_DEVICE(ABBOTT_VENDOR_ID, ABBOTT_STRIP_PORT_ID) }, | ||
193 | { USB_DEVICE(TI_VENDOR_ID, FRI2_PRODUCT_ID) }, | 194 | { USB_DEVICE(TI_VENDOR_ID, FRI2_PRODUCT_ID) }, |
194 | { } /* terminator */ | 195 | { } /* terminator */ |
195 | }; | 196 | }; |
diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c index 94d75edef77f..18509e6c21ab 100644 --- a/drivers/usb/storage/scsiglue.c +++ b/drivers/usb/storage/scsiglue.c | |||
@@ -211,8 +211,11 @@ static int slave_configure(struct scsi_device *sdev) | |||
211 | /* | 211 | /* |
212 | * Many devices do not respond properly to READ_CAPACITY_16. | 212 | * Many devices do not respond properly to READ_CAPACITY_16. |
213 | * Tell the SCSI layer to try READ_CAPACITY_10 first. | 213 | * Tell the SCSI layer to try READ_CAPACITY_10 first. |
214 | * However some USB 3.0 drive enclosures return capacity | ||
215 | * modulo 2TB. Those must use READ_CAPACITY_16 | ||
214 | */ | 216 | */ |
215 | sdev->try_rc_10_first = 1; | 217 | if (!(us->fflags & US_FL_NEEDS_CAP16)) |
218 | sdev->try_rc_10_first = 1; | ||
216 | 219 | ||
217 | /* assume SPC3 or latter devices support sense size > 18 */ | 220 | /* assume SPC3 or latter devices support sense size > 18 */ |
218 | if (sdev->scsi_level > SCSI_SPC_2) | 221 | if (sdev->scsi_level > SCSI_SPC_2) |
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h index c015f2c16729..de32cfa5bfa6 100644 --- a/drivers/usb/storage/unusual_devs.h +++ b/drivers/usb/storage/unusual_devs.h | |||
@@ -1925,6 +1925,13 @@ UNUSUAL_DEV( 0x1652, 0x6600, 0x0201, 0x0201, | |||
1925 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, | 1925 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, |
1926 | US_FL_IGNORE_RESIDUE ), | 1926 | US_FL_IGNORE_RESIDUE ), |
1927 | 1927 | ||
1928 | /* Reported by Oliver Neukum <oneukum@suse.com> */ | ||
1929 | UNUSUAL_DEV( 0x174c, 0x55aa, 0x0100, 0x0100, | ||
1930 | "ASMedia", | ||
1931 | "AS2105", | ||
1932 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, | ||
1933 | US_FL_NEEDS_CAP16), | ||
1934 | |||
1928 | /* Reported by Jesse Feddema <jdfeddema@gmail.com> */ | 1935 | /* Reported by Jesse Feddema <jdfeddema@gmail.com> */ |
1929 | UNUSUAL_DEV( 0x177f, 0x0400, 0x0000, 0x0000, | 1936 | UNUSUAL_DEV( 0x177f, 0x0400, 0x0000, 0x0000, |
1930 | "Yarvik", | 1937 | "Yarvik", |
diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c index a9807dea3887..4fb7a8f83c8a 100644 --- a/drivers/vfio/vfio_iommu_type1.c +++ b/drivers/vfio/vfio_iommu_type1.c | |||
@@ -545,6 +545,8 @@ static int vfio_dma_do_map(struct vfio_iommu *iommu, | |||
545 | long npage; | 545 | long npage; |
546 | int ret = 0, prot = 0; | 546 | int ret = 0, prot = 0; |
547 | uint64_t mask; | 547 | uint64_t mask; |
548 | struct vfio_dma *dma = NULL; | ||
549 | unsigned long pfn; | ||
548 | 550 | ||
549 | end = map->iova + map->size; | 551 | end = map->iova + map->size; |
550 | 552 | ||
@@ -587,8 +589,6 @@ static int vfio_dma_do_map(struct vfio_iommu *iommu, | |||
587 | } | 589 | } |
588 | 590 | ||
589 | for (iova = map->iova; iova < end; iova += size, vaddr += size) { | 591 | for (iova = map->iova; iova < end; iova += size, vaddr += size) { |
590 | struct vfio_dma *dma = NULL; | ||
591 | unsigned long pfn; | ||
592 | long i; | 592 | long i; |
593 | 593 | ||
594 | /* Pin a contiguous chunk of memory */ | 594 | /* Pin a contiguous chunk of memory */ |
@@ -597,16 +597,15 @@ static int vfio_dma_do_map(struct vfio_iommu *iommu, | |||
597 | if (npage <= 0) { | 597 | if (npage <= 0) { |
598 | WARN_ON(!npage); | 598 | WARN_ON(!npage); |
599 | ret = (int)npage; | 599 | ret = (int)npage; |
600 | break; | 600 | goto out; |
601 | } | 601 | } |
602 | 602 | ||
603 | /* Verify pages are not already mapped */ | 603 | /* Verify pages are not already mapped */ |
604 | for (i = 0; i < npage; i++) { | 604 | for (i = 0; i < npage; i++) { |
605 | if (iommu_iova_to_phys(iommu->domain, | 605 | if (iommu_iova_to_phys(iommu->domain, |
606 | iova + (i << PAGE_SHIFT))) { | 606 | iova + (i << PAGE_SHIFT))) { |
607 | vfio_unpin_pages(pfn, npage, prot, true); | ||
608 | ret = -EBUSY; | 607 | ret = -EBUSY; |
609 | break; | 608 | goto out_unpin; |
610 | } | 609 | } |
611 | } | 610 | } |
612 | 611 | ||
@@ -616,8 +615,7 @@ static int vfio_dma_do_map(struct vfio_iommu *iommu, | |||
616 | if (ret) { | 615 | if (ret) { |
617 | if (ret != -EBUSY || | 616 | if (ret != -EBUSY || |
618 | map_try_harder(iommu, iova, pfn, npage, prot)) { | 617 | map_try_harder(iommu, iova, pfn, npage, prot)) { |
619 | vfio_unpin_pages(pfn, npage, prot, true); | 618 | goto out_unpin; |
620 | break; | ||
621 | } | 619 | } |
622 | } | 620 | } |
623 | 621 | ||
@@ -672,9 +670,8 @@ static int vfio_dma_do_map(struct vfio_iommu *iommu, | |||
672 | dma = kzalloc(sizeof(*dma), GFP_KERNEL); | 670 | dma = kzalloc(sizeof(*dma), GFP_KERNEL); |
673 | if (!dma) { | 671 | if (!dma) { |
674 | iommu_unmap(iommu->domain, iova, size); | 672 | iommu_unmap(iommu->domain, iova, size); |
675 | vfio_unpin_pages(pfn, npage, prot, true); | ||
676 | ret = -ENOMEM; | 673 | ret = -ENOMEM; |
677 | break; | 674 | goto out_unpin; |
678 | } | 675 | } |
679 | 676 | ||
680 | dma->size = size; | 677 | dma->size = size; |
@@ -685,16 +682,21 @@ static int vfio_dma_do_map(struct vfio_iommu *iommu, | |||
685 | } | 682 | } |
686 | } | 683 | } |
687 | 684 | ||
688 | if (ret) { | 685 | WARN_ON(ret); |
689 | struct vfio_dma *tmp; | 686 | mutex_unlock(&iommu->lock); |
690 | iova = map->iova; | 687 | return ret; |
691 | size = map->size; | 688 | |
692 | while ((tmp = vfio_find_dma(iommu, iova, size))) { | 689 | out_unpin: |
693 | int r = vfio_remove_dma_overlap(iommu, iova, | 690 | vfio_unpin_pages(pfn, npage, prot, true); |
694 | &size, tmp); | 691 | |
695 | if (WARN_ON(r || !size)) | 692 | out: |
696 | break; | 693 | iova = map->iova; |
697 | } | 694 | size = map->size; |
695 | while ((dma = vfio_find_dma(iommu, iova, size))) { | ||
696 | int r = vfio_remove_dma_overlap(iommu, iova, | ||
697 | &size, dma); | ||
698 | if (WARN_ON(r || !size)) | ||
699 | break; | ||
698 | } | 700 | } |
699 | 701 | ||
700 | mutex_unlock(&iommu->lock); | 702 | mutex_unlock(&iommu->lock); |
diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c index c7c64f18773d..fa932c2f7d97 100644 --- a/drivers/w1/w1.c +++ b/drivers/w1/w1.c | |||
@@ -613,6 +613,9 @@ static int w1_bus_notify(struct notifier_block *nb, unsigned long action, | |||
613 | sl = dev_to_w1_slave(dev); | 613 | sl = dev_to_w1_slave(dev); |
614 | fops = sl->family->fops; | 614 | fops = sl->family->fops; |
615 | 615 | ||
616 | if (!fops) | ||
617 | return 0; | ||
618 | |||
616 | switch (action) { | 619 | switch (action) { |
617 | case BUS_NOTIFY_ADD_DEVICE: | 620 | case BUS_NOTIFY_ADD_DEVICE: |
618 | /* if the family driver needs to initialize something... */ | 621 | /* if the family driver needs to initialize something... */ |
@@ -713,7 +716,10 @@ static int w1_attach_slave_device(struct w1_master *dev, struct w1_reg_num *rn) | |||
713 | atomic_set(&sl->refcnt, 0); | 716 | atomic_set(&sl->refcnt, 0); |
714 | init_completion(&sl->released); | 717 | init_completion(&sl->released); |
715 | 718 | ||
719 | /* slave modules need to be loaded in a context with unlocked mutex */ | ||
720 | mutex_unlock(&dev->mutex); | ||
716 | request_module("w1-family-0x%0x", rn->family); | 721 | request_module("w1-family-0x%0x", rn->family); |
722 | mutex_lock(&dev->mutex); | ||
717 | 723 | ||
718 | spin_lock(&w1_flock); | 724 | spin_lock(&w1_flock); |
719 | f = w1_family_registered(rn->family); | 725 | f = w1_family_registered(rn->family); |
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index b0ef7b07b1b3..51e3afa78354 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
@@ -6437,6 +6437,7 @@ noinline int can_nocow_extent(struct inode *inode, u64 offset, u64 *len, | |||
6437 | 6437 | ||
6438 | if (btrfs_extent_readonly(root, disk_bytenr)) | 6438 | if (btrfs_extent_readonly(root, disk_bytenr)) |
6439 | goto out; | 6439 | goto out; |
6440 | btrfs_release_path(path); | ||
6440 | 6441 | ||
6441 | /* | 6442 | /* |
6442 | * look for other files referencing this extent, if we | 6443 | * look for other files referencing this extent, if we |
diff --git a/fs/buffer.c b/fs/buffer.c index 4d7433534f5c..6024877335ca 100644 --- a/fs/buffer.c +++ b/fs/buffer.c | |||
@@ -1005,9 +1005,19 @@ grow_dev_page(struct block_device *bdev, sector_t block, | |||
1005 | struct buffer_head *bh; | 1005 | struct buffer_head *bh; |
1006 | sector_t end_block; | 1006 | sector_t end_block; |
1007 | int ret = 0; /* Will call free_more_memory() */ | 1007 | int ret = 0; /* Will call free_more_memory() */ |
1008 | gfp_t gfp_mask; | ||
1008 | 1009 | ||
1009 | page = find_or_create_page(inode->i_mapping, index, | 1010 | gfp_mask = mapping_gfp_mask(inode->i_mapping) & ~__GFP_FS; |
1010 | (mapping_gfp_mask(inode->i_mapping) & ~__GFP_FS)|__GFP_MOVABLE); | 1011 | gfp_mask |= __GFP_MOVABLE; |
1012 | /* | ||
1013 | * XXX: __getblk_slow() can not really deal with failure and | ||
1014 | * will endlessly loop on improvised global reclaim. Prefer | ||
1015 | * looping in the allocator rather than here, at least that | ||
1016 | * code knows what it's doing. | ||
1017 | */ | ||
1018 | gfp_mask |= __GFP_NOFAIL; | ||
1019 | |||
1020 | page = find_or_create_page(inode->i_mapping, index, gfp_mask); | ||
1011 | if (!page) | 1021 | if (!page) |
1012 | return ret; | 1022 | return ret; |
1013 | 1023 | ||
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c index a16b4e58bcc6..77fc5e181077 100644 --- a/fs/cifs/cifsfs.c +++ b/fs/cifs/cifsfs.c | |||
@@ -120,14 +120,16 @@ cifs_read_super(struct super_block *sb) | |||
120 | { | 120 | { |
121 | struct inode *inode; | 121 | struct inode *inode; |
122 | struct cifs_sb_info *cifs_sb; | 122 | struct cifs_sb_info *cifs_sb; |
123 | struct cifs_tcon *tcon; | ||
123 | int rc = 0; | 124 | int rc = 0; |
124 | 125 | ||
125 | cifs_sb = CIFS_SB(sb); | 126 | cifs_sb = CIFS_SB(sb); |
127 | tcon = cifs_sb_master_tcon(cifs_sb); | ||
126 | 128 | ||
127 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIXACL) | 129 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIXACL) |
128 | sb->s_flags |= MS_POSIXACL; | 130 | sb->s_flags |= MS_POSIXACL; |
129 | 131 | ||
130 | if (cifs_sb_master_tcon(cifs_sb)->ses->capabilities & CAP_LARGE_FILES) | 132 | if (tcon->ses->capabilities & tcon->ses->server->vals->cap_large_files) |
131 | sb->s_maxbytes = MAX_LFS_FILESIZE; | 133 | sb->s_maxbytes = MAX_LFS_FILESIZE; |
132 | else | 134 | else |
133 | sb->s_maxbytes = MAX_NON_LFS; | 135 | sb->s_maxbytes = MAX_NON_LFS; |
@@ -147,7 +149,7 @@ cifs_read_super(struct super_block *sb) | |||
147 | goto out_no_root; | 149 | goto out_no_root; |
148 | } | 150 | } |
149 | 151 | ||
150 | if (cifs_sb_master_tcon(cifs_sb)->nocase) | 152 | if (tcon->nocase) |
151 | sb->s_d_op = &cifs_ci_dentry_ops; | 153 | sb->s_d_op = &cifs_ci_dentry_ops; |
152 | else | 154 | else |
153 | sb->s_d_op = &cifs_dentry_ops; | 155 | sb->s_d_op = &cifs_dentry_ops; |
diff --git a/fs/cifs/cifspdu.h b/fs/cifs/cifspdu.h index a630475e421c..08f9dfb1a894 100644 --- a/fs/cifs/cifspdu.h +++ b/fs/cifs/cifspdu.h | |||
@@ -1491,15 +1491,30 @@ struct file_notify_information { | |||
1491 | __u8 FileName[0]; | 1491 | __u8 FileName[0]; |
1492 | } __attribute__((packed)); | 1492 | } __attribute__((packed)); |
1493 | 1493 | ||
1494 | struct reparse_data { | 1494 | /* For IO_REPARSE_TAG_SYMLINK */ |
1495 | __u32 ReparseTag; | 1495 | struct reparse_symlink_data { |
1496 | __u16 ReparseDataLength; | 1496 | __le32 ReparseTag; |
1497 | __le16 ReparseDataLength; | ||
1497 | __u16 Reserved; | 1498 | __u16 Reserved; |
1498 | __u16 SubstituteNameOffset; | 1499 | __le16 SubstituteNameOffset; |
1499 | __u16 SubstituteNameLength; | 1500 | __le16 SubstituteNameLength; |
1500 | __u16 PrintNameOffset; | 1501 | __le16 PrintNameOffset; |
1501 | __u16 PrintNameLength; | 1502 | __le16 PrintNameLength; |
1502 | __u32 Flags; | 1503 | __le32 Flags; |
1504 | char PathBuffer[0]; | ||
1505 | } __attribute__((packed)); | ||
1506 | |||
1507 | /* For IO_REPARSE_TAG_NFS */ | ||
1508 | #define NFS_SPECFILE_LNK 0x00000000014B4E4C | ||
1509 | #define NFS_SPECFILE_CHR 0x0000000000524843 | ||
1510 | #define NFS_SPECFILE_BLK 0x00000000004B4C42 | ||
1511 | #define NFS_SPECFILE_FIFO 0x000000004F464946 | ||
1512 | #define NFS_SPECFILE_SOCK 0x000000004B434F53 | ||
1513 | struct reparse_posix_data { | ||
1514 | __le32 ReparseTag; | ||
1515 | __le16 ReparseDataLength; | ||
1516 | __u16 Reserved; | ||
1517 | __le64 InodeType; /* LNK, FIFO, CHR etc. */ | ||
1503 | char PathBuffer[0]; | 1518 | char PathBuffer[0]; |
1504 | } __attribute__((packed)); | 1519 | } __attribute__((packed)); |
1505 | 1520 | ||
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c index 4baf35949b51..ccd31ab815d4 100644 --- a/fs/cifs/cifssmb.c +++ b/fs/cifs/cifssmb.c | |||
@@ -3088,7 +3088,8 @@ CIFSSMBQuerySymLink(const unsigned int xid, struct cifs_tcon *tcon, | |||
3088 | bool is_unicode; | 3088 | bool is_unicode; |
3089 | unsigned int sub_len; | 3089 | unsigned int sub_len; |
3090 | char *sub_start; | 3090 | char *sub_start; |
3091 | struct reparse_data *reparse_buf; | 3091 | struct reparse_symlink_data *reparse_buf; |
3092 | struct reparse_posix_data *posix_buf; | ||
3092 | __u32 data_offset, data_count; | 3093 | __u32 data_offset, data_count; |
3093 | char *end_of_smb; | 3094 | char *end_of_smb; |
3094 | 3095 | ||
@@ -3137,20 +3138,47 @@ CIFSSMBQuerySymLink(const unsigned int xid, struct cifs_tcon *tcon, | |||
3137 | goto qreparse_out; | 3138 | goto qreparse_out; |
3138 | } | 3139 | } |
3139 | end_of_smb = 2 + get_bcc(&pSMBr->hdr) + (char *)&pSMBr->ByteCount; | 3140 | end_of_smb = 2 + get_bcc(&pSMBr->hdr) + (char *)&pSMBr->ByteCount; |
3140 | reparse_buf = (struct reparse_data *) | 3141 | reparse_buf = (struct reparse_symlink_data *) |
3141 | ((char *)&pSMBr->hdr.Protocol + data_offset); | 3142 | ((char *)&pSMBr->hdr.Protocol + data_offset); |
3142 | if ((char *)reparse_buf >= end_of_smb) { | 3143 | if ((char *)reparse_buf >= end_of_smb) { |
3143 | rc = -EIO; | 3144 | rc = -EIO; |
3144 | goto qreparse_out; | 3145 | goto qreparse_out; |
3145 | } | 3146 | } |
3146 | if ((reparse_buf->PathBuffer + reparse_buf->PrintNameOffset + | 3147 | if (reparse_buf->ReparseTag == cpu_to_le32(IO_REPARSE_TAG_NFS)) { |
3147 | reparse_buf->PrintNameLength) > end_of_smb) { | 3148 | cifs_dbg(FYI, "NFS style reparse tag\n"); |
3149 | posix_buf = (struct reparse_posix_data *)reparse_buf; | ||
3150 | |||
3151 | if (posix_buf->InodeType != cpu_to_le64(NFS_SPECFILE_LNK)) { | ||
3152 | cifs_dbg(FYI, "unsupported file type 0x%llx\n", | ||
3153 | le64_to_cpu(posix_buf->InodeType)); | ||
3154 | rc = -EOPNOTSUPP; | ||
3155 | goto qreparse_out; | ||
3156 | } | ||
3157 | is_unicode = true; | ||
3158 | sub_len = le16_to_cpu(reparse_buf->ReparseDataLength); | ||
3159 | if (posix_buf->PathBuffer + sub_len > end_of_smb) { | ||
3160 | cifs_dbg(FYI, "reparse buf beyond SMB\n"); | ||
3161 | rc = -EIO; | ||
3162 | goto qreparse_out; | ||
3163 | } | ||
3164 | *symlinkinfo = cifs_strndup_from_utf16(posix_buf->PathBuffer, | ||
3165 | sub_len, is_unicode, nls_codepage); | ||
3166 | goto qreparse_out; | ||
3167 | } else if (reparse_buf->ReparseTag != | ||
3168 | cpu_to_le32(IO_REPARSE_TAG_SYMLINK)) { | ||
3169 | rc = -EOPNOTSUPP; | ||
3170 | goto qreparse_out; | ||
3171 | } | ||
3172 | |||
3173 | /* Reparse tag is NTFS symlink */ | ||
3174 | sub_start = le16_to_cpu(reparse_buf->SubstituteNameOffset) + | ||
3175 | reparse_buf->PathBuffer; | ||
3176 | sub_len = le16_to_cpu(reparse_buf->SubstituteNameLength); | ||
3177 | if (sub_start + sub_len > end_of_smb) { | ||
3148 | cifs_dbg(FYI, "reparse buf beyond SMB\n"); | 3178 | cifs_dbg(FYI, "reparse buf beyond SMB\n"); |
3149 | rc = -EIO; | 3179 | rc = -EIO; |
3150 | goto qreparse_out; | 3180 | goto qreparse_out; |
3151 | } | 3181 | } |
3152 | sub_start = reparse_buf->SubstituteNameOffset + reparse_buf->PathBuffer; | ||
3153 | sub_len = reparse_buf->SubstituteNameLength; | ||
3154 | if (pSMBr->hdr.Flags2 & SMBFLG2_UNICODE) | 3182 | if (pSMBr->hdr.Flags2 & SMBFLG2_UNICODE) |
3155 | is_unicode = true; | 3183 | is_unicode = true; |
3156 | else | 3184 | else |
diff --git a/fs/cifs/netmisc.c b/fs/cifs/netmisc.c index af847e1cf1c1..651a5279607b 100644 --- a/fs/cifs/netmisc.c +++ b/fs/cifs/netmisc.c | |||
@@ -780,7 +780,9 @@ static const struct { | |||
780 | ERRDOS, ERRnoaccess, 0xc0000290}, { | 780 | ERRDOS, ERRnoaccess, 0xc0000290}, { |
781 | ERRDOS, ERRbadfunc, 0xc000029c}, { | 781 | ERRDOS, ERRbadfunc, 0xc000029c}, { |
782 | ERRDOS, ERRsymlink, NT_STATUS_STOPPED_ON_SYMLINK}, { | 782 | ERRDOS, ERRsymlink, NT_STATUS_STOPPED_ON_SYMLINK}, { |
783 | ERRDOS, ERRinvlevel, 0x007c0001}, }; | 783 | ERRDOS, ERRinvlevel, 0x007c0001}, { |
784 | 0, 0, 0 } | ||
785 | }; | ||
784 | 786 | ||
785 | /***************************************************************************** | 787 | /***************************************************************************** |
786 | Print an error message from the status code | 788 | Print an error message from the status code |
diff --git a/fs/cifs/sess.c b/fs/cifs/sess.c index 352358de1d7e..e87387dbf39f 100644 --- a/fs/cifs/sess.c +++ b/fs/cifs/sess.c | |||
@@ -500,9 +500,9 @@ select_sectype(struct TCP_Server_Info *server, enum securityEnum requested) | |||
500 | return NTLMv2; | 500 | return NTLMv2; |
501 | if (global_secflags & CIFSSEC_MAY_NTLM) | 501 | if (global_secflags & CIFSSEC_MAY_NTLM) |
502 | return NTLM; | 502 | return NTLM; |
503 | /* Fallthrough */ | ||
504 | default: | 503 | default: |
505 | return Unspecified; | 504 | /* Fallthrough to attempt LANMAN authentication next */ |
505 | break; | ||
506 | } | 506 | } |
507 | case CIFS_NEGFLAVOR_LANMAN: | 507 | case CIFS_NEGFLAVOR_LANMAN: |
508 | switch (requested) { | 508 | switch (requested) { |
diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c index eba0efde66d7..edccb5252462 100644 --- a/fs/cifs/smb2pdu.c +++ b/fs/cifs/smb2pdu.c | |||
@@ -687,6 +687,10 @@ SMB2_logoff(const unsigned int xid, struct cifs_ses *ses) | |||
687 | else | 687 | else |
688 | return -EIO; | 688 | return -EIO; |
689 | 689 | ||
690 | /* no need to send SMB logoff if uid already closed due to reconnect */ | ||
691 | if (ses->need_reconnect) | ||
692 | goto smb2_session_already_dead; | ||
693 | |||
690 | rc = small_smb2_init(SMB2_LOGOFF, NULL, (void **) &req); | 694 | rc = small_smb2_init(SMB2_LOGOFF, NULL, (void **) &req); |
691 | if (rc) | 695 | if (rc) |
692 | return rc; | 696 | return rc; |
@@ -701,6 +705,8 @@ SMB2_logoff(const unsigned int xid, struct cifs_ses *ses) | |||
701 | * No tcon so can't do | 705 | * No tcon so can't do |
702 | * cifs_stats_inc(&tcon->stats.smb2_stats.smb2_com_fail[SMB2...]); | 706 | * cifs_stats_inc(&tcon->stats.smb2_stats.smb2_com_fail[SMB2...]); |
703 | */ | 707 | */ |
708 | |||
709 | smb2_session_already_dead: | ||
704 | return rc; | 710 | return rc; |
705 | } | 711 | } |
706 | 712 | ||
diff --git a/fs/cifs/smbfsctl.h b/fs/cifs/smbfsctl.h index d952ee48f4dc..a4b2391fe66e 100644 --- a/fs/cifs/smbfsctl.h +++ b/fs/cifs/smbfsctl.h | |||
@@ -97,9 +97,23 @@ | |||
97 | #define FSCTL_QUERY_NETWORK_INTERFACE_INFO 0x001401FC /* BB add struct */ | 97 | #define FSCTL_QUERY_NETWORK_INTERFACE_INFO 0x001401FC /* BB add struct */ |
98 | #define FSCTL_SRV_READ_HASH 0x001441BB /* BB add struct */ | 98 | #define FSCTL_SRV_READ_HASH 0x001441BB /* BB add struct */ |
99 | 99 | ||
100 | /* See FSCC 2.1.2.5 */ | ||
100 | #define IO_REPARSE_TAG_MOUNT_POINT 0xA0000003 | 101 | #define IO_REPARSE_TAG_MOUNT_POINT 0xA0000003 |
101 | #define IO_REPARSE_TAG_HSM 0xC0000004 | 102 | #define IO_REPARSE_TAG_HSM 0xC0000004 |
102 | #define IO_REPARSE_TAG_SIS 0x80000007 | 103 | #define IO_REPARSE_TAG_SIS 0x80000007 |
104 | #define IO_REPARSE_TAG_HSM2 0x80000006 | ||
105 | #define IO_REPARSE_TAG_DRIVER_EXTENDER 0x80000005 | ||
106 | /* Used by the DFS filter. See MS-DFSC */ | ||
107 | #define IO_REPARSE_TAG_DFS 0x8000000A | ||
108 | /* Used by the DFS filter See MS-DFSC */ | ||
109 | #define IO_REPARSE_TAG_DFSR 0x80000012 | ||
110 | #define IO_REPARSE_TAG_FILTER_MANAGER 0x8000000B | ||
111 | /* See section MS-FSCC 2.1.2.4 */ | ||
112 | #define IO_REPARSE_TAG_SYMLINK 0xA000000C | ||
113 | #define IO_REPARSE_TAG_DEDUP 0x80000013 | ||
114 | #define IO_REPARSE_APPXSTREAM 0xC0000014 | ||
115 | /* NFS symlinks, Win 8/SMB3 and later */ | ||
116 | #define IO_REPARSE_TAG_NFS 0x80000014 | ||
103 | 117 | ||
104 | /* fsctl flags */ | 118 | /* fsctl flags */ |
105 | /* If Flags is set to this value, the request is an FSCTL not ioctl request */ | 119 | /* If Flags is set to this value, the request is an FSCTL not ioctl request */ |
diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c index 6fdcb1b4a106..800b938e4061 100644 --- a/fs/cifs/transport.c +++ b/fs/cifs/transport.c | |||
@@ -410,8 +410,13 @@ static int | |||
410 | wait_for_free_request(struct TCP_Server_Info *server, const int timeout, | 410 | wait_for_free_request(struct TCP_Server_Info *server, const int timeout, |
411 | const int optype) | 411 | const int optype) |
412 | { | 412 | { |
413 | return wait_for_free_credits(server, timeout, | 413 | int *val; |
414 | server->ops->get_credits_field(server, optype)); | 414 | |
415 | val = server->ops->get_credits_field(server, optype); | ||
416 | /* Since an echo is already inflight, no need to wait to send another */ | ||
417 | if (*val <= 0 && optype == CIFS_ECHO_OP) | ||
418 | return -EAGAIN; | ||
419 | return wait_for_free_credits(server, timeout, val); | ||
415 | } | 420 | } |
416 | 421 | ||
417 | static int allocate_mid(struct cifs_ses *ses, struct smb_hdr *in_buf, | 422 | static int allocate_mid(struct cifs_ses *ses, struct smb_hdr *in_buf, |
diff --git a/fs/ext3/namei.c b/fs/ext3/namei.c index 1194b1f0f839..f8cde46de9cd 100644 --- a/fs/ext3/namei.c +++ b/fs/ext3/namei.c | |||
@@ -1783,7 +1783,7 @@ retry: | |||
1783 | d_tmpfile(dentry, inode); | 1783 | d_tmpfile(dentry, inode); |
1784 | err = ext3_orphan_add(handle, inode); | 1784 | err = ext3_orphan_add(handle, inode); |
1785 | if (err) | 1785 | if (err) |
1786 | goto err_drop_inode; | 1786 | goto err_unlock_inode; |
1787 | mark_inode_dirty(inode); | 1787 | mark_inode_dirty(inode); |
1788 | unlock_new_inode(inode); | 1788 | unlock_new_inode(inode); |
1789 | } | 1789 | } |
@@ -1791,10 +1791,9 @@ retry: | |||
1791 | if (err == -ENOSPC && ext3_should_retry_alloc(dir->i_sb, &retries)) | 1791 | if (err == -ENOSPC && ext3_should_retry_alloc(dir->i_sb, &retries)) |
1792 | goto retry; | 1792 | goto retry; |
1793 | return err; | 1793 | return err; |
1794 | err_drop_inode: | 1794 | err_unlock_inode: |
1795 | ext3_journal_stop(handle); | 1795 | ext3_journal_stop(handle); |
1796 | unlock_new_inode(inode); | 1796 | unlock_new_inode(inode); |
1797 | iput(inode); | ||
1798 | return err; | 1797 | return err; |
1799 | } | 1798 | } |
1800 | 1799 | ||
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c index 1bec5a5c1e45..5a0408d7b114 100644 --- a/fs/ext4/namei.c +++ b/fs/ext4/namei.c | |||
@@ -2319,7 +2319,7 @@ retry: | |||
2319 | d_tmpfile(dentry, inode); | 2319 | d_tmpfile(dentry, inode); |
2320 | err = ext4_orphan_add(handle, inode); | 2320 | err = ext4_orphan_add(handle, inode); |
2321 | if (err) | 2321 | if (err) |
2322 | goto err_drop_inode; | 2322 | goto err_unlock_inode; |
2323 | mark_inode_dirty(inode); | 2323 | mark_inode_dirty(inode); |
2324 | unlock_new_inode(inode); | 2324 | unlock_new_inode(inode); |
2325 | } | 2325 | } |
@@ -2328,10 +2328,9 @@ retry: | |||
2328 | if (err == -ENOSPC && ext4_should_retry_alloc(dir->i_sb, &retries)) | 2328 | if (err == -ENOSPC && ext4_should_retry_alloc(dir->i_sb, &retries)) |
2329 | goto retry; | 2329 | goto retry; |
2330 | return err; | 2330 | return err; |
2331 | err_drop_inode: | 2331 | err_unlock_inode: |
2332 | ext4_journal_stop(handle); | 2332 | ext4_journal_stop(handle); |
2333 | unlock_new_inode(inode); | 2333 | unlock_new_inode(inode); |
2334 | iput(inode); | ||
2335 | return err; | 2334 | return err; |
2336 | } | 2335 | } |
2337 | 2336 | ||
diff --git a/fs/proc/inode.c b/fs/proc/inode.c index 9f8ef9b7674d..8eaa1ba793fc 100644 --- a/fs/proc/inode.c +++ b/fs/proc/inode.c | |||
@@ -288,10 +288,14 @@ static int proc_reg_mmap(struct file *file, struct vm_area_struct *vma) | |||
288 | static unsigned long proc_reg_get_unmapped_area(struct file *file, unsigned long orig_addr, unsigned long len, unsigned long pgoff, unsigned long flags) | 288 | static unsigned long proc_reg_get_unmapped_area(struct file *file, unsigned long orig_addr, unsigned long len, unsigned long pgoff, unsigned long flags) |
289 | { | 289 | { |
290 | struct proc_dir_entry *pde = PDE(file_inode(file)); | 290 | struct proc_dir_entry *pde = PDE(file_inode(file)); |
291 | int rv = -EIO; | 291 | unsigned long rv = -EIO; |
292 | unsigned long (*get_unmapped_area)(struct file *, unsigned long, unsigned long, unsigned long, unsigned long); | 292 | unsigned long (*get_unmapped_area)(struct file *, unsigned long, unsigned long, unsigned long, unsigned long) = NULL; |
293 | if (use_pde(pde)) { | 293 | if (use_pde(pde)) { |
294 | get_unmapped_area = pde->proc_fops->get_unmapped_area; | 294 | #ifdef CONFIG_MMU |
295 | get_unmapped_area = current->mm->get_unmapped_area; | ||
296 | #endif | ||
297 | if (pde->proc_fops->get_unmapped_area) | ||
298 | get_unmapped_area = pde->proc_fops->get_unmapped_area; | ||
295 | if (get_unmapped_area) | 299 | if (get_unmapped_area) |
296 | rv = get_unmapped_area(file, orig_addr, len, pgoff, flags); | 300 | rv = get_unmapped_area(file, orig_addr, len, pgoff, flags); |
297 | unuse_pde(pde); | 301 | unuse_pde(pde); |
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 7366e9d63cee..390bdab01c3c 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c | |||
@@ -941,6 +941,8 @@ static void pte_to_pagemap_entry(pagemap_entry_t *pme, struct pagemapread *pm, | |||
941 | frame = pte_pfn(pte); | 941 | frame = pte_pfn(pte); |
942 | flags = PM_PRESENT; | 942 | flags = PM_PRESENT; |
943 | page = vm_normal_page(vma, addr, pte); | 943 | page = vm_normal_page(vma, addr, pte); |
944 | if (pte_soft_dirty(pte)) | ||
945 | flags2 |= __PM_SOFT_DIRTY; | ||
944 | } else if (is_swap_pte(pte)) { | 946 | } else if (is_swap_pte(pte)) { |
945 | swp_entry_t entry; | 947 | swp_entry_t entry; |
946 | if (pte_swp_soft_dirty(pte)) | 948 | if (pte_swp_soft_dirty(pte)) |
@@ -960,7 +962,7 @@ static void pte_to_pagemap_entry(pagemap_entry_t *pme, struct pagemapread *pm, | |||
960 | 962 | ||
961 | if (page && !PageAnon(page)) | 963 | if (page && !PageAnon(page)) |
962 | flags |= PM_FILE; | 964 | flags |= PM_FILE; |
963 | if ((vma->vm_flags & VM_SOFTDIRTY) || pte_soft_dirty(pte)) | 965 | if ((vma->vm_flags & VM_SOFTDIRTY)) |
964 | flags2 |= __PM_SOFT_DIRTY; | 966 | flags2 |= __PM_SOFT_DIRTY; |
965 | 967 | ||
966 | *pme = make_pme(PM_PFRAME(frame) | PM_STATUS2(pm->v2, flags2) | flags); | 968 | *pme = make_pme(PM_PFRAME(frame) | PM_STATUS2(pm->v2, flags2) | flags); |
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h index 02e113bb8b7d..d9019821aa60 100644 --- a/include/acpi/acpi_bus.h +++ b/include/acpi/acpi_bus.h | |||
@@ -311,7 +311,6 @@ struct acpi_device { | |||
311 | unsigned int physical_node_count; | 311 | unsigned int physical_node_count; |
312 | struct list_head physical_node_list; | 312 | struct list_head physical_node_list; |
313 | struct mutex physical_node_lock; | 313 | struct mutex physical_node_lock; |
314 | struct list_head power_dependent; | ||
315 | void (*remove)(struct acpi_device *); | 314 | void (*remove)(struct acpi_device *); |
316 | }; | 315 | }; |
317 | 316 | ||
@@ -456,8 +455,6 @@ acpi_status acpi_add_pm_notifier(struct acpi_device *adev, | |||
456 | acpi_status acpi_remove_pm_notifier(struct acpi_device *adev, | 455 | acpi_status acpi_remove_pm_notifier(struct acpi_device *adev, |
457 | acpi_notify_handler handler); | 456 | acpi_notify_handler handler); |
458 | int acpi_pm_device_sleep_state(struct device *, int *, int); | 457 | int acpi_pm_device_sleep_state(struct device *, int *, int); |
459 | void acpi_dev_pm_add_dependent(acpi_handle handle, struct device *depdev); | ||
460 | void acpi_dev_pm_remove_dependent(acpi_handle handle, struct device *depdev); | ||
461 | #else | 458 | #else |
462 | static inline acpi_status acpi_add_pm_notifier(struct acpi_device *adev, | 459 | static inline acpi_status acpi_add_pm_notifier(struct acpi_device *adev, |
463 | acpi_notify_handler handler, | 460 | acpi_notify_handler handler, |
@@ -478,10 +475,6 @@ static inline int acpi_pm_device_sleep_state(struct device *d, int *p, int m) | |||
478 | return (m >= ACPI_STATE_D0 && m <= ACPI_STATE_D3_COLD) ? | 475 | return (m >= ACPI_STATE_D0 && m <= ACPI_STATE_D3_COLD) ? |
479 | m : ACPI_STATE_D0; | 476 | m : ACPI_STATE_D0; |
480 | } | 477 | } |
481 | static inline void acpi_dev_pm_add_dependent(acpi_handle handle, | ||
482 | struct device *depdev) {} | ||
483 | static inline void acpi_dev_pm_remove_dependent(acpi_handle handle, | ||
484 | struct device *depdev) {} | ||
485 | #endif | 478 | #endif |
486 | 479 | ||
487 | #ifdef CONFIG_PM_RUNTIME | 480 | #ifdef CONFIG_PM_RUNTIME |
diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index ecc82b37c4cc..b3e7a667e03c 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h | |||
@@ -137,47 +137,24 @@ extern void mem_cgroup_print_oom_info(struct mem_cgroup *memcg, | |||
137 | extern void mem_cgroup_replace_page_cache(struct page *oldpage, | 137 | extern void mem_cgroup_replace_page_cache(struct page *oldpage, |
138 | struct page *newpage); | 138 | struct page *newpage); |
139 | 139 | ||
140 | /** | 140 | static inline void mem_cgroup_oom_enable(void) |
141 | * mem_cgroup_toggle_oom - toggle the memcg OOM killer for the current task | ||
142 | * @new: true to enable, false to disable | ||
143 | * | ||
144 | * Toggle whether a failed memcg charge should invoke the OOM killer | ||
145 | * or just return -ENOMEM. Returns the previous toggle state. | ||
146 | * | ||
147 | * NOTE: Any path that enables the OOM killer before charging must | ||
148 | * call mem_cgroup_oom_synchronize() afterward to finalize the | ||
149 | * OOM handling and clean up. | ||
150 | */ | ||
151 | static inline bool mem_cgroup_toggle_oom(bool new) | ||
152 | { | 141 | { |
153 | bool old; | 142 | WARN_ON(current->memcg_oom.may_oom); |
154 | 143 | current->memcg_oom.may_oom = 1; | |
155 | old = current->memcg_oom.may_oom; | ||
156 | current->memcg_oom.may_oom = new; | ||
157 | |||
158 | return old; | ||
159 | } | 144 | } |
160 | 145 | ||
161 | static inline void mem_cgroup_enable_oom(void) | 146 | static inline void mem_cgroup_oom_disable(void) |
162 | { | 147 | { |
163 | bool old = mem_cgroup_toggle_oom(true); | 148 | WARN_ON(!current->memcg_oom.may_oom); |
164 | 149 | current->memcg_oom.may_oom = 0; | |
165 | WARN_ON(old == true); | ||
166 | } | ||
167 | |||
168 | static inline void mem_cgroup_disable_oom(void) | ||
169 | { | ||
170 | bool old = mem_cgroup_toggle_oom(false); | ||
171 | |||
172 | WARN_ON(old == false); | ||
173 | } | 150 | } |
174 | 151 | ||
175 | static inline bool task_in_memcg_oom(struct task_struct *p) | 152 | static inline bool task_in_memcg_oom(struct task_struct *p) |
176 | { | 153 | { |
177 | return p->memcg_oom.in_memcg_oom; | 154 | return p->memcg_oom.memcg; |
178 | } | 155 | } |
179 | 156 | ||
180 | bool mem_cgroup_oom_synchronize(void); | 157 | bool mem_cgroup_oom_synchronize(bool wait); |
181 | 158 | ||
182 | #ifdef CONFIG_MEMCG_SWAP | 159 | #ifdef CONFIG_MEMCG_SWAP |
183 | extern int do_swap_account; | 160 | extern int do_swap_account; |
@@ -402,16 +379,11 @@ static inline void mem_cgroup_end_update_page_stat(struct page *page, | |||
402 | { | 379 | { |
403 | } | 380 | } |
404 | 381 | ||
405 | static inline bool mem_cgroup_toggle_oom(bool new) | 382 | static inline void mem_cgroup_oom_enable(void) |
406 | { | ||
407 | return false; | ||
408 | } | ||
409 | |||
410 | static inline void mem_cgroup_enable_oom(void) | ||
411 | { | 383 | { |
412 | } | 384 | } |
413 | 385 | ||
414 | static inline void mem_cgroup_disable_oom(void) | 386 | static inline void mem_cgroup_oom_disable(void) |
415 | { | 387 | { |
416 | } | 388 | } |
417 | 389 | ||
@@ -420,7 +392,7 @@ static inline bool task_in_memcg_oom(struct task_struct *p) | |||
420 | return false; | 392 | return false; |
421 | } | 393 | } |
422 | 394 | ||
423 | static inline bool mem_cgroup_oom_synchronize(void) | 395 | static inline bool mem_cgroup_oom_synchronize(bool wait) |
424 | { | 396 | { |
425 | return false; | 397 | return false; |
426 | } | 398 | } |
diff --git a/include/linux/mfd/core.h b/include/linux/mfd/core.h index cebe97ee98b8..7314fc4e6d25 100644 --- a/include/linux/mfd/core.h +++ b/include/linux/mfd/core.h | |||
@@ -59,6 +59,12 @@ struct mfd_cell { | |||
59 | * pm_runtime_no_callbacks(). | 59 | * pm_runtime_no_callbacks(). |
60 | */ | 60 | */ |
61 | bool pm_runtime_no_callbacks; | 61 | bool pm_runtime_no_callbacks; |
62 | |||
63 | /* A list of regulator supplies that should be mapped to the MFD | ||
64 | * device rather than the child device when requested | ||
65 | */ | ||
66 | const char **parent_supplies; | ||
67 | int num_parent_supplies; | ||
62 | }; | 68 | }; |
63 | 69 | ||
64 | /* | 70 | /* |
diff --git a/include/linux/mlx5/device.h b/include/linux/mlx5/device.h index 68029b30c3dc..5eb4e31af22b 100644 --- a/include/linux/mlx5/device.h +++ b/include/linux/mlx5/device.h | |||
@@ -181,7 +181,7 @@ enum { | |||
181 | MLX5_DEV_CAP_FLAG_TLP_HINTS = 1LL << 39, | 181 | MLX5_DEV_CAP_FLAG_TLP_HINTS = 1LL << 39, |
182 | MLX5_DEV_CAP_FLAG_SIG_HAND_OVER = 1LL << 40, | 182 | MLX5_DEV_CAP_FLAG_SIG_HAND_OVER = 1LL << 40, |
183 | MLX5_DEV_CAP_FLAG_DCT = 1LL << 41, | 183 | MLX5_DEV_CAP_FLAG_DCT = 1LL << 41, |
184 | MLX5_DEV_CAP_FLAG_CMDIF_CSUM = 1LL << 46, | 184 | MLX5_DEV_CAP_FLAG_CMDIF_CSUM = 3LL << 46, |
185 | }; | 185 | }; |
186 | 186 | ||
187 | enum { | 187 | enum { |
@@ -417,7 +417,7 @@ struct mlx5_init_seg { | |||
417 | struct health_buffer health; | 417 | struct health_buffer health; |
418 | __be32 rsvd2[884]; | 418 | __be32 rsvd2[884]; |
419 | __be32 health_counter; | 419 | __be32 health_counter; |
420 | __be32 rsvd3[1023]; | 420 | __be32 rsvd3[1019]; |
421 | __be64 ieee1588_clk; | 421 | __be64 ieee1588_clk; |
422 | __be32 ieee1588_clk_type; | 422 | __be32 ieee1588_clk_type; |
423 | __be32 clr_intx; | 423 | __be32 clr_intx; |
diff --git a/include/linux/mlx5/driver.h b/include/linux/mlx5/driver.h index 8888381fc150..6b8c496572c8 100644 --- a/include/linux/mlx5/driver.h +++ b/include/linux/mlx5/driver.h | |||
@@ -82,7 +82,7 @@ enum { | |||
82 | }; | 82 | }; |
83 | 83 | ||
84 | enum { | 84 | enum { |
85 | MLX5_MAX_EQ_NAME = 20 | 85 | MLX5_MAX_EQ_NAME = 32 |
86 | }; | 86 | }; |
87 | 87 | ||
88 | enum { | 88 | enum { |
@@ -747,8 +747,7 @@ static inline u32 mlx5_idx_to_mkey(u32 mkey_idx) | |||
747 | 747 | ||
748 | enum { | 748 | enum { |
749 | MLX5_PROF_MASK_QP_SIZE = (u64)1 << 0, | 749 | MLX5_PROF_MASK_QP_SIZE = (u64)1 << 0, |
750 | MLX5_PROF_MASK_CMDIF_CSUM = (u64)1 << 1, | 750 | MLX5_PROF_MASK_MR_CACHE = (u64)1 << 1, |
751 | MLX5_PROF_MASK_MR_CACHE = (u64)1 << 2, | ||
752 | }; | 751 | }; |
753 | 752 | ||
754 | enum { | 753 | enum { |
@@ -758,7 +757,6 @@ enum { | |||
758 | struct mlx5_profile { | 757 | struct mlx5_profile { |
759 | u64 mask; | 758 | u64 mask; |
760 | u32 log_max_qp; | 759 | u32 log_max_qp; |
761 | int cmdif_csum; | ||
762 | struct { | 760 | struct { |
763 | int size; | 761 | int size; |
764 | int limit; | 762 | int limit; |
diff --git a/include/linux/of_reserved_mem.h b/include/linux/of_reserved_mem.h deleted file mode 100644 index c84128255814..000000000000 --- a/include/linux/of_reserved_mem.h +++ /dev/null | |||
@@ -1,14 +0,0 @@ | |||
1 | #ifndef __OF_RESERVED_MEM_H | ||
2 | #define __OF_RESERVED_MEM_H | ||
3 | |||
4 | #ifdef CONFIG_OF_RESERVED_MEM | ||
5 | void of_reserved_mem_device_init(struct device *dev); | ||
6 | void of_reserved_mem_device_release(struct device *dev); | ||
7 | void early_init_dt_scan_reserved_mem(void); | ||
8 | #else | ||
9 | static inline void of_reserved_mem_device_init(struct device *dev) { } | ||
10 | static inline void of_reserved_mem_device_release(struct device *dev) { } | ||
11 | static inline void early_init_dt_scan_reserved_mem(void) { } | ||
12 | #endif | ||
13 | |||
14 | #endif /* __OF_RESERVED_MEM_H */ | ||
diff --git a/include/linux/regulator/consumer.h b/include/linux/regulator/consumer.h index 27be915caa96..e530681bea70 100644 --- a/include/linux/regulator/consumer.h +++ b/include/linux/regulator/consumer.h | |||
@@ -146,6 +146,32 @@ struct regulator *__must_check devm_regulator_get_optional(struct device *dev, | |||
146 | void regulator_put(struct regulator *regulator); | 146 | void regulator_put(struct regulator *regulator); |
147 | void devm_regulator_put(struct regulator *regulator); | 147 | void devm_regulator_put(struct regulator *regulator); |
148 | 148 | ||
149 | int regulator_register_supply_alias(struct device *dev, const char *id, | ||
150 | struct device *alias_dev, | ||
151 | const char *alias_id); | ||
152 | void regulator_unregister_supply_alias(struct device *dev, const char *id); | ||
153 | |||
154 | int regulator_bulk_register_supply_alias(struct device *dev, const char **id, | ||
155 | struct device *alias_dev, | ||
156 | const char **alias_id, int num_id); | ||
157 | void regulator_bulk_unregister_supply_alias(struct device *dev, | ||
158 | const char **id, int num_id); | ||
159 | |||
160 | int devm_regulator_register_supply_alias(struct device *dev, const char *id, | ||
161 | struct device *alias_dev, | ||
162 | const char *alias_id); | ||
163 | void devm_regulator_unregister_supply_alias(struct device *dev, | ||
164 | const char *id); | ||
165 | |||
166 | int devm_regulator_bulk_register_supply_alias(struct device *dev, | ||
167 | const char **id, | ||
168 | struct device *alias_dev, | ||
169 | const char **alias_id, | ||
170 | int num_id); | ||
171 | void devm_regulator_bulk_unregister_supply_alias(struct device *dev, | ||
172 | const char **id, | ||
173 | int num_id); | ||
174 | |||
149 | /* regulator output control and status */ | 175 | /* regulator output control and status */ |
150 | int __must_check regulator_enable(struct regulator *regulator); | 176 | int __must_check regulator_enable(struct regulator *regulator); |
151 | int regulator_disable(struct regulator *regulator); | 177 | int regulator_disable(struct regulator *regulator); |
@@ -250,6 +276,59 @@ static inline void devm_regulator_put(struct regulator *regulator) | |||
250 | { | 276 | { |
251 | } | 277 | } |
252 | 278 | ||
279 | static inline int regulator_register_supply_alias(struct device *dev, | ||
280 | const char *id, | ||
281 | struct device *alias_dev, | ||
282 | const char *alias_id) | ||
283 | { | ||
284 | return 0; | ||
285 | } | ||
286 | |||
287 | static inline void regulator_unregister_supply_alias(struct device *dev, | ||
288 | const char *id) | ||
289 | { | ||
290 | } | ||
291 | |||
292 | static inline int regulator_bulk_register_supply_alias(struct device *dev, | ||
293 | const char **id, | ||
294 | struct device *alias_dev, | ||
295 | const char **alias_id, | ||
296 | int num_id) | ||
297 | { | ||
298 | return 0; | ||
299 | } | ||
300 | |||
301 | static inline void regulator_bulk_unregister_supply_alias(struct device *dev, | ||
302 | const char **id, | ||
303 | int num_id) | ||
304 | { | ||
305 | } | ||
306 | |||
307 | static inline int devm_regulator_register_supply_alias(struct device *dev, | ||
308 | const char *id, | ||
309 | struct device *alias_dev, | ||
310 | const char *alias_id) | ||
311 | { | ||
312 | return 0; | ||
313 | } | ||
314 | |||
315 | static inline void devm_regulator_unregister_supply_alias(struct device *dev, | ||
316 | const char *id) | ||
317 | { | ||
318 | } | ||
319 | |||
320 | static inline int devm_regulator_bulk_register_supply_alias( | ||
321 | struct device *dev, const char **id, struct device *alias_dev, | ||
322 | const char **alias_id, int num_id) | ||
323 | { | ||
324 | return 0; | ||
325 | } | ||
326 | |||
327 | static inline void devm_regulator_bulk_unregister_supply_alias( | ||
328 | struct device *dev, const char **id, int num_id) | ||
329 | { | ||
330 | } | ||
331 | |||
253 | static inline int regulator_enable(struct regulator *regulator) | 332 | static inline int regulator_enable(struct regulator *regulator) |
254 | { | 333 | { |
255 | return 0; | 334 | return 0; |
diff --git a/include/linux/regulator/driver.h b/include/linux/regulator/driver.h index 9bdad43ad228..9370e65348a4 100644 --- a/include/linux/regulator/driver.h +++ b/include/linux/regulator/driver.h | |||
@@ -46,19 +46,26 @@ enum regulator_status { | |||
46 | * regulator_list_linear_range(). | 46 | * regulator_list_linear_range(). |
47 | * | 47 | * |
48 | * @min_uV: Lowest voltage in range | 48 | * @min_uV: Lowest voltage in range |
49 | * @max_uV: Highest voltage in range | ||
50 | * @min_sel: Lowest selector for range | 49 | * @min_sel: Lowest selector for range |
51 | * @max_sel: Highest selector for range | 50 | * @max_sel: Highest selector for range |
52 | * @uV_step: Step size | 51 | * @uV_step: Step size |
53 | */ | 52 | */ |
54 | struct regulator_linear_range { | 53 | struct regulator_linear_range { |
55 | unsigned int min_uV; | 54 | unsigned int min_uV; |
56 | unsigned int max_uV; | ||
57 | unsigned int min_sel; | 55 | unsigned int min_sel; |
58 | unsigned int max_sel; | 56 | unsigned int max_sel; |
59 | unsigned int uV_step; | 57 | unsigned int uV_step; |
60 | }; | 58 | }; |
61 | 59 | ||
60 | /* Initialize struct regulator_linear_range */ | ||
61 | #define REGULATOR_LINEAR_RANGE(_min_uV, _min_sel, _max_sel, _step_uV) \ | ||
62 | { \ | ||
63 | .min_uV = _min_uV, \ | ||
64 | .min_sel = _min_sel, \ | ||
65 | .max_sel = _max_sel, \ | ||
66 | .uV_step = _step_uV, \ | ||
67 | } | ||
68 | |||
62 | /** | 69 | /** |
63 | * struct regulator_ops - regulator operations. | 70 | * struct regulator_ops - regulator operations. |
64 | * | 71 | * |
@@ -209,6 +216,7 @@ enum regulator_type { | |||
209 | * @min_uV: Voltage given by the lowest selector (if linear mapping) | 216 | * @min_uV: Voltage given by the lowest selector (if linear mapping) |
210 | * @uV_step: Voltage increase with each selector (if linear mapping) | 217 | * @uV_step: Voltage increase with each selector (if linear mapping) |
211 | * @linear_min_sel: Minimal selector for starting linear mapping | 218 | * @linear_min_sel: Minimal selector for starting linear mapping |
219 | * @fixed_uV: Fixed voltage of rails. | ||
212 | * @ramp_delay: Time to settle down after voltage change (unit: uV/us) | 220 | * @ramp_delay: Time to settle down after voltage change (unit: uV/us) |
213 | * @volt_table: Voltage mapping table (if table based mapping) | 221 | * @volt_table: Voltage mapping table (if table based mapping) |
214 | * | 222 | * |
@@ -241,6 +249,7 @@ struct regulator_desc { | |||
241 | unsigned int min_uV; | 249 | unsigned int min_uV; |
242 | unsigned int uV_step; | 250 | unsigned int uV_step; |
243 | unsigned int linear_min_sel; | 251 | unsigned int linear_min_sel; |
252 | int fixed_uV; | ||
244 | unsigned int ramp_delay; | 253 | unsigned int ramp_delay; |
245 | 254 | ||
246 | const struct regulator_linear_range *linear_ranges; | 255 | const struct regulator_linear_range *linear_ranges; |
@@ -336,7 +345,12 @@ struct regulator_dev { | |||
336 | struct regulator_dev * | 345 | struct regulator_dev * |
337 | regulator_register(const struct regulator_desc *regulator_desc, | 346 | regulator_register(const struct regulator_desc *regulator_desc, |
338 | const struct regulator_config *config); | 347 | const struct regulator_config *config); |
348 | struct regulator_dev * | ||
349 | devm_regulator_register(struct device *dev, | ||
350 | const struct regulator_desc *regulator_desc, | ||
351 | const struct regulator_config *config); | ||
339 | void regulator_unregister(struct regulator_dev *rdev); | 352 | void regulator_unregister(struct regulator_dev *rdev); |
353 | void devm_regulator_unregister(struct device *dev, struct regulator_dev *rdev); | ||
340 | 354 | ||
341 | int regulator_notifier_call_chain(struct regulator_dev *rdev, | 355 | int regulator_notifier_call_chain(struct regulator_dev *rdev, |
342 | unsigned long event, void *data); | 356 | unsigned long event, void *data); |
diff --git a/include/linux/regulator/machine.h b/include/linux/regulator/machine.h index 999b20ce06cf..730e638c5589 100644 --- a/include/linux/regulator/machine.h +++ b/include/linux/regulator/machine.h | |||
@@ -95,6 +95,7 @@ struct regulator_state { | |||
95 | * @initial_state: Suspend state to set by default. | 95 | * @initial_state: Suspend state to set by default. |
96 | * @initial_mode: Mode to set at startup. | 96 | * @initial_mode: Mode to set at startup. |
97 | * @ramp_delay: Time to settle down after voltage change (unit: uV/us) | 97 | * @ramp_delay: Time to settle down after voltage change (unit: uV/us) |
98 | * @enable_time: Turn-on time of the rails (unit: microseconds) | ||
98 | */ | 99 | */ |
99 | struct regulation_constraints { | 100 | struct regulation_constraints { |
100 | 101 | ||
@@ -129,6 +130,7 @@ struct regulation_constraints { | |||
129 | unsigned int initial_mode; | 130 | unsigned int initial_mode; |
130 | 131 | ||
131 | unsigned int ramp_delay; | 132 | unsigned int ramp_delay; |
133 | unsigned int enable_time; | ||
132 | 134 | ||
133 | /* constraint flags */ | 135 | /* constraint flags */ |
134 | unsigned always_on:1; /* regulator never off when system is on */ | 136 | unsigned always_on:1; /* regulator never off when system is on */ |
@@ -193,15 +195,10 @@ int regulator_suspend_finish(void); | |||
193 | 195 | ||
194 | #ifdef CONFIG_REGULATOR | 196 | #ifdef CONFIG_REGULATOR |
195 | void regulator_has_full_constraints(void); | 197 | void regulator_has_full_constraints(void); |
196 | void regulator_use_dummy_regulator(void); | ||
197 | #else | 198 | #else |
198 | static inline void regulator_has_full_constraints(void) | 199 | static inline void regulator_has_full_constraints(void) |
199 | { | 200 | { |
200 | } | 201 | } |
201 | |||
202 | static inline void regulator_use_dummy_regulator(void) | ||
203 | { | ||
204 | } | ||
205 | #endif | 202 | #endif |
206 | 203 | ||
207 | #endif | 204 | #endif |
diff --git a/include/linux/sched.h b/include/linux/sched.h index 6682da36b293..e27baeeda3f4 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h | |||
@@ -1394,11 +1394,10 @@ struct task_struct { | |||
1394 | } memcg_batch; | 1394 | } memcg_batch; |
1395 | unsigned int memcg_kmem_skip_account; | 1395 | unsigned int memcg_kmem_skip_account; |
1396 | struct memcg_oom_info { | 1396 | struct memcg_oom_info { |
1397 | struct mem_cgroup *memcg; | ||
1398 | gfp_t gfp_mask; | ||
1399 | int order; | ||
1397 | unsigned int may_oom:1; | 1400 | unsigned int may_oom:1; |
1398 | unsigned int in_memcg_oom:1; | ||
1399 | unsigned int oom_locked:1; | ||
1400 | int wakeups; | ||
1401 | struct mem_cgroup *wait_on_memcg; | ||
1402 | } memcg_oom; | 1401 | } memcg_oom; |
1403 | #endif | 1402 | #endif |
1404 | #ifdef CONFIG_UPROBES | 1403 | #ifdef CONFIG_UPROBES |
diff --git a/include/linux/usb/usb_phy_gen_xceiv.h b/include/linux/usb/usb_phy_gen_xceiv.h index f9a7e7bc925b..11d85b9c1b08 100644 --- a/include/linux/usb/usb_phy_gen_xceiv.h +++ b/include/linux/usb/usb_phy_gen_xceiv.h | |||
@@ -12,7 +12,7 @@ struct usb_phy_gen_xceiv_platform_data { | |||
12 | unsigned int needs_reset:1; | 12 | unsigned int needs_reset:1; |
13 | }; | 13 | }; |
14 | 14 | ||
15 | #if IS_ENABLED(CONFIG_NOP_USB_XCEIV) | 15 | #if defined(CONFIG_NOP_USB_XCEIV) || (defined(CONFIG_NOP_USB_XCEIV_MODULE) && defined(MODULE)) |
16 | /* sometimes transceivers are accessed only through e.g. ULPI */ | 16 | /* sometimes transceivers are accessed only through e.g. ULPI */ |
17 | extern void usb_nop_xceiv_register(void); | 17 | extern void usb_nop_xceiv_register(void); |
18 | extern void usb_nop_xceiv_unregister(void); | 18 | extern void usb_nop_xceiv_unregister(void); |
diff --git a/include/linux/usb_usual.h b/include/linux/usb_usual.h index bf99cd01be20..630356866030 100644 --- a/include/linux/usb_usual.h +++ b/include/linux/usb_usual.h | |||
@@ -66,7 +66,9 @@ | |||
66 | US_FLAG(INITIAL_READ10, 0x00100000) \ | 66 | US_FLAG(INITIAL_READ10, 0x00100000) \ |
67 | /* Initial READ(10) (and others) must be retried */ \ | 67 | /* Initial READ(10) (and others) must be retried */ \ |
68 | US_FLAG(WRITE_CACHE, 0x00200000) \ | 68 | US_FLAG(WRITE_CACHE, 0x00200000) \ |
69 | /* Write Cache status is not available */ | 69 | /* Write Cache status is not available */ \ |
70 | US_FLAG(NEEDS_CAP16, 0x00400000) | ||
71 | /* cannot handle READ_CAPACITY_10 */ | ||
70 | 72 | ||
71 | #define US_FLAG(name, value) US_FL_##name = value , | 73 | #define US_FLAG(name, value) US_FL_##name = value , |
72 | enum { US_DO_ALL_FLAGS }; | 74 | enum { US_DO_ALL_FLAGS }; |
@@ -1282,6 +1282,12 @@ static int semctl_setval(struct ipc_namespace *ns, int semid, int semnum, | |||
1282 | 1282 | ||
1283 | sem_lock(sma, NULL, -1); | 1283 | sem_lock(sma, NULL, -1); |
1284 | 1284 | ||
1285 | if (sma->sem_perm.deleted) { | ||
1286 | sem_unlock(sma, -1); | ||
1287 | rcu_read_unlock(); | ||
1288 | return -EIDRM; | ||
1289 | } | ||
1290 | |||
1285 | curr = &sma->sem_base[semnum]; | 1291 | curr = &sma->sem_base[semnum]; |
1286 | 1292 | ||
1287 | ipc_assert_locked_object(&sma->sem_perm); | 1293 | ipc_assert_locked_object(&sma->sem_perm); |
@@ -1336,12 +1342,14 @@ static int semctl_main(struct ipc_namespace *ns, int semid, int semnum, | |||
1336 | int i; | 1342 | int i; |
1337 | 1343 | ||
1338 | sem_lock(sma, NULL, -1); | 1344 | sem_lock(sma, NULL, -1); |
1345 | if (sma->sem_perm.deleted) { | ||
1346 | err = -EIDRM; | ||
1347 | goto out_unlock; | ||
1348 | } | ||
1339 | if(nsems > SEMMSL_FAST) { | 1349 | if(nsems > SEMMSL_FAST) { |
1340 | if (!ipc_rcu_getref(sma)) { | 1350 | if (!ipc_rcu_getref(sma)) { |
1341 | sem_unlock(sma, -1); | ||
1342 | rcu_read_unlock(); | ||
1343 | err = -EIDRM; | 1351 | err = -EIDRM; |
1344 | goto out_free; | 1352 | goto out_unlock; |
1345 | } | 1353 | } |
1346 | sem_unlock(sma, -1); | 1354 | sem_unlock(sma, -1); |
1347 | rcu_read_unlock(); | 1355 | rcu_read_unlock(); |
@@ -1354,10 +1362,8 @@ static int semctl_main(struct ipc_namespace *ns, int semid, int semnum, | |||
1354 | rcu_read_lock(); | 1362 | rcu_read_lock(); |
1355 | sem_lock_and_putref(sma); | 1363 | sem_lock_and_putref(sma); |
1356 | if (sma->sem_perm.deleted) { | 1364 | if (sma->sem_perm.deleted) { |
1357 | sem_unlock(sma, -1); | ||
1358 | rcu_read_unlock(); | ||
1359 | err = -EIDRM; | 1365 | err = -EIDRM; |
1360 | goto out_free; | 1366 | goto out_unlock; |
1361 | } | 1367 | } |
1362 | } | 1368 | } |
1363 | for (i = 0; i < sma->sem_nsems; i++) | 1369 | for (i = 0; i < sma->sem_nsems; i++) |
@@ -1375,8 +1381,8 @@ static int semctl_main(struct ipc_namespace *ns, int semid, int semnum, | |||
1375 | struct sem_undo *un; | 1381 | struct sem_undo *un; |
1376 | 1382 | ||
1377 | if (!ipc_rcu_getref(sma)) { | 1383 | if (!ipc_rcu_getref(sma)) { |
1378 | rcu_read_unlock(); | 1384 | err = -EIDRM; |
1379 | return -EIDRM; | 1385 | goto out_rcu_wakeup; |
1380 | } | 1386 | } |
1381 | rcu_read_unlock(); | 1387 | rcu_read_unlock(); |
1382 | 1388 | ||
@@ -1404,10 +1410,8 @@ static int semctl_main(struct ipc_namespace *ns, int semid, int semnum, | |||
1404 | rcu_read_lock(); | 1410 | rcu_read_lock(); |
1405 | sem_lock_and_putref(sma); | 1411 | sem_lock_and_putref(sma); |
1406 | if (sma->sem_perm.deleted) { | 1412 | if (sma->sem_perm.deleted) { |
1407 | sem_unlock(sma, -1); | ||
1408 | rcu_read_unlock(); | ||
1409 | err = -EIDRM; | 1413 | err = -EIDRM; |
1410 | goto out_free; | 1414 | goto out_unlock; |
1411 | } | 1415 | } |
1412 | 1416 | ||
1413 | for (i = 0; i < nsems; i++) | 1417 | for (i = 0; i < nsems; i++) |
@@ -1431,6 +1435,10 @@ static int semctl_main(struct ipc_namespace *ns, int semid, int semnum, | |||
1431 | goto out_rcu_wakeup; | 1435 | goto out_rcu_wakeup; |
1432 | 1436 | ||
1433 | sem_lock(sma, NULL, -1); | 1437 | sem_lock(sma, NULL, -1); |
1438 | if (sma->sem_perm.deleted) { | ||
1439 | err = -EIDRM; | ||
1440 | goto out_unlock; | ||
1441 | } | ||
1434 | curr = &sma->sem_base[semnum]; | 1442 | curr = &sma->sem_base[semnum]; |
1435 | 1443 | ||
1436 | switch (cmd) { | 1444 | switch (cmd) { |
@@ -1836,6 +1844,10 @@ SYSCALL_DEFINE4(semtimedop, int, semid, struct sembuf __user *, tsops, | |||
1836 | if (error) | 1844 | if (error) |
1837 | goto out_rcu_wakeup; | 1845 | goto out_rcu_wakeup; |
1838 | 1846 | ||
1847 | error = -EIDRM; | ||
1848 | locknum = sem_lock(sma, sops, nsops); | ||
1849 | if (sma->sem_perm.deleted) | ||
1850 | goto out_unlock_free; | ||
1839 | /* | 1851 | /* |
1840 | * semid identifiers are not unique - find_alloc_undo may have | 1852 | * semid identifiers are not unique - find_alloc_undo may have |
1841 | * allocated an undo structure, it was invalidated by an RMID | 1853 | * allocated an undo structure, it was invalidated by an RMID |
@@ -1843,8 +1855,6 @@ SYSCALL_DEFINE4(semtimedop, int, semid, struct sembuf __user *, tsops, | |||
1843 | * This case can be detected checking un->semid. The existence of | 1855 | * This case can be detected checking un->semid. The existence of |
1844 | * "un" itself is guaranteed by rcu. | 1856 | * "un" itself is guaranteed by rcu. |
1845 | */ | 1857 | */ |
1846 | error = -EIDRM; | ||
1847 | locknum = sem_lock(sma, sops, nsops); | ||
1848 | if (un && un->semid == -1) | 1858 | if (un && un->semid == -1) |
1849 | goto out_unlock_free; | 1859 | goto out_unlock_free; |
1850 | 1860 | ||
@@ -2057,6 +2067,12 @@ void exit_sem(struct task_struct *tsk) | |||
2057 | } | 2067 | } |
2058 | 2068 | ||
2059 | sem_lock(sma, NULL, -1); | 2069 | sem_lock(sma, NULL, -1); |
2070 | /* exit_sem raced with IPC_RMID, nothing to do */ | ||
2071 | if (sma->sem_perm.deleted) { | ||
2072 | sem_unlock(sma, -1); | ||
2073 | rcu_read_unlock(); | ||
2074 | continue; | ||
2075 | } | ||
2060 | un = __lookup_undo(ulp, semid); | 2076 | un = __lookup_undo(ulp, semid); |
2061 | if (un == NULL) { | 2077 | if (un == NULL) { |
2062 | /* exit_sem raced with IPC_RMID+semget() that created | 2078 | /* exit_sem raced with IPC_RMID+semget() that created |
diff --git a/ipc/util.c b/ipc/util.c index fdb8ae740775..7684f41bce76 100644 --- a/ipc/util.c +++ b/ipc/util.c | |||
@@ -17,12 +17,27 @@ | |||
17 | * Pavel Emelianov <xemul@openvz.org> | 17 | * Pavel Emelianov <xemul@openvz.org> |
18 | * | 18 | * |
19 | * General sysv ipc locking scheme: | 19 | * General sysv ipc locking scheme: |
20 | * when doing ipc id lookups, take the ids->rwsem | 20 | * rcu_read_lock() |
21 | * rcu_read_lock() | 21 | * obtain the ipc object (kern_ipc_perm) by looking up the id in an idr |
22 | * obtain the ipc object (kern_ipc_perm) | 22 | * tree. |
23 | * perform security, capabilities, auditing and permission checks, etc. | 23 | * - perform initial checks (capabilities, auditing and permission, |
24 | * acquire the ipc lock (kern_ipc_perm.lock) throught ipc_lock_object() | 24 | * etc). |
25 | * perform data updates (ie: SET, RMID, LOCK/UNLOCK commands) | 25 | * - perform read-only operations, such as STAT, INFO commands. |
26 | * acquire the ipc lock (kern_ipc_perm.lock) through | ||
27 | * ipc_lock_object() | ||
28 | * - perform data updates, such as SET, RMID commands and | ||
29 | * mechanism-specific operations (semop/semtimedop, | ||
30 | * msgsnd/msgrcv, shmat/shmdt). | ||
31 | * drop the ipc lock, through ipc_unlock_object(). | ||
32 | * rcu_read_unlock() | ||
33 | * | ||
34 | * The ids->rwsem must be taken when: | ||
35 | * - creating, removing and iterating the existing entries in ipc | ||
36 | * identifier sets. | ||
37 | * - iterating through files under /proc/sysvipc/ | ||
38 | * | ||
39 | * Note that sems have a special fast path that avoids kern_ipc_perm.lock - | ||
40 | * see sem_lock(). | ||
26 | */ | 41 | */ |
27 | 42 | ||
28 | #include <linux/mm.h> | 43 | #include <linux/mm.h> |
diff --git a/lib/percpu-refcount.c b/lib/percpu-refcount.c index 7deeb6297a48..1a53d497a8c5 100644 --- a/lib/percpu-refcount.c +++ b/lib/percpu-refcount.c | |||
@@ -53,6 +53,7 @@ int percpu_ref_init(struct percpu_ref *ref, percpu_ref_func_t *release) | |||
53 | ref->release = release; | 53 | ref->release = release; |
54 | return 0; | 54 | return 0; |
55 | } | 55 | } |
56 | EXPORT_SYMBOL_GPL(percpu_ref_init); | ||
56 | 57 | ||
57 | /** | 58 | /** |
58 | * percpu_ref_cancel_init - cancel percpu_ref_init() | 59 | * percpu_ref_cancel_init - cancel percpu_ref_init() |
@@ -84,6 +85,7 @@ void percpu_ref_cancel_init(struct percpu_ref *ref) | |||
84 | free_percpu(ref->pcpu_count); | 85 | free_percpu(ref->pcpu_count); |
85 | } | 86 | } |
86 | } | 87 | } |
88 | EXPORT_SYMBOL_GPL(percpu_ref_cancel_init); | ||
87 | 89 | ||
88 | static void percpu_ref_kill_rcu(struct rcu_head *rcu) | 90 | static void percpu_ref_kill_rcu(struct rcu_head *rcu) |
89 | { | 91 | { |
@@ -156,3 +158,4 @@ void percpu_ref_kill_and_confirm(struct percpu_ref *ref, | |||
156 | 158 | ||
157 | call_rcu_sched(&ref->rcu, percpu_ref_kill_rcu); | 159 | call_rcu_sched(&ref->rcu, percpu_ref_kill_rcu); |
158 | } | 160 | } |
161 | EXPORT_SYMBOL_GPL(percpu_ref_kill_and_confirm); | ||
diff --git a/mm/filemap.c b/mm/filemap.c index 1e6aec4a2d2e..ae4846ff4849 100644 --- a/mm/filemap.c +++ b/mm/filemap.c | |||
@@ -1616,7 +1616,6 @@ int filemap_fault(struct vm_area_struct *vma, struct vm_fault *vmf) | |||
1616 | struct inode *inode = mapping->host; | 1616 | struct inode *inode = mapping->host; |
1617 | pgoff_t offset = vmf->pgoff; | 1617 | pgoff_t offset = vmf->pgoff; |
1618 | struct page *page; | 1618 | struct page *page; |
1619 | bool memcg_oom; | ||
1620 | pgoff_t size; | 1619 | pgoff_t size; |
1621 | int ret = 0; | 1620 | int ret = 0; |
1622 | 1621 | ||
@@ -1625,11 +1624,7 @@ int filemap_fault(struct vm_area_struct *vma, struct vm_fault *vmf) | |||
1625 | return VM_FAULT_SIGBUS; | 1624 | return VM_FAULT_SIGBUS; |
1626 | 1625 | ||
1627 | /* | 1626 | /* |
1628 | * Do we have something in the page cache already? Either | 1627 | * Do we have something in the page cache already? |
1629 | * way, try readahead, but disable the memcg OOM killer for it | ||
1630 | * as readahead is optional and no errors are propagated up | ||
1631 | * the fault stack. The OOM killer is enabled while trying to | ||
1632 | * instantiate the faulting page individually below. | ||
1633 | */ | 1628 | */ |
1634 | page = find_get_page(mapping, offset); | 1629 | page = find_get_page(mapping, offset); |
1635 | if (likely(page) && !(vmf->flags & FAULT_FLAG_TRIED)) { | 1630 | if (likely(page) && !(vmf->flags & FAULT_FLAG_TRIED)) { |
@@ -1637,14 +1632,10 @@ int filemap_fault(struct vm_area_struct *vma, struct vm_fault *vmf) | |||
1637 | * We found the page, so try async readahead before | 1632 | * We found the page, so try async readahead before |
1638 | * waiting for the lock. | 1633 | * waiting for the lock. |
1639 | */ | 1634 | */ |
1640 | memcg_oom = mem_cgroup_toggle_oom(false); | ||
1641 | do_async_mmap_readahead(vma, ra, file, page, offset); | 1635 | do_async_mmap_readahead(vma, ra, file, page, offset); |
1642 | mem_cgroup_toggle_oom(memcg_oom); | ||
1643 | } else if (!page) { | 1636 | } else if (!page) { |
1644 | /* No page in the page cache at all */ | 1637 | /* No page in the page cache at all */ |
1645 | memcg_oom = mem_cgroup_toggle_oom(false); | ||
1646 | do_sync_mmap_readahead(vma, ra, file, offset); | 1638 | do_sync_mmap_readahead(vma, ra, file, offset); |
1647 | mem_cgroup_toggle_oom(memcg_oom); | ||
1648 | count_vm_event(PGMAJFAULT); | 1639 | count_vm_event(PGMAJFAULT); |
1649 | mem_cgroup_count_vm_event(vma->vm_mm, PGMAJFAULT); | 1640 | mem_cgroup_count_vm_event(vma->vm_mm, PGMAJFAULT); |
1650 | ret = VM_FAULT_MAJOR; | 1641 | ret = VM_FAULT_MAJOR; |
diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 7489884682d8..610e3df2768a 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c | |||
@@ -2697,6 +2697,7 @@ void __split_huge_page_pmd(struct vm_area_struct *vma, unsigned long address, | |||
2697 | 2697 | ||
2698 | mmun_start = haddr; | 2698 | mmun_start = haddr; |
2699 | mmun_end = haddr + HPAGE_PMD_SIZE; | 2699 | mmun_end = haddr + HPAGE_PMD_SIZE; |
2700 | again: | ||
2700 | mmu_notifier_invalidate_range_start(mm, mmun_start, mmun_end); | 2701 | mmu_notifier_invalidate_range_start(mm, mmun_start, mmun_end); |
2701 | spin_lock(&mm->page_table_lock); | 2702 | spin_lock(&mm->page_table_lock); |
2702 | if (unlikely(!pmd_trans_huge(*pmd))) { | 2703 | if (unlikely(!pmd_trans_huge(*pmd))) { |
@@ -2719,7 +2720,14 @@ void __split_huge_page_pmd(struct vm_area_struct *vma, unsigned long address, | |||
2719 | split_huge_page(page); | 2720 | split_huge_page(page); |
2720 | 2721 | ||
2721 | put_page(page); | 2722 | put_page(page); |
2722 | BUG_ON(pmd_trans_huge(*pmd)); | 2723 | |
2724 | /* | ||
2725 | * We don't always have down_write of mmap_sem here: a racing | ||
2726 | * do_huge_pmd_wp_page() might have copied-on-write to another | ||
2727 | * huge page before our split_huge_page() got the anon_vma lock. | ||
2728 | */ | ||
2729 | if (unlikely(pmd_trans_huge(*pmd))) | ||
2730 | goto again; | ||
2723 | } | 2731 | } |
2724 | 2732 | ||
2725 | void split_huge_page_pmd_mm(struct mm_struct *mm, unsigned long address, | 2733 | void split_huge_page_pmd_mm(struct mm_struct *mm, unsigned long address, |
diff --git a/mm/hugetlb.c b/mm/hugetlb.c index b49579c7f2a5..0b7656e804d1 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c | |||
@@ -653,6 +653,7 @@ static void free_huge_page(struct page *page) | |||
653 | BUG_ON(page_count(page)); | 653 | BUG_ON(page_count(page)); |
654 | BUG_ON(page_mapcount(page)); | 654 | BUG_ON(page_mapcount(page)); |
655 | restore_reserve = PagePrivate(page); | 655 | restore_reserve = PagePrivate(page); |
656 | ClearPagePrivate(page); | ||
656 | 657 | ||
657 | spin_lock(&hugetlb_lock); | 658 | spin_lock(&hugetlb_lock); |
658 | hugetlb_cgroup_uncharge_page(hstate_index(h), | 659 | hugetlb_cgroup_uncharge_page(hstate_index(h), |
@@ -695,8 +696,22 @@ static void prep_compound_gigantic_page(struct page *page, unsigned long order) | |||
695 | /* we rely on prep_new_huge_page to set the destructor */ | 696 | /* we rely on prep_new_huge_page to set the destructor */ |
696 | set_compound_order(page, order); | 697 | set_compound_order(page, order); |
697 | __SetPageHead(page); | 698 | __SetPageHead(page); |
699 | __ClearPageReserved(page); | ||
698 | for (i = 1; i < nr_pages; i++, p = mem_map_next(p, page, i)) { | 700 | for (i = 1; i < nr_pages; i++, p = mem_map_next(p, page, i)) { |
699 | __SetPageTail(p); | 701 | __SetPageTail(p); |
702 | /* | ||
703 | * For gigantic hugepages allocated through bootmem at | ||
704 | * boot, it's safer to be consistent with the not-gigantic | ||
705 | * hugepages and clear the PG_reserved bit from all tail pages | ||
706 | * too. Otherwse drivers using get_user_pages() to access tail | ||
707 | * pages may get the reference counting wrong if they see | ||
708 | * PG_reserved set on a tail page (despite the head page not | ||
709 | * having PG_reserved set). Enforcing this consistency between | ||
710 | * head and tail pages allows drivers to optimize away a check | ||
711 | * on the head page when they need know if put_page() is needed | ||
712 | * after get_user_pages(). | ||
713 | */ | ||
714 | __ClearPageReserved(p); | ||
700 | set_page_count(p, 0); | 715 | set_page_count(p, 0); |
701 | p->first_page = page; | 716 | p->first_page = page; |
702 | } | 717 | } |
@@ -1329,9 +1344,9 @@ static void __init gather_bootmem_prealloc(void) | |||
1329 | #else | 1344 | #else |
1330 | page = virt_to_page(m); | 1345 | page = virt_to_page(m); |
1331 | #endif | 1346 | #endif |
1332 | __ClearPageReserved(page); | ||
1333 | WARN_ON(page_count(page) != 1); | 1347 | WARN_ON(page_count(page) != 1); |
1334 | prep_compound_huge_page(page, h->order); | 1348 | prep_compound_huge_page(page, h->order); |
1349 | WARN_ON(PageReserved(page)); | ||
1335 | prep_new_huge_page(h, page, page_to_nid(page)); | 1350 | prep_new_huge_page(h, page, page_to_nid(page)); |
1336 | /* | 1351 | /* |
1337 | * If we had gigantic hugepages allocated at boot time, we need | 1352 | * If we had gigantic hugepages allocated at boot time, we need |
diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 1c52ddbc839b..34d3ca9572d6 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c | |||
@@ -866,6 +866,7 @@ static unsigned long mem_cgroup_read_events(struct mem_cgroup *memcg, | |||
866 | unsigned long val = 0; | 866 | unsigned long val = 0; |
867 | int cpu; | 867 | int cpu; |
868 | 868 | ||
869 | get_online_cpus(); | ||
869 | for_each_online_cpu(cpu) | 870 | for_each_online_cpu(cpu) |
870 | val += per_cpu(memcg->stat->events[idx], cpu); | 871 | val += per_cpu(memcg->stat->events[idx], cpu); |
871 | #ifdef CONFIG_HOTPLUG_CPU | 872 | #ifdef CONFIG_HOTPLUG_CPU |
@@ -873,6 +874,7 @@ static unsigned long mem_cgroup_read_events(struct mem_cgroup *memcg, | |||
873 | val += memcg->nocpu_base.events[idx]; | 874 | val += memcg->nocpu_base.events[idx]; |
874 | spin_unlock(&memcg->pcp_counter_lock); | 875 | spin_unlock(&memcg->pcp_counter_lock); |
875 | #endif | 876 | #endif |
877 | put_online_cpus(); | ||
876 | return val; | 878 | return val; |
877 | } | 879 | } |
878 | 880 | ||
@@ -2159,110 +2161,59 @@ static void memcg_oom_recover(struct mem_cgroup *memcg) | |||
2159 | memcg_wakeup_oom(memcg); | 2161 | memcg_wakeup_oom(memcg); |
2160 | } | 2162 | } |
2161 | 2163 | ||
2162 | /* | ||
2163 | * try to call OOM killer | ||
2164 | */ | ||
2165 | static void mem_cgroup_oom(struct mem_cgroup *memcg, gfp_t mask, int order) | 2164 | static void mem_cgroup_oom(struct mem_cgroup *memcg, gfp_t mask, int order) |
2166 | { | 2165 | { |
2167 | bool locked; | ||
2168 | int wakeups; | ||
2169 | |||
2170 | if (!current->memcg_oom.may_oom) | 2166 | if (!current->memcg_oom.may_oom) |
2171 | return; | 2167 | return; |
2172 | |||
2173 | current->memcg_oom.in_memcg_oom = 1; | ||
2174 | |||
2175 | /* | 2168 | /* |
2176 | * As with any blocking lock, a contender needs to start | 2169 | * We are in the middle of the charge context here, so we |
2177 | * listening for wakeups before attempting the trylock, | 2170 | * don't want to block when potentially sitting on a callstack |
2178 | * otherwise it can miss the wakeup from the unlock and sleep | 2171 | * that holds all kinds of filesystem and mm locks. |
2179 | * indefinitely. This is just open-coded because our locking | 2172 | * |
2180 | * is so particular to memcg hierarchies. | 2173 | * Also, the caller may handle a failed allocation gracefully |
2174 | * (like optional page cache readahead) and so an OOM killer | ||
2175 | * invocation might not even be necessary. | ||
2176 | * | ||
2177 | * That's why we don't do anything here except remember the | ||
2178 | * OOM context and then deal with it at the end of the page | ||
2179 | * fault when the stack is unwound, the locks are released, | ||
2180 | * and when we know whether the fault was overall successful. | ||
2181 | */ | 2181 | */ |
2182 | wakeups = atomic_read(&memcg->oom_wakeups); | 2182 | css_get(&memcg->css); |
2183 | mem_cgroup_mark_under_oom(memcg); | 2183 | current->memcg_oom.memcg = memcg; |
2184 | 2184 | current->memcg_oom.gfp_mask = mask; | |
2185 | locked = mem_cgroup_oom_trylock(memcg); | 2185 | current->memcg_oom.order = order; |
2186 | |||
2187 | if (locked) | ||
2188 | mem_cgroup_oom_notify(memcg); | ||
2189 | |||
2190 | if (locked && !memcg->oom_kill_disable) { | ||
2191 | mem_cgroup_unmark_under_oom(memcg); | ||
2192 | mem_cgroup_out_of_memory(memcg, mask, order); | ||
2193 | mem_cgroup_oom_unlock(memcg); | ||
2194 | /* | ||
2195 | * There is no guarantee that an OOM-lock contender | ||
2196 | * sees the wakeups triggered by the OOM kill | ||
2197 | * uncharges. Wake any sleepers explicitely. | ||
2198 | */ | ||
2199 | memcg_oom_recover(memcg); | ||
2200 | } else { | ||
2201 | /* | ||
2202 | * A system call can just return -ENOMEM, but if this | ||
2203 | * is a page fault and somebody else is handling the | ||
2204 | * OOM already, we need to sleep on the OOM waitqueue | ||
2205 | * for this memcg until the situation is resolved. | ||
2206 | * Which can take some time because it might be | ||
2207 | * handled by a userspace task. | ||
2208 | * | ||
2209 | * However, this is the charge context, which means | ||
2210 | * that we may sit on a large call stack and hold | ||
2211 | * various filesystem locks, the mmap_sem etc. and we | ||
2212 | * don't want the OOM handler to deadlock on them | ||
2213 | * while we sit here and wait. Store the current OOM | ||
2214 | * context in the task_struct, then return -ENOMEM. | ||
2215 | * At the end of the page fault handler, with the | ||
2216 | * stack unwound, pagefault_out_of_memory() will check | ||
2217 | * back with us by calling | ||
2218 | * mem_cgroup_oom_synchronize(), possibly putting the | ||
2219 | * task to sleep. | ||
2220 | */ | ||
2221 | current->memcg_oom.oom_locked = locked; | ||
2222 | current->memcg_oom.wakeups = wakeups; | ||
2223 | css_get(&memcg->css); | ||
2224 | current->memcg_oom.wait_on_memcg = memcg; | ||
2225 | } | ||
2226 | } | 2186 | } |
2227 | 2187 | ||
2228 | /** | 2188 | /** |
2229 | * mem_cgroup_oom_synchronize - complete memcg OOM handling | 2189 | * mem_cgroup_oom_synchronize - complete memcg OOM handling |
2190 | * @handle: actually kill/wait or just clean up the OOM state | ||
2230 | * | 2191 | * |
2231 | * This has to be called at the end of a page fault if the the memcg | 2192 | * This has to be called at the end of a page fault if the memcg OOM |
2232 | * OOM handler was enabled and the fault is returning %VM_FAULT_OOM. | 2193 | * handler was enabled. |
2233 | * | 2194 | * |
2234 | * Memcg supports userspace OOM handling, so failed allocations must | 2195 | * Memcg supports userspace OOM handling where failed allocations must |
2235 | * sleep on a waitqueue until the userspace task resolves the | 2196 | * sleep on a waitqueue until the userspace task resolves the |
2236 | * situation. Sleeping directly in the charge context with all kinds | 2197 | * situation. Sleeping directly in the charge context with all kinds |
2237 | * of locks held is not a good idea, instead we remember an OOM state | 2198 | * of locks held is not a good idea, instead we remember an OOM state |
2238 | * in the task and mem_cgroup_oom_synchronize() has to be called at | 2199 | * in the task and mem_cgroup_oom_synchronize() has to be called at |
2239 | * the end of the page fault to put the task to sleep and clean up the | 2200 | * the end of the page fault to complete the OOM handling. |
2240 | * OOM state. | ||
2241 | * | 2201 | * |
2242 | * Returns %true if an ongoing memcg OOM situation was detected and | 2202 | * Returns %true if an ongoing memcg OOM situation was detected and |
2243 | * finalized, %false otherwise. | 2203 | * completed, %false otherwise. |
2244 | */ | 2204 | */ |
2245 | bool mem_cgroup_oom_synchronize(void) | 2205 | bool mem_cgroup_oom_synchronize(bool handle) |
2246 | { | 2206 | { |
2207 | struct mem_cgroup *memcg = current->memcg_oom.memcg; | ||
2247 | struct oom_wait_info owait; | 2208 | struct oom_wait_info owait; |
2248 | struct mem_cgroup *memcg; | 2209 | bool locked; |
2249 | 2210 | ||
2250 | /* OOM is global, do not handle */ | 2211 | /* OOM is global, do not handle */ |
2251 | if (!current->memcg_oom.in_memcg_oom) | ||
2252 | return false; | ||
2253 | |||
2254 | /* | ||
2255 | * We invoked the OOM killer but there is a chance that a kill | ||
2256 | * did not free up any charges. Everybody else might already | ||
2257 | * be sleeping, so restart the fault and keep the rampage | ||
2258 | * going until some charges are released. | ||
2259 | */ | ||
2260 | memcg = current->memcg_oom.wait_on_memcg; | ||
2261 | if (!memcg) | 2212 | if (!memcg) |
2262 | goto out; | 2213 | return false; |
2263 | 2214 | ||
2264 | if (test_thread_flag(TIF_MEMDIE) || fatal_signal_pending(current)) | 2215 | if (!handle) |
2265 | goto out_memcg; | 2216 | goto cleanup; |
2266 | 2217 | ||
2267 | owait.memcg = memcg; | 2218 | owait.memcg = memcg; |
2268 | owait.wait.flags = 0; | 2219 | owait.wait.flags = 0; |
@@ -2271,13 +2222,25 @@ bool mem_cgroup_oom_synchronize(void) | |||
2271 | INIT_LIST_HEAD(&owait.wait.task_list); | 2222 | INIT_LIST_HEAD(&owait.wait.task_list); |
2272 | 2223 | ||
2273 | prepare_to_wait(&memcg_oom_waitq, &owait.wait, TASK_KILLABLE); | 2224 | prepare_to_wait(&memcg_oom_waitq, &owait.wait, TASK_KILLABLE); |
2274 | /* Only sleep if we didn't miss any wakeups since OOM */ | 2225 | mem_cgroup_mark_under_oom(memcg); |
2275 | if (atomic_read(&memcg->oom_wakeups) == current->memcg_oom.wakeups) | 2226 | |
2227 | locked = mem_cgroup_oom_trylock(memcg); | ||
2228 | |||
2229 | if (locked) | ||
2230 | mem_cgroup_oom_notify(memcg); | ||
2231 | |||
2232 | if (locked && !memcg->oom_kill_disable) { | ||
2233 | mem_cgroup_unmark_under_oom(memcg); | ||
2234 | finish_wait(&memcg_oom_waitq, &owait.wait); | ||
2235 | mem_cgroup_out_of_memory(memcg, current->memcg_oom.gfp_mask, | ||
2236 | current->memcg_oom.order); | ||
2237 | } else { | ||
2276 | schedule(); | 2238 | schedule(); |
2277 | finish_wait(&memcg_oom_waitq, &owait.wait); | 2239 | mem_cgroup_unmark_under_oom(memcg); |
2278 | out_memcg: | 2240 | finish_wait(&memcg_oom_waitq, &owait.wait); |
2279 | mem_cgroup_unmark_under_oom(memcg); | 2241 | } |
2280 | if (current->memcg_oom.oom_locked) { | 2242 | |
2243 | if (locked) { | ||
2281 | mem_cgroup_oom_unlock(memcg); | 2244 | mem_cgroup_oom_unlock(memcg); |
2282 | /* | 2245 | /* |
2283 | * There is no guarantee that an OOM-lock contender | 2246 | * There is no guarantee that an OOM-lock contender |
@@ -2286,10 +2249,9 @@ out_memcg: | |||
2286 | */ | 2249 | */ |
2287 | memcg_oom_recover(memcg); | 2250 | memcg_oom_recover(memcg); |
2288 | } | 2251 | } |
2252 | cleanup: | ||
2253 | current->memcg_oom.memcg = NULL; | ||
2289 | css_put(&memcg->css); | 2254 | css_put(&memcg->css); |
2290 | current->memcg_oom.wait_on_memcg = NULL; | ||
2291 | out: | ||
2292 | current->memcg_oom.in_memcg_oom = 0; | ||
2293 | return true; | 2255 | return true; |
2294 | } | 2256 | } |
2295 | 2257 | ||
@@ -2703,6 +2665,9 @@ static int __mem_cgroup_try_charge(struct mm_struct *mm, | |||
2703 | || fatal_signal_pending(current))) | 2665 | || fatal_signal_pending(current))) |
2704 | goto bypass; | 2666 | goto bypass; |
2705 | 2667 | ||
2668 | if (unlikely(task_in_memcg_oom(current))) | ||
2669 | goto bypass; | ||
2670 | |||
2706 | /* | 2671 | /* |
2707 | * We always charge the cgroup the mm_struct belongs to. | 2672 | * We always charge the cgroup the mm_struct belongs to. |
2708 | * The mm_struct's mem_cgroup changes on task migration if the | 2673 | * The mm_struct's mem_cgroup changes on task migration if the |
@@ -2801,6 +2766,8 @@ done: | |||
2801 | return 0; | 2766 | return 0; |
2802 | nomem: | 2767 | nomem: |
2803 | *ptr = NULL; | 2768 | *ptr = NULL; |
2769 | if (gfp_mask & __GFP_NOFAIL) | ||
2770 | return 0; | ||
2804 | return -ENOMEM; | 2771 | return -ENOMEM; |
2805 | bypass: | 2772 | bypass: |
2806 | *ptr = root_mem_cgroup; | 2773 | *ptr = root_mem_cgroup; |
diff --git a/mm/memory.c b/mm/memory.c index ca0003947115..1311f26497e6 100644 --- a/mm/memory.c +++ b/mm/memory.c | |||
@@ -837,6 +837,8 @@ copy_one_pte(struct mm_struct *dst_mm, struct mm_struct *src_mm, | |||
837 | */ | 837 | */ |
838 | make_migration_entry_read(&entry); | 838 | make_migration_entry_read(&entry); |
839 | pte = swp_entry_to_pte(entry); | 839 | pte = swp_entry_to_pte(entry); |
840 | if (pte_swp_soft_dirty(*src_pte)) | ||
841 | pte = pte_swp_mksoft_dirty(pte); | ||
840 | set_pte_at(src_mm, addr, src_pte, pte); | 842 | set_pte_at(src_mm, addr, src_pte, pte); |
841 | } | 843 | } |
842 | } | 844 | } |
@@ -3863,15 +3865,21 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma, | |||
3863 | * space. Kernel faults are handled more gracefully. | 3865 | * space. Kernel faults are handled more gracefully. |
3864 | */ | 3866 | */ |
3865 | if (flags & FAULT_FLAG_USER) | 3867 | if (flags & FAULT_FLAG_USER) |
3866 | mem_cgroup_enable_oom(); | 3868 | mem_cgroup_oom_enable(); |
3867 | 3869 | ||
3868 | ret = __handle_mm_fault(mm, vma, address, flags); | 3870 | ret = __handle_mm_fault(mm, vma, address, flags); |
3869 | 3871 | ||
3870 | if (flags & FAULT_FLAG_USER) | 3872 | if (flags & FAULT_FLAG_USER) { |
3871 | mem_cgroup_disable_oom(); | 3873 | mem_cgroup_oom_disable(); |
3872 | 3874 | /* | |
3873 | if (WARN_ON(task_in_memcg_oom(current) && !(ret & VM_FAULT_OOM))) | 3875 | * The task may have entered a memcg OOM situation but |
3874 | mem_cgroup_oom_synchronize(); | 3876 | * if the allocation error was handled gracefully (no |
3877 | * VM_FAULT_OOM), there is no need to kill anything. | ||
3878 | * Just clean up the OOM state peacefully. | ||
3879 | */ | ||
3880 | if (task_in_memcg_oom(current) && !(ret & VM_FAULT_OOM)) | ||
3881 | mem_cgroup_oom_synchronize(false); | ||
3882 | } | ||
3875 | 3883 | ||
3876 | return ret; | 3884 | return ret; |
3877 | } | 3885 | } |
diff --git a/mm/migrate.c b/mm/migrate.c index a26bccd44ccb..7a7325ee1d08 100644 --- a/mm/migrate.c +++ b/mm/migrate.c | |||
@@ -161,6 +161,8 @@ static int remove_migration_pte(struct page *new, struct vm_area_struct *vma, | |||
161 | 161 | ||
162 | get_page(new); | 162 | get_page(new); |
163 | pte = pte_mkold(mk_pte(new, vma->vm_page_prot)); | 163 | pte = pte_mkold(mk_pte(new, vma->vm_page_prot)); |
164 | if (pte_swp_soft_dirty(*ptep)) | ||
165 | pte = pte_mksoft_dirty(pte); | ||
164 | if (is_write_migration_entry(entry)) | 166 | if (is_write_migration_entry(entry)) |
165 | pte = pte_mkwrite(pte); | 167 | pte = pte_mkwrite(pte); |
166 | #ifdef CONFIG_HUGETLB_PAGE | 168 | #ifdef CONFIG_HUGETLB_PAGE |
diff --git a/mm/mprotect.c b/mm/mprotect.c index 94722a4d6b43..a3af058f68e4 100644 --- a/mm/mprotect.c +++ b/mm/mprotect.c | |||
@@ -94,13 +94,16 @@ static unsigned long change_pte_range(struct vm_area_struct *vma, pmd_t *pmd, | |||
94 | swp_entry_t entry = pte_to_swp_entry(oldpte); | 94 | swp_entry_t entry = pte_to_swp_entry(oldpte); |
95 | 95 | ||
96 | if (is_write_migration_entry(entry)) { | 96 | if (is_write_migration_entry(entry)) { |
97 | pte_t newpte; | ||
97 | /* | 98 | /* |
98 | * A protection check is difficult so | 99 | * A protection check is difficult so |
99 | * just be safe and disable write | 100 | * just be safe and disable write |
100 | */ | 101 | */ |
101 | make_migration_entry_read(&entry); | 102 | make_migration_entry_read(&entry); |
102 | set_pte_at(mm, addr, pte, | 103 | newpte = swp_entry_to_pte(entry); |
103 | swp_entry_to_pte(entry)); | 104 | if (pte_swp_soft_dirty(oldpte)) |
105 | newpte = pte_swp_mksoft_dirty(newpte); | ||
106 | set_pte_at(mm, addr, pte, newpte); | ||
104 | } | 107 | } |
105 | pages++; | 108 | pages++; |
106 | } | 109 | } |
diff --git a/mm/mremap.c b/mm/mremap.c index 91b13d6a16d4..0843feb66f3d 100644 --- a/mm/mremap.c +++ b/mm/mremap.c | |||
@@ -25,7 +25,6 @@ | |||
25 | #include <asm/uaccess.h> | 25 | #include <asm/uaccess.h> |
26 | #include <asm/cacheflush.h> | 26 | #include <asm/cacheflush.h> |
27 | #include <asm/tlbflush.h> | 27 | #include <asm/tlbflush.h> |
28 | #include <asm/pgalloc.h> | ||
29 | 28 | ||
30 | #include "internal.h" | 29 | #include "internal.h" |
31 | 30 | ||
@@ -63,10 +62,8 @@ static pmd_t *alloc_new_pmd(struct mm_struct *mm, struct vm_area_struct *vma, | |||
63 | return NULL; | 62 | return NULL; |
64 | 63 | ||
65 | pmd = pmd_alloc(mm, pud, addr); | 64 | pmd = pmd_alloc(mm, pud, addr); |
66 | if (!pmd) { | 65 | if (!pmd) |
67 | pud_free(mm, pud); | ||
68 | return NULL; | 66 | return NULL; |
69 | } | ||
70 | 67 | ||
71 | VM_BUG_ON(pmd_trans_huge(*pmd)); | 68 | VM_BUG_ON(pmd_trans_huge(*pmd)); |
72 | 69 | ||
diff --git a/mm/oom_kill.c b/mm/oom_kill.c index 314e9d274381..6738c47f1f72 100644 --- a/mm/oom_kill.c +++ b/mm/oom_kill.c | |||
@@ -680,7 +680,7 @@ void pagefault_out_of_memory(void) | |||
680 | { | 680 | { |
681 | struct zonelist *zonelist; | 681 | struct zonelist *zonelist; |
682 | 682 | ||
683 | if (mem_cgroup_oom_synchronize()) | 683 | if (mem_cgroup_oom_synchronize(true)) |
684 | return; | 684 | return; |
685 | 685 | ||
686 | zonelist = node_zonelist(first_online_node, GFP_KERNEL); | 686 | zonelist = node_zonelist(first_online_node, GFP_KERNEL); |
diff --git a/mm/page-writeback.c b/mm/page-writeback.c index f5236f804aa6..63807583d8e8 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c | |||
@@ -1210,11 +1210,11 @@ static unsigned long dirty_poll_interval(unsigned long dirty, | |||
1210 | return 1; | 1210 | return 1; |
1211 | } | 1211 | } |
1212 | 1212 | ||
1213 | static long bdi_max_pause(struct backing_dev_info *bdi, | 1213 | static unsigned long bdi_max_pause(struct backing_dev_info *bdi, |
1214 | unsigned long bdi_dirty) | 1214 | unsigned long bdi_dirty) |
1215 | { | 1215 | { |
1216 | long bw = bdi->avg_write_bandwidth; | 1216 | unsigned long bw = bdi->avg_write_bandwidth; |
1217 | long t; | 1217 | unsigned long t; |
1218 | 1218 | ||
1219 | /* | 1219 | /* |
1220 | * Limit pause time for small memory systems. If sleeping for too long | 1220 | * Limit pause time for small memory systems. If sleeping for too long |
@@ -1226,7 +1226,7 @@ static long bdi_max_pause(struct backing_dev_info *bdi, | |||
1226 | t = bdi_dirty / (1 + bw / roundup_pow_of_two(1 + HZ / 8)); | 1226 | t = bdi_dirty / (1 + bw / roundup_pow_of_two(1 + HZ / 8)); |
1227 | t++; | 1227 | t++; |
1228 | 1228 | ||
1229 | return min_t(long, t, MAX_PAUSE); | 1229 | return min_t(unsigned long, t, MAX_PAUSE); |
1230 | } | 1230 | } |
1231 | 1231 | ||
1232 | static long bdi_min_pause(struct backing_dev_info *bdi, | 1232 | static long bdi_min_pause(struct backing_dev_info *bdi, |
diff --git a/mm/slab_common.c b/mm/slab_common.c index a3443278ce3a..e2e98af703ea 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c | |||
@@ -56,6 +56,7 @@ static int kmem_cache_sanity_check(struct mem_cgroup *memcg, const char *name, | |||
56 | continue; | 56 | continue; |
57 | } | 57 | } |
58 | 58 | ||
59 | #if !defined(CONFIG_SLUB) || !defined(CONFIG_SLUB_DEBUG_ON) | ||
59 | /* | 60 | /* |
60 | * For simplicity, we won't check this in the list of memcg | 61 | * For simplicity, we won't check this in the list of memcg |
61 | * caches. We have control over memcg naming, and if there | 62 | * caches. We have control over memcg naming, and if there |
@@ -69,6 +70,7 @@ static int kmem_cache_sanity_check(struct mem_cgroup *memcg, const char *name, | |||
69 | s = NULL; | 70 | s = NULL; |
70 | return -EINVAL; | 71 | return -EINVAL; |
71 | } | 72 | } |
73 | #endif | ||
72 | } | 74 | } |
73 | 75 | ||
74 | WARN_ON(strchr(name, ' ')); /* It confuses parsers */ | 76 | WARN_ON(strchr(name, ' ')); /* It confuses parsers */ |
diff --git a/mm/swapfile.c b/mm/swapfile.c index 3963fc24fcc1..de7c904e52e5 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c | |||
@@ -1824,6 +1824,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile) | |||
1824 | struct filename *pathname; | 1824 | struct filename *pathname; |
1825 | int i, type, prev; | 1825 | int i, type, prev; |
1826 | int err; | 1826 | int err; |
1827 | unsigned int old_block_size; | ||
1827 | 1828 | ||
1828 | if (!capable(CAP_SYS_ADMIN)) | 1829 | if (!capable(CAP_SYS_ADMIN)) |
1829 | return -EPERM; | 1830 | return -EPERM; |
@@ -1914,6 +1915,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile) | |||
1914 | } | 1915 | } |
1915 | 1916 | ||
1916 | swap_file = p->swap_file; | 1917 | swap_file = p->swap_file; |
1918 | old_block_size = p->old_block_size; | ||
1917 | p->swap_file = NULL; | 1919 | p->swap_file = NULL; |
1918 | p->max = 0; | 1920 | p->max = 0; |
1919 | swap_map = p->swap_map; | 1921 | swap_map = p->swap_map; |
@@ -1938,7 +1940,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile) | |||
1938 | inode = mapping->host; | 1940 | inode = mapping->host; |
1939 | if (S_ISBLK(inode->i_mode)) { | 1941 | if (S_ISBLK(inode->i_mode)) { |
1940 | struct block_device *bdev = I_BDEV(inode); | 1942 | struct block_device *bdev = I_BDEV(inode); |
1941 | set_blocksize(bdev, p->old_block_size); | 1943 | set_blocksize(bdev, old_block_size); |
1942 | blkdev_put(bdev, FMODE_READ | FMODE_WRITE | FMODE_EXCL); | 1944 | blkdev_put(bdev, FMODE_READ | FMODE_WRITE | FMODE_EXCL); |
1943 | } else { | 1945 | } else { |
1944 | mutex_lock(&inode->i_mutex); | 1946 | mutex_lock(&inode->i_mutex); |
diff --git a/mm/vmscan.c b/mm/vmscan.c index 53f2f82f83ae..eea668d9cff6 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c | |||
@@ -211,6 +211,7 @@ void unregister_shrinker(struct shrinker *shrinker) | |||
211 | down_write(&shrinker_rwsem); | 211 | down_write(&shrinker_rwsem); |
212 | list_del(&shrinker->list); | 212 | list_del(&shrinker->list); |
213 | up_write(&shrinker_rwsem); | 213 | up_write(&shrinker_rwsem); |
214 | kfree(shrinker->nr_deferred); | ||
214 | } | 215 | } |
215 | EXPORT_SYMBOL(unregister_shrinker); | 216 | EXPORT_SYMBOL(unregister_shrinker); |
216 | 217 | ||
diff --git a/mm/zswap.c b/mm/zswap.c index 841e35f1db22..d93510c6aa2d 100644 --- a/mm/zswap.c +++ b/mm/zswap.c | |||
@@ -804,6 +804,10 @@ static void zswap_frontswap_invalidate_area(unsigned type) | |||
804 | } | 804 | } |
805 | tree->rbroot = RB_ROOT; | 805 | tree->rbroot = RB_ROOT; |
806 | spin_unlock(&tree->lock); | 806 | spin_unlock(&tree->lock); |
807 | |||
808 | zbud_destroy_pool(tree->pool); | ||
809 | kfree(tree); | ||
810 | zswap_trees[type] = NULL; | ||
807 | } | 811 | } |
808 | 812 | ||
809 | static struct zbud_ops zswap_zbud_ops = { | 813 | static struct zbud_ops zswap_zbud_ops = { |
diff --git a/security/apparmor/apparmorfs.c b/security/apparmor/apparmorfs.c index 95c2b2689a03..7db9954f1af2 100644 --- a/security/apparmor/apparmorfs.c +++ b/security/apparmor/apparmorfs.c | |||
@@ -580,15 +580,13 @@ static struct aa_namespace *__next_namespace(struct aa_namespace *root, | |||
580 | 580 | ||
581 | /* check if the next ns is a sibling, parent, gp, .. */ | 581 | /* check if the next ns is a sibling, parent, gp, .. */ |
582 | parent = ns->parent; | 582 | parent = ns->parent; |
583 | while (parent) { | 583 | while (ns != root) { |
584 | mutex_unlock(&ns->lock); | 584 | mutex_unlock(&ns->lock); |
585 | next = list_entry_next(ns, base.list); | 585 | next = list_entry_next(ns, base.list); |
586 | if (!list_entry_is_head(next, &parent->sub_ns, base.list)) { | 586 | if (!list_entry_is_head(next, &parent->sub_ns, base.list)) { |
587 | mutex_lock(&next->lock); | 587 | mutex_lock(&next->lock); |
588 | return next; | 588 | return next; |
589 | } | 589 | } |
590 | if (parent == root) | ||
591 | return NULL; | ||
592 | ns = parent; | 590 | ns = parent; |
593 | parent = parent->parent; | 591 | parent = parent->parent; |
594 | } | 592 | } |
diff --git a/security/apparmor/policy.c b/security/apparmor/policy.c index 345bec07a27d..705c2879d3a9 100644 --- a/security/apparmor/policy.c +++ b/security/apparmor/policy.c | |||
@@ -610,6 +610,7 @@ void aa_free_profile(struct aa_profile *profile) | |||
610 | aa_put_dfa(profile->policy.dfa); | 610 | aa_put_dfa(profile->policy.dfa); |
611 | aa_put_replacedby(profile->replacedby); | 611 | aa_put_replacedby(profile->replacedby); |
612 | 612 | ||
613 | kzfree(profile->hash); | ||
613 | kzfree(profile); | 614 | kzfree(profile); |
614 | } | 615 | } |
615 | 616 | ||
diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c index ac41e9cdc976..26ad4f0aade3 100644 --- a/sound/pci/hda/hda_generic.c +++ b/sound/pci/hda/hda_generic.c | |||
@@ -3531,7 +3531,7 @@ static int create_capture_mixers(struct hda_codec *codec) | |||
3531 | if (!multi) | 3531 | if (!multi) |
3532 | err = create_single_cap_vol_ctl(codec, n, vol, sw, | 3532 | err = create_single_cap_vol_ctl(codec, n, vol, sw, |
3533 | inv_dmic); | 3533 | inv_dmic); |
3534 | else if (!multi_cap_vol) | 3534 | else if (!multi_cap_vol && !inv_dmic) |
3535 | err = create_bind_cap_vol_ctl(codec, n, vol, sw); | 3535 | err = create_bind_cap_vol_ctl(codec, n, vol, sw); |
3536 | else | 3536 | else |
3537 | err = create_multi_cap_vol_ctl(codec); | 3537 | err = create_multi_cap_vol_ctl(codec); |
diff --git a/sound/pci/rme9652/hdsp.c b/sound/pci/rme9652/hdsp.c index 4f255dfee450..f59a321a6d6a 100644 --- a/sound/pci/rme9652/hdsp.c +++ b/sound/pci/rme9652/hdsp.c | |||
@@ -4845,6 +4845,7 @@ static int snd_hdsp_hwdep_ioctl(struct snd_hwdep *hw, struct file *file, unsigne | |||
4845 | if ((err = hdsp_get_iobox_version(hdsp)) < 0) | 4845 | if ((err = hdsp_get_iobox_version(hdsp)) < 0) |
4846 | return err; | 4846 | return err; |
4847 | } | 4847 | } |
4848 | memset(&hdsp_version, 0, sizeof(hdsp_version)); | ||
4848 | hdsp_version.io_type = hdsp->io_type; | 4849 | hdsp_version.io_type = hdsp->io_type; |
4849 | hdsp_version.firmware_rev = hdsp->firmware_rev; | 4850 | hdsp_version.firmware_rev = hdsp->firmware_rev; |
4850 | if ((err = copy_to_user(argp, &hdsp_version, sizeof(hdsp_version)))) | 4851 | if ((err = copy_to_user(argp, &hdsp_version, sizeof(hdsp_version)))) |
diff --git a/sound/usb/usx2y/us122l.c b/sound/usb/usx2y/us122l.c index d0323a693ba2..999550bbad40 100644 --- a/sound/usb/usx2y/us122l.c +++ b/sound/usb/usx2y/us122l.c | |||
@@ -262,7 +262,9 @@ static int usb_stream_hwdep_mmap(struct snd_hwdep *hw, | |||
262 | } | 262 | } |
263 | 263 | ||
264 | area->vm_ops = &usb_stream_hwdep_vm_ops; | 264 | area->vm_ops = &usb_stream_hwdep_vm_ops; |
265 | area->vm_flags |= VM_DONTEXPAND | VM_DONTDUMP; | 265 | area->vm_flags |= VM_DONTDUMP; |
266 | if (!read) | ||
267 | area->vm_flags |= VM_DONTEXPAND; | ||
266 | area->vm_private_data = us122l; | 268 | area->vm_private_data = us122l; |
267 | atomic_inc(&us122l->mmap_count); | 269 | atomic_inc(&us122l->mmap_count); |
268 | out: | 270 | out: |
diff --git a/tools/testing/selftests/timers/posix_timers.c b/tools/testing/selftests/timers/posix_timers.c index 4fa655d68a81..41bd85559d4b 100644 --- a/tools/testing/selftests/timers/posix_timers.c +++ b/tools/testing/selftests/timers/posix_timers.c | |||
@@ -151,7 +151,7 @@ static int check_timer_create(int which) | |||
151 | fflush(stdout); | 151 | fflush(stdout); |
152 | 152 | ||
153 | done = 0; | 153 | done = 0; |
154 | timer_create(which, NULL, &id); | 154 | err = timer_create(which, NULL, &id); |
155 | if (err < 0) { | 155 | if (err < 0) { |
156 | perror("Can't create timer\n"); | 156 | perror("Can't create timer\n"); |
157 | return -1; | 157 | return -1; |