aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2016-06-30 12:44:34 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-06-30 12:44:34 -0400
commit4aa34ce3c1ee86ee6abbe9adc310e5f8bcca2800 (patch)
treec616d8408f4962ced44a1dc3d8d04827997f3cf8
parente7bdea7750eb2a64aea4a08fa5c0a31719c8155d (diff)
parentba4a1c28a92df55b9263e838068b92eaa80c7850 (diff)
Merge tag 'mfd-fixes-4.7' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd
Pull MFD fixes from Lee Jones: "Contained are some standard fixes and unusually an extension to the Reset API. Some of those changes are required to fix a bug introduced in -rc1, which introduces extra 'reset line checks' i.e. whether the line is shared or not. If a line is shared and the new *_shared() API is not used, the request fails with an error. This breaks USB in v4.7 for ST's platforms. Admittedly, there are some patches contained in our (MFD/Reset) immutable branch which are not true -fixes, but there isn't anything I can do about that. Rest assured though, there aren't any API 'changes'. Everything is the same from the consumer's perspective. - Use new reset_*_get_shared() variant to prevent reset line obtainment failure (Fixes commit 0b52297f2288: "reset: Add support for shared reset controls") - Fix unintentional switch() fall-through into error path - Fix uninitialised variable compiler warning" * tag 'mfd-fixes-4.7' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd: mfd: da9053: Fix compiler warning message for uninitialised variable mfd: max77620: Fix FPS switch statements phy: phy-stih407-usb: Inform the reset framework that our reset line may be shared usb: dwc3: st: Inform the reset framework that our reset line may be shared usb: host: ehci-st: Inform the reset framework that our reset line may be shared usb: host: ohci-st: Inform the reset framework that our reset line may be shared reset: TRIVIAL: Add line break at same place for similar APIs reset: Supply *_shared variant calls when using *_optional APIs reset: Supply *_shared variant calls when using of_* API reset: Ensure drivers are explicit when requesting reset lines reset: Reorder inline reset_control_get*() wrappers
-rw-r--r--drivers/mfd/max77620.c2
-rw-r--r--drivers/phy/phy-stih407-usb.c2
-rw-r--r--drivers/usb/dwc3/dwc3-st.c3
-rw-r--r--drivers/usb/host/ehci-st.c6
-rw-r--r--drivers/usb/host/ohci-st.c6
-rw-r--r--include/linux/mfd/da9052/da9052.h2
-rw-r--r--include/linux/reset.h211
7 files changed, 181 insertions, 51 deletions
diff --git a/drivers/mfd/max77620.c b/drivers/mfd/max77620.c
index 199d261990be..f32fbb8e8129 100644
--- a/drivers/mfd/max77620.c
+++ b/drivers/mfd/max77620.c
@@ -203,6 +203,7 @@ static int max77620_get_fps_period_reg_value(struct max77620_chip *chip,
203 break; 203 break;
204 case MAX77620: 204 case MAX77620:
205 fps_min_period = MAX77620_FPS_PERIOD_MIN_US; 205 fps_min_period = MAX77620_FPS_PERIOD_MIN_US;
206 break;
206 default: 207 default:
207 return -EINVAL; 208 return -EINVAL;
208 } 209 }
@@ -236,6 +237,7 @@ static int max77620_config_fps(struct max77620_chip *chip,
236 break; 237 break;
237 case MAX77620: 238 case MAX77620:
238 fps_max_period = MAX77620_FPS_PERIOD_MAX_US; 239 fps_max_period = MAX77620_FPS_PERIOD_MAX_US;
240 break;
239 default: 241 default:
240 return -EINVAL; 242 return -EINVAL;
241 } 243 }
diff --git a/drivers/phy/phy-stih407-usb.c b/drivers/phy/phy-stih407-usb.c
index 1d5ae5f8ef69..53cf8d1b4116 100644
--- a/drivers/phy/phy-stih407-usb.c
+++ b/drivers/phy/phy-stih407-usb.c
@@ -105,7 +105,7 @@ static int stih407_usb2_picophy_probe(struct platform_device *pdev)
105 phy_dev->dev = dev; 105 phy_dev->dev = dev;
106 dev_set_drvdata(dev, phy_dev); 106 dev_set_drvdata(dev, phy_dev);
107 107
108 phy_dev->rstc = devm_reset_control_get(dev, "global"); 108 phy_dev->rstc = devm_reset_control_get_shared(dev, "global");
109 if (IS_ERR(phy_dev->rstc)) { 109 if (IS_ERR(phy_dev->rstc)) {
110 dev_err(dev, "failed to ctrl picoPHY reset\n"); 110 dev_err(dev, "failed to ctrl picoPHY reset\n");
111 return PTR_ERR(phy_dev->rstc); 111 return PTR_ERR(phy_dev->rstc);
diff --git a/drivers/usb/dwc3/dwc3-st.c b/drivers/usb/dwc3/dwc3-st.c
index 50d6ae6f88bc..055c55b0fb54 100644
--- a/drivers/usb/dwc3/dwc3-st.c
+++ b/drivers/usb/dwc3/dwc3-st.c
@@ -243,7 +243,8 @@ static int st_dwc3_probe(struct platform_device *pdev)
243 /* Manage PowerDown */ 243 /* Manage PowerDown */
244 reset_control_deassert(dwc3_data->rstc_pwrdn); 244 reset_control_deassert(dwc3_data->rstc_pwrdn);
245 245
246 dwc3_data->rstc_rst = devm_reset_control_get(dev, "softreset"); 246 dwc3_data->rstc_rst =
247 devm_reset_control_get_shared(dev, "softreset");
247 if (IS_ERR(dwc3_data->rstc_rst)) { 248 if (IS_ERR(dwc3_data->rstc_rst)) {
248 dev_err(&pdev->dev, "could not get reset controller\n"); 249 dev_err(&pdev->dev, "could not get reset controller\n");
249 ret = PTR_ERR(dwc3_data->rstc_rst); 250 ret = PTR_ERR(dwc3_data->rstc_rst);
diff --git a/drivers/usb/host/ehci-st.c b/drivers/usb/host/ehci-st.c
index a94ed677d937..be4a2788fc58 100644
--- a/drivers/usb/host/ehci-st.c
+++ b/drivers/usb/host/ehci-st.c
@@ -206,7 +206,8 @@ static int st_ehci_platform_probe(struct platform_device *dev)
206 priv->clk48 = NULL; 206 priv->clk48 = NULL;
207 } 207 }
208 208
209 priv->pwr = devm_reset_control_get_optional(&dev->dev, "power"); 209 priv->pwr =
210 devm_reset_control_get_optional_shared(&dev->dev, "power");
210 if (IS_ERR(priv->pwr)) { 211 if (IS_ERR(priv->pwr)) {
211 err = PTR_ERR(priv->pwr); 212 err = PTR_ERR(priv->pwr);
212 if (err == -EPROBE_DEFER) 213 if (err == -EPROBE_DEFER)
@@ -214,7 +215,8 @@ static int st_ehci_platform_probe(struct platform_device *dev)
214 priv->pwr = NULL; 215 priv->pwr = NULL;
215 } 216 }
216 217
217 priv->rst = devm_reset_control_get_optional(&dev->dev, "softreset"); 218 priv->rst =
219 devm_reset_control_get_optional_shared(&dev->dev, "softreset");
218 if (IS_ERR(priv->rst)) { 220 if (IS_ERR(priv->rst)) {
219 err = PTR_ERR(priv->rst); 221 err = PTR_ERR(priv->rst);
220 if (err == -EPROBE_DEFER) 222 if (err == -EPROBE_DEFER)
diff --git a/drivers/usb/host/ohci-st.c b/drivers/usb/host/ohci-st.c
index acf2eb2a5676..02816a1515a1 100644
--- a/drivers/usb/host/ohci-st.c
+++ b/drivers/usb/host/ohci-st.c
@@ -188,13 +188,15 @@ static int st_ohci_platform_probe(struct platform_device *dev)
188 priv->clk48 = NULL; 188 priv->clk48 = NULL;
189 } 189 }
190 190
191 priv->pwr = devm_reset_control_get_optional(&dev->dev, "power"); 191 priv->pwr =
192 devm_reset_control_get_optional_shared(&dev->dev, "power");
192 if (IS_ERR(priv->pwr)) { 193 if (IS_ERR(priv->pwr)) {
193 err = PTR_ERR(priv->pwr); 194 err = PTR_ERR(priv->pwr);
194 goto err_put_clks; 195 goto err_put_clks;
195 } 196 }
196 197
197 priv->rst = devm_reset_control_get_optional(&dev->dev, "softreset"); 198 priv->rst =
199 devm_reset_control_get_optional_shared(&dev->dev, "softreset");
198 if (IS_ERR(priv->rst)) { 200 if (IS_ERR(priv->rst)) {
199 err = PTR_ERR(priv->rst); 201 err = PTR_ERR(priv->rst);
200 goto err_put_clks; 202 goto err_put_clks;
diff --git a/include/linux/mfd/da9052/da9052.h b/include/linux/mfd/da9052/da9052.h
index c18a4c19d6fc..ce9230af09c2 100644
--- a/include/linux/mfd/da9052/da9052.h
+++ b/include/linux/mfd/da9052/da9052.h
@@ -171,7 +171,7 @@ static inline int da9052_group_read(struct da9052 *da9052, unsigned char reg,
171static inline int da9052_group_write(struct da9052 *da9052, unsigned char reg, 171static inline int da9052_group_write(struct da9052 *da9052, unsigned char reg,
172 unsigned reg_cnt, unsigned char *val) 172 unsigned reg_cnt, unsigned char *val)
173{ 173{
174 int ret; 174 int ret = 0;
175 int i; 175 int i;
176 176
177 for (i = 0; i < reg_cnt; i++) { 177 for (i = 0; i < reg_cnt; i++) {
diff --git a/include/linux/reset.h b/include/linux/reset.h
index ec0306ce7b92..45a4abeb6acb 100644
--- a/include/linux/reset.h
+++ b/include/linux/reset.h
@@ -84,8 +84,8 @@ static inline struct reset_control *__devm_reset_control_get(
84#endif /* CONFIG_RESET_CONTROLLER */ 84#endif /* CONFIG_RESET_CONTROLLER */
85 85
86/** 86/**
87 * reset_control_get - Lookup and obtain an exclusive reference to a 87 * reset_control_get_exclusive - Lookup and obtain an exclusive reference
88 * reset controller. 88 * to a reset controller.
89 * @dev: device to be reset by the controller 89 * @dev: device to be reset by the controller
90 * @id: reset line name 90 * @id: reset line name
91 * 91 *
@@ -98,8 +98,8 @@ static inline struct reset_control *__devm_reset_control_get(
98 * 98 *
99 * Use of id names is optional. 99 * Use of id names is optional.
100 */ 100 */
101static inline struct reset_control *__must_check reset_control_get( 101static inline struct reset_control *
102 struct device *dev, const char *id) 102__must_check reset_control_get_exclusive(struct device *dev, const char *id)
103{ 103{
104#ifndef CONFIG_RESET_CONTROLLER 104#ifndef CONFIG_RESET_CONTROLLER
105 WARN_ON(1); 105 WARN_ON(1);
@@ -107,12 +107,6 @@ static inline struct reset_control *__must_check reset_control_get(
107 return __of_reset_control_get(dev ? dev->of_node : NULL, id, 0, 0); 107 return __of_reset_control_get(dev ? dev->of_node : NULL, id, 0, 0);
108} 108}
109 109
110static inline struct reset_control *reset_control_get_optional(
111 struct device *dev, const char *id)
112{
113 return __of_reset_control_get(dev ? dev->of_node : NULL, id, 0, 0);
114}
115
116/** 110/**
117 * reset_control_get_shared - Lookup and obtain a shared reference to a 111 * reset_control_get_shared - Lookup and obtain a shared reference to a
118 * reset controller. 112 * reset controller.
@@ -141,9 +135,21 @@ static inline struct reset_control *reset_control_get_shared(
141 return __of_reset_control_get(dev ? dev->of_node : NULL, id, 0, 1); 135 return __of_reset_control_get(dev ? dev->of_node : NULL, id, 0, 1);
142} 136}
143 137
138static inline struct reset_control *reset_control_get_optional_exclusive(
139 struct device *dev, const char *id)
140{
141 return __of_reset_control_get(dev ? dev->of_node : NULL, id, 0, 0);
142}
143
144static inline struct reset_control *reset_control_get_optional_shared(
145 struct device *dev, const char *id)
146{
147 return __of_reset_control_get(dev ? dev->of_node : NULL, id, 0, 1);
148}
149
144/** 150/**
145 * of_reset_control_get - Lookup and obtain an exclusive reference to a 151 * of_reset_control_get_exclusive - Lookup and obtain an exclusive reference
146 * reset controller. 152 * to a reset controller.
147 * @node: device to be reset by the controller 153 * @node: device to be reset by the controller
148 * @id: reset line name 154 * @id: reset line name
149 * 155 *
@@ -151,15 +157,41 @@ static inline struct reset_control *reset_control_get_shared(
151 * 157 *
152 * Use of id names is optional. 158 * Use of id names is optional.
153 */ 159 */
154static inline struct reset_control *of_reset_control_get( 160static inline struct reset_control *of_reset_control_get_exclusive(
155 struct device_node *node, const char *id) 161 struct device_node *node, const char *id)
156{ 162{
157 return __of_reset_control_get(node, id, 0, 0); 163 return __of_reset_control_get(node, id, 0, 0);
158} 164}
159 165
160/** 166/**
161 * of_reset_control_get_by_index - Lookup and obtain an exclusive reference to 167 * of_reset_control_get_shared - Lookup and obtain an shared reference
162 * a reset controller by index. 168 * to a reset controller.
169 * @node: device to be reset by the controller
170 * @id: reset line name
171 *
172 * When a reset-control is shared, the behavior of reset_control_assert /
173 * deassert is changed, the reset-core will keep track of a deassert_count
174 * and only (re-)assert the reset after reset_control_assert has been called
175 * as many times as reset_control_deassert was called. Also see the remark
176 * about shared reset-controls in the reset_control_assert docs.
177 *
178 * Calling reset_control_assert without first calling reset_control_deassert
179 * is not allowed on a shared reset control. Calling reset_control_reset is
180 * also not allowed on a shared reset control.
181 * Returns a struct reset_control or IS_ERR() condition containing errno.
182 *
183 * Use of id names is optional.
184 */
185static inline struct reset_control *of_reset_control_get_shared(
186 struct device_node *node, const char *id)
187{
188 return __of_reset_control_get(node, id, 0, 1);
189}
190
191/**
192 * of_reset_control_get_exclusive_by_index - Lookup and obtain an exclusive
193 * reference to a reset controller
194 * by index.
163 * @node: device to be reset by the controller 195 * @node: device to be reset by the controller
164 * @index: index of the reset controller 196 * @index: index of the reset controller
165 * 197 *
@@ -167,49 +199,60 @@ static inline struct reset_control *of_reset_control_get(
167 * in whatever order. Returns a struct reset_control or IS_ERR() condition 199 * in whatever order. Returns a struct reset_control or IS_ERR() condition
168 * containing errno. 200 * containing errno.
169 */ 201 */
170static inline struct reset_control *of_reset_control_get_by_index( 202static inline struct reset_control *of_reset_control_get_exclusive_by_index(
171 struct device_node *node, int index) 203 struct device_node *node, int index)
172{ 204{
173 return __of_reset_control_get(node, NULL, index, 0); 205 return __of_reset_control_get(node, NULL, index, 0);
174} 206}
175 207
176/** 208/**
177 * devm_reset_control_get - resource managed reset_control_get() 209 * of_reset_control_get_shared_by_index - Lookup and obtain an shared
178 * @dev: device to be reset by the controller 210 * reference to a reset controller
179 * @id: reset line name 211 * by index.
212 * @node: device to be reset by the controller
213 * @index: index of the reset controller
214 *
215 * When a reset-control is shared, the behavior of reset_control_assert /
216 * deassert is changed, the reset-core will keep track of a deassert_count
217 * and only (re-)assert the reset after reset_control_assert has been called
218 * as many times as reset_control_deassert was called. Also see the remark
219 * about shared reset-controls in the reset_control_assert docs.
220 *
221 * Calling reset_control_assert without first calling reset_control_deassert
222 * is not allowed on a shared reset control. Calling reset_control_reset is
223 * also not allowed on a shared reset control.
224 * Returns a struct reset_control or IS_ERR() condition containing errno.
180 * 225 *
181 * Managed reset_control_get(). For reset controllers returned from this 226 * This is to be used to perform a list of resets for a device or power domain
182 * function, reset_control_put() is called automatically on driver detach. 227 * in whatever order. Returns a struct reset_control or IS_ERR() condition
183 * See reset_control_get() for more information. 228 * containing errno.
184 */ 229 */
185static inline struct reset_control *__must_check devm_reset_control_get( 230static inline struct reset_control *of_reset_control_get_shared_by_index(
186 struct device *dev, const char *id) 231 struct device_node *node, int index)
187{
188#ifndef CONFIG_RESET_CONTROLLER
189 WARN_ON(1);
190#endif
191 return __devm_reset_control_get(dev, id, 0, 0);
192}
193
194static inline struct reset_control *devm_reset_control_get_optional(
195 struct device *dev, const char *id)
196{ 232{
197 return __devm_reset_control_get(dev, id, 0, 0); 233 return __of_reset_control_get(node, NULL, index, 1);
198} 234}
199 235
200/** 236/**
201 * devm_reset_control_get_by_index - resource managed reset_control_get 237 * devm_reset_control_get_exclusive - resource managed
238 * reset_control_get_exclusive()
202 * @dev: device to be reset by the controller 239 * @dev: device to be reset by the controller
203 * @index: index of the reset controller 240 * @id: reset line name
204 * 241 *
205 * Managed reset_control_get(). For reset controllers returned from this 242 * Managed reset_control_get_exclusive(). For reset controllers returned
206 * function, reset_control_put() is called automatically on driver detach. 243 * from this function, reset_control_put() is called automatically on driver
207 * See reset_control_get() for more information. 244 * detach.
245 *
246 * See reset_control_get_exclusive() for more information.
208 */ 247 */
209static inline struct reset_control *devm_reset_control_get_by_index( 248static inline struct reset_control *
210 struct device *dev, int index) 249__must_check devm_reset_control_get_exclusive(struct device *dev,
250 const char *id)
211{ 251{
212 return __devm_reset_control_get(dev, NULL, index, 0); 252#ifndef CONFIG_RESET_CONTROLLER
253 WARN_ON(1);
254#endif
255 return __devm_reset_control_get(dev, id, 0, 0);
213} 256}
214 257
215/** 258/**
@@ -227,6 +270,36 @@ static inline struct reset_control *devm_reset_control_get_shared(
227 return __devm_reset_control_get(dev, id, 0, 1); 270 return __devm_reset_control_get(dev, id, 0, 1);
228} 271}
229 272
273static inline struct reset_control *devm_reset_control_get_optional_exclusive(
274 struct device *dev, const char *id)
275{
276 return __devm_reset_control_get(dev, id, 0, 0);
277}
278
279static inline struct reset_control *devm_reset_control_get_optional_shared(
280 struct device *dev, const char *id)
281{
282 return __devm_reset_control_get(dev, id, 0, 1);
283}
284
285/**
286 * devm_reset_control_get_exclusive_by_index - resource managed
287 * reset_control_get_exclusive()
288 * @dev: device to be reset by the controller
289 * @index: index of the reset controller
290 *
291 * Managed reset_control_get_exclusive(). For reset controllers returned from
292 * this function, reset_control_put() is called automatically on driver
293 * detach.
294 *
295 * See reset_control_get_exclusive() for more information.
296 */
297static inline struct reset_control *
298devm_reset_control_get_exclusive_by_index(struct device *dev, int index)
299{
300 return __devm_reset_control_get(dev, NULL, index, 0);
301}
302
230/** 303/**
231 * devm_reset_control_get_shared_by_index - resource managed 304 * devm_reset_control_get_shared_by_index - resource managed
232 * reset_control_get_shared 305 * reset_control_get_shared
@@ -237,10 +310,60 @@ static inline struct reset_control *devm_reset_control_get_shared(
237 * this function, reset_control_put() is called automatically on driver detach. 310 * this function, reset_control_put() is called automatically on driver detach.
238 * See reset_control_get_shared() for more information. 311 * See reset_control_get_shared() for more information.
239 */ 312 */
240static inline struct reset_control *devm_reset_control_get_shared_by_index( 313static inline struct reset_control *
241 struct device *dev, int index) 314devm_reset_control_get_shared_by_index(struct device *dev, int index)
242{ 315{
243 return __devm_reset_control_get(dev, NULL, index, 1); 316 return __devm_reset_control_get(dev, NULL, index, 1);
244} 317}
245 318
319/*
320 * TEMPORARY calls to use during transition:
321 *
322 * of_reset_control_get() => of_reset_control_get_exclusive()
323 *
324 * These inline function calls will be removed once all consumers
325 * have been moved over to the new explicit API.
326 */
327static inline struct reset_control *reset_control_get(
328 struct device *dev, const char *id)
329{
330 return reset_control_get_exclusive(dev, id);
331}
332
333static inline struct reset_control *reset_control_get_optional(
334 struct device *dev, const char *id)
335{
336 return reset_control_get_optional_exclusive(dev, id);
337}
338
339static inline struct reset_control *of_reset_control_get(
340 struct device_node *node, const char *id)
341{
342 return of_reset_control_get_exclusive(node, id);
343}
344
345static inline struct reset_control *of_reset_control_get_by_index(
346 struct device_node *node, int index)
347{
348 return of_reset_control_get_exclusive_by_index(node, index);
349}
350
351static inline struct reset_control *devm_reset_control_get(
352 struct device *dev, const char *id)
353{
354 return devm_reset_control_get_exclusive(dev, id);
355}
356
357static inline struct reset_control *devm_reset_control_get_optional(
358 struct device *dev, const char *id)
359{
360 return devm_reset_control_get_optional_exclusive(dev, id);
361
362}
363
364static inline struct reset_control *devm_reset_control_get_by_index(
365 struct device *dev, int index)
366{
367 return devm_reset_control_get_exclusive_by_index(dev, index);
368}
246#endif 369#endif