Commit d4ee21ef authored by Olof Johansson's avatar Olof Johansson

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 acbdad8d ("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: default avatarOlof Johansson <olof@lixom.net>
parents 0fa974b8 62e24c57
...@@ -275,7 +275,7 @@ int reset_control_status(struct reset_control *rstc) ...@@ -275,7 +275,7 @@ int reset_control_status(struct reset_control *rstc)
} }
EXPORT_SYMBOL_GPL(reset_control_status); EXPORT_SYMBOL_GPL(reset_control_status);
static struct reset_control *__reset_control_get( static struct reset_control *__reset_control_get_internal(
struct reset_controller_dev *rcdev, struct reset_controller_dev *rcdev,
unsigned int index, bool shared) unsigned int index, bool shared)
{ {
...@@ -308,7 +308,7 @@ static struct reset_control *__reset_control_get( ...@@ -308,7 +308,7 @@ static struct reset_control *__reset_control_get(
return rstc; return rstc;
} }
static void __reset_control_put(struct reset_control *rstc) static void __reset_control_put_internal(struct reset_control *rstc)
{ {
lockdep_assert_held(&reset_list_mutex); lockdep_assert_held(&reset_list_mutex);
...@@ -377,7 +377,7 @@ struct reset_control *__of_reset_control_get(struct device_node *node, ...@@ -377,7 +377,7 @@ struct reset_control *__of_reset_control_get(struct device_node *node,
} }
/* reset_list_mutex also protects the rcdev's reset_control list */ /* reset_list_mutex also protects the rcdev's reset_control list */
rstc = __reset_control_get(rcdev, rstc_id, shared); rstc = __reset_control_get_internal(rcdev, rstc_id, shared);
mutex_unlock(&reset_list_mutex); mutex_unlock(&reset_list_mutex);
...@@ -385,6 +385,17 @@ struct reset_control *__of_reset_control_get(struct device_node *node, ...@@ -385,6 +385,17 @@ struct reset_control *__of_reset_control_get(struct device_node *node,
} }
EXPORT_SYMBOL_GPL(__of_reset_control_get); EXPORT_SYMBOL_GPL(__of_reset_control_get);
struct reset_control *__reset_control_get(struct device *dev, const char *id,
int index, bool shared, bool optional)
{
if (dev->of_node)
return __of_reset_control_get(dev->of_node, id, index, shared,
optional);
return optional ? NULL : ERR_PTR(-EINVAL);
}
EXPORT_SYMBOL_GPL(__reset_control_get);
/** /**
* reset_control_put - free the reset controller * reset_control_put - free the reset controller
* @rstc: reset controller * @rstc: reset controller
...@@ -396,7 +407,7 @@ void reset_control_put(struct reset_control *rstc) ...@@ -396,7 +407,7 @@ void reset_control_put(struct reset_control *rstc)
return; return;
mutex_lock(&reset_list_mutex); mutex_lock(&reset_list_mutex);
__reset_control_put(rstc); __reset_control_put_internal(rstc);
mutex_unlock(&reset_list_mutex); mutex_unlock(&reset_list_mutex);
} }
EXPORT_SYMBOL_GPL(reset_control_put); EXPORT_SYMBOL_GPL(reset_control_put);
...@@ -417,8 +428,7 @@ struct reset_control *__devm_reset_control_get(struct device *dev, ...@@ -417,8 +428,7 @@ struct reset_control *__devm_reset_control_get(struct device *dev,
if (!ptr) if (!ptr)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
rstc = __of_reset_control_get(dev ? dev->of_node : NULL, rstc = __reset_control_get(dev, id, index, shared, optional);
id, index, shared, optional);
if (!IS_ERR(rstc)) { if (!IS_ERR(rstc)) {
*ptr = rstc; *ptr = rstc;
devres_add(dev, ptr); devres_add(dev, ptr);
......
...@@ -15,6 +15,9 @@ int reset_control_status(struct reset_control *rstc); ...@@ -15,6 +15,9 @@ int reset_control_status(struct reset_control *rstc);
struct reset_control *__of_reset_control_get(struct device_node *node, struct reset_control *__of_reset_control_get(struct device_node *node,
const char *id, int index, bool shared, const char *id, int index, bool shared,
bool optional); bool optional);
struct reset_control *__reset_control_get(struct device *dev, const char *id,
int index, bool shared,
bool optional);
void reset_control_put(struct reset_control *rstc); void reset_control_put(struct reset_control *rstc);
struct reset_control *__devm_reset_control_get(struct device *dev, struct reset_control *__devm_reset_control_get(struct device *dev,
const char *id, int index, bool shared, const char *id, int index, bool shared,
...@@ -72,6 +75,13 @@ static inline struct reset_control *__of_reset_control_get( ...@@ -72,6 +75,13 @@ static inline struct reset_control *__of_reset_control_get(
return optional ? NULL : ERR_PTR(-ENOTSUPP); return optional ? NULL : ERR_PTR(-ENOTSUPP);
} }
static inline struct reset_control *__reset_control_get(
struct device *dev, const char *id,
int index, bool shared, bool optional)
{
return optional ? NULL : ERR_PTR(-ENOTSUPP);
}
static inline struct reset_control *__devm_reset_control_get( static inline struct reset_control *__devm_reset_control_get(
struct device *dev, const char *id, struct device *dev, const char *id,
int index, bool shared, bool optional) int index, bool shared, bool optional)
...@@ -102,8 +112,7 @@ __must_check reset_control_get_exclusive(struct device *dev, const char *id) ...@@ -102,8 +112,7 @@ __must_check reset_control_get_exclusive(struct device *dev, const char *id)
#ifndef CONFIG_RESET_CONTROLLER #ifndef CONFIG_RESET_CONTROLLER
WARN_ON(1); WARN_ON(1);
#endif #endif
return __of_reset_control_get(dev ? dev->of_node : NULL, id, 0, false, return __reset_control_get(dev, id, 0, false, false);
false);
} }
/** /**
...@@ -131,22 +140,19 @@ __must_check reset_control_get_exclusive(struct device *dev, const char *id) ...@@ -131,22 +140,19 @@ __must_check reset_control_get_exclusive(struct device *dev, const char *id)
static inline struct reset_control *reset_control_get_shared( static inline struct reset_control *reset_control_get_shared(
struct device *dev, const char *id) struct device *dev, const char *id)
{ {
return __of_reset_control_get(dev ? dev->of_node : NULL, id, 0, true, return __reset_control_get(dev, id, 0, true, false);
false);
} }
static inline struct reset_control *reset_control_get_optional_exclusive( static inline struct reset_control *reset_control_get_optional_exclusive(
struct device *dev, const char *id) struct device *dev, const char *id)
{ {
return __of_reset_control_get(dev ? dev->of_node : NULL, id, 0, false, return __reset_control_get(dev, id, 0, false, true);
true);
} }
static inline struct reset_control *reset_control_get_optional_shared( static inline struct reset_control *reset_control_get_optional_shared(
struct device *dev, const char *id) struct device *dev, const char *id)
{ {
return __of_reset_control_get(dev ? dev->of_node : NULL, id, 0, true, return __reset_control_get(dev, id, 0, true, true);
true);
} }
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment