extcon: Fix extcon_get_extcon_dev() error handling
[platform/kernel/linux-rpi.git] / drivers / extcon / extcon.c
index e7a9561..9eb9299 100644 (file)
@@ -863,6 +863,8 @@ EXPORT_SYMBOL_GPL(extcon_set_property_capability);
  * @extcon_name:       the extcon name provided with extcon_dev_register()
  *
  * Return the pointer of extcon device if success or ERR_PTR(err) if fail.
+ * NOTE: This function returns -EPROBE_DEFER so it may only be called from
+ * probe() functions.
  */
 struct extcon_dev *extcon_get_extcon_dev(const char *extcon_name)
 {
@@ -876,7 +878,7 @@ struct extcon_dev *extcon_get_extcon_dev(const char *extcon_name)
                if (!strcmp(sd->name, extcon_name))
                        goto out;
        }
-       sd = NULL;
+       sd = ERR_PTR(-EPROBE_DEFER);
 out:
        mutex_unlock(&extcon_dev_list_lock);
        return sd;