[PATCH 2/3] provide a dummy implementation of the clk API

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Uwe Kleine-König
Date: Tuesday, April 22, 2008 - 2:52 am

With this implementation clk_get and clk_enable always succeed.  The
counterparts clk_put and clk_disable only do some minor error checking.

Signed-off-by: Uwe Kleine-König <Uwe.Kleine-Koenig@digi.com>
---
 lib/Kconfig    |    6 ++++++
 lib/Makefile   |    2 ++
 lib/dummyclk.c |   54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 62 insertions(+), 0 deletions(-)
 create mode 100644 lib/dummyclk.c

Hello,

this patch isn't really UIO related, but as my platform driver uses the
clk API and that's not implemented on X86 here comes a dummy
implementation.

This patch was already sent but up to now I got no feedback for it.

Best regards
Uwe

diff --git a/lib/Kconfig b/lib/Kconfig
index 2d53dc0..098830d 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -144,4 +144,10 @@ config CHECK_SIGNATURE
 config HAVE_LMB
 	boolean
 
+config DUMMY_CLK
+	def_bool y if X86
+	help
+	  This provides a dummy implementation for the API defined in
+	  linux/clk.h for platforms that don't implement it theirselves.
+
 endmenu
diff --git a/lib/Makefile b/lib/Makefile
index bf8000f..e355c69 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -70,6 +70,8 @@ lib-$(CONFIG_GENERIC_BUG) += bug.o
 
 obj-$(CONFIG_HAVE_LMB) += lmb.o
 
+obj-$(CONFIG_DUMMY_CLK) += dummyclk.o
+
 hostprogs-y	:= gen_crc32table
 clean-files	:= crc32table.h
 
diff --git a/lib/dummyclk.c b/lib/dummyclk.c
new file mode 100644
index 0000000..bf364df
--- /dev/null
+++ b/lib/dummyclk.c
@@ -0,0 +1,54 @@
+/*
+ * lib/dummyclk.c
+ *
+ * Copyright (C) 2008 by Digi International Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
+ */
+#include <linux/device.h>
+#include <linux/err.h>
+
+struct clk {
+	unsigned int enablecnt;
+};
+
+struct clk *clk_get(struct device *dev, const char *id)
+{
+	struct clk *ret = kzalloc(sizeof(*ret), GFP_KERNEL);
+
+	if (ret)
+		return ret;
+	else
+		return ERR_PTR(-ENOMEM);
+}
+EXPORT_SYMBOL(clk_get);
+
+void clk_put(struct clk *clk)
+{
+	WARN_ON(clk->enablecnt);
+}
+EXPORT_SYMBOL(clk_put);
+
+int clk_enable(struct clk *clk)
+{
+	++clk->enablecnt;
+	return 0;
+}
+EXPORT_SYMBOL(clk_enable);
+
+void clk_disable(struct clk *clk)
+{
+	BUG_ON(!clk->enablecnt);
+	--clk->enablecnt;
+}
+EXPORT_SYMBOL(clk_disable);
+
+unsigned long clk_get_rate(struct clk *clk)
+{
+	BUG_ON(!clk->enablecnt);
+	return 0;
+}
+EXPORT_SYMBOL(clk_get_rate);
-- 
1.5.5

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 0/4] UIO: fixes, cleanups and a new driver, Uwe Kleine-König, (Thu Apr 10, 5:36 am)
[PATCH 1/4] UIO: hold a reference to the device's owner wh ..., Uwe Kleine-König, (Thu Apr 10, 5:37 am)
[PATCH 2/4] UIO: use menuconfig, Uwe Kleine-König, (Thu Apr 10, 5:37 am)
[PATCH 4/4] [RFC] UIO: generic platform driver, Uwe Kleine-König, (Thu Apr 10, 5:37 am)
Re: [PATCH 2/4] UIO: use menuconfig, Hans J. Koch, (Thu Apr 10, 12:39 pm)
Re: [PATCH 4/4] [RFC] UIO: generic platform driver, Hans J. Koch, (Thu Apr 10, 12:54 pm)
Re: [PATCH 4/4] [RFC] UIO: generic platform driver, Hans J. Koch, (Thu Apr 10, 2:17 pm)
Re: [PATCH 4/4] [RFC] UIO: generic platform driver, Hans J. Koch, (Thu Apr 10, 3:48 pm)
Re: [PATCH 4/4] [RFC] UIO: generic platform driver, Ben Nizette, (Thu Apr 10, 6:34 pm)
Re: [PATCH 4/4] [RFC] UIO: generic platform driver, Hans J. Koch, (Fri Apr 11, 2:24 am)
Re: [PATCH 4/4 v2] [RFC] UIO: generic platform driver, Hans J. Koch, (Fri Apr 11, 3:33 am)
Re: [PATCH 4/4 v2] [RFC] UIO: generic platform driver, Hans J. Koch, (Fri Apr 11, 4:17 am)
Re: [PATCH 4/4] [RFC] UIO: generic platform driver, Hans J. Koch, (Fri Apr 11, 12:59 pm)
Re: [PATCH 2/4] UIO: use menuconfig, Greg KH, (Fri Apr 11, 2:36 pm)
Re: [PATCH 4/4 v2] [RFC] UIO: generic platform driver, Hans J. Koch, (Fri Apr 11, 3:54 pm)
Re: [PATCH 2/4] UIO: use menuconfig, Hans J. Koch, (Fri Apr 11, 3:58 pm)
Re: [PATCH 4/4 v2] [RFC] UIO: generic platform driver, Russell King - ARM Linux, (Sat Apr 12, 6:16 am)
Re: [PATCH] Re: [PATCH 4/4 v2] [RFC] UIO: generic platform ..., Russell King - ARM Linux, (Mon Apr 14, 2:37 am)
Re: [PATCH] Re: [PATCH 4/4 v2] [RFC] UIO: generic platform ..., Russell King - ARM Linux, (Mon Apr 14, 3:17 am)
Re: [PATCH] Re: [PATCH 4/4 v2] [RFC] UIO: generic platform ..., Russell King - ARM Linux, (Mon Apr 14, 4:37 am)
[PATCH 1/3] UIO: don't let UIO_CIF and UIO_SMX depend twic ..., Uwe Kleine-König, (Tue Apr 22, 2:52 am)
[PATCH 2/3] provide a dummy implementation of the clk API, Uwe Kleine-König, (Tue Apr 22, 2:52 am)
[PATCH 3/3] UIO: generic platform driver, Uwe Kleine-König, (Tue Apr 22, 2:52 am)
Re: [PATCH 3/3] UIO: generic platform driver, Ben Nizette, (Tue Apr 22, 3:26 am)
Re: [PATCH 3/3] UIO: generic platform driver, Hans J. Koch, (Tue Apr 22, 6:35 am)
Re: [PATCH 0/3] UIO: cleanup and platform driver, Hans J. Koch, (Tue Apr 22, 6:39 am)
Re: [PATCH 3/3] UIO: generic platform driver, Hans J. Koch, (Sun Apr 27, 10:12 am)
[PATCH] UIO: don't let UIO_CIF and UIO_SMX depend twice on UIO, Uwe Kleine-König, (Tue May 20, 2:24 am)
[PATCH] UIO: generic platform driver, Uwe Kleine-König, (Tue May 20, 2:24 am)
Re: [PATCH] UIO: generic platform driver, Hans J. Koch, (Tue May 20, 2:08 pm)
Re: [PATCH] UIO: generic platform driver, Uwe , (Sun May 25, 10:58 pm)
Re: [PATCH] UIO: generic platform driver, Greg KH, (Sun May 25, 11:02 pm)
Re: [PATCH] UIO: generic platform driver, Uwe , (Fri May 30, 2:16 am)
Re: [PATCH] UIO: generic platform driver, Greg KH, (Fri May 30, 9:35 am)
Re: [PATCH] UIO: generic platform driver, Uwe , (Tue Jun 3, 12:21 am)
Re: [PATCH] UIO: generic platform driver, Hans J. Koch, (Tue Jun 3, 2:24 am)