Skip to content

Commit d4ee21e

Browse files
committed
Merge tag 'reset-fixes-for-4.11-2' of git://git.pengutronix.de/git/pza/linux into fixes
Reset controller fixes for v4.11 Fix devm_reset_controller_get_optional to return NULL for non-DT devices, if the RESET_CONTROLLER Kconfig option is enabled. This fixes probe failures of the 8250_dw driver on Intel platforms after commit acbdad8 ("serial: 8250_dw: simplify optional reset handling"). * tag 'reset-fixes-for-4.11-2' of git://git.pengutronix.de/git/pza/linux: reset: add exported __reset_control_get, return NULL if optional Signed-off-by: Olof Johansson <olof@lixom.net>
2 parents 0fa974b + 62e24c5 commit d4ee21e

File tree

2 files changed

+30
-14
lines changed

2 files changed

+30
-14
lines changed

drivers/reset/core.c

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ int reset_control_status(struct reset_control *rstc)
275275
}
276276
EXPORT_SYMBOL_GPL(reset_control_status);
277277

278-
static struct reset_control *__reset_control_get(
278+
static struct reset_control *__reset_control_get_internal(
279279
struct reset_controller_dev *rcdev,
280280
unsigned int index, bool shared)
281281
{
@@ -308,7 +308,7 @@ static struct reset_control *__reset_control_get(
308308
return rstc;
309309
}
310310

311-
static void __reset_control_put(struct reset_control *rstc)
311+
static void __reset_control_put_internal(struct reset_control *rstc)
312312
{
313313
lockdep_assert_held(&reset_list_mutex);
314314

@@ -377,14 +377,25 @@ struct reset_control *__of_reset_control_get(struct device_node *node,
377377
}
378378

379379
/* reset_list_mutex also protects the rcdev's reset_control list */
380-
rstc = __reset_control_get(rcdev, rstc_id, shared);
380+
rstc = __reset_control_get_internal(rcdev, rstc_id, shared);
381381

382382
mutex_unlock(&reset_list_mutex);
383383

384384
return rstc;
385385
}
386386
EXPORT_SYMBOL_GPL(__of_reset_control_get);
387387

388+
struct reset_control *__reset_control_get(struct device *dev, const char *id,
389+
int index, bool shared, bool optional)
390+
{
391+
if (dev->of_node)
392+
return __of_reset_control_get(dev->of_node, id, index, shared,
393+
optional);
394+
395+
return optional ? NULL : ERR_PTR(-EINVAL);
396+
}
397+
EXPORT_SYMBOL_GPL(__reset_control_get);
398+
388399
/**
389400
* reset_control_put - free the reset controller
390401
* @rstc: reset controller
@@ -396,7 +407,7 @@ void reset_control_put(struct reset_control *rstc)
396407
return;
397408

398409
mutex_lock(&reset_list_mutex);
399-
__reset_control_put(rstc);
410+
__reset_control_put_internal(rstc);
400411
mutex_unlock(&reset_list_mutex);
401412
}
402413
EXPORT_SYMBOL_GPL(reset_control_put);
@@ -417,8 +428,7 @@ struct reset_control *__devm_reset_control_get(struct device *dev,
417428
if (!ptr)
418429
return ERR_PTR(-ENOMEM);
419430

420-
rstc = __of_reset_control_get(dev ? dev->of_node : NULL,
421-
id, index, shared, optional);
431+
rstc = __reset_control_get(dev, id, index, shared, optional);
422432
if (!IS_ERR(rstc)) {
423433
*ptr = rstc;
424434
devres_add(dev, ptr);

include/linux/reset.h

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ int reset_control_status(struct reset_control *rstc);
1515
struct reset_control *__of_reset_control_get(struct device_node *node,
1616
const char *id, int index, bool shared,
1717
bool optional);
18+
struct reset_control *__reset_control_get(struct device *dev, const char *id,
19+
int index, bool shared,
20+
bool optional);
1821
void reset_control_put(struct reset_control *rstc);
1922
struct reset_control *__devm_reset_control_get(struct device *dev,
2023
const char *id, int index, bool shared,
@@ -72,6 +75,13 @@ static inline struct reset_control *__of_reset_control_get(
7275
return optional ? NULL : ERR_PTR(-ENOTSUPP);
7376
}
7477

78+
static inline struct reset_control *__reset_control_get(
79+
struct device *dev, const char *id,
80+
int index, bool shared, bool optional)
81+
{
82+
return optional ? NULL : ERR_PTR(-ENOTSUPP);
83+
}
84+
7585
static inline struct reset_control *__devm_reset_control_get(
7686
struct device *dev, const char *id,
7787
int index, bool shared, bool optional)
@@ -102,8 +112,7 @@ __must_check reset_control_get_exclusive(struct device *dev, const char *id)
102112
#ifndef CONFIG_RESET_CONTROLLER
103113
WARN_ON(1);
104114
#endif
105-
return __of_reset_control_get(dev ? dev->of_node : NULL, id, 0, false,
106-
false);
115+
return __reset_control_get(dev, id, 0, false, false);
107116
}
108117

109118
/**
@@ -131,22 +140,19 @@ __must_check reset_control_get_exclusive(struct device *dev, const char *id)
131140
static inline struct reset_control *reset_control_get_shared(
132141
struct device *dev, const char *id)
133142
{
134-
return __of_reset_control_get(dev ? dev->of_node : NULL, id, 0, true,
135-
false);
143+
return __reset_control_get(dev, id, 0, true, false);
136144
}
137145

138146
static inline struct reset_control *reset_control_get_optional_exclusive(
139147
struct device *dev, const char *id)
140148
{
141-
return __of_reset_control_get(dev ? dev->of_node : NULL, id, 0, false,
142-
true);
149+
return __reset_control_get(dev, id, 0, false, true);
143150
}
144151

145152
static inline struct reset_control *reset_control_get_optional_shared(
146153
struct device *dev, const char *id)
147154
{
148-
return __of_reset_control_get(dev ? dev->of_node : NULL, id, 0, true,
149-
true);
155+
return __reset_control_get(dev, id, 0, true, true);
150156
}
151157

152158
/**

0 commit comments

Comments
 (0)