diff mbox

[U-Boot,RESEND,09/10] reset: add no-op stubs for optional reset control

Message ID 1474424946-16085-10-git-send-email-yamada.masahiro@socionext.com
State Accepted
Delegated to: Tom Rini
Headers show

Commit Message

Masahiro Yamada Sept. 21, 2016, 2:29 a.m. UTC
My motivation for this patch is to make reset control handling
optional for generic drivers.

I want to add reset control to drivers/usb/host/ehci-generic.c,
but it is used by several platforms, some will implement a reset
controller driver, some will not.

Add no-op stubs in order to avoid link error for drivers that
implement reset controlling, but still it is optional.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---

 include/reset.h | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

Comments

Tom Rini Sept. 24, 2016, 2:29 a.m. UTC | #1
On Wed, Sep 21, 2016 at 11:29:01AM +0900, Masahiro Yamada wrote:

> My motivation for this patch is to make reset control handling
> optional for generic drivers.
> 
> I want to add reset control to drivers/usb/host/ehci-generic.c,
> but it is used by several platforms, some will implement a reset
> controller driver, some will not.
> 
> Add no-op stubs in order to avoid link error for drivers that
> implement reset controlling, but still it is optional.
> 
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>

Applied to u-boot/master, thanks!
diff mbox

Patch

diff --git a/include/reset.h b/include/reset.h
index dc0900f..f45fcf8 100644
--- a/include/reset.h
+++ b/include/reset.h
@@ -7,6 +7,8 @@ 
 #ifndef _RESET_H
 #define _RESET_H
 
+#include <linux/errno.h>
+
 /**
  * A reset is a hardware signal indicating that a HW module (or IP block, or
  * sometimes an entire off-CPU chip) reset all of its internal state to some
@@ -58,6 +60,7 @@  struct reset_ctl {
 	unsigned long id;
 };
 
+#ifdef CONFIG_DM_RESET
 /**
  * reset_get_by_index - Get/request a reset signal by integer index.
  *
@@ -132,4 +135,33 @@  int reset_assert(struct reset_ctl *reset_ctl);
  */
 int reset_deassert(struct reset_ctl *reset_ctl);
 
+#else
+static inline int reset_get_by_index(struct udevice *dev, int index,
+				     struct reset_ctl *reset_ctl)
+{
+	return -ENOTSUPP;
+}
+
+static inline int reset_get_by_name(struct udevice *dev, const char *name,
+				    struct reset_ctl *reset_ctl)
+{
+	return -ENOTSUPP;
+}
+
+static inline int reset_free(struct reset_ctl *reset_ctl)
+{
+	return 0;
+}
+
+static inline int reset_assert(struct reset_ctl *reset_ctl)
+{
+	return 0;
+}
+
+static inline int reset_deassert(struct reset_ctl *reset_ctl)
+{
+	return 0;
+}
+#endif
+
 #endif