All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC] [PATCH] arm & sh: factorised duplicated clkdev.c
@ 2010-08-31 11:16 ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 0 replies; 133+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2010-08-31 11:16 UTC (permalink / raw)
  To: linux-arm-kernel

factorise some generic infrastructure to assist looking up struct clks
for the ARM & SH architecture.

as the code is identical at 99%

put the arch specific code for allocation as example in asm/lookup_clkdev.h

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 arch/arm/Kconfig                                   |   40 +++---
 arch/arm/common/Kconfig                            |    4 -
 arch/arm/common/Makefile                           |    1 -
 arch/arm/include/asm/lookup_clkdev.h               |   23 +++
 arch/arm/mach-shmobile/Kconfig                     |    6 +-
 arch/arm/plat-omap/Kconfig                         |    4 +-
 arch/sh/Kconfig                                    |    2 +-
 arch/sh/include/asm/lookup_clkdev.h                |   29 ++++
 arch/sh/kernel/Makefile                            |    2 +-
 arch/sh/kernel/clkdev.c                            |  169 --------------------
 arch/sh/kernel/cpu/clock.c                         |   16 --
 drivers/Kconfig                                    |    2 +
 drivers/Makefile                                   |    2 +
 drivers/clk/Kconfig                                |    4 +
 drivers/clk/Makefile                               |    2 +
 .../common/clkdev.c => drivers/clk/lookup_clkdev.c |   18 ++-
 16 files changed, 100 insertions(+), 224 deletions(-)
 create mode 100644 arch/arm/include/asm/lookup_clkdev.h
 create mode 100644 arch/sh/include/asm/lookup_clkdev.h
 delete mode 100644 arch/sh/kernel/clkdev.c
 create mode 100644 drivers/clk/Kconfig
 create mode 100644 drivers/clk/Makefile
 rename arch/arm/common/clkdev.c => drivers/clk/lookup_clkdev.c (89%)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index a7ed21f..e7ef725 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -221,7 +221,7 @@ config ARCH_INTEGRATOR
 	bool "ARM Ltd. Integrator family"
 	select ARM_AMBA
 	select ARCH_HAS_CPUFREQ
-	select COMMON_CLKDEV
+	select LOOKUP_CLKDEV
 	select ICST
 	select GENERIC_CLOCKEVENTS
 	select PLAT_VERSATILE
@@ -231,7 +231,7 @@ config ARCH_INTEGRATOR
 config ARCH_REALVIEW
 	bool "ARM Ltd. RealView family"
 	select ARM_AMBA
-	select COMMON_CLKDEV
+	select LOOKUP_CLKDEV
 	select ICST
 	select GENERIC_CLOCKEVENTS
 	select ARCH_WANT_OPTIONAL_GPIOLIB
@@ -245,7 +245,7 @@ config ARCH_VERSATILE
 	bool "ARM Ltd. Versatile family"
 	select ARM_AMBA
 	select ARM_VIC
-	select COMMON_CLKDEV
+	select LOOKUP_CLKDEV
 	select ICST
 	select GENERIC_CLOCKEVENTS
 	select ARCH_WANT_OPTIONAL_GPIOLIB
@@ -259,7 +259,7 @@ config ARCH_VEXPRESS
 	select ARCH_WANT_OPTIONAL_GPIOLIB
 	select ARM_AMBA
 	select ARM_TIMER_SP804
-	select COMMON_CLKDEV
+	select LOOKUP_CLKDEV
 	select GENERIC_CLOCKEVENTS
 	select HAVE_CLK
 	select ICST
@@ -281,7 +281,7 @@ config ARCH_BCMRING
 	depends on MMU
 	select CPU_V6
 	select ARM_AMBA
-	select COMMON_CLKDEV
+	select LOOKUP_CLKDEV
 	select GENERIC_CLOCKEVENTS
 	select ARCH_WANT_OPTIONAL_GPIOLIB
 	help
@@ -328,7 +328,7 @@ config ARCH_EP93XX
 	select CPU_ARM920T
 	select ARM_AMBA
 	select ARM_VIC
-	select COMMON_CLKDEV
+	select LOOKUP_CLKDEV
 	select ARCH_REQUIRE_GPIOLIB
 	select ARCH_HAS_HOLES_MEMORYMODEL
 	select ARCH_USES_GETTIMEOFFSET
@@ -348,14 +348,14 @@ config ARCH_MXC
 	bool "Freescale MXC/iMX-based"
 	select GENERIC_CLOCKEVENTS
 	select ARCH_REQUIRE_GPIOLIB
-	select COMMON_CLKDEV
+	select LOOKUP_CLKDEV
 	help
 	  Support for Freescale MXC/iMX-based family of processors
 
 config ARCH_STMP3XXX
 	bool "Freescale STMP3xxx"
 	select CPU_ARM926T
-	select COMMON_CLKDEV
+	select LOOKUP_CLKDEV
 	select ARCH_REQUIRE_GPIOLIB
 	select GENERIC_CLOCKEVENTS
 	select USB_ARCH_HAS_EHCI
@@ -473,7 +473,7 @@ config ARCH_LPC32XX
 	select HAVE_IDE
 	select ARM_AMBA
 	select USB_ARCH_HAS_OHCI
-	select COMMON_CLKDEV
+	select LOOKUP_CLKDEV
 	select GENERIC_TIME
 	select GENERIC_CLOCKEVENTS
 	help
@@ -507,7 +507,7 @@ config ARCH_MMP
 	bool "Marvell PXA168/910/MMP2"
 	depends on MMU
 	select ARCH_REQUIRE_GPIOLIB
-	select COMMON_CLKDEV
+	select LOOKUP_CLKDEV
 	select GENERIC_CLOCKEVENTS
 	select TICK_ONESHOT
 	select PLAT_PXA
@@ -539,7 +539,7 @@ config ARCH_W90X900
 	bool "Nuvoton W90X900 CPU"
 	select CPU_ARM926T
 	select ARCH_REQUIRE_GPIOLIB
-	select COMMON_CLKDEV
+	select LOOKUP_CLKDEV
 	select GENERIC_CLOCKEVENTS
 	help
 	  Support for Nuvoton (Winbond logic dept.) ARM9 processor,
@@ -553,7 +553,7 @@ config ARCH_W90X900
 config ARCH_NUC93X
 	bool "Nuvoton NUC93X CPU"
 	select CPU_ARM926T
-	select COMMON_CLKDEV
+	select LOOKUP_CLKDEV
 	help
 	  Support for Nuvoton (Winbond logic dept.) NUC93X MCU,The NUC93X is a
 	  low-power and high performance MPEG-4/JPEG multimedia controller chip.
@@ -564,7 +564,7 @@ config ARCH_TEGRA
 	select GENERIC_CLOCKEVENTS
 	select GENERIC_GPIO
 	select HAVE_CLK
-	select COMMON_CLKDEV
+	select LOOKUP_CLKDEV
 	select ARCH_HAS_BARRIERS if CACHE_L2X0
 	help
 	  This enables support for NVIDIA Tegra based systems (Tegra APX,
@@ -573,7 +573,7 @@ config ARCH_TEGRA
 config ARCH_PNX4008
 	bool "Philips Nexperia PNX4008 Mobile"
 	select CPU_ARM926T
-	select COMMON_CLKDEV
+	select LOOKUP_CLKDEV
 	select ARCH_USES_GETTIMEOFFSET
 	help
 	  This enables support for Philips PNX4008 mobile platform.
@@ -583,7 +583,7 @@ config ARCH_PXA
 	depends on MMU
 	select ARCH_MTD_XIP
 	select ARCH_HAS_CPUFREQ
-	select COMMON_CLKDEV
+	select LOOKUP_CLKDEV
 	select ARCH_REQUIRE_GPIOLIB
 	select GENERIC_CLOCKEVENTS
 	select TICK_ONESHOT
@@ -767,7 +767,7 @@ config ARCH_U300
 	select ARM_AMBA
 	select ARM_VIC
 	select GENERIC_CLOCKEVENTS
-	select COMMON_CLKDEV
+	select LOOKUP_CLKDEV
 	select GENERIC_GPIO
 	help
 	  Support for ST-Ericsson U300 series mobile platforms.
@@ -777,7 +777,7 @@ config ARCH_U8500
 	select CPU_V7
 	select ARM_AMBA
 	select GENERIC_CLOCKEVENTS
-	select COMMON_CLKDEV
+	select LOOKUP_CLKDEV
 	select ARCH_REQUIRE_GPIOLIB
 	help
 	  Support for ST-Ericsson's Ux500 architecture
@@ -787,7 +787,7 @@ config ARCH_NOMADIK
 	select ARM_AMBA
 	select ARM_VIC
 	select CPU_ARM926T
-	select COMMON_CLKDEV
+	select LOOKUP_CLKDEV
 	select GENERIC_CLOCKEVENTS
 	select ARCH_REQUIRE_GPIOLIB
 	help
@@ -799,7 +799,7 @@ config ARCH_DAVINCI
 	select ARCH_REQUIRE_GPIOLIB
 	select ZONE_DMA
 	select HAVE_IDE
-	select COMMON_CLKDEV
+	select LOOKUP_CLKDEV
 	select GENERIC_ALLOCATOR
 	select ARCH_HAS_HOLES_MEMORYMODEL
 	help
@@ -819,7 +819,7 @@ config PLAT_SPEAR
 	bool "ST SPEAr"
 	select ARM_AMBA
 	select ARCH_REQUIRE_GPIOLIB
-	select COMMON_CLKDEV
+	select LOOKUP_CLKDEV
 	select GENERIC_CLOCKEVENTS
 	select HAVE_CLK
 	help
diff --git a/arch/arm/common/Kconfig b/arch/arm/common/Kconfig
index 0a34c81..778655f 100644
--- a/arch/arm/common/Kconfig
+++ b/arch/arm/common/Kconfig
@@ -37,7 +37,3 @@ config SHARP_PARAM
 
 config SHARP_SCOOP
 	bool
-
-config COMMON_CLKDEV
-	bool
-	select HAVE_CLK
diff --git a/arch/arm/common/Makefile b/arch/arm/common/Makefile
index e6e8664..799e140 100644
--- a/arch/arm/common/Makefile
+++ b/arch/arm/common/Makefile
@@ -16,4 +16,3 @@ obj-$(CONFIG_SHARP_SCOOP)	+= scoop.o
 obj-$(CONFIG_ARCH_IXP2000)	+= uengine.o
 obj-$(CONFIG_ARCH_IXP23XX)	+= uengine.o
 obj-$(CONFIG_PCI_HOST_ITE8152)  += it8152.o
-obj-$(CONFIG_COMMON_CLKDEV)	+= clkdev.o
diff --git a/arch/arm/include/asm/lookup_clkdev.h b/arch/arm/include/asm/lookup_clkdev.h
new file mode 100644
index 0000000..d57f7a6
--- /dev/null
+++ b/arch/arm/include/asm/lookup_clkdev.h
@@ -0,0 +1,23 @@
+/*
+ *  arch/arm/common/clkdev.c
+ *
+ *  Copyright (C) 2008 Russell King.
+ *
+ * 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.
+ *
+ * Helper for the clk API to assist looking up a struct clk.
+ */
+
+#ifndef __LOOKUP_CLK_DEV__
+#define __LOOKUP_CLK_DEV__
+
+#include <mach/clkdev.h>
+
+static __inline__ struct clk_lookup_alloc *arch_kzalloc(size_t size)
+{
+	return kzalloc(size, GFP_KERNEL);
+}
+
+#endif /* __LOOKUP_CLK_DEV__ */
diff --git a/arch/arm/mach-shmobile/Kconfig b/arch/arm/mach-shmobile/Kconfig
index 54b479c..e4e964b 100644
--- a/arch/arm/mach-shmobile/Kconfig
+++ b/arch/arm/mach-shmobile/Kconfig
@@ -6,7 +6,7 @@ config ARCH_SH7367
 	bool "SH-Mobile G3 (SH7367)"
 	select CPU_V6
 	select HAVE_CLK
-	select COMMON_CLKDEV
+	select LOOKUP_CLKDEV
 	select SH_CLK_CPG
 	select GENERIC_CLOCKEVENTS
 
@@ -14,7 +14,7 @@ config ARCH_SH7377
 	bool "SH-Mobile G4 (SH7377)"
 	select CPU_V7
 	select HAVE_CLK
-	select COMMON_CLKDEV
+	select LOOKUP_CLKDEV
 	select SH_CLK_CPG
 	select GENERIC_CLOCKEVENTS
 
@@ -22,7 +22,7 @@ config ARCH_SH7372
 	bool "SH-Mobile AP4 (SH7372)"
 	select CPU_V7
 	select HAVE_CLK
-	select COMMON_CLKDEV
+	select LOOKUP_CLKDEV
 	select SH_CLK_CPG
 	select GENERIC_CLOCKEVENTS
 
diff --git a/arch/arm/plat-omap/Kconfig b/arch/arm/plat-omap/Kconfig
index e39a417..daba55a 100644
--- a/arch/arm/plat-omap/Kconfig
+++ b/arch/arm/plat-omap/Kconfig
@@ -11,13 +11,13 @@ choice
 
 config ARCH_OMAP1
 	bool "TI OMAP1"
-	select COMMON_CLKDEV
+	select LOOKUP_CLKDEV
 	help
 	  "Systems based on omap7xx, omap15xx or omap16xx"
 
 config ARCH_OMAP2PLUS
 	bool "TI OMAP2/3/4"
-	select COMMON_CLKDEV
+	select LOOKUP_CLKDEV
 	help
 	  "Systems based on omap24xx, omap34xx or omap44xx"
 
diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index 33990fa..6b7d206 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -8,7 +8,7 @@ mainmenu "Linux/SuperH Kernel Configuration"
 config SUPERH
 	def_bool y
 	select EMBEDDED
-	select HAVE_CLK
+	select LOOKUP_CLKDEV
 	select HAVE_IDE if HAS_IOPORT
 	select HAVE_MEMBLOCK
 	select HAVE_OPROFILE
diff --git a/arch/sh/include/asm/lookup_clkdev.h b/arch/sh/include/asm/lookup_clkdev.h
new file mode 100644
index 0000000..9ac7b10
--- /dev/null
+++ b/arch/sh/include/asm/lookup_clkdev.h
@@ -0,0 +1,29 @@
+/*
+ *  Copyright (C) 2010 Paul Mundt <lethal@linux-sh.org>
+ *
+ * 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.
+ *
+ * Helper for the clk API to assist looking up a struct clk.
+ */
+
+#ifndef __LOOKUP_CLK_DEV__
+#define __LOOKUP_CLK_DEV__
+
+#include <linux/bootmem.h>
+#include <linux/mm.h>
+#include <asm/clock.h>
+
+static __inline__ struct clk_lookup_alloc *arch_kzalloc(size_t size)
+{
+	if (!slab_is_available())
+		return alloc_bootmem_low_pages(size);
+	else
+		return kzalloc(size, GFP_KERNEL);
+}
+
+#define __clk_put(clk)
+#define __clk_get(clk) ({ 1; })
+
+#endif /* __LOOKUP_CLK_DEV__ */
diff --git a/arch/sh/kernel/Makefile b/arch/sh/kernel/Makefile
index e25f3c6..e4fe614 100644
--- a/arch/sh/kernel/Makefile
+++ b/arch/sh/kernel/Makefile
@@ -11,7 +11,7 @@ endif
 
 CFLAGS_REMOVE_return_address.o = -pg
 
-obj-y	:= clkdev.o debugtraps.o dma-nommu.o dumpstack.o 		\
+obj-y	:= debugtraps.o dma-nommu.o dumpstack.o 			\
 	   idle.o io.o irq.o						\
 	   irq_$(BITS).o machvec.o nmi_debug.o process.o		\
 	   process_$(BITS).o ptrace_$(BITS).o				\
diff --git a/arch/sh/kernel/clkdev.c b/arch/sh/kernel/clkdev.c
deleted file mode 100644
index befc255..0000000
--- a/arch/sh/kernel/clkdev.c
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * arch/sh/kernel/clkdev.c
- *
- * Cloned from arch/arm/common/clkdev.c:
- *
- *  Copyright (C) 2008 Russell King.
- *
- * 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.
- *
- * Helper for the clk API to assist looking up a struct clk.
- */
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/device.h>
-#include <linux/list.h>
-#include <linux/errno.h>
-#include <linux/err.h>
-#include <linux/string.h>
-#include <linux/mutex.h>
-#include <linux/clk.h>
-#include <linux/slab.h>
-#include <linux/bootmem.h>
-#include <linux/mm.h>
-#include <asm/clock.h>
-#include <asm/clkdev.h>
-
-static LIST_HEAD(clocks);
-static DEFINE_MUTEX(clocks_mutex);
-
-/*
- * Find the correct struct clk for the device and connection ID.
- * We do slightly fuzzy matching here:
- *  An entry with a NULL ID is assumed to be a wildcard.
- *  If an entry has a device ID, it must match
- *  If an entry has a connection ID, it must match
- * Then we take the most specific entry - with the following
- * order of precedence: dev+con > dev only > con only.
- */
-static struct clk *clk_find(const char *dev_id, const char *con_id)
-{
-	struct clk_lookup *p;
-	struct clk *clk = NULL;
-	int match, best = 0;
-
-	list_for_each_entry(p, &clocks, node) {
-		match = 0;
-		if (p->dev_id) {
-			if (!dev_id || strcmp(p->dev_id, dev_id))
-				continue;
-			match += 2;
-		}
-		if (p->con_id) {
-			if (!con_id || strcmp(p->con_id, con_id))
-				continue;
-			match += 1;
-		}
-		if (match = 0)
-			continue;
-
-		if (match > best) {
-			clk = p->clk;
-			best = match;
-		}
-	}
-	return clk;
-}
-
-struct clk *clk_get_sys(const char *dev_id, const char *con_id)
-{
-	struct clk *clk;
-
-	mutex_lock(&clocks_mutex);
-	clk = clk_find(dev_id, con_id);
-	mutex_unlock(&clocks_mutex);
-
-	return clk ? clk : ERR_PTR(-ENOENT);
-}
-EXPORT_SYMBOL(clk_get_sys);
-
-void clkdev_add(struct clk_lookup *cl)
-{
-	mutex_lock(&clocks_mutex);
-	list_add_tail(&cl->node, &clocks);
-	mutex_unlock(&clocks_mutex);
-}
-EXPORT_SYMBOL(clkdev_add);
-
-void __init clkdev_add_table(struct clk_lookup *cl, size_t num)
-{
-	mutex_lock(&clocks_mutex);
-	while (num--) {
-		list_add_tail(&cl->node, &clocks);
-		cl++;
-	}
-	mutex_unlock(&clocks_mutex);
-}
-
-#define MAX_DEV_ID	20
-#define MAX_CON_ID	16
-
-struct clk_lookup_alloc {
-	struct clk_lookup cl;
-	char	dev_id[MAX_DEV_ID];
-	char	con_id[MAX_CON_ID];
-};
-
-struct clk_lookup * __init_refok
-clkdev_alloc(struct clk *clk, const char *con_id, const char *dev_fmt, ...)
-{
-	struct clk_lookup_alloc *cla;
-
-	if (!slab_is_available())
-		cla = alloc_bootmem_low_pages(sizeof(*cla));
-	else
-		cla = kzalloc(sizeof(*cla), GFP_KERNEL);
-
-	if (!cla)
-		return NULL;
-
-	cla->cl.clk = clk;
-	if (con_id) {
-		strlcpy(cla->con_id, con_id, sizeof(cla->con_id));
-		cla->cl.con_id = cla->con_id;
-	}
-
-	if (dev_fmt) {
-		va_list ap;
-
-		va_start(ap, dev_fmt);
-		vscnprintf(cla->dev_id, sizeof(cla->dev_id), dev_fmt, ap);
-		cla->cl.dev_id = cla->dev_id;
-		va_end(ap);
-	}
-
-	return &cla->cl;
-}
-EXPORT_SYMBOL(clkdev_alloc);
-
-int clk_add_alias(const char *alias, const char *alias_dev_name, char *id,
-	struct device *dev)
-{
-	struct clk *r = clk_get(dev, id);
-	struct clk_lookup *l;
-
-	if (IS_ERR(r))
-		return PTR_ERR(r);
-
-	l = clkdev_alloc(r, alias, alias_dev_name);
-	clk_put(r);
-	if (!l)
-		return -ENODEV;
-	clkdev_add(l);
-	return 0;
-}
-EXPORT_SYMBOL(clk_add_alias);
-
-/*
- * clkdev_drop - remove a clock dynamically allocated
- */
-void clkdev_drop(struct clk_lookup *cl)
-{
-	mutex_lock(&clocks_mutex);
-	list_del(&cl->node);
-	mutex_unlock(&clocks_mutex);
-	kfree(cl);
-}
-EXPORT_SYMBOL(clkdev_drop);
diff --git a/arch/sh/kernel/cpu/clock.c b/arch/sh/kernel/cpu/clock.c
index 50f887d..4187cf4 100644
--- a/arch/sh/kernel/cpu/clock.c
+++ b/arch/sh/kernel/cpu/clock.c
@@ -48,20 +48,4 @@ int __init clk_init(void)
 	return ret;
 }
 
-/*
- * Returns a clock. Note that we first try to use device id on the bus
- * and clock name. If this fails, we try to use clock name only.
- */
-struct clk *clk_get(struct device *dev, const char *con_id)
-{
-	const char *dev_id = dev ? dev_name(dev) : NULL;
-
-	return clk_get_sys(dev_id, con_id);
-}
-EXPORT_SYMBOL_GPL(clk_get);
-
-void clk_put(struct clk *clk)
-{
-}
-EXPORT_SYMBOL_GPL(clk_put);
 
diff --git a/drivers/Kconfig b/drivers/Kconfig
index a2b902f..3d93b3a 100644
--- a/drivers/Kconfig
+++ b/drivers/Kconfig
@@ -111,4 +111,6 @@ source "drivers/xen/Kconfig"
 source "drivers/staging/Kconfig"
 
 source "drivers/platform/Kconfig"
+
+source "drivers/clk/Kconfig"
 endmenu
diff --git a/drivers/Makefile b/drivers/Makefile
index ae47344..b0e30b2 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -115,3 +115,5 @@ obj-$(CONFIG_VLYNQ)		+= vlynq/
 obj-$(CONFIG_STAGING)		+= staging/
 obj-y				+= platform/
 obj-y				+= ieee802154/
+#common clk code
+obj-y				+= clk/
diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig
new file mode 100644
index 0000000..cc5272c
--- /dev/null
+++ b/drivers/clk/Kconfig
@@ -0,0 +1,4 @@
+
+config LOOKUP_CLKDEV
+	bool
+	select HAVE_CLK
diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
new file mode 100644
index 0000000..288d997
--- /dev/null
+++ b/drivers/clk/Makefile
@@ -0,0 +1,2 @@
+
+obj-$(CONFIG_LOOKUP_CLKDEV)	+= lookup_clkdev.o
diff --git a/arch/arm/common/clkdev.c b/drivers/clk/lookup_clkdev.c
similarity index 89%
rename from arch/arm/common/clkdev.c
rename to drivers/clk/lookup_clkdev.c
index e2b2bb6..0a19626 100644
--- a/arch/arm/common/clkdev.c
+++ b/drivers/clk/lookup_clkdev.c
@@ -1,5 +1,5 @@
 /*
- *  arch/arm/common/clkdev.c
+ * drivers/clk/lookup_clkdev.c
  *
  *  Copyright (C) 2008 Russell King.
  *
@@ -21,7 +21,7 @@
 #include <linux/slab.h>
 
 #include <asm/clkdev.h>
-#include <mach/clkdev.h>
+#include <asm/lookup_clkdev.h>
 
 static LIST_HEAD(clocks);
 static DEFINE_MUTEX(clocks_mutex);
@@ -79,19 +79,23 @@ struct clk *clk_get_sys(const char *dev_id, const char *con_id)
 }
 EXPORT_SYMBOL(clk_get_sys);
 
+/*
+ * Returns a clock. Note that we first try to use device id on the bus
+ * and clock name. If this fails, we try to use clock name only.
+ */
 struct clk *clk_get(struct device *dev, const char *con_id)
 {
 	const char *dev_id = dev ? dev_name(dev) : NULL;
 
 	return clk_get_sys(dev_id, con_id);
 }
-EXPORT_SYMBOL(clk_get);
+EXPORT_SYMBOL_GPL(clk_get);
 
 void clk_put(struct clk *clk)
 {
 	__clk_put(clk);
 }
-EXPORT_SYMBOL(clk_put);
+EXPORT_SYMBOL_GPL(clk_put);
 
 void clkdev_add(struct clk_lookup *cl)
 {
@@ -120,12 +124,12 @@ struct clk_lookup_alloc {
 	char	con_id[MAX_CON_ID];
 };
 
-struct clk_lookup *clkdev_alloc(struct clk *clk, const char *con_id,
-	const char *dev_fmt, ...)
+struct clk_lookup * __init_refok
+clkdev_alloc(struct clk *clk, const char *con_id, const char *dev_fmt, ...)
 {
 	struct clk_lookup_alloc *cla;
 
-	cla = kzalloc(sizeof(*cla), GFP_KERNEL);
+	cla = arch_kzalloc(sizeof(*cla));
 	if (!cla)
 		return NULL;
 
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [RFC] [PATCH] arm & sh: factorised duplicated clkdev.c
@ 2010-08-31 11:16 ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 0 replies; 133+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2010-08-31 11:16 UTC (permalink / raw)
  To: linux-arm-kernel

factorise some generic infrastructure to assist looking up struct clks
for the ARM & SH architecture.

as the code is identical at 99%

put the arch specific code for allocation as example in asm/lookup_clkdev.h

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 arch/arm/Kconfig                                   |   40 +++---
 arch/arm/common/Kconfig                            |    4 -
 arch/arm/common/Makefile                           |    1 -
 arch/arm/include/asm/lookup_clkdev.h               |   23 +++
 arch/arm/mach-shmobile/Kconfig                     |    6 +-
 arch/arm/plat-omap/Kconfig                         |    4 +-
 arch/sh/Kconfig                                    |    2 +-
 arch/sh/include/asm/lookup_clkdev.h                |   29 ++++
 arch/sh/kernel/Makefile                            |    2 +-
 arch/sh/kernel/clkdev.c                            |  169 --------------------
 arch/sh/kernel/cpu/clock.c                         |   16 --
 drivers/Kconfig                                    |    2 +
 drivers/Makefile                                   |    2 +
 drivers/clk/Kconfig                                |    4 +
 drivers/clk/Makefile                               |    2 +
 .../common/clkdev.c => drivers/clk/lookup_clkdev.c |   18 ++-
 16 files changed, 100 insertions(+), 224 deletions(-)
 create mode 100644 arch/arm/include/asm/lookup_clkdev.h
 create mode 100644 arch/sh/include/asm/lookup_clkdev.h
 delete mode 100644 arch/sh/kernel/clkdev.c
 create mode 100644 drivers/clk/Kconfig
 create mode 100644 drivers/clk/Makefile
 rename arch/arm/common/clkdev.c => drivers/clk/lookup_clkdev.c (89%)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index a7ed21f..e7ef725 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -221,7 +221,7 @@ config ARCH_INTEGRATOR
 	bool "ARM Ltd. Integrator family"
 	select ARM_AMBA
 	select ARCH_HAS_CPUFREQ
-	select COMMON_CLKDEV
+	select LOOKUP_CLKDEV
 	select ICST
 	select GENERIC_CLOCKEVENTS
 	select PLAT_VERSATILE
@@ -231,7 +231,7 @@ config ARCH_INTEGRATOR
 config ARCH_REALVIEW
 	bool "ARM Ltd. RealView family"
 	select ARM_AMBA
-	select COMMON_CLKDEV
+	select LOOKUP_CLKDEV
 	select ICST
 	select GENERIC_CLOCKEVENTS
 	select ARCH_WANT_OPTIONAL_GPIOLIB
@@ -245,7 +245,7 @@ config ARCH_VERSATILE
 	bool "ARM Ltd. Versatile family"
 	select ARM_AMBA
 	select ARM_VIC
-	select COMMON_CLKDEV
+	select LOOKUP_CLKDEV
 	select ICST
 	select GENERIC_CLOCKEVENTS
 	select ARCH_WANT_OPTIONAL_GPIOLIB
@@ -259,7 +259,7 @@ config ARCH_VEXPRESS
 	select ARCH_WANT_OPTIONAL_GPIOLIB
 	select ARM_AMBA
 	select ARM_TIMER_SP804
-	select COMMON_CLKDEV
+	select LOOKUP_CLKDEV
 	select GENERIC_CLOCKEVENTS
 	select HAVE_CLK
 	select ICST
@@ -281,7 +281,7 @@ config ARCH_BCMRING
 	depends on MMU
 	select CPU_V6
 	select ARM_AMBA
-	select COMMON_CLKDEV
+	select LOOKUP_CLKDEV
 	select GENERIC_CLOCKEVENTS
 	select ARCH_WANT_OPTIONAL_GPIOLIB
 	help
@@ -328,7 +328,7 @@ config ARCH_EP93XX
 	select CPU_ARM920T
 	select ARM_AMBA
 	select ARM_VIC
-	select COMMON_CLKDEV
+	select LOOKUP_CLKDEV
 	select ARCH_REQUIRE_GPIOLIB
 	select ARCH_HAS_HOLES_MEMORYMODEL
 	select ARCH_USES_GETTIMEOFFSET
@@ -348,14 +348,14 @@ config ARCH_MXC
 	bool "Freescale MXC/iMX-based"
 	select GENERIC_CLOCKEVENTS
 	select ARCH_REQUIRE_GPIOLIB
-	select COMMON_CLKDEV
+	select LOOKUP_CLKDEV
 	help
 	  Support for Freescale MXC/iMX-based family of processors
 
 config ARCH_STMP3XXX
 	bool "Freescale STMP3xxx"
 	select CPU_ARM926T
-	select COMMON_CLKDEV
+	select LOOKUP_CLKDEV
 	select ARCH_REQUIRE_GPIOLIB
 	select GENERIC_CLOCKEVENTS
 	select USB_ARCH_HAS_EHCI
@@ -473,7 +473,7 @@ config ARCH_LPC32XX
 	select HAVE_IDE
 	select ARM_AMBA
 	select USB_ARCH_HAS_OHCI
-	select COMMON_CLKDEV
+	select LOOKUP_CLKDEV
 	select GENERIC_TIME
 	select GENERIC_CLOCKEVENTS
 	help
@@ -507,7 +507,7 @@ config ARCH_MMP
 	bool "Marvell PXA168/910/MMP2"
 	depends on MMU
 	select ARCH_REQUIRE_GPIOLIB
-	select COMMON_CLKDEV
+	select LOOKUP_CLKDEV
 	select GENERIC_CLOCKEVENTS
 	select TICK_ONESHOT
 	select PLAT_PXA
@@ -539,7 +539,7 @@ config ARCH_W90X900
 	bool "Nuvoton W90X900 CPU"
 	select CPU_ARM926T
 	select ARCH_REQUIRE_GPIOLIB
-	select COMMON_CLKDEV
+	select LOOKUP_CLKDEV
 	select GENERIC_CLOCKEVENTS
 	help
 	  Support for Nuvoton (Winbond logic dept.) ARM9 processor,
@@ -553,7 +553,7 @@ config ARCH_W90X900
 config ARCH_NUC93X
 	bool "Nuvoton NUC93X CPU"
 	select CPU_ARM926T
-	select COMMON_CLKDEV
+	select LOOKUP_CLKDEV
 	help
 	  Support for Nuvoton (Winbond logic dept.) NUC93X MCU,The NUC93X is a
 	  low-power and high performance MPEG-4/JPEG multimedia controller chip.
@@ -564,7 +564,7 @@ config ARCH_TEGRA
 	select GENERIC_CLOCKEVENTS
 	select GENERIC_GPIO
 	select HAVE_CLK
-	select COMMON_CLKDEV
+	select LOOKUP_CLKDEV
 	select ARCH_HAS_BARRIERS if CACHE_L2X0
 	help
 	  This enables support for NVIDIA Tegra based systems (Tegra APX,
@@ -573,7 +573,7 @@ config ARCH_TEGRA
 config ARCH_PNX4008
 	bool "Philips Nexperia PNX4008 Mobile"
 	select CPU_ARM926T
-	select COMMON_CLKDEV
+	select LOOKUP_CLKDEV
 	select ARCH_USES_GETTIMEOFFSET
 	help
 	  This enables support for Philips PNX4008 mobile platform.
@@ -583,7 +583,7 @@ config ARCH_PXA
 	depends on MMU
 	select ARCH_MTD_XIP
 	select ARCH_HAS_CPUFREQ
-	select COMMON_CLKDEV
+	select LOOKUP_CLKDEV
 	select ARCH_REQUIRE_GPIOLIB
 	select GENERIC_CLOCKEVENTS
 	select TICK_ONESHOT
@@ -767,7 +767,7 @@ config ARCH_U300
 	select ARM_AMBA
 	select ARM_VIC
 	select GENERIC_CLOCKEVENTS
-	select COMMON_CLKDEV
+	select LOOKUP_CLKDEV
 	select GENERIC_GPIO
 	help
 	  Support for ST-Ericsson U300 series mobile platforms.
@@ -777,7 +777,7 @@ config ARCH_U8500
 	select CPU_V7
 	select ARM_AMBA
 	select GENERIC_CLOCKEVENTS
-	select COMMON_CLKDEV
+	select LOOKUP_CLKDEV
 	select ARCH_REQUIRE_GPIOLIB
 	help
 	  Support for ST-Ericsson's Ux500 architecture
@@ -787,7 +787,7 @@ config ARCH_NOMADIK
 	select ARM_AMBA
 	select ARM_VIC
 	select CPU_ARM926T
-	select COMMON_CLKDEV
+	select LOOKUP_CLKDEV
 	select GENERIC_CLOCKEVENTS
 	select ARCH_REQUIRE_GPIOLIB
 	help
@@ -799,7 +799,7 @@ config ARCH_DAVINCI
 	select ARCH_REQUIRE_GPIOLIB
 	select ZONE_DMA
 	select HAVE_IDE
-	select COMMON_CLKDEV
+	select LOOKUP_CLKDEV
 	select GENERIC_ALLOCATOR
 	select ARCH_HAS_HOLES_MEMORYMODEL
 	help
@@ -819,7 +819,7 @@ config PLAT_SPEAR
 	bool "ST SPEAr"
 	select ARM_AMBA
 	select ARCH_REQUIRE_GPIOLIB
-	select COMMON_CLKDEV
+	select LOOKUP_CLKDEV
 	select GENERIC_CLOCKEVENTS
 	select HAVE_CLK
 	help
diff --git a/arch/arm/common/Kconfig b/arch/arm/common/Kconfig
index 0a34c81..778655f 100644
--- a/arch/arm/common/Kconfig
+++ b/arch/arm/common/Kconfig
@@ -37,7 +37,3 @@ config SHARP_PARAM
 
 config SHARP_SCOOP
 	bool
-
-config COMMON_CLKDEV
-	bool
-	select HAVE_CLK
diff --git a/arch/arm/common/Makefile b/arch/arm/common/Makefile
index e6e8664..799e140 100644
--- a/arch/arm/common/Makefile
+++ b/arch/arm/common/Makefile
@@ -16,4 +16,3 @@ obj-$(CONFIG_SHARP_SCOOP)	+= scoop.o
 obj-$(CONFIG_ARCH_IXP2000)	+= uengine.o
 obj-$(CONFIG_ARCH_IXP23XX)	+= uengine.o
 obj-$(CONFIG_PCI_HOST_ITE8152)  += it8152.o
-obj-$(CONFIG_COMMON_CLKDEV)	+= clkdev.o
diff --git a/arch/arm/include/asm/lookup_clkdev.h b/arch/arm/include/asm/lookup_clkdev.h
new file mode 100644
index 0000000..d57f7a6
--- /dev/null
+++ b/arch/arm/include/asm/lookup_clkdev.h
@@ -0,0 +1,23 @@
+/*
+ *  arch/arm/common/clkdev.c
+ *
+ *  Copyright (C) 2008 Russell King.
+ *
+ * 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.
+ *
+ * Helper for the clk API to assist looking up a struct clk.
+ */
+
+#ifndef __LOOKUP_CLK_DEV__
+#define __LOOKUP_CLK_DEV__
+
+#include <mach/clkdev.h>
+
+static __inline__ struct clk_lookup_alloc *arch_kzalloc(size_t size)
+{
+	return kzalloc(size, GFP_KERNEL);
+}
+
+#endif /* __LOOKUP_CLK_DEV__ */
diff --git a/arch/arm/mach-shmobile/Kconfig b/arch/arm/mach-shmobile/Kconfig
index 54b479c..e4e964b 100644
--- a/arch/arm/mach-shmobile/Kconfig
+++ b/arch/arm/mach-shmobile/Kconfig
@@ -6,7 +6,7 @@ config ARCH_SH7367
 	bool "SH-Mobile G3 (SH7367)"
 	select CPU_V6
 	select HAVE_CLK
-	select COMMON_CLKDEV
+	select LOOKUP_CLKDEV
 	select SH_CLK_CPG
 	select GENERIC_CLOCKEVENTS
 
@@ -14,7 +14,7 @@ config ARCH_SH7377
 	bool "SH-Mobile G4 (SH7377)"
 	select CPU_V7
 	select HAVE_CLK
-	select COMMON_CLKDEV
+	select LOOKUP_CLKDEV
 	select SH_CLK_CPG
 	select GENERIC_CLOCKEVENTS
 
@@ -22,7 +22,7 @@ config ARCH_SH7372
 	bool "SH-Mobile AP4 (SH7372)"
 	select CPU_V7
 	select HAVE_CLK
-	select COMMON_CLKDEV
+	select LOOKUP_CLKDEV
 	select SH_CLK_CPG
 	select GENERIC_CLOCKEVENTS
 
diff --git a/arch/arm/plat-omap/Kconfig b/arch/arm/plat-omap/Kconfig
index e39a417..daba55a 100644
--- a/arch/arm/plat-omap/Kconfig
+++ b/arch/arm/plat-omap/Kconfig
@@ -11,13 +11,13 @@ choice
 
 config ARCH_OMAP1
 	bool "TI OMAP1"
-	select COMMON_CLKDEV
+	select LOOKUP_CLKDEV
 	help
 	  "Systems based on omap7xx, omap15xx or omap16xx"
 
 config ARCH_OMAP2PLUS
 	bool "TI OMAP2/3/4"
-	select COMMON_CLKDEV
+	select LOOKUP_CLKDEV
 	help
 	  "Systems based on omap24xx, omap34xx or omap44xx"
 
diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index 33990fa..6b7d206 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -8,7 +8,7 @@ mainmenu "Linux/SuperH Kernel Configuration"
 config SUPERH
 	def_bool y
 	select EMBEDDED
-	select HAVE_CLK
+	select LOOKUP_CLKDEV
 	select HAVE_IDE if HAS_IOPORT
 	select HAVE_MEMBLOCK
 	select HAVE_OPROFILE
diff --git a/arch/sh/include/asm/lookup_clkdev.h b/arch/sh/include/asm/lookup_clkdev.h
new file mode 100644
index 0000000..9ac7b10
--- /dev/null
+++ b/arch/sh/include/asm/lookup_clkdev.h
@@ -0,0 +1,29 @@
+/*
+ *  Copyright (C) 2010 Paul Mundt <lethal@linux-sh.org>
+ *
+ * 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.
+ *
+ * Helper for the clk API to assist looking up a struct clk.
+ */
+
+#ifndef __LOOKUP_CLK_DEV__
+#define __LOOKUP_CLK_DEV__
+
+#include <linux/bootmem.h>
+#include <linux/mm.h>
+#include <asm/clock.h>
+
+static __inline__ struct clk_lookup_alloc *arch_kzalloc(size_t size)
+{
+	if (!slab_is_available())
+		return alloc_bootmem_low_pages(size);
+	else
+		return kzalloc(size, GFP_KERNEL);
+}
+
+#define __clk_put(clk)
+#define __clk_get(clk) ({ 1; })
+
+#endif /* __LOOKUP_CLK_DEV__ */
diff --git a/arch/sh/kernel/Makefile b/arch/sh/kernel/Makefile
index e25f3c6..e4fe614 100644
--- a/arch/sh/kernel/Makefile
+++ b/arch/sh/kernel/Makefile
@@ -11,7 +11,7 @@ endif
 
 CFLAGS_REMOVE_return_address.o = -pg
 
-obj-y	:= clkdev.o debugtraps.o dma-nommu.o dumpstack.o 		\
+obj-y	:= debugtraps.o dma-nommu.o dumpstack.o 			\
 	   idle.o io.o irq.o						\
 	   irq_$(BITS).o machvec.o nmi_debug.o process.o		\
 	   process_$(BITS).o ptrace_$(BITS).o				\
diff --git a/arch/sh/kernel/clkdev.c b/arch/sh/kernel/clkdev.c
deleted file mode 100644
index befc255..0000000
--- a/arch/sh/kernel/clkdev.c
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * arch/sh/kernel/clkdev.c
- *
- * Cloned from arch/arm/common/clkdev.c:
- *
- *  Copyright (C) 2008 Russell King.
- *
- * 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.
- *
- * Helper for the clk API to assist looking up a struct clk.
- */
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/device.h>
-#include <linux/list.h>
-#include <linux/errno.h>
-#include <linux/err.h>
-#include <linux/string.h>
-#include <linux/mutex.h>
-#include <linux/clk.h>
-#include <linux/slab.h>
-#include <linux/bootmem.h>
-#include <linux/mm.h>
-#include <asm/clock.h>
-#include <asm/clkdev.h>
-
-static LIST_HEAD(clocks);
-static DEFINE_MUTEX(clocks_mutex);
-
-/*
- * Find the correct struct clk for the device and connection ID.
- * We do slightly fuzzy matching here:
- *  An entry with a NULL ID is assumed to be a wildcard.
- *  If an entry has a device ID, it must match
- *  If an entry has a connection ID, it must match
- * Then we take the most specific entry - with the following
- * order of precedence: dev+con > dev only > con only.
- */
-static struct clk *clk_find(const char *dev_id, const char *con_id)
-{
-	struct clk_lookup *p;
-	struct clk *clk = NULL;
-	int match, best = 0;
-
-	list_for_each_entry(p, &clocks, node) {
-		match = 0;
-		if (p->dev_id) {
-			if (!dev_id || strcmp(p->dev_id, dev_id))
-				continue;
-			match += 2;
-		}
-		if (p->con_id) {
-			if (!con_id || strcmp(p->con_id, con_id))
-				continue;
-			match += 1;
-		}
-		if (match == 0)
-			continue;
-
-		if (match > best) {
-			clk = p->clk;
-			best = match;
-		}
-	}
-	return clk;
-}
-
-struct clk *clk_get_sys(const char *dev_id, const char *con_id)
-{
-	struct clk *clk;
-
-	mutex_lock(&clocks_mutex);
-	clk = clk_find(dev_id, con_id);
-	mutex_unlock(&clocks_mutex);
-
-	return clk ? clk : ERR_PTR(-ENOENT);
-}
-EXPORT_SYMBOL(clk_get_sys);
-
-void clkdev_add(struct clk_lookup *cl)
-{
-	mutex_lock(&clocks_mutex);
-	list_add_tail(&cl->node, &clocks);
-	mutex_unlock(&clocks_mutex);
-}
-EXPORT_SYMBOL(clkdev_add);
-
-void __init clkdev_add_table(struct clk_lookup *cl, size_t num)
-{
-	mutex_lock(&clocks_mutex);
-	while (num--) {
-		list_add_tail(&cl->node, &clocks);
-		cl++;
-	}
-	mutex_unlock(&clocks_mutex);
-}
-
-#define MAX_DEV_ID	20
-#define MAX_CON_ID	16
-
-struct clk_lookup_alloc {
-	struct clk_lookup cl;
-	char	dev_id[MAX_DEV_ID];
-	char	con_id[MAX_CON_ID];
-};
-
-struct clk_lookup * __init_refok
-clkdev_alloc(struct clk *clk, const char *con_id, const char *dev_fmt, ...)
-{
-	struct clk_lookup_alloc *cla;
-
-	if (!slab_is_available())
-		cla = alloc_bootmem_low_pages(sizeof(*cla));
-	else
-		cla = kzalloc(sizeof(*cla), GFP_KERNEL);
-
-	if (!cla)
-		return NULL;
-
-	cla->cl.clk = clk;
-	if (con_id) {
-		strlcpy(cla->con_id, con_id, sizeof(cla->con_id));
-		cla->cl.con_id = cla->con_id;
-	}
-
-	if (dev_fmt) {
-		va_list ap;
-
-		va_start(ap, dev_fmt);
-		vscnprintf(cla->dev_id, sizeof(cla->dev_id), dev_fmt, ap);
-		cla->cl.dev_id = cla->dev_id;
-		va_end(ap);
-	}
-
-	return &cla->cl;
-}
-EXPORT_SYMBOL(clkdev_alloc);
-
-int clk_add_alias(const char *alias, const char *alias_dev_name, char *id,
-	struct device *dev)
-{
-	struct clk *r = clk_get(dev, id);
-	struct clk_lookup *l;
-
-	if (IS_ERR(r))
-		return PTR_ERR(r);
-
-	l = clkdev_alloc(r, alias, alias_dev_name);
-	clk_put(r);
-	if (!l)
-		return -ENODEV;
-	clkdev_add(l);
-	return 0;
-}
-EXPORT_SYMBOL(clk_add_alias);
-
-/*
- * clkdev_drop - remove a clock dynamically allocated
- */
-void clkdev_drop(struct clk_lookup *cl)
-{
-	mutex_lock(&clocks_mutex);
-	list_del(&cl->node);
-	mutex_unlock(&clocks_mutex);
-	kfree(cl);
-}
-EXPORT_SYMBOL(clkdev_drop);
diff --git a/arch/sh/kernel/cpu/clock.c b/arch/sh/kernel/cpu/clock.c
index 50f887d..4187cf4 100644
--- a/arch/sh/kernel/cpu/clock.c
+++ b/arch/sh/kernel/cpu/clock.c
@@ -48,20 +48,4 @@ int __init clk_init(void)
 	return ret;
 }
 
-/*
- * Returns a clock. Note that we first try to use device id on the bus
- * and clock name. If this fails, we try to use clock name only.
- */
-struct clk *clk_get(struct device *dev, const char *con_id)
-{
-	const char *dev_id = dev ? dev_name(dev) : NULL;
-
-	return clk_get_sys(dev_id, con_id);
-}
-EXPORT_SYMBOL_GPL(clk_get);
-
-void clk_put(struct clk *clk)
-{
-}
-EXPORT_SYMBOL_GPL(clk_put);
 
diff --git a/drivers/Kconfig b/drivers/Kconfig
index a2b902f..3d93b3a 100644
--- a/drivers/Kconfig
+++ b/drivers/Kconfig
@@ -111,4 +111,6 @@ source "drivers/xen/Kconfig"
 source "drivers/staging/Kconfig"
 
 source "drivers/platform/Kconfig"
+
+source "drivers/clk/Kconfig"
 endmenu
diff --git a/drivers/Makefile b/drivers/Makefile
index ae47344..b0e30b2 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -115,3 +115,5 @@ obj-$(CONFIG_VLYNQ)		+= vlynq/
 obj-$(CONFIG_STAGING)		+= staging/
 obj-y				+= platform/
 obj-y				+= ieee802154/
+#common clk code
+obj-y				+= clk/
diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig
new file mode 100644
index 0000000..cc5272c
--- /dev/null
+++ b/drivers/clk/Kconfig
@@ -0,0 +1,4 @@
+
+config LOOKUP_CLKDEV
+	bool
+	select HAVE_CLK
diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
new file mode 100644
index 0000000..288d997
--- /dev/null
+++ b/drivers/clk/Makefile
@@ -0,0 +1,2 @@
+
+obj-$(CONFIG_LOOKUP_CLKDEV)	+= lookup_clkdev.o
diff --git a/arch/arm/common/clkdev.c b/drivers/clk/lookup_clkdev.c
similarity index 89%
rename from arch/arm/common/clkdev.c
rename to drivers/clk/lookup_clkdev.c
index e2b2bb6..0a19626 100644
--- a/arch/arm/common/clkdev.c
+++ b/drivers/clk/lookup_clkdev.c
@@ -1,5 +1,5 @@
 /*
- *  arch/arm/common/clkdev.c
+ * drivers/clk/lookup_clkdev.c
  *
  *  Copyright (C) 2008 Russell King.
  *
@@ -21,7 +21,7 @@
 #include <linux/slab.h>
 
 #include <asm/clkdev.h>
-#include <mach/clkdev.h>
+#include <asm/lookup_clkdev.h>
 
 static LIST_HEAD(clocks);
 static DEFINE_MUTEX(clocks_mutex);
@@ -79,19 +79,23 @@ struct clk *clk_get_sys(const char *dev_id, const char *con_id)
 }
 EXPORT_SYMBOL(clk_get_sys);
 
+/*
+ * Returns a clock. Note that we first try to use device id on the bus
+ * and clock name. If this fails, we try to use clock name only.
+ */
 struct clk *clk_get(struct device *dev, const char *con_id)
 {
 	const char *dev_id = dev ? dev_name(dev) : NULL;
 
 	return clk_get_sys(dev_id, con_id);
 }
-EXPORT_SYMBOL(clk_get);
+EXPORT_SYMBOL_GPL(clk_get);
 
 void clk_put(struct clk *clk)
 {
 	__clk_put(clk);
 }
-EXPORT_SYMBOL(clk_put);
+EXPORT_SYMBOL_GPL(clk_put);
 
 void clkdev_add(struct clk_lookup *cl)
 {
@@ -120,12 +124,12 @@ struct clk_lookup_alloc {
 	char	con_id[MAX_CON_ID];
 };
 
-struct clk_lookup *clkdev_alloc(struct clk *clk, const char *con_id,
-	const char *dev_fmt, ...)
+struct clk_lookup * __init_refok
+clkdev_alloc(struct clk *clk, const char *con_id, const char *dev_fmt, ...)
 {
 	struct clk_lookup_alloc *cla;
 
-	cla = kzalloc(sizeof(*cla), GFP_KERNEL);
+	cla = arch_kzalloc(sizeof(*cla));
 	if (!cla)
 		return NULL;
 
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* Re: [RFC] [PATCH] arm & sh: factorised duplicated clkdev.c
  2010-08-31 11:16 ` Jean-Christophe PLAGNIOL-VILLARD
@ 2010-09-01  9:12   ` Russell King - ARM Linux
  -1 siblings, 0 replies; 133+ messages in thread
From: Russell King - ARM Linux @ 2010-09-01  9:12 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Aug 31, 2010 at 01:16:42PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> factorise some generic infrastructure to assist looking up struct clks
> for the ARM & SH architecture.
> +/*
> + * Returns a clock. Note that we first try to use device id on the bus
> + * and clock name. If this fails, we try to use clock name only.
> + */
>  struct clk *clk_get(struct device *dev, const char *con_id)
>  {
>  	const char *dev_id = dev ? dev_name(dev) : NULL;
>  
>  	return clk_get_sys(dev_id, con_id);
>  }
> -EXPORT_SYMBOL(clk_get);
> +EXPORT_SYMBOL_GPL(clk_get);
>  
>  void clk_put(struct clk *clk)
>  {
>  	__clk_put(clk);
>  }
> -EXPORT_SYMBOL(clk_put);
> +EXPORT_SYMBOL_GPL(clk_put);

Please leave these as-is.

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [RFC] [PATCH] arm & sh: factorised duplicated clkdev.c
@ 2010-09-01  9:12   ` Russell King - ARM Linux
  0 siblings, 0 replies; 133+ messages in thread
From: Russell King - ARM Linux @ 2010-09-01  9:12 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Aug 31, 2010 at 01:16:42PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> factorise some generic infrastructure to assist looking up struct clks
> for the ARM & SH architecture.
> +/*
> + * Returns a clock. Note that we first try to use device id on the bus
> + * and clock name. If this fails, we try to use clock name only.
> + */
>  struct clk *clk_get(struct device *dev, const char *con_id)
>  {
>  	const char *dev_id = dev ? dev_name(dev) : NULL;
>  
>  	return clk_get_sys(dev_id, con_id);
>  }
> -EXPORT_SYMBOL(clk_get);
> +EXPORT_SYMBOL_GPL(clk_get);
>  
>  void clk_put(struct clk *clk)
>  {
>  	__clk_put(clk);
>  }
> -EXPORT_SYMBOL(clk_put);
> +EXPORT_SYMBOL_GPL(clk_put);

Please leave these as-is.

^ permalink raw reply	[flat|nested] 133+ messages in thread

* Re: [RFC] [PATCH] arm & sh: factorised duplicated clkdev.c
  2010-08-31 11:16 ` Jean-Christophe PLAGNIOL-VILLARD
@ 2010-09-01  9:51   ` Uwe Kleine-König
  -1 siblings, 0 replies; 133+ messages in thread
From:  @ 2010-09-01  9:51 UTC (permalink / raw)
  To: linux-arm-kernel

Hello,

On Tue, Aug 31, 2010 at 01:16:42PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> factorise some generic infrastructure to assist looking up struct clks
> for the ARM & SH architecture.
> 
> as the code is identical at 99%
> 
> put the arch specific code for allocation as example in asm/lookup_clkdev.h
> 
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> ---
>  arch/arm/Kconfig                                   |   40 +++---
>  arch/arm/common/Kconfig                            |    4 -
>  arch/arm/common/Makefile                           |    1 -
>  arch/arm/include/asm/lookup_clkdev.h               |   23 +++
>  arch/arm/mach-shmobile/Kconfig                     |    6 +-
>  arch/arm/plat-omap/Kconfig                         |    4 +-
>  arch/sh/Kconfig                                    |    2 +-
>  arch/sh/include/asm/lookup_clkdev.h                |   29 ++++
>  arch/sh/kernel/Makefile                            |    2 +-
>  arch/sh/kernel/clkdev.c                            |  169 --------------------
>  arch/sh/kernel/cpu/clock.c                         |   16 --
>  drivers/Kconfig                                    |    2 +
>  drivers/Makefile                                   |    2 +
>  drivers/clk/Kconfig                                |    4 +
>  drivers/clk/Makefile                               |    2 +
>  .../common/clkdev.c => drivers/clk/lookup_clkdev.c |   18 ++-
>  16 files changed, 100 insertions(+), 224 deletions(-)
>  create mode 100644 arch/arm/include/asm/lookup_clkdev.h
>  create mode 100644 arch/sh/include/asm/lookup_clkdev.h
>  delete mode 100644 arch/sh/kernel/clkdev.c
>  create mode 100644 drivers/clk/Kconfig
>  create mode 100644 drivers/clk/Makefile
>  rename arch/arm/common/clkdev.c => drivers/clk/lookup_clkdev.c (89%)
> 
> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
> index a7ed21f..e7ef725 100644
> --- a/arch/arm/Kconfig
> +++ b/arch/arm/Kconfig
> @@ -221,7 +221,7 @@ config ARCH_INTEGRATOR
>  	bool "ARM Ltd. Integrator family"
>  	select ARM_AMBA
>  	select ARCH_HAS_CPUFREQ
> -	select COMMON_CLKDEV
> +	select LOOKUP_CLKDEV
>  	select ICST
>  	select GENERIC_CLOCKEVENTS
>  	select PLAT_VERSATILE
> @@ -231,7 +231,7 @@ config ARCH_INTEGRATOR
>  config ARCH_REALVIEW
>  	bool "ARM Ltd. RealView family"
>  	select ARM_AMBA
> -	select COMMON_CLKDEV
> +	select LOOKUP_CLKDEV
>  	select ICST
>  	select GENERIC_CLOCKEVENTS
>  	select ARCH_WANT_OPTIONAL_GPIOLIB
> @@ -245,7 +245,7 @@ config ARCH_VERSATILE
>  	bool "ARM Ltd. Versatile family"
>  	select ARM_AMBA
>  	select ARM_VIC
> -	select COMMON_CLKDEV
> +	select LOOKUP_CLKDEV
>  	select ICST
>  	select GENERIC_CLOCKEVENTS
>  	select ARCH_WANT_OPTIONAL_GPIOLIB
> @@ -259,7 +259,7 @@ config ARCH_VEXPRESS
>  	select ARCH_WANT_OPTIONAL_GPIOLIB
>  	select ARM_AMBA
>  	select ARM_TIMER_SP804
> -	select COMMON_CLKDEV
> +	select LOOKUP_CLKDEV
>  	select GENERIC_CLOCKEVENTS
>  	select HAVE_CLK
>  	select ICST
> @@ -281,7 +281,7 @@ config ARCH_BCMRING
>  	depends on MMU
>  	select CPU_V6
>  	select ARM_AMBA
> -	select COMMON_CLKDEV
> +	select LOOKUP_CLKDEV
>  	select GENERIC_CLOCKEVENTS
>  	select ARCH_WANT_OPTIONAL_GPIOLIB
>  	help
> @@ -328,7 +328,7 @@ config ARCH_EP93XX
>  	select CPU_ARM920T
>  	select ARM_AMBA
>  	select ARM_VIC
> -	select COMMON_CLKDEV
> +	select LOOKUP_CLKDEV
>  	select ARCH_REQUIRE_GPIOLIB
>  	select ARCH_HAS_HOLES_MEMORYMODEL
>  	select ARCH_USES_GETTIMEOFFSET
> @@ -348,14 +348,14 @@ config ARCH_MXC
>  	bool "Freescale MXC/iMX-based"
>  	select GENERIC_CLOCKEVENTS
>  	select ARCH_REQUIRE_GPIOLIB
> -	select COMMON_CLKDEV
> +	select LOOKUP_CLKDEV
>  	help
>  	  Support for Freescale MXC/iMX-based family of processors
>  
>  config ARCH_STMP3XXX
>  	bool "Freescale STMP3xxx"
>  	select CPU_ARM926T
> -	select COMMON_CLKDEV
> +	select LOOKUP_CLKDEV
>  	select ARCH_REQUIRE_GPIOLIB
>  	select GENERIC_CLOCKEVENTS
>  	select USB_ARCH_HAS_EHCI
> @@ -473,7 +473,7 @@ config ARCH_LPC32XX
>  	select HAVE_IDE
>  	select ARM_AMBA
>  	select USB_ARCH_HAS_OHCI
> -	select COMMON_CLKDEV
> +	select LOOKUP_CLKDEV
>  	select GENERIC_TIME
>  	select GENERIC_CLOCKEVENTS
>  	help
> @@ -507,7 +507,7 @@ config ARCH_MMP
>  	bool "Marvell PXA168/910/MMP2"
>  	depends on MMU
>  	select ARCH_REQUIRE_GPIOLIB
> -	select COMMON_CLKDEV
> +	select LOOKUP_CLKDEV
>  	select GENERIC_CLOCKEVENTS
>  	select TICK_ONESHOT
>  	select PLAT_PXA
> @@ -539,7 +539,7 @@ config ARCH_W90X900
>  	bool "Nuvoton W90X900 CPU"
>  	select CPU_ARM926T
>  	select ARCH_REQUIRE_GPIOLIB
> -	select COMMON_CLKDEV
> +	select LOOKUP_CLKDEV
>  	select GENERIC_CLOCKEVENTS
>  	help
>  	  Support for Nuvoton (Winbond logic dept.) ARM9 processor,
> @@ -553,7 +553,7 @@ config ARCH_W90X900
>  config ARCH_NUC93X
>  	bool "Nuvoton NUC93X CPU"
>  	select CPU_ARM926T
> -	select COMMON_CLKDEV
> +	select LOOKUP_CLKDEV
>  	help
>  	  Support for Nuvoton (Winbond logic dept.) NUC93X MCU,The NUC93X is a
>  	  low-power and high performance MPEG-4/JPEG multimedia controller chip.
> @@ -564,7 +564,7 @@ config ARCH_TEGRA
>  	select GENERIC_CLOCKEVENTS
>  	select GENERIC_GPIO
>  	select HAVE_CLK
> -	select COMMON_CLKDEV
> +	select LOOKUP_CLKDEV
>  	select ARCH_HAS_BARRIERS if CACHE_L2X0
>  	help
>  	  This enables support for NVIDIA Tegra based systems (Tegra APX,
> @@ -573,7 +573,7 @@ config ARCH_TEGRA
>  config ARCH_PNX4008
>  	bool "Philips Nexperia PNX4008 Mobile"
>  	select CPU_ARM926T
> -	select COMMON_CLKDEV
> +	select LOOKUP_CLKDEV
>  	select ARCH_USES_GETTIMEOFFSET
>  	help
>  	  This enables support for Philips PNX4008 mobile platform.
> @@ -583,7 +583,7 @@ config ARCH_PXA
>  	depends on MMU
>  	select ARCH_MTD_XIP
>  	select ARCH_HAS_CPUFREQ
> -	select COMMON_CLKDEV
> +	select LOOKUP_CLKDEV
>  	select ARCH_REQUIRE_GPIOLIB
>  	select GENERIC_CLOCKEVENTS
>  	select TICK_ONESHOT
> @@ -767,7 +767,7 @@ config ARCH_U300
>  	select ARM_AMBA
>  	select ARM_VIC
>  	select GENERIC_CLOCKEVENTS
> -	select COMMON_CLKDEV
> +	select LOOKUP_CLKDEV
>  	select GENERIC_GPIO
>  	help
>  	  Support for ST-Ericsson U300 series mobile platforms.
> @@ -777,7 +777,7 @@ config ARCH_U8500
>  	select CPU_V7
>  	select ARM_AMBA
>  	select GENERIC_CLOCKEVENTS
> -	select COMMON_CLKDEV
> +	select LOOKUP_CLKDEV
>  	select ARCH_REQUIRE_GPIOLIB
>  	help
>  	  Support for ST-Ericsson's Ux500 architecture
> @@ -787,7 +787,7 @@ config ARCH_NOMADIK
>  	select ARM_AMBA
>  	select ARM_VIC
>  	select CPU_ARM926T
> -	select COMMON_CLKDEV
> +	select LOOKUP_CLKDEV
>  	select GENERIC_CLOCKEVENTS
>  	select ARCH_REQUIRE_GPIOLIB
>  	help
> @@ -799,7 +799,7 @@ config ARCH_DAVINCI
>  	select ARCH_REQUIRE_GPIOLIB
>  	select ZONE_DMA
>  	select HAVE_IDE
> -	select COMMON_CLKDEV
> +	select LOOKUP_CLKDEV
>  	select GENERIC_ALLOCATOR
>  	select ARCH_HAS_HOLES_MEMORYMODEL
>  	help
> @@ -819,7 +819,7 @@ config PLAT_SPEAR
>  	bool "ST SPEAr"
>  	select ARM_AMBA
>  	select ARCH_REQUIRE_GPIOLIB
> -	select COMMON_CLKDEV
> +	select LOOKUP_CLKDEV
>  	select GENERIC_CLOCKEVENTS
>  	select HAVE_CLK
>  	help
> diff --git a/arch/arm/common/Kconfig b/arch/arm/common/Kconfig
> index 0a34c81..778655f 100644
> --- a/arch/arm/common/Kconfig
> +++ b/arch/arm/common/Kconfig
> @@ -37,7 +37,3 @@ config SHARP_PARAM
>  
>  config SHARP_SCOOP
>  	bool
> -
> -config COMMON_CLKDEV
> -	bool
> -	select HAVE_CLK
> diff --git a/arch/arm/common/Makefile b/arch/arm/common/Makefile
> index e6e8664..799e140 100644
> --- a/arch/arm/common/Makefile
> +++ b/arch/arm/common/Makefile
> @@ -16,4 +16,3 @@ obj-$(CONFIG_SHARP_SCOOP)	+= scoop.o
>  obj-$(CONFIG_ARCH_IXP2000)	+= uengine.o
>  obj-$(CONFIG_ARCH_IXP23XX)	+= uengine.o
>  obj-$(CONFIG_PCI_HOST_ITE8152)  += it8152.o
> -obj-$(CONFIG_COMMON_CLKDEV)	+= clkdev.o
> diff --git a/arch/arm/include/asm/lookup_clkdev.h b/arch/arm/include/asm/lookup_clkdev.h
> new file mode 100644
> index 0000000..d57f7a6
> --- /dev/null
> +++ b/arch/arm/include/asm/lookup_clkdev.h
> @@ -0,0 +1,23 @@
> +/*
> + *  arch/arm/common/clkdev.c
This line is wrong.

> + *
> + *  Copyright (C) 2008 Russell King.
> + *
> + * 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.
> + *
> + * Helper for the clk API to assist looking up a struct clk.
> + */
> +
> +#ifndef __LOOKUP_CLK_DEV__
> +#define __LOOKUP_CLK_DEV__
> +
> +#include <mach/clkdev.h>
> +
> +static __inline__ struct clk_lookup_alloc *arch_kzalloc(size_t size)
> +{
> +	return kzalloc(size, GFP_KERNEL);
> +}
Is this really needed?  If yes it should either be in a different header
of be named clk_lookup_alloc or similar.
> +
> +#endif /* __LOOKUP_CLK_DEV__ */
> diff --git a/arch/arm/mach-shmobile/Kconfig b/arch/arm/mach-shmobile/Kconfig
> index 54b479c..e4e964b 100644
> --- a/arch/arm/mach-shmobile/Kconfig
> +++ b/arch/arm/mach-shmobile/Kconfig
> @@ -6,7 +6,7 @@ config ARCH_SH7367
>  	bool "SH-Mobile G3 (SH7367)"
>  	select CPU_V6
>  	select HAVE_CLK
> -	select COMMON_CLKDEV
> +	select LOOKUP_CLKDEV
>  	select SH_CLK_CPG
>  	select GENERIC_CLOCKEVENTS
>  
> @@ -14,7 +14,7 @@ config ARCH_SH7377
>  	bool "SH-Mobile G4 (SH7377)"
>  	select CPU_V7
>  	select HAVE_CLK
> -	select COMMON_CLKDEV
> +	select LOOKUP_CLKDEV
>  	select SH_CLK_CPG
>  	select GENERIC_CLOCKEVENTS
>  
> @@ -22,7 +22,7 @@ config ARCH_SH7372
>  	bool "SH-Mobile AP4 (SH7372)"
>  	select CPU_V7
>  	select HAVE_CLK
> -	select COMMON_CLKDEV
> +	select LOOKUP_CLKDEV
>  	select SH_CLK_CPG
>  	select GENERIC_CLOCKEVENTS
>  
> diff --git a/arch/arm/plat-omap/Kconfig b/arch/arm/plat-omap/Kconfig
> index e39a417..daba55a 100644
> --- a/arch/arm/plat-omap/Kconfig
> +++ b/arch/arm/plat-omap/Kconfig
> @@ -11,13 +11,13 @@ choice
>  
>  config ARCH_OMAP1
>  	bool "TI OMAP1"
> -	select COMMON_CLKDEV
> +	select LOOKUP_CLKDEV
>  	help
>  	  "Systems based on omap7xx, omap15xx or omap16xx"
>  
>  config ARCH_OMAP2PLUS
>  	bool "TI OMAP2/3/4"
> -	select COMMON_CLKDEV
> +	select LOOKUP_CLKDEV
>  	help
>  	  "Systems based on omap24xx, omap34xx or omap44xx"
>  
> diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
> index 33990fa..6b7d206 100644
> --- a/arch/sh/Kconfig
> +++ b/arch/sh/Kconfig
> @@ -8,7 +8,7 @@ mainmenu "Linux/SuperH Kernel Configuration"
>  config SUPERH
>  	def_bool y
>  	select EMBEDDED
> -	select HAVE_CLK
> +	select LOOKUP_CLKDEV
>  	select HAVE_IDE if HAS_IOPORT
>  	select HAVE_MEMBLOCK
>  	select HAVE_OPROFILE
> diff --git a/arch/sh/include/asm/lookup_clkdev.h b/arch/sh/include/asm/lookup_clkdev.h
> new file mode 100644
> index 0000000..9ac7b10
> --- /dev/null
> +++ b/arch/sh/include/asm/lookup_clkdev.h
> @@ -0,0 +1,29 @@
> +/*
> + *  Copyright (C) 2010 Paul Mundt <lethal@linux-sh.org>
> + *
> + * 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.
> + *
> + * Helper for the clk API to assist looking up a struct clk.
> + */
> +
> +#ifndef __LOOKUP_CLK_DEV__
> +#define __LOOKUP_CLK_DEV__
> +
> +#include <linux/bootmem.h>
> +#include <linux/mm.h>
> +#include <asm/clock.h>
> +
> +static __inline__ struct clk_lookup_alloc *arch_kzalloc(size_t size)
> +{
> +	if (!slab_is_available())
> +		return alloc_bootmem_low_pages(size);
> +	else
> +		return kzalloc(size, GFP_KERNEL);
> +}
> +
> +#define __clk_put(clk)
> +#define __clk_get(clk) ({ 1; })
> +
> +#endif /* __LOOKUP_CLK_DEV__ */
> diff --git a/arch/sh/kernel/Makefile b/arch/sh/kernel/Makefile
> index e25f3c6..e4fe614 100644
> --- a/arch/sh/kernel/Makefile
> +++ b/arch/sh/kernel/Makefile
> @@ -11,7 +11,7 @@ endif
>  
>  CFLAGS_REMOVE_return_address.o = -pg
>  
> -obj-y	:= clkdev.o debugtraps.o dma-nommu.o dumpstack.o 		\
> +obj-y	:= debugtraps.o dma-nommu.o dumpstack.o 			\
>  	   idle.o io.o irq.o						\
>  	   irq_$(BITS).o machvec.o nmi_debug.o process.o		\
>  	   process_$(BITS).o ptrace_$(BITS).o				\
> diff --git a/arch/sh/kernel/clkdev.c b/arch/sh/kernel/clkdev.c
> deleted file mode 100644
> index befc255..0000000
> --- a/arch/sh/kernel/clkdev.c
> +++ /dev/null
> @@ -1,169 +0,0 @@
> -/*
> - * arch/sh/kernel/clkdev.c
> - *
> - * Cloned from arch/arm/common/clkdev.c:
> - *
> - *  Copyright (C) 2008 Russell King.
> - *
> - * 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.
> - *
> - * Helper for the clk API to assist looking up a struct clk.
> - */
> -#include <linux/module.h>
> -#include <linux/kernel.h>
> -#include <linux/device.h>
> -#include <linux/list.h>
> -#include <linux/errno.h>
> -#include <linux/err.h>
> -#include <linux/string.h>
> -#include <linux/mutex.h>
> -#include <linux/clk.h>
> -#include <linux/slab.h>
> -#include <linux/bootmem.h>
> -#include <linux/mm.h>
> -#include <asm/clock.h>
> -#include <asm/clkdev.h>
> -
> -static LIST_HEAD(clocks);
> -static DEFINE_MUTEX(clocks_mutex);
> -
> -/*
> - * Find the correct struct clk for the device and connection ID.
> - * We do slightly fuzzy matching here:
> - *  An entry with a NULL ID is assumed to be a wildcard.
> - *  If an entry has a device ID, it must match
> - *  If an entry has a connection ID, it must match
> - * Then we take the most specific entry - with the following
> - * order of precedence: dev+con > dev only > con only.
> - */
> -static struct clk *clk_find(const char *dev_id, const char *con_id)
> -{
> -	struct clk_lookup *p;
> -	struct clk *clk = NULL;
> -	int match, best = 0;
> -
> -	list_for_each_entry(p, &clocks, node) {
> -		match = 0;
> -		if (p->dev_id) {
> -			if (!dev_id || strcmp(p->dev_id, dev_id))
> -				continue;
> -			match += 2;
> -		}
> -		if (p->con_id) {
> -			if (!con_id || strcmp(p->con_id, con_id))
> -				continue;
> -			match += 1;
> -		}
> -		if (match = 0)
> -			continue;
> -
> -		if (match > best) {
> -			clk = p->clk;
> -			best = match;
> -		}
> -	}
> -	return clk;
> -}
> -
> -struct clk *clk_get_sys(const char *dev_id, const char *con_id)
> -{
> -	struct clk *clk;
> -
> -	mutex_lock(&clocks_mutex);
> -	clk = clk_find(dev_id, con_id);
> -	mutex_unlock(&clocks_mutex);
> -
> -	return clk ? clk : ERR_PTR(-ENOENT);
> -}
> -EXPORT_SYMBOL(clk_get_sys);
> -
> -void clkdev_add(struct clk_lookup *cl)
> -{
> -	mutex_lock(&clocks_mutex);
> -	list_add_tail(&cl->node, &clocks);
> -	mutex_unlock(&clocks_mutex);
> -}
> -EXPORT_SYMBOL(clkdev_add);
> -
> -void __init clkdev_add_table(struct clk_lookup *cl, size_t num)
> -{
> -	mutex_lock(&clocks_mutex);
> -	while (num--) {
> -		list_add_tail(&cl->node, &clocks);
> -		cl++;
> -	}
> -	mutex_unlock(&clocks_mutex);
> -}
> -
> -#define MAX_DEV_ID	20
> -#define MAX_CON_ID	16
> -
> -struct clk_lookup_alloc {
> -	struct clk_lookup cl;
> -	char	dev_id[MAX_DEV_ID];
> -	char	con_id[MAX_CON_ID];
> -};
> -
> -struct clk_lookup * __init_refok
> -clkdev_alloc(struct clk *clk, const char *con_id, const char *dev_fmt, ...)
> -{
> -	struct clk_lookup_alloc *cla;
> -
> -	if (!slab_is_available())
> -		cla = alloc_bootmem_low_pages(sizeof(*cla));
> -	else
> -		cla = kzalloc(sizeof(*cla), GFP_KERNEL);
> -
> -	if (!cla)
> -		return NULL;
> -
> -	cla->cl.clk = clk;
> -	if (con_id) {
> -		strlcpy(cla->con_id, con_id, sizeof(cla->con_id));
> -		cla->cl.con_id = cla->con_id;
> -	}
> -
> -	if (dev_fmt) {
> -		va_list ap;
> -
> -		va_start(ap, dev_fmt);
> -		vscnprintf(cla->dev_id, sizeof(cla->dev_id), dev_fmt, ap);
> -		cla->cl.dev_id = cla->dev_id;
> -		va_end(ap);
> -	}
> -
> -	return &cla->cl;
> -}
> -EXPORT_SYMBOL(clkdev_alloc);
> -
> -int clk_add_alias(const char *alias, const char *alias_dev_name, char *id,
> -	struct device *dev)
> -{
> -	struct clk *r = clk_get(dev, id);
> -	struct clk_lookup *l;
> -
> -	if (IS_ERR(r))
> -		return PTR_ERR(r);
> -
> -	l = clkdev_alloc(r, alias, alias_dev_name);
> -	clk_put(r);
> -	if (!l)
> -		return -ENODEV;
> -	clkdev_add(l);
> -	return 0;
> -}
> -EXPORT_SYMBOL(clk_add_alias);
> -
> -/*
> - * clkdev_drop - remove a clock dynamically allocated
> - */
> -void clkdev_drop(struct clk_lookup *cl)
> -{
> -	mutex_lock(&clocks_mutex);
> -	list_del(&cl->node);
> -	mutex_unlock(&clocks_mutex);
> -	kfree(cl);
> -}
> -EXPORT_SYMBOL(clkdev_drop);
> diff --git a/arch/sh/kernel/cpu/clock.c b/arch/sh/kernel/cpu/clock.c
> index 50f887d..4187cf4 100644
> --- a/arch/sh/kernel/cpu/clock.c
> +++ b/arch/sh/kernel/cpu/clock.c
> @@ -48,20 +48,4 @@ int __init clk_init(void)
>  	return ret;
>  }
>  
> -/*
> - * Returns a clock. Note that we first try to use device id on the bus
> - * and clock name. If this fails, we try to use clock name only.
> - */
> -struct clk *clk_get(struct device *dev, const char *con_id)
> -{
> -	const char *dev_id = dev ? dev_name(dev) : NULL;
> -
> -	return clk_get_sys(dev_id, con_id);
> -}
> -EXPORT_SYMBOL_GPL(clk_get);
> -
> -void clk_put(struct clk *clk)
> -{
> -}
> -EXPORT_SYMBOL_GPL(clk_put);
>  
> diff --git a/drivers/Kconfig b/drivers/Kconfig
> index a2b902f..3d93b3a 100644
> --- a/drivers/Kconfig
> +++ b/drivers/Kconfig
> @@ -111,4 +111,6 @@ source "drivers/xen/Kconfig"
>  source "drivers/staging/Kconfig"
>  
>  source "drivers/platform/Kconfig"
> +
> +source "drivers/clk/Kconfig"
>  endmenu
> diff --git a/drivers/Makefile b/drivers/Makefile
> index ae47344..b0e30b2 100644
> --- a/drivers/Makefile
> +++ b/drivers/Makefile
> @@ -115,3 +115,5 @@ obj-$(CONFIG_VLYNQ)		+= vlynq/
>  obj-$(CONFIG_STAGING)		+= staging/
>  obj-y				+= platform/
>  obj-y				+= ieee802154/
> +#common clk code
> +obj-y				+= clk/
> diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig
> new file mode 100644
> index 0000000..cc5272c
> --- /dev/null
> +++ b/drivers/clk/Kconfig
> @@ -0,0 +1,4 @@
> +
> +config LOOKUP_CLKDEV
> +	bool
> +	select HAVE_CLK
> diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
> new file mode 100644
> index 0000000..288d997
> --- /dev/null
> +++ b/drivers/clk/Makefile
> @@ -0,0 +1,2 @@
> +
> +obj-$(CONFIG_LOOKUP_CLKDEV)	+= lookup_clkdev.o
> diff --git a/arch/arm/common/clkdev.c b/drivers/clk/lookup_clkdev.c
> similarity index 89%
> rename from arch/arm/common/clkdev.c
> rename to drivers/clk/lookup_clkdev.c
> index e2b2bb6..0a19626 100644
> --- a/arch/arm/common/clkdev.c
> +++ b/drivers/clk/lookup_clkdev.c
> @@ -1,5 +1,5 @@
>  /*
> - *  arch/arm/common/clkdev.c
> + * drivers/clk/lookup_clkdev.c
>   *
>   *  Copyright (C) 2008 Russell King.
>   *
> @@ -21,7 +21,7 @@
>  #include <linux/slab.h>
>  
>  #include <asm/clkdev.h>
> -#include <mach/clkdev.h>
> +#include <asm/lookup_clkdev.h>
>  
>  static LIST_HEAD(clocks);
>  static DEFINE_MUTEX(clocks_mutex);
> @@ -79,19 +79,23 @@ struct clk *clk_get_sys(const char *dev_id, const char *con_id)
>  }
>  EXPORT_SYMBOL(clk_get_sys);
>  
> +/*
> + * Returns a clock. Note that we first try to use device id on the bus
> + * and clock name. If this fails, we try to use clock name only.
> + */
>  struct clk *clk_get(struct device *dev, const char *con_id)
>  {
>  	const char *dev_id = dev ? dev_name(dev) : NULL;
>  
>  	return clk_get_sys(dev_id, con_id);
>  }
> -EXPORT_SYMBOL(clk_get);
> +EXPORT_SYMBOL_GPL(clk_get);
>  
>  void clk_put(struct clk *clk)
>  {
>  	__clk_put(clk);
>  }
> -EXPORT_SYMBOL(clk_put);
> +EXPORT_SYMBOL_GPL(clk_put);
>  
>  void clkdev_add(struct clk_lookup *cl)
>  {
> @@ -120,12 +124,12 @@ struct clk_lookup_alloc {
>  	char	con_id[MAX_CON_ID];
>  };
>  
> -struct clk_lookup *clkdev_alloc(struct clk *clk, const char *con_id,
> -	const char *dev_fmt, ...)
> +struct clk_lookup * __init_refok
Why do you need __init_refok?  __init_refok is defined as follows in
include/linux/init.h:

	/* compatibility defines */
	#define __init_refok     __ref

So if really needed better use __ref.  Couldn't this be __init?  

> +clkdev_alloc(struct clk *clk, const char *con_id, const char *dev_fmt, ...)
>  {
>  	struct clk_lookup_alloc *cla;
>  
> -	cla = kzalloc(sizeof(*cla), GFP_KERNEL);
> +	cla = arch_kzalloc(sizeof(*cla));
>  	if (!cla)
>  		return NULL;
Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [RFC] [PATCH] arm & sh: factorised duplicated clkdev.c
@ 2010-09-01  9:51   ` Uwe Kleine-König
  0 siblings, 0 replies; 133+ messages in thread
From: Uwe Kleine-König @ 2010-09-01  9:51 UTC (permalink / raw)
  To: linux-arm-kernel

Hello,

On Tue, Aug 31, 2010 at 01:16:42PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> factorise some generic infrastructure to assist looking up struct clks
> for the ARM & SH architecture.
> 
> as the code is identical at 99%
> 
> put the arch specific code for allocation as example in asm/lookup_clkdev.h
> 
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> ---
>  arch/arm/Kconfig                                   |   40 +++---
>  arch/arm/common/Kconfig                            |    4 -
>  arch/arm/common/Makefile                           |    1 -
>  arch/arm/include/asm/lookup_clkdev.h               |   23 +++
>  arch/arm/mach-shmobile/Kconfig                     |    6 +-
>  arch/arm/plat-omap/Kconfig                         |    4 +-
>  arch/sh/Kconfig                                    |    2 +-
>  arch/sh/include/asm/lookup_clkdev.h                |   29 ++++
>  arch/sh/kernel/Makefile                            |    2 +-
>  arch/sh/kernel/clkdev.c                            |  169 --------------------
>  arch/sh/kernel/cpu/clock.c                         |   16 --
>  drivers/Kconfig                                    |    2 +
>  drivers/Makefile                                   |    2 +
>  drivers/clk/Kconfig                                |    4 +
>  drivers/clk/Makefile                               |    2 +
>  .../common/clkdev.c => drivers/clk/lookup_clkdev.c |   18 ++-
>  16 files changed, 100 insertions(+), 224 deletions(-)
>  create mode 100644 arch/arm/include/asm/lookup_clkdev.h
>  create mode 100644 arch/sh/include/asm/lookup_clkdev.h
>  delete mode 100644 arch/sh/kernel/clkdev.c
>  create mode 100644 drivers/clk/Kconfig
>  create mode 100644 drivers/clk/Makefile
>  rename arch/arm/common/clkdev.c => drivers/clk/lookup_clkdev.c (89%)
> 
> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
> index a7ed21f..e7ef725 100644
> --- a/arch/arm/Kconfig
> +++ b/arch/arm/Kconfig
> @@ -221,7 +221,7 @@ config ARCH_INTEGRATOR
>  	bool "ARM Ltd. Integrator family"
>  	select ARM_AMBA
>  	select ARCH_HAS_CPUFREQ
> -	select COMMON_CLKDEV
> +	select LOOKUP_CLKDEV
>  	select ICST
>  	select GENERIC_CLOCKEVENTS
>  	select PLAT_VERSATILE
> @@ -231,7 +231,7 @@ config ARCH_INTEGRATOR
>  config ARCH_REALVIEW
>  	bool "ARM Ltd. RealView family"
>  	select ARM_AMBA
> -	select COMMON_CLKDEV
> +	select LOOKUP_CLKDEV
>  	select ICST
>  	select GENERIC_CLOCKEVENTS
>  	select ARCH_WANT_OPTIONAL_GPIOLIB
> @@ -245,7 +245,7 @@ config ARCH_VERSATILE
>  	bool "ARM Ltd. Versatile family"
>  	select ARM_AMBA
>  	select ARM_VIC
> -	select COMMON_CLKDEV
> +	select LOOKUP_CLKDEV
>  	select ICST
>  	select GENERIC_CLOCKEVENTS
>  	select ARCH_WANT_OPTIONAL_GPIOLIB
> @@ -259,7 +259,7 @@ config ARCH_VEXPRESS
>  	select ARCH_WANT_OPTIONAL_GPIOLIB
>  	select ARM_AMBA
>  	select ARM_TIMER_SP804
> -	select COMMON_CLKDEV
> +	select LOOKUP_CLKDEV
>  	select GENERIC_CLOCKEVENTS
>  	select HAVE_CLK
>  	select ICST
> @@ -281,7 +281,7 @@ config ARCH_BCMRING
>  	depends on MMU
>  	select CPU_V6
>  	select ARM_AMBA
> -	select COMMON_CLKDEV
> +	select LOOKUP_CLKDEV
>  	select GENERIC_CLOCKEVENTS
>  	select ARCH_WANT_OPTIONAL_GPIOLIB
>  	help
> @@ -328,7 +328,7 @@ config ARCH_EP93XX
>  	select CPU_ARM920T
>  	select ARM_AMBA
>  	select ARM_VIC
> -	select COMMON_CLKDEV
> +	select LOOKUP_CLKDEV
>  	select ARCH_REQUIRE_GPIOLIB
>  	select ARCH_HAS_HOLES_MEMORYMODEL
>  	select ARCH_USES_GETTIMEOFFSET
> @@ -348,14 +348,14 @@ config ARCH_MXC
>  	bool "Freescale MXC/iMX-based"
>  	select GENERIC_CLOCKEVENTS
>  	select ARCH_REQUIRE_GPIOLIB
> -	select COMMON_CLKDEV
> +	select LOOKUP_CLKDEV
>  	help
>  	  Support for Freescale MXC/iMX-based family of processors
>  
>  config ARCH_STMP3XXX
>  	bool "Freescale STMP3xxx"
>  	select CPU_ARM926T
> -	select COMMON_CLKDEV
> +	select LOOKUP_CLKDEV
>  	select ARCH_REQUIRE_GPIOLIB
>  	select GENERIC_CLOCKEVENTS
>  	select USB_ARCH_HAS_EHCI
> @@ -473,7 +473,7 @@ config ARCH_LPC32XX
>  	select HAVE_IDE
>  	select ARM_AMBA
>  	select USB_ARCH_HAS_OHCI
> -	select COMMON_CLKDEV
> +	select LOOKUP_CLKDEV
>  	select GENERIC_TIME
>  	select GENERIC_CLOCKEVENTS
>  	help
> @@ -507,7 +507,7 @@ config ARCH_MMP
>  	bool "Marvell PXA168/910/MMP2"
>  	depends on MMU
>  	select ARCH_REQUIRE_GPIOLIB
> -	select COMMON_CLKDEV
> +	select LOOKUP_CLKDEV
>  	select GENERIC_CLOCKEVENTS
>  	select TICK_ONESHOT
>  	select PLAT_PXA
> @@ -539,7 +539,7 @@ config ARCH_W90X900
>  	bool "Nuvoton W90X900 CPU"
>  	select CPU_ARM926T
>  	select ARCH_REQUIRE_GPIOLIB
> -	select COMMON_CLKDEV
> +	select LOOKUP_CLKDEV
>  	select GENERIC_CLOCKEVENTS
>  	help
>  	  Support for Nuvoton (Winbond logic dept.) ARM9 processor,
> @@ -553,7 +553,7 @@ config ARCH_W90X900
>  config ARCH_NUC93X
>  	bool "Nuvoton NUC93X CPU"
>  	select CPU_ARM926T
> -	select COMMON_CLKDEV
> +	select LOOKUP_CLKDEV
>  	help
>  	  Support for Nuvoton (Winbond logic dept.) NUC93X MCU,The NUC93X is a
>  	  low-power and high performance MPEG-4/JPEG multimedia controller chip.
> @@ -564,7 +564,7 @@ config ARCH_TEGRA
>  	select GENERIC_CLOCKEVENTS
>  	select GENERIC_GPIO
>  	select HAVE_CLK
> -	select COMMON_CLKDEV
> +	select LOOKUP_CLKDEV
>  	select ARCH_HAS_BARRIERS if CACHE_L2X0
>  	help
>  	  This enables support for NVIDIA Tegra based systems (Tegra APX,
> @@ -573,7 +573,7 @@ config ARCH_TEGRA
>  config ARCH_PNX4008
>  	bool "Philips Nexperia PNX4008 Mobile"
>  	select CPU_ARM926T
> -	select COMMON_CLKDEV
> +	select LOOKUP_CLKDEV
>  	select ARCH_USES_GETTIMEOFFSET
>  	help
>  	  This enables support for Philips PNX4008 mobile platform.
> @@ -583,7 +583,7 @@ config ARCH_PXA
>  	depends on MMU
>  	select ARCH_MTD_XIP
>  	select ARCH_HAS_CPUFREQ
> -	select COMMON_CLKDEV
> +	select LOOKUP_CLKDEV
>  	select ARCH_REQUIRE_GPIOLIB
>  	select GENERIC_CLOCKEVENTS
>  	select TICK_ONESHOT
> @@ -767,7 +767,7 @@ config ARCH_U300
>  	select ARM_AMBA
>  	select ARM_VIC
>  	select GENERIC_CLOCKEVENTS
> -	select COMMON_CLKDEV
> +	select LOOKUP_CLKDEV
>  	select GENERIC_GPIO
>  	help
>  	  Support for ST-Ericsson U300 series mobile platforms.
> @@ -777,7 +777,7 @@ config ARCH_U8500
>  	select CPU_V7
>  	select ARM_AMBA
>  	select GENERIC_CLOCKEVENTS
> -	select COMMON_CLKDEV
> +	select LOOKUP_CLKDEV
>  	select ARCH_REQUIRE_GPIOLIB
>  	help
>  	  Support for ST-Ericsson's Ux500 architecture
> @@ -787,7 +787,7 @@ config ARCH_NOMADIK
>  	select ARM_AMBA
>  	select ARM_VIC
>  	select CPU_ARM926T
> -	select COMMON_CLKDEV
> +	select LOOKUP_CLKDEV
>  	select GENERIC_CLOCKEVENTS
>  	select ARCH_REQUIRE_GPIOLIB
>  	help
> @@ -799,7 +799,7 @@ config ARCH_DAVINCI
>  	select ARCH_REQUIRE_GPIOLIB
>  	select ZONE_DMA
>  	select HAVE_IDE
> -	select COMMON_CLKDEV
> +	select LOOKUP_CLKDEV
>  	select GENERIC_ALLOCATOR
>  	select ARCH_HAS_HOLES_MEMORYMODEL
>  	help
> @@ -819,7 +819,7 @@ config PLAT_SPEAR
>  	bool "ST SPEAr"
>  	select ARM_AMBA
>  	select ARCH_REQUIRE_GPIOLIB
> -	select COMMON_CLKDEV
> +	select LOOKUP_CLKDEV
>  	select GENERIC_CLOCKEVENTS
>  	select HAVE_CLK
>  	help
> diff --git a/arch/arm/common/Kconfig b/arch/arm/common/Kconfig
> index 0a34c81..778655f 100644
> --- a/arch/arm/common/Kconfig
> +++ b/arch/arm/common/Kconfig
> @@ -37,7 +37,3 @@ config SHARP_PARAM
>  
>  config SHARP_SCOOP
>  	bool
> -
> -config COMMON_CLKDEV
> -	bool
> -	select HAVE_CLK
> diff --git a/arch/arm/common/Makefile b/arch/arm/common/Makefile
> index e6e8664..799e140 100644
> --- a/arch/arm/common/Makefile
> +++ b/arch/arm/common/Makefile
> @@ -16,4 +16,3 @@ obj-$(CONFIG_SHARP_SCOOP)	+= scoop.o
>  obj-$(CONFIG_ARCH_IXP2000)	+= uengine.o
>  obj-$(CONFIG_ARCH_IXP23XX)	+= uengine.o
>  obj-$(CONFIG_PCI_HOST_ITE8152)  += it8152.o
> -obj-$(CONFIG_COMMON_CLKDEV)	+= clkdev.o
> diff --git a/arch/arm/include/asm/lookup_clkdev.h b/arch/arm/include/asm/lookup_clkdev.h
> new file mode 100644
> index 0000000..d57f7a6
> --- /dev/null
> +++ b/arch/arm/include/asm/lookup_clkdev.h
> @@ -0,0 +1,23 @@
> +/*
> + *  arch/arm/common/clkdev.c
This line is wrong.

> + *
> + *  Copyright (C) 2008 Russell King.
> + *
> + * 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.
> + *
> + * Helper for the clk API to assist looking up a struct clk.
> + */
> +
> +#ifndef __LOOKUP_CLK_DEV__
> +#define __LOOKUP_CLK_DEV__
> +
> +#include <mach/clkdev.h>
> +
> +static __inline__ struct clk_lookup_alloc *arch_kzalloc(size_t size)
> +{
> +	return kzalloc(size, GFP_KERNEL);
> +}
Is this really needed?  If yes it should either be in a different header
of be named clk_lookup_alloc or similar.
> +
> +#endif /* __LOOKUP_CLK_DEV__ */
> diff --git a/arch/arm/mach-shmobile/Kconfig b/arch/arm/mach-shmobile/Kconfig
> index 54b479c..e4e964b 100644
> --- a/arch/arm/mach-shmobile/Kconfig
> +++ b/arch/arm/mach-shmobile/Kconfig
> @@ -6,7 +6,7 @@ config ARCH_SH7367
>  	bool "SH-Mobile G3 (SH7367)"
>  	select CPU_V6
>  	select HAVE_CLK
> -	select COMMON_CLKDEV
> +	select LOOKUP_CLKDEV
>  	select SH_CLK_CPG
>  	select GENERIC_CLOCKEVENTS
>  
> @@ -14,7 +14,7 @@ config ARCH_SH7377
>  	bool "SH-Mobile G4 (SH7377)"
>  	select CPU_V7
>  	select HAVE_CLK
> -	select COMMON_CLKDEV
> +	select LOOKUP_CLKDEV
>  	select SH_CLK_CPG
>  	select GENERIC_CLOCKEVENTS
>  
> @@ -22,7 +22,7 @@ config ARCH_SH7372
>  	bool "SH-Mobile AP4 (SH7372)"
>  	select CPU_V7
>  	select HAVE_CLK
> -	select COMMON_CLKDEV
> +	select LOOKUP_CLKDEV
>  	select SH_CLK_CPG
>  	select GENERIC_CLOCKEVENTS
>  
> diff --git a/arch/arm/plat-omap/Kconfig b/arch/arm/plat-omap/Kconfig
> index e39a417..daba55a 100644
> --- a/arch/arm/plat-omap/Kconfig
> +++ b/arch/arm/plat-omap/Kconfig
> @@ -11,13 +11,13 @@ choice
>  
>  config ARCH_OMAP1
>  	bool "TI OMAP1"
> -	select COMMON_CLKDEV
> +	select LOOKUP_CLKDEV
>  	help
>  	  "Systems based on omap7xx, omap15xx or omap16xx"
>  
>  config ARCH_OMAP2PLUS
>  	bool "TI OMAP2/3/4"
> -	select COMMON_CLKDEV
> +	select LOOKUP_CLKDEV
>  	help
>  	  "Systems based on omap24xx, omap34xx or omap44xx"
>  
> diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
> index 33990fa..6b7d206 100644
> --- a/arch/sh/Kconfig
> +++ b/arch/sh/Kconfig
> @@ -8,7 +8,7 @@ mainmenu "Linux/SuperH Kernel Configuration"
>  config SUPERH
>  	def_bool y
>  	select EMBEDDED
> -	select HAVE_CLK
> +	select LOOKUP_CLKDEV
>  	select HAVE_IDE if HAS_IOPORT
>  	select HAVE_MEMBLOCK
>  	select HAVE_OPROFILE
> diff --git a/arch/sh/include/asm/lookup_clkdev.h b/arch/sh/include/asm/lookup_clkdev.h
> new file mode 100644
> index 0000000..9ac7b10
> --- /dev/null
> +++ b/arch/sh/include/asm/lookup_clkdev.h
> @@ -0,0 +1,29 @@
> +/*
> + *  Copyright (C) 2010 Paul Mundt <lethal@linux-sh.org>
> + *
> + * 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.
> + *
> + * Helper for the clk API to assist looking up a struct clk.
> + */
> +
> +#ifndef __LOOKUP_CLK_DEV__
> +#define __LOOKUP_CLK_DEV__
> +
> +#include <linux/bootmem.h>
> +#include <linux/mm.h>
> +#include <asm/clock.h>
> +
> +static __inline__ struct clk_lookup_alloc *arch_kzalloc(size_t size)
> +{
> +	if (!slab_is_available())
> +		return alloc_bootmem_low_pages(size);
> +	else
> +		return kzalloc(size, GFP_KERNEL);
> +}
> +
> +#define __clk_put(clk)
> +#define __clk_get(clk) ({ 1; })
> +
> +#endif /* __LOOKUP_CLK_DEV__ */
> diff --git a/arch/sh/kernel/Makefile b/arch/sh/kernel/Makefile
> index e25f3c6..e4fe614 100644
> --- a/arch/sh/kernel/Makefile
> +++ b/arch/sh/kernel/Makefile
> @@ -11,7 +11,7 @@ endif
>  
>  CFLAGS_REMOVE_return_address.o = -pg
>  
> -obj-y	:= clkdev.o debugtraps.o dma-nommu.o dumpstack.o 		\
> +obj-y	:= debugtraps.o dma-nommu.o dumpstack.o 			\
>  	   idle.o io.o irq.o						\
>  	   irq_$(BITS).o machvec.o nmi_debug.o process.o		\
>  	   process_$(BITS).o ptrace_$(BITS).o				\
> diff --git a/arch/sh/kernel/clkdev.c b/arch/sh/kernel/clkdev.c
> deleted file mode 100644
> index befc255..0000000
> --- a/arch/sh/kernel/clkdev.c
> +++ /dev/null
> @@ -1,169 +0,0 @@
> -/*
> - * arch/sh/kernel/clkdev.c
> - *
> - * Cloned from arch/arm/common/clkdev.c:
> - *
> - *  Copyright (C) 2008 Russell King.
> - *
> - * 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.
> - *
> - * Helper for the clk API to assist looking up a struct clk.
> - */
> -#include <linux/module.h>
> -#include <linux/kernel.h>
> -#include <linux/device.h>
> -#include <linux/list.h>
> -#include <linux/errno.h>
> -#include <linux/err.h>
> -#include <linux/string.h>
> -#include <linux/mutex.h>
> -#include <linux/clk.h>
> -#include <linux/slab.h>
> -#include <linux/bootmem.h>
> -#include <linux/mm.h>
> -#include <asm/clock.h>
> -#include <asm/clkdev.h>
> -
> -static LIST_HEAD(clocks);
> -static DEFINE_MUTEX(clocks_mutex);
> -
> -/*
> - * Find the correct struct clk for the device and connection ID.
> - * We do slightly fuzzy matching here:
> - *  An entry with a NULL ID is assumed to be a wildcard.
> - *  If an entry has a device ID, it must match
> - *  If an entry has a connection ID, it must match
> - * Then we take the most specific entry - with the following
> - * order of precedence: dev+con > dev only > con only.
> - */
> -static struct clk *clk_find(const char *dev_id, const char *con_id)
> -{
> -	struct clk_lookup *p;
> -	struct clk *clk = NULL;
> -	int match, best = 0;
> -
> -	list_for_each_entry(p, &clocks, node) {
> -		match = 0;
> -		if (p->dev_id) {
> -			if (!dev_id || strcmp(p->dev_id, dev_id))
> -				continue;
> -			match += 2;
> -		}
> -		if (p->con_id) {
> -			if (!con_id || strcmp(p->con_id, con_id))
> -				continue;
> -			match += 1;
> -		}
> -		if (match == 0)
> -			continue;
> -
> -		if (match > best) {
> -			clk = p->clk;
> -			best = match;
> -		}
> -	}
> -	return clk;
> -}
> -
> -struct clk *clk_get_sys(const char *dev_id, const char *con_id)
> -{
> -	struct clk *clk;
> -
> -	mutex_lock(&clocks_mutex);
> -	clk = clk_find(dev_id, con_id);
> -	mutex_unlock(&clocks_mutex);
> -
> -	return clk ? clk : ERR_PTR(-ENOENT);
> -}
> -EXPORT_SYMBOL(clk_get_sys);
> -
> -void clkdev_add(struct clk_lookup *cl)
> -{
> -	mutex_lock(&clocks_mutex);
> -	list_add_tail(&cl->node, &clocks);
> -	mutex_unlock(&clocks_mutex);
> -}
> -EXPORT_SYMBOL(clkdev_add);
> -
> -void __init clkdev_add_table(struct clk_lookup *cl, size_t num)
> -{
> -	mutex_lock(&clocks_mutex);
> -	while (num--) {
> -		list_add_tail(&cl->node, &clocks);
> -		cl++;
> -	}
> -	mutex_unlock(&clocks_mutex);
> -}
> -
> -#define MAX_DEV_ID	20
> -#define MAX_CON_ID	16
> -
> -struct clk_lookup_alloc {
> -	struct clk_lookup cl;
> -	char	dev_id[MAX_DEV_ID];
> -	char	con_id[MAX_CON_ID];
> -};
> -
> -struct clk_lookup * __init_refok
> -clkdev_alloc(struct clk *clk, const char *con_id, const char *dev_fmt, ...)
> -{
> -	struct clk_lookup_alloc *cla;
> -
> -	if (!slab_is_available())
> -		cla = alloc_bootmem_low_pages(sizeof(*cla));
> -	else
> -		cla = kzalloc(sizeof(*cla), GFP_KERNEL);
> -
> -	if (!cla)
> -		return NULL;
> -
> -	cla->cl.clk = clk;
> -	if (con_id) {
> -		strlcpy(cla->con_id, con_id, sizeof(cla->con_id));
> -		cla->cl.con_id = cla->con_id;
> -	}
> -
> -	if (dev_fmt) {
> -		va_list ap;
> -
> -		va_start(ap, dev_fmt);
> -		vscnprintf(cla->dev_id, sizeof(cla->dev_id), dev_fmt, ap);
> -		cla->cl.dev_id = cla->dev_id;
> -		va_end(ap);
> -	}
> -
> -	return &cla->cl;
> -}
> -EXPORT_SYMBOL(clkdev_alloc);
> -
> -int clk_add_alias(const char *alias, const char *alias_dev_name, char *id,
> -	struct device *dev)
> -{
> -	struct clk *r = clk_get(dev, id);
> -	struct clk_lookup *l;
> -
> -	if (IS_ERR(r))
> -		return PTR_ERR(r);
> -
> -	l = clkdev_alloc(r, alias, alias_dev_name);
> -	clk_put(r);
> -	if (!l)
> -		return -ENODEV;
> -	clkdev_add(l);
> -	return 0;
> -}
> -EXPORT_SYMBOL(clk_add_alias);
> -
> -/*
> - * clkdev_drop - remove a clock dynamically allocated
> - */
> -void clkdev_drop(struct clk_lookup *cl)
> -{
> -	mutex_lock(&clocks_mutex);
> -	list_del(&cl->node);
> -	mutex_unlock(&clocks_mutex);
> -	kfree(cl);
> -}
> -EXPORT_SYMBOL(clkdev_drop);
> diff --git a/arch/sh/kernel/cpu/clock.c b/arch/sh/kernel/cpu/clock.c
> index 50f887d..4187cf4 100644
> --- a/arch/sh/kernel/cpu/clock.c
> +++ b/arch/sh/kernel/cpu/clock.c
> @@ -48,20 +48,4 @@ int __init clk_init(void)
>  	return ret;
>  }
>  
> -/*
> - * Returns a clock. Note that we first try to use device id on the bus
> - * and clock name. If this fails, we try to use clock name only.
> - */
> -struct clk *clk_get(struct device *dev, const char *con_id)
> -{
> -	const char *dev_id = dev ? dev_name(dev) : NULL;
> -
> -	return clk_get_sys(dev_id, con_id);
> -}
> -EXPORT_SYMBOL_GPL(clk_get);
> -
> -void clk_put(struct clk *clk)
> -{
> -}
> -EXPORT_SYMBOL_GPL(clk_put);
>  
> diff --git a/drivers/Kconfig b/drivers/Kconfig
> index a2b902f..3d93b3a 100644
> --- a/drivers/Kconfig
> +++ b/drivers/Kconfig
> @@ -111,4 +111,6 @@ source "drivers/xen/Kconfig"
>  source "drivers/staging/Kconfig"
>  
>  source "drivers/platform/Kconfig"
> +
> +source "drivers/clk/Kconfig"
>  endmenu
> diff --git a/drivers/Makefile b/drivers/Makefile
> index ae47344..b0e30b2 100644
> --- a/drivers/Makefile
> +++ b/drivers/Makefile
> @@ -115,3 +115,5 @@ obj-$(CONFIG_VLYNQ)		+= vlynq/
>  obj-$(CONFIG_STAGING)		+= staging/
>  obj-y				+= platform/
>  obj-y				+= ieee802154/
> +#common clk code
> +obj-y				+= clk/
> diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig
> new file mode 100644
> index 0000000..cc5272c
> --- /dev/null
> +++ b/drivers/clk/Kconfig
> @@ -0,0 +1,4 @@
> +
> +config LOOKUP_CLKDEV
> +	bool
> +	select HAVE_CLK
> diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
> new file mode 100644
> index 0000000..288d997
> --- /dev/null
> +++ b/drivers/clk/Makefile
> @@ -0,0 +1,2 @@
> +
> +obj-$(CONFIG_LOOKUP_CLKDEV)	+= lookup_clkdev.o
> diff --git a/arch/arm/common/clkdev.c b/drivers/clk/lookup_clkdev.c
> similarity index 89%
> rename from arch/arm/common/clkdev.c
> rename to drivers/clk/lookup_clkdev.c
> index e2b2bb6..0a19626 100644
> --- a/arch/arm/common/clkdev.c
> +++ b/drivers/clk/lookup_clkdev.c
> @@ -1,5 +1,5 @@
>  /*
> - *  arch/arm/common/clkdev.c
> + * drivers/clk/lookup_clkdev.c
>   *
>   *  Copyright (C) 2008 Russell King.
>   *
> @@ -21,7 +21,7 @@
>  #include <linux/slab.h>
>  
>  #include <asm/clkdev.h>
> -#include <mach/clkdev.h>
> +#include <asm/lookup_clkdev.h>
>  
>  static LIST_HEAD(clocks);
>  static DEFINE_MUTEX(clocks_mutex);
> @@ -79,19 +79,23 @@ struct clk *clk_get_sys(const char *dev_id, const char *con_id)
>  }
>  EXPORT_SYMBOL(clk_get_sys);
>  
> +/*
> + * Returns a clock. Note that we first try to use device id on the bus
> + * and clock name. If this fails, we try to use clock name only.
> + */
>  struct clk *clk_get(struct device *dev, const char *con_id)
>  {
>  	const char *dev_id = dev ? dev_name(dev) : NULL;
>  
>  	return clk_get_sys(dev_id, con_id);
>  }
> -EXPORT_SYMBOL(clk_get);
> +EXPORT_SYMBOL_GPL(clk_get);
>  
>  void clk_put(struct clk *clk)
>  {
>  	__clk_put(clk);
>  }
> -EXPORT_SYMBOL(clk_put);
> +EXPORT_SYMBOL_GPL(clk_put);
>  
>  void clkdev_add(struct clk_lookup *cl)
>  {
> @@ -120,12 +124,12 @@ struct clk_lookup_alloc {
>  	char	con_id[MAX_CON_ID];
>  };
>  
> -struct clk_lookup *clkdev_alloc(struct clk *clk, const char *con_id,
> -	const char *dev_fmt, ...)
> +struct clk_lookup * __init_refok
Why do you need __init_refok?  __init_refok is defined as follows in
include/linux/init.h:

	/* compatibility defines */
	#define __init_refok     __ref

So if really needed better use __ref.  Couldn't this be __init?  

> +clkdev_alloc(struct clk *clk, const char *con_id, const char *dev_fmt, ...)
>  {
>  	struct clk_lookup_alloc *cla;
>  
> -	cla = kzalloc(sizeof(*cla), GFP_KERNEL);
> +	cla = arch_kzalloc(sizeof(*cla));
>  	if (!cla)
>  		return NULL;
Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

^ permalink raw reply	[flat|nested] 133+ messages in thread

* Re: [RFC] [PATCH] arm & sh: factorised duplicated clkdev.c
  2010-08-31 11:16 ` Jean-Christophe PLAGNIOL-VILLARD
@ 2010-09-01 10:01   ` Russell King - ARM Linux
  -1 siblings, 0 replies; 133+ messages in thread
From: Russell King - ARM Linux @ 2010-09-01 10:01 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Aug 31, 2010 at 01:16:42PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> diff --git a/arch/arm/include/asm/lookup_clkdev.h b/arch/arm/include/asm/lookup_clkdev.h
> new file mode 100644
> index 0000000..d57f7a6
> --- /dev/null
> +++ b/arch/arm/include/asm/lookup_clkdev.h
> @@ -0,0 +1,23 @@
> +/*
> + *  arch/arm/common/clkdev.c
> + *
> + *  Copyright (C) 2008 Russell King.
> + *
> + * 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.
> + *
> + * Helper for the clk API to assist looking up a struct clk.
> + */
> +
> +#ifndef __LOOKUP_CLK_DEV__
> +#define __LOOKUP_CLK_DEV__
> +
> +#include <mach/clkdev.h>
> +
> +static __inline__ struct clk_lookup_alloc *arch_kzalloc(size_t size)

No need to use __inline__ here - use inline instead.

> +static __inline__ struct clk_lookup_alloc *arch_kzalloc(size_t size)

Ditto.

> @@ -120,12 +124,12 @@ struct clk_lookup_alloc {
>  	char	con_id[MAX_CON_ID];
>  };
>  
> -struct clk_lookup *clkdev_alloc(struct clk *clk, const char *con_id,
> -	const char *dev_fmt, ...)
> +struct clk_lookup * __init_refok
> +clkdev_alloc(struct clk *clk, const char *con_id, const char *dev_fmt, ...)

This looks like a nasty hack to get around the problem of calling a
boot-time only allocator - but I guess given what sh is doing we don't
have much choice here.

The choice of 'arch_kzalloc' is imho very poor - it potentially could
clash with some other use.  Maybe __clkdev_alloc() instead?

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [RFC] [PATCH] arm & sh: factorised duplicated clkdev.c
@ 2010-09-01 10:01   ` Russell King - ARM Linux
  0 siblings, 0 replies; 133+ messages in thread
From: Russell King - ARM Linux @ 2010-09-01 10:01 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Aug 31, 2010 at 01:16:42PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> diff --git a/arch/arm/include/asm/lookup_clkdev.h b/arch/arm/include/asm/lookup_clkdev.h
> new file mode 100644
> index 0000000..d57f7a6
> --- /dev/null
> +++ b/arch/arm/include/asm/lookup_clkdev.h
> @@ -0,0 +1,23 @@
> +/*
> + *  arch/arm/common/clkdev.c
> + *
> + *  Copyright (C) 2008 Russell King.
> + *
> + * 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.
> + *
> + * Helper for the clk API to assist looking up a struct clk.
> + */
> +
> +#ifndef __LOOKUP_CLK_DEV__
> +#define __LOOKUP_CLK_DEV__
> +
> +#include <mach/clkdev.h>
> +
> +static __inline__ struct clk_lookup_alloc *arch_kzalloc(size_t size)

No need to use __inline__ here - use inline instead.

> +static __inline__ struct clk_lookup_alloc *arch_kzalloc(size_t size)

Ditto.

> @@ -120,12 +124,12 @@ struct clk_lookup_alloc {
>  	char	con_id[MAX_CON_ID];
>  };
>  
> -struct clk_lookup *clkdev_alloc(struct clk *clk, const char *con_id,
> -	const char *dev_fmt, ...)
> +struct clk_lookup * __init_refok
> +clkdev_alloc(struct clk *clk, const char *con_id, const char *dev_fmt, ...)

This looks like a nasty hack to get around the problem of calling a
boot-time only allocator - but I guess given what sh is doing we don't
have much choice here.

The choice of 'arch_kzalloc' is imho very poor - it potentially could
clash with some other use.  Maybe __clkdev_alloc() instead?

^ permalink raw reply	[flat|nested] 133+ messages in thread

* Re: [RFC] [PATCH] arm & sh: factorised duplicated clkdev.c
  2010-09-01 10:01   ` Russell King - ARM Linux
@ 2010-09-01 11:12     ` Jean-Christophe PLAGNIOL-VILLARD
  -1 siblings, 0 replies; 133+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2010-09-01 11:12 UTC (permalink / raw)
  To: linux-arm-kernel

> > +
> > +static __inline__ struct clk_lookup_alloc *arch_kzalloc(size_t size)
> 
> No need to use __inline__ here - use inline instead.
> 
> > +static __inline__ struct clk_lookup_alloc *arch_kzalloc(size_t size)
> 
> Ditto.
> 
> > @@ -120,12 +124,12 @@ struct clk_lookup_alloc {
> >  	char	con_id[MAX_CON_ID];
> >  };
> >  
> > -struct clk_lookup *clkdev_alloc(struct clk *clk, const char *con_id,
> > -	const char *dev_fmt, ...)
> > +struct clk_lookup * __init_refok
> > +clkdev_alloc(struct clk *clk, const char *con_id, const char *dev_fmt, ...)
> 
> This looks like a nasty hack to get around the problem of calling a
> boot-time only allocator - but I guess given what sh is doing we don't
> have much choice here.
> 
> The choice of 'arch_kzalloc' is imho very poor - it potentially could
> clash with some other use.  Maybe __clkdev_alloc() instead?
ok I'll update

Best Regards,
J.

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [RFC] [PATCH] arm & sh: factorised duplicated clkdev.c
@ 2010-09-01 11:12     ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 0 replies; 133+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2010-09-01 11:12 UTC (permalink / raw)
  To: linux-arm-kernel

> > +
> > +static __inline__ struct clk_lookup_alloc *arch_kzalloc(size_t size)
> 
> No need to use __inline__ here - use inline instead.
> 
> > +static __inline__ struct clk_lookup_alloc *arch_kzalloc(size_t size)
> 
> Ditto.
> 
> > @@ -120,12 +124,12 @@ struct clk_lookup_alloc {
> >  	char	con_id[MAX_CON_ID];
> >  };
> >  
> > -struct clk_lookup *clkdev_alloc(struct clk *clk, const char *con_id,
> > -	const char *dev_fmt, ...)
> > +struct clk_lookup * __init_refok
> > +clkdev_alloc(struct clk *clk, const char *con_id, const char *dev_fmt, ...)
> 
> This looks like a nasty hack to get around the problem of calling a
> boot-time only allocator - but I guess given what sh is doing we don't
> have much choice here.
> 
> The choice of 'arch_kzalloc' is imho very poor - it potentially could
> clash with some other use.  Maybe __clkdev_alloc() instead?
ok I'll update

Best Regards,
J.

^ permalink raw reply	[flat|nested] 133+ messages in thread

* Re: [RFC] [PATCH] arm & sh: factorised duplicated clkdev.c
  2010-09-01  9:12   ` Russell King - ARM Linux
@ 2010-09-01 11:13     ` Jean-Christophe PLAGNIOL-VILLARD
  -1 siblings, 0 replies; 133+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2010-09-01 11:13 UTC (permalink / raw)
  To: linux-arm-kernel

On 10:12 Wed 01 Sep     , Russell King - ARM Linux wrote:
> On Tue, Aug 31, 2010 at 01:16:42PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > factorise some generic infrastructure to assist looking up struct clks
> > for the ARM & SH architecture.
> > +/*
> > + * Returns a clock. Note that we first try to use device id on the bus
> > + * and clock name. If this fails, we try to use clock name only.
> > + */
> >  struct clk *clk_get(struct device *dev, const char *con_id)
> >  {
> >  	const char *dev_id = dev ? dev_name(dev) : NULL;
> >  
> >  	return clk_get_sys(dev_id, con_id);
> >  }
> > -EXPORT_SYMBOL(clk_get);
> > +EXPORT_SYMBOL_GPL(clk_get);
> >  
> >  void clk_put(struct clk *clk)
> >  {
> >  	__clk_put(clk);
> >  }
> > -EXPORT_SYMBOL(clk_put);
> > +EXPORT_SYMBOL_GPL(clk_put);
> 
> Please leave these as-is.
ok but on SH it's GPL so it is ok with you Paul too?

Best Regards,
J.

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [RFC] [PATCH] arm & sh: factorised duplicated clkdev.c
@ 2010-09-01 11:13     ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 0 replies; 133+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2010-09-01 11:13 UTC (permalink / raw)
  To: linux-arm-kernel

On 10:12 Wed 01 Sep     , Russell King - ARM Linux wrote:
> On Tue, Aug 31, 2010 at 01:16:42PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > factorise some generic infrastructure to assist looking up struct clks
> > for the ARM & SH architecture.
> > +/*
> > + * Returns a clock. Note that we first try to use device id on the bus
> > + * and clock name. If this fails, we try to use clock name only.
> > + */
> >  struct clk *clk_get(struct device *dev, const char *con_id)
> >  {
> >  	const char *dev_id = dev ? dev_name(dev) : NULL;
> >  
> >  	return clk_get_sys(dev_id, con_id);
> >  }
> > -EXPORT_SYMBOL(clk_get);
> > +EXPORT_SYMBOL_GPL(clk_get);
> >  
> >  void clk_put(struct clk *clk)
> >  {
> >  	__clk_put(clk);
> >  }
> > -EXPORT_SYMBOL(clk_put);
> > +EXPORT_SYMBOL_GPL(clk_put);
> 
> Please leave these as-is.
ok but on SH it's GPL so it is ok with you Paul too?

Best Regards,
J.

^ permalink raw reply	[flat|nested] 133+ messages in thread

* Re: [RFC] [PATCH] arm & sh: factorised duplicated clkdev.c
  2010-09-01  9:51   ` Uwe Kleine-König
@ 2010-09-01 11:18     ` Jean-Christophe PLAGNIOL-VILLARD
  -1 siblings, 0 replies; 133+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2010-09-01 11:18 UTC (permalink / raw)
  To: linux-arm-kernel

> >  
> > -struct clk_lookup *clkdev_alloc(struct clk *clk, const char *con_id,
> > -	const char *dev_fmt, ...)
> > +struct clk_lookup * __init_refok
> Why do you need __init_refok?  __init_refok is defined as follows in
> include/linux/init.h:
> 
> 	/* compatibility defines */
> 	#define __init_refok     __ref
> 
> So if really needed better use __ref.  Couldn't this be __init?  
ok for __ref but __init_refok is more clear IMHO
and yes we need it as for early device we may use bootmem as slab allocators
may no be availlable in some case

Best Regards,
J.

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [RFC] [PATCH] arm & sh: factorised duplicated clkdev.c
@ 2010-09-01 11:18     ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 0 replies; 133+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2010-09-01 11:18 UTC (permalink / raw)
  To: linux-arm-kernel

> >  
> > -struct clk_lookup *clkdev_alloc(struct clk *clk, const char *con_id,
> > -	const char *dev_fmt, ...)
> > +struct clk_lookup * __init_refok
> Why do you need __init_refok?  __init_refok is defined as follows in
> include/linux/init.h:
> 
> 	/* compatibility defines */
> 	#define __init_refok     __ref
> 
> So if really needed better use __ref.  Couldn't this be __init?  
ok for __ref but __init_refok is more clear IMHO
and yes we need it as for early device we may use bootmem as slab allocators
may no be availlable in some case

Best Regards,
J.

^ permalink raw reply	[flat|nested] 133+ messages in thread

* Re: [RFC] [PATCH] arm & sh: factorised duplicated clkdev.c
  2010-09-01 11:18     ` Jean-Christophe PLAGNIOL-VILLARD
@ 2010-09-01 15:01       ` Uwe Kleine-König
  -1 siblings, 0 replies; 133+ messages in thread
From:  @ 2010-09-01 15:01 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Sep 01, 2010 at 01:18:46PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > >  
> > > -struct clk_lookup *clkdev_alloc(struct clk *clk, const char *con_id,
> > > -	const char *dev_fmt, ...)
> > > +struct clk_lookup * __init_refok
> > Why do you need __init_refok?  __init_refok is defined as follows in
> > include/linux/init.h:
> > 
> > 	/* compatibility defines */
> > 	#define __init_refok     __ref
> > 
> > So if really needed better use __ref.  Couldn't this be __init?  
> ok for __ref but __init_refok is more clear IMHO
For me it was not, because before your mail I didn't know __init_refok
so I had to look it up.

> and yes we need it as for early device we may use bootmem as slab allocators
> may no be availlable in some case
Yes I got that, but it doesn't explain why you need to mark your
function as __ref or why you cannot use __init.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [RFC] [PATCH] arm & sh: factorised duplicated clkdev.c
@ 2010-09-01 15:01       ` Uwe Kleine-König
  0 siblings, 0 replies; 133+ messages in thread
From: Uwe Kleine-König @ 2010-09-01 15:01 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Sep 01, 2010 at 01:18:46PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > >  
> > > -struct clk_lookup *clkdev_alloc(struct clk *clk, const char *con_id,
> > > -	const char *dev_fmt, ...)
> > > +struct clk_lookup * __init_refok
> > Why do you need __init_refok?  __init_refok is defined as follows in
> > include/linux/init.h:
> > 
> > 	/* compatibility defines */
> > 	#define __init_refok     __ref
> > 
> > So if really needed better use __ref.  Couldn't this be __init?  
> ok for __ref but __init_refok is more clear IMHO
For me it was not, because before your mail I didn't know __init_refok
so I had to look it up.

> and yes we need it as for early device we may use bootmem as slab allocators
> may no be availlable in some case
Yes I got that, but it doesn't explain why you need to mark your
function as __ref or why you cannot use __init.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

^ permalink raw reply	[flat|nested] 133+ messages in thread

* Re: [RFC] [PATCH] arm & sh: factorised duplicated clkdev.c
  2010-09-01 15:01       ` Uwe Kleine-König
@ 2010-09-01 15:27         ` Jean-Christophe PLAGNIOL-VILLARD
  -1 siblings, 0 replies; 133+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2010-09-01 15:27 UTC (permalink / raw)
  To: linux-arm-kernel

On 17:01 Wed 01 Sep     , Uwe Kleine-König wrote:
> On Wed, Sep 01, 2010 at 01:18:46PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > > >  
> > > > -struct clk_lookup *clkdev_alloc(struct clk *clk, const char *con_id,
> > > > -	const char *dev_fmt, ...)
> > > > +struct clk_lookup * __init_refok
> > > Why do you need __init_refok?  __init_refok is defined as follows in
> > > include/linux/init.h:
> > > 
> > > 	/* compatibility defines */
> > > 	#define __init_refok     __ref
> > > 
> > > So if really needed better use __ref.  Couldn't this be __init?  
> > ok for __ref but __init_refok is more clear IMHO
> For me it was not, because before your mail I didn't know __init_refok
> so I had to look it up.
> 
> > and yes we need it as for early device we may use bootmem as slab allocators
> > may no be availlable in some case
> Yes I got that, but it doesn't explain why you need to mark your
> function as __ref or why you cannot use __init.
Take a look in this commit 312b1485fb509c9bc32eda28ad29537896658cb8

it will be more clear

Best Regards,
J.

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [RFC] [PATCH] arm & sh: factorised duplicated clkdev.c
@ 2010-09-01 15:27         ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 0 replies; 133+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2010-09-01 15:27 UTC (permalink / raw)
  To: linux-arm-kernel

On 17:01 Wed 01 Sep     , Uwe Kleine-K?nig wrote:
> On Wed, Sep 01, 2010 at 01:18:46PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > > >  
> > > > -struct clk_lookup *clkdev_alloc(struct clk *clk, const char *con_id,
> > > > -	const char *dev_fmt, ...)
> > > > +struct clk_lookup * __init_refok
> > > Why do you need __init_refok?  __init_refok is defined as follows in
> > > include/linux/init.h:
> > > 
> > > 	/* compatibility defines */
> > > 	#define __init_refok     __ref
> > > 
> > > So if really needed better use __ref.  Couldn't this be __init?  
> > ok for __ref but __init_refok is more clear IMHO
> For me it was not, because before your mail I didn't know __init_refok
> so I had to look it up.
> 
> > and yes we need it as for early device we may use bootmem as slab allocators
> > may no be availlable in some case
> Yes I got that, but it doesn't explain why you need to mark your
> function as __ref or why you cannot use __init.
Take a look in this commit 312b1485fb509c9bc32eda28ad29537896658cb8

it will be more clear

Best Regards,
J.

^ permalink raw reply	[flat|nested] 133+ messages in thread

* Re: [RFC] [PATCH] arm & sh: factorised duplicated clkdev.c
  2010-09-01 15:27         ` Jean-Christophe PLAGNIOL-VILLARD
@ 2010-09-01 15:40           ` Uwe Kleine-König
  -1 siblings, 0 replies; 133+ messages in thread
From:  @ 2010-09-01 15:40 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Sep 01, 2010 at 05:27:19PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> On 17:01 Wed 01 Sep     , Uwe Kleine-König wrote:
> > On Wed, Sep 01, 2010 at 01:18:46PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > > > >  
> > > > > -struct clk_lookup *clkdev_alloc(struct clk *clk, const char *con_id,
> > > > > -	const char *dev_fmt, ...)
> > > > > +struct clk_lookup * __init_refok
> > > > Why do you need __init_refok?  __init_refok is defined as follows in
> > > > include/linux/init.h:
> > > > 
> > > > 	/* compatibility defines */
> > > > 	#define __init_refok     __ref
> > > > 
> > > > So if really needed better use __ref.  Couldn't this be __init?  
> > > ok for __ref but __init_refok is more clear IMHO
> > For me it was not, because before your mail I didn't know __init_refok
> > so I had to look it up.
> > 
> > > and yes we need it as for early device we may use bootmem as slab allocators
> > > may no be availlable in some case
> > Yes I got that, but it doesn't explain why you need to mark your
> > function as __ref or why you cannot use __init.
> Take a look in this commit 312b1485fb509c9bc32eda28ad29537896658cb8
> 
> it will be more clear
Assume I understand in which cases you need to use __ref.  Which of
these cases is valid for clkdev_alloc?

And further, which function calls (or which structure references)
clkdev_alloc that makes it impossible to mark it using __init?

Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [RFC] [PATCH] arm & sh: factorised duplicated clkdev.c
@ 2010-09-01 15:40           ` Uwe Kleine-König
  0 siblings, 0 replies; 133+ messages in thread
From: Uwe Kleine-König @ 2010-09-01 15:40 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Sep 01, 2010 at 05:27:19PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> On 17:01 Wed 01 Sep     , Uwe Kleine-K?nig wrote:
> > On Wed, Sep 01, 2010 at 01:18:46PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > > > >  
> > > > > -struct clk_lookup *clkdev_alloc(struct clk *clk, const char *con_id,
> > > > > -	const char *dev_fmt, ...)
> > > > > +struct clk_lookup * __init_refok
> > > > Why do you need __init_refok?  __init_refok is defined as follows in
> > > > include/linux/init.h:
> > > > 
> > > > 	/* compatibility defines */
> > > > 	#define __init_refok     __ref
> > > > 
> > > > So if really needed better use __ref.  Couldn't this be __init?  
> > > ok for __ref but __init_refok is more clear IMHO
> > For me it was not, because before your mail I didn't know __init_refok
> > so I had to look it up.
> > 
> > > and yes we need it as for early device we may use bootmem as slab allocators
> > > may no be availlable in some case
> > Yes I got that, but it doesn't explain why you need to mark your
> > function as __ref or why you cannot use __init.
> Take a look in this commit 312b1485fb509c9bc32eda28ad29537896658cb8
> 
> it will be more clear
Assume I understand in which cases you need to use __ref.  Which of
these cases is valid for clkdev_alloc?

And further, which function calls (or which structure references)
clkdev_alloc that makes it impossible to mark it using __init?

Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

^ permalink raw reply	[flat|nested] 133+ messages in thread

* Re: [RFC] [PATCH] arm & sh: factorised duplicated clkdev.c
  2010-09-01 11:13     ` Jean-Christophe PLAGNIOL-VILLARD
@ 2010-09-01 23:17       ` Russell King - ARM Linux
  -1 siblings, 0 replies; 133+ messages in thread
From: Russell King - ARM Linux @ 2010-09-01 23:17 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Sep 01, 2010 at 01:13:02PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> On 10:12 Wed 01 Sep     , Russell King - ARM Linux wrote:
> > On Tue, Aug 31, 2010 at 01:16:42PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > > factorise some generic infrastructure to assist looking up struct clks
> > > for the ARM & SH architecture.
> > > +/*
> > > + * Returns a clock. Note that we first try to use device id on the bus
> > > + * and clock name. If this fails, we try to use clock name only.
> > > + */
> > >  struct clk *clk_get(struct device *dev, const char *con_id)
> > >  {
> > >  	const char *dev_id = dev ? dev_name(dev) : NULL;
> > >  
> > >  	return clk_get_sys(dev_id, con_id);
> > >  }
> > > -EXPORT_SYMBOL(clk_get);
> > > +EXPORT_SYMBOL_GPL(clk_get);
> > >  
> > >  void clk_put(struct clk *clk)
> > >  {
> > >  	__clk_put(clk);
> > >  }
> > > -EXPORT_SYMBOL(clk_put);
> > > +EXPORT_SYMBOL_GPL(clk_put);
> > 
> > Please leave these as-is.
> ok but on SH it's GPL so it is ok with you Paul too?

If you want to get that pedantic... I created clkdev, and Sascha Hauer
extended it with some refactoring to create the clk_get_sys() interface.

If you look at the history, the sh version is a copy of the ARM version:

commit 51a5006afcd13176276f0935ee57c4cc6f210e83
Author: Paul Mundt <lethal@linux-sh.org>
Date:   Mon Mar 8 21:45:19 2010 +0900

    sh: Merge clkdev API updates.

    This rolls in the remainder of the clkdev API bits from the ARM tree.
    This can more or less be used verbatim, so we just copy it over and nuke
    our local version.

    Signed-off-by: Paul Mundt <lethal@linux-sh.org>

and

commit 441c2440aba2efd8d0f48a5e3357deec92283d62
Author: Magnus Damm <damm@opensource.se>
Date:   Tue May 11 09:37:12 2010 +0000

    sh: remove unused clock lookup

    Now when all clocks are registered using clkdev,
    get rid of the special SH-specific clock lookup.

    Also ditch the unused module ref counting code.
    This patch syncs the SH behaviour with ARM.

    Signed-off-by: Magnus Damm <damm@opensource.se>
    Signed-off-by: Paul Mundt <lethal@linux-sh.org>

so really it's a question for primerily me, and maybe Sascha.

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [RFC] [PATCH] arm & sh: factorised duplicated clkdev.c
@ 2010-09-01 23:17       ` Russell King - ARM Linux
  0 siblings, 0 replies; 133+ messages in thread
From: Russell King - ARM Linux @ 2010-09-01 23:17 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Sep 01, 2010 at 01:13:02PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> On 10:12 Wed 01 Sep     , Russell King - ARM Linux wrote:
> > On Tue, Aug 31, 2010 at 01:16:42PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > > factorise some generic infrastructure to assist looking up struct clks
> > > for the ARM & SH architecture.
> > > +/*
> > > + * Returns a clock. Note that we first try to use device id on the bus
> > > + * and clock name. If this fails, we try to use clock name only.
> > > + */
> > >  struct clk *clk_get(struct device *dev, const char *con_id)
> > >  {
> > >  	const char *dev_id = dev ? dev_name(dev) : NULL;
> > >  
> > >  	return clk_get_sys(dev_id, con_id);
> > >  }
> > > -EXPORT_SYMBOL(clk_get);
> > > +EXPORT_SYMBOL_GPL(clk_get);
> > >  
> > >  void clk_put(struct clk *clk)
> > >  {
> > >  	__clk_put(clk);
> > >  }
> > > -EXPORT_SYMBOL(clk_put);
> > > +EXPORT_SYMBOL_GPL(clk_put);
> > 
> > Please leave these as-is.
> ok but on SH it's GPL so it is ok with you Paul too?

If you want to get that pedantic... I created clkdev, and Sascha Hauer
extended it with some refactoring to create the clk_get_sys() interface.

If you look at the history, the sh version is a copy of the ARM version:

commit 51a5006afcd13176276f0935ee57c4cc6f210e83
Author: Paul Mundt <lethal@linux-sh.org>
Date:   Mon Mar 8 21:45:19 2010 +0900

    sh: Merge clkdev API updates.

    This rolls in the remainder of the clkdev API bits from the ARM tree.
    This can more or less be used verbatim, so we just copy it over and nuke
    our local version.

    Signed-off-by: Paul Mundt <lethal@linux-sh.org>

and

commit 441c2440aba2efd8d0f48a5e3357deec92283d62
Author: Magnus Damm <damm@opensource.se>
Date:   Tue May 11 09:37:12 2010 +0000

    sh: remove unused clock lookup

    Now when all clocks are registered using clkdev,
    get rid of the special SH-specific clock lookup.

    Also ditch the unused module ref counting code.
    This patch syncs the SH behaviour with ARM.

    Signed-off-by: Magnus Damm <damm@opensource.se>
    Signed-off-by: Paul Mundt <lethal@linux-sh.org>

so really it's a question for primerily me, and maybe Sascha.

^ permalink raw reply	[flat|nested] 133+ messages in thread

* Re: [RFC] [PATCH] arm & sh: factorised duplicated clkdev.c
  2010-09-01 15:01       ` Uwe Kleine-König
@ 2010-09-01 23:18         ` Russell King - ARM Linux
  -1 siblings, 0 replies; 133+ messages in thread
From: Russell King - ARM Linux @ 2010-09-01 23:18 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Sep 01, 2010 at 05:01:12PM +0200, Uwe Kleine-König wrote:
> On Wed, Sep 01, 2010 at 01:18:46PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > > >  
> > > > -struct clk_lookup *clkdev_alloc(struct clk *clk, const char *con_id,
> > > > -	const char *dev_fmt, ...)
> > > > +struct clk_lookup * __init_refok
> > > Why do you need __init_refok?  __init_refok is defined as follows in
> > > include/linux/init.h:
> > > 
> > > 	/* compatibility defines */
> > > 	#define __init_refok     __ref
> > > 
> > > So if really needed better use __ref.  Couldn't this be __init?  
> > ok for __ref but __init_refok is more clear IMHO
> For me it was not, because before your mail I didn't know __init_refok
> so I had to look it up.
> 
> > and yes we need it as for early device we may use bootmem as slab allocators
> > may no be availlable in some case
> Yes I got that, but it doesn't explain why you need to mark your
> function as __ref or why you cannot use __init.

You can't use __init for this because this function may be used for
non-init code.

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [RFC] [PATCH] arm & sh: factorised duplicated clkdev.c
@ 2010-09-01 23:18         ` Russell King - ARM Linux
  0 siblings, 0 replies; 133+ messages in thread
From: Russell King - ARM Linux @ 2010-09-01 23:18 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Sep 01, 2010 at 05:01:12PM +0200, Uwe Kleine-K?nig wrote:
> On Wed, Sep 01, 2010 at 01:18:46PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > > >  
> > > > -struct clk_lookup *clkdev_alloc(struct clk *clk, const char *con_id,
> > > > -	const char *dev_fmt, ...)
> > > > +struct clk_lookup * __init_refok
> > > Why do you need __init_refok?  __init_refok is defined as follows in
> > > include/linux/init.h:
> > > 
> > > 	/* compatibility defines */
> > > 	#define __init_refok     __ref
> > > 
> > > So if really needed better use __ref.  Couldn't this be __init?  
> > ok for __ref but __init_refok is more clear IMHO
> For me it was not, because before your mail I didn't know __init_refok
> so I had to look it up.
> 
> > and yes we need it as for early device we may use bootmem as slab allocators
> > may no be availlable in some case
> Yes I got that, but it doesn't explain why you need to mark your
> function as __ref or why you cannot use __init.

You can't use __init for this because this function may be used for
non-init code.

^ permalink raw reply	[flat|nested] 133+ messages in thread

* Re: [RFC] [PATCH] arm & sh: factorised duplicated clkdev.c
  2010-09-01 23:17       ` Russell King - ARM Linux
@ 2010-09-02  2:37         ` Jean-Christophe PLAGNIOL-VILLARD
  -1 siblings, 0 replies; 133+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2010-09-02  2:37 UTC (permalink / raw)
  To: linux-arm-kernel

On 00:17 Thu 02 Sep     , Russell King - ARM Linux wrote:
> On Wed, Sep 01, 2010 at 01:13:02PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > On 10:12 Wed 01 Sep     , Russell King - ARM Linux wrote:
> > > On Tue, Aug 31, 2010 at 01:16:42PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > > > factorise some generic infrastructure to assist looking up struct clks
> > > > for the ARM & SH architecture.
> > > > +/*
> > > > + * Returns a clock. Note that we first try to use device id on the bus
> > > > + * and clock name. If this fails, we try to use clock name only.
> > > > + */
> > > >  struct clk *clk_get(struct device *dev, const char *con_id)
> > > >  {
> > > >  	const char *dev_id = dev ? dev_name(dev) : NULL;
> > > >  
> > > >  	return clk_get_sys(dev_id, con_id);
> > > >  }
> > > > -EXPORT_SYMBOL(clk_get);
> > > > +EXPORT_SYMBOL_GPL(clk_get);
> > > >  
> > > >  void clk_put(struct clk *clk)
> > > >  {
> > > >  	__clk_put(clk);
> > > >  }
> > > > -EXPORT_SYMBOL(clk_put);
> > > > +EXPORT_SYMBOL_GPL(clk_put);
> > > 
> > > Please leave these as-is.
> > ok but on SH it's GPL so it is ok with you Paul too?
> 
> If you want to get that pedantic... I created clkdev, and Sascha Hauer
> extended it with some refactoring to create the clk_get_sys() interface.
personnaly It's fine for I
I just get in mind to knon if Paul have a specific reason to put it as GPL
EXPORT_SYMBOL

Best Regards,
J.

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [RFC] [PATCH] arm & sh: factorised duplicated clkdev.c
@ 2010-09-02  2:37         ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 0 replies; 133+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2010-09-02  2:37 UTC (permalink / raw)
  To: linux-arm-kernel

On 00:17 Thu 02 Sep     , Russell King - ARM Linux wrote:
> On Wed, Sep 01, 2010 at 01:13:02PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > On 10:12 Wed 01 Sep     , Russell King - ARM Linux wrote:
> > > On Tue, Aug 31, 2010 at 01:16:42PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > > > factorise some generic infrastructure to assist looking up struct clks
> > > > for the ARM & SH architecture.
> > > > +/*
> > > > + * Returns a clock. Note that we first try to use device id on the bus
> > > > + * and clock name. If this fails, we try to use clock name only.
> > > > + */
> > > >  struct clk *clk_get(struct device *dev, const char *con_id)
> > > >  {
> > > >  	const char *dev_id = dev ? dev_name(dev) : NULL;
> > > >  
> > > >  	return clk_get_sys(dev_id, con_id);
> > > >  }
> > > > -EXPORT_SYMBOL(clk_get);
> > > > +EXPORT_SYMBOL_GPL(clk_get);
> > > >  
> > > >  void clk_put(struct clk *clk)
> > > >  {
> > > >  	__clk_put(clk);
> > > >  }
> > > > -EXPORT_SYMBOL(clk_put);
> > > > +EXPORT_SYMBOL_GPL(clk_put);
> > > 
> > > Please leave these as-is.
> > ok but on SH it's GPL so it is ok with you Paul too?
> 
> If you want to get that pedantic... I created clkdev, and Sascha Hauer
> extended it with some refactoring to create the clk_get_sys() interface.
personnaly It's fine for I
I just get in mind to knon if Paul have a specific reason to put it as GPL
EXPORT_SYMBOL

Best Regards,
J.

^ permalink raw reply	[flat|nested] 133+ messages in thread

* Re: [RFC] [PATCH] arm & sh: factorised duplicated clkdev.c
  2010-09-02  2:37         ` Jean-Christophe PLAGNIOL-VILLARD
@ 2010-09-02  2:42           ` Paul Mundt
  -1 siblings, 0 replies; 133+ messages in thread
From: Paul Mundt @ 2010-09-02  2:42 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Sep 02, 2010 at 04:37:12AM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> On 00:17 Thu 02 Sep     , Russell King - ARM Linux wrote:
> > On Wed, Sep 01, 2010 at 01:13:02PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > > On 10:12 Wed 01 Sep     , Russell King - ARM Linux wrote:
> > > > On Tue, Aug 31, 2010 at 01:16:42PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > > > > factorise some generic infrastructure to assist looking up struct clks
> > > > > for the ARM & SH architecture.
> > > > > +/*
> > > > > + * Returns a clock. Note that we first try to use device id on the bus
> > > > > + * and clock name. If this fails, we try to use clock name only.
> > > > > + */
> > > > >  struct clk *clk_get(struct device *dev, const char *con_id)
> > > > >  {
> > > > >  	const char *dev_id = dev ? dev_name(dev) : NULL;
> > > > >  
> > > > >  	return clk_get_sys(dev_id, con_id);
> > > > >  }
> > > > > -EXPORT_SYMBOL(clk_get);
> > > > > +EXPORT_SYMBOL_GPL(clk_get);
> > > > >  
> > > > >  void clk_put(struct clk *clk)
> > > > >  {
> > > > >  	__clk_put(clk);
> > > > >  }
> > > > > -EXPORT_SYMBOL(clk_put);
> > > > > +EXPORT_SYMBOL_GPL(clk_put);
> > > > 
> > > > Please leave these as-is.
> > > ok but on SH it's GPL so it is ok with you Paul too?
> > 
> > If you want to get that pedantic... I created clkdev, and Sascha Hauer
> > extended it with some refactoring to create the clk_get_sys() interface.
> personnaly It's fine for I
> I just get in mind to knon if Paul have a specific reason to put it as GPL
> EXPORT_SYMBOL
> 
The original SH interfaces were GPL exported, when I moved the ARM code
in I suppose I forgot to sync the symbol exports at the same time.  My
reasons for having it GPL only in the first place are irrelevant here, we
defer to whatever ARM is doing.

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [RFC] [PATCH] arm & sh: factorised duplicated clkdev.c
@ 2010-09-02  2:42           ` Paul Mundt
  0 siblings, 0 replies; 133+ messages in thread
From: Paul Mundt @ 2010-09-02  2:42 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Sep 02, 2010 at 04:37:12AM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> On 00:17 Thu 02 Sep     , Russell King - ARM Linux wrote:
> > On Wed, Sep 01, 2010 at 01:13:02PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > > On 10:12 Wed 01 Sep     , Russell King - ARM Linux wrote:
> > > > On Tue, Aug 31, 2010 at 01:16:42PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > > > > factorise some generic infrastructure to assist looking up struct clks
> > > > > for the ARM & SH architecture.
> > > > > +/*
> > > > > + * Returns a clock. Note that we first try to use device id on the bus
> > > > > + * and clock name. If this fails, we try to use clock name only.
> > > > > + */
> > > > >  struct clk *clk_get(struct device *dev, const char *con_id)
> > > > >  {
> > > > >  	const char *dev_id = dev ? dev_name(dev) : NULL;
> > > > >  
> > > > >  	return clk_get_sys(dev_id, con_id);
> > > > >  }
> > > > > -EXPORT_SYMBOL(clk_get);
> > > > > +EXPORT_SYMBOL_GPL(clk_get);
> > > > >  
> > > > >  void clk_put(struct clk *clk)
> > > > >  {
> > > > >  	__clk_put(clk);
> > > > >  }
> > > > > -EXPORT_SYMBOL(clk_put);
> > > > > +EXPORT_SYMBOL_GPL(clk_put);
> > > > 
> > > > Please leave these as-is.
> > > ok but on SH it's GPL so it is ok with you Paul too?
> > 
> > If you want to get that pedantic... I created clkdev, and Sascha Hauer
> > extended it with some refactoring to create the clk_get_sys() interface.
> personnaly It's fine for I
> I just get in mind to knon if Paul have a specific reason to put it as GPL
> EXPORT_SYMBOL
> 
The original SH interfaces were GPL exported, when I moved the ARM code
in I suppose I forgot to sync the symbol exports at the same time.  My
reasons for having it GPL only in the first place are irrelevant here, we
defer to whatever ARM is doing.

^ permalink raw reply	[flat|nested] 133+ messages in thread

* Re: [RFC] [PATCH] arm & sh: factorised duplicated clkdev.c
  2010-09-01 23:18         ` Russell King - ARM Linux
@ 2010-09-02  5:46           ` Uwe Kleine-König
  -1 siblings, 0 replies; 133+ messages in thread
From:  @ 2010-09-02  5:46 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Sep 02, 2010 at 12:18:49AM +0100, Russell King - ARM Linux wrote:
> On Wed, Sep 01, 2010 at 05:01:12PM +0200, Uwe Kleine-König wrote:
> > On Wed, Sep 01, 2010 at 01:18:46PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > > > >  
> > > > > -struct clk_lookup *clkdev_alloc(struct clk *clk, const char *con_id,
> > > > > -	const char *dev_fmt, ...)
> > > > > +struct clk_lookup * __init_refok
> > > > Why do you need __init_refok?  __init_refok is defined as follows in
> > > > include/linux/init.h:
> > > > 
> > > > 	/* compatibility defines */
> > > > 	#define __init_refok     __ref
> > > > 
> > > > So if really needed better use __ref.  Couldn't this be __init?  
> > > ok for __ref but __init_refok is more clear IMHO
> > For me it was not, because before your mail I didn't know __init_refok
> > so I had to look it up.
> > 
> > > and yes we need it as for early device we may use bootmem as slab allocators
> > > may no be availlable in some case
> > Yes I got that, but it doesn't explain why you need to mark your
> > function as __ref or why you cannot use __init.
> 
> You can't use __init for this because this function may be used for
> non-init code.
Hmmm, as I don't seem to be able to persude someone else to do the hard
work, I did it.  Here are the hard facts:

	- clkdev_alloc is exported
	- clkdev is called by clk_add_alias
	- clk_add_alias is exported
	- clkdev_alloc is called by impd1_probe
	  (arch/arm/mach-integrator/impd1.c)
	  Can be compiled as a module.
	- clk_add_alias is called from __init functions only in
		arch/arm/mach-davinci/dm355.c
		arch/arm/mach-davinci/dm365.c
		arch/arm/mach-davinci/dm644x.c
		arch/arm/mach-pxa/eseries.c
		arch/arm/mach-pxa/lubbock.c
		arch/arm/mach-pxa/tosa.c
		arch/sh/kernel/cpu/clock-cpg.c
	  All these cannot be compiled as a module.
	- clk_add_alias is called from non-__init functions that could
	  be __init:
		arch/arm/mach-omap1/board-nokia770.c
	  This cannot be compiled as a module.

So the actions needed before make clkdev_alloc and clk_add_alias __init are:

	- register the clocks for impd1 in machine code, not the driver
	- move hwa742_dev_init to .init.text
	- don't export clkdev_alloc and clk_add_alias

I guess the first is simple, the rest trivial, no?

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [RFC] [PATCH] arm & sh: factorised duplicated clkdev.c
@ 2010-09-02  5:46           ` Uwe Kleine-König
  0 siblings, 0 replies; 133+ messages in thread
From: Uwe Kleine-König @ 2010-09-02  5:46 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Sep 02, 2010 at 12:18:49AM +0100, Russell King - ARM Linux wrote:
> On Wed, Sep 01, 2010 at 05:01:12PM +0200, Uwe Kleine-K?nig wrote:
> > On Wed, Sep 01, 2010 at 01:18:46PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > > > >  
> > > > > -struct clk_lookup *clkdev_alloc(struct clk *clk, const char *con_id,
> > > > > -	const char *dev_fmt, ...)
> > > > > +struct clk_lookup * __init_refok
> > > > Why do you need __init_refok?  __init_refok is defined as follows in
> > > > include/linux/init.h:
> > > > 
> > > > 	/* compatibility defines */
> > > > 	#define __init_refok     __ref
> > > > 
> > > > So if really needed better use __ref.  Couldn't this be __init?  
> > > ok for __ref but __init_refok is more clear IMHO
> > For me it was not, because before your mail I didn't know __init_refok
> > so I had to look it up.
> > 
> > > and yes we need it as for early device we may use bootmem as slab allocators
> > > may no be availlable in some case
> > Yes I got that, but it doesn't explain why you need to mark your
> > function as __ref or why you cannot use __init.
> 
> You can't use __init for this because this function may be used for
> non-init code.
Hmmm, as I don't seem to be able to persude someone else to do the hard
work, I did it.  Here are the hard facts:

	- clkdev_alloc is exported
	- clkdev is called by clk_add_alias
	- clk_add_alias is exported
	- clkdev_alloc is called by impd1_probe
	  (arch/arm/mach-integrator/impd1.c)
	  Can be compiled as a module.
	- clk_add_alias is called from __init functions only in
		arch/arm/mach-davinci/dm355.c
		arch/arm/mach-davinci/dm365.c
		arch/arm/mach-davinci/dm644x.c
		arch/arm/mach-pxa/eseries.c
		arch/arm/mach-pxa/lubbock.c
		arch/arm/mach-pxa/tosa.c
		arch/sh/kernel/cpu/clock-cpg.c
	  All these cannot be compiled as a module.
	- clk_add_alias is called from non-__init functions that could
	  be __init:
		arch/arm/mach-omap1/board-nokia770.c
	  This cannot be compiled as a module.

So the actions needed before make clkdev_alloc and clk_add_alias __init are:

	- register the clocks for impd1 in machine code, not the driver
	- move hwa742_dev_init to .init.text
	- don't export clkdev_alloc and clk_add_alias

I guess the first is simple, the rest trivial, no?

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [PATCH] ARM: omap1/nokia770: mark some functions __init
  2010-09-02  5:46           ` Uwe Kleine-König
  (?)
@ 2010-09-02  6:17           ` Uwe Kleine-König
  2010-09-02  8:03               ` Uwe Kleine-König
                               ` (5 more replies)
  -1 siblings, 6 replies; 133+ messages in thread
From: Uwe Kleine-König @ 2010-09-02  6:17 UTC (permalink / raw)
  To: linux-arm-kernel

These are only called from omap_nokia770_init which is in .init.text, too.

Signed-off-by: Uwe Kleine-K?nig <u.kleine-koenig@pengutronix.de>
---
 arch/arm/mach-omap1/board-nokia770.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/arm/mach-omap1/board-nokia770.c b/arch/arm/mach-omap1/board-nokia770.c
index 51a4539..09b3f46 100644
--- a/arch/arm/mach-omap1/board-nokia770.c
+++ b/arch/arm/mach-omap1/board-nokia770.c
@@ -112,7 +112,7 @@ static struct mipid_platform_data nokia770_mipid_platform_data = {
 	.shutdown = mipid_shutdown,
 };
 
-static void mipid_dev_init(void)
+static void __init mipid_dev_init(void)
 {
 	const struct omap_lcd_config *conf;
 
@@ -123,7 +123,7 @@ static void mipid_dev_init(void)
 	}
 }
 
-static void ads7846_dev_init(void)
+static void __init ads7846_dev_init(void)
 {
 	if (gpio_request(ADS7846_PENDOWN_GPIO, "ADS7846 pendown") < 0)
 		printk(KERN_ERR "can't get ads7846 pen down GPIO\n");
@@ -167,7 +167,7 @@ static struct hwa742_platform_data nokia770_hwa742_platform_data = {
 	.te_connected		= 1,
 };
 
-static void hwa742_dev_init(void)
+static void __init hwa742_dev_init(void)
 {
 	clk_add_alias("hwa_sys_ck", NULL, "bclk", NULL);
 	omapfb_set_ctrl_platform_data(&nokia770_hwa742_platform_data);
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [PATCH 1/5] ARM: omap/fb: move omap_init_fb to .init.text
  2010-09-02  6:17           ` [PATCH] ARM: omap1/nokia770: mark some functions __init Uwe Kleine-König
@ 2010-09-02  8:03               ` Uwe Kleine-König
  2010-09-02  8:03               ` Uwe Kleine-König
                                 ` (4 subsequent siblings)
  5 siblings, 0 replies; 133+ messages in thread
From: Uwe Kleine-König @ 2010-09-02  8:03 UTC (permalink / raw)
  To: linux-omap; +Cc: linux-arm-kernel

omap_init_fb() is only called as arch_initcall and so can live in
.init.text.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 arch/arm/plat-omap/fb.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/plat-omap/fb.c b/arch/arm/plat-omap/fb.c
index 0054b95..a727133 100644
--- a/arch/arm/plat-omap/fb.c
+++ b/arch/arm/plat-omap/fb.c
@@ -336,7 +336,7 @@ void omapfb_set_ctrl_platform_data(void *data)
 	omapfb_config.ctrl_platform_data = data;
 }
 
-static inline int omap_init_fb(void)
+static int __init omap_init_fb(void)
 {
 	const struct omap_lcd_config *conf;
 
@@ -381,7 +381,7 @@ void omapfb_set_platform_data(struct omapfb_platform_data *data)
 	omapfb_config = *data;
 }
 
-static inline int omap_init_fb(void)
+static int __init omap_init_fb(void)
 {
 	return platform_device_register(&omap_fb_device);
 }
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [PATCH 1/5] ARM: omap/fb: move omap_init_fb to .init.text
@ 2010-09-02  8:03               ` Uwe Kleine-König
  0 siblings, 0 replies; 133+ messages in thread
From: Uwe Kleine-König @ 2010-09-02  8:03 UTC (permalink / raw)
  To: linux-arm-kernel

omap_init_fb() is only called as arch_initcall and so can live in
.init.text.

Signed-off-by: Uwe Kleine-K?nig <u.kleine-koenig@pengutronix.de>
---
 arch/arm/plat-omap/fb.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/plat-omap/fb.c b/arch/arm/plat-omap/fb.c
index 0054b95..a727133 100644
--- a/arch/arm/plat-omap/fb.c
+++ b/arch/arm/plat-omap/fb.c
@@ -336,7 +336,7 @@ void omapfb_set_ctrl_platform_data(void *data)
 	omapfb_config.ctrl_platform_data = data;
 }
 
-static inline int omap_init_fb(void)
+static int __init omap_init_fb(void)
 {
 	const struct omap_lcd_config *conf;
 
@@ -381,7 +381,7 @@ void omapfb_set_platform_data(struct omapfb_platform_data *data)
 	omapfb_config = *data;
 }
 
-static inline int omap_init_fb(void)
+static int __init omap_init_fb(void)
 {
 	return platform_device_register(&omap_fb_device);
 }
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [PATCH 2/5] ARM: omap/fb: move omapfb_reserve_sram to .init.text
  2010-09-02  6:17           ` [PATCH] ARM: omap1/nokia770: mark some functions __init Uwe Kleine-König
@ 2010-09-02  8:03               ` Uwe Kleine-König
  2010-09-02  8:03               ` Uwe Kleine-König
                                 ` (4 subsequent siblings)
  5 siblings, 0 replies; 133+ messages in thread
From: Uwe Kleine-König @ 2010-09-02  8:03 UTC (permalink / raw)
  To: linux-omap; +Cc: linux-arm-kernel

This function is only called by omap_detect_sram which lives in .init.text,
too.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 arch/arm/plat-omap/fb.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/arm/plat-omap/fb.c b/arch/arm/plat-omap/fb.c
index a727133..72a36ca 100644
--- a/arch/arm/plat-omap/fb.c
+++ b/arch/arm/plat-omap/fb.c
@@ -262,7 +262,7 @@ void __init omapfb_reserve_sdram_memblock(void)
  * this point, since the driver built as a module would have problem with
  * freeing / reallocating the regions.
  */
-unsigned long omapfb_reserve_sram(unsigned long sram_pstart,
+unsigned long __init omapfb_reserve_sram(unsigned long sram_pstart,
 				  unsigned long sram_vstart,
 				  unsigned long sram_size,
 				  unsigned long pstart_avail,
@@ -392,7 +392,7 @@ void omapfb_reserve_sdram_memblock(void)
 {
 }
 
-unsigned long omapfb_reserve_sram(unsigned long sram_pstart,
+unsigned long __init omapfb_reserve_sram(unsigned long sram_pstart,
 				  unsigned long sram_vstart,
 				  unsigned long sram_size,
 				  unsigned long start_avail,
@@ -411,7 +411,7 @@ void omapfb_reserve_sdram_memblock(void)
 {
 }
 
-unsigned long omapfb_reserve_sram(unsigned long sram_pstart,
+unsigned long __init omapfb_reserve_sram(unsigned long sram_pstart,
 				  unsigned long sram_vstart,
 				  unsigned long sram_size,
 				  unsigned long start_avail,
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [PATCH 2/5] ARM: omap/fb: move omapfb_reserve_sram to .init.text
@ 2010-09-02  8:03               ` Uwe Kleine-König
  0 siblings, 0 replies; 133+ messages in thread
From: Uwe Kleine-König @ 2010-09-02  8:03 UTC (permalink / raw)
  To: linux-arm-kernel

This function is only called by omap_detect_sram which lives in .init.text,
too.

Signed-off-by: Uwe Kleine-K?nig <u.kleine-koenig@pengutronix.de>
---
 arch/arm/plat-omap/fb.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/arm/plat-omap/fb.c b/arch/arm/plat-omap/fb.c
index a727133..72a36ca 100644
--- a/arch/arm/plat-omap/fb.c
+++ b/arch/arm/plat-omap/fb.c
@@ -262,7 +262,7 @@ void __init omapfb_reserve_sdram_memblock(void)
  * this point, since the driver built as a module would have problem with
  * freeing / reallocating the regions.
  */
-unsigned long omapfb_reserve_sram(unsigned long sram_pstart,
+unsigned long __init omapfb_reserve_sram(unsigned long sram_pstart,
 				  unsigned long sram_vstart,
 				  unsigned long sram_size,
 				  unsigned long pstart_avail,
@@ -392,7 +392,7 @@ void omapfb_reserve_sdram_memblock(void)
 {
 }
 
-unsigned long omapfb_reserve_sram(unsigned long sram_pstart,
+unsigned long __init omapfb_reserve_sram(unsigned long sram_pstart,
 				  unsigned long sram_vstart,
 				  unsigned long sram_size,
 				  unsigned long start_avail,
@@ -411,7 +411,7 @@ void omapfb_reserve_sdram_memblock(void)
 {
 }
 
-unsigned long omapfb_reserve_sram(unsigned long sram_pstart,
+unsigned long __init omapfb_reserve_sram(unsigned long sram_pstart,
 				  unsigned long sram_vstart,
 				  unsigned long sram_size,
 				  unsigned long start_avail,
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [PATCH 3/5] ARM: omap/fb: move get_fbmem_region() to .init.text
  2010-09-02  6:17           ` [PATCH] ARM: omap1/nokia770: mark some functions __init Uwe Kleine-König
@ 2010-09-02  8:03               ` Uwe Kleine-König
  2010-09-02  8:03               ` Uwe Kleine-König
                                 ` (4 subsequent siblings)
  5 siblings, 0 replies; 133+ messages in thread
From: Uwe Kleine-König @ 2010-09-02  8:03 UTC (permalink / raw)
  To: linux-omap; +Cc: linux-arm-kernel

get_fbmem_region() is only called by omapfb_reserve_sdram_memblock() and
omapfb_reserve_sram() that both live in .init.text.  So get_fbmem_region
can go there, too.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 arch/arm/plat-omap/fb.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/arm/plat-omap/fb.c b/arch/arm/plat-omap/fb.c
index 72a36ca..fffc1a0 100644
--- a/arch/arm/plat-omap/fb.c
+++ b/arch/arm/plat-omap/fb.c
@@ -94,7 +94,7 @@ static int fbmem_region_reserved(unsigned long start, size_t size)
  * Get the region_idx`th region from board config/ATAG and convert it to
  * our internal format.
  */
-static int get_fbmem_region(int region_idx, struct omapfb_mem_region *rg)
+static int __init get_fbmem_region(int region_idx, struct omapfb_mem_region *rg)
 {
 	const struct omap_fbmem_config	*conf;
 	u32				paddr;
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [PATCH 3/5] ARM: omap/fb: move get_fbmem_region() to .init.text
@ 2010-09-02  8:03               ` Uwe Kleine-König
  0 siblings, 0 replies; 133+ messages in thread
From: Uwe Kleine-König @ 2010-09-02  8:03 UTC (permalink / raw)
  To: linux-arm-kernel

get_fbmem_region() is only called by omapfb_reserve_sdram_memblock() and
omapfb_reserve_sram() that both live in .init.text.  So get_fbmem_region
can go there, too.

Signed-off-by: Uwe Kleine-K?nig <u.kleine-koenig@pengutronix.de>
---
 arch/arm/plat-omap/fb.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/arm/plat-omap/fb.c b/arch/arm/plat-omap/fb.c
index 72a36ca..fffc1a0 100644
--- a/arch/arm/plat-omap/fb.c
+++ b/arch/arm/plat-omap/fb.c
@@ -94,7 +94,7 @@ static int fbmem_region_reserved(unsigned long start, size_t size)
  * Get the region_idx`th region from board config/ATAG and convert it to
  * our internal format.
  */
-static int get_fbmem_region(int region_idx, struct omapfb_mem_region *rg)
+static int __init get_fbmem_region(int region_idx, struct omapfb_mem_region *rg)
 {
 	const struct omap_fbmem_config	*conf;
 	u32				paddr;
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [PATCH 4/5] ARM: omap: move omap_get_config et al. to .init.text
  2010-09-02  6:17           ` [PATCH] ARM: omap1/nokia770: mark some functions __init Uwe Kleine-König
@ 2010-09-02  8:03               ` Uwe Kleine-König
  2010-09-02  8:03               ` Uwe Kleine-König
                                 ` (4 subsequent siblings)
  5 siblings, 0 replies; 133+ messages in thread
From: Uwe Kleine-König @ 2010-09-02  8:03 UTC (permalink / raw)
  To: linux-omap; +Cc: linux-arm-kernel

All callers of these functions live in .init.text, so these can go there,
too.  There they must not be exported anymore, this is no problem though,
as all callers are always built-in.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 arch/arm/plat-omap/common.c             |    6 ++----
 arch/arm/plat-omap/include/plat/board.h |    4 ++--
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/arch/arm/plat-omap/common.c b/arch/arm/plat-omap/common.c
index 3008e71..227d985 100644
--- a/arch/arm/plat-omap/common.c
+++ b/arch/arm/plat-omap/common.c
@@ -71,17 +71,15 @@ static const void *get_config(u16 tag, size_t len, int skip, size_t *len_out)
 	return kinfo->data;
 }
 
-const void *__omap_get_config(u16 tag, size_t len, int nr)
+const void *__init __omap_get_config(u16 tag, size_t len, int nr)
 {
         return get_config(tag, len, nr, NULL);
 }
-EXPORT_SYMBOL(__omap_get_config);
 
-const void *omap_get_var_config(u16 tag, size_t *len)
+const void *__init omap_get_var_config(u16 tag, size_t *len)
 {
         return get_config(tag, NO_LENGTH_CHECK, 0, len);
 }
-EXPORT_SYMBOL(omap_get_var_config);
 
 void __init omap_reserve(void)
 {
diff --git a/arch/arm/plat-omap/include/plat/board.h b/arch/arm/plat-omap/include/plat/board.h
index 3cf4fa2..97126df 100644
--- a/arch/arm/plat-omap/include/plat/board.h
+++ b/arch/arm/plat-omap/include/plat/board.h
@@ -151,14 +151,14 @@ struct omap_board_config_kernel {
 	const void *data;
 };
 
-extern const void *__omap_get_config(u16 tag, size_t len, int nr);
+extern const void *__init __omap_get_config(u16 tag, size_t len, int nr);
 
 #define omap_get_config(tag, type) \
 	((const type *) __omap_get_config((tag), sizeof(type), 0))
 #define omap_get_nr_config(tag, type, nr) \
 	((const type *) __omap_get_config((tag), sizeof(type), (nr)))
 
-extern const void *omap_get_var_config(u16 tag, size_t *len);
+extern const void *__init omap_get_var_config(u16 tag, size_t *len);
 
 extern struct omap_board_config_kernel *omap_board_config;
 extern int omap_board_config_size;
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [PATCH 4/5] ARM: omap: move omap_get_config et al. to .init.text
@ 2010-09-02  8:03               ` Uwe Kleine-König
  0 siblings, 0 replies; 133+ messages in thread
From: Uwe Kleine-König @ 2010-09-02  8:03 UTC (permalink / raw)
  To: linux-arm-kernel

All callers of these functions live in .init.text, so these can go there,
too.  There they must not be exported anymore, this is no problem though,
as all callers are always built-in.

Signed-off-by: Uwe Kleine-K?nig <u.kleine-koenig@pengutronix.de>
---
 arch/arm/plat-omap/common.c             |    6 ++----
 arch/arm/plat-omap/include/plat/board.h |    4 ++--
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/arch/arm/plat-omap/common.c b/arch/arm/plat-omap/common.c
index 3008e71..227d985 100644
--- a/arch/arm/plat-omap/common.c
+++ b/arch/arm/plat-omap/common.c
@@ -71,17 +71,15 @@ static const void *get_config(u16 tag, size_t len, int skip, size_t *len_out)
 	return kinfo->data;
 }
 
-const void *__omap_get_config(u16 tag, size_t len, int nr)
+const void *__init __omap_get_config(u16 tag, size_t len, int nr)
 {
         return get_config(tag, len, nr, NULL);
 }
-EXPORT_SYMBOL(__omap_get_config);
 
-const void *omap_get_var_config(u16 tag, size_t *len)
+const void *__init omap_get_var_config(u16 tag, size_t *len)
 {
         return get_config(tag, NO_LENGTH_CHECK, 0, len);
 }
-EXPORT_SYMBOL(omap_get_var_config);
 
 void __init omap_reserve(void)
 {
diff --git a/arch/arm/plat-omap/include/plat/board.h b/arch/arm/plat-omap/include/plat/board.h
index 3cf4fa2..97126df 100644
--- a/arch/arm/plat-omap/include/plat/board.h
+++ b/arch/arm/plat-omap/include/plat/board.h
@@ -151,14 +151,14 @@ struct omap_board_config_kernel {
 	const void *data;
 };
 
-extern const void *__omap_get_config(u16 tag, size_t len, int nr);
+extern const void *__init __omap_get_config(u16 tag, size_t len, int nr);
 
 #define omap_get_config(tag, type) \
 	((const type *) __omap_get_config((tag), sizeof(type), 0))
 #define omap_get_nr_config(tag, type, nr) \
 	((const type *) __omap_get_config((tag), sizeof(type), (nr)))
 
-extern const void *omap_get_var_config(u16 tag, size_t *len);
+extern const void *__init omap_get_var_config(u16 tag, size_t *len);
 
 extern struct omap_board_config_kernel *omap_board_config;
 extern int omap_board_config_size;
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [PATCH 5/5] wip: ARM: omap: move omap_board_config_kernel to .init.data
  2010-09-02  6:17           ` [PATCH] ARM: omap1/nokia770: mark some functions __init Uwe Kleine-König
@ 2010-09-02  8:03               ` Uwe Kleine-König
  2010-09-02  8:03               ` Uwe Kleine-König
                                 ` (4 subsequent siblings)
  5 siblings, 0 replies; 133+ messages in thread
From: Uwe Kleine-König @ 2010-09-02  8:03 UTC (permalink / raw)
  To: linux-omap; +Cc: linux-arm-kernel

Probably this works ...
---
 arch/arm/plat-omap/common.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/arm/plat-omap/common.c b/arch/arm/plat-omap/common.c
index 227d985..c8451c2 100644
--- a/arch/arm/plat-omap/common.c
+++ b/arch/arm/plat-omap/common.c
@@ -46,7 +46,7 @@
 
 #define NO_LENGTH_CHECK 0xffffffff
 
-struct omap_board_config_kernel *omap_board_config;
+struct omap_board_config_kernel *omap_board_config __initdata;
 int omap_board_config_size;
 
 static const void *get_config(u16 tag, size_t len, int skip, size_t *len_out)
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [PATCH 5/5] wip: ARM: omap: move omap_board_config_kernel to .init.data
@ 2010-09-02  8:03               ` Uwe Kleine-König
  0 siblings, 0 replies; 133+ messages in thread
From: Uwe Kleine-König @ 2010-09-02  8:03 UTC (permalink / raw)
  To: linux-arm-kernel

Probably this works ...
---
 arch/arm/plat-omap/common.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/arm/plat-omap/common.c b/arch/arm/plat-omap/common.c
index 227d985..c8451c2 100644
--- a/arch/arm/plat-omap/common.c
+++ b/arch/arm/plat-omap/common.c
@@ -46,7 +46,7 @@
 
 #define NO_LENGTH_CHECK 0xffffffff
 
-struct omap_board_config_kernel *omap_board_config;
+struct omap_board_config_kernel *omap_board_config __initdata;
 int omap_board_config_size;
 
 static const void *get_config(u16 tag, size_t len, int skip, size_t *len_out)
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* Re: [RFC] [PATCH] arm & sh: factorised duplicated clkdev.c
  2010-09-02  5:46           ` Uwe Kleine-König
@ 2010-09-02  8:45             ` Russell King - ARM Linux
  -1 siblings, 0 replies; 133+ messages in thread
From: Russell King - ARM Linux @ 2010-09-02  8:45 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Sep 02, 2010 at 07:46:30AM +0200, Uwe Kleine-König wrote:
> I guess the first is simple, the rest trivial, no?

Stop it.  Just accept that we don't want clk_add_alias to be __init.

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [RFC] [PATCH] arm & sh: factorised duplicated clkdev.c
@ 2010-09-02  8:45             ` Russell King - ARM Linux
  0 siblings, 0 replies; 133+ messages in thread
From: Russell King - ARM Linux @ 2010-09-02  8:45 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Sep 02, 2010 at 07:46:30AM +0200, Uwe Kleine-K?nig wrote:
> I guess the first is simple, the rest trivial, no?

Stop it.  Just accept that we don't want clk_add_alias to be __init.

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [RFC] [PATCH v2] arm & sh: factorised duplicated clkdev.c
  2010-08-31 11:16 ` Jean-Christophe PLAGNIOL-VILLARD
@ 2010-09-02 12:48   ` Jean-Christophe PLAGNIOL-VILLARD
  -1 siblings, 0 replies; 133+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2010-09-02 12:48 UTC (permalink / raw)
  To: linux-arm-kernel

factorise some generic infrastructure to assist looking up struct clks
for the ARM & SH architecture.

as the code is identical at 99%

put the arch specific code for allocation as example in asm/clkdev.h

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
V2:

	update base on Russel & Uwe Comments

Best Regards,
J.
 arch/arm/Kconfig                                |   40 +++---
 arch/arm/common/Kconfig                         |    4 -
 arch/arm/common/Makefile                        |    1 -
 arch/arm/include/asm/clkdev.h                   |   24 +---
 arch/arm/mach-bcmring/clock.c                   |    3 +-
 arch/arm/mach-bcmring/core.c                    |    2 +-
 arch/arm/mach-davinci/clock.h                   |    2 +-
 arch/arm/mach-ep93xx/clock.c                    |    2 +-
 arch/arm/mach-imx/clock-imx1.c                  |    3 +-
 arch/arm/mach-imx/clock-imx21.c                 |    2 +-
 arch/arm/mach-imx/clock-imx27.c                 |    2 +-
 arch/arm/mach-integrator/core.c                 |    3 +-
 arch/arm/mach-integrator/impd1.c                |    3 +-
 arch/arm/mach-integrator/integrator_cp.c        |    3 +-
 arch/arm/mach-lpc32xx/clock.c                   |    3 +-
 arch/arm/mach-mmp/clock.h                       |    2 +-
 arch/arm/mach-mx25/clock.c                      |    3 +-
 arch/arm/mach-mx3/clock-imx31.c                 |    2 +-
 arch/arm/mach-mx3/clock-imx35.c                 |    3 +-
 arch/arm/mach-mx5/clock-mx51.c                  |    2 +-
 arch/arm/mach-mxc91231/clock.c                  |    2 +-
 arch/arm/mach-nomadik/clock.c                   |    2 +-
 arch/arm/mach-nuc93x/clock.h                    |    2 +-
 arch/arm/mach-omap1/clock.c                     |    2 +-
 arch/arm/mach-omap2/dpll3xxx.c                  |    2 +-
 arch/arm/mach-pnx4008/clock.c                   |    3 +-
 arch/arm/mach-pxa/clock.c                       |    2 +-
 arch/arm/mach-pxa/clock.h                       |    2 +-
 arch/arm/mach-realview/core.c                   |    3 +-
 arch/arm/mach-shmobile/Kconfig                  |    6 +-
 arch/arm/mach-shmobile/clock-sh7367.c           |    2 +-
 arch/arm/mach-shmobile/clock-sh7372.c           |    2 +-
 arch/arm/mach-shmobile/clock-sh7377.c           |    2 +-
 arch/arm/mach-tegra/clock.c                     |    2 +-
 arch/arm/mach-tegra/clock.h                     |    2 +-
 arch/arm/mach-tegra/tegra2_clocks.c             |    3 +-
 arch/arm/mach-u300/clock.c                      |    2 +-
 arch/arm/mach-ux500/clock.c                     |    3 +-
 arch/arm/mach-versatile/core.c                  |    3 +-
 arch/arm/mach-vexpress/ct-ca9x4.c               |    3 +-
 arch/arm/mach-vexpress/v2m.c                    |    3 +-
 arch/arm/mach-w90x900/clock.h                   |    2 +-
 arch/arm/plat-omap/Kconfig                      |    4 +-
 arch/arm/plat-omap/include/plat/clkdev_omap.h   |    2 +-
 arch/arm/plat-spear/include/plat/clock.h        |    2 +-
 arch/arm/plat-stmp3xxx/clock.c                  |    2 +-
 arch/sh/Kconfig                                 |    2 +-
 arch/sh/boards/mach-highlander/setup.c          |    2 +-
 arch/sh/include/asm/clkdev.h                    |   66 ++++-----
 arch/sh/kernel/Makefile                         |    2 +-
 arch/sh/kernel/clkdev.c                         |  169 -----------------------
 arch/sh/kernel/cpu/clock-cpg.c                  |    2 +-
 arch/sh/kernel/cpu/clock.c                      |   16 --
 arch/sh/kernel/cpu/sh4/clock-sh4-202.c          |    2 +-
 arch/sh/kernel/cpu/sh4a/clock-sh7343.c          |    2 +-
 arch/sh/kernel/cpu/sh4a/clock-sh7366.c          |    2 +-
 arch/sh/kernel/cpu/sh4a/clock-sh7722.c          |    2 +-
 arch/sh/kernel/cpu/sh4a/clock-sh7723.c          |    2 +-
 arch/sh/kernel/cpu/sh4a/clock-sh7724.c          |    2 +-
 arch/sh/kernel/cpu/sh4a/clock-sh7757.c          |    2 +-
 arch/sh/kernel/cpu/sh4a/clock-sh7763.c          |    2 +-
 arch/sh/kernel/cpu/sh4a/clock-sh7780.c          |    2 +-
 arch/sh/kernel/cpu/sh4a/clock-sh7785.c          |    2 +-
 arch/sh/kernel/cpu/sh4a/clock-sh7786.c          |    2 +-
 arch/sh/kernel/cpu/sh4a/clock-shx3.c            |    2 +-
 drivers/Kconfig                                 |    2 +
 drivers/Makefile                                |    2 +
 drivers/clk/Kconfig                             |    4 +
 drivers/clk/Makefile                            |    2 +
 {arch/arm/common => drivers/clk}/clkdev.c       |   17 ++-
 {arch/sh/include/asm => include/linux}/clkdev.h |   10 +-
 71 files changed, 143 insertions(+), 351 deletions(-)
 rewrite arch/sh/include/asm/clkdev.h (69%)
 delete mode 100644 arch/sh/kernel/clkdev.c
 create mode 100644 drivers/clk/Kconfig
 create mode 100644 drivers/clk/Makefile
 rename {arch/arm/common => drivers/clk}/clkdev.c (91%)
 rename {arch/sh/include/asm => include/linux}/clkdev.h (85%)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index a7ed21f..1d8a26c 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -221,7 +221,7 @@ config ARCH_INTEGRATOR
 	bool "ARM Ltd. Integrator family"
 	select ARM_AMBA
 	select ARCH_HAS_CPUFREQ
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	select ICST
 	select GENERIC_CLOCKEVENTS
 	select PLAT_VERSATILE
@@ -231,7 +231,7 @@ config ARCH_INTEGRATOR
 config ARCH_REALVIEW
 	bool "ARM Ltd. RealView family"
 	select ARM_AMBA
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	select ICST
 	select GENERIC_CLOCKEVENTS
 	select ARCH_WANT_OPTIONAL_GPIOLIB
@@ -245,7 +245,7 @@ config ARCH_VERSATILE
 	bool "ARM Ltd. Versatile family"
 	select ARM_AMBA
 	select ARM_VIC
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	select ICST
 	select GENERIC_CLOCKEVENTS
 	select ARCH_WANT_OPTIONAL_GPIOLIB
@@ -259,7 +259,7 @@ config ARCH_VEXPRESS
 	select ARCH_WANT_OPTIONAL_GPIOLIB
 	select ARM_AMBA
 	select ARM_TIMER_SP804
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	select GENERIC_CLOCKEVENTS
 	select HAVE_CLK
 	select ICST
@@ -281,7 +281,7 @@ config ARCH_BCMRING
 	depends on MMU
 	select CPU_V6
 	select ARM_AMBA
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	select GENERIC_CLOCKEVENTS
 	select ARCH_WANT_OPTIONAL_GPIOLIB
 	help
@@ -328,7 +328,7 @@ config ARCH_EP93XX
 	select CPU_ARM920T
 	select ARM_AMBA
 	select ARM_VIC
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	select ARCH_REQUIRE_GPIOLIB
 	select ARCH_HAS_HOLES_MEMORYMODEL
 	select ARCH_USES_GETTIMEOFFSET
@@ -348,14 +348,14 @@ config ARCH_MXC
 	bool "Freescale MXC/iMX-based"
 	select GENERIC_CLOCKEVENTS
 	select ARCH_REQUIRE_GPIOLIB
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	help
 	  Support for Freescale MXC/iMX-based family of processors
 
 config ARCH_STMP3XXX
 	bool "Freescale STMP3xxx"
 	select CPU_ARM926T
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	select ARCH_REQUIRE_GPIOLIB
 	select GENERIC_CLOCKEVENTS
 	select USB_ARCH_HAS_EHCI
@@ -473,7 +473,7 @@ config ARCH_LPC32XX
 	select HAVE_IDE
 	select ARM_AMBA
 	select USB_ARCH_HAS_OHCI
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	select GENERIC_TIME
 	select GENERIC_CLOCKEVENTS
 	help
@@ -507,7 +507,7 @@ config ARCH_MMP
 	bool "Marvell PXA168/910/MMP2"
 	depends on MMU
 	select ARCH_REQUIRE_GPIOLIB
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	select GENERIC_CLOCKEVENTS
 	select TICK_ONESHOT
 	select PLAT_PXA
@@ -539,7 +539,7 @@ config ARCH_W90X900
 	bool "Nuvoton W90X900 CPU"
 	select CPU_ARM926T
 	select ARCH_REQUIRE_GPIOLIB
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	select GENERIC_CLOCKEVENTS
 	help
 	  Support for Nuvoton (Winbond logic dept.) ARM9 processor,
@@ -553,7 +553,7 @@ config ARCH_W90X900
 config ARCH_NUC93X
 	bool "Nuvoton NUC93X CPU"
 	select CPU_ARM926T
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	help
 	  Support for Nuvoton (Winbond logic dept.) NUC93X MCU,The NUC93X is a
 	  low-power and high performance MPEG-4/JPEG multimedia controller chip.
@@ -564,7 +564,7 @@ config ARCH_TEGRA
 	select GENERIC_CLOCKEVENTS
 	select GENERIC_GPIO
 	select HAVE_CLK
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	select ARCH_HAS_BARRIERS if CACHE_L2X0
 	help
 	  This enables support for NVIDIA Tegra based systems (Tegra APX,
@@ -573,7 +573,7 @@ config ARCH_TEGRA
 config ARCH_PNX4008
 	bool "Philips Nexperia PNX4008 Mobile"
 	select CPU_ARM926T
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	select ARCH_USES_GETTIMEOFFSET
 	help
 	  This enables support for Philips PNX4008 mobile platform.
@@ -583,7 +583,7 @@ config ARCH_PXA
 	depends on MMU
 	select ARCH_MTD_XIP
 	select ARCH_HAS_CPUFREQ
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	select ARCH_REQUIRE_GPIOLIB
 	select GENERIC_CLOCKEVENTS
 	select TICK_ONESHOT
@@ -767,7 +767,7 @@ config ARCH_U300
 	select ARM_AMBA
 	select ARM_VIC
 	select GENERIC_CLOCKEVENTS
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	select GENERIC_GPIO
 	help
 	  Support for ST-Ericsson U300 series mobile platforms.
@@ -777,7 +777,7 @@ config ARCH_U8500
 	select CPU_V7
 	select ARM_AMBA
 	select GENERIC_CLOCKEVENTS
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	select ARCH_REQUIRE_GPIOLIB
 	help
 	  Support for ST-Ericsson's Ux500 architecture
@@ -787,7 +787,7 @@ config ARCH_NOMADIK
 	select ARM_AMBA
 	select ARM_VIC
 	select CPU_ARM926T
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	select GENERIC_CLOCKEVENTS
 	select ARCH_REQUIRE_GPIOLIB
 	help
@@ -799,7 +799,7 @@ config ARCH_DAVINCI
 	select ARCH_REQUIRE_GPIOLIB
 	select ZONE_DMA
 	select HAVE_IDE
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	select GENERIC_ALLOCATOR
 	select ARCH_HAS_HOLES_MEMORYMODEL
 	help
@@ -819,7 +819,7 @@ config PLAT_SPEAR
 	bool "ST SPEAr"
 	select ARM_AMBA
 	select ARCH_REQUIRE_GPIOLIB
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	select GENERIC_CLOCKEVENTS
 	select HAVE_CLK
 	help
diff --git a/arch/arm/common/Kconfig b/arch/arm/common/Kconfig
index 0a34c81..778655f 100644
--- a/arch/arm/common/Kconfig
+++ b/arch/arm/common/Kconfig
@@ -37,7 +37,3 @@ config SHARP_PARAM
 
 config SHARP_SCOOP
 	bool
-
-config COMMON_CLKDEV
-	bool
-	select HAVE_CLK
diff --git a/arch/arm/common/Makefile b/arch/arm/common/Makefile
index e6e8664..799e140 100644
--- a/arch/arm/common/Makefile
+++ b/arch/arm/common/Makefile
@@ -16,4 +16,3 @@ obj-$(CONFIG_SHARP_SCOOP)	+= scoop.o
 obj-$(CONFIG_ARCH_IXP2000)	+= uengine.o
 obj-$(CONFIG_ARCH_IXP23XX)	+= uengine.o
 obj-$(CONFIG_PCI_HOST_ITE8152)  += it8152.o
-obj-$(CONFIG_COMMON_CLKDEV)	+= clkdev.o
diff --git a/arch/arm/include/asm/clkdev.h b/arch/arm/include/asm/clkdev.h
index b56c138..1293780 100644
--- a/arch/arm/include/asm/clkdev.h
+++ b/arch/arm/include/asm/clkdev.h
@@ -1,5 +1,5 @@
 /*
- *  arch/arm/include/asm/clkdev.h
+ *  arch/arm/include/linux/clkdev.h
  *
  *  Copyright (C) 2008 Russell King.
  *
@@ -12,23 +12,13 @@
 #ifndef __ASM_CLKDEV_H
 #define __ASM_CLKDEV_H
 
-struct clk;
-struct device;
+#include <linux/slab.h>
 
-struct clk_lookup {
-	struct list_head	node;
-	const char		*dev_id;
-	const char		*con_id;
-	struct clk		*clk;
-};
+#include <mach/clkdev.h>
 
-struct clk_lookup *clkdev_alloc(struct clk *clk, const char *con_id,
-	const char *dev_fmt, ...);
-
-void clkdev_add(struct clk_lookup *cl);
-void clkdev_drop(struct clk_lookup *cl);
-
-void clkdev_add_table(struct clk_lookup *, size_t);
-int clk_add_alias(const char *, const char *, char *, struct device *);
+static inline struct clk_lookup_alloc *__clkdev_alloc(size_t size)
+{
+	return kzalloc(size, GFP_KERNEL);
+}
 
 #endif
diff --git a/arch/arm/mach-bcmring/clock.c b/arch/arm/mach-bcmring/clock.c
index 14bafc3..ad237a4 100644
--- a/arch/arm/mach-bcmring/clock.c
+++ b/arch/arm/mach-bcmring/clock.c
@@ -21,13 +21,12 @@
 #include <linux/string.h>
 #include <linux/clk.h>
 #include <linux/spinlock.h>
+#include <linux/clkdev.h>
 #include <mach/csp/hw_cfg.h>
 #include <mach/csp/chipcHw_def.h>
 #include <mach/csp/chipcHw_reg.h>
 #include <mach/csp/chipcHw_inline.h>
 
-#include <asm/clkdev.h>
-
 #include "clock.h"
 
 #define clk_is_primary(x)       ((x)->type & CLK_TYPE_PRIMARY)
diff --git a/arch/arm/mach-bcmring/core.c b/arch/arm/mach-bcmring/core.c
index d3f959e..ed96ef4 100644
--- a/arch/arm/mach-bcmring/core.c
+++ b/arch/arm/mach-bcmring/core.c
@@ -30,10 +30,10 @@
 #include <linux/amba/bus.h>
 #include <linux/clocksource.h>
 #include <linux/clockchips.h>
+#include <linux/clkdev.h>
 
 #include <mach/csp/mm_addr.h>
 #include <mach/hardware.h>
-#include <asm/clkdev.h>
 #include <linux/io.h>
 #include <asm/irq.h>
 #include <asm/hardware/arm_timer.h>
diff --git a/arch/arm/mach-davinci/clock.h b/arch/arm/mach-davinci/clock.h
index 01e3648..64c58ad 100644
--- a/arch/arm/mach-davinci/clock.h
+++ b/arch/arm/mach-davinci/clock.h
@@ -68,7 +68,7 @@
 #ifndef __ASSEMBLER__
 
 #include <linux/list.h>
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 
 struct pll_data {
 	u32 phys_base;
diff --git a/arch/arm/mach-ep93xx/clock.c b/arch/arm/mach-ep93xx/clock.c
index 8bf3cec..f60d636 100644
--- a/arch/arm/mach-ep93xx/clock.c
+++ b/arch/arm/mach-ep93xx/clock.c
@@ -19,10 +19,10 @@
 #include <linux/string.h>
 #include <linux/io.h>
 #include <linux/spinlock.h>
+#include <linux/clkdev.h>
 
 #include <mach/hardware.h>
 
-#include <asm/clkdev.h>
 #include <asm/div64.h>
 
 
diff --git a/arch/arm/mach-imx/clock-imx1.c b/arch/arm/mach-imx/clock-imx1.c
index c05096c..9c848d9 100644
--- a/arch/arm/mach-imx/clock-imx1.c
+++ b/arch/arm/mach-imx/clock-imx1.c
@@ -22,8 +22,7 @@
 #include <linux/err.h>
 #include <linux/clk.h>
 #include <linux/io.h>
-
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 
 #include <mach/clock.h>
 #include <mach/hardware.h>
diff --git a/arch/arm/mach-imx/clock-imx21.c b/arch/arm/mach-imx/clock-imx21.c
index bb419ef..19e966e 100644
--- a/arch/arm/mach-imx/clock-imx21.c
+++ b/arch/arm/mach-imx/clock-imx21.c
@@ -21,11 +21,11 @@
 #include <linux/clk.h>
 #include <linux/io.h>
 #include <linux/module.h>
+#include <linux/clkdev.h>
 
 #include <mach/clock.h>
 #include <mach/hardware.h>
 #include <mach/common.h>
-#include <asm/clkdev.h>
 #include <asm/div64.h>
 
 #define IO_ADDR_CCM(off)	(MX21_IO_ADDRESS(MX21_CCM_BASE_ADDR + (off)))
diff --git a/arch/arm/mach-imx/clock-imx27.c b/arch/arm/mach-imx/clock-imx27.c
index 5a1aa15..f121114 100644
--- a/arch/arm/mach-imx/clock-imx27.c
+++ b/arch/arm/mach-imx/clock-imx27.c
@@ -21,8 +21,8 @@
 #include <linux/clk.h>
 #include <linux/io.h>
 #include <linux/module.h>
+#include <linux/clkdev.h>
 
-#include <asm/clkdev.h>
 #include <asm/div64.h>
 
 #include <mach/clock.h>
diff --git a/arch/arm/mach-integrator/core.c b/arch/arm/mach-integrator/core.c
index 8f4fb6d..b8e884b 100644
--- a/arch/arm/mach-integrator/core.c
+++ b/arch/arm/mach-integrator/core.c
@@ -21,9 +21,8 @@
 #include <linux/amba/bus.h>
 #include <linux/amba/serial.h>
 #include <linux/io.h>
+#include <linux/clkdev.h>
 
-#include <asm/clkdev.h>
-#include <mach/clkdev.h>
 #include <mach/hardware.h>
 #include <mach/platform.h>
 #include <asm/irq.h>
diff --git a/arch/arm/mach-integrator/impd1.c b/arch/arm/mach-integrator/impd1.c
index fd684bf..5db574f 100644
--- a/arch/arm/mach-integrator/impd1.c
+++ b/arch/arm/mach-integrator/impd1.c
@@ -22,9 +22,8 @@
 #include <linux/amba/clcd.h>
 #include <linux/io.h>
 #include <linux/slab.h>
+#include <linux/clkdev.h>
 
-#include <asm/clkdev.h>
-#include <mach/clkdev.h>
 #include <asm/hardware/icst.h>
 #include <mach/lm.h>
 #include <mach/impd1.h>
diff --git a/arch/arm/mach-integrator/integrator_cp.c b/arch/arm/mach-integrator/integrator_cp.c
index 05db40e..fce64fc 100644
--- a/arch/arm/mach-integrator/integrator_cp.c
+++ b/arch/arm/mach-integrator/integrator_cp.c
@@ -21,9 +21,8 @@
 #include <linux/amba/mmci.h>
 #include <linux/io.h>
 #include <linux/gfp.h>
+#include <linux/clkdev.h>
 
-#include <asm/clkdev.h>
-#include <mach/clkdev.h>
 #include <mach/hardware.h>
 #include <mach/platform.h>
 #include <asm/irq.h>
diff --git a/arch/arm/mach-lpc32xx/clock.c b/arch/arm/mach-lpc32xx/clock.c
index 32d6379..da0e649 100644
--- a/arch/arm/mach-lpc32xx/clock.c
+++ b/arch/arm/mach-lpc32xx/clock.c
@@ -90,10 +90,9 @@
 #include <linux/clk.h>
 #include <linux/amba/bus.h>
 #include <linux/amba/clcd.h>
+#include <linux/clkdev.h>
 
 #include <mach/hardware.h>
-#include <asm/clkdev.h>
-#include <mach/clkdev.h>
 #include <mach/platform.h>
 #include "clock.h"
 #include "common.h"
diff --git a/arch/arm/mach-mmp/clock.h b/arch/arm/mach-mmp/clock.h
index 016ae94..9b027d7 100644
--- a/arch/arm/mach-mmp/clock.h
+++ b/arch/arm/mach-mmp/clock.h
@@ -6,7 +6,7 @@
  *  published by the Free Software Foundation.
  */
 
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 
 struct clkops {
 	void			(*enable)(struct clk *);
diff --git a/arch/arm/mach-mx25/clock.c b/arch/arm/mach-mx25/clock.c
index 40c7cc4..b3196bb 100644
--- a/arch/arm/mach-mx25/clock.c
+++ b/arch/arm/mach-mx25/clock.c
@@ -21,8 +21,7 @@
 #include <linux/list.h>
 #include <linux/clk.h>
 #include <linux/io.h>
-
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 
 #include <mach/clock.h>
 #include <mach/hardware.h>
diff --git a/arch/arm/mach-mx3/clock-imx31.c b/arch/arm/mach-mx3/clock-imx31.c
index 9a9eb6d..2ba7094 100644
--- a/arch/arm/mach-mx3/clock-imx31.c
+++ b/arch/arm/mach-mx3/clock-imx31.c
@@ -23,8 +23,8 @@
 #include <linux/clk.h>
 #include <linux/err.h>
 #include <linux/io.h>
+#include <linux/clkdev.h>
 
-#include <asm/clkdev.h>
 #include <asm/div64.h>
 
 #include <mach/clock.h>
diff --git a/arch/arm/mach-mx3/clock-imx35.c b/arch/arm/mach-mx3/clock-imx35.c
index d3af0fd..2d17c03 100644
--- a/arch/arm/mach-mx3/clock-imx35.c
+++ b/arch/arm/mach-mx3/clock-imx35.c
@@ -21,8 +21,7 @@
 #include <linux/list.h>
 #include <linux/clk.h>
 #include <linux/io.h>
-
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 
 #include <mach/clock.h>
 #include <mach/hardware.h>
diff --git a/arch/arm/mach-mx5/clock-mx51.c b/arch/arm/mach-mx5/clock-mx51.c
index 6af69de..e599b6d 100644
--- a/arch/arm/mach-mx5/clock-mx51.c
+++ b/arch/arm/mach-mx5/clock-mx51.c
@@ -14,8 +14,8 @@
 #include <linux/delay.h>
 #include <linux/clk.h>
 #include <linux/io.h>
+#include <linux/clkdev.h>
 
-#include <asm/clkdev.h>
 #include <asm/div64.h>
 
 #include <mach/hardware.h>
diff --git a/arch/arm/mach-mxc91231/clock.c b/arch/arm/mach-mxc91231/clock.c
index 5c85075..9fab505 100644
--- a/arch/arm/mach-mxc91231/clock.c
+++ b/arch/arm/mach-mxc91231/clock.c
@@ -2,12 +2,12 @@
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/io.h>
+#include <linux/clkdev.h>
 
 #include <mach/clock.h>
 #include <mach/hardware.h>
 #include <mach/common.h>
 
-#include <asm/clkdev.h>
 #include <asm/bug.h>
 #include <asm/div64.h>
 
diff --git a/arch/arm/mach-nomadik/clock.c b/arch/arm/mach-nomadik/clock.c
index 89f793a..48a59f2 100644
--- a/arch/arm/mach-nomadik/clock.c
+++ b/arch/arm/mach-nomadik/clock.c
@@ -7,7 +7,7 @@
 #include <linux/module.h>
 #include <linux/errno.h>
 #include <linux/clk.h>
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 #include "clock.h"
 
 /*
diff --git a/arch/arm/mach-nuc93x/clock.h b/arch/arm/mach-nuc93x/clock.h
index 18e51be..4de1f1d 100644
--- a/arch/arm/mach-nuc93x/clock.h
+++ b/arch/arm/mach-nuc93x/clock.h
@@ -10,7 +10,7 @@
  * the Free Software Foundation; either version 2 of the License.
  */
 
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 
 void nuc93x_clk_enable(struct clk *clk, int enable);
 void clks_register(struct clk_lookup *clks, size_t num);
diff --git a/arch/arm/mach-omap1/clock.c b/arch/arm/mach-omap1/clock.c
index b8c7fb9..84ef704 100644
--- a/arch/arm/mach-omap1/clock.c
+++ b/arch/arm/mach-omap1/clock.c
@@ -17,9 +17,9 @@
 #include <linux/err.h>
 #include <linux/clk.h>
 #include <linux/io.h>
+#include <linux/clkdev.h>
 
 #include <asm/mach-types.h>
-#include <asm/clkdev.h>
 
 #include <plat/cpu.h>
 #include <plat/usb.h>
diff --git a/arch/arm/mach-omap2/dpll3xxx.c b/arch/arm/mach-omap2/dpll3xxx.c
index ed8d330..ebb888f 100644
--- a/arch/arm/mach-omap2/dpll3xxx.c
+++ b/arch/arm/mach-omap2/dpll3xxx.c
@@ -26,10 +26,10 @@
 #include <linux/clk.h>
 #include <linux/io.h>
 #include <linux/bitops.h>
+#include <linux/clkdev.h>
 
 #include <plat/cpu.h>
 #include <plat/clock.h>
-#include <asm/clkdev.h>
 
 #include "clock.h"
 #include "prm.h"
diff --git a/arch/arm/mach-pnx4008/clock.c b/arch/arm/mach-pnx4008/clock.c
index 9d1975f..a4a3819 100644
--- a/arch/arm/mach-pnx4008/clock.c
+++ b/arch/arm/mach-pnx4008/clock.c
@@ -21,8 +21,7 @@
 #include <linux/err.h>
 #include <linux/delay.h>
 #include <linux/io.h>
-
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 
 #include <mach/hardware.h>
 #include <mach/clock.h>
diff --git a/arch/arm/mach-pxa/clock.c b/arch/arm/mach-pxa/clock.c
index abba008..4e4a84b 100644
--- a/arch/arm/mach-pxa/clock.c
+++ b/arch/arm/mach-pxa/clock.c
@@ -11,8 +11,8 @@
 #include <linux/spinlock.h>
 #include <linux/platform_device.h>
 #include <linux/delay.h>
+#include <linux/clkdev.h>
 
-#include <asm/clkdev.h>
 #include <mach/pxa2xx-regs.h>
 #include <mach/hardware.h>
 
diff --git a/arch/arm/mach-pxa/clock.h b/arch/arm/mach-pxa/clock.h
index d848874..12cc0e8 100644
--- a/arch/arm/mach-pxa/clock.h
+++ b/arch/arm/mach-pxa/clock.h
@@ -1,4 +1,4 @@
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 
 struct clkops {
 	void			(*enable)(struct clk *);
diff --git a/arch/arm/mach-realview/core.c b/arch/arm/mach-realview/core.c
index 2fa38df..cda8b04 100644
--- a/arch/arm/mach-realview/core.c
+++ b/arch/arm/mach-realview/core.c
@@ -30,8 +30,8 @@
 #include <linux/ata_platform.h>
 #include <linux/amba/mmci.h>
 #include <linux/gfp.h>
+#include <linux/clkdev.h>
 
-#include <asm/clkdev.h>
 #include <asm/system.h>
 #include <mach/hardware.h>
 #include <asm/irq.h>
@@ -47,7 +47,6 @@
 
 #include <asm/hardware/gic.h>
 
-#include <mach/clkdev.h>
 #include <mach/platform.h>
 #include <mach/irqs.h>
 #include <plat/timer-sp.h>
diff --git a/arch/arm/mach-shmobile/Kconfig b/arch/arm/mach-shmobile/Kconfig
index 54b479c..f8f06e9 100644
--- a/arch/arm/mach-shmobile/Kconfig
+++ b/arch/arm/mach-shmobile/Kconfig
@@ -6,7 +6,7 @@ config ARCH_SH7367
 	bool "SH-Mobile G3 (SH7367)"
 	select CPU_V6
 	select HAVE_CLK
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	select SH_CLK_CPG
 	select GENERIC_CLOCKEVENTS
 
@@ -14,7 +14,7 @@ config ARCH_SH7377
 	bool "SH-Mobile G4 (SH7377)"
 	select CPU_V7
 	select HAVE_CLK
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	select SH_CLK_CPG
 	select GENERIC_CLOCKEVENTS
 
@@ -22,7 +22,7 @@ config ARCH_SH7372
 	bool "SH-Mobile AP4 (SH7372)"
 	select CPU_V7
 	select HAVE_CLK
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	select SH_CLK_CPG
 	select GENERIC_CLOCKEVENTS
 
diff --git a/arch/arm/mach-shmobile/clock-sh7367.c b/arch/arm/mach-shmobile/clock-sh7367.c
index b6454c9..3030935 100644
--- a/arch/arm/mach-shmobile/clock-sh7367.c
+++ b/arch/arm/mach-shmobile/clock-sh7367.c
@@ -20,8 +20,8 @@
 #include <linux/kernel.h>
 #include <linux/io.h>
 #include <linux/sh_clk.h>
+#include <linux/clkdev.h>
 #include <mach/common.h>
-#include <asm/clkdev.h>
 
 /* SH7367 registers */
 #define RTFRQCR    0xe6150000
diff --git a/arch/arm/mach-shmobile/clock-sh7372.c b/arch/arm/mach-shmobile/clock-sh7372.c
index fb4e9b1..907f46d 100644
--- a/arch/arm/mach-shmobile/clock-sh7372.c
+++ b/arch/arm/mach-shmobile/clock-sh7372.c
@@ -20,8 +20,8 @@
 #include <linux/kernel.h>
 #include <linux/io.h>
 #include <linux/sh_clk.h>
+#include <linux/clkdev.h>
 #include <mach/common.h>
-#include <asm/clkdev.h>
 
 /* SH7372 registers */
 #define FRQCRA		0xe6150000
diff --git a/arch/arm/mach-shmobile/clock-sh7377.c b/arch/arm/mach-shmobile/clock-sh7377.c
index e007c28..a322c9b 100644
--- a/arch/arm/mach-shmobile/clock-sh7377.c
+++ b/arch/arm/mach-shmobile/clock-sh7377.c
@@ -20,8 +20,8 @@
 #include <linux/kernel.h>
 #include <linux/io.h>
 #include <linux/sh_clk.h>
+#include <linux/clkdev.h>
 #include <mach/common.h>
-#include <asm/clkdev.h>
 
 /* SH7377 registers */
 #define RTFRQCR    0xe6150000
diff --git a/arch/arm/mach-tegra/clock.c b/arch/arm/mach-tegra/clock.c
index 03ad578..cad740c 100644
--- a/arch/arm/mach-tegra/clock.c
+++ b/arch/arm/mach-tegra/clock.c
@@ -24,7 +24,7 @@
 #include <linux/debugfs.h>
 #include <linux/slab.h>
 #include <linux/seq_file.h>
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 
 #include "clock.h"
 
diff --git a/arch/arm/mach-tegra/clock.h b/arch/arm/mach-tegra/clock.h
index af7c70e..39a87e7 100644
--- a/arch/arm/mach-tegra/clock.h
+++ b/arch/arm/mach-tegra/clock.h
@@ -21,7 +21,7 @@
 #define __MACH_TEGRA_CLOCK_H
 
 #include <linux/list.h>
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 
 #define DIV_BUS			(1 << 0)
 #define DIV_U71			(1 << 1)
diff --git a/arch/arm/mach-tegra/tegra2_clocks.c b/arch/arm/mach-tegra/tegra2_clocks.c
index 4261632..d2cecbf 100644
--- a/arch/arm/mach-tegra/tegra2_clocks.c
+++ b/arch/arm/mach-tegra/tegra2_clocks.c
@@ -24,8 +24,7 @@
 #include <linux/delay.h>
 #include <linux/io.h>
 #include <linux/hrtimer.h>
-
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 
 #include <mach/iomap.h>
 
diff --git a/arch/arm/mach-u300/clock.c b/arch/arm/mach-u300/clock.c
index 60acf9e..cb3ab08 100644
--- a/arch/arm/mach-u300/clock.c
+++ b/arch/arm/mach-u300/clock.c
@@ -25,8 +25,8 @@
 #include <linux/timer.h>
 #include <linux/io.h>
 #include <linux/seq_file.h>
+#include <linux/clkdev.h>
 
-#include <asm/clkdev.h>
 #include <mach/hardware.h>
 #include <mach/syscon.h>
 
diff --git a/arch/arm/mach-ux500/clock.c b/arch/arm/mach-ux500/clock.c
index d8ab7f1..df238ab 100644
--- a/arch/arm/mach-ux500/clock.c
+++ b/arch/arm/mach-ux500/clock.c
@@ -13,8 +13,7 @@
 #include <linux/err.h>
 #include <linux/clk.h>
 #include <linux/io.h>
-
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 
 #include <plat/mtu.h>
 #include <mach/hardware.h>
diff --git a/arch/arm/mach-versatile/core.c b/arch/arm/mach-versatile/core.c
index e38acb0..8c1ca1d 100644
--- a/arch/arm/mach-versatile/core.c
+++ b/arch/arm/mach-versatile/core.c
@@ -31,8 +31,8 @@
 #include <linux/amba/pl022.h>
 #include <linux/io.h>
 #include <linux/gfp.h>
+#include <linux/clkdev.h>
 
-#include <asm/clkdev.h>
 #include <asm/system.h>
 #include <asm/irq.h>
 #include <asm/leds.h>
@@ -46,7 +46,6 @@
 #include <asm/mach/irq.h>
 #include <asm/mach/time.h>
 #include <asm/mach/map.h>
-#include <mach/clkdev.h>
 #include <mach/hardware.h>
 #include <mach/platform.h>
 #include <plat/timer-sp.h>
diff --git a/arch/arm/mach-vexpress/ct-ca9x4.c b/arch/arm/mach-vexpress/ct-ca9x4.c
index 577df6c..fb94f30 100644
--- a/arch/arm/mach-vexpress/ct-ca9x4.c
+++ b/arch/arm/mach-vexpress/ct-ca9x4.c
@@ -8,8 +8,8 @@
 #include <linux/platform_device.h>
 #include <linux/amba/bus.h>
 #include <linux/amba/clcd.h>
+#include <linux/clkdev.h>
 
-#include <asm/clkdev.h>
 #include <asm/pgtable.h>
 #include <asm/hardware/arm_timer.h>
 #include <asm/hardware/cache-l2x0.h>
@@ -18,7 +18,6 @@
 #include <asm/pmu.h>
 #include <asm/smp_twd.h>
 
-#include <mach/clkdev.h>
 #include <mach/ct-ca9x4.h>
 
 #include <plat/timer-sp.h>
diff --git a/arch/arm/mach-vexpress/v2m.c b/arch/arm/mach-vexpress/v2m.c
index 817f0ad..919103d 100644
--- a/arch/arm/mach-vexpress/v2m.c
+++ b/arch/arm/mach-vexpress/v2m.c
@@ -11,15 +11,14 @@
 #include <linux/spinlock.h>
 #include <linux/sysdev.h>
 #include <linux/usb/isp1760.h>
+#include <linux/clkdev.h>
 
-#include <asm/clkdev.h>
 #include <asm/sizes.h>
 #include <asm/mach/flash.h>
 #include <asm/mach/map.h>
 #include <asm/mach/time.h>
 #include <asm/hardware/arm_timer.h>
 
-#include <mach/clkdev.h>
 #include <mach/motherboard.h>
 
 #include <plat/timer-sp.h>
diff --git a/arch/arm/mach-w90x900/clock.h b/arch/arm/mach-w90x900/clock.h
index c56ddab..b88a1b1 100644
--- a/arch/arm/mach-w90x900/clock.h
+++ b/arch/arm/mach-w90x900/clock.h
@@ -10,7 +10,7 @@
  * the Free Software Foundation; either version 2 of the License.
  */
 
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 
 void nuc900_clk_enable(struct clk *clk, int enable);
 void nuc900_subclk_enable(struct clk *clk, int enable);
diff --git a/arch/arm/plat-omap/Kconfig b/arch/arm/plat-omap/Kconfig
index e39a417..271d7b8 100644
--- a/arch/arm/plat-omap/Kconfig
+++ b/arch/arm/plat-omap/Kconfig
@@ -11,13 +11,13 @@ choice
 
 config ARCH_OMAP1
 	bool "TI OMAP1"
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	help
 	  "Systems based on omap7xx, omap15xx or omap16xx"
 
 config ARCH_OMAP2PLUS
 	bool "TI OMAP2/3/4"
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	help
 	  "Systems based on omap24xx, omap34xx or omap44xx"
 
diff --git a/arch/arm/plat-omap/include/plat/clkdev_omap.h b/arch/arm/plat-omap/include/plat/clkdev_omap.h
index bb937f3..4b2028a 100644
--- a/arch/arm/plat-omap/include/plat/clkdev_omap.h
+++ b/arch/arm/plat-omap/include/plat/clkdev_omap.h
@@ -8,7 +8,7 @@
 #ifndef __ARCH_ARM_PLAT_OMAP_INCLUDE_PLAT_CLKDEV_OMAP_H
 #define __ARCH_ARM_PLAT_OMAP_INCLUDE_PLAT_CLKDEV_OMAP_H
 
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 
 struct omap_clk {
 	u16				cpu;
diff --git a/arch/arm/plat-spear/include/plat/clock.h b/arch/arm/plat-spear/include/plat/clock.h
index 298bafc..2572260 100644
--- a/arch/arm/plat-spear/include/plat/clock.h
+++ b/arch/arm/plat-spear/include/plat/clock.h
@@ -15,7 +15,7 @@
 #define __PLAT_CLOCK_H
 
 #include <linux/list.h>
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 #include <linux/types.h>
 
 /* clk structure flags */
diff --git a/arch/arm/plat-stmp3xxx/clock.c b/arch/arm/plat-stmp3xxx/clock.c
index e593a2a..2e712e1 100644
--- a/arch/arm/plat-stmp3xxx/clock.c
+++ b/arch/arm/plat-stmp3xxx/clock.c
@@ -25,9 +25,9 @@
 #include <linux/err.h>
 #include <linux/delay.h>
 #include <linux/io.h>
+#include <linux/clkdev.h>
 
 #include <asm/mach-types.h>
-#include <asm/clkdev.h>
 #include <mach/platform.h>
 #include <mach/regs-clkctrl.h>
 
diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index 33990fa..b5f8a0f 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -8,7 +8,7 @@ mainmenu "Linux/SuperH Kernel Configuration"
 config SUPERH
 	def_bool y
 	select EMBEDDED
-	select HAVE_CLK
+	select CLKDEV_LOOKUP
 	select HAVE_IDE if HAS_IOPORT
 	select HAVE_MEMBLOCK
 	select HAVE_OPROFILE
diff --git a/arch/sh/boards/mach-highlander/setup.c b/arch/sh/boards/mach-highlander/setup.c
index a5ecfba..87618c9 100644
--- a/arch/sh/boards/mach-highlander/setup.c
+++ b/arch/sh/boards/mach-highlander/setup.c
@@ -24,10 +24,10 @@
 #include <linux/interrupt.h>
 #include <linux/usb/r8a66597.h>
 #include <linux/usb/m66592.h>
+#include <linux/clkdev.h>
 #include <net/ax88796.h>
 #include <asm/machvec.h>
 #include <mach/highlander.h>
-#include <asm/clkdev.h>
 #include <asm/clock.h>
 #include <asm/heartbeat.h>
 #include <asm/io.h>
diff --git a/arch/sh/include/asm/clkdev.h b/arch/sh/include/asm/clkdev.h
dissimilarity index 69%
index 5645f35..6ba9186 100644
--- a/arch/sh/include/asm/clkdev.h
+++ b/arch/sh/include/asm/clkdev.h
@@ -1,35 +1,31 @@
-/*
- *  arch/sh/include/asm/clkdev.h
- *
- * Cloned from arch/arm/include/asm/clkdev.h:
- *
- *  Copyright (C) 2008 Russell King.
- *
- * 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.
- *
- * Helper for the clk API to assist looking up a struct clk.
- */
-#ifndef __ASM_CLKDEV_H
-#define __ASM_CLKDEV_H
-
-struct clk;
-
-struct clk_lookup {
-	struct list_head	node;
-	const char		*dev_id;
-	const char		*con_id;
-	struct clk		*clk;
-};
-
-struct clk_lookup *clkdev_alloc(struct clk *clk, const char *con_id,
-	const char *dev_fmt, ...);
-
-void clkdev_add(struct clk_lookup *cl);
-void clkdev_drop(struct clk_lookup *cl);
-
-void clkdev_add_table(struct clk_lookup *, size_t);
-int clk_add_alias(const char *, const char *, char *, struct device *);
-
-#endif
+/*
+ *  Copyright (C) 2010 Paul Mundt <lethal@linux-sh.org>
+ *
+ * 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.
+ *
+ * Helper for the clk API to assist looking up a struct clk.
+ */
+
+#ifndef __CLKDEV__H_
+#define __CLKDEV__H_
+
+#include <linux/bootmem.h>
+#include <linux/mm.h>
+#include <linux/slab.h>
+
+#include <asm/clock.h>
+
+static inline struct clk_lookup_alloc *__clkdev_alloc(size_t size)
+{
+	if (!slab_is_available())
+		return alloc_bootmem_low_pages(size);
+	else
+		return kzalloc(size, GFP_KERNEL);
+}
+
+#define __clk_put(clk)
+#define __clk_get(clk) ({ 1; })
+
+#endif /* __CLKDEV_H__ */
diff --git a/arch/sh/kernel/Makefile b/arch/sh/kernel/Makefile
index e25f3c6..e4fe614 100644
--- a/arch/sh/kernel/Makefile
+++ b/arch/sh/kernel/Makefile
@@ -11,7 +11,7 @@ endif
 
 CFLAGS_REMOVE_return_address.o = -pg
 
-obj-y	:= clkdev.o debugtraps.o dma-nommu.o dumpstack.o 		\
+obj-y	:= debugtraps.o dma-nommu.o dumpstack.o 			\
 	   idle.o io.o irq.o						\
 	   irq_$(BITS).o machvec.o nmi_debug.o process.o		\
 	   process_$(BITS).o ptrace_$(BITS).o				\
diff --git a/arch/sh/kernel/clkdev.c b/arch/sh/kernel/clkdev.c
deleted file mode 100644
index befc255..0000000
--- a/arch/sh/kernel/clkdev.c
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * arch/sh/kernel/clkdev.c
- *
- * Cloned from arch/arm/common/clkdev.c:
- *
- *  Copyright (C) 2008 Russell King.
- *
- * 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.
- *
- * Helper for the clk API to assist looking up a struct clk.
- */
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/device.h>
-#include <linux/list.h>
-#include <linux/errno.h>
-#include <linux/err.h>
-#include <linux/string.h>
-#include <linux/mutex.h>
-#include <linux/clk.h>
-#include <linux/slab.h>
-#include <linux/bootmem.h>
-#include <linux/mm.h>
-#include <asm/clock.h>
-#include <asm/clkdev.h>
-
-static LIST_HEAD(clocks);
-static DEFINE_MUTEX(clocks_mutex);
-
-/*
- * Find the correct struct clk for the device and connection ID.
- * We do slightly fuzzy matching here:
- *  An entry with a NULL ID is assumed to be a wildcard.
- *  If an entry has a device ID, it must match
- *  If an entry has a connection ID, it must match
- * Then we take the most specific entry - with the following
- * order of precedence: dev+con > dev only > con only.
- */
-static struct clk *clk_find(const char *dev_id, const char *con_id)
-{
-	struct clk_lookup *p;
-	struct clk *clk = NULL;
-	int match, best = 0;
-
-	list_for_each_entry(p, &clocks, node) {
-		match = 0;
-		if (p->dev_id) {
-			if (!dev_id || strcmp(p->dev_id, dev_id))
-				continue;
-			match += 2;
-		}
-		if (p->con_id) {
-			if (!con_id || strcmp(p->con_id, con_id))
-				continue;
-			match += 1;
-		}
-		if (match = 0)
-			continue;
-
-		if (match > best) {
-			clk = p->clk;
-			best = match;
-		}
-	}
-	return clk;
-}
-
-struct clk *clk_get_sys(const char *dev_id, const char *con_id)
-{
-	struct clk *clk;
-
-	mutex_lock(&clocks_mutex);
-	clk = clk_find(dev_id, con_id);
-	mutex_unlock(&clocks_mutex);
-
-	return clk ? clk : ERR_PTR(-ENOENT);
-}
-EXPORT_SYMBOL(clk_get_sys);
-
-void clkdev_add(struct clk_lookup *cl)
-{
-	mutex_lock(&clocks_mutex);
-	list_add_tail(&cl->node, &clocks);
-	mutex_unlock(&clocks_mutex);
-}
-EXPORT_SYMBOL(clkdev_add);
-
-void __init clkdev_add_table(struct clk_lookup *cl, size_t num)
-{
-	mutex_lock(&clocks_mutex);
-	while (num--) {
-		list_add_tail(&cl->node, &clocks);
-		cl++;
-	}
-	mutex_unlock(&clocks_mutex);
-}
-
-#define MAX_DEV_ID	20
-#define MAX_CON_ID	16
-
-struct clk_lookup_alloc {
-	struct clk_lookup cl;
-	char	dev_id[MAX_DEV_ID];
-	char	con_id[MAX_CON_ID];
-};
-
-struct clk_lookup * __init_refok
-clkdev_alloc(struct clk *clk, const char *con_id, const char *dev_fmt, ...)
-{
-	struct clk_lookup_alloc *cla;
-
-	if (!slab_is_available())
-		cla = alloc_bootmem_low_pages(sizeof(*cla));
-	else
-		cla = kzalloc(sizeof(*cla), GFP_KERNEL);
-
-	if (!cla)
-		return NULL;
-
-	cla->cl.clk = clk;
-	if (con_id) {
-		strlcpy(cla->con_id, con_id, sizeof(cla->con_id));
-		cla->cl.con_id = cla->con_id;
-	}
-
-	if (dev_fmt) {
-		va_list ap;
-
-		va_start(ap, dev_fmt);
-		vscnprintf(cla->dev_id, sizeof(cla->dev_id), dev_fmt, ap);
-		cla->cl.dev_id = cla->dev_id;
-		va_end(ap);
-	}
-
-	return &cla->cl;
-}
-EXPORT_SYMBOL(clkdev_alloc);
-
-int clk_add_alias(const char *alias, const char *alias_dev_name, char *id,
-	struct device *dev)
-{
-	struct clk *r = clk_get(dev, id);
-	struct clk_lookup *l;
-
-	if (IS_ERR(r))
-		return PTR_ERR(r);
-
-	l = clkdev_alloc(r, alias, alias_dev_name);
-	clk_put(r);
-	if (!l)
-		return -ENODEV;
-	clkdev_add(l);
-	return 0;
-}
-EXPORT_SYMBOL(clk_add_alias);
-
-/*
- * clkdev_drop - remove a clock dynamically allocated
- */
-void clkdev_drop(struct clk_lookup *cl)
-{
-	mutex_lock(&clocks_mutex);
-	list_del(&cl->node);
-	mutex_unlock(&clocks_mutex);
-	kfree(cl);
-}
-EXPORT_SYMBOL(clkdev_drop);
diff --git a/arch/sh/kernel/cpu/clock-cpg.c b/arch/sh/kernel/cpu/clock-cpg.c
index e2f63d6..dd0e0f2 100644
--- a/arch/sh/kernel/cpu/clock-cpg.c
+++ b/arch/sh/kernel/cpu/clock-cpg.c
@@ -2,7 +2,7 @@
 #include <linux/compiler.h>
 #include <linux/slab.h>
 #include <linux/io.h>
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 #include <asm/clock.h>
 
 static struct clk master_clk = {
diff --git a/arch/sh/kernel/cpu/clock.c b/arch/sh/kernel/cpu/clock.c
index 50f887d..4187cf4 100644
--- a/arch/sh/kernel/cpu/clock.c
+++ b/arch/sh/kernel/cpu/clock.c
@@ -48,20 +48,4 @@ int __init clk_init(void)
 	return ret;
 }
 
-/*
- * Returns a clock. Note that we first try to use device id on the bus
- * and clock name. If this fails, we try to use clock name only.
- */
-struct clk *clk_get(struct device *dev, const char *con_id)
-{
-	const char *dev_id = dev ? dev_name(dev) : NULL;
-
-	return clk_get_sys(dev_id, con_id);
-}
-EXPORT_SYMBOL_GPL(clk_get);
-
-void clk_put(struct clk *clk)
-{
-}
-EXPORT_SYMBOL_GPL(clk_put);
 
diff --git a/arch/sh/kernel/cpu/sh4/clock-sh4-202.c b/arch/sh/kernel/cpu/sh4/clock-sh4-202.c
index 4eabc68..6c1492b 100644
--- a/arch/sh/kernel/cpu/sh4/clock-sh4-202.c
+++ b/arch/sh/kernel/cpu/sh4/clock-sh4-202.c
@@ -13,7 +13,7 @@
 #include <linux/kernel.h>
 #include <linux/err.h>
 #include <linux/io.h>
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 #include <asm/clock.h>
 #include <asm/freq.h>
 
diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7343.c b/arch/sh/kernel/cpu/sh4a/clock-sh7343.c
index 71291ae..93c6460 100644
--- a/arch/sh/kernel/cpu/sh4a/clock-sh7343.c
+++ b/arch/sh/kernel/cpu/sh4a/clock-sh7343.c
@@ -21,7 +21,7 @@
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/io.h>
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 #include <asm/clock.h>
 
 /* SH7343 registers */
diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7366.c b/arch/sh/kernel/cpu/sh4a/clock-sh7366.c
index 7ce5bbc..049dc06 100644
--- a/arch/sh/kernel/cpu/sh4a/clock-sh7366.c
+++ b/arch/sh/kernel/cpu/sh4a/clock-sh7366.c
@@ -21,7 +21,7 @@
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/io.h>
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 #include <asm/clock.h>
 
 /* SH7366 registers */
diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7722.c b/arch/sh/kernel/cpu/sh4a/clock-sh7722.c
index 2030f3d..9d23a36 100644
--- a/arch/sh/kernel/cpu/sh4a/clock-sh7722.c
+++ b/arch/sh/kernel/cpu/sh4a/clock-sh7722.c
@@ -21,7 +21,7 @@
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/io.h>
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 #include <asm/clock.h>
 #include <asm/hwblk.h>
 #include <cpu/sh7722.h>
diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7723.c b/arch/sh/kernel/cpu/sh4a/clock-sh7723.c
index d3938f0..55493cd 100644
--- a/arch/sh/kernel/cpu/sh4a/clock-sh7723.c
+++ b/arch/sh/kernel/cpu/sh4a/clock-sh7723.c
@@ -22,7 +22,7 @@
 #include <linux/kernel.h>
 #include <linux/io.h>
 #include <linux/clk.h>
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 #include <asm/clock.h>
 #include <asm/hwblk.h>
 #include <cpu/sh7723.h>
diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7724.c b/arch/sh/kernel/cpu/sh4a/clock-sh7724.c
index 2d9700c..527936b 100644
--- a/arch/sh/kernel/cpu/sh4a/clock-sh7724.c
+++ b/arch/sh/kernel/cpu/sh4a/clock-sh7724.c
@@ -22,7 +22,7 @@
 #include <linux/kernel.h>
 #include <linux/io.h>
 #include <linux/clk.h>
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 #include <asm/clock.h>
 #include <asm/hwblk.h>
 #include <cpu/sh7724.h>
diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7757.c b/arch/sh/kernel/cpu/sh4a/clock-sh7757.c
index 0a752bd..589ee0a 100644
--- a/arch/sh/kernel/cpu/sh4a/clock-sh7757.c
+++ b/arch/sh/kernel/cpu/sh4a/clock-sh7757.c
@@ -12,7 +12,7 @@
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/io.h>
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 #include <asm/clock.h>
 #include <asm/freq.h>
 
diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7763.c b/arch/sh/kernel/cpu/sh4a/clock-sh7763.c
index 1f1df48..599630f 100644
--- a/arch/sh/kernel/cpu/sh4a/clock-sh7763.c
+++ b/arch/sh/kernel/cpu/sh4a/clock-sh7763.c
@@ -13,7 +13,7 @@
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/io.h>
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 #include <asm/clock.h>
 #include <asm/freq.h>
 #include <asm/io.h>
diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7780.c b/arch/sh/kernel/cpu/sh4a/clock-sh7780.c
index 62d7063..8894926 100644
--- a/arch/sh/kernel/cpu/sh4a/clock-sh7780.c
+++ b/arch/sh/kernel/cpu/sh4a/clock-sh7780.c
@@ -12,7 +12,7 @@
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/io.h>
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 #include <asm/clock.h>
 #include <asm/freq.h>
 #include <asm/io.h>
diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7785.c b/arch/sh/kernel/cpu/sh4a/clock-sh7785.c
index c3e458a..2d96024 100644
--- a/arch/sh/kernel/cpu/sh4a/clock-sh7785.c
+++ b/arch/sh/kernel/cpu/sh4a/clock-sh7785.c
@@ -14,7 +14,7 @@
 #include <linux/clk.h>
 #include <linux/io.h>
 #include <linux/cpufreq.h>
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 #include <asm/clock.h>
 #include <asm/freq.h>
 #include <cpu/sh7785.h>
diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7786.c b/arch/sh/kernel/cpu/sh4a/clock-sh7786.c
index 597c9fb..42e403b 100644
--- a/arch/sh/kernel/cpu/sh4a/clock-sh7786.c
+++ b/arch/sh/kernel/cpu/sh4a/clock-sh7786.c
@@ -13,7 +13,7 @@
 #include <linux/kernel.h>
 #include <linux/clk.h>
 #include <linux/io.h>
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 #include <asm/clock.h>
 #include <asm/freq.h>
 
diff --git a/arch/sh/kernel/cpu/sh4a/clock-shx3.c b/arch/sh/kernel/cpu/sh4a/clock-shx3.c
index 236a628..228d7e6 100644
--- a/arch/sh/kernel/cpu/sh4a/clock-shx3.c
+++ b/arch/sh/kernel/cpu/sh4a/clock-shx3.c
@@ -14,7 +14,7 @@
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/io.h>
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 #include <asm/clock.h>
 #include <asm/freq.h>
 
diff --git a/drivers/Kconfig b/drivers/Kconfig
index a2b902f..3d93b3a 100644
--- a/drivers/Kconfig
+++ b/drivers/Kconfig
@@ -111,4 +111,6 @@ source "drivers/xen/Kconfig"
 source "drivers/staging/Kconfig"
 
 source "drivers/platform/Kconfig"
+
+source "drivers/clk/Kconfig"
 endmenu
diff --git a/drivers/Makefile b/drivers/Makefile
index ae47344..b0e30b2 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -115,3 +115,5 @@ obj-$(CONFIG_VLYNQ)		+= vlynq/
 obj-$(CONFIG_STAGING)		+= staging/
 obj-y				+= platform/
 obj-y				+= ieee802154/
+#common clk code
+obj-y				+= clk/
diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig
new file mode 100644
index 0000000..4168c88
--- /dev/null
+++ b/drivers/clk/Kconfig
@@ -0,0 +1,4 @@
+
+config CLKDEV_LOOKUP
+	bool
+	select HAVE_CLK
diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
new file mode 100644
index 0000000..07613fa
--- /dev/null
+++ b/drivers/clk/Makefile
@@ -0,0 +1,2 @@
+
+obj-$(CONFIG_CLKDEV_LOOKUP)	+= clkdev.o
diff --git a/arch/arm/common/clkdev.c b/drivers/clk/clkdev.c
similarity index 91%
rename from arch/arm/common/clkdev.c
rename to drivers/clk/clkdev.c
index e2b2bb6..d8b91ae 100644
--- a/arch/arm/common/clkdev.c
+++ b/drivers/clk/clkdev.c
@@ -1,5 +1,5 @@
 /*
- *  arch/arm/common/clkdev.c
+ * drivers/clk/clkdev.c
  *
  *  Copyright (C) 2008 Russell King.
  *
@@ -18,10 +18,7 @@
 #include <linux/string.h>
 #include <linux/mutex.h>
 #include <linux/clk.h>
-#include <linux/slab.h>
-
-#include <asm/clkdev.h>
-#include <mach/clkdev.h>
+#include <linux/clkdev.h>
 
 static LIST_HEAD(clocks);
 static DEFINE_MUTEX(clocks_mutex);
@@ -79,6 +76,10 @@ struct clk *clk_get_sys(const char *dev_id, const char *con_id)
 }
 EXPORT_SYMBOL(clk_get_sys);
 
+/*
+ * Returns a clock. Note that we first try to use device id on the bus
+ * and clock name. If this fails, we try to use clock name only.
+ */
 struct clk *clk_get(struct device *dev, const char *con_id)
 {
 	const char *dev_id = dev ? dev_name(dev) : NULL;
@@ -120,12 +121,12 @@ struct clk_lookup_alloc {
 	char	con_id[MAX_CON_ID];
 };
 
-struct clk_lookup *clkdev_alloc(struct clk *clk, const char *con_id,
-	const char *dev_fmt, ...)
+struct clk_lookup * __init_refok
+clkdev_alloc(struct clk *clk, const char *con_id, const char *dev_fmt, ...)
 {
 	struct clk_lookup_alloc *cla;
 
-	cla = kzalloc(sizeof(*cla), GFP_KERNEL);
+	cla = __clkdev_alloc(sizeof(*cla));
 	if (!cla)
 		return NULL;
 
diff --git a/arch/sh/include/asm/clkdev.h b/include/linux/clkdev.h
similarity index 85%
rename from arch/sh/include/asm/clkdev.h
rename to include/linux/clkdev.h
index 5645f35..bd2ec89 100644
--- a/arch/sh/include/asm/clkdev.h
+++ b/include/linux/clkdev.h
@@ -1,7 +1,5 @@
 /*
- *  arch/sh/include/asm/clkdev.h
- *
- * Cloned from arch/arm/include/asm/clkdev.h:
+ *  include/linux/clkdev.h
  *
  *  Copyright (C) 2008 Russell King.
  *
@@ -11,8 +9,10 @@
  *
  * Helper for the clk API to assist looking up a struct clk.
  */
-#ifndef __ASM_CLKDEV_H
-#define __ASM_CLKDEV_H
+#ifndef __CLKDEV_H
+#define __CLKDEV_H
+
+#include <asm/clkdev.h>
 
 struct clk;
 
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [RFC] [PATCH v2] arm & sh: factorised duplicated clkdev.c
@ 2010-09-02 12:48   ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 0 replies; 133+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2010-09-02 12:48 UTC (permalink / raw)
  To: linux-arm-kernel

factorise some generic infrastructure to assist looking up struct clks
for the ARM & SH architecture.

as the code is identical at 99%

put the arch specific code for allocation as example in asm/clkdev.h

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
V2:

	update base on Russel & Uwe Comments

Best Regards,
J.
 arch/arm/Kconfig                                |   40 +++---
 arch/arm/common/Kconfig                         |    4 -
 arch/arm/common/Makefile                        |    1 -
 arch/arm/include/asm/clkdev.h                   |   24 +---
 arch/arm/mach-bcmring/clock.c                   |    3 +-
 arch/arm/mach-bcmring/core.c                    |    2 +-
 arch/arm/mach-davinci/clock.h                   |    2 +-
 arch/arm/mach-ep93xx/clock.c                    |    2 +-
 arch/arm/mach-imx/clock-imx1.c                  |    3 +-
 arch/arm/mach-imx/clock-imx21.c                 |    2 +-
 arch/arm/mach-imx/clock-imx27.c                 |    2 +-
 arch/arm/mach-integrator/core.c                 |    3 +-
 arch/arm/mach-integrator/impd1.c                |    3 +-
 arch/arm/mach-integrator/integrator_cp.c        |    3 +-
 arch/arm/mach-lpc32xx/clock.c                   |    3 +-
 arch/arm/mach-mmp/clock.h                       |    2 +-
 arch/arm/mach-mx25/clock.c                      |    3 +-
 arch/arm/mach-mx3/clock-imx31.c                 |    2 +-
 arch/arm/mach-mx3/clock-imx35.c                 |    3 +-
 arch/arm/mach-mx5/clock-mx51.c                  |    2 +-
 arch/arm/mach-mxc91231/clock.c                  |    2 +-
 arch/arm/mach-nomadik/clock.c                   |    2 +-
 arch/arm/mach-nuc93x/clock.h                    |    2 +-
 arch/arm/mach-omap1/clock.c                     |    2 +-
 arch/arm/mach-omap2/dpll3xxx.c                  |    2 +-
 arch/arm/mach-pnx4008/clock.c                   |    3 +-
 arch/arm/mach-pxa/clock.c                       |    2 +-
 arch/arm/mach-pxa/clock.h                       |    2 +-
 arch/arm/mach-realview/core.c                   |    3 +-
 arch/arm/mach-shmobile/Kconfig                  |    6 +-
 arch/arm/mach-shmobile/clock-sh7367.c           |    2 +-
 arch/arm/mach-shmobile/clock-sh7372.c           |    2 +-
 arch/arm/mach-shmobile/clock-sh7377.c           |    2 +-
 arch/arm/mach-tegra/clock.c                     |    2 +-
 arch/arm/mach-tegra/clock.h                     |    2 +-
 arch/arm/mach-tegra/tegra2_clocks.c             |    3 +-
 arch/arm/mach-u300/clock.c                      |    2 +-
 arch/arm/mach-ux500/clock.c                     |    3 +-
 arch/arm/mach-versatile/core.c                  |    3 +-
 arch/arm/mach-vexpress/ct-ca9x4.c               |    3 +-
 arch/arm/mach-vexpress/v2m.c                    |    3 +-
 arch/arm/mach-w90x900/clock.h                   |    2 +-
 arch/arm/plat-omap/Kconfig                      |    4 +-
 arch/arm/plat-omap/include/plat/clkdev_omap.h   |    2 +-
 arch/arm/plat-spear/include/plat/clock.h        |    2 +-
 arch/arm/plat-stmp3xxx/clock.c                  |    2 +-
 arch/sh/Kconfig                                 |    2 +-
 arch/sh/boards/mach-highlander/setup.c          |    2 +-
 arch/sh/include/asm/clkdev.h                    |   66 ++++-----
 arch/sh/kernel/Makefile                         |    2 +-
 arch/sh/kernel/clkdev.c                         |  169 -----------------------
 arch/sh/kernel/cpu/clock-cpg.c                  |    2 +-
 arch/sh/kernel/cpu/clock.c                      |   16 --
 arch/sh/kernel/cpu/sh4/clock-sh4-202.c          |    2 +-
 arch/sh/kernel/cpu/sh4a/clock-sh7343.c          |    2 +-
 arch/sh/kernel/cpu/sh4a/clock-sh7366.c          |    2 +-
 arch/sh/kernel/cpu/sh4a/clock-sh7722.c          |    2 +-
 arch/sh/kernel/cpu/sh4a/clock-sh7723.c          |    2 +-
 arch/sh/kernel/cpu/sh4a/clock-sh7724.c          |    2 +-
 arch/sh/kernel/cpu/sh4a/clock-sh7757.c          |    2 +-
 arch/sh/kernel/cpu/sh4a/clock-sh7763.c          |    2 +-
 arch/sh/kernel/cpu/sh4a/clock-sh7780.c          |    2 +-
 arch/sh/kernel/cpu/sh4a/clock-sh7785.c          |    2 +-
 arch/sh/kernel/cpu/sh4a/clock-sh7786.c          |    2 +-
 arch/sh/kernel/cpu/sh4a/clock-shx3.c            |    2 +-
 drivers/Kconfig                                 |    2 +
 drivers/Makefile                                |    2 +
 drivers/clk/Kconfig                             |    4 +
 drivers/clk/Makefile                            |    2 +
 {arch/arm/common => drivers/clk}/clkdev.c       |   17 ++-
 {arch/sh/include/asm => include/linux}/clkdev.h |   10 +-
 71 files changed, 143 insertions(+), 351 deletions(-)
 rewrite arch/sh/include/asm/clkdev.h (69%)
 delete mode 100644 arch/sh/kernel/clkdev.c
 create mode 100644 drivers/clk/Kconfig
 create mode 100644 drivers/clk/Makefile
 rename {arch/arm/common => drivers/clk}/clkdev.c (91%)
 rename {arch/sh/include/asm => include/linux}/clkdev.h (85%)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index a7ed21f..1d8a26c 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -221,7 +221,7 @@ config ARCH_INTEGRATOR
 	bool "ARM Ltd. Integrator family"
 	select ARM_AMBA
 	select ARCH_HAS_CPUFREQ
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	select ICST
 	select GENERIC_CLOCKEVENTS
 	select PLAT_VERSATILE
@@ -231,7 +231,7 @@ config ARCH_INTEGRATOR
 config ARCH_REALVIEW
 	bool "ARM Ltd. RealView family"
 	select ARM_AMBA
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	select ICST
 	select GENERIC_CLOCKEVENTS
 	select ARCH_WANT_OPTIONAL_GPIOLIB
@@ -245,7 +245,7 @@ config ARCH_VERSATILE
 	bool "ARM Ltd. Versatile family"
 	select ARM_AMBA
 	select ARM_VIC
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	select ICST
 	select GENERIC_CLOCKEVENTS
 	select ARCH_WANT_OPTIONAL_GPIOLIB
@@ -259,7 +259,7 @@ config ARCH_VEXPRESS
 	select ARCH_WANT_OPTIONAL_GPIOLIB
 	select ARM_AMBA
 	select ARM_TIMER_SP804
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	select GENERIC_CLOCKEVENTS
 	select HAVE_CLK
 	select ICST
@@ -281,7 +281,7 @@ config ARCH_BCMRING
 	depends on MMU
 	select CPU_V6
 	select ARM_AMBA
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	select GENERIC_CLOCKEVENTS
 	select ARCH_WANT_OPTIONAL_GPIOLIB
 	help
@@ -328,7 +328,7 @@ config ARCH_EP93XX
 	select CPU_ARM920T
 	select ARM_AMBA
 	select ARM_VIC
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	select ARCH_REQUIRE_GPIOLIB
 	select ARCH_HAS_HOLES_MEMORYMODEL
 	select ARCH_USES_GETTIMEOFFSET
@@ -348,14 +348,14 @@ config ARCH_MXC
 	bool "Freescale MXC/iMX-based"
 	select GENERIC_CLOCKEVENTS
 	select ARCH_REQUIRE_GPIOLIB
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	help
 	  Support for Freescale MXC/iMX-based family of processors
 
 config ARCH_STMP3XXX
 	bool "Freescale STMP3xxx"
 	select CPU_ARM926T
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	select ARCH_REQUIRE_GPIOLIB
 	select GENERIC_CLOCKEVENTS
 	select USB_ARCH_HAS_EHCI
@@ -473,7 +473,7 @@ config ARCH_LPC32XX
 	select HAVE_IDE
 	select ARM_AMBA
 	select USB_ARCH_HAS_OHCI
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	select GENERIC_TIME
 	select GENERIC_CLOCKEVENTS
 	help
@@ -507,7 +507,7 @@ config ARCH_MMP
 	bool "Marvell PXA168/910/MMP2"
 	depends on MMU
 	select ARCH_REQUIRE_GPIOLIB
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	select GENERIC_CLOCKEVENTS
 	select TICK_ONESHOT
 	select PLAT_PXA
@@ -539,7 +539,7 @@ config ARCH_W90X900
 	bool "Nuvoton W90X900 CPU"
 	select CPU_ARM926T
 	select ARCH_REQUIRE_GPIOLIB
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	select GENERIC_CLOCKEVENTS
 	help
 	  Support for Nuvoton (Winbond logic dept.) ARM9 processor,
@@ -553,7 +553,7 @@ config ARCH_W90X900
 config ARCH_NUC93X
 	bool "Nuvoton NUC93X CPU"
 	select CPU_ARM926T
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	help
 	  Support for Nuvoton (Winbond logic dept.) NUC93X MCU,The NUC93X is a
 	  low-power and high performance MPEG-4/JPEG multimedia controller chip.
@@ -564,7 +564,7 @@ config ARCH_TEGRA
 	select GENERIC_CLOCKEVENTS
 	select GENERIC_GPIO
 	select HAVE_CLK
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	select ARCH_HAS_BARRIERS if CACHE_L2X0
 	help
 	  This enables support for NVIDIA Tegra based systems (Tegra APX,
@@ -573,7 +573,7 @@ config ARCH_TEGRA
 config ARCH_PNX4008
 	bool "Philips Nexperia PNX4008 Mobile"
 	select CPU_ARM926T
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	select ARCH_USES_GETTIMEOFFSET
 	help
 	  This enables support for Philips PNX4008 mobile platform.
@@ -583,7 +583,7 @@ config ARCH_PXA
 	depends on MMU
 	select ARCH_MTD_XIP
 	select ARCH_HAS_CPUFREQ
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	select ARCH_REQUIRE_GPIOLIB
 	select GENERIC_CLOCKEVENTS
 	select TICK_ONESHOT
@@ -767,7 +767,7 @@ config ARCH_U300
 	select ARM_AMBA
 	select ARM_VIC
 	select GENERIC_CLOCKEVENTS
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	select GENERIC_GPIO
 	help
 	  Support for ST-Ericsson U300 series mobile platforms.
@@ -777,7 +777,7 @@ config ARCH_U8500
 	select CPU_V7
 	select ARM_AMBA
 	select GENERIC_CLOCKEVENTS
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	select ARCH_REQUIRE_GPIOLIB
 	help
 	  Support for ST-Ericsson's Ux500 architecture
@@ -787,7 +787,7 @@ config ARCH_NOMADIK
 	select ARM_AMBA
 	select ARM_VIC
 	select CPU_ARM926T
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	select GENERIC_CLOCKEVENTS
 	select ARCH_REQUIRE_GPIOLIB
 	help
@@ -799,7 +799,7 @@ config ARCH_DAVINCI
 	select ARCH_REQUIRE_GPIOLIB
 	select ZONE_DMA
 	select HAVE_IDE
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	select GENERIC_ALLOCATOR
 	select ARCH_HAS_HOLES_MEMORYMODEL
 	help
@@ -819,7 +819,7 @@ config PLAT_SPEAR
 	bool "ST SPEAr"
 	select ARM_AMBA
 	select ARCH_REQUIRE_GPIOLIB
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	select GENERIC_CLOCKEVENTS
 	select HAVE_CLK
 	help
diff --git a/arch/arm/common/Kconfig b/arch/arm/common/Kconfig
index 0a34c81..778655f 100644
--- a/arch/arm/common/Kconfig
+++ b/arch/arm/common/Kconfig
@@ -37,7 +37,3 @@ config SHARP_PARAM
 
 config SHARP_SCOOP
 	bool
-
-config COMMON_CLKDEV
-	bool
-	select HAVE_CLK
diff --git a/arch/arm/common/Makefile b/arch/arm/common/Makefile
index e6e8664..799e140 100644
--- a/arch/arm/common/Makefile
+++ b/arch/arm/common/Makefile
@@ -16,4 +16,3 @@ obj-$(CONFIG_SHARP_SCOOP)	+= scoop.o
 obj-$(CONFIG_ARCH_IXP2000)	+= uengine.o
 obj-$(CONFIG_ARCH_IXP23XX)	+= uengine.o
 obj-$(CONFIG_PCI_HOST_ITE8152)  += it8152.o
-obj-$(CONFIG_COMMON_CLKDEV)	+= clkdev.o
diff --git a/arch/arm/include/asm/clkdev.h b/arch/arm/include/asm/clkdev.h
index b56c138..1293780 100644
--- a/arch/arm/include/asm/clkdev.h
+++ b/arch/arm/include/asm/clkdev.h
@@ -1,5 +1,5 @@
 /*
- *  arch/arm/include/asm/clkdev.h
+ *  arch/arm/include/linux/clkdev.h
  *
  *  Copyright (C) 2008 Russell King.
  *
@@ -12,23 +12,13 @@
 #ifndef __ASM_CLKDEV_H
 #define __ASM_CLKDEV_H
 
-struct clk;
-struct device;
+#include <linux/slab.h>
 
-struct clk_lookup {
-	struct list_head	node;
-	const char		*dev_id;
-	const char		*con_id;
-	struct clk		*clk;
-};
+#include <mach/clkdev.h>
 
-struct clk_lookup *clkdev_alloc(struct clk *clk, const char *con_id,
-	const char *dev_fmt, ...);
-
-void clkdev_add(struct clk_lookup *cl);
-void clkdev_drop(struct clk_lookup *cl);
-
-void clkdev_add_table(struct clk_lookup *, size_t);
-int clk_add_alias(const char *, const char *, char *, struct device *);
+static inline struct clk_lookup_alloc *__clkdev_alloc(size_t size)
+{
+	return kzalloc(size, GFP_KERNEL);
+}
 
 #endif
diff --git a/arch/arm/mach-bcmring/clock.c b/arch/arm/mach-bcmring/clock.c
index 14bafc3..ad237a4 100644
--- a/arch/arm/mach-bcmring/clock.c
+++ b/arch/arm/mach-bcmring/clock.c
@@ -21,13 +21,12 @@
 #include <linux/string.h>
 #include <linux/clk.h>
 #include <linux/spinlock.h>
+#include <linux/clkdev.h>
 #include <mach/csp/hw_cfg.h>
 #include <mach/csp/chipcHw_def.h>
 #include <mach/csp/chipcHw_reg.h>
 #include <mach/csp/chipcHw_inline.h>
 
-#include <asm/clkdev.h>
-
 #include "clock.h"
 
 #define clk_is_primary(x)       ((x)->type & CLK_TYPE_PRIMARY)
diff --git a/arch/arm/mach-bcmring/core.c b/arch/arm/mach-bcmring/core.c
index d3f959e..ed96ef4 100644
--- a/arch/arm/mach-bcmring/core.c
+++ b/arch/arm/mach-bcmring/core.c
@@ -30,10 +30,10 @@
 #include <linux/amba/bus.h>
 #include <linux/clocksource.h>
 #include <linux/clockchips.h>
+#include <linux/clkdev.h>
 
 #include <mach/csp/mm_addr.h>
 #include <mach/hardware.h>
-#include <asm/clkdev.h>
 #include <linux/io.h>
 #include <asm/irq.h>
 #include <asm/hardware/arm_timer.h>
diff --git a/arch/arm/mach-davinci/clock.h b/arch/arm/mach-davinci/clock.h
index 01e3648..64c58ad 100644
--- a/arch/arm/mach-davinci/clock.h
+++ b/arch/arm/mach-davinci/clock.h
@@ -68,7 +68,7 @@
 #ifndef __ASSEMBLER__
 
 #include <linux/list.h>
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 
 struct pll_data {
 	u32 phys_base;
diff --git a/arch/arm/mach-ep93xx/clock.c b/arch/arm/mach-ep93xx/clock.c
index 8bf3cec..f60d636 100644
--- a/arch/arm/mach-ep93xx/clock.c
+++ b/arch/arm/mach-ep93xx/clock.c
@@ -19,10 +19,10 @@
 #include <linux/string.h>
 #include <linux/io.h>
 #include <linux/spinlock.h>
+#include <linux/clkdev.h>
 
 #include <mach/hardware.h>
 
-#include <asm/clkdev.h>
 #include <asm/div64.h>
 
 
diff --git a/arch/arm/mach-imx/clock-imx1.c b/arch/arm/mach-imx/clock-imx1.c
index c05096c..9c848d9 100644
--- a/arch/arm/mach-imx/clock-imx1.c
+++ b/arch/arm/mach-imx/clock-imx1.c
@@ -22,8 +22,7 @@
 #include <linux/err.h>
 #include <linux/clk.h>
 #include <linux/io.h>
-
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 
 #include <mach/clock.h>
 #include <mach/hardware.h>
diff --git a/arch/arm/mach-imx/clock-imx21.c b/arch/arm/mach-imx/clock-imx21.c
index bb419ef..19e966e 100644
--- a/arch/arm/mach-imx/clock-imx21.c
+++ b/arch/arm/mach-imx/clock-imx21.c
@@ -21,11 +21,11 @@
 #include <linux/clk.h>
 #include <linux/io.h>
 #include <linux/module.h>
+#include <linux/clkdev.h>
 
 #include <mach/clock.h>
 #include <mach/hardware.h>
 #include <mach/common.h>
-#include <asm/clkdev.h>
 #include <asm/div64.h>
 
 #define IO_ADDR_CCM(off)	(MX21_IO_ADDRESS(MX21_CCM_BASE_ADDR + (off)))
diff --git a/arch/arm/mach-imx/clock-imx27.c b/arch/arm/mach-imx/clock-imx27.c
index 5a1aa15..f121114 100644
--- a/arch/arm/mach-imx/clock-imx27.c
+++ b/arch/arm/mach-imx/clock-imx27.c
@@ -21,8 +21,8 @@
 #include <linux/clk.h>
 #include <linux/io.h>
 #include <linux/module.h>
+#include <linux/clkdev.h>
 
-#include <asm/clkdev.h>
 #include <asm/div64.h>
 
 #include <mach/clock.h>
diff --git a/arch/arm/mach-integrator/core.c b/arch/arm/mach-integrator/core.c
index 8f4fb6d..b8e884b 100644
--- a/arch/arm/mach-integrator/core.c
+++ b/arch/arm/mach-integrator/core.c
@@ -21,9 +21,8 @@
 #include <linux/amba/bus.h>
 #include <linux/amba/serial.h>
 #include <linux/io.h>
+#include <linux/clkdev.h>
 
-#include <asm/clkdev.h>
-#include <mach/clkdev.h>
 #include <mach/hardware.h>
 #include <mach/platform.h>
 #include <asm/irq.h>
diff --git a/arch/arm/mach-integrator/impd1.c b/arch/arm/mach-integrator/impd1.c
index fd684bf..5db574f 100644
--- a/arch/arm/mach-integrator/impd1.c
+++ b/arch/arm/mach-integrator/impd1.c
@@ -22,9 +22,8 @@
 #include <linux/amba/clcd.h>
 #include <linux/io.h>
 #include <linux/slab.h>
+#include <linux/clkdev.h>
 
-#include <asm/clkdev.h>
-#include <mach/clkdev.h>
 #include <asm/hardware/icst.h>
 #include <mach/lm.h>
 #include <mach/impd1.h>
diff --git a/arch/arm/mach-integrator/integrator_cp.c b/arch/arm/mach-integrator/integrator_cp.c
index 05db40e..fce64fc 100644
--- a/arch/arm/mach-integrator/integrator_cp.c
+++ b/arch/arm/mach-integrator/integrator_cp.c
@@ -21,9 +21,8 @@
 #include <linux/amba/mmci.h>
 #include <linux/io.h>
 #include <linux/gfp.h>
+#include <linux/clkdev.h>
 
-#include <asm/clkdev.h>
-#include <mach/clkdev.h>
 #include <mach/hardware.h>
 #include <mach/platform.h>
 #include <asm/irq.h>
diff --git a/arch/arm/mach-lpc32xx/clock.c b/arch/arm/mach-lpc32xx/clock.c
index 32d6379..da0e649 100644
--- a/arch/arm/mach-lpc32xx/clock.c
+++ b/arch/arm/mach-lpc32xx/clock.c
@@ -90,10 +90,9 @@
 #include <linux/clk.h>
 #include <linux/amba/bus.h>
 #include <linux/amba/clcd.h>
+#include <linux/clkdev.h>
 
 #include <mach/hardware.h>
-#include <asm/clkdev.h>
-#include <mach/clkdev.h>
 #include <mach/platform.h>
 #include "clock.h"
 #include "common.h"
diff --git a/arch/arm/mach-mmp/clock.h b/arch/arm/mach-mmp/clock.h
index 016ae94..9b027d7 100644
--- a/arch/arm/mach-mmp/clock.h
+++ b/arch/arm/mach-mmp/clock.h
@@ -6,7 +6,7 @@
  *  published by the Free Software Foundation.
  */
 
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 
 struct clkops {
 	void			(*enable)(struct clk *);
diff --git a/arch/arm/mach-mx25/clock.c b/arch/arm/mach-mx25/clock.c
index 40c7cc4..b3196bb 100644
--- a/arch/arm/mach-mx25/clock.c
+++ b/arch/arm/mach-mx25/clock.c
@@ -21,8 +21,7 @@
 #include <linux/list.h>
 #include <linux/clk.h>
 #include <linux/io.h>
-
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 
 #include <mach/clock.h>
 #include <mach/hardware.h>
diff --git a/arch/arm/mach-mx3/clock-imx31.c b/arch/arm/mach-mx3/clock-imx31.c
index 9a9eb6d..2ba7094 100644
--- a/arch/arm/mach-mx3/clock-imx31.c
+++ b/arch/arm/mach-mx3/clock-imx31.c
@@ -23,8 +23,8 @@
 #include <linux/clk.h>
 #include <linux/err.h>
 #include <linux/io.h>
+#include <linux/clkdev.h>
 
-#include <asm/clkdev.h>
 #include <asm/div64.h>
 
 #include <mach/clock.h>
diff --git a/arch/arm/mach-mx3/clock-imx35.c b/arch/arm/mach-mx3/clock-imx35.c
index d3af0fd..2d17c03 100644
--- a/arch/arm/mach-mx3/clock-imx35.c
+++ b/arch/arm/mach-mx3/clock-imx35.c
@@ -21,8 +21,7 @@
 #include <linux/list.h>
 #include <linux/clk.h>
 #include <linux/io.h>
-
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 
 #include <mach/clock.h>
 #include <mach/hardware.h>
diff --git a/arch/arm/mach-mx5/clock-mx51.c b/arch/arm/mach-mx5/clock-mx51.c
index 6af69de..e599b6d 100644
--- a/arch/arm/mach-mx5/clock-mx51.c
+++ b/arch/arm/mach-mx5/clock-mx51.c
@@ -14,8 +14,8 @@
 #include <linux/delay.h>
 #include <linux/clk.h>
 #include <linux/io.h>
+#include <linux/clkdev.h>
 
-#include <asm/clkdev.h>
 #include <asm/div64.h>
 
 #include <mach/hardware.h>
diff --git a/arch/arm/mach-mxc91231/clock.c b/arch/arm/mach-mxc91231/clock.c
index 5c85075..9fab505 100644
--- a/arch/arm/mach-mxc91231/clock.c
+++ b/arch/arm/mach-mxc91231/clock.c
@@ -2,12 +2,12 @@
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/io.h>
+#include <linux/clkdev.h>
 
 #include <mach/clock.h>
 #include <mach/hardware.h>
 #include <mach/common.h>
 
-#include <asm/clkdev.h>
 #include <asm/bug.h>
 #include <asm/div64.h>
 
diff --git a/arch/arm/mach-nomadik/clock.c b/arch/arm/mach-nomadik/clock.c
index 89f793a..48a59f2 100644
--- a/arch/arm/mach-nomadik/clock.c
+++ b/arch/arm/mach-nomadik/clock.c
@@ -7,7 +7,7 @@
 #include <linux/module.h>
 #include <linux/errno.h>
 #include <linux/clk.h>
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 #include "clock.h"
 
 /*
diff --git a/arch/arm/mach-nuc93x/clock.h b/arch/arm/mach-nuc93x/clock.h
index 18e51be..4de1f1d 100644
--- a/arch/arm/mach-nuc93x/clock.h
+++ b/arch/arm/mach-nuc93x/clock.h
@@ -10,7 +10,7 @@
  * the Free Software Foundation; either version 2 of the License.
  */
 
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 
 void nuc93x_clk_enable(struct clk *clk, int enable);
 void clks_register(struct clk_lookup *clks, size_t num);
diff --git a/arch/arm/mach-omap1/clock.c b/arch/arm/mach-omap1/clock.c
index b8c7fb9..84ef704 100644
--- a/arch/arm/mach-omap1/clock.c
+++ b/arch/arm/mach-omap1/clock.c
@@ -17,9 +17,9 @@
 #include <linux/err.h>
 #include <linux/clk.h>
 #include <linux/io.h>
+#include <linux/clkdev.h>
 
 #include <asm/mach-types.h>
-#include <asm/clkdev.h>
 
 #include <plat/cpu.h>
 #include <plat/usb.h>
diff --git a/arch/arm/mach-omap2/dpll3xxx.c b/arch/arm/mach-omap2/dpll3xxx.c
index ed8d330..ebb888f 100644
--- a/arch/arm/mach-omap2/dpll3xxx.c
+++ b/arch/arm/mach-omap2/dpll3xxx.c
@@ -26,10 +26,10 @@
 #include <linux/clk.h>
 #include <linux/io.h>
 #include <linux/bitops.h>
+#include <linux/clkdev.h>
 
 #include <plat/cpu.h>
 #include <plat/clock.h>
-#include <asm/clkdev.h>
 
 #include "clock.h"
 #include "prm.h"
diff --git a/arch/arm/mach-pnx4008/clock.c b/arch/arm/mach-pnx4008/clock.c
index 9d1975f..a4a3819 100644
--- a/arch/arm/mach-pnx4008/clock.c
+++ b/arch/arm/mach-pnx4008/clock.c
@@ -21,8 +21,7 @@
 #include <linux/err.h>
 #include <linux/delay.h>
 #include <linux/io.h>
-
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 
 #include <mach/hardware.h>
 #include <mach/clock.h>
diff --git a/arch/arm/mach-pxa/clock.c b/arch/arm/mach-pxa/clock.c
index abba008..4e4a84b 100644
--- a/arch/arm/mach-pxa/clock.c
+++ b/arch/arm/mach-pxa/clock.c
@@ -11,8 +11,8 @@
 #include <linux/spinlock.h>
 #include <linux/platform_device.h>
 #include <linux/delay.h>
+#include <linux/clkdev.h>
 
-#include <asm/clkdev.h>
 #include <mach/pxa2xx-regs.h>
 #include <mach/hardware.h>
 
diff --git a/arch/arm/mach-pxa/clock.h b/arch/arm/mach-pxa/clock.h
index d848874..12cc0e8 100644
--- a/arch/arm/mach-pxa/clock.h
+++ b/arch/arm/mach-pxa/clock.h
@@ -1,4 +1,4 @@
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 
 struct clkops {
 	void			(*enable)(struct clk *);
diff --git a/arch/arm/mach-realview/core.c b/arch/arm/mach-realview/core.c
index 2fa38df..cda8b04 100644
--- a/arch/arm/mach-realview/core.c
+++ b/arch/arm/mach-realview/core.c
@@ -30,8 +30,8 @@
 #include <linux/ata_platform.h>
 #include <linux/amba/mmci.h>
 #include <linux/gfp.h>
+#include <linux/clkdev.h>
 
-#include <asm/clkdev.h>
 #include <asm/system.h>
 #include <mach/hardware.h>
 #include <asm/irq.h>
@@ -47,7 +47,6 @@
 
 #include <asm/hardware/gic.h>
 
-#include <mach/clkdev.h>
 #include <mach/platform.h>
 #include <mach/irqs.h>
 #include <plat/timer-sp.h>
diff --git a/arch/arm/mach-shmobile/Kconfig b/arch/arm/mach-shmobile/Kconfig
index 54b479c..f8f06e9 100644
--- a/arch/arm/mach-shmobile/Kconfig
+++ b/arch/arm/mach-shmobile/Kconfig
@@ -6,7 +6,7 @@ config ARCH_SH7367
 	bool "SH-Mobile G3 (SH7367)"
 	select CPU_V6
 	select HAVE_CLK
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	select SH_CLK_CPG
 	select GENERIC_CLOCKEVENTS
 
@@ -14,7 +14,7 @@ config ARCH_SH7377
 	bool "SH-Mobile G4 (SH7377)"
 	select CPU_V7
 	select HAVE_CLK
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	select SH_CLK_CPG
 	select GENERIC_CLOCKEVENTS
 
@@ -22,7 +22,7 @@ config ARCH_SH7372
 	bool "SH-Mobile AP4 (SH7372)"
 	select CPU_V7
 	select HAVE_CLK
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	select SH_CLK_CPG
 	select GENERIC_CLOCKEVENTS
 
diff --git a/arch/arm/mach-shmobile/clock-sh7367.c b/arch/arm/mach-shmobile/clock-sh7367.c
index b6454c9..3030935 100644
--- a/arch/arm/mach-shmobile/clock-sh7367.c
+++ b/arch/arm/mach-shmobile/clock-sh7367.c
@@ -20,8 +20,8 @@
 #include <linux/kernel.h>
 #include <linux/io.h>
 #include <linux/sh_clk.h>
+#include <linux/clkdev.h>
 #include <mach/common.h>
-#include <asm/clkdev.h>
 
 /* SH7367 registers */
 #define RTFRQCR    0xe6150000
diff --git a/arch/arm/mach-shmobile/clock-sh7372.c b/arch/arm/mach-shmobile/clock-sh7372.c
index fb4e9b1..907f46d 100644
--- a/arch/arm/mach-shmobile/clock-sh7372.c
+++ b/arch/arm/mach-shmobile/clock-sh7372.c
@@ -20,8 +20,8 @@
 #include <linux/kernel.h>
 #include <linux/io.h>
 #include <linux/sh_clk.h>
+#include <linux/clkdev.h>
 #include <mach/common.h>
-#include <asm/clkdev.h>
 
 /* SH7372 registers */
 #define FRQCRA		0xe6150000
diff --git a/arch/arm/mach-shmobile/clock-sh7377.c b/arch/arm/mach-shmobile/clock-sh7377.c
index e007c28..a322c9b 100644
--- a/arch/arm/mach-shmobile/clock-sh7377.c
+++ b/arch/arm/mach-shmobile/clock-sh7377.c
@@ -20,8 +20,8 @@
 #include <linux/kernel.h>
 #include <linux/io.h>
 #include <linux/sh_clk.h>
+#include <linux/clkdev.h>
 #include <mach/common.h>
-#include <asm/clkdev.h>
 
 /* SH7377 registers */
 #define RTFRQCR    0xe6150000
diff --git a/arch/arm/mach-tegra/clock.c b/arch/arm/mach-tegra/clock.c
index 03ad578..cad740c 100644
--- a/arch/arm/mach-tegra/clock.c
+++ b/arch/arm/mach-tegra/clock.c
@@ -24,7 +24,7 @@
 #include <linux/debugfs.h>
 #include <linux/slab.h>
 #include <linux/seq_file.h>
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 
 #include "clock.h"
 
diff --git a/arch/arm/mach-tegra/clock.h b/arch/arm/mach-tegra/clock.h
index af7c70e..39a87e7 100644
--- a/arch/arm/mach-tegra/clock.h
+++ b/arch/arm/mach-tegra/clock.h
@@ -21,7 +21,7 @@
 #define __MACH_TEGRA_CLOCK_H
 
 #include <linux/list.h>
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 
 #define DIV_BUS			(1 << 0)
 #define DIV_U71			(1 << 1)
diff --git a/arch/arm/mach-tegra/tegra2_clocks.c b/arch/arm/mach-tegra/tegra2_clocks.c
index 4261632..d2cecbf 100644
--- a/arch/arm/mach-tegra/tegra2_clocks.c
+++ b/arch/arm/mach-tegra/tegra2_clocks.c
@@ -24,8 +24,7 @@
 #include <linux/delay.h>
 #include <linux/io.h>
 #include <linux/hrtimer.h>
-
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 
 #include <mach/iomap.h>
 
diff --git a/arch/arm/mach-u300/clock.c b/arch/arm/mach-u300/clock.c
index 60acf9e..cb3ab08 100644
--- a/arch/arm/mach-u300/clock.c
+++ b/arch/arm/mach-u300/clock.c
@@ -25,8 +25,8 @@
 #include <linux/timer.h>
 #include <linux/io.h>
 #include <linux/seq_file.h>
+#include <linux/clkdev.h>
 
-#include <asm/clkdev.h>
 #include <mach/hardware.h>
 #include <mach/syscon.h>
 
diff --git a/arch/arm/mach-ux500/clock.c b/arch/arm/mach-ux500/clock.c
index d8ab7f1..df238ab 100644
--- a/arch/arm/mach-ux500/clock.c
+++ b/arch/arm/mach-ux500/clock.c
@@ -13,8 +13,7 @@
 #include <linux/err.h>
 #include <linux/clk.h>
 #include <linux/io.h>
-
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 
 #include <plat/mtu.h>
 #include <mach/hardware.h>
diff --git a/arch/arm/mach-versatile/core.c b/arch/arm/mach-versatile/core.c
index e38acb0..8c1ca1d 100644
--- a/arch/arm/mach-versatile/core.c
+++ b/arch/arm/mach-versatile/core.c
@@ -31,8 +31,8 @@
 #include <linux/amba/pl022.h>
 #include <linux/io.h>
 #include <linux/gfp.h>
+#include <linux/clkdev.h>
 
-#include <asm/clkdev.h>
 #include <asm/system.h>
 #include <asm/irq.h>
 #include <asm/leds.h>
@@ -46,7 +46,6 @@
 #include <asm/mach/irq.h>
 #include <asm/mach/time.h>
 #include <asm/mach/map.h>
-#include <mach/clkdev.h>
 #include <mach/hardware.h>
 #include <mach/platform.h>
 #include <plat/timer-sp.h>
diff --git a/arch/arm/mach-vexpress/ct-ca9x4.c b/arch/arm/mach-vexpress/ct-ca9x4.c
index 577df6c..fb94f30 100644
--- a/arch/arm/mach-vexpress/ct-ca9x4.c
+++ b/arch/arm/mach-vexpress/ct-ca9x4.c
@@ -8,8 +8,8 @@
 #include <linux/platform_device.h>
 #include <linux/amba/bus.h>
 #include <linux/amba/clcd.h>
+#include <linux/clkdev.h>
 
-#include <asm/clkdev.h>
 #include <asm/pgtable.h>
 #include <asm/hardware/arm_timer.h>
 #include <asm/hardware/cache-l2x0.h>
@@ -18,7 +18,6 @@
 #include <asm/pmu.h>
 #include <asm/smp_twd.h>
 
-#include <mach/clkdev.h>
 #include <mach/ct-ca9x4.h>
 
 #include <plat/timer-sp.h>
diff --git a/arch/arm/mach-vexpress/v2m.c b/arch/arm/mach-vexpress/v2m.c
index 817f0ad..919103d 100644
--- a/arch/arm/mach-vexpress/v2m.c
+++ b/arch/arm/mach-vexpress/v2m.c
@@ -11,15 +11,14 @@
 #include <linux/spinlock.h>
 #include <linux/sysdev.h>
 #include <linux/usb/isp1760.h>
+#include <linux/clkdev.h>
 
-#include <asm/clkdev.h>
 #include <asm/sizes.h>
 #include <asm/mach/flash.h>
 #include <asm/mach/map.h>
 #include <asm/mach/time.h>
 #include <asm/hardware/arm_timer.h>
 
-#include <mach/clkdev.h>
 #include <mach/motherboard.h>
 
 #include <plat/timer-sp.h>
diff --git a/arch/arm/mach-w90x900/clock.h b/arch/arm/mach-w90x900/clock.h
index c56ddab..b88a1b1 100644
--- a/arch/arm/mach-w90x900/clock.h
+++ b/arch/arm/mach-w90x900/clock.h
@@ -10,7 +10,7 @@
  * the Free Software Foundation; either version 2 of the License.
  */
 
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 
 void nuc900_clk_enable(struct clk *clk, int enable);
 void nuc900_subclk_enable(struct clk *clk, int enable);
diff --git a/arch/arm/plat-omap/Kconfig b/arch/arm/plat-omap/Kconfig
index e39a417..271d7b8 100644
--- a/arch/arm/plat-omap/Kconfig
+++ b/arch/arm/plat-omap/Kconfig
@@ -11,13 +11,13 @@ choice
 
 config ARCH_OMAP1
 	bool "TI OMAP1"
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	help
 	  "Systems based on omap7xx, omap15xx or omap16xx"
 
 config ARCH_OMAP2PLUS
 	bool "TI OMAP2/3/4"
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	help
 	  "Systems based on omap24xx, omap34xx or omap44xx"
 
diff --git a/arch/arm/plat-omap/include/plat/clkdev_omap.h b/arch/arm/plat-omap/include/plat/clkdev_omap.h
index bb937f3..4b2028a 100644
--- a/arch/arm/plat-omap/include/plat/clkdev_omap.h
+++ b/arch/arm/plat-omap/include/plat/clkdev_omap.h
@@ -8,7 +8,7 @@
 #ifndef __ARCH_ARM_PLAT_OMAP_INCLUDE_PLAT_CLKDEV_OMAP_H
 #define __ARCH_ARM_PLAT_OMAP_INCLUDE_PLAT_CLKDEV_OMAP_H
 
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 
 struct omap_clk {
 	u16				cpu;
diff --git a/arch/arm/plat-spear/include/plat/clock.h b/arch/arm/plat-spear/include/plat/clock.h
index 298bafc..2572260 100644
--- a/arch/arm/plat-spear/include/plat/clock.h
+++ b/arch/arm/plat-spear/include/plat/clock.h
@@ -15,7 +15,7 @@
 #define __PLAT_CLOCK_H
 
 #include <linux/list.h>
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 #include <linux/types.h>
 
 /* clk structure flags */
diff --git a/arch/arm/plat-stmp3xxx/clock.c b/arch/arm/plat-stmp3xxx/clock.c
index e593a2a..2e712e1 100644
--- a/arch/arm/plat-stmp3xxx/clock.c
+++ b/arch/arm/plat-stmp3xxx/clock.c
@@ -25,9 +25,9 @@
 #include <linux/err.h>
 #include <linux/delay.h>
 #include <linux/io.h>
+#include <linux/clkdev.h>
 
 #include <asm/mach-types.h>
-#include <asm/clkdev.h>
 #include <mach/platform.h>
 #include <mach/regs-clkctrl.h>
 
diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index 33990fa..b5f8a0f 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -8,7 +8,7 @@ mainmenu "Linux/SuperH Kernel Configuration"
 config SUPERH
 	def_bool y
 	select EMBEDDED
-	select HAVE_CLK
+	select CLKDEV_LOOKUP
 	select HAVE_IDE if HAS_IOPORT
 	select HAVE_MEMBLOCK
 	select HAVE_OPROFILE
diff --git a/arch/sh/boards/mach-highlander/setup.c b/arch/sh/boards/mach-highlander/setup.c
index a5ecfba..87618c9 100644
--- a/arch/sh/boards/mach-highlander/setup.c
+++ b/arch/sh/boards/mach-highlander/setup.c
@@ -24,10 +24,10 @@
 #include <linux/interrupt.h>
 #include <linux/usb/r8a66597.h>
 #include <linux/usb/m66592.h>
+#include <linux/clkdev.h>
 #include <net/ax88796.h>
 #include <asm/machvec.h>
 #include <mach/highlander.h>
-#include <asm/clkdev.h>
 #include <asm/clock.h>
 #include <asm/heartbeat.h>
 #include <asm/io.h>
diff --git a/arch/sh/include/asm/clkdev.h b/arch/sh/include/asm/clkdev.h
dissimilarity index 69%
index 5645f35..6ba9186 100644
--- a/arch/sh/include/asm/clkdev.h
+++ b/arch/sh/include/asm/clkdev.h
@@ -1,35 +1,31 @@
-/*
- *  arch/sh/include/asm/clkdev.h
- *
- * Cloned from arch/arm/include/asm/clkdev.h:
- *
- *  Copyright (C) 2008 Russell King.
- *
- * 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.
- *
- * Helper for the clk API to assist looking up a struct clk.
- */
-#ifndef __ASM_CLKDEV_H
-#define __ASM_CLKDEV_H
-
-struct clk;
-
-struct clk_lookup {
-	struct list_head	node;
-	const char		*dev_id;
-	const char		*con_id;
-	struct clk		*clk;
-};
-
-struct clk_lookup *clkdev_alloc(struct clk *clk, const char *con_id,
-	const char *dev_fmt, ...);
-
-void clkdev_add(struct clk_lookup *cl);
-void clkdev_drop(struct clk_lookup *cl);
-
-void clkdev_add_table(struct clk_lookup *, size_t);
-int clk_add_alias(const char *, const char *, char *, struct device *);
-
-#endif
+/*
+ *  Copyright (C) 2010 Paul Mundt <lethal@linux-sh.org>
+ *
+ * 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.
+ *
+ * Helper for the clk API to assist looking up a struct clk.
+ */
+
+#ifndef __CLKDEV__H_
+#define __CLKDEV__H_
+
+#include <linux/bootmem.h>
+#include <linux/mm.h>
+#include <linux/slab.h>
+
+#include <asm/clock.h>
+
+static inline struct clk_lookup_alloc *__clkdev_alloc(size_t size)
+{
+	if (!slab_is_available())
+		return alloc_bootmem_low_pages(size);
+	else
+		return kzalloc(size, GFP_KERNEL);
+}
+
+#define __clk_put(clk)
+#define __clk_get(clk) ({ 1; })
+
+#endif /* __CLKDEV_H__ */
diff --git a/arch/sh/kernel/Makefile b/arch/sh/kernel/Makefile
index e25f3c6..e4fe614 100644
--- a/arch/sh/kernel/Makefile
+++ b/arch/sh/kernel/Makefile
@@ -11,7 +11,7 @@ endif
 
 CFLAGS_REMOVE_return_address.o = -pg
 
-obj-y	:= clkdev.o debugtraps.o dma-nommu.o dumpstack.o 		\
+obj-y	:= debugtraps.o dma-nommu.o dumpstack.o 			\
 	   idle.o io.o irq.o						\
 	   irq_$(BITS).o machvec.o nmi_debug.o process.o		\
 	   process_$(BITS).o ptrace_$(BITS).o				\
diff --git a/arch/sh/kernel/clkdev.c b/arch/sh/kernel/clkdev.c
deleted file mode 100644
index befc255..0000000
--- a/arch/sh/kernel/clkdev.c
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * arch/sh/kernel/clkdev.c
- *
- * Cloned from arch/arm/common/clkdev.c:
- *
- *  Copyright (C) 2008 Russell King.
- *
- * 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.
- *
- * Helper for the clk API to assist looking up a struct clk.
- */
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/device.h>
-#include <linux/list.h>
-#include <linux/errno.h>
-#include <linux/err.h>
-#include <linux/string.h>
-#include <linux/mutex.h>
-#include <linux/clk.h>
-#include <linux/slab.h>
-#include <linux/bootmem.h>
-#include <linux/mm.h>
-#include <asm/clock.h>
-#include <asm/clkdev.h>
-
-static LIST_HEAD(clocks);
-static DEFINE_MUTEX(clocks_mutex);
-
-/*
- * Find the correct struct clk for the device and connection ID.
- * We do slightly fuzzy matching here:
- *  An entry with a NULL ID is assumed to be a wildcard.
- *  If an entry has a device ID, it must match
- *  If an entry has a connection ID, it must match
- * Then we take the most specific entry - with the following
- * order of precedence: dev+con > dev only > con only.
- */
-static struct clk *clk_find(const char *dev_id, const char *con_id)
-{
-	struct clk_lookup *p;
-	struct clk *clk = NULL;
-	int match, best = 0;
-
-	list_for_each_entry(p, &clocks, node) {
-		match = 0;
-		if (p->dev_id) {
-			if (!dev_id || strcmp(p->dev_id, dev_id))
-				continue;
-			match += 2;
-		}
-		if (p->con_id) {
-			if (!con_id || strcmp(p->con_id, con_id))
-				continue;
-			match += 1;
-		}
-		if (match == 0)
-			continue;
-
-		if (match > best) {
-			clk = p->clk;
-			best = match;
-		}
-	}
-	return clk;
-}
-
-struct clk *clk_get_sys(const char *dev_id, const char *con_id)
-{
-	struct clk *clk;
-
-	mutex_lock(&clocks_mutex);
-	clk = clk_find(dev_id, con_id);
-	mutex_unlock(&clocks_mutex);
-
-	return clk ? clk : ERR_PTR(-ENOENT);
-}
-EXPORT_SYMBOL(clk_get_sys);
-
-void clkdev_add(struct clk_lookup *cl)
-{
-	mutex_lock(&clocks_mutex);
-	list_add_tail(&cl->node, &clocks);
-	mutex_unlock(&clocks_mutex);
-}
-EXPORT_SYMBOL(clkdev_add);
-
-void __init clkdev_add_table(struct clk_lookup *cl, size_t num)
-{
-	mutex_lock(&clocks_mutex);
-	while (num--) {
-		list_add_tail(&cl->node, &clocks);
-		cl++;
-	}
-	mutex_unlock(&clocks_mutex);
-}
-
-#define MAX_DEV_ID	20
-#define MAX_CON_ID	16
-
-struct clk_lookup_alloc {
-	struct clk_lookup cl;
-	char	dev_id[MAX_DEV_ID];
-	char	con_id[MAX_CON_ID];
-};
-
-struct clk_lookup * __init_refok
-clkdev_alloc(struct clk *clk, const char *con_id, const char *dev_fmt, ...)
-{
-	struct clk_lookup_alloc *cla;
-
-	if (!slab_is_available())
-		cla = alloc_bootmem_low_pages(sizeof(*cla));
-	else
-		cla = kzalloc(sizeof(*cla), GFP_KERNEL);
-
-	if (!cla)
-		return NULL;
-
-	cla->cl.clk = clk;
-	if (con_id) {
-		strlcpy(cla->con_id, con_id, sizeof(cla->con_id));
-		cla->cl.con_id = cla->con_id;
-	}
-
-	if (dev_fmt) {
-		va_list ap;
-
-		va_start(ap, dev_fmt);
-		vscnprintf(cla->dev_id, sizeof(cla->dev_id), dev_fmt, ap);
-		cla->cl.dev_id = cla->dev_id;
-		va_end(ap);
-	}
-
-	return &cla->cl;
-}
-EXPORT_SYMBOL(clkdev_alloc);
-
-int clk_add_alias(const char *alias, const char *alias_dev_name, char *id,
-	struct device *dev)
-{
-	struct clk *r = clk_get(dev, id);
-	struct clk_lookup *l;
-
-	if (IS_ERR(r))
-		return PTR_ERR(r);
-
-	l = clkdev_alloc(r, alias, alias_dev_name);
-	clk_put(r);
-	if (!l)
-		return -ENODEV;
-	clkdev_add(l);
-	return 0;
-}
-EXPORT_SYMBOL(clk_add_alias);
-
-/*
- * clkdev_drop - remove a clock dynamically allocated
- */
-void clkdev_drop(struct clk_lookup *cl)
-{
-	mutex_lock(&clocks_mutex);
-	list_del(&cl->node);
-	mutex_unlock(&clocks_mutex);
-	kfree(cl);
-}
-EXPORT_SYMBOL(clkdev_drop);
diff --git a/arch/sh/kernel/cpu/clock-cpg.c b/arch/sh/kernel/cpu/clock-cpg.c
index e2f63d6..dd0e0f2 100644
--- a/arch/sh/kernel/cpu/clock-cpg.c
+++ b/arch/sh/kernel/cpu/clock-cpg.c
@@ -2,7 +2,7 @@
 #include <linux/compiler.h>
 #include <linux/slab.h>
 #include <linux/io.h>
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 #include <asm/clock.h>
 
 static struct clk master_clk = {
diff --git a/arch/sh/kernel/cpu/clock.c b/arch/sh/kernel/cpu/clock.c
index 50f887d..4187cf4 100644
--- a/arch/sh/kernel/cpu/clock.c
+++ b/arch/sh/kernel/cpu/clock.c
@@ -48,20 +48,4 @@ int __init clk_init(void)
 	return ret;
 }
 
-/*
- * Returns a clock. Note that we first try to use device id on the bus
- * and clock name. If this fails, we try to use clock name only.
- */
-struct clk *clk_get(struct device *dev, const char *con_id)
-{
-	const char *dev_id = dev ? dev_name(dev) : NULL;
-
-	return clk_get_sys(dev_id, con_id);
-}
-EXPORT_SYMBOL_GPL(clk_get);
-
-void clk_put(struct clk *clk)
-{
-}
-EXPORT_SYMBOL_GPL(clk_put);
 
diff --git a/arch/sh/kernel/cpu/sh4/clock-sh4-202.c b/arch/sh/kernel/cpu/sh4/clock-sh4-202.c
index 4eabc68..6c1492b 100644
--- a/arch/sh/kernel/cpu/sh4/clock-sh4-202.c
+++ b/arch/sh/kernel/cpu/sh4/clock-sh4-202.c
@@ -13,7 +13,7 @@
 #include <linux/kernel.h>
 #include <linux/err.h>
 #include <linux/io.h>
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 #include <asm/clock.h>
 #include <asm/freq.h>
 
diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7343.c b/arch/sh/kernel/cpu/sh4a/clock-sh7343.c
index 71291ae..93c6460 100644
--- a/arch/sh/kernel/cpu/sh4a/clock-sh7343.c
+++ b/arch/sh/kernel/cpu/sh4a/clock-sh7343.c
@@ -21,7 +21,7 @@
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/io.h>
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 #include <asm/clock.h>
 
 /* SH7343 registers */
diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7366.c b/arch/sh/kernel/cpu/sh4a/clock-sh7366.c
index 7ce5bbc..049dc06 100644
--- a/arch/sh/kernel/cpu/sh4a/clock-sh7366.c
+++ b/arch/sh/kernel/cpu/sh4a/clock-sh7366.c
@@ -21,7 +21,7 @@
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/io.h>
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 #include <asm/clock.h>
 
 /* SH7366 registers */
diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7722.c b/arch/sh/kernel/cpu/sh4a/clock-sh7722.c
index 2030f3d..9d23a36 100644
--- a/arch/sh/kernel/cpu/sh4a/clock-sh7722.c
+++ b/arch/sh/kernel/cpu/sh4a/clock-sh7722.c
@@ -21,7 +21,7 @@
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/io.h>
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 #include <asm/clock.h>
 #include <asm/hwblk.h>
 #include <cpu/sh7722.h>
diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7723.c b/arch/sh/kernel/cpu/sh4a/clock-sh7723.c
index d3938f0..55493cd 100644
--- a/arch/sh/kernel/cpu/sh4a/clock-sh7723.c
+++ b/arch/sh/kernel/cpu/sh4a/clock-sh7723.c
@@ -22,7 +22,7 @@
 #include <linux/kernel.h>
 #include <linux/io.h>
 #include <linux/clk.h>
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 #include <asm/clock.h>
 #include <asm/hwblk.h>
 #include <cpu/sh7723.h>
diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7724.c b/arch/sh/kernel/cpu/sh4a/clock-sh7724.c
index 2d9700c..527936b 100644
--- a/arch/sh/kernel/cpu/sh4a/clock-sh7724.c
+++ b/arch/sh/kernel/cpu/sh4a/clock-sh7724.c
@@ -22,7 +22,7 @@
 #include <linux/kernel.h>
 #include <linux/io.h>
 #include <linux/clk.h>
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 #include <asm/clock.h>
 #include <asm/hwblk.h>
 #include <cpu/sh7724.h>
diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7757.c b/arch/sh/kernel/cpu/sh4a/clock-sh7757.c
index 0a752bd..589ee0a 100644
--- a/arch/sh/kernel/cpu/sh4a/clock-sh7757.c
+++ b/arch/sh/kernel/cpu/sh4a/clock-sh7757.c
@@ -12,7 +12,7 @@
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/io.h>
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 #include <asm/clock.h>
 #include <asm/freq.h>
 
diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7763.c b/arch/sh/kernel/cpu/sh4a/clock-sh7763.c
index 1f1df48..599630f 100644
--- a/arch/sh/kernel/cpu/sh4a/clock-sh7763.c
+++ b/arch/sh/kernel/cpu/sh4a/clock-sh7763.c
@@ -13,7 +13,7 @@
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/io.h>
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 #include <asm/clock.h>
 #include <asm/freq.h>
 #include <asm/io.h>
diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7780.c b/arch/sh/kernel/cpu/sh4a/clock-sh7780.c
index 62d7063..8894926 100644
--- a/arch/sh/kernel/cpu/sh4a/clock-sh7780.c
+++ b/arch/sh/kernel/cpu/sh4a/clock-sh7780.c
@@ -12,7 +12,7 @@
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/io.h>
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 #include <asm/clock.h>
 #include <asm/freq.h>
 #include <asm/io.h>
diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7785.c b/arch/sh/kernel/cpu/sh4a/clock-sh7785.c
index c3e458a..2d96024 100644
--- a/arch/sh/kernel/cpu/sh4a/clock-sh7785.c
+++ b/arch/sh/kernel/cpu/sh4a/clock-sh7785.c
@@ -14,7 +14,7 @@
 #include <linux/clk.h>
 #include <linux/io.h>
 #include <linux/cpufreq.h>
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 #include <asm/clock.h>
 #include <asm/freq.h>
 #include <cpu/sh7785.h>
diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7786.c b/arch/sh/kernel/cpu/sh4a/clock-sh7786.c
index 597c9fb..42e403b 100644
--- a/arch/sh/kernel/cpu/sh4a/clock-sh7786.c
+++ b/arch/sh/kernel/cpu/sh4a/clock-sh7786.c
@@ -13,7 +13,7 @@
 #include <linux/kernel.h>
 #include <linux/clk.h>
 #include <linux/io.h>
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 #include <asm/clock.h>
 #include <asm/freq.h>
 
diff --git a/arch/sh/kernel/cpu/sh4a/clock-shx3.c b/arch/sh/kernel/cpu/sh4a/clock-shx3.c
index 236a628..228d7e6 100644
--- a/arch/sh/kernel/cpu/sh4a/clock-shx3.c
+++ b/arch/sh/kernel/cpu/sh4a/clock-shx3.c
@@ -14,7 +14,7 @@
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/io.h>
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 #include <asm/clock.h>
 #include <asm/freq.h>
 
diff --git a/drivers/Kconfig b/drivers/Kconfig
index a2b902f..3d93b3a 100644
--- a/drivers/Kconfig
+++ b/drivers/Kconfig
@@ -111,4 +111,6 @@ source "drivers/xen/Kconfig"
 source "drivers/staging/Kconfig"
 
 source "drivers/platform/Kconfig"
+
+source "drivers/clk/Kconfig"
 endmenu
diff --git a/drivers/Makefile b/drivers/Makefile
index ae47344..b0e30b2 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -115,3 +115,5 @@ obj-$(CONFIG_VLYNQ)		+= vlynq/
 obj-$(CONFIG_STAGING)		+= staging/
 obj-y				+= platform/
 obj-y				+= ieee802154/
+#common clk code
+obj-y				+= clk/
diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig
new file mode 100644
index 0000000..4168c88
--- /dev/null
+++ b/drivers/clk/Kconfig
@@ -0,0 +1,4 @@
+
+config CLKDEV_LOOKUP
+	bool
+	select HAVE_CLK
diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
new file mode 100644
index 0000000..07613fa
--- /dev/null
+++ b/drivers/clk/Makefile
@@ -0,0 +1,2 @@
+
+obj-$(CONFIG_CLKDEV_LOOKUP)	+= clkdev.o
diff --git a/arch/arm/common/clkdev.c b/drivers/clk/clkdev.c
similarity index 91%
rename from arch/arm/common/clkdev.c
rename to drivers/clk/clkdev.c
index e2b2bb6..d8b91ae 100644
--- a/arch/arm/common/clkdev.c
+++ b/drivers/clk/clkdev.c
@@ -1,5 +1,5 @@
 /*
- *  arch/arm/common/clkdev.c
+ * drivers/clk/clkdev.c
  *
  *  Copyright (C) 2008 Russell King.
  *
@@ -18,10 +18,7 @@
 #include <linux/string.h>
 #include <linux/mutex.h>
 #include <linux/clk.h>
-#include <linux/slab.h>
-
-#include <asm/clkdev.h>
-#include <mach/clkdev.h>
+#include <linux/clkdev.h>
 
 static LIST_HEAD(clocks);
 static DEFINE_MUTEX(clocks_mutex);
@@ -79,6 +76,10 @@ struct clk *clk_get_sys(const char *dev_id, const char *con_id)
 }
 EXPORT_SYMBOL(clk_get_sys);
 
+/*
+ * Returns a clock. Note that we first try to use device id on the bus
+ * and clock name. If this fails, we try to use clock name only.
+ */
 struct clk *clk_get(struct device *dev, const char *con_id)
 {
 	const char *dev_id = dev ? dev_name(dev) : NULL;
@@ -120,12 +121,12 @@ struct clk_lookup_alloc {
 	char	con_id[MAX_CON_ID];
 };
 
-struct clk_lookup *clkdev_alloc(struct clk *clk, const char *con_id,
-	const char *dev_fmt, ...)
+struct clk_lookup * __init_refok
+clkdev_alloc(struct clk *clk, const char *con_id, const char *dev_fmt, ...)
 {
 	struct clk_lookup_alloc *cla;
 
-	cla = kzalloc(sizeof(*cla), GFP_KERNEL);
+	cla = __clkdev_alloc(sizeof(*cla));
 	if (!cla)
 		return NULL;
 
diff --git a/arch/sh/include/asm/clkdev.h b/include/linux/clkdev.h
similarity index 85%
rename from arch/sh/include/asm/clkdev.h
rename to include/linux/clkdev.h
index 5645f35..bd2ec89 100644
--- a/arch/sh/include/asm/clkdev.h
+++ b/include/linux/clkdev.h
@@ -1,7 +1,5 @@
 /*
- *  arch/sh/include/asm/clkdev.h
- *
- * Cloned from arch/arm/include/asm/clkdev.h:
+ *  include/linux/clkdev.h
  *
  *  Copyright (C) 2008 Russell King.
  *
@@ -11,8 +9,10 @@
  *
  * Helper for the clk API to assist looking up a struct clk.
  */
-#ifndef __ASM_CLKDEV_H
-#define __ASM_CLKDEV_H
+#ifndef __CLKDEV_H
+#define __CLKDEV_H
+
+#include <asm/clkdev.h>
 
 struct clk;
 
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* Re: [RFC] [PATCH v2] arm & sh: factorised duplicated clkdev.c
  2010-09-02 12:48   ` Jean-Christophe PLAGNIOL-VILLARD
@ 2010-09-02 13:06     ` Russell King - ARM Linux
  -1 siblings, 0 replies; 133+ messages in thread
From: Russell King - ARM Linux @ 2010-09-02 13:06 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Sep 02, 2010 at 02:48:36PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> diff --git a/arch/arm/include/asm/clkdev.h b/arch/arm/include/asm/clkdev.h
> index b56c138..1293780 100644
> --- a/arch/arm/include/asm/clkdev.h
> +++ b/arch/arm/include/asm/clkdev.h
> @@ -1,5 +1,5 @@
>  /*
> - *  arch/arm/include/asm/clkdev.h
> + *  arch/arm/include/linux/clkdev.h

?

> +/*
> + * Returns a clock. Note that we first try to use device id on the bus
> + * and clock name. If this fails, we try to use clock name only.
> + */

This comment is actually wrong, and conflicts with the commentry against
clk_find(), which describes completely how clocks are found.  Therefore,
this comment should be deleted.

> diff --git a/arch/sh/include/asm/clkdev.h b/include/linux/clkdev.h
> similarity index 85%
> rename from arch/sh/include/asm/clkdev.h
> rename to include/linux/clkdev.h
> index 5645f35..bd2ec89 100644
> --- a/arch/sh/include/asm/clkdev.h
> +++ b/include/linux/clkdev.h
> @@ -1,7 +1,5 @@
>  /*
> - *  arch/sh/include/asm/clkdev.h
> - *
> - * Cloned from arch/arm/include/asm/clkdev.h:
> + *  include/linux/clkdev.h
>   *
>   *  Copyright (C) 2008 Russell King.
>   *
> @@ -11,8 +9,10 @@
>   *
>   * Helper for the clk API to assist looking up a struct clk.
>   */
> -#ifndef __ASM_CLKDEV_H
> -#define __ASM_CLKDEV_H
> +#ifndef __CLKDEV_H
> +#define __CLKDEV_H
> +
> +#include <asm/clkdev.h>
>  
>  struct clk;
>  

This should really be a clone of the ARM version of clkdev.h - the sh
version misses the predeclaration of 'struct device' which is required
for the function prototypes in this file.

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [RFC] [PATCH v2] arm & sh: factorised duplicated clkdev.c
@ 2010-09-02 13:06     ` Russell King - ARM Linux
  0 siblings, 0 replies; 133+ messages in thread
From: Russell King - ARM Linux @ 2010-09-02 13:06 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Sep 02, 2010 at 02:48:36PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> diff --git a/arch/arm/include/asm/clkdev.h b/arch/arm/include/asm/clkdev.h
> index b56c138..1293780 100644
> --- a/arch/arm/include/asm/clkdev.h
> +++ b/arch/arm/include/asm/clkdev.h
> @@ -1,5 +1,5 @@
>  /*
> - *  arch/arm/include/asm/clkdev.h
> + *  arch/arm/include/linux/clkdev.h

?

> +/*
> + * Returns a clock. Note that we first try to use device id on the bus
> + * and clock name. If this fails, we try to use clock name only.
> + */

This comment is actually wrong, and conflicts with the commentry against
clk_find(), which describes completely how clocks are found.  Therefore,
this comment should be deleted.

> diff --git a/arch/sh/include/asm/clkdev.h b/include/linux/clkdev.h
> similarity index 85%
> rename from arch/sh/include/asm/clkdev.h
> rename to include/linux/clkdev.h
> index 5645f35..bd2ec89 100644
> --- a/arch/sh/include/asm/clkdev.h
> +++ b/include/linux/clkdev.h
> @@ -1,7 +1,5 @@
>  /*
> - *  arch/sh/include/asm/clkdev.h
> - *
> - * Cloned from arch/arm/include/asm/clkdev.h:
> + *  include/linux/clkdev.h
>   *
>   *  Copyright (C) 2008 Russell King.
>   *
> @@ -11,8 +9,10 @@
>   *
>   * Helper for the clk API to assist looking up a struct clk.
>   */
> -#ifndef __ASM_CLKDEV_H
> -#define __ASM_CLKDEV_H
> +#ifndef __CLKDEV_H
> +#define __CLKDEV_H
> +
> +#include <asm/clkdev.h>
>  
>  struct clk;
>  

This should really be a clone of the ARM version of clkdev.h - the sh
version misses the predeclaration of 'struct device' which is required
for the function prototypes in this file.

^ permalink raw reply	[flat|nested] 133+ messages in thread

* Re: [RFC] [PATCH v2] arm & sh: factorised duplicated clkdev.c
  2010-09-02 12:48   ` Jean-Christophe PLAGNIOL-VILLARD
@ 2010-09-02 13:26     ` Uwe Kleine-König
  -1 siblings, 0 replies; 133+ messages in thread
From:  @ 2010-09-02 13:26 UTC (permalink / raw)
  To: linux-arm-kernel

Hello Jean,

On Thu, Sep 02, 2010 at 02:48:36PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> factorise some generic infrastructure to assist looking up struct clks
> for the ARM & SH architecture.
> 
> as the code is identical at 99%
> 
> put the arch specific code for allocation as example in asm/clkdev.h
> 
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> ---
> V2:
> 
> 	update base on Russel & Uwe Comments
s/Russel/Russell/ BTW.

> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
> index a7ed21f..1d8a26c 100644
> --- a/arch/arm/Kconfig
> +++ b/arch/arm/Kconfig
> @@ -221,7 +221,7 @@ config ARCH_INTEGRATOR
>  	bool "ARM Ltd. Integrator family"
>  	select ARM_AMBA
>  	select ARCH_HAS_CPUFREQ
> -	select COMMON_CLKDEV
> +	select CLKDEV_LOOKUP
>  	select ICST
>  	select GENERIC_CLOCKEVENTS
>  	select PLAT_VERSATILE
did you think about keeping the name COMMON_CLKDEV?

> @@ -231,7 +231,7 @@ config ARCH_INTEGRATOR
>  config ARCH_REALVIEW
>  	bool "ARM Ltd. RealView family"
>  	select ARM_AMBA
> -	select COMMON_CLKDEV
> +	select CLKDEV_LOOKUP
>  	select ICST
>  	select GENERIC_CLOCKEVENTS
>  	select ARCH_WANT_OPTIONAL_GPIOLIB
> @@ -245,7 +245,7 @@ config ARCH_VERSATILE
>  	bool "ARM Ltd. Versatile family"
>  	select ARM_AMBA
>  	select ARM_VIC
> -	select COMMON_CLKDEV
> +	select CLKDEV_LOOKUP
>  	select ICST
>  	select GENERIC_CLOCKEVENTS
>  	select ARCH_WANT_OPTIONAL_GPIOLIB
> @@ -259,7 +259,7 @@ config ARCH_VEXPRESS
>  	select ARCH_WANT_OPTIONAL_GPIOLIB
>  	select ARM_AMBA
>  	select ARM_TIMER_SP804
> -	select COMMON_CLKDEV
> +	select CLKDEV_LOOKUP
>  	select GENERIC_CLOCKEVENTS
>  	select HAVE_CLK
>  	select ICST
> @@ -281,7 +281,7 @@ config ARCH_BCMRING
>  	depends on MMU
>  	select CPU_V6
>  	select ARM_AMBA
> -	select COMMON_CLKDEV
> +	select CLKDEV_LOOKUP
>  	select GENERIC_CLOCKEVENTS
>  	select ARCH_WANT_OPTIONAL_GPIOLIB
>  	help
> @@ -328,7 +328,7 @@ config ARCH_EP93XX
>  	select CPU_ARM920T
>  	select ARM_AMBA
>  	select ARM_VIC
> -	select COMMON_CLKDEV
> +	select CLKDEV_LOOKUP
>  	select ARCH_REQUIRE_GPIOLIB
>  	select ARCH_HAS_HOLES_MEMORYMODEL
>  	select ARCH_USES_GETTIMEOFFSET
> @@ -348,14 +348,14 @@ config ARCH_MXC
>  	bool "Freescale MXC/iMX-based"
>  	select GENERIC_CLOCKEVENTS
>  	select ARCH_REQUIRE_GPIOLIB
> -	select COMMON_CLKDEV
> +	select CLKDEV_LOOKUP
>  	help
>  	  Support for Freescale MXC/iMX-based family of processors
>  
>  config ARCH_STMP3XXX
>  	bool "Freescale STMP3xxx"
>  	select CPU_ARM926T
> -	select COMMON_CLKDEV
> +	select CLKDEV_LOOKUP
>  	select ARCH_REQUIRE_GPIOLIB
>  	select GENERIC_CLOCKEVENTS
>  	select USB_ARCH_HAS_EHCI
> @@ -473,7 +473,7 @@ config ARCH_LPC32XX
>  	select HAVE_IDE
>  	select ARM_AMBA
>  	select USB_ARCH_HAS_OHCI
> -	select COMMON_CLKDEV
> +	select CLKDEV_LOOKUP
>  	select GENERIC_TIME
>  	select GENERIC_CLOCKEVENTS
>  	help
> @@ -507,7 +507,7 @@ config ARCH_MMP
>  	bool "Marvell PXA168/910/MMP2"
>  	depends on MMU
>  	select ARCH_REQUIRE_GPIOLIB
> -	select COMMON_CLKDEV
> +	select CLKDEV_LOOKUP
>  	select GENERIC_CLOCKEVENTS
>  	select TICK_ONESHOT
>  	select PLAT_PXA
> @@ -539,7 +539,7 @@ config ARCH_W90X900
>  	bool "Nuvoton W90X900 CPU"
>  	select CPU_ARM926T
>  	select ARCH_REQUIRE_GPIOLIB
> -	select COMMON_CLKDEV
> +	select CLKDEV_LOOKUP
>  	select GENERIC_CLOCKEVENTS
>  	help
>  	  Support for Nuvoton (Winbond logic dept.) ARM9 processor,
> @@ -553,7 +553,7 @@ config ARCH_W90X900
>  config ARCH_NUC93X
>  	bool "Nuvoton NUC93X CPU"
>  	select CPU_ARM926T
> -	select COMMON_CLKDEV
> +	select CLKDEV_LOOKUP
>  	help
>  	  Support for Nuvoton (Winbond logic dept.) NUC93X MCU,The NUC93X is a
>  	  low-power and high performance MPEG-4/JPEG multimedia controller chip.
> @@ -564,7 +564,7 @@ config ARCH_TEGRA
>  	select GENERIC_CLOCKEVENTS
>  	select GENERIC_GPIO
>  	select HAVE_CLK
> -	select COMMON_CLKDEV
> +	select CLKDEV_LOOKUP
>  	select ARCH_HAS_BARRIERS if CACHE_L2X0
>  	help
>  	  This enables support for NVIDIA Tegra based systems (Tegra APX,
> @@ -573,7 +573,7 @@ config ARCH_TEGRA
>  config ARCH_PNX4008
>  	bool "Philips Nexperia PNX4008 Mobile"
>  	select CPU_ARM926T
> -	select COMMON_CLKDEV
> +	select CLKDEV_LOOKUP
>  	select ARCH_USES_GETTIMEOFFSET
>  	help
>  	  This enables support for Philips PNX4008 mobile platform.
> @@ -583,7 +583,7 @@ config ARCH_PXA
>  	depends on MMU
>  	select ARCH_MTD_XIP
>  	select ARCH_HAS_CPUFREQ
> -	select COMMON_CLKDEV
> +	select CLKDEV_LOOKUP
>  	select ARCH_REQUIRE_GPIOLIB
>  	select GENERIC_CLOCKEVENTS
>  	select TICK_ONESHOT
> @@ -767,7 +767,7 @@ config ARCH_U300
>  	select ARM_AMBA
>  	select ARM_VIC
>  	select GENERIC_CLOCKEVENTS
> -	select COMMON_CLKDEV
> +	select CLKDEV_LOOKUP
>  	select GENERIC_GPIO
>  	help
>  	  Support for ST-Ericsson U300 series mobile platforms.
> @@ -777,7 +777,7 @@ config ARCH_U8500
>  	select CPU_V7
>  	select ARM_AMBA
>  	select GENERIC_CLOCKEVENTS
> -	select COMMON_CLKDEV
> +	select CLKDEV_LOOKUP
>  	select ARCH_REQUIRE_GPIOLIB
>  	help
>  	  Support for ST-Ericsson's Ux500 architecture
> @@ -787,7 +787,7 @@ config ARCH_NOMADIK
>  	select ARM_AMBA
>  	select ARM_VIC
>  	select CPU_ARM926T
> -	select COMMON_CLKDEV
> +	select CLKDEV_LOOKUP
>  	select GENERIC_CLOCKEVENTS
>  	select ARCH_REQUIRE_GPIOLIB
>  	help
> @@ -799,7 +799,7 @@ config ARCH_DAVINCI
>  	select ARCH_REQUIRE_GPIOLIB
>  	select ZONE_DMA
>  	select HAVE_IDE
> -	select COMMON_CLKDEV
> +	select CLKDEV_LOOKUP
>  	select GENERIC_ALLOCATOR
>  	select ARCH_HAS_HOLES_MEMORYMODEL
>  	help
> @@ -819,7 +819,7 @@ config PLAT_SPEAR
>  	bool "ST SPEAr"
>  	select ARM_AMBA
>  	select ARCH_REQUIRE_GPIOLIB
> -	select COMMON_CLKDEV
> +	select CLKDEV_LOOKUP
>  	select GENERIC_CLOCKEVENTS
>  	select HAVE_CLK
>  	help
> diff --git a/arch/arm/common/Kconfig b/arch/arm/common/Kconfig
> index 0a34c81..778655f 100644
> --- a/arch/arm/common/Kconfig
> +++ b/arch/arm/common/Kconfig
> @@ -37,7 +37,3 @@ config SHARP_PARAM
>  
>  config SHARP_SCOOP
>  	bool
> -
> -config COMMON_CLKDEV
> -	bool
> -	select HAVE_CLK
> diff --git a/arch/arm/common/Makefile b/arch/arm/common/Makefile
> index e6e8664..799e140 100644
> --- a/arch/arm/common/Makefile
> +++ b/arch/arm/common/Makefile
> @@ -16,4 +16,3 @@ obj-$(CONFIG_SHARP_SCOOP)	+= scoop.o
>  obj-$(CONFIG_ARCH_IXP2000)	+= uengine.o
>  obj-$(CONFIG_ARCH_IXP23XX)	+= uengine.o
>  obj-$(CONFIG_PCI_HOST_ITE8152)  += it8152.o
> -obj-$(CONFIG_COMMON_CLKDEV)	+= clkdev.o
> diff --git a/arch/arm/include/asm/clkdev.h b/arch/arm/include/asm/clkdev.h
> index b56c138..1293780 100644
> --- a/arch/arm/include/asm/clkdev.h
> +++ b/arch/arm/include/asm/clkdev.h
> @@ -1,5 +1,5 @@
>  /*
> - *  arch/arm/include/asm/clkdev.h
> + *  arch/arm/include/linux/clkdev.h
??, arch/arm/include/asm/clkdev.h was correct, no?

>   *
>   *  Copyright (C) 2008 Russell King.
>   *
> @@ -12,23 +12,13 @@
>  #ifndef __ASM_CLKDEV_H
>  #define __ASM_CLKDEV_H
>  
> -struct clk;
> -struct device;
> +#include <linux/slab.h>
>  
> -struct clk_lookup {
> -	struct list_head	node;
> -	const char		*dev_id;
> -	const char		*con_id;
> -	struct clk		*clk;
> -};
> +#include <mach/clkdev.h>
>  
> -struct clk_lookup *clkdev_alloc(struct clk *clk, const char *con_id,
> -	const char *dev_fmt, ...);
> -
> -void clkdev_add(struct clk_lookup *cl);
> -void clkdev_drop(struct clk_lookup *cl);
> -
> -void clkdev_add_table(struct clk_lookup *, size_t);
> -int clk_add_alias(const char *, const char *, char *, struct device *);
> +static inline struct clk_lookup_alloc *__clkdev_alloc(size_t size)
> +{
> +	return kzalloc(size, GFP_KERNEL);
> +}
>  
>  #endif
> diff --git a/arch/arm/mach-bcmring/clock.c b/arch/arm/mach-bcmring/clock.c
> index 14bafc3..ad237a4 100644
> --- a/arch/arm/mach-bcmring/clock.c
> +++ b/arch/arm/mach-bcmring/clock.c
> @@ -21,13 +21,12 @@
>  #include <linux/string.h>
>  #include <linux/clk.h>
>  #include <linux/spinlock.h>
> +#include <linux/clkdev.h>
>  #include <mach/csp/hw_cfg.h>
>  #include <mach/csp/chipcHw_def.h>
>  #include <mach/csp/chipcHw_reg.h>
>  #include <mach/csp/chipcHw_inline.h>
>  
> -#include <asm/clkdev.h>
> -
>  #include "clock.h"
>  
>  #define clk_is_primary(x)       ((x)->type & CLK_TYPE_PRIMARY)
> diff --git a/arch/arm/mach-bcmring/core.c b/arch/arm/mach-bcmring/core.c
> index d3f959e..ed96ef4 100644
> --- a/arch/arm/mach-bcmring/core.c
> +++ b/arch/arm/mach-bcmring/core.c
> @@ -30,10 +30,10 @@
>  #include <linux/amba/bus.h>
>  #include <linux/clocksource.h>
>  #include <linux/clockchips.h>
> +#include <linux/clkdev.h>
>  
>  #include <mach/csp/mm_addr.h>
>  #include <mach/hardware.h>
> -#include <asm/clkdev.h>
>  #include <linux/io.h>
>  #include <asm/irq.h>
>  #include <asm/hardware/arm_timer.h>
> diff --git a/arch/arm/mach-davinci/clock.h b/arch/arm/mach-davinci/clock.h
> index 01e3648..64c58ad 100644
> --- a/arch/arm/mach-davinci/clock.h
> +++ b/arch/arm/mach-davinci/clock.h
> @@ -68,7 +68,7 @@
>  #ifndef __ASSEMBLER__
>  
>  #include <linux/list.h>
> -#include <asm/clkdev.h>
> +#include <linux/clkdev.h>
>  
>  struct pll_data {
>  	u32 phys_base;
> diff --git a/arch/arm/mach-ep93xx/clock.c b/arch/arm/mach-ep93xx/clock.c
> index 8bf3cec..f60d636 100644
> --- a/arch/arm/mach-ep93xx/clock.c
> +++ b/arch/arm/mach-ep93xx/clock.c
> @@ -19,10 +19,10 @@
>  #include <linux/string.h>
>  #include <linux/io.h>
>  #include <linux/spinlock.h>
> +#include <linux/clkdev.h>
>  
>  #include <mach/hardware.h>
>  
> -#include <asm/clkdev.h>
>  #include <asm/div64.h>
>  
>  
> diff --git a/arch/arm/mach-imx/clock-imx1.c b/arch/arm/mach-imx/clock-imx1.c
> index c05096c..9c848d9 100644
> --- a/arch/arm/mach-imx/clock-imx1.c
> +++ b/arch/arm/mach-imx/clock-imx1.c
> @@ -22,8 +22,7 @@
>  #include <linux/err.h>
>  #include <linux/clk.h>
>  #include <linux/io.h>
> -
> -#include <asm/clkdev.h>
> +#include <linux/clkdev.h>
>  
>  #include <mach/clock.h>
>  #include <mach/hardware.h>
> diff --git a/arch/arm/mach-imx/clock-imx21.c b/arch/arm/mach-imx/clock-imx21.c
> index bb419ef..19e966e 100644
> --- a/arch/arm/mach-imx/clock-imx21.c
> +++ b/arch/arm/mach-imx/clock-imx21.c
> @@ -21,11 +21,11 @@
>  #include <linux/clk.h>
>  #include <linux/io.h>
>  #include <linux/module.h>
> +#include <linux/clkdev.h>
>  
>  #include <mach/clock.h>
>  #include <mach/hardware.h>
>  #include <mach/common.h>
> -#include <asm/clkdev.h>
>  #include <asm/div64.h>
>  
>  #define IO_ADDR_CCM(off)	(MX21_IO_ADDRESS(MX21_CCM_BASE_ADDR + (off)))
> diff --git a/arch/arm/mach-imx/clock-imx27.c b/arch/arm/mach-imx/clock-imx27.c
> index 5a1aa15..f121114 100644
> --- a/arch/arm/mach-imx/clock-imx27.c
> +++ b/arch/arm/mach-imx/clock-imx27.c
> @@ -21,8 +21,8 @@
>  #include <linux/clk.h>
>  #include <linux/io.h>
>  #include <linux/module.h>
> +#include <linux/clkdev.h>
>  
> -#include <asm/clkdev.h>
>  #include <asm/div64.h>
>  
>  #include <mach/clock.h>
> diff --git a/arch/arm/mach-integrator/core.c b/arch/arm/mach-integrator/core.c
> index 8f4fb6d..b8e884b 100644
> --- a/arch/arm/mach-integrator/core.c
> +++ b/arch/arm/mach-integrator/core.c
> @@ -21,9 +21,8 @@
>  #include <linux/amba/bus.h>
>  #include <linux/amba/serial.h>
>  #include <linux/io.h>
> +#include <linux/clkdev.h>
>  
> -#include <asm/clkdev.h>
> -#include <mach/clkdev.h>
>  #include <mach/hardware.h>
>  #include <mach/platform.h>
>  #include <asm/irq.h>
> diff --git a/arch/arm/mach-integrator/impd1.c b/arch/arm/mach-integrator/impd1.c
> index fd684bf..5db574f 100644
> --- a/arch/arm/mach-integrator/impd1.c
> +++ b/arch/arm/mach-integrator/impd1.c
> @@ -22,9 +22,8 @@
>  #include <linux/amba/clcd.h>
>  #include <linux/io.h>
>  #include <linux/slab.h>
> +#include <linux/clkdev.h>
>  
> -#include <asm/clkdev.h>
> -#include <mach/clkdev.h>
>  #include <asm/hardware/icst.h>
>  #include <mach/lm.h>
>  #include <mach/impd1.h>
> diff --git a/arch/arm/mach-integrator/integrator_cp.c b/arch/arm/mach-integrator/integrator_cp.c
> index 05db40e..fce64fc 100644
> --- a/arch/arm/mach-integrator/integrator_cp.c
> +++ b/arch/arm/mach-integrator/integrator_cp.c
> @@ -21,9 +21,8 @@
>  #include <linux/amba/mmci.h>
>  #include <linux/io.h>
>  #include <linux/gfp.h>
> +#include <linux/clkdev.h>
>  
> -#include <asm/clkdev.h>
> -#include <mach/clkdev.h>
>  #include <mach/hardware.h>
>  #include <mach/platform.h>
>  #include <asm/irq.h>
> diff --git a/arch/arm/mach-lpc32xx/clock.c b/arch/arm/mach-lpc32xx/clock.c
> index 32d6379..da0e649 100644
> --- a/arch/arm/mach-lpc32xx/clock.c
> +++ b/arch/arm/mach-lpc32xx/clock.c
> @@ -90,10 +90,9 @@
>  #include <linux/clk.h>
>  #include <linux/amba/bus.h>
>  #include <linux/amba/clcd.h>
> +#include <linux/clkdev.h>
>  
>  #include <mach/hardware.h>
> -#include <asm/clkdev.h>
> -#include <mach/clkdev.h>
>  #include <mach/platform.h>
>  #include "clock.h"
>  #include "common.h"
> diff --git a/arch/arm/mach-mmp/clock.h b/arch/arm/mach-mmp/clock.h
> index 016ae94..9b027d7 100644
> --- a/arch/arm/mach-mmp/clock.h
> +++ b/arch/arm/mach-mmp/clock.h
> @@ -6,7 +6,7 @@
>   *  published by the Free Software Foundation.
>   */
>  
> -#include <asm/clkdev.h>
> +#include <linux/clkdev.h>
>  
>  struct clkops {
>  	void			(*enable)(struct clk *);
> diff --git a/arch/arm/mach-mx25/clock.c b/arch/arm/mach-mx25/clock.c
> index 40c7cc4..b3196bb 100644
> --- a/arch/arm/mach-mx25/clock.c
> +++ b/arch/arm/mach-mx25/clock.c
> @@ -21,8 +21,7 @@
>  #include <linux/list.h>
>  #include <linux/clk.h>
>  #include <linux/io.h>
> -
> -#include <asm/clkdev.h>
> +#include <linux/clkdev.h>
>  
>  #include <mach/clock.h>
>  #include <mach/hardware.h>
> diff --git a/arch/arm/mach-mx3/clock-imx31.c b/arch/arm/mach-mx3/clock-imx31.c
> index 9a9eb6d..2ba7094 100644
> --- a/arch/arm/mach-mx3/clock-imx31.c
> +++ b/arch/arm/mach-mx3/clock-imx31.c
> @@ -23,8 +23,8 @@
>  #include <linux/clk.h>
>  #include <linux/err.h>
>  #include <linux/io.h>
> +#include <linux/clkdev.h>
>  
> -#include <asm/clkdev.h>
>  #include <asm/div64.h>
>  
>  #include <mach/clock.h>
> diff --git a/arch/arm/mach-mx3/clock-imx35.c b/arch/arm/mach-mx3/clock-imx35.c
> index d3af0fd..2d17c03 100644
> --- a/arch/arm/mach-mx3/clock-imx35.c
> +++ b/arch/arm/mach-mx3/clock-imx35.c
> @@ -21,8 +21,7 @@
>  #include <linux/list.h>
>  #include <linux/clk.h>
>  #include <linux/io.h>
> -
> -#include <asm/clkdev.h>
> +#include <linux/clkdev.h>
>  
>  #include <mach/clock.h>
>  #include <mach/hardware.h>
> diff --git a/arch/arm/mach-mx5/clock-mx51.c b/arch/arm/mach-mx5/clock-mx51.c
> index 6af69de..e599b6d 100644
> --- a/arch/arm/mach-mx5/clock-mx51.c
> +++ b/arch/arm/mach-mx5/clock-mx51.c
> @@ -14,8 +14,8 @@
>  #include <linux/delay.h>
>  #include <linux/clk.h>
>  #include <linux/io.h>
> +#include <linux/clkdev.h>
>  
> -#include <asm/clkdev.h>
>  #include <asm/div64.h>
>  
>  #include <mach/hardware.h>
> diff --git a/arch/arm/mach-mxc91231/clock.c b/arch/arm/mach-mxc91231/clock.c
> index 5c85075..9fab505 100644
> --- a/arch/arm/mach-mxc91231/clock.c
> +++ b/arch/arm/mach-mxc91231/clock.c
> @@ -2,12 +2,12 @@
>  #include <linux/kernel.h>
>  #include <linux/init.h>
>  #include <linux/io.h>
> +#include <linux/clkdev.h>
>  
>  #include <mach/clock.h>
>  #include <mach/hardware.h>
>  #include <mach/common.h>
>  
> -#include <asm/clkdev.h>
>  #include <asm/bug.h>
>  #include <asm/div64.h>
>  
> diff --git a/arch/arm/mach-nomadik/clock.c b/arch/arm/mach-nomadik/clock.c
> index 89f793a..48a59f2 100644
> --- a/arch/arm/mach-nomadik/clock.c
> +++ b/arch/arm/mach-nomadik/clock.c
> @@ -7,7 +7,7 @@
>  #include <linux/module.h>
>  #include <linux/errno.h>
>  #include <linux/clk.h>
> -#include <asm/clkdev.h>
> +#include <linux/clkdev.h>
>  #include "clock.h"
>  
>  /*
> diff --git a/arch/arm/mach-nuc93x/clock.h b/arch/arm/mach-nuc93x/clock.h
> index 18e51be..4de1f1d 100644
> --- a/arch/arm/mach-nuc93x/clock.h
> +++ b/arch/arm/mach-nuc93x/clock.h
> @@ -10,7 +10,7 @@
>   * the Free Software Foundation; either version 2 of the License.
>   */
>  
> -#include <asm/clkdev.h>
> +#include <linux/clkdev.h>
>  
>  void nuc93x_clk_enable(struct clk *clk, int enable);
>  void clks_register(struct clk_lookup *clks, size_t num);
> diff --git a/arch/arm/mach-omap1/clock.c b/arch/arm/mach-omap1/clock.c
> index b8c7fb9..84ef704 100644
> --- a/arch/arm/mach-omap1/clock.c
> +++ b/arch/arm/mach-omap1/clock.c
> @@ -17,9 +17,9 @@
>  #include <linux/err.h>
>  #include <linux/clk.h>
>  #include <linux/io.h>
> +#include <linux/clkdev.h>
>  
>  #include <asm/mach-types.h>
> -#include <asm/clkdev.h>
>  
>  #include <plat/cpu.h>
>  #include <plat/usb.h>
> diff --git a/arch/arm/mach-omap2/dpll3xxx.c b/arch/arm/mach-omap2/dpll3xxx.c
> index ed8d330..ebb888f 100644
> --- a/arch/arm/mach-omap2/dpll3xxx.c
> +++ b/arch/arm/mach-omap2/dpll3xxx.c
> @@ -26,10 +26,10 @@
>  #include <linux/clk.h>
>  #include <linux/io.h>
>  #include <linux/bitops.h>
> +#include <linux/clkdev.h>
>  
>  #include <plat/cpu.h>
>  #include <plat/clock.h>
> -#include <asm/clkdev.h>
>  
>  #include "clock.h"
>  #include "prm.h"
> diff --git a/arch/arm/mach-pnx4008/clock.c b/arch/arm/mach-pnx4008/clock.c
> index 9d1975f..a4a3819 100644
> --- a/arch/arm/mach-pnx4008/clock.c
> +++ b/arch/arm/mach-pnx4008/clock.c
> @@ -21,8 +21,7 @@
>  #include <linux/err.h>
>  #include <linux/delay.h>
>  #include <linux/io.h>
> -
> -#include <asm/clkdev.h>
> +#include <linux/clkdev.h>
>  
>  #include <mach/hardware.h>
>  #include <mach/clock.h>
> diff --git a/arch/arm/mach-pxa/clock.c b/arch/arm/mach-pxa/clock.c
> index abba008..4e4a84b 100644
> --- a/arch/arm/mach-pxa/clock.c
> +++ b/arch/arm/mach-pxa/clock.c
> @@ -11,8 +11,8 @@
>  #include <linux/spinlock.h>
>  #include <linux/platform_device.h>
>  #include <linux/delay.h>
> +#include <linux/clkdev.h>
>  
> -#include <asm/clkdev.h>
>  #include <mach/pxa2xx-regs.h>
>  #include <mach/hardware.h>
>  
> diff --git a/arch/arm/mach-pxa/clock.h b/arch/arm/mach-pxa/clock.h
> index d848874..12cc0e8 100644
> --- a/arch/arm/mach-pxa/clock.h
> +++ b/arch/arm/mach-pxa/clock.h
> @@ -1,4 +1,4 @@
> -#include <asm/clkdev.h>
> +#include <linux/clkdev.h>
>  
>  struct clkops {
>  	void			(*enable)(struct clk *);
> diff --git a/arch/arm/mach-realview/core.c b/arch/arm/mach-realview/core.c
> index 2fa38df..cda8b04 100644
> --- a/arch/arm/mach-realview/core.c
> +++ b/arch/arm/mach-realview/core.c
> @@ -30,8 +30,8 @@
>  #include <linux/ata_platform.h>
>  #include <linux/amba/mmci.h>
>  #include <linux/gfp.h>
> +#include <linux/clkdev.h>
>  
> -#include <asm/clkdev.h>
>  #include <asm/system.h>
>  #include <mach/hardware.h>
>  #include <asm/irq.h>
> @@ -47,7 +47,6 @@
>  
>  #include <asm/hardware/gic.h>
>  
> -#include <mach/clkdev.h>
>  #include <mach/platform.h>
>  #include <mach/irqs.h>
>  #include <plat/timer-sp.h>
> diff --git a/arch/arm/mach-shmobile/Kconfig b/arch/arm/mach-shmobile/Kconfig
> index 54b479c..f8f06e9 100644
> --- a/arch/arm/mach-shmobile/Kconfig
> +++ b/arch/arm/mach-shmobile/Kconfig
> @@ -6,7 +6,7 @@ config ARCH_SH7367
>  	bool "SH-Mobile G3 (SH7367)"
>  	select CPU_V6
>  	select HAVE_CLK
> -	select COMMON_CLKDEV
> +	select CLKDEV_LOOKUP
>  	select SH_CLK_CPG
>  	select GENERIC_CLOCKEVENTS
>  
> @@ -14,7 +14,7 @@ config ARCH_SH7377
>  	bool "SH-Mobile G4 (SH7377)"
>  	select CPU_V7
>  	select HAVE_CLK
> -	select COMMON_CLKDEV
> +	select CLKDEV_LOOKUP
>  	select SH_CLK_CPG
>  	select GENERIC_CLOCKEVENTS
>  
> @@ -22,7 +22,7 @@ config ARCH_SH7372
>  	bool "SH-Mobile AP4 (SH7372)"
>  	select CPU_V7
>  	select HAVE_CLK
> -	select COMMON_CLKDEV
> +	select CLKDEV_LOOKUP
>  	select SH_CLK_CPG
>  	select GENERIC_CLOCKEVENTS
>  
> diff --git a/arch/arm/mach-shmobile/clock-sh7367.c b/arch/arm/mach-shmobile/clock-sh7367.c
> index b6454c9..3030935 100644
> --- a/arch/arm/mach-shmobile/clock-sh7367.c
> +++ b/arch/arm/mach-shmobile/clock-sh7367.c
> @@ -20,8 +20,8 @@
>  #include <linux/kernel.h>
>  #include <linux/io.h>
>  #include <linux/sh_clk.h>
> +#include <linux/clkdev.h>
>  #include <mach/common.h>
> -#include <asm/clkdev.h>
>  
>  /* SH7367 registers */
>  #define RTFRQCR    0xe6150000
> diff --git a/arch/arm/mach-shmobile/clock-sh7372.c b/arch/arm/mach-shmobile/clock-sh7372.c
> index fb4e9b1..907f46d 100644
> --- a/arch/arm/mach-shmobile/clock-sh7372.c
> +++ b/arch/arm/mach-shmobile/clock-sh7372.c
> @@ -20,8 +20,8 @@
>  #include <linux/kernel.h>
>  #include <linux/io.h>
>  #include <linux/sh_clk.h>
> +#include <linux/clkdev.h>
>  #include <mach/common.h>
> -#include <asm/clkdev.h>
>  
>  /* SH7372 registers */
>  #define FRQCRA		0xe6150000
> diff --git a/arch/arm/mach-shmobile/clock-sh7377.c b/arch/arm/mach-shmobile/clock-sh7377.c
> index e007c28..a322c9b 100644
> --- a/arch/arm/mach-shmobile/clock-sh7377.c
> +++ b/arch/arm/mach-shmobile/clock-sh7377.c
> @@ -20,8 +20,8 @@
>  #include <linux/kernel.h>
>  #include <linux/io.h>
>  #include <linux/sh_clk.h>
> +#include <linux/clkdev.h>
>  #include <mach/common.h>
> -#include <asm/clkdev.h>
>  
>  /* SH7377 registers */
>  #define RTFRQCR    0xe6150000
> diff --git a/arch/arm/mach-tegra/clock.c b/arch/arm/mach-tegra/clock.c
> index 03ad578..cad740c 100644
> --- a/arch/arm/mach-tegra/clock.c
> +++ b/arch/arm/mach-tegra/clock.c
> @@ -24,7 +24,7 @@
>  #include <linux/debugfs.h>
>  #include <linux/slab.h>
>  #include <linux/seq_file.h>
> -#include <asm/clkdev.h>
> +#include <linux/clkdev.h>
>  
>  #include "clock.h"
>  
> diff --git a/arch/arm/mach-tegra/clock.h b/arch/arm/mach-tegra/clock.h
> index af7c70e..39a87e7 100644
> --- a/arch/arm/mach-tegra/clock.h
> +++ b/arch/arm/mach-tegra/clock.h
> @@ -21,7 +21,7 @@
>  #define __MACH_TEGRA_CLOCK_H
>  
>  #include <linux/list.h>
> -#include <asm/clkdev.h>
> +#include <linux/clkdev.h>
>  
>  #define DIV_BUS			(1 << 0)
>  #define DIV_U71			(1 << 1)
> diff --git a/arch/arm/mach-tegra/tegra2_clocks.c b/arch/arm/mach-tegra/tegra2_clocks.c
> index 4261632..d2cecbf 100644
> --- a/arch/arm/mach-tegra/tegra2_clocks.c
> +++ b/arch/arm/mach-tegra/tegra2_clocks.c
> @@ -24,8 +24,7 @@
>  #include <linux/delay.h>
>  #include <linux/io.h>
>  #include <linux/hrtimer.h>
> -
> -#include <asm/clkdev.h>
> +#include <linux/clkdev.h>
>  
>  #include <mach/iomap.h>
>  
> diff --git a/arch/arm/mach-u300/clock.c b/arch/arm/mach-u300/clock.c
> index 60acf9e..cb3ab08 100644
> --- a/arch/arm/mach-u300/clock.c
> +++ b/arch/arm/mach-u300/clock.c
> @@ -25,8 +25,8 @@
>  #include <linux/timer.h>
>  #include <linux/io.h>
>  #include <linux/seq_file.h>
> +#include <linux/clkdev.h>
>  
> -#include <asm/clkdev.h>
>  #include <mach/hardware.h>
>  #include <mach/syscon.h>
>  
> diff --git a/arch/arm/mach-ux500/clock.c b/arch/arm/mach-ux500/clock.c
> index d8ab7f1..df238ab 100644
> --- a/arch/arm/mach-ux500/clock.c
> +++ b/arch/arm/mach-ux500/clock.c
> @@ -13,8 +13,7 @@
>  #include <linux/err.h>
>  #include <linux/clk.h>
>  #include <linux/io.h>
> -
> -#include <asm/clkdev.h>
> +#include <linux/clkdev.h>
>  
>  #include <plat/mtu.h>
>  #include <mach/hardware.h>
> diff --git a/arch/arm/mach-versatile/core.c b/arch/arm/mach-versatile/core.c
> index e38acb0..8c1ca1d 100644
> --- a/arch/arm/mach-versatile/core.c
> +++ b/arch/arm/mach-versatile/core.c
> @@ -31,8 +31,8 @@
>  #include <linux/amba/pl022.h>
>  #include <linux/io.h>
>  #include <linux/gfp.h>
> +#include <linux/clkdev.h>
>  
> -#include <asm/clkdev.h>
>  #include <asm/system.h>
>  #include <asm/irq.h>
>  #include <asm/leds.h>
> @@ -46,7 +46,6 @@
>  #include <asm/mach/irq.h>
>  #include <asm/mach/time.h>
>  #include <asm/mach/map.h>
> -#include <mach/clkdev.h>
>  #include <mach/hardware.h>
>  #include <mach/platform.h>
>  #include <plat/timer-sp.h>
> diff --git a/arch/arm/mach-vexpress/ct-ca9x4.c b/arch/arm/mach-vexpress/ct-ca9x4.c
> index 577df6c..fb94f30 100644
> --- a/arch/arm/mach-vexpress/ct-ca9x4.c
> +++ b/arch/arm/mach-vexpress/ct-ca9x4.c
> @@ -8,8 +8,8 @@
>  #include <linux/platform_device.h>
>  #include <linux/amba/bus.h>
>  #include <linux/amba/clcd.h>
> +#include <linux/clkdev.h>
>  
> -#include <asm/clkdev.h>
>  #include <asm/pgtable.h>
>  #include <asm/hardware/arm_timer.h>
>  #include <asm/hardware/cache-l2x0.h>
> @@ -18,7 +18,6 @@
>  #include <asm/pmu.h>
>  #include <asm/smp_twd.h>
>  
> -#include <mach/clkdev.h>
>  #include <mach/ct-ca9x4.h>
>  
>  #include <plat/timer-sp.h>
> diff --git a/arch/arm/mach-vexpress/v2m.c b/arch/arm/mach-vexpress/v2m.c
> index 817f0ad..919103d 100644
> --- a/arch/arm/mach-vexpress/v2m.c
> +++ b/arch/arm/mach-vexpress/v2m.c
> @@ -11,15 +11,14 @@
>  #include <linux/spinlock.h>
>  #include <linux/sysdev.h>
>  #include <linux/usb/isp1760.h>
> +#include <linux/clkdev.h>
>  
> -#include <asm/clkdev.h>
>  #include <asm/sizes.h>
>  #include <asm/mach/flash.h>
>  #include <asm/mach/map.h>
>  #include <asm/mach/time.h>
>  #include <asm/hardware/arm_timer.h>
>  
> -#include <mach/clkdev.h>
>  #include <mach/motherboard.h>
>  
>  #include <plat/timer-sp.h>
> diff --git a/arch/arm/mach-w90x900/clock.h b/arch/arm/mach-w90x900/clock.h
> index c56ddab..b88a1b1 100644
> --- a/arch/arm/mach-w90x900/clock.h
> +++ b/arch/arm/mach-w90x900/clock.h
> @@ -10,7 +10,7 @@
>   * the Free Software Foundation; either version 2 of the License.
>   */
>  
> -#include <asm/clkdev.h>
> +#include <linux/clkdev.h>
>  
>  void nuc900_clk_enable(struct clk *clk, int enable);
>  void nuc900_subclk_enable(struct clk *clk, int enable);
> diff --git a/arch/arm/plat-omap/Kconfig b/arch/arm/plat-omap/Kconfig
> index e39a417..271d7b8 100644
> --- a/arch/arm/plat-omap/Kconfig
> +++ b/arch/arm/plat-omap/Kconfig
> @@ -11,13 +11,13 @@ choice
>  
>  config ARCH_OMAP1
>  	bool "TI OMAP1"
> -	select COMMON_CLKDEV
> +	select CLKDEV_LOOKUP
>  	help
>  	  "Systems based on omap7xx, omap15xx or omap16xx"
>  
>  config ARCH_OMAP2PLUS
>  	bool "TI OMAP2/3/4"
> -	select COMMON_CLKDEV
> +	select CLKDEV_LOOKUP
>  	help
>  	  "Systems based on omap24xx, omap34xx or omap44xx"
>  
> diff --git a/arch/arm/plat-omap/include/plat/clkdev_omap.h b/arch/arm/plat-omap/include/plat/clkdev_omap.h
> index bb937f3..4b2028a 100644
> --- a/arch/arm/plat-omap/include/plat/clkdev_omap.h
> +++ b/arch/arm/plat-omap/include/plat/clkdev_omap.h
> @@ -8,7 +8,7 @@
>  #ifndef __ARCH_ARM_PLAT_OMAP_INCLUDE_PLAT_CLKDEV_OMAP_H
>  #define __ARCH_ARM_PLAT_OMAP_INCLUDE_PLAT_CLKDEV_OMAP_H
>  
> -#include <asm/clkdev.h>
> +#include <linux/clkdev.h>
>  
>  struct omap_clk {
>  	u16				cpu;
> diff --git a/arch/arm/plat-spear/include/plat/clock.h b/arch/arm/plat-spear/include/plat/clock.h
> index 298bafc..2572260 100644
> --- a/arch/arm/plat-spear/include/plat/clock.h
> +++ b/arch/arm/plat-spear/include/plat/clock.h
> @@ -15,7 +15,7 @@
>  #define __PLAT_CLOCK_H
>  
>  #include <linux/list.h>
> -#include <asm/clkdev.h>
> +#include <linux/clkdev.h>
>  #include <linux/types.h>
>  
>  /* clk structure flags */
> diff --git a/arch/arm/plat-stmp3xxx/clock.c b/arch/arm/plat-stmp3xxx/clock.c
> index e593a2a..2e712e1 100644
> --- a/arch/arm/plat-stmp3xxx/clock.c
> +++ b/arch/arm/plat-stmp3xxx/clock.c
> @@ -25,9 +25,9 @@
>  #include <linux/err.h>
>  #include <linux/delay.h>
>  #include <linux/io.h>
> +#include <linux/clkdev.h>
>  
>  #include <asm/mach-types.h>
> -#include <asm/clkdev.h>
>  #include <mach/platform.h>
>  #include <mach/regs-clkctrl.h>
>  
> diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
> index 33990fa..b5f8a0f 100644
> --- a/arch/sh/Kconfig
> +++ b/arch/sh/Kconfig
> @@ -8,7 +8,7 @@ mainmenu "Linux/SuperH Kernel Configuration"
>  config SUPERH
>  	def_bool y
>  	select EMBEDDED
> -	select HAVE_CLK
> +	select CLKDEV_LOOKUP
>  	select HAVE_IDE if HAS_IOPORT
>  	select HAVE_MEMBLOCK
>  	select HAVE_OPROFILE
> diff --git a/arch/sh/boards/mach-highlander/setup.c b/arch/sh/boards/mach-highlander/setup.c
> index a5ecfba..87618c9 100644
> --- a/arch/sh/boards/mach-highlander/setup.c
> +++ b/arch/sh/boards/mach-highlander/setup.c
> @@ -24,10 +24,10 @@
>  #include <linux/interrupt.h>
>  #include <linux/usb/r8a66597.h>
>  #include <linux/usb/m66592.h>
> +#include <linux/clkdev.h>
>  #include <net/ax88796.h>
>  #include <asm/machvec.h>
>  #include <mach/highlander.h>
> -#include <asm/clkdev.h>
>  #include <asm/clock.h>
>  #include <asm/heartbeat.h>
>  #include <asm/io.h>
> diff --git a/arch/sh/include/asm/clkdev.h b/arch/sh/include/asm/clkdev.h
> dissimilarity index 69%
> index 5645f35..6ba9186 100644
> --- a/arch/sh/include/asm/clkdev.h
> +++ b/arch/sh/include/asm/clkdev.h
> @@ -1,35 +1,31 @@
> -/*
> - *  arch/sh/include/asm/clkdev.h
> - *
> - * Cloned from arch/arm/include/asm/clkdev.h:
> - *
> - *  Copyright (C) 2008 Russell King.
> - *
> - * 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.
> - *
> - * Helper for the clk API to assist looking up a struct clk.
> - */
> -#ifndef __ASM_CLKDEV_H
> -#define __ASM_CLKDEV_H
> -
> -struct clk;
> -
> -struct clk_lookup {
> -	struct list_head	node;
> -	const char		*dev_id;
> -	const char		*con_id;
> -	struct clk		*clk;
> -};
> -
> -struct clk_lookup *clkdev_alloc(struct clk *clk, const char *con_id,
> -	const char *dev_fmt, ...);
> -
> -void clkdev_add(struct clk_lookup *cl);
> -void clkdev_drop(struct clk_lookup *cl);
> -
> -void clkdev_add_table(struct clk_lookup *, size_t);
> -int clk_add_alias(const char *, const char *, char *, struct device *);
> -
> -#endif
> +/*
> + *  Copyright (C) 2010 Paul Mundt <lethal@linux-sh.org>
> + *
> + * 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.
> + *
> + * Helper for the clk API to assist looking up a struct clk.
> + */
> +
> +#ifndef __CLKDEV__H_
> +#define __CLKDEV__H_
> +
> +#include <linux/bootmem.h>
> +#include <linux/mm.h>
> +#include <linux/slab.h>
> +
> +#include <asm/clock.h>
> +
> +static inline struct clk_lookup_alloc *__clkdev_alloc(size_t size)
> +{
> +	if (!slab_is_available())
> +		return alloc_bootmem_low_pages(size);
> +	else
> +		return kzalloc(size, GFP_KERNEL);
> +}
> +
> +#define __clk_put(clk)
> +#define __clk_get(clk) ({ 1; })
> +
> +#endif /* __CLKDEV_H__ */
> diff --git a/arch/sh/kernel/Makefile b/arch/sh/kernel/Makefile
> index e25f3c6..e4fe614 100644
> --- a/arch/sh/kernel/Makefile
> +++ b/arch/sh/kernel/Makefile
> @@ -11,7 +11,7 @@ endif
>  
>  CFLAGS_REMOVE_return_address.o = -pg
>  
> -obj-y	:= clkdev.o debugtraps.o dma-nommu.o dumpstack.o 		\
> +obj-y	:= debugtraps.o dma-nommu.o dumpstack.o 			\
>  	   idle.o io.o irq.o						\
>  	   irq_$(BITS).o machvec.o nmi_debug.o process.o		\
>  	   process_$(BITS).o ptrace_$(BITS).o				\
> diff --git a/arch/sh/kernel/clkdev.c b/arch/sh/kernel/clkdev.c
> deleted file mode 100644
> index befc255..0000000
> --- a/arch/sh/kernel/clkdev.c
> +++ /dev/null
> @@ -1,169 +0,0 @@
> -/*
> - * arch/sh/kernel/clkdev.c
> - *
> - * Cloned from arch/arm/common/clkdev.c:
> - *
> - *  Copyright (C) 2008 Russell King.
> - *
> - * 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.
> - *
> - * Helper for the clk API to assist looking up a struct clk.
> - */
> -#include <linux/module.h>
> -#include <linux/kernel.h>
> -#include <linux/device.h>
> -#include <linux/list.h>
> -#include <linux/errno.h>
> -#include <linux/err.h>
> -#include <linux/string.h>
> -#include <linux/mutex.h>
> -#include <linux/clk.h>
> -#include <linux/slab.h>
> -#include <linux/bootmem.h>
> -#include <linux/mm.h>
> -#include <asm/clock.h>
> -#include <asm/clkdev.h>
> -
> -static LIST_HEAD(clocks);
> -static DEFINE_MUTEX(clocks_mutex);
> -
> -/*
> - * Find the correct struct clk for the device and connection ID.
> - * We do slightly fuzzy matching here:
> - *  An entry with a NULL ID is assumed to be a wildcard.
> - *  If an entry has a device ID, it must match
> - *  If an entry has a connection ID, it must match
> - * Then we take the most specific entry - with the following
> - * order of precedence: dev+con > dev only > con only.
> - */
> -static struct clk *clk_find(const char *dev_id, const char *con_id)
> -{
> -	struct clk_lookup *p;
> -	struct clk *clk = NULL;
> -	int match, best = 0;
> -
> -	list_for_each_entry(p, &clocks, node) {
> -		match = 0;
> -		if (p->dev_id) {
> -			if (!dev_id || strcmp(p->dev_id, dev_id))
> -				continue;
> -			match += 2;
> -		}
> -		if (p->con_id) {
> -			if (!con_id || strcmp(p->con_id, con_id))
> -				continue;
> -			match += 1;
> -		}
> -		if (match = 0)
> -			continue;
> -
> -		if (match > best) {
> -			clk = p->clk;
> -			best = match;
> -		}
> -	}
> -	return clk;
> -}
> -
> -struct clk *clk_get_sys(const char *dev_id, const char *con_id)
> -{
> -	struct clk *clk;
> -
> -	mutex_lock(&clocks_mutex);
> -	clk = clk_find(dev_id, con_id);
> -	mutex_unlock(&clocks_mutex);
> -
> -	return clk ? clk : ERR_PTR(-ENOENT);
> -}
> -EXPORT_SYMBOL(clk_get_sys);
> -
> -void clkdev_add(struct clk_lookup *cl)
> -{
> -	mutex_lock(&clocks_mutex);
> -	list_add_tail(&cl->node, &clocks);
> -	mutex_unlock(&clocks_mutex);
> -}
> -EXPORT_SYMBOL(clkdev_add);
> -
> -void __init clkdev_add_table(struct clk_lookup *cl, size_t num)
> -{
> -	mutex_lock(&clocks_mutex);
> -	while (num--) {
> -		list_add_tail(&cl->node, &clocks);
> -		cl++;
> -	}
> -	mutex_unlock(&clocks_mutex);
> -}
> -
> -#define MAX_DEV_ID	20
> -#define MAX_CON_ID	16
> -
> -struct clk_lookup_alloc {
> -	struct clk_lookup cl;
> -	char	dev_id[MAX_DEV_ID];
> -	char	con_id[MAX_CON_ID];
> -};
> -
> -struct clk_lookup * __init_refok
> -clkdev_alloc(struct clk *clk, const char *con_id, const char *dev_fmt, ...)
> -{
> -	struct clk_lookup_alloc *cla;
> -
> -	if (!slab_is_available())
> -		cla = alloc_bootmem_low_pages(sizeof(*cla));
> -	else
> -		cla = kzalloc(sizeof(*cla), GFP_KERNEL);
> -
> -	if (!cla)
> -		return NULL;
> -
> -	cla->cl.clk = clk;
> -	if (con_id) {
> -		strlcpy(cla->con_id, con_id, sizeof(cla->con_id));
> -		cla->cl.con_id = cla->con_id;
> -	}
> -
> -	if (dev_fmt) {
> -		va_list ap;
> -
> -		va_start(ap, dev_fmt);
> -		vscnprintf(cla->dev_id, sizeof(cla->dev_id), dev_fmt, ap);
> -		cla->cl.dev_id = cla->dev_id;
> -		va_end(ap);
> -	}
> -
> -	return &cla->cl;
> -}
> -EXPORT_SYMBOL(clkdev_alloc);
> -
> -int clk_add_alias(const char *alias, const char *alias_dev_name, char *id,
> -	struct device *dev)
> -{
> -	struct clk *r = clk_get(dev, id);
> -	struct clk_lookup *l;
> -
> -	if (IS_ERR(r))
> -		return PTR_ERR(r);
> -
> -	l = clkdev_alloc(r, alias, alias_dev_name);
> -	clk_put(r);
> -	if (!l)
> -		return -ENODEV;
> -	clkdev_add(l);
> -	return 0;
> -}
> -EXPORT_SYMBOL(clk_add_alias);
> -
> -/*
> - * clkdev_drop - remove a clock dynamically allocated
> - */
> -void clkdev_drop(struct clk_lookup *cl)
> -{
> -	mutex_lock(&clocks_mutex);
> -	list_del(&cl->node);
> -	mutex_unlock(&clocks_mutex);
> -	kfree(cl);
> -}
> -EXPORT_SYMBOL(clkdev_drop);
> diff --git a/arch/sh/kernel/cpu/clock-cpg.c b/arch/sh/kernel/cpu/clock-cpg.c
> index e2f63d6..dd0e0f2 100644
> --- a/arch/sh/kernel/cpu/clock-cpg.c
> +++ b/arch/sh/kernel/cpu/clock-cpg.c
> @@ -2,7 +2,7 @@
>  #include <linux/compiler.h>
>  #include <linux/slab.h>
>  #include <linux/io.h>
> -#include <asm/clkdev.h>
> +#include <linux/clkdev.h>
>  #include <asm/clock.h>
>  
>  static struct clk master_clk = {
> diff --git a/arch/sh/kernel/cpu/clock.c b/arch/sh/kernel/cpu/clock.c
> index 50f887d..4187cf4 100644
> --- a/arch/sh/kernel/cpu/clock.c
> +++ b/arch/sh/kernel/cpu/clock.c
> @@ -48,20 +48,4 @@ int __init clk_init(void)
>  	return ret;
>  }
>  
> -/*
> - * Returns a clock. Note that we first try to use device id on the bus
> - * and clock name. If this fails, we try to use clock name only.
> - */
> -struct clk *clk_get(struct device *dev, const char *con_id)
> -{
> -	const char *dev_id = dev ? dev_name(dev) : NULL;
> -
> -	return clk_get_sys(dev_id, con_id);
> -}
> -EXPORT_SYMBOL_GPL(clk_get);
> -
> -void clk_put(struct clk *clk)
> -{
> -}
> -EXPORT_SYMBOL_GPL(clk_put);
>  
> diff --git a/arch/sh/kernel/cpu/sh4/clock-sh4-202.c b/arch/sh/kernel/cpu/sh4/clock-sh4-202.c
> index 4eabc68..6c1492b 100644
> --- a/arch/sh/kernel/cpu/sh4/clock-sh4-202.c
> +++ b/arch/sh/kernel/cpu/sh4/clock-sh4-202.c
> @@ -13,7 +13,7 @@
>  #include <linux/kernel.h>
>  #include <linux/err.h>
>  #include <linux/io.h>
> -#include <asm/clkdev.h>
> +#include <linux/clkdev.h>
>  #include <asm/clock.h>
>  #include <asm/freq.h>
>  
> diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7343.c b/arch/sh/kernel/cpu/sh4a/clock-sh7343.c
> index 71291ae..93c6460 100644
> --- a/arch/sh/kernel/cpu/sh4a/clock-sh7343.c
> +++ b/arch/sh/kernel/cpu/sh4a/clock-sh7343.c
> @@ -21,7 +21,7 @@
>  #include <linux/init.h>
>  #include <linux/kernel.h>
>  #include <linux/io.h>
> -#include <asm/clkdev.h>
> +#include <linux/clkdev.h>
>  #include <asm/clock.h>
>  
>  /* SH7343 registers */
> diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7366.c b/arch/sh/kernel/cpu/sh4a/clock-sh7366.c
> index 7ce5bbc..049dc06 100644
> --- a/arch/sh/kernel/cpu/sh4a/clock-sh7366.c
> +++ b/arch/sh/kernel/cpu/sh4a/clock-sh7366.c
> @@ -21,7 +21,7 @@
>  #include <linux/init.h>
>  #include <linux/kernel.h>
>  #include <linux/io.h>
> -#include <asm/clkdev.h>
> +#include <linux/clkdev.h>
>  #include <asm/clock.h>
>  
>  /* SH7366 registers */
> diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7722.c b/arch/sh/kernel/cpu/sh4a/clock-sh7722.c
> index 2030f3d..9d23a36 100644
> --- a/arch/sh/kernel/cpu/sh4a/clock-sh7722.c
> +++ b/arch/sh/kernel/cpu/sh4a/clock-sh7722.c
> @@ -21,7 +21,7 @@
>  #include <linux/init.h>
>  #include <linux/kernel.h>
>  #include <linux/io.h>
> -#include <asm/clkdev.h>
> +#include <linux/clkdev.h>
>  #include <asm/clock.h>
>  #include <asm/hwblk.h>
>  #include <cpu/sh7722.h>
> diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7723.c b/arch/sh/kernel/cpu/sh4a/clock-sh7723.c
> index d3938f0..55493cd 100644
> --- a/arch/sh/kernel/cpu/sh4a/clock-sh7723.c
> +++ b/arch/sh/kernel/cpu/sh4a/clock-sh7723.c
> @@ -22,7 +22,7 @@
>  #include <linux/kernel.h>
>  #include <linux/io.h>
>  #include <linux/clk.h>
> -#include <asm/clkdev.h>
> +#include <linux/clkdev.h>
>  #include <asm/clock.h>
>  #include <asm/hwblk.h>
>  #include <cpu/sh7723.h>
> diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7724.c b/arch/sh/kernel/cpu/sh4a/clock-sh7724.c
> index 2d9700c..527936b 100644
> --- a/arch/sh/kernel/cpu/sh4a/clock-sh7724.c
> +++ b/arch/sh/kernel/cpu/sh4a/clock-sh7724.c
> @@ -22,7 +22,7 @@
>  #include <linux/kernel.h>
>  #include <linux/io.h>
>  #include <linux/clk.h>
> -#include <asm/clkdev.h>
> +#include <linux/clkdev.h>
>  #include <asm/clock.h>
>  #include <asm/hwblk.h>
>  #include <cpu/sh7724.h>
> diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7757.c b/arch/sh/kernel/cpu/sh4a/clock-sh7757.c
> index 0a752bd..589ee0a 100644
> --- a/arch/sh/kernel/cpu/sh4a/clock-sh7757.c
> +++ b/arch/sh/kernel/cpu/sh4a/clock-sh7757.c
> @@ -12,7 +12,7 @@
>  #include <linux/init.h>
>  #include <linux/kernel.h>
>  #include <linux/io.h>
> -#include <asm/clkdev.h>
> +#include <linux/clkdev.h>
>  #include <asm/clock.h>
>  #include <asm/freq.h>
>  
> diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7763.c b/arch/sh/kernel/cpu/sh4a/clock-sh7763.c
> index 1f1df48..599630f 100644
> --- a/arch/sh/kernel/cpu/sh4a/clock-sh7763.c
> +++ b/arch/sh/kernel/cpu/sh4a/clock-sh7763.c
> @@ -13,7 +13,7 @@
>  #include <linux/init.h>
>  #include <linux/kernel.h>
>  #include <linux/io.h>
> -#include <asm/clkdev.h>
> +#include <linux/clkdev.h>
>  #include <asm/clock.h>
>  #include <asm/freq.h>
>  #include <asm/io.h>
> diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7780.c b/arch/sh/kernel/cpu/sh4a/clock-sh7780.c
> index 62d7063..8894926 100644
> --- a/arch/sh/kernel/cpu/sh4a/clock-sh7780.c
> +++ b/arch/sh/kernel/cpu/sh4a/clock-sh7780.c
> @@ -12,7 +12,7 @@
>  #include <linux/init.h>
>  #include <linux/kernel.h>
>  #include <linux/io.h>
> -#include <asm/clkdev.h>
> +#include <linux/clkdev.h>
>  #include <asm/clock.h>
>  #include <asm/freq.h>
>  #include <asm/io.h>
> diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7785.c b/arch/sh/kernel/cpu/sh4a/clock-sh7785.c
> index c3e458a..2d96024 100644
> --- a/arch/sh/kernel/cpu/sh4a/clock-sh7785.c
> +++ b/arch/sh/kernel/cpu/sh4a/clock-sh7785.c
> @@ -14,7 +14,7 @@
>  #include <linux/clk.h>
>  #include <linux/io.h>
>  #include <linux/cpufreq.h>
> -#include <asm/clkdev.h>
> +#include <linux/clkdev.h>
>  #include <asm/clock.h>
>  #include <asm/freq.h>
>  #include <cpu/sh7785.h>
> diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7786.c b/arch/sh/kernel/cpu/sh4a/clock-sh7786.c
> index 597c9fb..42e403b 100644
> --- a/arch/sh/kernel/cpu/sh4a/clock-sh7786.c
> +++ b/arch/sh/kernel/cpu/sh4a/clock-sh7786.c
> @@ -13,7 +13,7 @@
>  #include <linux/kernel.h>
>  #include <linux/clk.h>
>  #include <linux/io.h>
> -#include <asm/clkdev.h>
> +#include <linux/clkdev.h>
>  #include <asm/clock.h>
>  #include <asm/freq.h>
>  
> diff --git a/arch/sh/kernel/cpu/sh4a/clock-shx3.c b/arch/sh/kernel/cpu/sh4a/clock-shx3.c
> index 236a628..228d7e6 100644
> --- a/arch/sh/kernel/cpu/sh4a/clock-shx3.c
> +++ b/arch/sh/kernel/cpu/sh4a/clock-shx3.c
> @@ -14,7 +14,7 @@
>  #include <linux/init.h>
>  #include <linux/kernel.h>
>  #include <linux/io.h>
> -#include <asm/clkdev.h>
> +#include <linux/clkdev.h>
>  #include <asm/clock.h>
>  #include <asm/freq.h>
>  
> diff --git a/drivers/Kconfig b/drivers/Kconfig
> index a2b902f..3d93b3a 100644
> --- a/drivers/Kconfig
> +++ b/drivers/Kconfig
> @@ -111,4 +111,6 @@ source "drivers/xen/Kconfig"
>  source "drivers/staging/Kconfig"
>  
>  source "drivers/platform/Kconfig"
> +
> +source "drivers/clk/Kconfig"
>  endmenu
> diff --git a/drivers/Makefile b/drivers/Makefile
> index ae47344..b0e30b2 100644
> --- a/drivers/Makefile
> +++ b/drivers/Makefile
> @@ -115,3 +115,5 @@ obj-$(CONFIG_VLYNQ)		+= vlynq/
>  obj-$(CONFIG_STAGING)		+= staging/
>  obj-y				+= platform/
>  obj-y				+= ieee802154/
> +#common clk code
> +obj-y				+= clk/
> diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig
> new file mode 100644
> index 0000000..4168c88
> --- /dev/null
> +++ b/drivers/clk/Kconfig
> @@ -0,0 +1,4 @@
> +
> +config CLKDEV_LOOKUP
> +	bool
> +	select HAVE_CLK
> diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
> new file mode 100644
> index 0000000..07613fa
> --- /dev/null
> +++ b/drivers/clk/Makefile
> @@ -0,0 +1,2 @@
> +
> +obj-$(CONFIG_CLKDEV_LOOKUP)	+= clkdev.o
> diff --git a/arch/arm/common/clkdev.c b/drivers/clk/clkdev.c
> similarity index 91%
> rename from arch/arm/common/clkdev.c
> rename to drivers/clk/clkdev.c
> index e2b2bb6..d8b91ae 100644
> --- a/arch/arm/common/clkdev.c
> +++ b/drivers/clk/clkdev.c
> @@ -1,5 +1,5 @@
>  /*
> - *  arch/arm/common/clkdev.c
> + * drivers/clk/clkdev.c
>   *
>   *  Copyright (C) 2008 Russell King.
>   *
> @@ -18,10 +18,7 @@
>  #include <linux/string.h>
>  #include <linux/mutex.h>
>  #include <linux/clk.h>
> -#include <linux/slab.h>
> -
> -#include <asm/clkdev.h>
> -#include <mach/clkdev.h>
> +#include <linux/clkdev.h>
>  
>  static LIST_HEAD(clocks);
>  static DEFINE_MUTEX(clocks_mutex);
> @@ -79,6 +76,10 @@ struct clk *clk_get_sys(const char *dev_id, const char *con_id)
>  }
>  EXPORT_SYMBOL(clk_get_sys);
>  
> +/*
> + * Returns a clock. Note that we first try to use device id on the bus
> + * and clock name. If this fails, we try to use clock name only.
> + */
>  struct clk *clk_get(struct device *dev, const char *con_id)
>  {
>  	const char *dev_id = dev ? dev_name(dev) : NULL;
> @@ -120,12 +121,12 @@ struct clk_lookup_alloc {
>  	char	con_id[MAX_CON_ID];
>  };
>  
> -struct clk_lookup *clkdev_alloc(struct clk *clk, const char *con_id,
> -	const char *dev_fmt, ...)
> +struct clk_lookup * __init_refok
> +clkdev_alloc(struct clk *clk, const char *con_id, const char *dev_fmt, ...)
I'm not very satisfied by Russell's answer.  But even if I accept that
it should not move to .init.text, why .ref.text?  If I'm not mistaken
clkdev_alloc references the following non-local symbols:

	__clkdev_alloc
	strlcpy
	vscnprintf

non of these are in .init, so I think it's not needed.

Russell, would at least __module_or_init be OK?
 
Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [RFC] [PATCH v2] arm & sh: factorised duplicated clkdev.c
@ 2010-09-02 13:26     ` Uwe Kleine-König
  0 siblings, 0 replies; 133+ messages in thread
From: Uwe Kleine-König @ 2010-09-02 13:26 UTC (permalink / raw)
  To: linux-arm-kernel

Hello Jean,

On Thu, Sep 02, 2010 at 02:48:36PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> factorise some generic infrastructure to assist looking up struct clks
> for the ARM & SH architecture.
> 
> as the code is identical at 99%
> 
> put the arch specific code for allocation as example in asm/clkdev.h
> 
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> ---
> V2:
> 
> 	update base on Russel & Uwe Comments
s/Russel/Russell/ BTW.

> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
> index a7ed21f..1d8a26c 100644
> --- a/arch/arm/Kconfig
> +++ b/arch/arm/Kconfig
> @@ -221,7 +221,7 @@ config ARCH_INTEGRATOR
>  	bool "ARM Ltd. Integrator family"
>  	select ARM_AMBA
>  	select ARCH_HAS_CPUFREQ
> -	select COMMON_CLKDEV
> +	select CLKDEV_LOOKUP
>  	select ICST
>  	select GENERIC_CLOCKEVENTS
>  	select PLAT_VERSATILE
did you think about keeping the name COMMON_CLKDEV?

> @@ -231,7 +231,7 @@ config ARCH_INTEGRATOR
>  config ARCH_REALVIEW
>  	bool "ARM Ltd. RealView family"
>  	select ARM_AMBA
> -	select COMMON_CLKDEV
> +	select CLKDEV_LOOKUP
>  	select ICST
>  	select GENERIC_CLOCKEVENTS
>  	select ARCH_WANT_OPTIONAL_GPIOLIB
> @@ -245,7 +245,7 @@ config ARCH_VERSATILE
>  	bool "ARM Ltd. Versatile family"
>  	select ARM_AMBA
>  	select ARM_VIC
> -	select COMMON_CLKDEV
> +	select CLKDEV_LOOKUP
>  	select ICST
>  	select GENERIC_CLOCKEVENTS
>  	select ARCH_WANT_OPTIONAL_GPIOLIB
> @@ -259,7 +259,7 @@ config ARCH_VEXPRESS
>  	select ARCH_WANT_OPTIONAL_GPIOLIB
>  	select ARM_AMBA
>  	select ARM_TIMER_SP804
> -	select COMMON_CLKDEV
> +	select CLKDEV_LOOKUP
>  	select GENERIC_CLOCKEVENTS
>  	select HAVE_CLK
>  	select ICST
> @@ -281,7 +281,7 @@ config ARCH_BCMRING
>  	depends on MMU
>  	select CPU_V6
>  	select ARM_AMBA
> -	select COMMON_CLKDEV
> +	select CLKDEV_LOOKUP
>  	select GENERIC_CLOCKEVENTS
>  	select ARCH_WANT_OPTIONAL_GPIOLIB
>  	help
> @@ -328,7 +328,7 @@ config ARCH_EP93XX
>  	select CPU_ARM920T
>  	select ARM_AMBA
>  	select ARM_VIC
> -	select COMMON_CLKDEV
> +	select CLKDEV_LOOKUP
>  	select ARCH_REQUIRE_GPIOLIB
>  	select ARCH_HAS_HOLES_MEMORYMODEL
>  	select ARCH_USES_GETTIMEOFFSET
> @@ -348,14 +348,14 @@ config ARCH_MXC
>  	bool "Freescale MXC/iMX-based"
>  	select GENERIC_CLOCKEVENTS
>  	select ARCH_REQUIRE_GPIOLIB
> -	select COMMON_CLKDEV
> +	select CLKDEV_LOOKUP
>  	help
>  	  Support for Freescale MXC/iMX-based family of processors
>  
>  config ARCH_STMP3XXX
>  	bool "Freescale STMP3xxx"
>  	select CPU_ARM926T
> -	select COMMON_CLKDEV
> +	select CLKDEV_LOOKUP
>  	select ARCH_REQUIRE_GPIOLIB
>  	select GENERIC_CLOCKEVENTS
>  	select USB_ARCH_HAS_EHCI
> @@ -473,7 +473,7 @@ config ARCH_LPC32XX
>  	select HAVE_IDE
>  	select ARM_AMBA
>  	select USB_ARCH_HAS_OHCI
> -	select COMMON_CLKDEV
> +	select CLKDEV_LOOKUP
>  	select GENERIC_TIME
>  	select GENERIC_CLOCKEVENTS
>  	help
> @@ -507,7 +507,7 @@ config ARCH_MMP
>  	bool "Marvell PXA168/910/MMP2"
>  	depends on MMU
>  	select ARCH_REQUIRE_GPIOLIB
> -	select COMMON_CLKDEV
> +	select CLKDEV_LOOKUP
>  	select GENERIC_CLOCKEVENTS
>  	select TICK_ONESHOT
>  	select PLAT_PXA
> @@ -539,7 +539,7 @@ config ARCH_W90X900
>  	bool "Nuvoton W90X900 CPU"
>  	select CPU_ARM926T
>  	select ARCH_REQUIRE_GPIOLIB
> -	select COMMON_CLKDEV
> +	select CLKDEV_LOOKUP
>  	select GENERIC_CLOCKEVENTS
>  	help
>  	  Support for Nuvoton (Winbond logic dept.) ARM9 processor,
> @@ -553,7 +553,7 @@ config ARCH_W90X900
>  config ARCH_NUC93X
>  	bool "Nuvoton NUC93X CPU"
>  	select CPU_ARM926T
> -	select COMMON_CLKDEV
> +	select CLKDEV_LOOKUP
>  	help
>  	  Support for Nuvoton (Winbond logic dept.) NUC93X MCU,The NUC93X is a
>  	  low-power and high performance MPEG-4/JPEG multimedia controller chip.
> @@ -564,7 +564,7 @@ config ARCH_TEGRA
>  	select GENERIC_CLOCKEVENTS
>  	select GENERIC_GPIO
>  	select HAVE_CLK
> -	select COMMON_CLKDEV
> +	select CLKDEV_LOOKUP
>  	select ARCH_HAS_BARRIERS if CACHE_L2X0
>  	help
>  	  This enables support for NVIDIA Tegra based systems (Tegra APX,
> @@ -573,7 +573,7 @@ config ARCH_TEGRA
>  config ARCH_PNX4008
>  	bool "Philips Nexperia PNX4008 Mobile"
>  	select CPU_ARM926T
> -	select COMMON_CLKDEV
> +	select CLKDEV_LOOKUP
>  	select ARCH_USES_GETTIMEOFFSET
>  	help
>  	  This enables support for Philips PNX4008 mobile platform.
> @@ -583,7 +583,7 @@ config ARCH_PXA
>  	depends on MMU
>  	select ARCH_MTD_XIP
>  	select ARCH_HAS_CPUFREQ
> -	select COMMON_CLKDEV
> +	select CLKDEV_LOOKUP
>  	select ARCH_REQUIRE_GPIOLIB
>  	select GENERIC_CLOCKEVENTS
>  	select TICK_ONESHOT
> @@ -767,7 +767,7 @@ config ARCH_U300
>  	select ARM_AMBA
>  	select ARM_VIC
>  	select GENERIC_CLOCKEVENTS
> -	select COMMON_CLKDEV
> +	select CLKDEV_LOOKUP
>  	select GENERIC_GPIO
>  	help
>  	  Support for ST-Ericsson U300 series mobile platforms.
> @@ -777,7 +777,7 @@ config ARCH_U8500
>  	select CPU_V7
>  	select ARM_AMBA
>  	select GENERIC_CLOCKEVENTS
> -	select COMMON_CLKDEV
> +	select CLKDEV_LOOKUP
>  	select ARCH_REQUIRE_GPIOLIB
>  	help
>  	  Support for ST-Ericsson's Ux500 architecture
> @@ -787,7 +787,7 @@ config ARCH_NOMADIK
>  	select ARM_AMBA
>  	select ARM_VIC
>  	select CPU_ARM926T
> -	select COMMON_CLKDEV
> +	select CLKDEV_LOOKUP
>  	select GENERIC_CLOCKEVENTS
>  	select ARCH_REQUIRE_GPIOLIB
>  	help
> @@ -799,7 +799,7 @@ config ARCH_DAVINCI
>  	select ARCH_REQUIRE_GPIOLIB
>  	select ZONE_DMA
>  	select HAVE_IDE
> -	select COMMON_CLKDEV
> +	select CLKDEV_LOOKUP
>  	select GENERIC_ALLOCATOR
>  	select ARCH_HAS_HOLES_MEMORYMODEL
>  	help
> @@ -819,7 +819,7 @@ config PLAT_SPEAR
>  	bool "ST SPEAr"
>  	select ARM_AMBA
>  	select ARCH_REQUIRE_GPIOLIB
> -	select COMMON_CLKDEV
> +	select CLKDEV_LOOKUP
>  	select GENERIC_CLOCKEVENTS
>  	select HAVE_CLK
>  	help
> diff --git a/arch/arm/common/Kconfig b/arch/arm/common/Kconfig
> index 0a34c81..778655f 100644
> --- a/arch/arm/common/Kconfig
> +++ b/arch/arm/common/Kconfig
> @@ -37,7 +37,3 @@ config SHARP_PARAM
>  
>  config SHARP_SCOOP
>  	bool
> -
> -config COMMON_CLKDEV
> -	bool
> -	select HAVE_CLK
> diff --git a/arch/arm/common/Makefile b/arch/arm/common/Makefile
> index e6e8664..799e140 100644
> --- a/arch/arm/common/Makefile
> +++ b/arch/arm/common/Makefile
> @@ -16,4 +16,3 @@ obj-$(CONFIG_SHARP_SCOOP)	+= scoop.o
>  obj-$(CONFIG_ARCH_IXP2000)	+= uengine.o
>  obj-$(CONFIG_ARCH_IXP23XX)	+= uengine.o
>  obj-$(CONFIG_PCI_HOST_ITE8152)  += it8152.o
> -obj-$(CONFIG_COMMON_CLKDEV)	+= clkdev.o
> diff --git a/arch/arm/include/asm/clkdev.h b/arch/arm/include/asm/clkdev.h
> index b56c138..1293780 100644
> --- a/arch/arm/include/asm/clkdev.h
> +++ b/arch/arm/include/asm/clkdev.h
> @@ -1,5 +1,5 @@
>  /*
> - *  arch/arm/include/asm/clkdev.h
> + *  arch/arm/include/linux/clkdev.h
??, arch/arm/include/asm/clkdev.h was correct, no?

>   *
>   *  Copyright (C) 2008 Russell King.
>   *
> @@ -12,23 +12,13 @@
>  #ifndef __ASM_CLKDEV_H
>  #define __ASM_CLKDEV_H
>  
> -struct clk;
> -struct device;
> +#include <linux/slab.h>
>  
> -struct clk_lookup {
> -	struct list_head	node;
> -	const char		*dev_id;
> -	const char		*con_id;
> -	struct clk		*clk;
> -};
> +#include <mach/clkdev.h>
>  
> -struct clk_lookup *clkdev_alloc(struct clk *clk, const char *con_id,
> -	const char *dev_fmt, ...);
> -
> -void clkdev_add(struct clk_lookup *cl);
> -void clkdev_drop(struct clk_lookup *cl);
> -
> -void clkdev_add_table(struct clk_lookup *, size_t);
> -int clk_add_alias(const char *, const char *, char *, struct device *);
> +static inline struct clk_lookup_alloc *__clkdev_alloc(size_t size)
> +{
> +	return kzalloc(size, GFP_KERNEL);
> +}
>  
>  #endif
> diff --git a/arch/arm/mach-bcmring/clock.c b/arch/arm/mach-bcmring/clock.c
> index 14bafc3..ad237a4 100644
> --- a/arch/arm/mach-bcmring/clock.c
> +++ b/arch/arm/mach-bcmring/clock.c
> @@ -21,13 +21,12 @@
>  #include <linux/string.h>
>  #include <linux/clk.h>
>  #include <linux/spinlock.h>
> +#include <linux/clkdev.h>
>  #include <mach/csp/hw_cfg.h>
>  #include <mach/csp/chipcHw_def.h>
>  #include <mach/csp/chipcHw_reg.h>
>  #include <mach/csp/chipcHw_inline.h>
>  
> -#include <asm/clkdev.h>
> -
>  #include "clock.h"
>  
>  #define clk_is_primary(x)       ((x)->type & CLK_TYPE_PRIMARY)
> diff --git a/arch/arm/mach-bcmring/core.c b/arch/arm/mach-bcmring/core.c
> index d3f959e..ed96ef4 100644
> --- a/arch/arm/mach-bcmring/core.c
> +++ b/arch/arm/mach-bcmring/core.c
> @@ -30,10 +30,10 @@
>  #include <linux/amba/bus.h>
>  #include <linux/clocksource.h>
>  #include <linux/clockchips.h>
> +#include <linux/clkdev.h>
>  
>  #include <mach/csp/mm_addr.h>
>  #include <mach/hardware.h>
> -#include <asm/clkdev.h>
>  #include <linux/io.h>
>  #include <asm/irq.h>
>  #include <asm/hardware/arm_timer.h>
> diff --git a/arch/arm/mach-davinci/clock.h b/arch/arm/mach-davinci/clock.h
> index 01e3648..64c58ad 100644
> --- a/arch/arm/mach-davinci/clock.h
> +++ b/arch/arm/mach-davinci/clock.h
> @@ -68,7 +68,7 @@
>  #ifndef __ASSEMBLER__
>  
>  #include <linux/list.h>
> -#include <asm/clkdev.h>
> +#include <linux/clkdev.h>
>  
>  struct pll_data {
>  	u32 phys_base;
> diff --git a/arch/arm/mach-ep93xx/clock.c b/arch/arm/mach-ep93xx/clock.c
> index 8bf3cec..f60d636 100644
> --- a/arch/arm/mach-ep93xx/clock.c
> +++ b/arch/arm/mach-ep93xx/clock.c
> @@ -19,10 +19,10 @@
>  #include <linux/string.h>
>  #include <linux/io.h>
>  #include <linux/spinlock.h>
> +#include <linux/clkdev.h>
>  
>  #include <mach/hardware.h>
>  
> -#include <asm/clkdev.h>
>  #include <asm/div64.h>
>  
>  
> diff --git a/arch/arm/mach-imx/clock-imx1.c b/arch/arm/mach-imx/clock-imx1.c
> index c05096c..9c848d9 100644
> --- a/arch/arm/mach-imx/clock-imx1.c
> +++ b/arch/arm/mach-imx/clock-imx1.c
> @@ -22,8 +22,7 @@
>  #include <linux/err.h>
>  #include <linux/clk.h>
>  #include <linux/io.h>
> -
> -#include <asm/clkdev.h>
> +#include <linux/clkdev.h>
>  
>  #include <mach/clock.h>
>  #include <mach/hardware.h>
> diff --git a/arch/arm/mach-imx/clock-imx21.c b/arch/arm/mach-imx/clock-imx21.c
> index bb419ef..19e966e 100644
> --- a/arch/arm/mach-imx/clock-imx21.c
> +++ b/arch/arm/mach-imx/clock-imx21.c
> @@ -21,11 +21,11 @@
>  #include <linux/clk.h>
>  #include <linux/io.h>
>  #include <linux/module.h>
> +#include <linux/clkdev.h>
>  
>  #include <mach/clock.h>
>  #include <mach/hardware.h>
>  #include <mach/common.h>
> -#include <asm/clkdev.h>
>  #include <asm/div64.h>
>  
>  #define IO_ADDR_CCM(off)	(MX21_IO_ADDRESS(MX21_CCM_BASE_ADDR + (off)))
> diff --git a/arch/arm/mach-imx/clock-imx27.c b/arch/arm/mach-imx/clock-imx27.c
> index 5a1aa15..f121114 100644
> --- a/arch/arm/mach-imx/clock-imx27.c
> +++ b/arch/arm/mach-imx/clock-imx27.c
> @@ -21,8 +21,8 @@
>  #include <linux/clk.h>
>  #include <linux/io.h>
>  #include <linux/module.h>
> +#include <linux/clkdev.h>
>  
> -#include <asm/clkdev.h>
>  #include <asm/div64.h>
>  
>  #include <mach/clock.h>
> diff --git a/arch/arm/mach-integrator/core.c b/arch/arm/mach-integrator/core.c
> index 8f4fb6d..b8e884b 100644
> --- a/arch/arm/mach-integrator/core.c
> +++ b/arch/arm/mach-integrator/core.c
> @@ -21,9 +21,8 @@
>  #include <linux/amba/bus.h>
>  #include <linux/amba/serial.h>
>  #include <linux/io.h>
> +#include <linux/clkdev.h>
>  
> -#include <asm/clkdev.h>
> -#include <mach/clkdev.h>
>  #include <mach/hardware.h>
>  #include <mach/platform.h>
>  #include <asm/irq.h>
> diff --git a/arch/arm/mach-integrator/impd1.c b/arch/arm/mach-integrator/impd1.c
> index fd684bf..5db574f 100644
> --- a/arch/arm/mach-integrator/impd1.c
> +++ b/arch/arm/mach-integrator/impd1.c
> @@ -22,9 +22,8 @@
>  #include <linux/amba/clcd.h>
>  #include <linux/io.h>
>  #include <linux/slab.h>
> +#include <linux/clkdev.h>
>  
> -#include <asm/clkdev.h>
> -#include <mach/clkdev.h>
>  #include <asm/hardware/icst.h>
>  #include <mach/lm.h>
>  #include <mach/impd1.h>
> diff --git a/arch/arm/mach-integrator/integrator_cp.c b/arch/arm/mach-integrator/integrator_cp.c
> index 05db40e..fce64fc 100644
> --- a/arch/arm/mach-integrator/integrator_cp.c
> +++ b/arch/arm/mach-integrator/integrator_cp.c
> @@ -21,9 +21,8 @@
>  #include <linux/amba/mmci.h>
>  #include <linux/io.h>
>  #include <linux/gfp.h>
> +#include <linux/clkdev.h>
>  
> -#include <asm/clkdev.h>
> -#include <mach/clkdev.h>
>  #include <mach/hardware.h>
>  #include <mach/platform.h>
>  #include <asm/irq.h>
> diff --git a/arch/arm/mach-lpc32xx/clock.c b/arch/arm/mach-lpc32xx/clock.c
> index 32d6379..da0e649 100644
> --- a/arch/arm/mach-lpc32xx/clock.c
> +++ b/arch/arm/mach-lpc32xx/clock.c
> @@ -90,10 +90,9 @@
>  #include <linux/clk.h>
>  #include <linux/amba/bus.h>
>  #include <linux/amba/clcd.h>
> +#include <linux/clkdev.h>
>  
>  #include <mach/hardware.h>
> -#include <asm/clkdev.h>
> -#include <mach/clkdev.h>
>  #include <mach/platform.h>
>  #include "clock.h"
>  #include "common.h"
> diff --git a/arch/arm/mach-mmp/clock.h b/arch/arm/mach-mmp/clock.h
> index 016ae94..9b027d7 100644
> --- a/arch/arm/mach-mmp/clock.h
> +++ b/arch/arm/mach-mmp/clock.h
> @@ -6,7 +6,7 @@
>   *  published by the Free Software Foundation.
>   */
>  
> -#include <asm/clkdev.h>
> +#include <linux/clkdev.h>
>  
>  struct clkops {
>  	void			(*enable)(struct clk *);
> diff --git a/arch/arm/mach-mx25/clock.c b/arch/arm/mach-mx25/clock.c
> index 40c7cc4..b3196bb 100644
> --- a/arch/arm/mach-mx25/clock.c
> +++ b/arch/arm/mach-mx25/clock.c
> @@ -21,8 +21,7 @@
>  #include <linux/list.h>
>  #include <linux/clk.h>
>  #include <linux/io.h>
> -
> -#include <asm/clkdev.h>
> +#include <linux/clkdev.h>
>  
>  #include <mach/clock.h>
>  #include <mach/hardware.h>
> diff --git a/arch/arm/mach-mx3/clock-imx31.c b/arch/arm/mach-mx3/clock-imx31.c
> index 9a9eb6d..2ba7094 100644
> --- a/arch/arm/mach-mx3/clock-imx31.c
> +++ b/arch/arm/mach-mx3/clock-imx31.c
> @@ -23,8 +23,8 @@
>  #include <linux/clk.h>
>  #include <linux/err.h>
>  #include <linux/io.h>
> +#include <linux/clkdev.h>
>  
> -#include <asm/clkdev.h>
>  #include <asm/div64.h>
>  
>  #include <mach/clock.h>
> diff --git a/arch/arm/mach-mx3/clock-imx35.c b/arch/arm/mach-mx3/clock-imx35.c
> index d3af0fd..2d17c03 100644
> --- a/arch/arm/mach-mx3/clock-imx35.c
> +++ b/arch/arm/mach-mx3/clock-imx35.c
> @@ -21,8 +21,7 @@
>  #include <linux/list.h>
>  #include <linux/clk.h>
>  #include <linux/io.h>
> -
> -#include <asm/clkdev.h>
> +#include <linux/clkdev.h>
>  
>  #include <mach/clock.h>
>  #include <mach/hardware.h>
> diff --git a/arch/arm/mach-mx5/clock-mx51.c b/arch/arm/mach-mx5/clock-mx51.c
> index 6af69de..e599b6d 100644
> --- a/arch/arm/mach-mx5/clock-mx51.c
> +++ b/arch/arm/mach-mx5/clock-mx51.c
> @@ -14,8 +14,8 @@
>  #include <linux/delay.h>
>  #include <linux/clk.h>
>  #include <linux/io.h>
> +#include <linux/clkdev.h>
>  
> -#include <asm/clkdev.h>
>  #include <asm/div64.h>
>  
>  #include <mach/hardware.h>
> diff --git a/arch/arm/mach-mxc91231/clock.c b/arch/arm/mach-mxc91231/clock.c
> index 5c85075..9fab505 100644
> --- a/arch/arm/mach-mxc91231/clock.c
> +++ b/arch/arm/mach-mxc91231/clock.c
> @@ -2,12 +2,12 @@
>  #include <linux/kernel.h>
>  #include <linux/init.h>
>  #include <linux/io.h>
> +#include <linux/clkdev.h>
>  
>  #include <mach/clock.h>
>  #include <mach/hardware.h>
>  #include <mach/common.h>
>  
> -#include <asm/clkdev.h>
>  #include <asm/bug.h>
>  #include <asm/div64.h>
>  
> diff --git a/arch/arm/mach-nomadik/clock.c b/arch/arm/mach-nomadik/clock.c
> index 89f793a..48a59f2 100644
> --- a/arch/arm/mach-nomadik/clock.c
> +++ b/arch/arm/mach-nomadik/clock.c
> @@ -7,7 +7,7 @@
>  #include <linux/module.h>
>  #include <linux/errno.h>
>  #include <linux/clk.h>
> -#include <asm/clkdev.h>
> +#include <linux/clkdev.h>
>  #include "clock.h"
>  
>  /*
> diff --git a/arch/arm/mach-nuc93x/clock.h b/arch/arm/mach-nuc93x/clock.h
> index 18e51be..4de1f1d 100644
> --- a/arch/arm/mach-nuc93x/clock.h
> +++ b/arch/arm/mach-nuc93x/clock.h
> @@ -10,7 +10,7 @@
>   * the Free Software Foundation; either version 2 of the License.
>   */
>  
> -#include <asm/clkdev.h>
> +#include <linux/clkdev.h>
>  
>  void nuc93x_clk_enable(struct clk *clk, int enable);
>  void clks_register(struct clk_lookup *clks, size_t num);
> diff --git a/arch/arm/mach-omap1/clock.c b/arch/arm/mach-omap1/clock.c
> index b8c7fb9..84ef704 100644
> --- a/arch/arm/mach-omap1/clock.c
> +++ b/arch/arm/mach-omap1/clock.c
> @@ -17,9 +17,9 @@
>  #include <linux/err.h>
>  #include <linux/clk.h>
>  #include <linux/io.h>
> +#include <linux/clkdev.h>
>  
>  #include <asm/mach-types.h>
> -#include <asm/clkdev.h>
>  
>  #include <plat/cpu.h>
>  #include <plat/usb.h>
> diff --git a/arch/arm/mach-omap2/dpll3xxx.c b/arch/arm/mach-omap2/dpll3xxx.c
> index ed8d330..ebb888f 100644
> --- a/arch/arm/mach-omap2/dpll3xxx.c
> +++ b/arch/arm/mach-omap2/dpll3xxx.c
> @@ -26,10 +26,10 @@
>  #include <linux/clk.h>
>  #include <linux/io.h>
>  #include <linux/bitops.h>
> +#include <linux/clkdev.h>
>  
>  #include <plat/cpu.h>
>  #include <plat/clock.h>
> -#include <asm/clkdev.h>
>  
>  #include "clock.h"
>  #include "prm.h"
> diff --git a/arch/arm/mach-pnx4008/clock.c b/arch/arm/mach-pnx4008/clock.c
> index 9d1975f..a4a3819 100644
> --- a/arch/arm/mach-pnx4008/clock.c
> +++ b/arch/arm/mach-pnx4008/clock.c
> @@ -21,8 +21,7 @@
>  #include <linux/err.h>
>  #include <linux/delay.h>
>  #include <linux/io.h>
> -
> -#include <asm/clkdev.h>
> +#include <linux/clkdev.h>
>  
>  #include <mach/hardware.h>
>  #include <mach/clock.h>
> diff --git a/arch/arm/mach-pxa/clock.c b/arch/arm/mach-pxa/clock.c
> index abba008..4e4a84b 100644
> --- a/arch/arm/mach-pxa/clock.c
> +++ b/arch/arm/mach-pxa/clock.c
> @@ -11,8 +11,8 @@
>  #include <linux/spinlock.h>
>  #include <linux/platform_device.h>
>  #include <linux/delay.h>
> +#include <linux/clkdev.h>
>  
> -#include <asm/clkdev.h>
>  #include <mach/pxa2xx-regs.h>
>  #include <mach/hardware.h>
>  
> diff --git a/arch/arm/mach-pxa/clock.h b/arch/arm/mach-pxa/clock.h
> index d848874..12cc0e8 100644
> --- a/arch/arm/mach-pxa/clock.h
> +++ b/arch/arm/mach-pxa/clock.h
> @@ -1,4 +1,4 @@
> -#include <asm/clkdev.h>
> +#include <linux/clkdev.h>
>  
>  struct clkops {
>  	void			(*enable)(struct clk *);
> diff --git a/arch/arm/mach-realview/core.c b/arch/arm/mach-realview/core.c
> index 2fa38df..cda8b04 100644
> --- a/arch/arm/mach-realview/core.c
> +++ b/arch/arm/mach-realview/core.c
> @@ -30,8 +30,8 @@
>  #include <linux/ata_platform.h>
>  #include <linux/amba/mmci.h>
>  #include <linux/gfp.h>
> +#include <linux/clkdev.h>
>  
> -#include <asm/clkdev.h>
>  #include <asm/system.h>
>  #include <mach/hardware.h>
>  #include <asm/irq.h>
> @@ -47,7 +47,6 @@
>  
>  #include <asm/hardware/gic.h>
>  
> -#include <mach/clkdev.h>
>  #include <mach/platform.h>
>  #include <mach/irqs.h>
>  #include <plat/timer-sp.h>
> diff --git a/arch/arm/mach-shmobile/Kconfig b/arch/arm/mach-shmobile/Kconfig
> index 54b479c..f8f06e9 100644
> --- a/arch/arm/mach-shmobile/Kconfig
> +++ b/arch/arm/mach-shmobile/Kconfig
> @@ -6,7 +6,7 @@ config ARCH_SH7367
>  	bool "SH-Mobile G3 (SH7367)"
>  	select CPU_V6
>  	select HAVE_CLK
> -	select COMMON_CLKDEV
> +	select CLKDEV_LOOKUP
>  	select SH_CLK_CPG
>  	select GENERIC_CLOCKEVENTS
>  
> @@ -14,7 +14,7 @@ config ARCH_SH7377
>  	bool "SH-Mobile G4 (SH7377)"
>  	select CPU_V7
>  	select HAVE_CLK
> -	select COMMON_CLKDEV
> +	select CLKDEV_LOOKUP
>  	select SH_CLK_CPG
>  	select GENERIC_CLOCKEVENTS
>  
> @@ -22,7 +22,7 @@ config ARCH_SH7372
>  	bool "SH-Mobile AP4 (SH7372)"
>  	select CPU_V7
>  	select HAVE_CLK
> -	select COMMON_CLKDEV
> +	select CLKDEV_LOOKUP
>  	select SH_CLK_CPG
>  	select GENERIC_CLOCKEVENTS
>  
> diff --git a/arch/arm/mach-shmobile/clock-sh7367.c b/arch/arm/mach-shmobile/clock-sh7367.c
> index b6454c9..3030935 100644
> --- a/arch/arm/mach-shmobile/clock-sh7367.c
> +++ b/arch/arm/mach-shmobile/clock-sh7367.c
> @@ -20,8 +20,8 @@
>  #include <linux/kernel.h>
>  #include <linux/io.h>
>  #include <linux/sh_clk.h>
> +#include <linux/clkdev.h>
>  #include <mach/common.h>
> -#include <asm/clkdev.h>
>  
>  /* SH7367 registers */
>  #define RTFRQCR    0xe6150000
> diff --git a/arch/arm/mach-shmobile/clock-sh7372.c b/arch/arm/mach-shmobile/clock-sh7372.c
> index fb4e9b1..907f46d 100644
> --- a/arch/arm/mach-shmobile/clock-sh7372.c
> +++ b/arch/arm/mach-shmobile/clock-sh7372.c
> @@ -20,8 +20,8 @@
>  #include <linux/kernel.h>
>  #include <linux/io.h>
>  #include <linux/sh_clk.h>
> +#include <linux/clkdev.h>
>  #include <mach/common.h>
> -#include <asm/clkdev.h>
>  
>  /* SH7372 registers */
>  #define FRQCRA		0xe6150000
> diff --git a/arch/arm/mach-shmobile/clock-sh7377.c b/arch/arm/mach-shmobile/clock-sh7377.c
> index e007c28..a322c9b 100644
> --- a/arch/arm/mach-shmobile/clock-sh7377.c
> +++ b/arch/arm/mach-shmobile/clock-sh7377.c
> @@ -20,8 +20,8 @@
>  #include <linux/kernel.h>
>  #include <linux/io.h>
>  #include <linux/sh_clk.h>
> +#include <linux/clkdev.h>
>  #include <mach/common.h>
> -#include <asm/clkdev.h>
>  
>  /* SH7377 registers */
>  #define RTFRQCR    0xe6150000
> diff --git a/arch/arm/mach-tegra/clock.c b/arch/arm/mach-tegra/clock.c
> index 03ad578..cad740c 100644
> --- a/arch/arm/mach-tegra/clock.c
> +++ b/arch/arm/mach-tegra/clock.c
> @@ -24,7 +24,7 @@
>  #include <linux/debugfs.h>
>  #include <linux/slab.h>
>  #include <linux/seq_file.h>
> -#include <asm/clkdev.h>
> +#include <linux/clkdev.h>
>  
>  #include "clock.h"
>  
> diff --git a/arch/arm/mach-tegra/clock.h b/arch/arm/mach-tegra/clock.h
> index af7c70e..39a87e7 100644
> --- a/arch/arm/mach-tegra/clock.h
> +++ b/arch/arm/mach-tegra/clock.h
> @@ -21,7 +21,7 @@
>  #define __MACH_TEGRA_CLOCK_H
>  
>  #include <linux/list.h>
> -#include <asm/clkdev.h>
> +#include <linux/clkdev.h>
>  
>  #define DIV_BUS			(1 << 0)
>  #define DIV_U71			(1 << 1)
> diff --git a/arch/arm/mach-tegra/tegra2_clocks.c b/arch/arm/mach-tegra/tegra2_clocks.c
> index 4261632..d2cecbf 100644
> --- a/arch/arm/mach-tegra/tegra2_clocks.c
> +++ b/arch/arm/mach-tegra/tegra2_clocks.c
> @@ -24,8 +24,7 @@
>  #include <linux/delay.h>
>  #include <linux/io.h>
>  #include <linux/hrtimer.h>
> -
> -#include <asm/clkdev.h>
> +#include <linux/clkdev.h>
>  
>  #include <mach/iomap.h>
>  
> diff --git a/arch/arm/mach-u300/clock.c b/arch/arm/mach-u300/clock.c
> index 60acf9e..cb3ab08 100644
> --- a/arch/arm/mach-u300/clock.c
> +++ b/arch/arm/mach-u300/clock.c
> @@ -25,8 +25,8 @@
>  #include <linux/timer.h>
>  #include <linux/io.h>
>  #include <linux/seq_file.h>
> +#include <linux/clkdev.h>
>  
> -#include <asm/clkdev.h>
>  #include <mach/hardware.h>
>  #include <mach/syscon.h>
>  
> diff --git a/arch/arm/mach-ux500/clock.c b/arch/arm/mach-ux500/clock.c
> index d8ab7f1..df238ab 100644
> --- a/arch/arm/mach-ux500/clock.c
> +++ b/arch/arm/mach-ux500/clock.c
> @@ -13,8 +13,7 @@
>  #include <linux/err.h>
>  #include <linux/clk.h>
>  #include <linux/io.h>
> -
> -#include <asm/clkdev.h>
> +#include <linux/clkdev.h>
>  
>  #include <plat/mtu.h>
>  #include <mach/hardware.h>
> diff --git a/arch/arm/mach-versatile/core.c b/arch/arm/mach-versatile/core.c
> index e38acb0..8c1ca1d 100644
> --- a/arch/arm/mach-versatile/core.c
> +++ b/arch/arm/mach-versatile/core.c
> @@ -31,8 +31,8 @@
>  #include <linux/amba/pl022.h>
>  #include <linux/io.h>
>  #include <linux/gfp.h>
> +#include <linux/clkdev.h>
>  
> -#include <asm/clkdev.h>
>  #include <asm/system.h>
>  #include <asm/irq.h>
>  #include <asm/leds.h>
> @@ -46,7 +46,6 @@
>  #include <asm/mach/irq.h>
>  #include <asm/mach/time.h>
>  #include <asm/mach/map.h>
> -#include <mach/clkdev.h>
>  #include <mach/hardware.h>
>  #include <mach/platform.h>
>  #include <plat/timer-sp.h>
> diff --git a/arch/arm/mach-vexpress/ct-ca9x4.c b/arch/arm/mach-vexpress/ct-ca9x4.c
> index 577df6c..fb94f30 100644
> --- a/arch/arm/mach-vexpress/ct-ca9x4.c
> +++ b/arch/arm/mach-vexpress/ct-ca9x4.c
> @@ -8,8 +8,8 @@
>  #include <linux/platform_device.h>
>  #include <linux/amba/bus.h>
>  #include <linux/amba/clcd.h>
> +#include <linux/clkdev.h>
>  
> -#include <asm/clkdev.h>
>  #include <asm/pgtable.h>
>  #include <asm/hardware/arm_timer.h>
>  #include <asm/hardware/cache-l2x0.h>
> @@ -18,7 +18,6 @@
>  #include <asm/pmu.h>
>  #include <asm/smp_twd.h>
>  
> -#include <mach/clkdev.h>
>  #include <mach/ct-ca9x4.h>
>  
>  #include <plat/timer-sp.h>
> diff --git a/arch/arm/mach-vexpress/v2m.c b/arch/arm/mach-vexpress/v2m.c
> index 817f0ad..919103d 100644
> --- a/arch/arm/mach-vexpress/v2m.c
> +++ b/arch/arm/mach-vexpress/v2m.c
> @@ -11,15 +11,14 @@
>  #include <linux/spinlock.h>
>  #include <linux/sysdev.h>
>  #include <linux/usb/isp1760.h>
> +#include <linux/clkdev.h>
>  
> -#include <asm/clkdev.h>
>  #include <asm/sizes.h>
>  #include <asm/mach/flash.h>
>  #include <asm/mach/map.h>
>  #include <asm/mach/time.h>
>  #include <asm/hardware/arm_timer.h>
>  
> -#include <mach/clkdev.h>
>  #include <mach/motherboard.h>
>  
>  #include <plat/timer-sp.h>
> diff --git a/arch/arm/mach-w90x900/clock.h b/arch/arm/mach-w90x900/clock.h
> index c56ddab..b88a1b1 100644
> --- a/arch/arm/mach-w90x900/clock.h
> +++ b/arch/arm/mach-w90x900/clock.h
> @@ -10,7 +10,7 @@
>   * the Free Software Foundation; either version 2 of the License.
>   */
>  
> -#include <asm/clkdev.h>
> +#include <linux/clkdev.h>
>  
>  void nuc900_clk_enable(struct clk *clk, int enable);
>  void nuc900_subclk_enable(struct clk *clk, int enable);
> diff --git a/arch/arm/plat-omap/Kconfig b/arch/arm/plat-omap/Kconfig
> index e39a417..271d7b8 100644
> --- a/arch/arm/plat-omap/Kconfig
> +++ b/arch/arm/plat-omap/Kconfig
> @@ -11,13 +11,13 @@ choice
>  
>  config ARCH_OMAP1
>  	bool "TI OMAP1"
> -	select COMMON_CLKDEV
> +	select CLKDEV_LOOKUP
>  	help
>  	  "Systems based on omap7xx, omap15xx or omap16xx"
>  
>  config ARCH_OMAP2PLUS
>  	bool "TI OMAP2/3/4"
> -	select COMMON_CLKDEV
> +	select CLKDEV_LOOKUP
>  	help
>  	  "Systems based on omap24xx, omap34xx or omap44xx"
>  
> diff --git a/arch/arm/plat-omap/include/plat/clkdev_omap.h b/arch/arm/plat-omap/include/plat/clkdev_omap.h
> index bb937f3..4b2028a 100644
> --- a/arch/arm/plat-omap/include/plat/clkdev_omap.h
> +++ b/arch/arm/plat-omap/include/plat/clkdev_omap.h
> @@ -8,7 +8,7 @@
>  #ifndef __ARCH_ARM_PLAT_OMAP_INCLUDE_PLAT_CLKDEV_OMAP_H
>  #define __ARCH_ARM_PLAT_OMAP_INCLUDE_PLAT_CLKDEV_OMAP_H
>  
> -#include <asm/clkdev.h>
> +#include <linux/clkdev.h>
>  
>  struct omap_clk {
>  	u16				cpu;
> diff --git a/arch/arm/plat-spear/include/plat/clock.h b/arch/arm/plat-spear/include/plat/clock.h
> index 298bafc..2572260 100644
> --- a/arch/arm/plat-spear/include/plat/clock.h
> +++ b/arch/arm/plat-spear/include/plat/clock.h
> @@ -15,7 +15,7 @@
>  #define __PLAT_CLOCK_H
>  
>  #include <linux/list.h>
> -#include <asm/clkdev.h>
> +#include <linux/clkdev.h>
>  #include <linux/types.h>
>  
>  /* clk structure flags */
> diff --git a/arch/arm/plat-stmp3xxx/clock.c b/arch/arm/plat-stmp3xxx/clock.c
> index e593a2a..2e712e1 100644
> --- a/arch/arm/plat-stmp3xxx/clock.c
> +++ b/arch/arm/plat-stmp3xxx/clock.c
> @@ -25,9 +25,9 @@
>  #include <linux/err.h>
>  #include <linux/delay.h>
>  #include <linux/io.h>
> +#include <linux/clkdev.h>
>  
>  #include <asm/mach-types.h>
> -#include <asm/clkdev.h>
>  #include <mach/platform.h>
>  #include <mach/regs-clkctrl.h>
>  
> diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
> index 33990fa..b5f8a0f 100644
> --- a/arch/sh/Kconfig
> +++ b/arch/sh/Kconfig
> @@ -8,7 +8,7 @@ mainmenu "Linux/SuperH Kernel Configuration"
>  config SUPERH
>  	def_bool y
>  	select EMBEDDED
> -	select HAVE_CLK
> +	select CLKDEV_LOOKUP
>  	select HAVE_IDE if HAS_IOPORT
>  	select HAVE_MEMBLOCK
>  	select HAVE_OPROFILE
> diff --git a/arch/sh/boards/mach-highlander/setup.c b/arch/sh/boards/mach-highlander/setup.c
> index a5ecfba..87618c9 100644
> --- a/arch/sh/boards/mach-highlander/setup.c
> +++ b/arch/sh/boards/mach-highlander/setup.c
> @@ -24,10 +24,10 @@
>  #include <linux/interrupt.h>
>  #include <linux/usb/r8a66597.h>
>  #include <linux/usb/m66592.h>
> +#include <linux/clkdev.h>
>  #include <net/ax88796.h>
>  #include <asm/machvec.h>
>  #include <mach/highlander.h>
> -#include <asm/clkdev.h>
>  #include <asm/clock.h>
>  #include <asm/heartbeat.h>
>  #include <asm/io.h>
> diff --git a/arch/sh/include/asm/clkdev.h b/arch/sh/include/asm/clkdev.h
> dissimilarity index 69%
> index 5645f35..6ba9186 100644
> --- a/arch/sh/include/asm/clkdev.h
> +++ b/arch/sh/include/asm/clkdev.h
> @@ -1,35 +1,31 @@
> -/*
> - *  arch/sh/include/asm/clkdev.h
> - *
> - * Cloned from arch/arm/include/asm/clkdev.h:
> - *
> - *  Copyright (C) 2008 Russell King.
> - *
> - * 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.
> - *
> - * Helper for the clk API to assist looking up a struct clk.
> - */
> -#ifndef __ASM_CLKDEV_H
> -#define __ASM_CLKDEV_H
> -
> -struct clk;
> -
> -struct clk_lookup {
> -	struct list_head	node;
> -	const char		*dev_id;
> -	const char		*con_id;
> -	struct clk		*clk;
> -};
> -
> -struct clk_lookup *clkdev_alloc(struct clk *clk, const char *con_id,
> -	const char *dev_fmt, ...);
> -
> -void clkdev_add(struct clk_lookup *cl);
> -void clkdev_drop(struct clk_lookup *cl);
> -
> -void clkdev_add_table(struct clk_lookup *, size_t);
> -int clk_add_alias(const char *, const char *, char *, struct device *);
> -
> -#endif
> +/*
> + *  Copyright (C) 2010 Paul Mundt <lethal@linux-sh.org>
> + *
> + * 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.
> + *
> + * Helper for the clk API to assist looking up a struct clk.
> + */
> +
> +#ifndef __CLKDEV__H_
> +#define __CLKDEV__H_
> +
> +#include <linux/bootmem.h>
> +#include <linux/mm.h>
> +#include <linux/slab.h>
> +
> +#include <asm/clock.h>
> +
> +static inline struct clk_lookup_alloc *__clkdev_alloc(size_t size)
> +{
> +	if (!slab_is_available())
> +		return alloc_bootmem_low_pages(size);
> +	else
> +		return kzalloc(size, GFP_KERNEL);
> +}
> +
> +#define __clk_put(clk)
> +#define __clk_get(clk) ({ 1; })
> +
> +#endif /* __CLKDEV_H__ */
> diff --git a/arch/sh/kernel/Makefile b/arch/sh/kernel/Makefile
> index e25f3c6..e4fe614 100644
> --- a/arch/sh/kernel/Makefile
> +++ b/arch/sh/kernel/Makefile
> @@ -11,7 +11,7 @@ endif
>  
>  CFLAGS_REMOVE_return_address.o = -pg
>  
> -obj-y	:= clkdev.o debugtraps.o dma-nommu.o dumpstack.o 		\
> +obj-y	:= debugtraps.o dma-nommu.o dumpstack.o 			\
>  	   idle.o io.o irq.o						\
>  	   irq_$(BITS).o machvec.o nmi_debug.o process.o		\
>  	   process_$(BITS).o ptrace_$(BITS).o				\
> diff --git a/arch/sh/kernel/clkdev.c b/arch/sh/kernel/clkdev.c
> deleted file mode 100644
> index befc255..0000000
> --- a/arch/sh/kernel/clkdev.c
> +++ /dev/null
> @@ -1,169 +0,0 @@
> -/*
> - * arch/sh/kernel/clkdev.c
> - *
> - * Cloned from arch/arm/common/clkdev.c:
> - *
> - *  Copyright (C) 2008 Russell King.
> - *
> - * 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.
> - *
> - * Helper for the clk API to assist looking up a struct clk.
> - */
> -#include <linux/module.h>
> -#include <linux/kernel.h>
> -#include <linux/device.h>
> -#include <linux/list.h>
> -#include <linux/errno.h>
> -#include <linux/err.h>
> -#include <linux/string.h>
> -#include <linux/mutex.h>
> -#include <linux/clk.h>
> -#include <linux/slab.h>
> -#include <linux/bootmem.h>
> -#include <linux/mm.h>
> -#include <asm/clock.h>
> -#include <asm/clkdev.h>
> -
> -static LIST_HEAD(clocks);
> -static DEFINE_MUTEX(clocks_mutex);
> -
> -/*
> - * Find the correct struct clk for the device and connection ID.
> - * We do slightly fuzzy matching here:
> - *  An entry with a NULL ID is assumed to be a wildcard.
> - *  If an entry has a device ID, it must match
> - *  If an entry has a connection ID, it must match
> - * Then we take the most specific entry - with the following
> - * order of precedence: dev+con > dev only > con only.
> - */
> -static struct clk *clk_find(const char *dev_id, const char *con_id)
> -{
> -	struct clk_lookup *p;
> -	struct clk *clk = NULL;
> -	int match, best = 0;
> -
> -	list_for_each_entry(p, &clocks, node) {
> -		match = 0;
> -		if (p->dev_id) {
> -			if (!dev_id || strcmp(p->dev_id, dev_id))
> -				continue;
> -			match += 2;
> -		}
> -		if (p->con_id) {
> -			if (!con_id || strcmp(p->con_id, con_id))
> -				continue;
> -			match += 1;
> -		}
> -		if (match == 0)
> -			continue;
> -
> -		if (match > best) {
> -			clk = p->clk;
> -			best = match;
> -		}
> -	}
> -	return clk;
> -}
> -
> -struct clk *clk_get_sys(const char *dev_id, const char *con_id)
> -{
> -	struct clk *clk;
> -
> -	mutex_lock(&clocks_mutex);
> -	clk = clk_find(dev_id, con_id);
> -	mutex_unlock(&clocks_mutex);
> -
> -	return clk ? clk : ERR_PTR(-ENOENT);
> -}
> -EXPORT_SYMBOL(clk_get_sys);
> -
> -void clkdev_add(struct clk_lookup *cl)
> -{
> -	mutex_lock(&clocks_mutex);
> -	list_add_tail(&cl->node, &clocks);
> -	mutex_unlock(&clocks_mutex);
> -}
> -EXPORT_SYMBOL(clkdev_add);
> -
> -void __init clkdev_add_table(struct clk_lookup *cl, size_t num)
> -{
> -	mutex_lock(&clocks_mutex);
> -	while (num--) {
> -		list_add_tail(&cl->node, &clocks);
> -		cl++;
> -	}
> -	mutex_unlock(&clocks_mutex);
> -}
> -
> -#define MAX_DEV_ID	20
> -#define MAX_CON_ID	16
> -
> -struct clk_lookup_alloc {
> -	struct clk_lookup cl;
> -	char	dev_id[MAX_DEV_ID];
> -	char	con_id[MAX_CON_ID];
> -};
> -
> -struct clk_lookup * __init_refok
> -clkdev_alloc(struct clk *clk, const char *con_id, const char *dev_fmt, ...)
> -{
> -	struct clk_lookup_alloc *cla;
> -
> -	if (!slab_is_available())
> -		cla = alloc_bootmem_low_pages(sizeof(*cla));
> -	else
> -		cla = kzalloc(sizeof(*cla), GFP_KERNEL);
> -
> -	if (!cla)
> -		return NULL;
> -
> -	cla->cl.clk = clk;
> -	if (con_id) {
> -		strlcpy(cla->con_id, con_id, sizeof(cla->con_id));
> -		cla->cl.con_id = cla->con_id;
> -	}
> -
> -	if (dev_fmt) {
> -		va_list ap;
> -
> -		va_start(ap, dev_fmt);
> -		vscnprintf(cla->dev_id, sizeof(cla->dev_id), dev_fmt, ap);
> -		cla->cl.dev_id = cla->dev_id;
> -		va_end(ap);
> -	}
> -
> -	return &cla->cl;
> -}
> -EXPORT_SYMBOL(clkdev_alloc);
> -
> -int clk_add_alias(const char *alias, const char *alias_dev_name, char *id,
> -	struct device *dev)
> -{
> -	struct clk *r = clk_get(dev, id);
> -	struct clk_lookup *l;
> -
> -	if (IS_ERR(r))
> -		return PTR_ERR(r);
> -
> -	l = clkdev_alloc(r, alias, alias_dev_name);
> -	clk_put(r);
> -	if (!l)
> -		return -ENODEV;
> -	clkdev_add(l);
> -	return 0;
> -}
> -EXPORT_SYMBOL(clk_add_alias);
> -
> -/*
> - * clkdev_drop - remove a clock dynamically allocated
> - */
> -void clkdev_drop(struct clk_lookup *cl)
> -{
> -	mutex_lock(&clocks_mutex);
> -	list_del(&cl->node);
> -	mutex_unlock(&clocks_mutex);
> -	kfree(cl);
> -}
> -EXPORT_SYMBOL(clkdev_drop);
> diff --git a/arch/sh/kernel/cpu/clock-cpg.c b/arch/sh/kernel/cpu/clock-cpg.c
> index e2f63d6..dd0e0f2 100644
> --- a/arch/sh/kernel/cpu/clock-cpg.c
> +++ b/arch/sh/kernel/cpu/clock-cpg.c
> @@ -2,7 +2,7 @@
>  #include <linux/compiler.h>
>  #include <linux/slab.h>
>  #include <linux/io.h>
> -#include <asm/clkdev.h>
> +#include <linux/clkdev.h>
>  #include <asm/clock.h>
>  
>  static struct clk master_clk = {
> diff --git a/arch/sh/kernel/cpu/clock.c b/arch/sh/kernel/cpu/clock.c
> index 50f887d..4187cf4 100644
> --- a/arch/sh/kernel/cpu/clock.c
> +++ b/arch/sh/kernel/cpu/clock.c
> @@ -48,20 +48,4 @@ int __init clk_init(void)
>  	return ret;
>  }
>  
> -/*
> - * Returns a clock. Note that we first try to use device id on the bus
> - * and clock name. If this fails, we try to use clock name only.
> - */
> -struct clk *clk_get(struct device *dev, const char *con_id)
> -{
> -	const char *dev_id = dev ? dev_name(dev) : NULL;
> -
> -	return clk_get_sys(dev_id, con_id);
> -}
> -EXPORT_SYMBOL_GPL(clk_get);
> -
> -void clk_put(struct clk *clk)
> -{
> -}
> -EXPORT_SYMBOL_GPL(clk_put);
>  
> diff --git a/arch/sh/kernel/cpu/sh4/clock-sh4-202.c b/arch/sh/kernel/cpu/sh4/clock-sh4-202.c
> index 4eabc68..6c1492b 100644
> --- a/arch/sh/kernel/cpu/sh4/clock-sh4-202.c
> +++ b/arch/sh/kernel/cpu/sh4/clock-sh4-202.c
> @@ -13,7 +13,7 @@
>  #include <linux/kernel.h>
>  #include <linux/err.h>
>  #include <linux/io.h>
> -#include <asm/clkdev.h>
> +#include <linux/clkdev.h>
>  #include <asm/clock.h>
>  #include <asm/freq.h>
>  
> diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7343.c b/arch/sh/kernel/cpu/sh4a/clock-sh7343.c
> index 71291ae..93c6460 100644
> --- a/arch/sh/kernel/cpu/sh4a/clock-sh7343.c
> +++ b/arch/sh/kernel/cpu/sh4a/clock-sh7343.c
> @@ -21,7 +21,7 @@
>  #include <linux/init.h>
>  #include <linux/kernel.h>
>  #include <linux/io.h>
> -#include <asm/clkdev.h>
> +#include <linux/clkdev.h>
>  #include <asm/clock.h>
>  
>  /* SH7343 registers */
> diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7366.c b/arch/sh/kernel/cpu/sh4a/clock-sh7366.c
> index 7ce5bbc..049dc06 100644
> --- a/arch/sh/kernel/cpu/sh4a/clock-sh7366.c
> +++ b/arch/sh/kernel/cpu/sh4a/clock-sh7366.c
> @@ -21,7 +21,7 @@
>  #include <linux/init.h>
>  #include <linux/kernel.h>
>  #include <linux/io.h>
> -#include <asm/clkdev.h>
> +#include <linux/clkdev.h>
>  #include <asm/clock.h>
>  
>  /* SH7366 registers */
> diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7722.c b/arch/sh/kernel/cpu/sh4a/clock-sh7722.c
> index 2030f3d..9d23a36 100644
> --- a/arch/sh/kernel/cpu/sh4a/clock-sh7722.c
> +++ b/arch/sh/kernel/cpu/sh4a/clock-sh7722.c
> @@ -21,7 +21,7 @@
>  #include <linux/init.h>
>  #include <linux/kernel.h>
>  #include <linux/io.h>
> -#include <asm/clkdev.h>
> +#include <linux/clkdev.h>
>  #include <asm/clock.h>
>  #include <asm/hwblk.h>
>  #include <cpu/sh7722.h>
> diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7723.c b/arch/sh/kernel/cpu/sh4a/clock-sh7723.c
> index d3938f0..55493cd 100644
> --- a/arch/sh/kernel/cpu/sh4a/clock-sh7723.c
> +++ b/arch/sh/kernel/cpu/sh4a/clock-sh7723.c
> @@ -22,7 +22,7 @@
>  #include <linux/kernel.h>
>  #include <linux/io.h>
>  #include <linux/clk.h>
> -#include <asm/clkdev.h>
> +#include <linux/clkdev.h>
>  #include <asm/clock.h>
>  #include <asm/hwblk.h>
>  #include <cpu/sh7723.h>
> diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7724.c b/arch/sh/kernel/cpu/sh4a/clock-sh7724.c
> index 2d9700c..527936b 100644
> --- a/arch/sh/kernel/cpu/sh4a/clock-sh7724.c
> +++ b/arch/sh/kernel/cpu/sh4a/clock-sh7724.c
> @@ -22,7 +22,7 @@
>  #include <linux/kernel.h>
>  #include <linux/io.h>
>  #include <linux/clk.h>
> -#include <asm/clkdev.h>
> +#include <linux/clkdev.h>
>  #include <asm/clock.h>
>  #include <asm/hwblk.h>
>  #include <cpu/sh7724.h>
> diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7757.c b/arch/sh/kernel/cpu/sh4a/clock-sh7757.c
> index 0a752bd..589ee0a 100644
> --- a/arch/sh/kernel/cpu/sh4a/clock-sh7757.c
> +++ b/arch/sh/kernel/cpu/sh4a/clock-sh7757.c
> @@ -12,7 +12,7 @@
>  #include <linux/init.h>
>  #include <linux/kernel.h>
>  #include <linux/io.h>
> -#include <asm/clkdev.h>
> +#include <linux/clkdev.h>
>  #include <asm/clock.h>
>  #include <asm/freq.h>
>  
> diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7763.c b/arch/sh/kernel/cpu/sh4a/clock-sh7763.c
> index 1f1df48..599630f 100644
> --- a/arch/sh/kernel/cpu/sh4a/clock-sh7763.c
> +++ b/arch/sh/kernel/cpu/sh4a/clock-sh7763.c
> @@ -13,7 +13,7 @@
>  #include <linux/init.h>
>  #include <linux/kernel.h>
>  #include <linux/io.h>
> -#include <asm/clkdev.h>
> +#include <linux/clkdev.h>
>  #include <asm/clock.h>
>  #include <asm/freq.h>
>  #include <asm/io.h>
> diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7780.c b/arch/sh/kernel/cpu/sh4a/clock-sh7780.c
> index 62d7063..8894926 100644
> --- a/arch/sh/kernel/cpu/sh4a/clock-sh7780.c
> +++ b/arch/sh/kernel/cpu/sh4a/clock-sh7780.c
> @@ -12,7 +12,7 @@
>  #include <linux/init.h>
>  #include <linux/kernel.h>
>  #include <linux/io.h>
> -#include <asm/clkdev.h>
> +#include <linux/clkdev.h>
>  #include <asm/clock.h>
>  #include <asm/freq.h>
>  #include <asm/io.h>
> diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7785.c b/arch/sh/kernel/cpu/sh4a/clock-sh7785.c
> index c3e458a..2d96024 100644
> --- a/arch/sh/kernel/cpu/sh4a/clock-sh7785.c
> +++ b/arch/sh/kernel/cpu/sh4a/clock-sh7785.c
> @@ -14,7 +14,7 @@
>  #include <linux/clk.h>
>  #include <linux/io.h>
>  #include <linux/cpufreq.h>
> -#include <asm/clkdev.h>
> +#include <linux/clkdev.h>
>  #include <asm/clock.h>
>  #include <asm/freq.h>
>  #include <cpu/sh7785.h>
> diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7786.c b/arch/sh/kernel/cpu/sh4a/clock-sh7786.c
> index 597c9fb..42e403b 100644
> --- a/arch/sh/kernel/cpu/sh4a/clock-sh7786.c
> +++ b/arch/sh/kernel/cpu/sh4a/clock-sh7786.c
> @@ -13,7 +13,7 @@
>  #include <linux/kernel.h>
>  #include <linux/clk.h>
>  #include <linux/io.h>
> -#include <asm/clkdev.h>
> +#include <linux/clkdev.h>
>  #include <asm/clock.h>
>  #include <asm/freq.h>
>  
> diff --git a/arch/sh/kernel/cpu/sh4a/clock-shx3.c b/arch/sh/kernel/cpu/sh4a/clock-shx3.c
> index 236a628..228d7e6 100644
> --- a/arch/sh/kernel/cpu/sh4a/clock-shx3.c
> +++ b/arch/sh/kernel/cpu/sh4a/clock-shx3.c
> @@ -14,7 +14,7 @@
>  #include <linux/init.h>
>  #include <linux/kernel.h>
>  #include <linux/io.h>
> -#include <asm/clkdev.h>
> +#include <linux/clkdev.h>
>  #include <asm/clock.h>
>  #include <asm/freq.h>
>  
> diff --git a/drivers/Kconfig b/drivers/Kconfig
> index a2b902f..3d93b3a 100644
> --- a/drivers/Kconfig
> +++ b/drivers/Kconfig
> @@ -111,4 +111,6 @@ source "drivers/xen/Kconfig"
>  source "drivers/staging/Kconfig"
>  
>  source "drivers/platform/Kconfig"
> +
> +source "drivers/clk/Kconfig"
>  endmenu
> diff --git a/drivers/Makefile b/drivers/Makefile
> index ae47344..b0e30b2 100644
> --- a/drivers/Makefile
> +++ b/drivers/Makefile
> @@ -115,3 +115,5 @@ obj-$(CONFIG_VLYNQ)		+= vlynq/
>  obj-$(CONFIG_STAGING)		+= staging/
>  obj-y				+= platform/
>  obj-y				+= ieee802154/
> +#common clk code
> +obj-y				+= clk/
> diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig
> new file mode 100644
> index 0000000..4168c88
> --- /dev/null
> +++ b/drivers/clk/Kconfig
> @@ -0,0 +1,4 @@
> +
> +config CLKDEV_LOOKUP
> +	bool
> +	select HAVE_CLK
> diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
> new file mode 100644
> index 0000000..07613fa
> --- /dev/null
> +++ b/drivers/clk/Makefile
> @@ -0,0 +1,2 @@
> +
> +obj-$(CONFIG_CLKDEV_LOOKUP)	+= clkdev.o
> diff --git a/arch/arm/common/clkdev.c b/drivers/clk/clkdev.c
> similarity index 91%
> rename from arch/arm/common/clkdev.c
> rename to drivers/clk/clkdev.c
> index e2b2bb6..d8b91ae 100644
> --- a/arch/arm/common/clkdev.c
> +++ b/drivers/clk/clkdev.c
> @@ -1,5 +1,5 @@
>  /*
> - *  arch/arm/common/clkdev.c
> + * drivers/clk/clkdev.c
>   *
>   *  Copyright (C) 2008 Russell King.
>   *
> @@ -18,10 +18,7 @@
>  #include <linux/string.h>
>  #include <linux/mutex.h>
>  #include <linux/clk.h>
> -#include <linux/slab.h>
> -
> -#include <asm/clkdev.h>
> -#include <mach/clkdev.h>
> +#include <linux/clkdev.h>
>  
>  static LIST_HEAD(clocks);
>  static DEFINE_MUTEX(clocks_mutex);
> @@ -79,6 +76,10 @@ struct clk *clk_get_sys(const char *dev_id, const char *con_id)
>  }
>  EXPORT_SYMBOL(clk_get_sys);
>  
> +/*
> + * Returns a clock. Note that we first try to use device id on the bus
> + * and clock name. If this fails, we try to use clock name only.
> + */
>  struct clk *clk_get(struct device *dev, const char *con_id)
>  {
>  	const char *dev_id = dev ? dev_name(dev) : NULL;
> @@ -120,12 +121,12 @@ struct clk_lookup_alloc {
>  	char	con_id[MAX_CON_ID];
>  };
>  
> -struct clk_lookup *clkdev_alloc(struct clk *clk, const char *con_id,
> -	const char *dev_fmt, ...)
> +struct clk_lookup * __init_refok
> +clkdev_alloc(struct clk *clk, const char *con_id, const char *dev_fmt, ...)
I'm not very satisfied by Russell's answer.  But even if I accept that
it should not move to .init.text, why .ref.text?  If I'm not mistaken
clkdev_alloc references the following non-local symbols:

	__clkdev_alloc
	strlcpy
	vscnprintf

non of these are in .init, so I think it's not needed.

Russell, would at least __module_or_init be OK?
 
Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [PATCH V3] arm & sh: factorised duplicated clkdev.c
  2010-09-02 12:48   ` Jean-Christophe PLAGNIOL-VILLARD
@ 2010-09-02 13:39     ` Jean-Christophe PLAGNIOL-VILLARD
  -1 siblings, 0 replies; 133+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2010-09-02 13:39 UTC (permalink / raw)
  To: linux-sh

factorise some generic infrastructure to assist looking up struct clks
for the ARM & SH architecture.

as the code is identical at 99%

put the arch specific code for allocation as example in asm/clkdev.h

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
v3:
	wrong comment removed
	headers fixed

Best Regards,
J.
 arch/arm/Kconfig                                |   40 +++---
 arch/arm/common/Kconfig                         |    4 -
 arch/arm/common/Makefile                        |    1 -
 arch/arm/include/asm/clkdev.h                   |   22 +--
 arch/arm/mach-bcmring/clock.c                   |    3 +-
 arch/arm/mach-bcmring/core.c                    |    2 +-
 arch/arm/mach-davinci/clock.h                   |    2 +-
 arch/arm/mach-ep93xx/clock.c                    |    2 +-
 arch/arm/mach-imx/clock-imx1.c                  |    3 +-
 arch/arm/mach-imx/clock-imx21.c                 |    2 +-
 arch/arm/mach-imx/clock-imx27.c                 |    2 +-
 arch/arm/mach-integrator/core.c                 |    3 +-
 arch/arm/mach-integrator/impd1.c                |    3 +-
 arch/arm/mach-integrator/integrator_cp.c        |    3 +-
 arch/arm/mach-lpc32xx/clock.c                   |    3 +-
 arch/arm/mach-mmp/clock.h                       |    2 +-
 arch/arm/mach-mx25/clock.c                      |    3 +-
 arch/arm/mach-mx3/clock-imx31.c                 |    2 +-
 arch/arm/mach-mx3/clock-imx35.c                 |    3 +-
 arch/arm/mach-mx5/clock-mx51.c                  |    2 +-
 arch/arm/mach-mxc91231/clock.c                  |    2 +-
 arch/arm/mach-nomadik/clock.c                   |    2 +-
 arch/arm/mach-nuc93x/clock.h                    |    2 +-
 arch/arm/mach-omap1/clock.c                     |    2 +-
 arch/arm/mach-omap2/dpll3xxx.c                  |    2 +-
 arch/arm/mach-pnx4008/clock.c                   |    3 +-
 arch/arm/mach-pxa/clock.c                       |    2 +-
 arch/arm/mach-pxa/clock.h                       |    2 +-
 arch/arm/mach-realview/core.c                   |    3 +-
 arch/arm/mach-shmobile/Kconfig                  |    6 +-
 arch/arm/mach-shmobile/clock-sh7367.c           |    2 +-
 arch/arm/mach-shmobile/clock-sh7372.c           |    2 +-
 arch/arm/mach-shmobile/clock-sh7377.c           |    2 +-
 arch/arm/mach-tegra/clock.c                     |    2 +-
 arch/arm/mach-tegra/clock.h                     |    2 +-
 arch/arm/mach-tegra/tegra2_clocks.c             |    3 +-
 arch/arm/mach-u300/clock.c                      |    2 +-
 arch/arm/mach-ux500/clock.c                     |    3 +-
 arch/arm/mach-versatile/core.c                  |    3 +-
 arch/arm/mach-vexpress/ct-ca9x4.c               |    3 +-
 arch/arm/mach-vexpress/v2m.c                    |    3 +-
 arch/arm/mach-w90x900/clock.h                   |    2 +-
 arch/arm/plat-omap/Kconfig                      |    4 +-
 arch/arm/plat-omap/include/plat/clkdev_omap.h   |    2 +-
 arch/arm/plat-spear/include/plat/clock.h        |    2 +-
 arch/arm/plat-stmp3xxx/clock.c                  |    2 +-
 arch/sh/Kconfig                                 |    2 +-
 arch/sh/boards/mach-highlander/setup.c          |    2 +-
 arch/sh/include/asm/clkdev.h                    |   66 ++++-----
 arch/sh/kernel/Makefile                         |    2 +-
 arch/sh/kernel/clkdev.c                         |  169 -----------------------
 arch/sh/kernel/cpu/clock-cpg.c                  |    2 +-
 arch/sh/kernel/cpu/clock.c                      |   16 --
 arch/sh/kernel/cpu/sh4/clock-sh4-202.c          |    2 +-
 arch/sh/kernel/cpu/sh4a/clock-sh7343.c          |    2 +-
 arch/sh/kernel/cpu/sh4a/clock-sh7366.c          |    2 +-
 arch/sh/kernel/cpu/sh4a/clock-sh7722.c          |    2 +-
 arch/sh/kernel/cpu/sh4a/clock-sh7723.c          |    2 +-
 arch/sh/kernel/cpu/sh4a/clock-sh7724.c          |    2 +-
 arch/sh/kernel/cpu/sh4a/clock-sh7757.c          |    2 +-
 arch/sh/kernel/cpu/sh4a/clock-sh7763.c          |    2 +-
 arch/sh/kernel/cpu/sh4a/clock-sh7780.c          |    2 +-
 arch/sh/kernel/cpu/sh4a/clock-sh7785.c          |    2 +-
 arch/sh/kernel/cpu/sh4a/clock-sh7786.c          |    2 +-
 arch/sh/kernel/cpu/sh4a/clock-shx3.c            |    2 +-
 drivers/Kconfig                                 |    2 +
 drivers/Makefile                                |    2 +
 drivers/clk/Kconfig                             |    4 +
 drivers/clk/Makefile                            |    2 +
 {arch/arm/common => drivers/clk}/clkdev.c       |   13 +-
 {arch/sh/include/asm => include/linux}/clkdev.h |   11 +-
 71 files changed, 139 insertions(+), 350 deletions(-)
 rewrite arch/sh/include/asm/clkdev.h (69%)
 delete mode 100644 arch/sh/kernel/clkdev.c
 create mode 100644 drivers/clk/Kconfig
 create mode 100644 drivers/clk/Makefile
 rename {arch/arm/common => drivers/clk}/clkdev.c (93%)
 rename {arch/sh/include/asm => include/linux}/clkdev.h (85%)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index a7ed21f..1d8a26c 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -221,7 +221,7 @@ config ARCH_INTEGRATOR
 	bool "ARM Ltd. Integrator family"
 	select ARM_AMBA
 	select ARCH_HAS_CPUFREQ
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	select ICST
 	select GENERIC_CLOCKEVENTS
 	select PLAT_VERSATILE
@@ -231,7 +231,7 @@ config ARCH_INTEGRATOR
 config ARCH_REALVIEW
 	bool "ARM Ltd. RealView family"
 	select ARM_AMBA
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	select ICST
 	select GENERIC_CLOCKEVENTS
 	select ARCH_WANT_OPTIONAL_GPIOLIB
@@ -245,7 +245,7 @@ config ARCH_VERSATILE
 	bool "ARM Ltd. Versatile family"
 	select ARM_AMBA
 	select ARM_VIC
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	select ICST
 	select GENERIC_CLOCKEVENTS
 	select ARCH_WANT_OPTIONAL_GPIOLIB
@@ -259,7 +259,7 @@ config ARCH_VEXPRESS
 	select ARCH_WANT_OPTIONAL_GPIOLIB
 	select ARM_AMBA
 	select ARM_TIMER_SP804
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	select GENERIC_CLOCKEVENTS
 	select HAVE_CLK
 	select ICST
@@ -281,7 +281,7 @@ config ARCH_BCMRING
 	depends on MMU
 	select CPU_V6
 	select ARM_AMBA
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	select GENERIC_CLOCKEVENTS
 	select ARCH_WANT_OPTIONAL_GPIOLIB
 	help
@@ -328,7 +328,7 @@ config ARCH_EP93XX
 	select CPU_ARM920T
 	select ARM_AMBA
 	select ARM_VIC
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	select ARCH_REQUIRE_GPIOLIB
 	select ARCH_HAS_HOLES_MEMORYMODEL
 	select ARCH_USES_GETTIMEOFFSET
@@ -348,14 +348,14 @@ config ARCH_MXC
 	bool "Freescale MXC/iMX-based"
 	select GENERIC_CLOCKEVENTS
 	select ARCH_REQUIRE_GPIOLIB
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	help
 	  Support for Freescale MXC/iMX-based family of processors
 
 config ARCH_STMP3XXX
 	bool "Freescale STMP3xxx"
 	select CPU_ARM926T
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	select ARCH_REQUIRE_GPIOLIB
 	select GENERIC_CLOCKEVENTS
 	select USB_ARCH_HAS_EHCI
@@ -473,7 +473,7 @@ config ARCH_LPC32XX
 	select HAVE_IDE
 	select ARM_AMBA
 	select USB_ARCH_HAS_OHCI
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	select GENERIC_TIME
 	select GENERIC_CLOCKEVENTS
 	help
@@ -507,7 +507,7 @@ config ARCH_MMP
 	bool "Marvell PXA168/910/MMP2"
 	depends on MMU
 	select ARCH_REQUIRE_GPIOLIB
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	select GENERIC_CLOCKEVENTS
 	select TICK_ONESHOT
 	select PLAT_PXA
@@ -539,7 +539,7 @@ config ARCH_W90X900
 	bool "Nuvoton W90X900 CPU"
 	select CPU_ARM926T
 	select ARCH_REQUIRE_GPIOLIB
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	select GENERIC_CLOCKEVENTS
 	help
 	  Support for Nuvoton (Winbond logic dept.) ARM9 processor,
@@ -553,7 +553,7 @@ config ARCH_W90X900
 config ARCH_NUC93X
 	bool "Nuvoton NUC93X CPU"
 	select CPU_ARM926T
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	help
 	  Support for Nuvoton (Winbond logic dept.) NUC93X MCU,The NUC93X is a
 	  low-power and high performance MPEG-4/JPEG multimedia controller chip.
@@ -564,7 +564,7 @@ config ARCH_TEGRA
 	select GENERIC_CLOCKEVENTS
 	select GENERIC_GPIO
 	select HAVE_CLK
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	select ARCH_HAS_BARRIERS if CACHE_L2X0
 	help
 	  This enables support for NVIDIA Tegra based systems (Tegra APX,
@@ -573,7 +573,7 @@ config ARCH_TEGRA
 config ARCH_PNX4008
 	bool "Philips Nexperia PNX4008 Mobile"
 	select CPU_ARM926T
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	select ARCH_USES_GETTIMEOFFSET
 	help
 	  This enables support for Philips PNX4008 mobile platform.
@@ -583,7 +583,7 @@ config ARCH_PXA
 	depends on MMU
 	select ARCH_MTD_XIP
 	select ARCH_HAS_CPUFREQ
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	select ARCH_REQUIRE_GPIOLIB
 	select GENERIC_CLOCKEVENTS
 	select TICK_ONESHOT
@@ -767,7 +767,7 @@ config ARCH_U300
 	select ARM_AMBA
 	select ARM_VIC
 	select GENERIC_CLOCKEVENTS
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	select GENERIC_GPIO
 	help
 	  Support for ST-Ericsson U300 series mobile platforms.
@@ -777,7 +777,7 @@ config ARCH_U8500
 	select CPU_V7
 	select ARM_AMBA
 	select GENERIC_CLOCKEVENTS
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	select ARCH_REQUIRE_GPIOLIB
 	help
 	  Support for ST-Ericsson's Ux500 architecture
@@ -787,7 +787,7 @@ config ARCH_NOMADIK
 	select ARM_AMBA
 	select ARM_VIC
 	select CPU_ARM926T
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	select GENERIC_CLOCKEVENTS
 	select ARCH_REQUIRE_GPIOLIB
 	help
@@ -799,7 +799,7 @@ config ARCH_DAVINCI
 	select ARCH_REQUIRE_GPIOLIB
 	select ZONE_DMA
 	select HAVE_IDE
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	select GENERIC_ALLOCATOR
 	select ARCH_HAS_HOLES_MEMORYMODEL
 	help
@@ -819,7 +819,7 @@ config PLAT_SPEAR
 	bool "ST SPEAr"
 	select ARM_AMBA
 	select ARCH_REQUIRE_GPIOLIB
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	select GENERIC_CLOCKEVENTS
 	select HAVE_CLK
 	help
diff --git a/arch/arm/common/Kconfig b/arch/arm/common/Kconfig
index 0a34c81..778655f 100644
--- a/arch/arm/common/Kconfig
+++ b/arch/arm/common/Kconfig
@@ -37,7 +37,3 @@ config SHARP_PARAM
 
 config SHARP_SCOOP
 	bool
-
-config COMMON_CLKDEV
-	bool
-	select HAVE_CLK
diff --git a/arch/arm/common/Makefile b/arch/arm/common/Makefile
index e6e8664..799e140 100644
--- a/arch/arm/common/Makefile
+++ b/arch/arm/common/Makefile
@@ -16,4 +16,3 @@ obj-$(CONFIG_SHARP_SCOOP)	+= scoop.o
 obj-$(CONFIG_ARCH_IXP2000)	+= uengine.o
 obj-$(CONFIG_ARCH_IXP23XX)	+= uengine.o
 obj-$(CONFIG_PCI_HOST_ITE8152)  += it8152.o
-obj-$(CONFIG_COMMON_CLKDEV)	+= clkdev.o
diff --git a/arch/arm/include/asm/clkdev.h b/arch/arm/include/asm/clkdev.h
index b56c138..765d332 100644
--- a/arch/arm/include/asm/clkdev.h
+++ b/arch/arm/include/asm/clkdev.h
@@ -12,23 +12,13 @@
 #ifndef __ASM_CLKDEV_H
 #define __ASM_CLKDEV_H
 
-struct clk;
-struct device;
+#include <linux/slab.h>
 
-struct clk_lookup {
-	struct list_head	node;
-	const char		*dev_id;
-	const char		*con_id;
-	struct clk		*clk;
-};
+#include <mach/clkdev.h>
 
-struct clk_lookup *clkdev_alloc(struct clk *clk, const char *con_id,
-	const char *dev_fmt, ...);
-
-void clkdev_add(struct clk_lookup *cl);
-void clkdev_drop(struct clk_lookup *cl);
-
-void clkdev_add_table(struct clk_lookup *, size_t);
-int clk_add_alias(const char *, const char *, char *, struct device *);
+static inline struct clk_lookup_alloc *__clkdev_alloc(size_t size)
+{
+	return kzalloc(size, GFP_KERNEL);
+}
 
 #endif
diff --git a/arch/arm/mach-bcmring/clock.c b/arch/arm/mach-bcmring/clock.c
index 14bafc3..ad237a4 100644
--- a/arch/arm/mach-bcmring/clock.c
+++ b/arch/arm/mach-bcmring/clock.c
@@ -21,13 +21,12 @@
 #include <linux/string.h>
 #include <linux/clk.h>
 #include <linux/spinlock.h>
+#include <linux/clkdev.h>
 #include <mach/csp/hw_cfg.h>
 #include <mach/csp/chipcHw_def.h>
 #include <mach/csp/chipcHw_reg.h>
 #include <mach/csp/chipcHw_inline.h>
 
-#include <asm/clkdev.h>
-
 #include "clock.h"
 
 #define clk_is_primary(x)       ((x)->type & CLK_TYPE_PRIMARY)
diff --git a/arch/arm/mach-bcmring/core.c b/arch/arm/mach-bcmring/core.c
index d3f959e..ed96ef4 100644
--- a/arch/arm/mach-bcmring/core.c
+++ b/arch/arm/mach-bcmring/core.c
@@ -30,10 +30,10 @@
 #include <linux/amba/bus.h>
 #include <linux/clocksource.h>
 #include <linux/clockchips.h>
+#include <linux/clkdev.h>
 
 #include <mach/csp/mm_addr.h>
 #include <mach/hardware.h>
-#include <asm/clkdev.h>
 #include <linux/io.h>
 #include <asm/irq.h>
 #include <asm/hardware/arm_timer.h>
diff --git a/arch/arm/mach-davinci/clock.h b/arch/arm/mach-davinci/clock.h
index 01e3648..64c58ad 100644
--- a/arch/arm/mach-davinci/clock.h
+++ b/arch/arm/mach-davinci/clock.h
@@ -68,7 +68,7 @@
 #ifndef __ASSEMBLER__
 
 #include <linux/list.h>
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 
 struct pll_data {
 	u32 phys_base;
diff --git a/arch/arm/mach-ep93xx/clock.c b/arch/arm/mach-ep93xx/clock.c
index 8bf3cec..f60d636 100644
--- a/arch/arm/mach-ep93xx/clock.c
+++ b/arch/arm/mach-ep93xx/clock.c
@@ -19,10 +19,10 @@
 #include <linux/string.h>
 #include <linux/io.h>
 #include <linux/spinlock.h>
+#include <linux/clkdev.h>
 
 #include <mach/hardware.h>
 
-#include <asm/clkdev.h>
 #include <asm/div64.h>
 
 
diff --git a/arch/arm/mach-imx/clock-imx1.c b/arch/arm/mach-imx/clock-imx1.c
index c05096c..9c848d9 100644
--- a/arch/arm/mach-imx/clock-imx1.c
+++ b/arch/arm/mach-imx/clock-imx1.c
@@ -22,8 +22,7 @@
 #include <linux/err.h>
 #include <linux/clk.h>
 #include <linux/io.h>
-
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 
 #include <mach/clock.h>
 #include <mach/hardware.h>
diff --git a/arch/arm/mach-imx/clock-imx21.c b/arch/arm/mach-imx/clock-imx21.c
index bb419ef..19e966e 100644
--- a/arch/arm/mach-imx/clock-imx21.c
+++ b/arch/arm/mach-imx/clock-imx21.c
@@ -21,11 +21,11 @@
 #include <linux/clk.h>
 #include <linux/io.h>
 #include <linux/module.h>
+#include <linux/clkdev.h>
 
 #include <mach/clock.h>
 #include <mach/hardware.h>
 #include <mach/common.h>
-#include <asm/clkdev.h>
 #include <asm/div64.h>
 
 #define IO_ADDR_CCM(off)	(MX21_IO_ADDRESS(MX21_CCM_BASE_ADDR + (off)))
diff --git a/arch/arm/mach-imx/clock-imx27.c b/arch/arm/mach-imx/clock-imx27.c
index 5a1aa15..f121114 100644
--- a/arch/arm/mach-imx/clock-imx27.c
+++ b/arch/arm/mach-imx/clock-imx27.c
@@ -21,8 +21,8 @@
 #include <linux/clk.h>
 #include <linux/io.h>
 #include <linux/module.h>
+#include <linux/clkdev.h>
 
-#include <asm/clkdev.h>
 #include <asm/div64.h>
 
 #include <mach/clock.h>
diff --git a/arch/arm/mach-integrator/core.c b/arch/arm/mach-integrator/core.c
index 8f4fb6d..b8e884b 100644
--- a/arch/arm/mach-integrator/core.c
+++ b/arch/arm/mach-integrator/core.c
@@ -21,9 +21,8 @@
 #include <linux/amba/bus.h>
 #include <linux/amba/serial.h>
 #include <linux/io.h>
+#include <linux/clkdev.h>
 
-#include <asm/clkdev.h>
-#include <mach/clkdev.h>
 #include <mach/hardware.h>
 #include <mach/platform.h>
 #include <asm/irq.h>
diff --git a/arch/arm/mach-integrator/impd1.c b/arch/arm/mach-integrator/impd1.c
index fd684bf..5db574f 100644
--- a/arch/arm/mach-integrator/impd1.c
+++ b/arch/arm/mach-integrator/impd1.c
@@ -22,9 +22,8 @@
 #include <linux/amba/clcd.h>
 #include <linux/io.h>
 #include <linux/slab.h>
+#include <linux/clkdev.h>
 
-#include <asm/clkdev.h>
-#include <mach/clkdev.h>
 #include <asm/hardware/icst.h>
 #include <mach/lm.h>
 #include <mach/impd1.h>
diff --git a/arch/arm/mach-integrator/integrator_cp.c b/arch/arm/mach-integrator/integrator_cp.c
index 05db40e..fce64fc 100644
--- a/arch/arm/mach-integrator/integrator_cp.c
+++ b/arch/arm/mach-integrator/integrator_cp.c
@@ -21,9 +21,8 @@
 #include <linux/amba/mmci.h>
 #include <linux/io.h>
 #include <linux/gfp.h>
+#include <linux/clkdev.h>
 
-#include <asm/clkdev.h>
-#include <mach/clkdev.h>
 #include <mach/hardware.h>
 #include <mach/platform.h>
 #include <asm/irq.h>
diff --git a/arch/arm/mach-lpc32xx/clock.c b/arch/arm/mach-lpc32xx/clock.c
index 32d6379..da0e649 100644
--- a/arch/arm/mach-lpc32xx/clock.c
+++ b/arch/arm/mach-lpc32xx/clock.c
@@ -90,10 +90,9 @@
 #include <linux/clk.h>
 #include <linux/amba/bus.h>
 #include <linux/amba/clcd.h>
+#include <linux/clkdev.h>
 
 #include <mach/hardware.h>
-#include <asm/clkdev.h>
-#include <mach/clkdev.h>
 #include <mach/platform.h>
 #include "clock.h"
 #include "common.h"
diff --git a/arch/arm/mach-mmp/clock.h b/arch/arm/mach-mmp/clock.h
index 016ae94..9b027d7 100644
--- a/arch/arm/mach-mmp/clock.h
+++ b/arch/arm/mach-mmp/clock.h
@@ -6,7 +6,7 @@
  *  published by the Free Software Foundation.
  */
 
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 
 struct clkops {
 	void			(*enable)(struct clk *);
diff --git a/arch/arm/mach-mx25/clock.c b/arch/arm/mach-mx25/clock.c
index 40c7cc4..b3196bb 100644
--- a/arch/arm/mach-mx25/clock.c
+++ b/arch/arm/mach-mx25/clock.c
@@ -21,8 +21,7 @@
 #include <linux/list.h>
 #include <linux/clk.h>
 #include <linux/io.h>
-
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 
 #include <mach/clock.h>
 #include <mach/hardware.h>
diff --git a/arch/arm/mach-mx3/clock-imx31.c b/arch/arm/mach-mx3/clock-imx31.c
index 9a9eb6d..2ba7094 100644
--- a/arch/arm/mach-mx3/clock-imx31.c
+++ b/arch/arm/mach-mx3/clock-imx31.c
@@ -23,8 +23,8 @@
 #include <linux/clk.h>
 #include <linux/err.h>
 #include <linux/io.h>
+#include <linux/clkdev.h>
 
-#include <asm/clkdev.h>
 #include <asm/div64.h>
 
 #include <mach/clock.h>
diff --git a/arch/arm/mach-mx3/clock-imx35.c b/arch/arm/mach-mx3/clock-imx35.c
index d3af0fd..2d17c03 100644
--- a/arch/arm/mach-mx3/clock-imx35.c
+++ b/arch/arm/mach-mx3/clock-imx35.c
@@ -21,8 +21,7 @@
 #include <linux/list.h>
 #include <linux/clk.h>
 #include <linux/io.h>
-
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 
 #include <mach/clock.h>
 #include <mach/hardware.h>
diff --git a/arch/arm/mach-mx5/clock-mx51.c b/arch/arm/mach-mx5/clock-mx51.c
index 6af69de..e599b6d 100644
--- a/arch/arm/mach-mx5/clock-mx51.c
+++ b/arch/arm/mach-mx5/clock-mx51.c
@@ -14,8 +14,8 @@
 #include <linux/delay.h>
 #include <linux/clk.h>
 #include <linux/io.h>
+#include <linux/clkdev.h>
 
-#include <asm/clkdev.h>
 #include <asm/div64.h>
 
 #include <mach/hardware.h>
diff --git a/arch/arm/mach-mxc91231/clock.c b/arch/arm/mach-mxc91231/clock.c
index 5c85075..9fab505 100644
--- a/arch/arm/mach-mxc91231/clock.c
+++ b/arch/arm/mach-mxc91231/clock.c
@@ -2,12 +2,12 @@
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/io.h>
+#include <linux/clkdev.h>
 
 #include <mach/clock.h>
 #include <mach/hardware.h>
 #include <mach/common.h>
 
-#include <asm/clkdev.h>
 #include <asm/bug.h>
 #include <asm/div64.h>
 
diff --git a/arch/arm/mach-nomadik/clock.c b/arch/arm/mach-nomadik/clock.c
index 89f793a..48a59f2 100644
--- a/arch/arm/mach-nomadik/clock.c
+++ b/arch/arm/mach-nomadik/clock.c
@@ -7,7 +7,7 @@
 #include <linux/module.h>
 #include <linux/errno.h>
 #include <linux/clk.h>
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 #include "clock.h"
 
 /*
diff --git a/arch/arm/mach-nuc93x/clock.h b/arch/arm/mach-nuc93x/clock.h
index 18e51be..4de1f1d 100644
--- a/arch/arm/mach-nuc93x/clock.h
+++ b/arch/arm/mach-nuc93x/clock.h
@@ -10,7 +10,7 @@
  * the Free Software Foundation; either version 2 of the License.
  */
 
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 
 void nuc93x_clk_enable(struct clk *clk, int enable);
 void clks_register(struct clk_lookup *clks, size_t num);
diff --git a/arch/arm/mach-omap1/clock.c b/arch/arm/mach-omap1/clock.c
index b8c7fb9..84ef704 100644
--- a/arch/arm/mach-omap1/clock.c
+++ b/arch/arm/mach-omap1/clock.c
@@ -17,9 +17,9 @@
 #include <linux/err.h>
 #include <linux/clk.h>
 #include <linux/io.h>
+#include <linux/clkdev.h>
 
 #include <asm/mach-types.h>
-#include <asm/clkdev.h>
 
 #include <plat/cpu.h>
 #include <plat/usb.h>
diff --git a/arch/arm/mach-omap2/dpll3xxx.c b/arch/arm/mach-omap2/dpll3xxx.c
index ed8d330..ebb888f 100644
--- a/arch/arm/mach-omap2/dpll3xxx.c
+++ b/arch/arm/mach-omap2/dpll3xxx.c
@@ -26,10 +26,10 @@
 #include <linux/clk.h>
 #include <linux/io.h>
 #include <linux/bitops.h>
+#include <linux/clkdev.h>
 
 #include <plat/cpu.h>
 #include <plat/clock.h>
-#include <asm/clkdev.h>
 
 #include "clock.h"
 #include "prm.h"
diff --git a/arch/arm/mach-pnx4008/clock.c b/arch/arm/mach-pnx4008/clock.c
index 9d1975f..a4a3819 100644
--- a/arch/arm/mach-pnx4008/clock.c
+++ b/arch/arm/mach-pnx4008/clock.c
@@ -21,8 +21,7 @@
 #include <linux/err.h>
 #include <linux/delay.h>
 #include <linux/io.h>
-
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 
 #include <mach/hardware.h>
 #include <mach/clock.h>
diff --git a/arch/arm/mach-pxa/clock.c b/arch/arm/mach-pxa/clock.c
index abba008..4e4a84b 100644
--- a/arch/arm/mach-pxa/clock.c
+++ b/arch/arm/mach-pxa/clock.c
@@ -11,8 +11,8 @@
 #include <linux/spinlock.h>
 #include <linux/platform_device.h>
 #include <linux/delay.h>
+#include <linux/clkdev.h>
 
-#include <asm/clkdev.h>
 #include <mach/pxa2xx-regs.h>
 #include <mach/hardware.h>
 
diff --git a/arch/arm/mach-pxa/clock.h b/arch/arm/mach-pxa/clock.h
index d848874..12cc0e8 100644
--- a/arch/arm/mach-pxa/clock.h
+++ b/arch/arm/mach-pxa/clock.h
@@ -1,4 +1,4 @@
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 
 struct clkops {
 	void			(*enable)(struct clk *);
diff --git a/arch/arm/mach-realview/core.c b/arch/arm/mach-realview/core.c
index 2fa38df..cda8b04 100644
--- a/arch/arm/mach-realview/core.c
+++ b/arch/arm/mach-realview/core.c
@@ -30,8 +30,8 @@
 #include <linux/ata_platform.h>
 #include <linux/amba/mmci.h>
 #include <linux/gfp.h>
+#include <linux/clkdev.h>
 
-#include <asm/clkdev.h>
 #include <asm/system.h>
 #include <mach/hardware.h>
 #include <asm/irq.h>
@@ -47,7 +47,6 @@
 
 #include <asm/hardware/gic.h>
 
-#include <mach/clkdev.h>
 #include <mach/platform.h>
 #include <mach/irqs.h>
 #include <plat/timer-sp.h>
diff --git a/arch/arm/mach-shmobile/Kconfig b/arch/arm/mach-shmobile/Kconfig
index 54b479c..f8f06e9 100644
--- a/arch/arm/mach-shmobile/Kconfig
+++ b/arch/arm/mach-shmobile/Kconfig
@@ -6,7 +6,7 @@ config ARCH_SH7367
 	bool "SH-Mobile G3 (SH7367)"
 	select CPU_V6
 	select HAVE_CLK
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	select SH_CLK_CPG
 	select GENERIC_CLOCKEVENTS
 
@@ -14,7 +14,7 @@ config ARCH_SH7377
 	bool "SH-Mobile G4 (SH7377)"
 	select CPU_V7
 	select HAVE_CLK
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	select SH_CLK_CPG
 	select GENERIC_CLOCKEVENTS
 
@@ -22,7 +22,7 @@ config ARCH_SH7372
 	bool "SH-Mobile AP4 (SH7372)"
 	select CPU_V7
 	select HAVE_CLK
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	select SH_CLK_CPG
 	select GENERIC_CLOCKEVENTS
 
diff --git a/arch/arm/mach-shmobile/clock-sh7367.c b/arch/arm/mach-shmobile/clock-sh7367.c
index b6454c9..3030935 100644
--- a/arch/arm/mach-shmobile/clock-sh7367.c
+++ b/arch/arm/mach-shmobile/clock-sh7367.c
@@ -20,8 +20,8 @@
 #include <linux/kernel.h>
 #include <linux/io.h>
 #include <linux/sh_clk.h>
+#include <linux/clkdev.h>
 #include <mach/common.h>
-#include <asm/clkdev.h>
 
 /* SH7367 registers */
 #define RTFRQCR    0xe6150000
diff --git a/arch/arm/mach-shmobile/clock-sh7372.c b/arch/arm/mach-shmobile/clock-sh7372.c
index fb4e9b1..907f46d 100644
--- a/arch/arm/mach-shmobile/clock-sh7372.c
+++ b/arch/arm/mach-shmobile/clock-sh7372.c
@@ -20,8 +20,8 @@
 #include <linux/kernel.h>
 #include <linux/io.h>
 #include <linux/sh_clk.h>
+#include <linux/clkdev.h>
 #include <mach/common.h>
-#include <asm/clkdev.h>
 
 /* SH7372 registers */
 #define FRQCRA		0xe6150000
diff --git a/arch/arm/mach-shmobile/clock-sh7377.c b/arch/arm/mach-shmobile/clock-sh7377.c
index e007c28..a322c9b 100644
--- a/arch/arm/mach-shmobile/clock-sh7377.c
+++ b/arch/arm/mach-shmobile/clock-sh7377.c
@@ -20,8 +20,8 @@
 #include <linux/kernel.h>
 #include <linux/io.h>
 #include <linux/sh_clk.h>
+#include <linux/clkdev.h>
 #include <mach/common.h>
-#include <asm/clkdev.h>
 
 /* SH7377 registers */
 #define RTFRQCR    0xe6150000
diff --git a/arch/arm/mach-tegra/clock.c b/arch/arm/mach-tegra/clock.c
index 03ad578..cad740c 100644
--- a/arch/arm/mach-tegra/clock.c
+++ b/arch/arm/mach-tegra/clock.c
@@ -24,7 +24,7 @@
 #include <linux/debugfs.h>
 #include <linux/slab.h>
 #include <linux/seq_file.h>
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 
 #include "clock.h"
 
diff --git a/arch/arm/mach-tegra/clock.h b/arch/arm/mach-tegra/clock.h
index af7c70e..39a87e7 100644
--- a/arch/arm/mach-tegra/clock.h
+++ b/arch/arm/mach-tegra/clock.h
@@ -21,7 +21,7 @@
 #define __MACH_TEGRA_CLOCK_H
 
 #include <linux/list.h>
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 
 #define DIV_BUS			(1 << 0)
 #define DIV_U71			(1 << 1)
diff --git a/arch/arm/mach-tegra/tegra2_clocks.c b/arch/arm/mach-tegra/tegra2_clocks.c
index 4261632..d2cecbf 100644
--- a/arch/arm/mach-tegra/tegra2_clocks.c
+++ b/arch/arm/mach-tegra/tegra2_clocks.c
@@ -24,8 +24,7 @@
 #include <linux/delay.h>
 #include <linux/io.h>
 #include <linux/hrtimer.h>
-
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 
 #include <mach/iomap.h>
 
diff --git a/arch/arm/mach-u300/clock.c b/arch/arm/mach-u300/clock.c
index 60acf9e..cb3ab08 100644
--- a/arch/arm/mach-u300/clock.c
+++ b/arch/arm/mach-u300/clock.c
@@ -25,8 +25,8 @@
 #include <linux/timer.h>
 #include <linux/io.h>
 #include <linux/seq_file.h>
+#include <linux/clkdev.h>
 
-#include <asm/clkdev.h>
 #include <mach/hardware.h>
 #include <mach/syscon.h>
 
diff --git a/arch/arm/mach-ux500/clock.c b/arch/arm/mach-ux500/clock.c
index d8ab7f1..df238ab 100644
--- a/arch/arm/mach-ux500/clock.c
+++ b/arch/arm/mach-ux500/clock.c
@@ -13,8 +13,7 @@
 #include <linux/err.h>
 #include <linux/clk.h>
 #include <linux/io.h>
-
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 
 #include <plat/mtu.h>
 #include <mach/hardware.h>
diff --git a/arch/arm/mach-versatile/core.c b/arch/arm/mach-versatile/core.c
index e38acb0..8c1ca1d 100644
--- a/arch/arm/mach-versatile/core.c
+++ b/arch/arm/mach-versatile/core.c
@@ -31,8 +31,8 @@
 #include <linux/amba/pl022.h>
 #include <linux/io.h>
 #include <linux/gfp.h>
+#include <linux/clkdev.h>
 
-#include <asm/clkdev.h>
 #include <asm/system.h>
 #include <asm/irq.h>
 #include <asm/leds.h>
@@ -46,7 +46,6 @@
 #include <asm/mach/irq.h>
 #include <asm/mach/time.h>
 #include <asm/mach/map.h>
-#include <mach/clkdev.h>
 #include <mach/hardware.h>
 #include <mach/platform.h>
 #include <plat/timer-sp.h>
diff --git a/arch/arm/mach-vexpress/ct-ca9x4.c b/arch/arm/mach-vexpress/ct-ca9x4.c
index 577df6c..fb94f30 100644
--- a/arch/arm/mach-vexpress/ct-ca9x4.c
+++ b/arch/arm/mach-vexpress/ct-ca9x4.c
@@ -8,8 +8,8 @@
 #include <linux/platform_device.h>
 #include <linux/amba/bus.h>
 #include <linux/amba/clcd.h>
+#include <linux/clkdev.h>
 
-#include <asm/clkdev.h>
 #include <asm/pgtable.h>
 #include <asm/hardware/arm_timer.h>
 #include <asm/hardware/cache-l2x0.h>
@@ -18,7 +18,6 @@
 #include <asm/pmu.h>
 #include <asm/smp_twd.h>
 
-#include <mach/clkdev.h>
 #include <mach/ct-ca9x4.h>
 
 #include <plat/timer-sp.h>
diff --git a/arch/arm/mach-vexpress/v2m.c b/arch/arm/mach-vexpress/v2m.c
index 817f0ad..919103d 100644
--- a/arch/arm/mach-vexpress/v2m.c
+++ b/arch/arm/mach-vexpress/v2m.c
@@ -11,15 +11,14 @@
 #include <linux/spinlock.h>
 #include <linux/sysdev.h>
 #include <linux/usb/isp1760.h>
+#include <linux/clkdev.h>
 
-#include <asm/clkdev.h>
 #include <asm/sizes.h>
 #include <asm/mach/flash.h>
 #include <asm/mach/map.h>
 #include <asm/mach/time.h>
 #include <asm/hardware/arm_timer.h>
 
-#include <mach/clkdev.h>
 #include <mach/motherboard.h>
 
 #include <plat/timer-sp.h>
diff --git a/arch/arm/mach-w90x900/clock.h b/arch/arm/mach-w90x900/clock.h
index c56ddab..b88a1b1 100644
--- a/arch/arm/mach-w90x900/clock.h
+++ b/arch/arm/mach-w90x900/clock.h
@@ -10,7 +10,7 @@
  * the Free Software Foundation; either version 2 of the License.
  */
 
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 
 void nuc900_clk_enable(struct clk *clk, int enable);
 void nuc900_subclk_enable(struct clk *clk, int enable);
diff --git a/arch/arm/plat-omap/Kconfig b/arch/arm/plat-omap/Kconfig
index e39a417..271d7b8 100644
--- a/arch/arm/plat-omap/Kconfig
+++ b/arch/arm/plat-omap/Kconfig
@@ -11,13 +11,13 @@ choice
 
 config ARCH_OMAP1
 	bool "TI OMAP1"
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	help
 	  "Systems based on omap7xx, omap15xx or omap16xx"
 
 config ARCH_OMAP2PLUS
 	bool "TI OMAP2/3/4"
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	help
 	  "Systems based on omap24xx, omap34xx or omap44xx"
 
diff --git a/arch/arm/plat-omap/include/plat/clkdev_omap.h b/arch/arm/plat-omap/include/plat/clkdev_omap.h
index bb937f3..4b2028a 100644
--- a/arch/arm/plat-omap/include/plat/clkdev_omap.h
+++ b/arch/arm/plat-omap/include/plat/clkdev_omap.h
@@ -8,7 +8,7 @@
 #ifndef __ARCH_ARM_PLAT_OMAP_INCLUDE_PLAT_CLKDEV_OMAP_H
 #define __ARCH_ARM_PLAT_OMAP_INCLUDE_PLAT_CLKDEV_OMAP_H
 
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 
 struct omap_clk {
 	u16				cpu;
diff --git a/arch/arm/plat-spear/include/plat/clock.h b/arch/arm/plat-spear/include/plat/clock.h
index 298bafc..2572260 100644
--- a/arch/arm/plat-spear/include/plat/clock.h
+++ b/arch/arm/plat-spear/include/plat/clock.h
@@ -15,7 +15,7 @@
 #define __PLAT_CLOCK_H
 
 #include <linux/list.h>
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 #include <linux/types.h>
 
 /* clk structure flags */
diff --git a/arch/arm/plat-stmp3xxx/clock.c b/arch/arm/plat-stmp3xxx/clock.c
index e593a2a..2e712e1 100644
--- a/arch/arm/plat-stmp3xxx/clock.c
+++ b/arch/arm/plat-stmp3xxx/clock.c
@@ -25,9 +25,9 @@
 #include <linux/err.h>
 #include <linux/delay.h>
 #include <linux/io.h>
+#include <linux/clkdev.h>
 
 #include <asm/mach-types.h>
-#include <asm/clkdev.h>
 #include <mach/platform.h>
 #include <mach/regs-clkctrl.h>
 
diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index 33990fa..b5f8a0f 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -8,7 +8,7 @@ mainmenu "Linux/SuperH Kernel Configuration"
 config SUPERH
 	def_bool y
 	select EMBEDDED
-	select HAVE_CLK
+	select CLKDEV_LOOKUP
 	select HAVE_IDE if HAS_IOPORT
 	select HAVE_MEMBLOCK
 	select HAVE_OPROFILE
diff --git a/arch/sh/boards/mach-highlander/setup.c b/arch/sh/boards/mach-highlander/setup.c
index a5ecfba..87618c9 100644
--- a/arch/sh/boards/mach-highlander/setup.c
+++ b/arch/sh/boards/mach-highlander/setup.c
@@ -24,10 +24,10 @@
 #include <linux/interrupt.h>
 #include <linux/usb/r8a66597.h>
 #include <linux/usb/m66592.h>
+#include <linux/clkdev.h>
 #include <net/ax88796.h>
 #include <asm/machvec.h>
 #include <mach/highlander.h>
-#include <asm/clkdev.h>
 #include <asm/clock.h>
 #include <asm/heartbeat.h>
 #include <asm/io.h>
diff --git a/arch/sh/include/asm/clkdev.h b/arch/sh/include/asm/clkdev.h
dissimilarity index 69%
index 5645f35..6ba9186 100644
--- a/arch/sh/include/asm/clkdev.h
+++ b/arch/sh/include/asm/clkdev.h
@@ -1,35 +1,31 @@
-/*
- *  arch/sh/include/asm/clkdev.h
- *
- * Cloned from arch/arm/include/asm/clkdev.h:
- *
- *  Copyright (C) 2008 Russell King.
- *
- * 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.
- *
- * Helper for the clk API to assist looking up a struct clk.
- */
-#ifndef __ASM_CLKDEV_H
-#define __ASM_CLKDEV_H
-
-struct clk;
-
-struct clk_lookup {
-	struct list_head	node;
-	const char		*dev_id;
-	const char		*con_id;
-	struct clk		*clk;
-};
-
-struct clk_lookup *clkdev_alloc(struct clk *clk, const char *con_id,
-	const char *dev_fmt, ...);
-
-void clkdev_add(struct clk_lookup *cl);
-void clkdev_drop(struct clk_lookup *cl);
-
-void clkdev_add_table(struct clk_lookup *, size_t);
-int clk_add_alias(const char *, const char *, char *, struct device *);
-
-#endif
+/*
+ *  Copyright (C) 2010 Paul Mundt <lethal@linux-sh.org>
+ *
+ * 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.
+ *
+ * Helper for the clk API to assist looking up a struct clk.
+ */
+
+#ifndef __CLKDEV__H_
+#define __CLKDEV__H_
+
+#include <linux/bootmem.h>
+#include <linux/mm.h>
+#include <linux/slab.h>
+
+#include <asm/clock.h>
+
+static inline struct clk_lookup_alloc *__clkdev_alloc(size_t size)
+{
+	if (!slab_is_available())
+		return alloc_bootmem_low_pages(size);
+	else
+		return kzalloc(size, GFP_KERNEL);
+}
+
+#define __clk_put(clk)
+#define __clk_get(clk) ({ 1; })
+
+#endif /* __CLKDEV_H__ */
diff --git a/arch/sh/kernel/Makefile b/arch/sh/kernel/Makefile
index e25f3c6..e4fe614 100644
--- a/arch/sh/kernel/Makefile
+++ b/arch/sh/kernel/Makefile
@@ -11,7 +11,7 @@ endif
 
 CFLAGS_REMOVE_return_address.o = -pg
 
-obj-y	:= clkdev.o debugtraps.o dma-nommu.o dumpstack.o 		\
+obj-y	:= debugtraps.o dma-nommu.o dumpstack.o 			\
 	   idle.o io.o irq.o						\
 	   irq_$(BITS).o machvec.o nmi_debug.o process.o		\
 	   process_$(BITS).o ptrace_$(BITS).o				\
diff --git a/arch/sh/kernel/clkdev.c b/arch/sh/kernel/clkdev.c
deleted file mode 100644
index befc255..0000000
--- a/arch/sh/kernel/clkdev.c
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * arch/sh/kernel/clkdev.c
- *
- * Cloned from arch/arm/common/clkdev.c:
- *
- *  Copyright (C) 2008 Russell King.
- *
- * 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.
- *
- * Helper for the clk API to assist looking up a struct clk.
- */
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/device.h>
-#include <linux/list.h>
-#include <linux/errno.h>
-#include <linux/err.h>
-#include <linux/string.h>
-#include <linux/mutex.h>
-#include <linux/clk.h>
-#include <linux/slab.h>
-#include <linux/bootmem.h>
-#include <linux/mm.h>
-#include <asm/clock.h>
-#include <asm/clkdev.h>
-
-static LIST_HEAD(clocks);
-static DEFINE_MUTEX(clocks_mutex);
-
-/*
- * Find the correct struct clk for the device and connection ID.
- * We do slightly fuzzy matching here:
- *  An entry with a NULL ID is assumed to be a wildcard.
- *  If an entry has a device ID, it must match
- *  If an entry has a connection ID, it must match
- * Then we take the most specific entry - with the following
- * order of precedence: dev+con > dev only > con only.
- */
-static struct clk *clk_find(const char *dev_id, const char *con_id)
-{
-	struct clk_lookup *p;
-	struct clk *clk = NULL;
-	int match, best = 0;
-
-	list_for_each_entry(p, &clocks, node) {
-		match = 0;
-		if (p->dev_id) {
-			if (!dev_id || strcmp(p->dev_id, dev_id))
-				continue;
-			match += 2;
-		}
-		if (p->con_id) {
-			if (!con_id || strcmp(p->con_id, con_id))
-				continue;
-			match += 1;
-		}
-		if (match = 0)
-			continue;
-
-		if (match > best) {
-			clk = p->clk;
-			best = match;
-		}
-	}
-	return clk;
-}
-
-struct clk *clk_get_sys(const char *dev_id, const char *con_id)
-{
-	struct clk *clk;
-
-	mutex_lock(&clocks_mutex);
-	clk = clk_find(dev_id, con_id);
-	mutex_unlock(&clocks_mutex);
-
-	return clk ? clk : ERR_PTR(-ENOENT);
-}
-EXPORT_SYMBOL(clk_get_sys);
-
-void clkdev_add(struct clk_lookup *cl)
-{
-	mutex_lock(&clocks_mutex);
-	list_add_tail(&cl->node, &clocks);
-	mutex_unlock(&clocks_mutex);
-}
-EXPORT_SYMBOL(clkdev_add);
-
-void __init clkdev_add_table(struct clk_lookup *cl, size_t num)
-{
-	mutex_lock(&clocks_mutex);
-	while (num--) {
-		list_add_tail(&cl->node, &clocks);
-		cl++;
-	}
-	mutex_unlock(&clocks_mutex);
-}
-
-#define MAX_DEV_ID	20
-#define MAX_CON_ID	16
-
-struct clk_lookup_alloc {
-	struct clk_lookup cl;
-	char	dev_id[MAX_DEV_ID];
-	char	con_id[MAX_CON_ID];
-};
-
-struct clk_lookup * __init_refok
-clkdev_alloc(struct clk *clk, const char *con_id, const char *dev_fmt, ...)
-{
-	struct clk_lookup_alloc *cla;
-
-	if (!slab_is_available())
-		cla = alloc_bootmem_low_pages(sizeof(*cla));
-	else
-		cla = kzalloc(sizeof(*cla), GFP_KERNEL);
-
-	if (!cla)
-		return NULL;
-
-	cla->cl.clk = clk;
-	if (con_id) {
-		strlcpy(cla->con_id, con_id, sizeof(cla->con_id));
-		cla->cl.con_id = cla->con_id;
-	}
-
-	if (dev_fmt) {
-		va_list ap;
-
-		va_start(ap, dev_fmt);
-		vscnprintf(cla->dev_id, sizeof(cla->dev_id), dev_fmt, ap);
-		cla->cl.dev_id = cla->dev_id;
-		va_end(ap);
-	}
-
-	return &cla->cl;
-}
-EXPORT_SYMBOL(clkdev_alloc);
-
-int clk_add_alias(const char *alias, const char *alias_dev_name, char *id,
-	struct device *dev)
-{
-	struct clk *r = clk_get(dev, id);
-	struct clk_lookup *l;
-
-	if (IS_ERR(r))
-		return PTR_ERR(r);
-
-	l = clkdev_alloc(r, alias, alias_dev_name);
-	clk_put(r);
-	if (!l)
-		return -ENODEV;
-	clkdev_add(l);
-	return 0;
-}
-EXPORT_SYMBOL(clk_add_alias);
-
-/*
- * clkdev_drop - remove a clock dynamically allocated
- */
-void clkdev_drop(struct clk_lookup *cl)
-{
-	mutex_lock(&clocks_mutex);
-	list_del(&cl->node);
-	mutex_unlock(&clocks_mutex);
-	kfree(cl);
-}
-EXPORT_SYMBOL(clkdev_drop);
diff --git a/arch/sh/kernel/cpu/clock-cpg.c b/arch/sh/kernel/cpu/clock-cpg.c
index e2f63d6..dd0e0f2 100644
--- a/arch/sh/kernel/cpu/clock-cpg.c
+++ b/arch/sh/kernel/cpu/clock-cpg.c
@@ -2,7 +2,7 @@
 #include <linux/compiler.h>
 #include <linux/slab.h>
 #include <linux/io.h>
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 #include <asm/clock.h>
 
 static struct clk master_clk = {
diff --git a/arch/sh/kernel/cpu/clock.c b/arch/sh/kernel/cpu/clock.c
index 50f887d..4187cf4 100644
--- a/arch/sh/kernel/cpu/clock.c
+++ b/arch/sh/kernel/cpu/clock.c
@@ -48,20 +48,4 @@ int __init clk_init(void)
 	return ret;
 }
 
-/*
- * Returns a clock. Note that we first try to use device id on the bus
- * and clock name. If this fails, we try to use clock name only.
- */
-struct clk *clk_get(struct device *dev, const char *con_id)
-{
-	const char *dev_id = dev ? dev_name(dev) : NULL;
-
-	return clk_get_sys(dev_id, con_id);
-}
-EXPORT_SYMBOL_GPL(clk_get);
-
-void clk_put(struct clk *clk)
-{
-}
-EXPORT_SYMBOL_GPL(clk_put);
 
diff --git a/arch/sh/kernel/cpu/sh4/clock-sh4-202.c b/arch/sh/kernel/cpu/sh4/clock-sh4-202.c
index 4eabc68..6c1492b 100644
--- a/arch/sh/kernel/cpu/sh4/clock-sh4-202.c
+++ b/arch/sh/kernel/cpu/sh4/clock-sh4-202.c
@@ -13,7 +13,7 @@
 #include <linux/kernel.h>
 #include <linux/err.h>
 #include <linux/io.h>
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 #include <asm/clock.h>
 #include <asm/freq.h>
 
diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7343.c b/arch/sh/kernel/cpu/sh4a/clock-sh7343.c
index 71291ae..93c6460 100644
--- a/arch/sh/kernel/cpu/sh4a/clock-sh7343.c
+++ b/arch/sh/kernel/cpu/sh4a/clock-sh7343.c
@@ -21,7 +21,7 @@
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/io.h>
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 #include <asm/clock.h>
 
 /* SH7343 registers */
diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7366.c b/arch/sh/kernel/cpu/sh4a/clock-sh7366.c
index 7ce5bbc..049dc06 100644
--- a/arch/sh/kernel/cpu/sh4a/clock-sh7366.c
+++ b/arch/sh/kernel/cpu/sh4a/clock-sh7366.c
@@ -21,7 +21,7 @@
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/io.h>
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 #include <asm/clock.h>
 
 /* SH7366 registers */
diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7722.c b/arch/sh/kernel/cpu/sh4a/clock-sh7722.c
index 2030f3d..9d23a36 100644
--- a/arch/sh/kernel/cpu/sh4a/clock-sh7722.c
+++ b/arch/sh/kernel/cpu/sh4a/clock-sh7722.c
@@ -21,7 +21,7 @@
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/io.h>
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 #include <asm/clock.h>
 #include <asm/hwblk.h>
 #include <cpu/sh7722.h>
diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7723.c b/arch/sh/kernel/cpu/sh4a/clock-sh7723.c
index d3938f0..55493cd 100644
--- a/arch/sh/kernel/cpu/sh4a/clock-sh7723.c
+++ b/arch/sh/kernel/cpu/sh4a/clock-sh7723.c
@@ -22,7 +22,7 @@
 #include <linux/kernel.h>
 #include <linux/io.h>
 #include <linux/clk.h>
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 #include <asm/clock.h>
 #include <asm/hwblk.h>
 #include <cpu/sh7723.h>
diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7724.c b/arch/sh/kernel/cpu/sh4a/clock-sh7724.c
index 2d9700c..527936b 100644
--- a/arch/sh/kernel/cpu/sh4a/clock-sh7724.c
+++ b/arch/sh/kernel/cpu/sh4a/clock-sh7724.c
@@ -22,7 +22,7 @@
 #include <linux/kernel.h>
 #include <linux/io.h>
 #include <linux/clk.h>
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 #include <asm/clock.h>
 #include <asm/hwblk.h>
 #include <cpu/sh7724.h>
diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7757.c b/arch/sh/kernel/cpu/sh4a/clock-sh7757.c
index 0a752bd..589ee0a 100644
--- a/arch/sh/kernel/cpu/sh4a/clock-sh7757.c
+++ b/arch/sh/kernel/cpu/sh4a/clock-sh7757.c
@@ -12,7 +12,7 @@
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/io.h>
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 #include <asm/clock.h>
 #include <asm/freq.h>
 
diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7763.c b/arch/sh/kernel/cpu/sh4a/clock-sh7763.c
index 1f1df48..599630f 100644
--- a/arch/sh/kernel/cpu/sh4a/clock-sh7763.c
+++ b/arch/sh/kernel/cpu/sh4a/clock-sh7763.c
@@ -13,7 +13,7 @@
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/io.h>
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 #include <asm/clock.h>
 #include <asm/freq.h>
 #include <asm/io.h>
diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7780.c b/arch/sh/kernel/cpu/sh4a/clock-sh7780.c
index 62d7063..8894926 100644
--- a/arch/sh/kernel/cpu/sh4a/clock-sh7780.c
+++ b/arch/sh/kernel/cpu/sh4a/clock-sh7780.c
@@ -12,7 +12,7 @@
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/io.h>
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 #include <asm/clock.h>
 #include <asm/freq.h>
 #include <asm/io.h>
diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7785.c b/arch/sh/kernel/cpu/sh4a/clock-sh7785.c
index c3e458a..2d96024 100644
--- a/arch/sh/kernel/cpu/sh4a/clock-sh7785.c
+++ b/arch/sh/kernel/cpu/sh4a/clock-sh7785.c
@@ -14,7 +14,7 @@
 #include <linux/clk.h>
 #include <linux/io.h>
 #include <linux/cpufreq.h>
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 #include <asm/clock.h>
 #include <asm/freq.h>
 #include <cpu/sh7785.h>
diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7786.c b/arch/sh/kernel/cpu/sh4a/clock-sh7786.c
index 597c9fb..42e403b 100644
--- a/arch/sh/kernel/cpu/sh4a/clock-sh7786.c
+++ b/arch/sh/kernel/cpu/sh4a/clock-sh7786.c
@@ -13,7 +13,7 @@
 #include <linux/kernel.h>
 #include <linux/clk.h>
 #include <linux/io.h>
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 #include <asm/clock.h>
 #include <asm/freq.h>
 
diff --git a/arch/sh/kernel/cpu/sh4a/clock-shx3.c b/arch/sh/kernel/cpu/sh4a/clock-shx3.c
index 236a628..228d7e6 100644
--- a/arch/sh/kernel/cpu/sh4a/clock-shx3.c
+++ b/arch/sh/kernel/cpu/sh4a/clock-shx3.c
@@ -14,7 +14,7 @@
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/io.h>
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 #include <asm/clock.h>
 #include <asm/freq.h>
 
diff --git a/drivers/Kconfig b/drivers/Kconfig
index a2b902f..3d93b3a 100644
--- a/drivers/Kconfig
+++ b/drivers/Kconfig
@@ -111,4 +111,6 @@ source "drivers/xen/Kconfig"
 source "drivers/staging/Kconfig"
 
 source "drivers/platform/Kconfig"
+
+source "drivers/clk/Kconfig"
 endmenu
diff --git a/drivers/Makefile b/drivers/Makefile
index ae47344..b0e30b2 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -115,3 +115,5 @@ obj-$(CONFIG_VLYNQ)		+= vlynq/
 obj-$(CONFIG_STAGING)		+= staging/
 obj-y				+= platform/
 obj-y				+= ieee802154/
+#common clk code
+obj-y				+= clk/
diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig
new file mode 100644
index 0000000..4168c88
--- /dev/null
+++ b/drivers/clk/Kconfig
@@ -0,0 +1,4 @@
+
+config CLKDEV_LOOKUP
+	bool
+	select HAVE_CLK
diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
new file mode 100644
index 0000000..07613fa
--- /dev/null
+++ b/drivers/clk/Makefile
@@ -0,0 +1,2 @@
+
+obj-$(CONFIG_CLKDEV_LOOKUP)	+= clkdev.o
diff --git a/arch/arm/common/clkdev.c b/drivers/clk/clkdev.c
similarity index 93%
rename from arch/arm/common/clkdev.c
rename to drivers/clk/clkdev.c
index e2b2bb6..0fc0a79 100644
--- a/arch/arm/common/clkdev.c
+++ b/drivers/clk/clkdev.c
@@ -1,5 +1,5 @@
 /*
- *  arch/arm/common/clkdev.c
+ * drivers/clk/clkdev.c
  *
  *  Copyright (C) 2008 Russell King.
  *
@@ -18,10 +18,7 @@
 #include <linux/string.h>
 #include <linux/mutex.h>
 #include <linux/clk.h>
-#include <linux/slab.h>
-
-#include <asm/clkdev.h>
-#include <mach/clkdev.h>
+#include <linux/clkdev.h>
 
 static LIST_HEAD(clocks);
 static DEFINE_MUTEX(clocks_mutex);
@@ -120,12 +117,12 @@ struct clk_lookup_alloc {
 	char	con_id[MAX_CON_ID];
 };
 
-struct clk_lookup *clkdev_alloc(struct clk *clk, const char *con_id,
-	const char *dev_fmt, ...)
+struct clk_lookup * __init_refok
+clkdev_alloc(struct clk *clk, const char *con_id, const char *dev_fmt, ...)
 {
 	struct clk_lookup_alloc *cla;
 
-	cla = kzalloc(sizeof(*cla), GFP_KERNEL);
+	cla = __clkdev_alloc(sizeof(*cla));
 	if (!cla)
 		return NULL;
 
diff --git a/arch/sh/include/asm/clkdev.h b/include/linux/clkdev.h
similarity index 85%
rename from arch/sh/include/asm/clkdev.h
rename to include/linux/clkdev.h
index 5645f35..457bcb0 100644
--- a/arch/sh/include/asm/clkdev.h
+++ b/include/linux/clkdev.h
@@ -1,7 +1,5 @@
 /*
- *  arch/sh/include/asm/clkdev.h
- *
- * Cloned from arch/arm/include/asm/clkdev.h:
+ *  include/linux/clkdev.h
  *
  *  Copyright (C) 2008 Russell King.
  *
@@ -11,10 +9,13 @@
  *
  * Helper for the clk API to assist looking up a struct clk.
  */
-#ifndef __ASM_CLKDEV_H
-#define __ASM_CLKDEV_H
+#ifndef __CLKDEV_H
+#define __CLKDEV_H
+
+#include <asm/clkdev.h>
 
 struct clk;
+struct device;
 
 struct clk_lookup {
 	struct list_head	node;
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [PATCH V3] arm & sh: factorised duplicated clkdev.c
@ 2010-09-02 13:39     ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 0 replies; 133+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2010-09-02 13:39 UTC (permalink / raw)
  To: linux-arm-kernel

factorise some generic infrastructure to assist looking up struct clks
for the ARM & SH architecture.

as the code is identical at 99%

put the arch specific code for allocation as example in asm/clkdev.h

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
v3:
	wrong comment removed
	headers fixed

Best Regards,
J.
 arch/arm/Kconfig                                |   40 +++---
 arch/arm/common/Kconfig                         |    4 -
 arch/arm/common/Makefile                        |    1 -
 arch/arm/include/asm/clkdev.h                   |   22 +--
 arch/arm/mach-bcmring/clock.c                   |    3 +-
 arch/arm/mach-bcmring/core.c                    |    2 +-
 arch/arm/mach-davinci/clock.h                   |    2 +-
 arch/arm/mach-ep93xx/clock.c                    |    2 +-
 arch/arm/mach-imx/clock-imx1.c                  |    3 +-
 arch/arm/mach-imx/clock-imx21.c                 |    2 +-
 arch/arm/mach-imx/clock-imx27.c                 |    2 +-
 arch/arm/mach-integrator/core.c                 |    3 +-
 arch/arm/mach-integrator/impd1.c                |    3 +-
 arch/arm/mach-integrator/integrator_cp.c        |    3 +-
 arch/arm/mach-lpc32xx/clock.c                   |    3 +-
 arch/arm/mach-mmp/clock.h                       |    2 +-
 arch/arm/mach-mx25/clock.c                      |    3 +-
 arch/arm/mach-mx3/clock-imx31.c                 |    2 +-
 arch/arm/mach-mx3/clock-imx35.c                 |    3 +-
 arch/arm/mach-mx5/clock-mx51.c                  |    2 +-
 arch/arm/mach-mxc91231/clock.c                  |    2 +-
 arch/arm/mach-nomadik/clock.c                   |    2 +-
 arch/arm/mach-nuc93x/clock.h                    |    2 +-
 arch/arm/mach-omap1/clock.c                     |    2 +-
 arch/arm/mach-omap2/dpll3xxx.c                  |    2 +-
 arch/arm/mach-pnx4008/clock.c                   |    3 +-
 arch/arm/mach-pxa/clock.c                       |    2 +-
 arch/arm/mach-pxa/clock.h                       |    2 +-
 arch/arm/mach-realview/core.c                   |    3 +-
 arch/arm/mach-shmobile/Kconfig                  |    6 +-
 arch/arm/mach-shmobile/clock-sh7367.c           |    2 +-
 arch/arm/mach-shmobile/clock-sh7372.c           |    2 +-
 arch/arm/mach-shmobile/clock-sh7377.c           |    2 +-
 arch/arm/mach-tegra/clock.c                     |    2 +-
 arch/arm/mach-tegra/clock.h                     |    2 +-
 arch/arm/mach-tegra/tegra2_clocks.c             |    3 +-
 arch/arm/mach-u300/clock.c                      |    2 +-
 arch/arm/mach-ux500/clock.c                     |    3 +-
 arch/arm/mach-versatile/core.c                  |    3 +-
 arch/arm/mach-vexpress/ct-ca9x4.c               |    3 +-
 arch/arm/mach-vexpress/v2m.c                    |    3 +-
 arch/arm/mach-w90x900/clock.h                   |    2 +-
 arch/arm/plat-omap/Kconfig                      |    4 +-
 arch/arm/plat-omap/include/plat/clkdev_omap.h   |    2 +-
 arch/arm/plat-spear/include/plat/clock.h        |    2 +-
 arch/arm/plat-stmp3xxx/clock.c                  |    2 +-
 arch/sh/Kconfig                                 |    2 +-
 arch/sh/boards/mach-highlander/setup.c          |    2 +-
 arch/sh/include/asm/clkdev.h                    |   66 ++++-----
 arch/sh/kernel/Makefile                         |    2 +-
 arch/sh/kernel/clkdev.c                         |  169 -----------------------
 arch/sh/kernel/cpu/clock-cpg.c                  |    2 +-
 arch/sh/kernel/cpu/clock.c                      |   16 --
 arch/sh/kernel/cpu/sh4/clock-sh4-202.c          |    2 +-
 arch/sh/kernel/cpu/sh4a/clock-sh7343.c          |    2 +-
 arch/sh/kernel/cpu/sh4a/clock-sh7366.c          |    2 +-
 arch/sh/kernel/cpu/sh4a/clock-sh7722.c          |    2 +-
 arch/sh/kernel/cpu/sh4a/clock-sh7723.c          |    2 +-
 arch/sh/kernel/cpu/sh4a/clock-sh7724.c          |    2 +-
 arch/sh/kernel/cpu/sh4a/clock-sh7757.c          |    2 +-
 arch/sh/kernel/cpu/sh4a/clock-sh7763.c          |    2 +-
 arch/sh/kernel/cpu/sh4a/clock-sh7780.c          |    2 +-
 arch/sh/kernel/cpu/sh4a/clock-sh7785.c          |    2 +-
 arch/sh/kernel/cpu/sh4a/clock-sh7786.c          |    2 +-
 arch/sh/kernel/cpu/sh4a/clock-shx3.c            |    2 +-
 drivers/Kconfig                                 |    2 +
 drivers/Makefile                                |    2 +
 drivers/clk/Kconfig                             |    4 +
 drivers/clk/Makefile                            |    2 +
 {arch/arm/common => drivers/clk}/clkdev.c       |   13 +-
 {arch/sh/include/asm => include/linux}/clkdev.h |   11 +-
 71 files changed, 139 insertions(+), 350 deletions(-)
 rewrite arch/sh/include/asm/clkdev.h (69%)
 delete mode 100644 arch/sh/kernel/clkdev.c
 create mode 100644 drivers/clk/Kconfig
 create mode 100644 drivers/clk/Makefile
 rename {arch/arm/common => drivers/clk}/clkdev.c (93%)
 rename {arch/sh/include/asm => include/linux}/clkdev.h (85%)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index a7ed21f..1d8a26c 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -221,7 +221,7 @@ config ARCH_INTEGRATOR
 	bool "ARM Ltd. Integrator family"
 	select ARM_AMBA
 	select ARCH_HAS_CPUFREQ
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	select ICST
 	select GENERIC_CLOCKEVENTS
 	select PLAT_VERSATILE
@@ -231,7 +231,7 @@ config ARCH_INTEGRATOR
 config ARCH_REALVIEW
 	bool "ARM Ltd. RealView family"
 	select ARM_AMBA
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	select ICST
 	select GENERIC_CLOCKEVENTS
 	select ARCH_WANT_OPTIONAL_GPIOLIB
@@ -245,7 +245,7 @@ config ARCH_VERSATILE
 	bool "ARM Ltd. Versatile family"
 	select ARM_AMBA
 	select ARM_VIC
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	select ICST
 	select GENERIC_CLOCKEVENTS
 	select ARCH_WANT_OPTIONAL_GPIOLIB
@@ -259,7 +259,7 @@ config ARCH_VEXPRESS
 	select ARCH_WANT_OPTIONAL_GPIOLIB
 	select ARM_AMBA
 	select ARM_TIMER_SP804
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	select GENERIC_CLOCKEVENTS
 	select HAVE_CLK
 	select ICST
@@ -281,7 +281,7 @@ config ARCH_BCMRING
 	depends on MMU
 	select CPU_V6
 	select ARM_AMBA
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	select GENERIC_CLOCKEVENTS
 	select ARCH_WANT_OPTIONAL_GPIOLIB
 	help
@@ -328,7 +328,7 @@ config ARCH_EP93XX
 	select CPU_ARM920T
 	select ARM_AMBA
 	select ARM_VIC
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	select ARCH_REQUIRE_GPIOLIB
 	select ARCH_HAS_HOLES_MEMORYMODEL
 	select ARCH_USES_GETTIMEOFFSET
@@ -348,14 +348,14 @@ config ARCH_MXC
 	bool "Freescale MXC/iMX-based"
 	select GENERIC_CLOCKEVENTS
 	select ARCH_REQUIRE_GPIOLIB
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	help
 	  Support for Freescale MXC/iMX-based family of processors
 
 config ARCH_STMP3XXX
 	bool "Freescale STMP3xxx"
 	select CPU_ARM926T
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	select ARCH_REQUIRE_GPIOLIB
 	select GENERIC_CLOCKEVENTS
 	select USB_ARCH_HAS_EHCI
@@ -473,7 +473,7 @@ config ARCH_LPC32XX
 	select HAVE_IDE
 	select ARM_AMBA
 	select USB_ARCH_HAS_OHCI
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	select GENERIC_TIME
 	select GENERIC_CLOCKEVENTS
 	help
@@ -507,7 +507,7 @@ config ARCH_MMP
 	bool "Marvell PXA168/910/MMP2"
 	depends on MMU
 	select ARCH_REQUIRE_GPIOLIB
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	select GENERIC_CLOCKEVENTS
 	select TICK_ONESHOT
 	select PLAT_PXA
@@ -539,7 +539,7 @@ config ARCH_W90X900
 	bool "Nuvoton W90X900 CPU"
 	select CPU_ARM926T
 	select ARCH_REQUIRE_GPIOLIB
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	select GENERIC_CLOCKEVENTS
 	help
 	  Support for Nuvoton (Winbond logic dept.) ARM9 processor,
@@ -553,7 +553,7 @@ config ARCH_W90X900
 config ARCH_NUC93X
 	bool "Nuvoton NUC93X CPU"
 	select CPU_ARM926T
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	help
 	  Support for Nuvoton (Winbond logic dept.) NUC93X MCU,The NUC93X is a
 	  low-power and high performance MPEG-4/JPEG multimedia controller chip.
@@ -564,7 +564,7 @@ config ARCH_TEGRA
 	select GENERIC_CLOCKEVENTS
 	select GENERIC_GPIO
 	select HAVE_CLK
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	select ARCH_HAS_BARRIERS if CACHE_L2X0
 	help
 	  This enables support for NVIDIA Tegra based systems (Tegra APX,
@@ -573,7 +573,7 @@ config ARCH_TEGRA
 config ARCH_PNX4008
 	bool "Philips Nexperia PNX4008 Mobile"
 	select CPU_ARM926T
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	select ARCH_USES_GETTIMEOFFSET
 	help
 	  This enables support for Philips PNX4008 mobile platform.
@@ -583,7 +583,7 @@ config ARCH_PXA
 	depends on MMU
 	select ARCH_MTD_XIP
 	select ARCH_HAS_CPUFREQ
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	select ARCH_REQUIRE_GPIOLIB
 	select GENERIC_CLOCKEVENTS
 	select TICK_ONESHOT
@@ -767,7 +767,7 @@ config ARCH_U300
 	select ARM_AMBA
 	select ARM_VIC
 	select GENERIC_CLOCKEVENTS
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	select GENERIC_GPIO
 	help
 	  Support for ST-Ericsson U300 series mobile platforms.
@@ -777,7 +777,7 @@ config ARCH_U8500
 	select CPU_V7
 	select ARM_AMBA
 	select GENERIC_CLOCKEVENTS
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	select ARCH_REQUIRE_GPIOLIB
 	help
 	  Support for ST-Ericsson's Ux500 architecture
@@ -787,7 +787,7 @@ config ARCH_NOMADIK
 	select ARM_AMBA
 	select ARM_VIC
 	select CPU_ARM926T
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	select GENERIC_CLOCKEVENTS
 	select ARCH_REQUIRE_GPIOLIB
 	help
@@ -799,7 +799,7 @@ config ARCH_DAVINCI
 	select ARCH_REQUIRE_GPIOLIB
 	select ZONE_DMA
 	select HAVE_IDE
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	select GENERIC_ALLOCATOR
 	select ARCH_HAS_HOLES_MEMORYMODEL
 	help
@@ -819,7 +819,7 @@ config PLAT_SPEAR
 	bool "ST SPEAr"
 	select ARM_AMBA
 	select ARCH_REQUIRE_GPIOLIB
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	select GENERIC_CLOCKEVENTS
 	select HAVE_CLK
 	help
diff --git a/arch/arm/common/Kconfig b/arch/arm/common/Kconfig
index 0a34c81..778655f 100644
--- a/arch/arm/common/Kconfig
+++ b/arch/arm/common/Kconfig
@@ -37,7 +37,3 @@ config SHARP_PARAM
 
 config SHARP_SCOOP
 	bool
-
-config COMMON_CLKDEV
-	bool
-	select HAVE_CLK
diff --git a/arch/arm/common/Makefile b/arch/arm/common/Makefile
index e6e8664..799e140 100644
--- a/arch/arm/common/Makefile
+++ b/arch/arm/common/Makefile
@@ -16,4 +16,3 @@ obj-$(CONFIG_SHARP_SCOOP)	+= scoop.o
 obj-$(CONFIG_ARCH_IXP2000)	+= uengine.o
 obj-$(CONFIG_ARCH_IXP23XX)	+= uengine.o
 obj-$(CONFIG_PCI_HOST_ITE8152)  += it8152.o
-obj-$(CONFIG_COMMON_CLKDEV)	+= clkdev.o
diff --git a/arch/arm/include/asm/clkdev.h b/arch/arm/include/asm/clkdev.h
index b56c138..765d332 100644
--- a/arch/arm/include/asm/clkdev.h
+++ b/arch/arm/include/asm/clkdev.h
@@ -12,23 +12,13 @@
 #ifndef __ASM_CLKDEV_H
 #define __ASM_CLKDEV_H
 
-struct clk;
-struct device;
+#include <linux/slab.h>
 
-struct clk_lookup {
-	struct list_head	node;
-	const char		*dev_id;
-	const char		*con_id;
-	struct clk		*clk;
-};
+#include <mach/clkdev.h>
 
-struct clk_lookup *clkdev_alloc(struct clk *clk, const char *con_id,
-	const char *dev_fmt, ...);
-
-void clkdev_add(struct clk_lookup *cl);
-void clkdev_drop(struct clk_lookup *cl);
-
-void clkdev_add_table(struct clk_lookup *, size_t);
-int clk_add_alias(const char *, const char *, char *, struct device *);
+static inline struct clk_lookup_alloc *__clkdev_alloc(size_t size)
+{
+	return kzalloc(size, GFP_KERNEL);
+}
 
 #endif
diff --git a/arch/arm/mach-bcmring/clock.c b/arch/arm/mach-bcmring/clock.c
index 14bafc3..ad237a4 100644
--- a/arch/arm/mach-bcmring/clock.c
+++ b/arch/arm/mach-bcmring/clock.c
@@ -21,13 +21,12 @@
 #include <linux/string.h>
 #include <linux/clk.h>
 #include <linux/spinlock.h>
+#include <linux/clkdev.h>
 #include <mach/csp/hw_cfg.h>
 #include <mach/csp/chipcHw_def.h>
 #include <mach/csp/chipcHw_reg.h>
 #include <mach/csp/chipcHw_inline.h>
 
-#include <asm/clkdev.h>
-
 #include "clock.h"
 
 #define clk_is_primary(x)       ((x)->type & CLK_TYPE_PRIMARY)
diff --git a/arch/arm/mach-bcmring/core.c b/arch/arm/mach-bcmring/core.c
index d3f959e..ed96ef4 100644
--- a/arch/arm/mach-bcmring/core.c
+++ b/arch/arm/mach-bcmring/core.c
@@ -30,10 +30,10 @@
 #include <linux/amba/bus.h>
 #include <linux/clocksource.h>
 #include <linux/clockchips.h>
+#include <linux/clkdev.h>
 
 #include <mach/csp/mm_addr.h>
 #include <mach/hardware.h>
-#include <asm/clkdev.h>
 #include <linux/io.h>
 #include <asm/irq.h>
 #include <asm/hardware/arm_timer.h>
diff --git a/arch/arm/mach-davinci/clock.h b/arch/arm/mach-davinci/clock.h
index 01e3648..64c58ad 100644
--- a/arch/arm/mach-davinci/clock.h
+++ b/arch/arm/mach-davinci/clock.h
@@ -68,7 +68,7 @@
 #ifndef __ASSEMBLER__
 
 #include <linux/list.h>
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 
 struct pll_data {
 	u32 phys_base;
diff --git a/arch/arm/mach-ep93xx/clock.c b/arch/arm/mach-ep93xx/clock.c
index 8bf3cec..f60d636 100644
--- a/arch/arm/mach-ep93xx/clock.c
+++ b/arch/arm/mach-ep93xx/clock.c
@@ -19,10 +19,10 @@
 #include <linux/string.h>
 #include <linux/io.h>
 #include <linux/spinlock.h>
+#include <linux/clkdev.h>
 
 #include <mach/hardware.h>
 
-#include <asm/clkdev.h>
 #include <asm/div64.h>
 
 
diff --git a/arch/arm/mach-imx/clock-imx1.c b/arch/arm/mach-imx/clock-imx1.c
index c05096c..9c848d9 100644
--- a/arch/arm/mach-imx/clock-imx1.c
+++ b/arch/arm/mach-imx/clock-imx1.c
@@ -22,8 +22,7 @@
 #include <linux/err.h>
 #include <linux/clk.h>
 #include <linux/io.h>
-
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 
 #include <mach/clock.h>
 #include <mach/hardware.h>
diff --git a/arch/arm/mach-imx/clock-imx21.c b/arch/arm/mach-imx/clock-imx21.c
index bb419ef..19e966e 100644
--- a/arch/arm/mach-imx/clock-imx21.c
+++ b/arch/arm/mach-imx/clock-imx21.c
@@ -21,11 +21,11 @@
 #include <linux/clk.h>
 #include <linux/io.h>
 #include <linux/module.h>
+#include <linux/clkdev.h>
 
 #include <mach/clock.h>
 #include <mach/hardware.h>
 #include <mach/common.h>
-#include <asm/clkdev.h>
 #include <asm/div64.h>
 
 #define IO_ADDR_CCM(off)	(MX21_IO_ADDRESS(MX21_CCM_BASE_ADDR + (off)))
diff --git a/arch/arm/mach-imx/clock-imx27.c b/arch/arm/mach-imx/clock-imx27.c
index 5a1aa15..f121114 100644
--- a/arch/arm/mach-imx/clock-imx27.c
+++ b/arch/arm/mach-imx/clock-imx27.c
@@ -21,8 +21,8 @@
 #include <linux/clk.h>
 #include <linux/io.h>
 #include <linux/module.h>
+#include <linux/clkdev.h>
 
-#include <asm/clkdev.h>
 #include <asm/div64.h>
 
 #include <mach/clock.h>
diff --git a/arch/arm/mach-integrator/core.c b/arch/arm/mach-integrator/core.c
index 8f4fb6d..b8e884b 100644
--- a/arch/arm/mach-integrator/core.c
+++ b/arch/arm/mach-integrator/core.c
@@ -21,9 +21,8 @@
 #include <linux/amba/bus.h>
 #include <linux/amba/serial.h>
 #include <linux/io.h>
+#include <linux/clkdev.h>
 
-#include <asm/clkdev.h>
-#include <mach/clkdev.h>
 #include <mach/hardware.h>
 #include <mach/platform.h>
 #include <asm/irq.h>
diff --git a/arch/arm/mach-integrator/impd1.c b/arch/arm/mach-integrator/impd1.c
index fd684bf..5db574f 100644
--- a/arch/arm/mach-integrator/impd1.c
+++ b/arch/arm/mach-integrator/impd1.c
@@ -22,9 +22,8 @@
 #include <linux/amba/clcd.h>
 #include <linux/io.h>
 #include <linux/slab.h>
+#include <linux/clkdev.h>
 
-#include <asm/clkdev.h>
-#include <mach/clkdev.h>
 #include <asm/hardware/icst.h>
 #include <mach/lm.h>
 #include <mach/impd1.h>
diff --git a/arch/arm/mach-integrator/integrator_cp.c b/arch/arm/mach-integrator/integrator_cp.c
index 05db40e..fce64fc 100644
--- a/arch/arm/mach-integrator/integrator_cp.c
+++ b/arch/arm/mach-integrator/integrator_cp.c
@@ -21,9 +21,8 @@
 #include <linux/amba/mmci.h>
 #include <linux/io.h>
 #include <linux/gfp.h>
+#include <linux/clkdev.h>
 
-#include <asm/clkdev.h>
-#include <mach/clkdev.h>
 #include <mach/hardware.h>
 #include <mach/platform.h>
 #include <asm/irq.h>
diff --git a/arch/arm/mach-lpc32xx/clock.c b/arch/arm/mach-lpc32xx/clock.c
index 32d6379..da0e649 100644
--- a/arch/arm/mach-lpc32xx/clock.c
+++ b/arch/arm/mach-lpc32xx/clock.c
@@ -90,10 +90,9 @@
 #include <linux/clk.h>
 #include <linux/amba/bus.h>
 #include <linux/amba/clcd.h>
+#include <linux/clkdev.h>
 
 #include <mach/hardware.h>
-#include <asm/clkdev.h>
-#include <mach/clkdev.h>
 #include <mach/platform.h>
 #include "clock.h"
 #include "common.h"
diff --git a/arch/arm/mach-mmp/clock.h b/arch/arm/mach-mmp/clock.h
index 016ae94..9b027d7 100644
--- a/arch/arm/mach-mmp/clock.h
+++ b/arch/arm/mach-mmp/clock.h
@@ -6,7 +6,7 @@
  *  published by the Free Software Foundation.
  */
 
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 
 struct clkops {
 	void			(*enable)(struct clk *);
diff --git a/arch/arm/mach-mx25/clock.c b/arch/arm/mach-mx25/clock.c
index 40c7cc4..b3196bb 100644
--- a/arch/arm/mach-mx25/clock.c
+++ b/arch/arm/mach-mx25/clock.c
@@ -21,8 +21,7 @@
 #include <linux/list.h>
 #include <linux/clk.h>
 #include <linux/io.h>
-
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 
 #include <mach/clock.h>
 #include <mach/hardware.h>
diff --git a/arch/arm/mach-mx3/clock-imx31.c b/arch/arm/mach-mx3/clock-imx31.c
index 9a9eb6d..2ba7094 100644
--- a/arch/arm/mach-mx3/clock-imx31.c
+++ b/arch/arm/mach-mx3/clock-imx31.c
@@ -23,8 +23,8 @@
 #include <linux/clk.h>
 #include <linux/err.h>
 #include <linux/io.h>
+#include <linux/clkdev.h>
 
-#include <asm/clkdev.h>
 #include <asm/div64.h>
 
 #include <mach/clock.h>
diff --git a/arch/arm/mach-mx3/clock-imx35.c b/arch/arm/mach-mx3/clock-imx35.c
index d3af0fd..2d17c03 100644
--- a/arch/arm/mach-mx3/clock-imx35.c
+++ b/arch/arm/mach-mx3/clock-imx35.c
@@ -21,8 +21,7 @@
 #include <linux/list.h>
 #include <linux/clk.h>
 #include <linux/io.h>
-
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 
 #include <mach/clock.h>
 #include <mach/hardware.h>
diff --git a/arch/arm/mach-mx5/clock-mx51.c b/arch/arm/mach-mx5/clock-mx51.c
index 6af69de..e599b6d 100644
--- a/arch/arm/mach-mx5/clock-mx51.c
+++ b/arch/arm/mach-mx5/clock-mx51.c
@@ -14,8 +14,8 @@
 #include <linux/delay.h>
 #include <linux/clk.h>
 #include <linux/io.h>
+#include <linux/clkdev.h>
 
-#include <asm/clkdev.h>
 #include <asm/div64.h>
 
 #include <mach/hardware.h>
diff --git a/arch/arm/mach-mxc91231/clock.c b/arch/arm/mach-mxc91231/clock.c
index 5c85075..9fab505 100644
--- a/arch/arm/mach-mxc91231/clock.c
+++ b/arch/arm/mach-mxc91231/clock.c
@@ -2,12 +2,12 @@
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/io.h>
+#include <linux/clkdev.h>
 
 #include <mach/clock.h>
 #include <mach/hardware.h>
 #include <mach/common.h>
 
-#include <asm/clkdev.h>
 #include <asm/bug.h>
 #include <asm/div64.h>
 
diff --git a/arch/arm/mach-nomadik/clock.c b/arch/arm/mach-nomadik/clock.c
index 89f793a..48a59f2 100644
--- a/arch/arm/mach-nomadik/clock.c
+++ b/arch/arm/mach-nomadik/clock.c
@@ -7,7 +7,7 @@
 #include <linux/module.h>
 #include <linux/errno.h>
 #include <linux/clk.h>
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 #include "clock.h"
 
 /*
diff --git a/arch/arm/mach-nuc93x/clock.h b/arch/arm/mach-nuc93x/clock.h
index 18e51be..4de1f1d 100644
--- a/arch/arm/mach-nuc93x/clock.h
+++ b/arch/arm/mach-nuc93x/clock.h
@@ -10,7 +10,7 @@
  * the Free Software Foundation; either version 2 of the License.
  */
 
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 
 void nuc93x_clk_enable(struct clk *clk, int enable);
 void clks_register(struct clk_lookup *clks, size_t num);
diff --git a/arch/arm/mach-omap1/clock.c b/arch/arm/mach-omap1/clock.c
index b8c7fb9..84ef704 100644
--- a/arch/arm/mach-omap1/clock.c
+++ b/arch/arm/mach-omap1/clock.c
@@ -17,9 +17,9 @@
 #include <linux/err.h>
 #include <linux/clk.h>
 #include <linux/io.h>
+#include <linux/clkdev.h>
 
 #include <asm/mach-types.h>
-#include <asm/clkdev.h>
 
 #include <plat/cpu.h>
 #include <plat/usb.h>
diff --git a/arch/arm/mach-omap2/dpll3xxx.c b/arch/arm/mach-omap2/dpll3xxx.c
index ed8d330..ebb888f 100644
--- a/arch/arm/mach-omap2/dpll3xxx.c
+++ b/arch/arm/mach-omap2/dpll3xxx.c
@@ -26,10 +26,10 @@
 #include <linux/clk.h>
 #include <linux/io.h>
 #include <linux/bitops.h>
+#include <linux/clkdev.h>
 
 #include <plat/cpu.h>
 #include <plat/clock.h>
-#include <asm/clkdev.h>
 
 #include "clock.h"
 #include "prm.h"
diff --git a/arch/arm/mach-pnx4008/clock.c b/arch/arm/mach-pnx4008/clock.c
index 9d1975f..a4a3819 100644
--- a/arch/arm/mach-pnx4008/clock.c
+++ b/arch/arm/mach-pnx4008/clock.c
@@ -21,8 +21,7 @@
 #include <linux/err.h>
 #include <linux/delay.h>
 #include <linux/io.h>
-
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 
 #include <mach/hardware.h>
 #include <mach/clock.h>
diff --git a/arch/arm/mach-pxa/clock.c b/arch/arm/mach-pxa/clock.c
index abba008..4e4a84b 100644
--- a/arch/arm/mach-pxa/clock.c
+++ b/arch/arm/mach-pxa/clock.c
@@ -11,8 +11,8 @@
 #include <linux/spinlock.h>
 #include <linux/platform_device.h>
 #include <linux/delay.h>
+#include <linux/clkdev.h>
 
-#include <asm/clkdev.h>
 #include <mach/pxa2xx-regs.h>
 #include <mach/hardware.h>
 
diff --git a/arch/arm/mach-pxa/clock.h b/arch/arm/mach-pxa/clock.h
index d848874..12cc0e8 100644
--- a/arch/arm/mach-pxa/clock.h
+++ b/arch/arm/mach-pxa/clock.h
@@ -1,4 +1,4 @@
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 
 struct clkops {
 	void			(*enable)(struct clk *);
diff --git a/arch/arm/mach-realview/core.c b/arch/arm/mach-realview/core.c
index 2fa38df..cda8b04 100644
--- a/arch/arm/mach-realview/core.c
+++ b/arch/arm/mach-realview/core.c
@@ -30,8 +30,8 @@
 #include <linux/ata_platform.h>
 #include <linux/amba/mmci.h>
 #include <linux/gfp.h>
+#include <linux/clkdev.h>
 
-#include <asm/clkdev.h>
 #include <asm/system.h>
 #include <mach/hardware.h>
 #include <asm/irq.h>
@@ -47,7 +47,6 @@
 
 #include <asm/hardware/gic.h>
 
-#include <mach/clkdev.h>
 #include <mach/platform.h>
 #include <mach/irqs.h>
 #include <plat/timer-sp.h>
diff --git a/arch/arm/mach-shmobile/Kconfig b/arch/arm/mach-shmobile/Kconfig
index 54b479c..f8f06e9 100644
--- a/arch/arm/mach-shmobile/Kconfig
+++ b/arch/arm/mach-shmobile/Kconfig
@@ -6,7 +6,7 @@ config ARCH_SH7367
 	bool "SH-Mobile G3 (SH7367)"
 	select CPU_V6
 	select HAVE_CLK
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	select SH_CLK_CPG
 	select GENERIC_CLOCKEVENTS
 
@@ -14,7 +14,7 @@ config ARCH_SH7377
 	bool "SH-Mobile G4 (SH7377)"
 	select CPU_V7
 	select HAVE_CLK
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	select SH_CLK_CPG
 	select GENERIC_CLOCKEVENTS
 
@@ -22,7 +22,7 @@ config ARCH_SH7372
 	bool "SH-Mobile AP4 (SH7372)"
 	select CPU_V7
 	select HAVE_CLK
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	select SH_CLK_CPG
 	select GENERIC_CLOCKEVENTS
 
diff --git a/arch/arm/mach-shmobile/clock-sh7367.c b/arch/arm/mach-shmobile/clock-sh7367.c
index b6454c9..3030935 100644
--- a/arch/arm/mach-shmobile/clock-sh7367.c
+++ b/arch/arm/mach-shmobile/clock-sh7367.c
@@ -20,8 +20,8 @@
 #include <linux/kernel.h>
 #include <linux/io.h>
 #include <linux/sh_clk.h>
+#include <linux/clkdev.h>
 #include <mach/common.h>
-#include <asm/clkdev.h>
 
 /* SH7367 registers */
 #define RTFRQCR    0xe6150000
diff --git a/arch/arm/mach-shmobile/clock-sh7372.c b/arch/arm/mach-shmobile/clock-sh7372.c
index fb4e9b1..907f46d 100644
--- a/arch/arm/mach-shmobile/clock-sh7372.c
+++ b/arch/arm/mach-shmobile/clock-sh7372.c
@@ -20,8 +20,8 @@
 #include <linux/kernel.h>
 #include <linux/io.h>
 #include <linux/sh_clk.h>
+#include <linux/clkdev.h>
 #include <mach/common.h>
-#include <asm/clkdev.h>
 
 /* SH7372 registers */
 #define FRQCRA		0xe6150000
diff --git a/arch/arm/mach-shmobile/clock-sh7377.c b/arch/arm/mach-shmobile/clock-sh7377.c
index e007c28..a322c9b 100644
--- a/arch/arm/mach-shmobile/clock-sh7377.c
+++ b/arch/arm/mach-shmobile/clock-sh7377.c
@@ -20,8 +20,8 @@
 #include <linux/kernel.h>
 #include <linux/io.h>
 #include <linux/sh_clk.h>
+#include <linux/clkdev.h>
 #include <mach/common.h>
-#include <asm/clkdev.h>
 
 /* SH7377 registers */
 #define RTFRQCR    0xe6150000
diff --git a/arch/arm/mach-tegra/clock.c b/arch/arm/mach-tegra/clock.c
index 03ad578..cad740c 100644
--- a/arch/arm/mach-tegra/clock.c
+++ b/arch/arm/mach-tegra/clock.c
@@ -24,7 +24,7 @@
 #include <linux/debugfs.h>
 #include <linux/slab.h>
 #include <linux/seq_file.h>
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 
 #include "clock.h"
 
diff --git a/arch/arm/mach-tegra/clock.h b/arch/arm/mach-tegra/clock.h
index af7c70e..39a87e7 100644
--- a/arch/arm/mach-tegra/clock.h
+++ b/arch/arm/mach-tegra/clock.h
@@ -21,7 +21,7 @@
 #define __MACH_TEGRA_CLOCK_H
 
 #include <linux/list.h>
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 
 #define DIV_BUS			(1 << 0)
 #define DIV_U71			(1 << 1)
diff --git a/arch/arm/mach-tegra/tegra2_clocks.c b/arch/arm/mach-tegra/tegra2_clocks.c
index 4261632..d2cecbf 100644
--- a/arch/arm/mach-tegra/tegra2_clocks.c
+++ b/arch/arm/mach-tegra/tegra2_clocks.c
@@ -24,8 +24,7 @@
 #include <linux/delay.h>
 #include <linux/io.h>
 #include <linux/hrtimer.h>
-
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 
 #include <mach/iomap.h>
 
diff --git a/arch/arm/mach-u300/clock.c b/arch/arm/mach-u300/clock.c
index 60acf9e..cb3ab08 100644
--- a/arch/arm/mach-u300/clock.c
+++ b/arch/arm/mach-u300/clock.c
@@ -25,8 +25,8 @@
 #include <linux/timer.h>
 #include <linux/io.h>
 #include <linux/seq_file.h>
+#include <linux/clkdev.h>
 
-#include <asm/clkdev.h>
 #include <mach/hardware.h>
 #include <mach/syscon.h>
 
diff --git a/arch/arm/mach-ux500/clock.c b/arch/arm/mach-ux500/clock.c
index d8ab7f1..df238ab 100644
--- a/arch/arm/mach-ux500/clock.c
+++ b/arch/arm/mach-ux500/clock.c
@@ -13,8 +13,7 @@
 #include <linux/err.h>
 #include <linux/clk.h>
 #include <linux/io.h>
-
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 
 #include <plat/mtu.h>
 #include <mach/hardware.h>
diff --git a/arch/arm/mach-versatile/core.c b/arch/arm/mach-versatile/core.c
index e38acb0..8c1ca1d 100644
--- a/arch/arm/mach-versatile/core.c
+++ b/arch/arm/mach-versatile/core.c
@@ -31,8 +31,8 @@
 #include <linux/amba/pl022.h>
 #include <linux/io.h>
 #include <linux/gfp.h>
+#include <linux/clkdev.h>
 
-#include <asm/clkdev.h>
 #include <asm/system.h>
 #include <asm/irq.h>
 #include <asm/leds.h>
@@ -46,7 +46,6 @@
 #include <asm/mach/irq.h>
 #include <asm/mach/time.h>
 #include <asm/mach/map.h>
-#include <mach/clkdev.h>
 #include <mach/hardware.h>
 #include <mach/platform.h>
 #include <plat/timer-sp.h>
diff --git a/arch/arm/mach-vexpress/ct-ca9x4.c b/arch/arm/mach-vexpress/ct-ca9x4.c
index 577df6c..fb94f30 100644
--- a/arch/arm/mach-vexpress/ct-ca9x4.c
+++ b/arch/arm/mach-vexpress/ct-ca9x4.c
@@ -8,8 +8,8 @@
 #include <linux/platform_device.h>
 #include <linux/amba/bus.h>
 #include <linux/amba/clcd.h>
+#include <linux/clkdev.h>
 
-#include <asm/clkdev.h>
 #include <asm/pgtable.h>
 #include <asm/hardware/arm_timer.h>
 #include <asm/hardware/cache-l2x0.h>
@@ -18,7 +18,6 @@
 #include <asm/pmu.h>
 #include <asm/smp_twd.h>
 
-#include <mach/clkdev.h>
 #include <mach/ct-ca9x4.h>
 
 #include <plat/timer-sp.h>
diff --git a/arch/arm/mach-vexpress/v2m.c b/arch/arm/mach-vexpress/v2m.c
index 817f0ad..919103d 100644
--- a/arch/arm/mach-vexpress/v2m.c
+++ b/arch/arm/mach-vexpress/v2m.c
@@ -11,15 +11,14 @@
 #include <linux/spinlock.h>
 #include <linux/sysdev.h>
 #include <linux/usb/isp1760.h>
+#include <linux/clkdev.h>
 
-#include <asm/clkdev.h>
 #include <asm/sizes.h>
 #include <asm/mach/flash.h>
 #include <asm/mach/map.h>
 #include <asm/mach/time.h>
 #include <asm/hardware/arm_timer.h>
 
-#include <mach/clkdev.h>
 #include <mach/motherboard.h>
 
 #include <plat/timer-sp.h>
diff --git a/arch/arm/mach-w90x900/clock.h b/arch/arm/mach-w90x900/clock.h
index c56ddab..b88a1b1 100644
--- a/arch/arm/mach-w90x900/clock.h
+++ b/arch/arm/mach-w90x900/clock.h
@@ -10,7 +10,7 @@
  * the Free Software Foundation; either version 2 of the License.
  */
 
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 
 void nuc900_clk_enable(struct clk *clk, int enable);
 void nuc900_subclk_enable(struct clk *clk, int enable);
diff --git a/arch/arm/plat-omap/Kconfig b/arch/arm/plat-omap/Kconfig
index e39a417..271d7b8 100644
--- a/arch/arm/plat-omap/Kconfig
+++ b/arch/arm/plat-omap/Kconfig
@@ -11,13 +11,13 @@ choice
 
 config ARCH_OMAP1
 	bool "TI OMAP1"
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	help
 	  "Systems based on omap7xx, omap15xx or omap16xx"
 
 config ARCH_OMAP2PLUS
 	bool "TI OMAP2/3/4"
-	select COMMON_CLKDEV
+	select CLKDEV_LOOKUP
 	help
 	  "Systems based on omap24xx, omap34xx or omap44xx"
 
diff --git a/arch/arm/plat-omap/include/plat/clkdev_omap.h b/arch/arm/plat-omap/include/plat/clkdev_omap.h
index bb937f3..4b2028a 100644
--- a/arch/arm/plat-omap/include/plat/clkdev_omap.h
+++ b/arch/arm/plat-omap/include/plat/clkdev_omap.h
@@ -8,7 +8,7 @@
 #ifndef __ARCH_ARM_PLAT_OMAP_INCLUDE_PLAT_CLKDEV_OMAP_H
 #define __ARCH_ARM_PLAT_OMAP_INCLUDE_PLAT_CLKDEV_OMAP_H
 
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 
 struct omap_clk {
 	u16				cpu;
diff --git a/arch/arm/plat-spear/include/plat/clock.h b/arch/arm/plat-spear/include/plat/clock.h
index 298bafc..2572260 100644
--- a/arch/arm/plat-spear/include/plat/clock.h
+++ b/arch/arm/plat-spear/include/plat/clock.h
@@ -15,7 +15,7 @@
 #define __PLAT_CLOCK_H
 
 #include <linux/list.h>
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 #include <linux/types.h>
 
 /* clk structure flags */
diff --git a/arch/arm/plat-stmp3xxx/clock.c b/arch/arm/plat-stmp3xxx/clock.c
index e593a2a..2e712e1 100644
--- a/arch/arm/plat-stmp3xxx/clock.c
+++ b/arch/arm/plat-stmp3xxx/clock.c
@@ -25,9 +25,9 @@
 #include <linux/err.h>
 #include <linux/delay.h>
 #include <linux/io.h>
+#include <linux/clkdev.h>
 
 #include <asm/mach-types.h>
-#include <asm/clkdev.h>
 #include <mach/platform.h>
 #include <mach/regs-clkctrl.h>
 
diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index 33990fa..b5f8a0f 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -8,7 +8,7 @@ mainmenu "Linux/SuperH Kernel Configuration"
 config SUPERH
 	def_bool y
 	select EMBEDDED
-	select HAVE_CLK
+	select CLKDEV_LOOKUP
 	select HAVE_IDE if HAS_IOPORT
 	select HAVE_MEMBLOCK
 	select HAVE_OPROFILE
diff --git a/arch/sh/boards/mach-highlander/setup.c b/arch/sh/boards/mach-highlander/setup.c
index a5ecfba..87618c9 100644
--- a/arch/sh/boards/mach-highlander/setup.c
+++ b/arch/sh/boards/mach-highlander/setup.c
@@ -24,10 +24,10 @@
 #include <linux/interrupt.h>
 #include <linux/usb/r8a66597.h>
 #include <linux/usb/m66592.h>
+#include <linux/clkdev.h>
 #include <net/ax88796.h>
 #include <asm/machvec.h>
 #include <mach/highlander.h>
-#include <asm/clkdev.h>
 #include <asm/clock.h>
 #include <asm/heartbeat.h>
 #include <asm/io.h>
diff --git a/arch/sh/include/asm/clkdev.h b/arch/sh/include/asm/clkdev.h
dissimilarity index 69%
index 5645f35..6ba9186 100644
--- a/arch/sh/include/asm/clkdev.h
+++ b/arch/sh/include/asm/clkdev.h
@@ -1,35 +1,31 @@
-/*
- *  arch/sh/include/asm/clkdev.h
- *
- * Cloned from arch/arm/include/asm/clkdev.h:
- *
- *  Copyright (C) 2008 Russell King.
- *
- * 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.
- *
- * Helper for the clk API to assist looking up a struct clk.
- */
-#ifndef __ASM_CLKDEV_H
-#define __ASM_CLKDEV_H
-
-struct clk;
-
-struct clk_lookup {
-	struct list_head	node;
-	const char		*dev_id;
-	const char		*con_id;
-	struct clk		*clk;
-};
-
-struct clk_lookup *clkdev_alloc(struct clk *clk, const char *con_id,
-	const char *dev_fmt, ...);
-
-void clkdev_add(struct clk_lookup *cl);
-void clkdev_drop(struct clk_lookup *cl);
-
-void clkdev_add_table(struct clk_lookup *, size_t);
-int clk_add_alias(const char *, const char *, char *, struct device *);
-
-#endif
+/*
+ *  Copyright (C) 2010 Paul Mundt <lethal@linux-sh.org>
+ *
+ * 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.
+ *
+ * Helper for the clk API to assist looking up a struct clk.
+ */
+
+#ifndef __CLKDEV__H_
+#define __CLKDEV__H_
+
+#include <linux/bootmem.h>
+#include <linux/mm.h>
+#include <linux/slab.h>
+
+#include <asm/clock.h>
+
+static inline struct clk_lookup_alloc *__clkdev_alloc(size_t size)
+{
+	if (!slab_is_available())
+		return alloc_bootmem_low_pages(size);
+	else
+		return kzalloc(size, GFP_KERNEL);
+}
+
+#define __clk_put(clk)
+#define __clk_get(clk) ({ 1; })
+
+#endif /* __CLKDEV_H__ */
diff --git a/arch/sh/kernel/Makefile b/arch/sh/kernel/Makefile
index e25f3c6..e4fe614 100644
--- a/arch/sh/kernel/Makefile
+++ b/arch/sh/kernel/Makefile
@@ -11,7 +11,7 @@ endif
 
 CFLAGS_REMOVE_return_address.o = -pg
 
-obj-y	:= clkdev.o debugtraps.o dma-nommu.o dumpstack.o 		\
+obj-y	:= debugtraps.o dma-nommu.o dumpstack.o 			\
 	   idle.o io.o irq.o						\
 	   irq_$(BITS).o machvec.o nmi_debug.o process.o		\
 	   process_$(BITS).o ptrace_$(BITS).o				\
diff --git a/arch/sh/kernel/clkdev.c b/arch/sh/kernel/clkdev.c
deleted file mode 100644
index befc255..0000000
--- a/arch/sh/kernel/clkdev.c
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * arch/sh/kernel/clkdev.c
- *
- * Cloned from arch/arm/common/clkdev.c:
- *
- *  Copyright (C) 2008 Russell King.
- *
- * 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.
- *
- * Helper for the clk API to assist looking up a struct clk.
- */
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/device.h>
-#include <linux/list.h>
-#include <linux/errno.h>
-#include <linux/err.h>
-#include <linux/string.h>
-#include <linux/mutex.h>
-#include <linux/clk.h>
-#include <linux/slab.h>
-#include <linux/bootmem.h>
-#include <linux/mm.h>
-#include <asm/clock.h>
-#include <asm/clkdev.h>
-
-static LIST_HEAD(clocks);
-static DEFINE_MUTEX(clocks_mutex);
-
-/*
- * Find the correct struct clk for the device and connection ID.
- * We do slightly fuzzy matching here:
- *  An entry with a NULL ID is assumed to be a wildcard.
- *  If an entry has a device ID, it must match
- *  If an entry has a connection ID, it must match
- * Then we take the most specific entry - with the following
- * order of precedence: dev+con > dev only > con only.
- */
-static struct clk *clk_find(const char *dev_id, const char *con_id)
-{
-	struct clk_lookup *p;
-	struct clk *clk = NULL;
-	int match, best = 0;
-
-	list_for_each_entry(p, &clocks, node) {
-		match = 0;
-		if (p->dev_id) {
-			if (!dev_id || strcmp(p->dev_id, dev_id))
-				continue;
-			match += 2;
-		}
-		if (p->con_id) {
-			if (!con_id || strcmp(p->con_id, con_id))
-				continue;
-			match += 1;
-		}
-		if (match == 0)
-			continue;
-
-		if (match > best) {
-			clk = p->clk;
-			best = match;
-		}
-	}
-	return clk;
-}
-
-struct clk *clk_get_sys(const char *dev_id, const char *con_id)
-{
-	struct clk *clk;
-
-	mutex_lock(&clocks_mutex);
-	clk = clk_find(dev_id, con_id);
-	mutex_unlock(&clocks_mutex);
-
-	return clk ? clk : ERR_PTR(-ENOENT);
-}
-EXPORT_SYMBOL(clk_get_sys);
-
-void clkdev_add(struct clk_lookup *cl)
-{
-	mutex_lock(&clocks_mutex);
-	list_add_tail(&cl->node, &clocks);
-	mutex_unlock(&clocks_mutex);
-}
-EXPORT_SYMBOL(clkdev_add);
-
-void __init clkdev_add_table(struct clk_lookup *cl, size_t num)
-{
-	mutex_lock(&clocks_mutex);
-	while (num--) {
-		list_add_tail(&cl->node, &clocks);
-		cl++;
-	}
-	mutex_unlock(&clocks_mutex);
-}
-
-#define MAX_DEV_ID	20
-#define MAX_CON_ID	16
-
-struct clk_lookup_alloc {
-	struct clk_lookup cl;
-	char	dev_id[MAX_DEV_ID];
-	char	con_id[MAX_CON_ID];
-};
-
-struct clk_lookup * __init_refok
-clkdev_alloc(struct clk *clk, const char *con_id, const char *dev_fmt, ...)
-{
-	struct clk_lookup_alloc *cla;
-
-	if (!slab_is_available())
-		cla = alloc_bootmem_low_pages(sizeof(*cla));
-	else
-		cla = kzalloc(sizeof(*cla), GFP_KERNEL);
-
-	if (!cla)
-		return NULL;
-
-	cla->cl.clk = clk;
-	if (con_id) {
-		strlcpy(cla->con_id, con_id, sizeof(cla->con_id));
-		cla->cl.con_id = cla->con_id;
-	}
-
-	if (dev_fmt) {
-		va_list ap;
-
-		va_start(ap, dev_fmt);
-		vscnprintf(cla->dev_id, sizeof(cla->dev_id), dev_fmt, ap);
-		cla->cl.dev_id = cla->dev_id;
-		va_end(ap);
-	}
-
-	return &cla->cl;
-}
-EXPORT_SYMBOL(clkdev_alloc);
-
-int clk_add_alias(const char *alias, const char *alias_dev_name, char *id,
-	struct device *dev)
-{
-	struct clk *r = clk_get(dev, id);
-	struct clk_lookup *l;
-
-	if (IS_ERR(r))
-		return PTR_ERR(r);
-
-	l = clkdev_alloc(r, alias, alias_dev_name);
-	clk_put(r);
-	if (!l)
-		return -ENODEV;
-	clkdev_add(l);
-	return 0;
-}
-EXPORT_SYMBOL(clk_add_alias);
-
-/*
- * clkdev_drop - remove a clock dynamically allocated
- */
-void clkdev_drop(struct clk_lookup *cl)
-{
-	mutex_lock(&clocks_mutex);
-	list_del(&cl->node);
-	mutex_unlock(&clocks_mutex);
-	kfree(cl);
-}
-EXPORT_SYMBOL(clkdev_drop);
diff --git a/arch/sh/kernel/cpu/clock-cpg.c b/arch/sh/kernel/cpu/clock-cpg.c
index e2f63d6..dd0e0f2 100644
--- a/arch/sh/kernel/cpu/clock-cpg.c
+++ b/arch/sh/kernel/cpu/clock-cpg.c
@@ -2,7 +2,7 @@
 #include <linux/compiler.h>
 #include <linux/slab.h>
 #include <linux/io.h>
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 #include <asm/clock.h>
 
 static struct clk master_clk = {
diff --git a/arch/sh/kernel/cpu/clock.c b/arch/sh/kernel/cpu/clock.c
index 50f887d..4187cf4 100644
--- a/arch/sh/kernel/cpu/clock.c
+++ b/arch/sh/kernel/cpu/clock.c
@@ -48,20 +48,4 @@ int __init clk_init(void)
 	return ret;
 }
 
-/*
- * Returns a clock. Note that we first try to use device id on the bus
- * and clock name. If this fails, we try to use clock name only.
- */
-struct clk *clk_get(struct device *dev, const char *con_id)
-{
-	const char *dev_id = dev ? dev_name(dev) : NULL;
-
-	return clk_get_sys(dev_id, con_id);
-}
-EXPORT_SYMBOL_GPL(clk_get);
-
-void clk_put(struct clk *clk)
-{
-}
-EXPORT_SYMBOL_GPL(clk_put);
 
diff --git a/arch/sh/kernel/cpu/sh4/clock-sh4-202.c b/arch/sh/kernel/cpu/sh4/clock-sh4-202.c
index 4eabc68..6c1492b 100644
--- a/arch/sh/kernel/cpu/sh4/clock-sh4-202.c
+++ b/arch/sh/kernel/cpu/sh4/clock-sh4-202.c
@@ -13,7 +13,7 @@
 #include <linux/kernel.h>
 #include <linux/err.h>
 #include <linux/io.h>
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 #include <asm/clock.h>
 #include <asm/freq.h>
 
diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7343.c b/arch/sh/kernel/cpu/sh4a/clock-sh7343.c
index 71291ae..93c6460 100644
--- a/arch/sh/kernel/cpu/sh4a/clock-sh7343.c
+++ b/arch/sh/kernel/cpu/sh4a/clock-sh7343.c
@@ -21,7 +21,7 @@
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/io.h>
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 #include <asm/clock.h>
 
 /* SH7343 registers */
diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7366.c b/arch/sh/kernel/cpu/sh4a/clock-sh7366.c
index 7ce5bbc..049dc06 100644
--- a/arch/sh/kernel/cpu/sh4a/clock-sh7366.c
+++ b/arch/sh/kernel/cpu/sh4a/clock-sh7366.c
@@ -21,7 +21,7 @@
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/io.h>
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 #include <asm/clock.h>
 
 /* SH7366 registers */
diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7722.c b/arch/sh/kernel/cpu/sh4a/clock-sh7722.c
index 2030f3d..9d23a36 100644
--- a/arch/sh/kernel/cpu/sh4a/clock-sh7722.c
+++ b/arch/sh/kernel/cpu/sh4a/clock-sh7722.c
@@ -21,7 +21,7 @@
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/io.h>
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 #include <asm/clock.h>
 #include <asm/hwblk.h>
 #include <cpu/sh7722.h>
diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7723.c b/arch/sh/kernel/cpu/sh4a/clock-sh7723.c
index d3938f0..55493cd 100644
--- a/arch/sh/kernel/cpu/sh4a/clock-sh7723.c
+++ b/arch/sh/kernel/cpu/sh4a/clock-sh7723.c
@@ -22,7 +22,7 @@
 #include <linux/kernel.h>
 #include <linux/io.h>
 #include <linux/clk.h>
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 #include <asm/clock.h>
 #include <asm/hwblk.h>
 #include <cpu/sh7723.h>
diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7724.c b/arch/sh/kernel/cpu/sh4a/clock-sh7724.c
index 2d9700c..527936b 100644
--- a/arch/sh/kernel/cpu/sh4a/clock-sh7724.c
+++ b/arch/sh/kernel/cpu/sh4a/clock-sh7724.c
@@ -22,7 +22,7 @@
 #include <linux/kernel.h>
 #include <linux/io.h>
 #include <linux/clk.h>
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 #include <asm/clock.h>
 #include <asm/hwblk.h>
 #include <cpu/sh7724.h>
diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7757.c b/arch/sh/kernel/cpu/sh4a/clock-sh7757.c
index 0a752bd..589ee0a 100644
--- a/arch/sh/kernel/cpu/sh4a/clock-sh7757.c
+++ b/arch/sh/kernel/cpu/sh4a/clock-sh7757.c
@@ -12,7 +12,7 @@
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/io.h>
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 #include <asm/clock.h>
 #include <asm/freq.h>
 
diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7763.c b/arch/sh/kernel/cpu/sh4a/clock-sh7763.c
index 1f1df48..599630f 100644
--- a/arch/sh/kernel/cpu/sh4a/clock-sh7763.c
+++ b/arch/sh/kernel/cpu/sh4a/clock-sh7763.c
@@ -13,7 +13,7 @@
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/io.h>
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 #include <asm/clock.h>
 #include <asm/freq.h>
 #include <asm/io.h>
diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7780.c b/arch/sh/kernel/cpu/sh4a/clock-sh7780.c
index 62d7063..8894926 100644
--- a/arch/sh/kernel/cpu/sh4a/clock-sh7780.c
+++ b/arch/sh/kernel/cpu/sh4a/clock-sh7780.c
@@ -12,7 +12,7 @@
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/io.h>
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 #include <asm/clock.h>
 #include <asm/freq.h>
 #include <asm/io.h>
diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7785.c b/arch/sh/kernel/cpu/sh4a/clock-sh7785.c
index c3e458a..2d96024 100644
--- a/arch/sh/kernel/cpu/sh4a/clock-sh7785.c
+++ b/arch/sh/kernel/cpu/sh4a/clock-sh7785.c
@@ -14,7 +14,7 @@
 #include <linux/clk.h>
 #include <linux/io.h>
 #include <linux/cpufreq.h>
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 #include <asm/clock.h>
 #include <asm/freq.h>
 #include <cpu/sh7785.h>
diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7786.c b/arch/sh/kernel/cpu/sh4a/clock-sh7786.c
index 597c9fb..42e403b 100644
--- a/arch/sh/kernel/cpu/sh4a/clock-sh7786.c
+++ b/arch/sh/kernel/cpu/sh4a/clock-sh7786.c
@@ -13,7 +13,7 @@
 #include <linux/kernel.h>
 #include <linux/clk.h>
 #include <linux/io.h>
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 #include <asm/clock.h>
 #include <asm/freq.h>
 
diff --git a/arch/sh/kernel/cpu/sh4a/clock-shx3.c b/arch/sh/kernel/cpu/sh4a/clock-shx3.c
index 236a628..228d7e6 100644
--- a/arch/sh/kernel/cpu/sh4a/clock-shx3.c
+++ b/arch/sh/kernel/cpu/sh4a/clock-shx3.c
@@ -14,7 +14,7 @@
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/io.h>
-#include <asm/clkdev.h>
+#include <linux/clkdev.h>
 #include <asm/clock.h>
 #include <asm/freq.h>
 
diff --git a/drivers/Kconfig b/drivers/Kconfig
index a2b902f..3d93b3a 100644
--- a/drivers/Kconfig
+++ b/drivers/Kconfig
@@ -111,4 +111,6 @@ source "drivers/xen/Kconfig"
 source "drivers/staging/Kconfig"
 
 source "drivers/platform/Kconfig"
+
+source "drivers/clk/Kconfig"
 endmenu
diff --git a/drivers/Makefile b/drivers/Makefile
index ae47344..b0e30b2 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -115,3 +115,5 @@ obj-$(CONFIG_VLYNQ)		+= vlynq/
 obj-$(CONFIG_STAGING)		+= staging/
 obj-y				+= platform/
 obj-y				+= ieee802154/
+#common clk code
+obj-y				+= clk/
diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig
new file mode 100644
index 0000000..4168c88
--- /dev/null
+++ b/drivers/clk/Kconfig
@@ -0,0 +1,4 @@
+
+config CLKDEV_LOOKUP
+	bool
+	select HAVE_CLK
diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
new file mode 100644
index 0000000..07613fa
--- /dev/null
+++ b/drivers/clk/Makefile
@@ -0,0 +1,2 @@
+
+obj-$(CONFIG_CLKDEV_LOOKUP)	+= clkdev.o
diff --git a/arch/arm/common/clkdev.c b/drivers/clk/clkdev.c
similarity index 93%
rename from arch/arm/common/clkdev.c
rename to drivers/clk/clkdev.c
index e2b2bb6..0fc0a79 100644
--- a/arch/arm/common/clkdev.c
+++ b/drivers/clk/clkdev.c
@@ -1,5 +1,5 @@
 /*
- *  arch/arm/common/clkdev.c
+ * drivers/clk/clkdev.c
  *
  *  Copyright (C) 2008 Russell King.
  *
@@ -18,10 +18,7 @@
 #include <linux/string.h>
 #include <linux/mutex.h>
 #include <linux/clk.h>
-#include <linux/slab.h>
-
-#include <asm/clkdev.h>
-#include <mach/clkdev.h>
+#include <linux/clkdev.h>
 
 static LIST_HEAD(clocks);
 static DEFINE_MUTEX(clocks_mutex);
@@ -120,12 +117,12 @@ struct clk_lookup_alloc {
 	char	con_id[MAX_CON_ID];
 };
 
-struct clk_lookup *clkdev_alloc(struct clk *clk, const char *con_id,
-	const char *dev_fmt, ...)
+struct clk_lookup * __init_refok
+clkdev_alloc(struct clk *clk, const char *con_id, const char *dev_fmt, ...)
 {
 	struct clk_lookup_alloc *cla;
 
-	cla = kzalloc(sizeof(*cla), GFP_KERNEL);
+	cla = __clkdev_alloc(sizeof(*cla));
 	if (!cla)
 		return NULL;
 
diff --git a/arch/sh/include/asm/clkdev.h b/include/linux/clkdev.h
similarity index 85%
rename from arch/sh/include/asm/clkdev.h
rename to include/linux/clkdev.h
index 5645f35..457bcb0 100644
--- a/arch/sh/include/asm/clkdev.h
+++ b/include/linux/clkdev.h
@@ -1,7 +1,5 @@
 /*
- *  arch/sh/include/asm/clkdev.h
- *
- * Cloned from arch/arm/include/asm/clkdev.h:
+ *  include/linux/clkdev.h
  *
  *  Copyright (C) 2008 Russell King.
  *
@@ -11,10 +9,13 @@
  *
  * Helper for the clk API to assist looking up a struct clk.
  */
-#ifndef __ASM_CLKDEV_H
-#define __ASM_CLKDEV_H
+#ifndef __CLKDEV_H
+#define __CLKDEV_H
+
+#include <asm/clkdev.h>
 
 struct clk;
+struct device;
 
 struct clk_lookup {
 	struct list_head	node;
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* Re: [RFC] [PATCH v2] arm & sh: factorised duplicated clkdev.c
  2010-09-02 13:26     ` Uwe Kleine-König
@ 2010-09-02 13:47       ` Russell King - ARM Linux
  -1 siblings, 0 replies; 133+ messages in thread
From: Russell King - ARM Linux @ 2010-09-02 13:47 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Sep 02, 2010 at 03:26:41PM +0200, Uwe Kleine-König wrote:
> I'm not very satisfied by Russell's answer.  But even if I accept that
> it should not move to .init.text, why .ref.text?  If I'm not mistaken
> clkdev_alloc references the following non-local symbols:
> 
> 	__clkdev_alloc
> 	strlcpy
> 	vscnprintf

__clkdev_alloc() is an inline function, so effectively it's part of this
function.  On sh, this calls the boot time allocator which is marked as
__init if the normal memory allocators aren't online yet.

> Russell, would at least __module_or_init be OK?

It's a conceptual thing - we want to allow people to create aliases at
run time.  Making it an __init thing will only encourage people to do
silly things to work around the "it can only be used at init time"
problem rather than taking the obvious step of removing the __init tag.

Make it easy for people to do the right thing.

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [RFC] [PATCH v2] arm & sh: factorised duplicated clkdev.c
@ 2010-09-02 13:47       ` Russell King - ARM Linux
  0 siblings, 0 replies; 133+ messages in thread
From: Russell King - ARM Linux @ 2010-09-02 13:47 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Sep 02, 2010 at 03:26:41PM +0200, Uwe Kleine-K?nig wrote:
> I'm not very satisfied by Russell's answer.  But even if I accept that
> it should not move to .init.text, why .ref.text?  If I'm not mistaken
> clkdev_alloc references the following non-local symbols:
> 
> 	__clkdev_alloc
> 	strlcpy
> 	vscnprintf

__clkdev_alloc() is an inline function, so effectively it's part of this
function.  On sh, this calls the boot time allocator which is marked as
__init if the normal memory allocators aren't online yet.

> Russell, would at least __module_or_init be OK?

It's a conceptual thing - we want to allow people to create aliases at
run time.  Making it an __init thing will only encourage people to do
silly things to work around the "it can only be used at init time"
problem rather than taking the obvious step of removing the __init tag.

Make it easy for people to do the right thing.

^ permalink raw reply	[flat|nested] 133+ messages in thread

* Re: [RFC] [PATCH v2] arm & sh: factorised duplicated clkdev.c
  2010-09-02 13:47       ` Russell King - ARM Linux
@ 2010-09-02 13:55         ` Uwe Kleine-König
  -1 siblings, 0 replies; 133+ messages in thread
From:  @ 2010-09-02 13:55 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Russell,

On Thu, Sep 02, 2010 at 02:47:32PM +0100, Russell King - ARM Linux wrote:
> On Thu, Sep 02, 2010 at 03:26:41PM +0200, Uwe Kleine-König wrote:
> > I'm not very satisfied by Russell's answer.  But even if I accept that
> > it should not move to .init.text, why .ref.text?  If I'm not mistaken
> > clkdev_alloc references the following non-local symbols:
> > 
> > 	__clkdev_alloc
> > 	strlcpy
> > 	vscnprintf
> 
> __clkdev_alloc() is an inline function, so effectively it's part of this
> function.  On sh, this calls the boot time allocator which is marked as
> __init if the normal memory allocators aren't online yet.
ah, OK, so I suggest to do

	#ifdef CONFIG_SH
	__ref
	#endif

Just kidding :-)

> > Russell, would at least __module_or_init be OK?
> 
> It's a conceptual thing - we want to allow people to create aliases at
> run time.  Making it an __init thing will only encourage people to do
> silly things to work around the "it can only be used at init time"
> problem rather than taking the obvious step of removing the __init tag.
OK, thanks for your explanation.

Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [RFC] [PATCH v2] arm & sh: factorised duplicated clkdev.c
@ 2010-09-02 13:55         ` Uwe Kleine-König
  0 siblings, 0 replies; 133+ messages in thread
From: Uwe Kleine-König @ 2010-09-02 13:55 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Russell,

On Thu, Sep 02, 2010 at 02:47:32PM +0100, Russell King - ARM Linux wrote:
> On Thu, Sep 02, 2010 at 03:26:41PM +0200, Uwe Kleine-K?nig wrote:
> > I'm not very satisfied by Russell's answer.  But even if I accept that
> > it should not move to .init.text, why .ref.text?  If I'm not mistaken
> > clkdev_alloc references the following non-local symbols:
> > 
> > 	__clkdev_alloc
> > 	strlcpy
> > 	vscnprintf
> 
> __clkdev_alloc() is an inline function, so effectively it's part of this
> function.  On sh, this calls the boot time allocator which is marked as
> __init if the normal memory allocators aren't online yet.
ah, OK, so I suggest to do

	#ifdef CONFIG_SH
	__ref
	#endif

Just kidding :-)

> > Russell, would at least __module_or_init be OK?
> 
> It's a conceptual thing - we want to allow people to create aliases at
> run time.  Making it an __init thing will only encourage people to do
> silly things to work around the "it can only be used at init time"
> problem rather than taking the obvious step of removing the __init tag.
OK, thanks for your explanation.

Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

^ permalink raw reply	[flat|nested] 133+ messages in thread

* Re: [PATCH V3] arm & sh: factorised duplicated clkdev.c
  2010-09-02 13:39     ` Jean-Christophe PLAGNIOL-VILLARD
@ 2010-09-03 10:18       ` Magnus Damm
  -1 siblings, 0 replies; 133+ messages in thread
From: Magnus Damm @ 2010-09-03 10:18 UTC (permalink / raw)
  To: linux-sh

On Thu, Sep 2, 2010 at 10:39 PM, Jean-Christophe PLAGNIOL-VILLARD
<plagnioj@jcrosoft.com> wrote:
> factorise some generic infrastructure to assist looking up struct clks
> for the ARM & SH architecture.
>
> as the code is identical at 99%
>
> put the arch specific code for allocation as example in asm/clkdev.h
>
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> ---
> v3:
>        wrong comment removed
>        headers fixed

[snip]

I can't apply this patch using GNU patch. I've tested 2.5.9 and 2.6.1
from Gentoo.

Using --dry-run is fine, but omitting dry-run gives me:

...
patching file arch/arm/common/clkdev.c
patching file arch/sh/include/asm/clkdev.h
Hunk #1 FAILED at 1.
Hunk #2 FAILED at 11.
2 out of 2 hunks FAILED -- saving rejects to file
arch/sh/include/asm/clkdev.h.rej

I guess this is caused by the last "renaming" hunk, see below.

I thought these things were supposed to work out of the box...

/ magnus

> diff --git a/arch/sh/include/asm/clkdev.h b/include/linux/clkdev.h
> similarity index 85%
> rename from arch/sh/include/asm/clkdev.h
> rename to include/linux/clkdev.h
> index 5645f35..457bcb0 100644
> --- a/arch/sh/include/asm/clkdev.h
> +++ b/include/linux/clkdev.h
> @@ -1,7 +1,5 @@
>  /*
> - *  arch/sh/include/asm/clkdev.h
> - *
> - * Cloned from arch/arm/include/asm/clkdev.h:
> + *  include/linux/clkdev.h
>  *
>  *  Copyright (C) 2008 Russell King.
>  *
> @@ -11,10 +9,13 @@
>  *
>  * Helper for the clk API to assist looking up a struct clk.
>  */
> -#ifndef __ASM_CLKDEV_H
> -#define __ASM_CLKDEV_H
> +#ifndef __CLKDEV_H
> +#define __CLKDEV_H
> +
> +#include <asm/clkdev.h>
>
>  struct clk;
> +struct device;
>
>  struct clk_lookup {
>        struct list_head        node;
> --
> 1.7.1

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [PATCH V3] arm & sh: factorised duplicated clkdev.c
@ 2010-09-03 10:18       ` Magnus Damm
  0 siblings, 0 replies; 133+ messages in thread
From: Magnus Damm @ 2010-09-03 10:18 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Sep 2, 2010 at 10:39 PM, Jean-Christophe PLAGNIOL-VILLARD
<plagnioj@jcrosoft.com> wrote:
> factorise some generic infrastructure to assist looking up struct clks
> for the ARM & SH architecture.
>
> as the code is identical at 99%
>
> put the arch specific code for allocation as example in asm/clkdev.h
>
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> ---
> v3:
> ? ? ? ?wrong comment removed
> ? ? ? ?headers fixed

[snip]

I can't apply this patch using GNU patch. I've tested 2.5.9 and 2.6.1
from Gentoo.

Using --dry-run is fine, but omitting dry-run gives me:

...
patching file arch/arm/common/clkdev.c
patching file arch/sh/include/asm/clkdev.h
Hunk #1 FAILED at 1.
Hunk #2 FAILED at 11.
2 out of 2 hunks FAILED -- saving rejects to file
arch/sh/include/asm/clkdev.h.rej

I guess this is caused by the last "renaming" hunk, see below.

I thought these things were supposed to work out of the box...

/ magnus

> diff --git a/arch/sh/include/asm/clkdev.h b/include/linux/clkdev.h
> similarity index 85%
> rename from arch/sh/include/asm/clkdev.h
> rename to include/linux/clkdev.h
> index 5645f35..457bcb0 100644
> --- a/arch/sh/include/asm/clkdev.h
> +++ b/include/linux/clkdev.h
> @@ -1,7 +1,5 @@
> ?/*
> - * ?arch/sh/include/asm/clkdev.h
> - *
> - * Cloned from arch/arm/include/asm/clkdev.h:
> + * ?include/linux/clkdev.h
> ?*
> ?* ?Copyright (C) 2008 Russell King.
> ?*
> @@ -11,10 +9,13 @@
> ?*
> ?* Helper for the clk API to assist looking up a struct clk.
> ?*/
> -#ifndef __ASM_CLKDEV_H
> -#define __ASM_CLKDEV_H
> +#ifndef __CLKDEV_H
> +#define __CLKDEV_H
> +
> +#include <asm/clkdev.h>
>
> ?struct clk;
> +struct device;
>
> ?struct clk_lookup {
> ? ? ? ?struct list_head ? ? ? ?node;
> --
> 1.7.1

^ permalink raw reply	[flat|nested] 133+ messages in thread

* Re: [PATCH V3] arm & sh: factorised duplicated clkdev.c
  2010-09-03 10:18       ` Magnus Damm
@ 2010-09-03 10:32       ` Jean-Christophe PLAGNIOL-VILLARD
  -1 siblings, 0 replies; 133+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2010-09-03 10:32 UTC (permalink / raw)
  To: linux-sh

On 19:18 Fri 03 Sep     , Magnus Damm wrote:
> On Thu, Sep 2, 2010 at 10:39 PM, Jean-Christophe PLAGNIOL-VILLARD
> <plagnioj@jcrosoft.com> wrote:
> > factorise some generic infrastructure to assist looking up struct clks
> > for the ARM & SH architecture.
> >
> > as the code is identical at 99%
> >
> > put the arch specific code for allocation as example in asm/clkdev.h
> >
> > Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> > ---
> > v3:
> >        wrong comment removed
> >        headers fixed
> 
> [snip]
> 
> I can't apply this patch using GNU patch. I've tested 2.5.9 and 2.6.1
> from Gentoo.
> 
> Using --dry-run is fine, but omitting dry-run gives me:
> 
> ...
> patching file arch/arm/common/clkdev.c
> patching file arch/sh/include/asm/clkdev.h
> Hunk #1 FAILED at 1.
> Hunk #2 FAILED at 11.
> 2 out of 2 hunks FAILED -- saving rejects to file
> arch/sh/include/asm/clkdev.h.rej
> 
> I guess this is caused by the last "renaming" hunk, see below.
> 
> I thought these things were supposed to work out of the box...
I generate it as usual with git (1.7.1)

with the following options git format-patch -M -B -C

and I agree it's supposed to work out of the box

Best Regards,
J.

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [PATCH V3] arm & sh: factorised duplicated clkdev.c
@ 2010-09-03 10:32       ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 0 replies; 133+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2010-09-03 10:32 UTC (permalink / raw)
  To: linux-arm-kernel

On 19:18 Fri 03 Sep     , Magnus Damm wrote:
> On Thu, Sep 2, 2010 at 10:39 PM, Jean-Christophe PLAGNIOL-VILLARD
> <plagnioj@jcrosoft.com> wrote:
> > factorise some generic infrastructure to assist looking up struct clks
> > for the ARM & SH architecture.
> >
> > as the code is identical at 99%
> >
> > put the arch specific code for allocation as example in asm/clkdev.h
> >
> > Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> > ---
> > v3:
> > ? ? ? ?wrong comment removed
> > ? ? ? ?headers fixed
> 
> [snip]
> 
> I can't apply this patch using GNU patch. I've tested 2.5.9 and 2.6.1
> from Gentoo.
> 
> Using --dry-run is fine, but omitting dry-run gives me:
> 
> ...
> patching file arch/arm/common/clkdev.c
> patching file arch/sh/include/asm/clkdev.h
> Hunk #1 FAILED at 1.
> Hunk #2 FAILED at 11.
> 2 out of 2 hunks FAILED -- saving rejects to file
> arch/sh/include/asm/clkdev.h.rej
> 
> I guess this is caused by the last "renaming" hunk, see below.
> 
> I thought these things were supposed to work out of the box...
I generate it as usual with git (1.7.1)

with the following options git format-patch -M -B -C

and I agree it's supposed to work out of the box

Best Regards,
J.

^ permalink raw reply	[flat|nested] 133+ messages in thread

* Re: [PATCH V3] arm & sh: factorised duplicated clkdev.c
  2010-09-03 10:18       ` Magnus Damm
  (?)
@ 2010-09-03 18:23       ` Uwe Kleine-König
  -1 siblings, 0 replies; 133+ messages in thread
From:  @ 2010-09-03 18:23 UTC (permalink / raw)
  To: linux-sh

Hello,

[added git ML to Cc:]

On Fri, Sep 03, 2010 at 07:18:43PM +0900, Magnus Damm wrote:
> On Thu, Sep 2, 2010 at 10:39 PM, Jean-Christophe PLAGNIOL-VILLARD
> <plagnioj@jcrosoft.com> wrote:
> > factorise some generic infrastructure to assist looking up struct clks
> > for the ARM & SH architecture.
> >
> > as the code is identical at 99%
> >
> > put the arch specific code for allocation as example in asm/clkdev.h
> >
> > Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> > ---
> > v3:
> >        wrong comment removed
> >        headers fixed
> 
> [snip]
> 
> I can't apply this patch using GNU patch. I've tested 2.5.9 and 2.6.1
> from Gentoo.
> 
> Using --dry-run is fine, but omitting dry-run gives me:
> 
> ...
> patching file arch/arm/common/clkdev.c
> patching file arch/sh/include/asm/clkdev.h
> Hunk #1 FAILED at 1.
> Hunk #2 FAILED at 11.
> 2 out of 2 hunks FAILED -- saving rejects to file
> arch/sh/include/asm/clkdev.h.rej
> 
> I guess this is caused by the last "renaming" hunk, see below.
> 
> I thought these things were supposed to work out of the box...
Yes, they work out of the box, but only for people using git :-)

Maybe git-apply can be used instead of patch?

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

^ permalink raw reply	[flat|nested] 133+ messages in thread

* Re: [PATCH V3] arm & sh: factorised duplicated clkdev.c
@ 2010-09-03 18:23       ` Uwe Kleine-König
  0 siblings, 0 replies; 133+ messages in thread
From: Uwe Kleine-König @ 2010-09-03 18:23 UTC (permalink / raw)
  To: Magnus Damm
  Cc: Jean-Christophe PLAGNIOL-VILLARD, linux-arm-kernel, linux-sh, git

Hello,

[added git ML to Cc:]

On Fri, Sep 03, 2010 at 07:18:43PM +0900, Magnus Damm wrote:
> On Thu, Sep 2, 2010 at 10:39 PM, Jean-Christophe PLAGNIOL-VILLARD
> <plagnioj@jcrosoft.com> wrote:
> > factorise some generic infrastructure to assist looking up struct clks
> > for the ARM & SH architecture.
> >
> > as the code is identical at 99%
> >
> > put the arch specific code for allocation as example in asm/clkdev.h
> >
> > Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> > ---
> > v3:
> >        wrong comment removed
> >        headers fixed
> 
> [snip]
> 
> I can't apply this patch using GNU patch. I've tested 2.5.9 and 2.6.1
> from Gentoo.
> 
> Using --dry-run is fine, but omitting dry-run gives me:
> 
> ...
> patching file arch/arm/common/clkdev.c
> patching file arch/sh/include/asm/clkdev.h
> Hunk #1 FAILED at 1.
> Hunk #2 FAILED at 11.
> 2 out of 2 hunks FAILED -- saving rejects to file
> arch/sh/include/asm/clkdev.h.rej
> 
> I guess this is caused by the last "renaming" hunk, see below.
> 
> I thought these things were supposed to work out of the box...
Yes, they work out of the box, but only for people using git :-)

Maybe git-apply can be used instead of patch?

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [PATCH V3] arm & sh: factorised duplicated clkdev.c
@ 2010-09-03 18:23       ` Uwe Kleine-König
  0 siblings, 0 replies; 133+ messages in thread
From: Uwe Kleine-König @ 2010-09-03 18:23 UTC (permalink / raw)
  To: linux-arm-kernel

Hello,

[added git ML to Cc:]

On Fri, Sep 03, 2010 at 07:18:43PM +0900, Magnus Damm wrote:
> On Thu, Sep 2, 2010 at 10:39 PM, Jean-Christophe PLAGNIOL-VILLARD
> <plagnioj@jcrosoft.com> wrote:
> > factorise some generic infrastructure to assist looking up struct clks
> > for the ARM & SH architecture.
> >
> > as the code is identical at 99%
> >
> > put the arch specific code for allocation as example in asm/clkdev.h
> >
> > Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> > ---
> > v3:
> > ? ? ? ?wrong comment removed
> > ? ? ? ?headers fixed
> 
> [snip]
> 
> I can't apply this patch using GNU patch. I've tested 2.5.9 and 2.6.1
> from Gentoo.
> 
> Using --dry-run is fine, but omitting dry-run gives me:
> 
> ...
> patching file arch/arm/common/clkdev.c
> patching file arch/sh/include/asm/clkdev.h
> Hunk #1 FAILED at 1.
> Hunk #2 FAILED at 11.
> 2 out of 2 hunks FAILED -- saving rejects to file
> arch/sh/include/asm/clkdev.h.rej
> 
> I guess this is caused by the last "renaming" hunk, see below.
> 
> I thought these things were supposed to work out of the box...
Yes, they work out of the box, but only for people using git :-)

Maybe git-apply can be used instead of patch?

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [BUG?] rename patch accepted with --dry-run, rejected without (Re:
  2010-09-03 18:23       ` Uwe Kleine-König
  (?)
@ 2010-09-03 18:43         ` Jonathan Nieder
  -1 siblings, 0 replies; 133+ messages in thread
From: Jonathan Nieder @ 2010-09-03 18:43 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Magnus Damm, Jean-Christophe PLAGNIOL-VILLARD, linux-arm-kernel,
	linux-sh, git, bug-patch

(+cc: bug-patch)

Hi,

Uwe Kleine-König wrote:
> On Fri, Sep 03, 2010 at 07:18:43PM +0900, Magnus Damm wrote:

>> Using --dry-run is fine, but omitting dry-run gives me:
>> 
>> ...
>> patching file arch/arm/common/clkdev.c
>> patching file arch/sh/include/asm/clkdev.h
>> Hunk #1 FAILED at 1.
>> Hunk #2 FAILED at 11.
>> 2 out of 2 hunks FAILED -- saving rejects to file
>> arch/sh/include/asm/clkdev.h.rej
>> 
>> I guess this is caused by the last "renaming" hunk, see below.

Yep, I can reproduce this.  Patch applies with "git apply",
"patch --dry-run -p1" accepts it, "patch -p1" fails.

 $ patch --version | head -1
 GNU patch 2.6.1.85-423d
 $ cd ~/src/linux-2.6
 $ git checkout 2bfc96a12
 $ git clean -fd
 $ wget http://download.gmane.org/gmane.linux.ports.sh.devel/8747/8748
 $ patch -p1 --quiet --dry-run <8748 
 $ echo $?
 0
 $ patch -p1 --quiet <8748 
 2 out of 2 hunks FAILED -- saving rejects to file include/linux/clkdev.h.rej
 $ echo $?
 1

Andreas: ideas?

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [BUG?] rename patch accepted with --dry-run, rejected without (Re: [PATCH V3] arm & sh: factorised duplicated clkdev.c)
@ 2010-09-03 18:43         ` Jonathan Nieder
  0 siblings, 0 replies; 133+ messages in thread
From: Jonathan Nieder @ 2010-09-03 18:43 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Magnus Damm, Jean-Christophe PLAGNIOL-VILLARD, linux-arm-kernel,
	linux-sh, git, bug-patch

(+cc: bug-patch)

Hi,

Uwe Kleine-König wrote:
> On Fri, Sep 03, 2010 at 07:18:43PM +0900, Magnus Damm wrote:

>> Using --dry-run is fine, but omitting dry-run gives me:
>> 
>> ...
>> patching file arch/arm/common/clkdev.c
>> patching file arch/sh/include/asm/clkdev.h
>> Hunk #1 FAILED at 1.
>> Hunk #2 FAILED at 11.
>> 2 out of 2 hunks FAILED -- saving rejects to file
>> arch/sh/include/asm/clkdev.h.rej
>> 
>> I guess this is caused by the last "renaming" hunk, see below.

Yep, I can reproduce this.  Patch applies with "git apply",
"patch --dry-run -p1" accepts it, "patch -p1" fails.

 $ patch --version | head -1
 GNU patch 2.6.1.85-423d
 $ cd ~/src/linux-2.6
 $ git checkout 2bfc96a12
 $ git clean -fd
 $ wget http://download.gmane.org/gmane.linux.ports.sh.devel/8747/8748
 $ patch -p1 --quiet --dry-run <8748 
 $ echo $?
 0
 $ patch -p1 --quiet <8748 
 2 out of 2 hunks FAILED -- saving rejects to file include/linux/clkdev.h.rej
 $ echo $?
 1

Andreas: ideas?

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [BUG?] rename patch accepted with --dry-run, rejected without (Re: [PATCH V3] arm & sh: factorised duplicated clkdev.c)
@ 2010-09-03 18:43         ` Jonathan Nieder
  0 siblings, 0 replies; 133+ messages in thread
From: Jonathan Nieder @ 2010-09-03 18:43 UTC (permalink / raw)
  To: linux-arm-kernel

(+cc: bug-patch)

Hi,

Uwe Kleine-K?nig wrote:
> On Fri, Sep 03, 2010 at 07:18:43PM +0900, Magnus Damm wrote:

>> Using --dry-run is fine, but omitting dry-run gives me:
>> 
>> ...
>> patching file arch/arm/common/clkdev.c
>> patching file arch/sh/include/asm/clkdev.h
>> Hunk #1 FAILED at 1.
>> Hunk #2 FAILED at 11.
>> 2 out of 2 hunks FAILED -- saving rejects to file
>> arch/sh/include/asm/clkdev.h.rej
>> 
>> I guess this is caused by the last "renaming" hunk, see below.

Yep, I can reproduce this.  Patch applies with "git apply",
"patch --dry-run -p1" accepts it, "patch -p1" fails.

 $ patch --version | head -1
 GNU patch 2.6.1.85-423d
 $ cd ~/src/linux-2.6
 $ git checkout 2bfc96a12
 $ git clean -fd
 $ wget http://download.gmane.org/gmane.linux.ports.sh.devel/8747/8748
 $ patch -p1 --quiet --dry-run <8748 
 $ echo $?
 0
 $ patch -p1 --quiet <8748 
 2 out of 2 hunks FAILED -- saving rejects to file include/linux/clkdev.h.rej
 $ echo $?
 1

Andreas: ideas?

^ permalink raw reply	[flat|nested] 133+ messages in thread

* Re: [BUG?] rename patch accepted with --dry-run, rejected without
  2010-09-03 18:43         ` Jonathan Nieder
  (?)
@ 2010-09-03 19:29           ` Russell King - ARM Linux
  -1 siblings, 0 replies; 133+ messages in thread
From: Russell King - ARM Linux @ 2010-09-03 19:29 UTC (permalink / raw)
  To: Jonathan Nieder
  Cc: Uwe Kleine-König, linux-sh, bug-patch, Magnus Damm,
	linux-arm-kernel, Jean-Christophe PLAGNIOL-VILLARD, git

On Fri, Sep 03, 2010 at 01:43:51PM -0500, Jonathan Nieder wrote:
> (+cc: bug-patch)
> 
> Hi,
> 
> Uwe Kleine-König wrote:
> > On Fri, Sep 03, 2010 at 07:18:43PM +0900, Magnus Damm wrote:
> 
> >> Using --dry-run is fine, but omitting dry-run gives me:
> >> 
> >> ...
> >> patching file arch/arm/common/clkdev.c
> >> patching file arch/sh/include/asm/clkdev.h
> >> Hunk #1 FAILED at 1.
> >> Hunk #2 FAILED at 11.
> >> 2 out of 2 hunks FAILED -- saving rejects to file
> >> arch/sh/include/asm/clkdev.h.rej
> >> 
> >> I guess this is caused by the last "renaming" hunk, see below.
> 
> Yep, I can reproduce this.  Patch applies with "git apply",
> "patch --dry-run -p1" accepts it, "patch -p1" fails.

git patches include additional metadata for renaming files, which gnu patch
will not understand.

If you want GNU patch compatible diffs, don't use -C or -M when generating
patches out of git.

^ permalink raw reply	[flat|nested] 133+ messages in thread

* Re: [BUG?] rename patch accepted with --dry-run, rejected without (Re: [PATCH V3] arm & sh: factorised duplicated clkdev.c)
@ 2010-09-03 19:29           ` Russell King - ARM Linux
  0 siblings, 0 replies; 133+ messages in thread
From: Russell King - ARM Linux @ 2010-09-03 19:29 UTC (permalink / raw)
  To: Jonathan Nieder
  Cc: Uwe Kleine-König, linux-sh, bug-patch, Magnus Damm,
	linux-arm-kernel, Jean-Christophe PLAGNIOL-VILLARD, git

On Fri, Sep 03, 2010 at 01:43:51PM -0500, Jonathan Nieder wrote:
> (+cc: bug-patch)
> 
> Hi,
> 
> Uwe Kleine-König wrote:
> > On Fri, Sep 03, 2010 at 07:18:43PM +0900, Magnus Damm wrote:
> 
> >> Using --dry-run is fine, but omitting dry-run gives me:
> >> 
> >> ...
> >> patching file arch/arm/common/clkdev.c
> >> patching file arch/sh/include/asm/clkdev.h
> >> Hunk #1 FAILED at 1.
> >> Hunk #2 FAILED at 11.
> >> 2 out of 2 hunks FAILED -- saving rejects to file
> >> arch/sh/include/asm/clkdev.h.rej
> >> 
> >> I guess this is caused by the last "renaming" hunk, see below.
> 
> Yep, I can reproduce this.  Patch applies with "git apply",
> "patch --dry-run -p1" accepts it, "patch -p1" fails.

git patches include additional metadata for renaming files, which gnu patch
will not understand.

If you want GNU patch compatible diffs, don't use -C or -M when generating
patches out of git.

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [BUG?] rename patch accepted with --dry-run, rejected without (Re: [PATCH V3] arm & sh: factorised duplicated clkdev.c)
@ 2010-09-03 19:29           ` Russell King - ARM Linux
  0 siblings, 0 replies; 133+ messages in thread
From: Russell King - ARM Linux @ 2010-09-03 19:29 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Sep 03, 2010 at 01:43:51PM -0500, Jonathan Nieder wrote:
> (+cc: bug-patch)
> 
> Hi,
> 
> Uwe Kleine-K?nig wrote:
> > On Fri, Sep 03, 2010 at 07:18:43PM +0900, Magnus Damm wrote:
> 
> >> Using --dry-run is fine, but omitting dry-run gives me:
> >> 
> >> ...
> >> patching file arch/arm/common/clkdev.c
> >> patching file arch/sh/include/asm/clkdev.h
> >> Hunk #1 FAILED at 1.
> >> Hunk #2 FAILED at 11.
> >> 2 out of 2 hunks FAILED -- saving rejects to file
> >> arch/sh/include/asm/clkdev.h.rej
> >> 
> >> I guess this is caused by the last "renaming" hunk, see below.
> 
> Yep, I can reproduce this.  Patch applies with "git apply",
> "patch --dry-run -p1" accepts it, "patch -p1" fails.

git patches include additional metadata for renaming files, which gnu patch
will not understand.

If you want GNU patch compatible diffs, don't use -C or -M when generating
patches out of git.

^ permalink raw reply	[flat|nested] 133+ messages in thread

* Re: [BUG?] rename patch accepted with --dry-run, rejected without
  2010-09-03 19:29           ` Russell King - ARM Linux
  (?)
@ 2010-09-03 19:33             ` Uwe Kleine-König
  -1 siblings, 0 replies; 133+ messages in thread
From:  @ 2010-09-03 19:33 UTC (permalink / raw)
  To: Russell King - ARM Linux
  Cc: Jonathan Nieder, linux-sh, bug-patch, Magnus Damm,
	linux-arm-kernel, Jean-Christophe PLAGNIOL-VILLARD, git

Hey Russell,

On Fri, Sep 03, 2010 at 08:29:07PM +0100, Russell King - ARM Linux wrote:
> On Fri, Sep 03, 2010 at 01:43:51PM -0500, Jonathan Nieder wrote:
> > Uwe Kleine-König wrote:
> > > On Fri, Sep 03, 2010 at 07:18:43PM +0900, Magnus Damm wrote:
> > 
> > >> Using --dry-run is fine, but omitting dry-run gives me:
> > >> 
> > >> ...
> > >> patching file arch/arm/common/clkdev.c
> > >> patching file arch/sh/include/asm/clkdev.h
> > >> Hunk #1 FAILED at 1.
> > >> Hunk #2 FAILED at 11.
> > >> 2 out of 2 hunks FAILED -- saving rejects to file
> > >> arch/sh/include/asm/clkdev.h.rej
> > >> 
> > >> I guess this is caused by the last "renaming" hunk, see below.
> > 
> > Yep, I can reproduce this.  Patch applies with "git apply",
> > "patch --dry-run -p1" accepts it, "patch -p1" fails.
> 
> git patches include additional metadata for renaming files, which gnu patch
> will not understand.
> 
> If you want GNU patch compatible diffs, don't use -C or -M when generating
> patches out of git.
Still GNU patch should then already fail in --dry-run mode.
 
Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

^ permalink raw reply	[flat|nested] 133+ messages in thread

* Re: [BUG?] rename patch accepted with --dry-run, rejected without (Re: [PATCH V3] arm & sh: factorised duplicated clkdev.c)
@ 2010-09-03 19:33             ` Uwe Kleine-König
  0 siblings, 0 replies; 133+ messages in thread
From: Uwe Kleine-König @ 2010-09-03 19:33 UTC (permalink / raw)
  To: Russell King - ARM Linux
  Cc: Jonathan Nieder, linux-sh, bug-patch, Magnus Damm,
	linux-arm-kernel, Jean-Christophe PLAGNIOL-VILLARD, git

Hey Russell,

On Fri, Sep 03, 2010 at 08:29:07PM +0100, Russell King - ARM Linux wrote:
> On Fri, Sep 03, 2010 at 01:43:51PM -0500, Jonathan Nieder wrote:
> > Uwe Kleine-König wrote:
> > > On Fri, Sep 03, 2010 at 07:18:43PM +0900, Magnus Damm wrote:
> > 
> > >> Using --dry-run is fine, but omitting dry-run gives me:
> > >> 
> > >> ...
> > >> patching file arch/arm/common/clkdev.c
> > >> patching file arch/sh/include/asm/clkdev.h
> > >> Hunk #1 FAILED at 1.
> > >> Hunk #2 FAILED at 11.
> > >> 2 out of 2 hunks FAILED -- saving rejects to file
> > >> arch/sh/include/asm/clkdev.h.rej
> > >> 
> > >> I guess this is caused by the last "renaming" hunk, see below.
> > 
> > Yep, I can reproduce this.  Patch applies with "git apply",
> > "patch --dry-run -p1" accepts it, "patch -p1" fails.
> 
> git patches include additional metadata for renaming files, which gnu patch
> will not understand.
> 
> If you want GNU patch compatible diffs, don't use -C or -M when generating
> patches out of git.
Still GNU patch should then already fail in --dry-run mode.
 
Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [BUG?] rename patch accepted with --dry-run, rejected without (Re: [PATCH V3] arm & sh: factorised duplicated clkdev.c)
@ 2010-09-03 19:33             ` Uwe Kleine-König
  0 siblings, 0 replies; 133+ messages in thread
From: Uwe Kleine-König @ 2010-09-03 19:33 UTC (permalink / raw)
  To: linux-arm-kernel

Hey Russell,

On Fri, Sep 03, 2010 at 08:29:07PM +0100, Russell King - ARM Linux wrote:
> On Fri, Sep 03, 2010 at 01:43:51PM -0500, Jonathan Nieder wrote:
> > Uwe Kleine-K?nig wrote:
> > > On Fri, Sep 03, 2010 at 07:18:43PM +0900, Magnus Damm wrote:
> > 
> > >> Using --dry-run is fine, but omitting dry-run gives me:
> > >> 
> > >> ...
> > >> patching file arch/arm/common/clkdev.c
> > >> patching file arch/sh/include/asm/clkdev.h
> > >> Hunk #1 FAILED at 1.
> > >> Hunk #2 FAILED at 11.
> > >> 2 out of 2 hunks FAILED -- saving rejects to file
> > >> arch/sh/include/asm/clkdev.h.rej
> > >> 
> > >> I guess this is caused by the last "renaming" hunk, see below.
> > 
> > Yep, I can reproduce this.  Patch applies with "git apply",
> > "patch --dry-run -p1" accepts it, "patch -p1" fails.
> 
> git patches include additional metadata for renaming files, which gnu patch
> will not understand.
> 
> If you want GNU patch compatible diffs, don't use -C or -M when generating
> patches out of git.
Still GNU patch should then already fail in --dry-run mode.
 
Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

^ permalink raw reply	[flat|nested] 133+ messages in thread

* Re: [BUG?] rename patch accepted with --dry-run, rejected without (Re: [PATCH V3] arm & sh: factoris
  2010-09-03 19:29           ` Russell King - ARM Linux
  (?)
@ 2010-09-03 19:34             ` Matthieu Moy
  -1 siblings, 0 replies; 133+ messages in thread
From: Matthieu Moy @ 2010-09-03 19:34 UTC (permalink / raw)
  To: Russell King - ARM Linux
  Cc: Jonathan Nieder, Uwe Kleine-König, linux-sh, bug-patch,
	Magnus Damm, linux-arm-kernel, Jean-Christophe PLAGNIOL-VILLARD,
	git

Russell King - ARM Linux <linux@arm.linux.org.uk> writes:

> git patches include additional metadata for renaming files, which gnu patch
> will not understand.
>
> If you want GNU patch compatible diffs, don't use -C or -M when generating
> patches out of git.

Fyi: actually, GNU patch will support git-style patches in the next
version according to

http://savannah.gnu.org/forum/forum.php?forum_idc20

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

^ permalink raw reply	[flat|nested] 133+ messages in thread

* Re: [BUG?] rename patch accepted with --dry-run, rejected without (Re: [PATCH V3] arm & sh: factorised duplicated clkdev.c)
@ 2010-09-03 19:34             ` Matthieu Moy
  0 siblings, 0 replies; 133+ messages in thread
From: Matthieu Moy @ 2010-09-03 19:34 UTC (permalink / raw)
  To: Russell King - ARM Linux
  Cc: Jonathan Nieder, Uwe Kleine-König, linux-sh, bug-patch,
	Magnus Damm, linux-arm-kernel, Jean-Christophe PLAGNIOL-VILLARD,
	git

Russell King - ARM Linux <linux@arm.linux.org.uk> writes:

> git patches include additional metadata for renaming files, which gnu patch
> will not understand.
>
> If you want GNU patch compatible diffs, don't use -C or -M when generating
> patches out of git.

Fyi: actually, GNU patch will support git-style patches in the next
version according to

http://savannah.gnu.org/forum/forum.php?forum_id=6320

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [BUG?] rename patch accepted with --dry-run, rejected without (Re: [PATCH V3] arm & sh: factorised duplicated clkdev.c)
@ 2010-09-03 19:34             ` Matthieu Moy
  0 siblings, 0 replies; 133+ messages in thread
From: Matthieu Moy @ 2010-09-03 19:34 UTC (permalink / raw)
  To: linux-arm-kernel

Russell King - ARM Linux <linux@arm.linux.org.uk> writes:

> git patches include additional metadata for renaming files, which gnu patch
> will not understand.
>
> If you want GNU patch compatible diffs, don't use -C or -M when generating
> patches out of git.

Fyi: actually, GNU patch will support git-style patches in the next
version according to

http://savannah.gnu.org/forum/forum.php?forum_id=6320

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

^ permalink raw reply	[flat|nested] 133+ messages in thread

* Re: [BUG?] rename patch accepted with --dry-run, rejected without (Re: [PATCH V3] arm & sh: factoris
  2010-09-03 19:33             ` Uwe Kleine-König
  (?)
@ 2010-09-03 19:45               ` Andreas Schwab
  -1 siblings, 0 replies; 133+ messages in thread
From: Andreas Schwab @ 2010-09-03 19:45 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Russell King - ARM Linux, Jonathan Nieder, linux-sh, bug-patch,
	Magnus Damm, linux-arm-kernel, Jean-Christophe PLAGNIOL-VILLARD,
	git

Uwe Kleine-König <u.kleine-koenig@pengutronix.de> writes:

> Still GNU patch should then already fail in --dry-run mode.

Since --dry-run doesn't actually perform any changes it can easily be
fooled when a file is patched twice.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

^ permalink raw reply	[flat|nested] 133+ messages in thread

* Re: [BUG?] rename patch accepted with --dry-run, rejected without (Re: [PATCH V3] arm & sh: factorised duplicated clkdev.c)
@ 2010-09-03 19:45               ` Andreas Schwab
  0 siblings, 0 replies; 133+ messages in thread
From: Andreas Schwab @ 2010-09-03 19:45 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Russell King - ARM Linux, Jonathan Nieder, linux-sh, bug-patch,
	Magnus Damm, linux-arm-kernel, Jean-Christophe PLAGNIOL-VILLARD,
	git

Uwe Kleine-König <u.kleine-koenig@pengutronix.de> writes:

> Still GNU patch should then already fail in --dry-run mode.

Since --dry-run doesn't actually perform any changes it can easily be
fooled when a file is patched twice.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [BUG?] rename patch accepted with --dry-run, rejected without (Re: [PATCH V3] arm & sh: factorised duplicated clkdev.c)
@ 2010-09-03 19:45               ` Andreas Schwab
  0 siblings, 0 replies; 133+ messages in thread
From: Andreas Schwab @ 2010-09-03 19:45 UTC (permalink / raw)
  To: linux-arm-kernel

Uwe Kleine-K?nig <u.kleine-koenig@pengutronix.de> writes:

> Still GNU patch should then already fail in --dry-run mode.

Since --dry-run doesn't actually perform any changes it can easily be
fooled when a file is patched twice.

Andreas.

-- 
Andreas Schwab, schwab at linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

^ permalink raw reply	[flat|nested] 133+ messages in thread

* Re: [bug-patch] [BUG?] rename patch accepted with --dry-run, rejected without (Re: [PATCH V3] arm &
  2010-09-03 18:43         ` Jonathan Nieder
  (?)
@ 2010-09-03 22:58           ` Andreas Gruenbacher
  -1 siblings, 0 replies; 133+ messages in thread
From: Andreas Gruenbacher @ 2010-09-03 22:58 UTC (permalink / raw)
  To: Jonathan Nieder
  Cc: bug-patch, Uwe Kleine-König, linux-sh, Magnus Damm,
	linux-arm-kernel, Jean-Christophe PLAGNIOL-VILLARD, git

Hi,

On Friday 03 September 2010 20:43:51 Jonathan Nieder wrote:
> Uwe Kleine-König wrote:
> > On Fri, Sep 03, 2010 at 07:18:43PM +0900, Magnus Damm wrote:
> 
> >> Using --dry-run is fine, but omitting dry-run gives me:
> >> 
> >> ...
> >> patching file arch/arm/common/clkdev.c
> >> patching file arch/sh/include/asm/clkdev.h
> >> Hunk #1 FAILED at 1.
> >> Hunk #2 FAILED at 11.
> >> 2 out of 2 hunks FAILED -- saving rejects to file
> >> arch/sh/include/asm/clkdev.h.rej
> >> 
> >> I guess this is caused by the last "renaming" hunk, see below.
> 
> Yep, I can reproduce this.  Patch applies with "git apply",
> "patch --dry-run -p1" accepts it, "patch -p1" fails.
> 
>  $ patch --version | head -1
>  GNU patch 2.6.1.85-423d
>  $ cd ~/src/linux-2.6
>  $ git checkout 2bfc96a12
>  $ git clean -fd
>  $ wget http://download.gmane.org/gmane.linux.ports.sh.devel/8747/8748
> [...]

something pretty bizarre is going on here.  The wget output modifies the same 
file twice, but both patches to this file have the same source sha1 (5645f35):

> diff --git a/arch/sh/include/asm/clkdev.h b/arch/sh/include/asm/clkdev.h
> dissimilarity index 69%
> index 5645f35..6ba9186 100644
> --- a/arch/sh/include/asm/clkdev.h
> +++ b/arch/sh/include/asm/clkdev.h

> diff --git a/arch/sh/include/asm/clkdev.h b/include/linux/clkdev.h
> similarity index 85%
> rename from arch/sh/include/asm/clkdev.h
> rename to include/linux/clkdev.h
> index 5645f35..457bcb0 100644

So "git apply" and "patch --dry-run" seem to work only by accident.

How was this patch generated: with git itself?

The fact that "patch --dry-run" may not work for patches that modify the same 
file twice is a known defect.  I don't know how to solve this in a reasonably 
elegant way.  Luckily the problem only triggers when people are doing 
something "strange" such as concatenating patches.

Andreas

^ permalink raw reply	[flat|nested] 133+ messages in thread

* Re: [bug-patch] [BUG?] rename patch accepted with --dry-run, rejected without (Re: [PATCH V3] arm & sh: factorised duplicated clkdev.c)
@ 2010-09-03 22:58           ` Andreas Gruenbacher
  0 siblings, 0 replies; 133+ messages in thread
From: Andreas Gruenbacher @ 2010-09-03 22:58 UTC (permalink / raw)
  To: Jonathan Nieder
  Cc: bug-patch, Uwe Kleine-König, linux-sh, Magnus Damm,
	linux-arm-kernel, Jean-Christophe PLAGNIOL-VILLARD, git

Hi,

On Friday 03 September 2010 20:43:51 Jonathan Nieder wrote:
> Uwe Kleine-König wrote:
> > On Fri, Sep 03, 2010 at 07:18:43PM +0900, Magnus Damm wrote:
> 
> >> Using --dry-run is fine, but omitting dry-run gives me:
> >> 
> >> ...
> >> patching file arch/arm/common/clkdev.c
> >> patching file arch/sh/include/asm/clkdev.h
> >> Hunk #1 FAILED at 1.
> >> Hunk #2 FAILED at 11.
> >> 2 out of 2 hunks FAILED -- saving rejects to file
> >> arch/sh/include/asm/clkdev.h.rej
> >> 
> >> I guess this is caused by the last "renaming" hunk, see below.
> 
> Yep, I can reproduce this.  Patch applies with "git apply",
> "patch --dry-run -p1" accepts it, "patch -p1" fails.
> 
>  $ patch --version | head -1
>  GNU patch 2.6.1.85-423d
>  $ cd ~/src/linux-2.6
>  $ git checkout 2bfc96a12
>  $ git clean -fd
>  $ wget http://download.gmane.org/gmane.linux.ports.sh.devel/8747/8748
> [...]

something pretty bizarre is going on here.  The wget output modifies the same 
file twice, but both patches to this file have the same source sha1 (5645f35):

> diff --git a/arch/sh/include/asm/clkdev.h b/arch/sh/include/asm/clkdev.h
> dissimilarity index 69%
> index 5645f35..6ba9186 100644
> --- a/arch/sh/include/asm/clkdev.h
> +++ b/arch/sh/include/asm/clkdev.h

> diff --git a/arch/sh/include/asm/clkdev.h b/include/linux/clkdev.h
> similarity index 85%
> rename from arch/sh/include/asm/clkdev.h
> rename to include/linux/clkdev.h
> index 5645f35..457bcb0 100644

So "git apply" and "patch --dry-run" seem to work only by accident.

How was this patch generated: with git itself?

The fact that "patch --dry-run" may not work for patches that modify the same 
file twice is a known defect.  I don't know how to solve this in a reasonably 
elegant way.  Luckily the problem only triggers when people are doing 
something "strange" such as concatenating patches.

Andreas

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [bug-patch] [BUG?] rename patch accepted with --dry-run, rejected without (Re: [PATCH V3] arm & sh: factorised duplicated clkdev.c)
@ 2010-09-03 22:58           ` Andreas Gruenbacher
  0 siblings, 0 replies; 133+ messages in thread
From: Andreas Gruenbacher @ 2010-09-03 22:58 UTC (permalink / raw)
  To: linux-arm-kernel

Hi,

On Friday 03 September 2010 20:43:51 Jonathan Nieder wrote:
> Uwe Kleine-K?nig wrote:
> > On Fri, Sep 03, 2010 at 07:18:43PM +0900, Magnus Damm wrote:
> 
> >> Using --dry-run is fine, but omitting dry-run gives me:
> >> 
> >> ...
> >> patching file arch/arm/common/clkdev.c
> >> patching file arch/sh/include/asm/clkdev.h
> >> Hunk #1 FAILED at 1.
> >> Hunk #2 FAILED at 11.
> >> 2 out of 2 hunks FAILED -- saving rejects to file
> >> arch/sh/include/asm/clkdev.h.rej
> >> 
> >> I guess this is caused by the last "renaming" hunk, see below.
> 
> Yep, I can reproduce this.  Patch applies with "git apply",
> "patch --dry-run -p1" accepts it, "patch -p1" fails.
> 
>  $ patch --version | head -1
>  GNU patch 2.6.1.85-423d
>  $ cd ~/src/linux-2.6
>  $ git checkout 2bfc96a12
>  $ git clean -fd
>  $ wget http://download.gmane.org/gmane.linux.ports.sh.devel/8747/8748
> [...]

something pretty bizarre is going on here.  The wget output modifies the same 
file twice, but both patches to this file have the same source sha1 (5645f35):

> diff --git a/arch/sh/include/asm/clkdev.h b/arch/sh/include/asm/clkdev.h
> dissimilarity index 69%
> index 5645f35..6ba9186 100644
> --- a/arch/sh/include/asm/clkdev.h
> +++ b/arch/sh/include/asm/clkdev.h

> diff --git a/arch/sh/include/asm/clkdev.h b/include/linux/clkdev.h
> similarity index 85%
> rename from arch/sh/include/asm/clkdev.h
> rename to include/linux/clkdev.h
> index 5645f35..457bcb0 100644

So "git apply" and "patch --dry-run" seem to work only by accident.

How was this patch generated: with git itself?

The fact that "patch --dry-run" may not work for patches that modify the same 
file twice is a known defect.  I don't know how to solve this in a reasonably 
elegant way.  Luckily the problem only triggers when people are doing 
something "strange" such as concatenating patches.

Andreas

^ permalink raw reply	[flat|nested] 133+ messages in thread

* Re: [bug-patch] [BUG?] rename patch accepted with --dry-run,
  2010-09-03 22:58           ` Andreas Gruenbacher
  (?)
@ 2010-09-03 23:32             ` Jonathan Nieder
  -1 siblings, 0 replies; 133+ messages in thread
From: Jonathan Nieder @ 2010-09-03 23:32 UTC (permalink / raw)
  To: Andreas Gruenbacher
  Cc: bug-patch, Uwe Kleine-König, linux-sh, Magnus Damm,
	linux-arm-kernel, Jean-Christophe PLAGNIOL-VILLARD, git

Andreas Gruenbacher wrote:

> something pretty bizarre is going on here.  The wget output modifies the same 
> file twice, but both patches to this file have the same source sha1 (5645f35):

From the git v1.6.0-rc0~92 changelog entry:

    apply: fix copy/rename breakage
    
    7ebd52a (Merge branch 'dz/apply-again', 2008-07-01) taught "git-apply" to
    grok a (non-git) patch that is a concatenation of separate patches that
    touch the same file number of times, by recording the postimage of patch
    application of previous round and using it as the preimage for later
    rounds.
    
    This "incremental" mode of patch application fundamentally contradicts
    with the way git rename/copy patches are designed.  When a git patch talks
    about a file A getting modified, and a new file B created out of A, like
    this:
    
        diff --git a/A b/A
        --- a/A
        +++ b/A
        ... change text here ...
        diff --git a/A b/B
        copy from A
        copy to B
        --- a/A
        +++ b/B
        ... change text here ...
    
    the second change to produce B does not depend on what is done to A with
    the first change in any way.  This is explicitly done so for reviewability
    of individual patches.
    
    With this commit, we do not look at 'fn_table' that records the postimage
    of previous round when applying a patch to produce a new file out of an
    existing file.

> How was this patch generated: with git itself?

Yes, the patch basically agrees with what I get by applying it and running

 git format-patch -M -B HEAD^..HEAD

^ permalink raw reply	[flat|nested] 133+ messages in thread

* Re: [bug-patch] [BUG?] rename patch accepted with --dry-run, rejected without (Re: [PATCH V3] arm & sh: factorised duplicated clkdev.c)
@ 2010-09-03 23:32             ` Jonathan Nieder
  0 siblings, 0 replies; 133+ messages in thread
From: Jonathan Nieder @ 2010-09-03 23:32 UTC (permalink / raw)
  To: Andreas Gruenbacher
  Cc: bug-patch, Uwe Kleine-König, linux-sh, Magnus Damm,
	linux-arm-kernel, Jean-Christophe PLAGNIOL-VILLARD, git

Andreas Gruenbacher wrote:

> something pretty bizarre is going on here.  The wget output modifies the same 
> file twice, but both patches to this file have the same source sha1 (5645f35):

>From the git v1.6.0-rc0~92 changelog entry:

    apply: fix copy/rename breakage
    
    7ebd52a (Merge branch 'dz/apply-again', 2008-07-01) taught "git-apply" to
    grok a (non-git) patch that is a concatenation of separate patches that
    touch the same file number of times, by recording the postimage of patch
    application of previous round and using it as the preimage for later
    rounds.
    
    This "incremental" mode of patch application fundamentally contradicts
    with the way git rename/copy patches are designed.  When a git patch talks
    about a file A getting modified, and a new file B created out of A, like
    this:
    
        diff --git a/A b/A
        --- a/A
        +++ b/A
        ... change text here ...
        diff --git a/A b/B
        copy from A
        copy to B
        --- a/A
        +++ b/B
        ... change text here ...
    
    the second change to produce B does not depend on what is done to A with
    the first change in any way.  This is explicitly done so for reviewability
    of individual patches.
    
    With this commit, we do not look at 'fn_table' that records the postimage
    of previous round when applying a patch to produce a new file out of an
    existing file.

> How was this patch generated: with git itself?

Yes, the patch basically agrees with what I get by applying it and running

 git format-patch -M -B HEAD^..HEAD

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [bug-patch] [BUG?] rename patch accepted with --dry-run, rejected without (Re: [PATCH V3] arm & sh: factorised duplicated clkdev.c)
@ 2010-09-03 23:32             ` Jonathan Nieder
  0 siblings, 0 replies; 133+ messages in thread
From: Jonathan Nieder @ 2010-09-03 23:32 UTC (permalink / raw)
  To: linux-arm-kernel

Andreas Gruenbacher wrote:

> something pretty bizarre is going on here.  The wget output modifies the same 
> file twice, but both patches to this file have the same source sha1 (5645f35):

^ permalink raw reply	[flat|nested] 133+ messages in thread

* Re: [BUG?] rename patch accepted with --dry-run, rejected without
  2010-09-03 19:33             ` Uwe Kleine-König
  (?)
@ 2010-09-04  0:03               ` Russell King - ARM Linux
  -1 siblings, 0 replies; 133+ messages in thread
From: Russell King - ARM Linux @ 2010-09-04  0:03 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Jonathan Nieder, linux-sh, bug-patch, Magnus Damm,
	linux-arm-kernel, Jean-Christophe PLAGNIOL-VILLARD, git

On Fri, Sep 03, 2010 at 09:33:09PM +0200, Uwe Kleine-König wrote:
> > git patches include additional metadata for renaming files, which gnu patch
> > will not understand.
> > 
> > If you want GNU patch compatible diffs, don't use -C or -M when generating
> > patches out of git.
> Still GNU patch should then already fail in --dry-run mode.

And now look at the patch - it touches arch/sh/include/asm/clkdev.h twice.
Once to remove it and once as a rename.

GNU patch not in --dry-run mode will first remove arch/sh/include/asm/clkdev.h,
and then not have a file to deal with when it tries to patch the rename
part.  Whereas with --dry-run, the file stays around.

As I say, it's because GNU patch doesn't (currently) understand GIT
patches.  I wouldn't call that a bug in GNU patch.

^ permalink raw reply	[flat|nested] 133+ messages in thread

* Re: [BUG?] rename patch accepted with --dry-run, rejected without (Re: [PATCH V3] arm & sh: factorised duplicated clkdev.c)
@ 2010-09-04  0:03               ` Russell King - ARM Linux
  0 siblings, 0 replies; 133+ messages in thread
From: Russell King - ARM Linux @ 2010-09-04  0:03 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Jonathan Nieder, linux-sh, bug-patch, Magnus Damm,
	linux-arm-kernel, Jean-Christophe PLAGNIOL-VILLARD, git

On Fri, Sep 03, 2010 at 09:33:09PM +0200, Uwe Kleine-König wrote:
> > git patches include additional metadata for renaming files, which gnu patch
> > will not understand.
> > 
> > If you want GNU patch compatible diffs, don't use -C or -M when generating
> > patches out of git.
> Still GNU patch should then already fail in --dry-run mode.

And now look at the patch - it touches arch/sh/include/asm/clkdev.h twice.
Once to remove it and once as a rename.

GNU patch not in --dry-run mode will first remove arch/sh/include/asm/clkdev.h,
and then not have a file to deal with when it tries to patch the rename
part.  Whereas with --dry-run, the file stays around.

As I say, it's because GNU patch doesn't (currently) understand GIT
patches.  I wouldn't call that a bug in GNU patch.

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [BUG?] rename patch accepted with --dry-run, rejected without (Re: [PATCH V3] arm & sh: factorised duplicated clkdev.c)
@ 2010-09-04  0:03               ` Russell King - ARM Linux
  0 siblings, 0 replies; 133+ messages in thread
From: Russell King - ARM Linux @ 2010-09-04  0:03 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Sep 03, 2010 at 09:33:09PM +0200, Uwe Kleine-K?nig wrote:
> > git patches include additional metadata for renaming files, which gnu patch
> > will not understand.
> > 
> > If you want GNU patch compatible diffs, don't use -C or -M when generating
> > patches out of git.
> Still GNU patch should then already fail in --dry-run mode.

And now look at the patch - it touches arch/sh/include/asm/clkdev.h twice.
Once to remove it and once as a rename.

GNU patch not in --dry-run mode will first remove arch/sh/include/asm/clkdev.h,
and then not have a file to deal with when it tries to patch the rename
part.  Whereas with --dry-run, the file stays around.

As I say, it's because GNU patch doesn't (currently) understand GIT
patches.  I wouldn't call that a bug in GNU patch.

^ permalink raw reply	[flat|nested] 133+ messages in thread

* Re: [bug-patch] [BUG?] rename patch accepted with --dry-run,
  2010-09-03 22:58           ` Andreas Gruenbacher
  (?)
@ 2010-09-04  3:21             ` Jean-Christophe PLAGNIOL-VILLARD
  -1 siblings, 0 replies; 133+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2010-09-04  3:21 UTC (permalink / raw)
  To: Andreas Gruenbacher
  Cc: Jonathan Nieder, bug-patch, Uwe Kleine-König, linux-sh,
	Magnus Damm, linux-arm-kernel, git

> 
> So "git apply" and "patch --dry-run" seem to work only by accident.
> 
> How was this patch generated: with git itself?
I did as usual
git format-patch -M -B -C HEAD~
> 
> The fact that "patch --dry-run" may not work for patches that modify the same 
> file twice is a known defect.  I don't know how to solve this in a reasonably 
> elegant way.  Luckily the problem only triggers when people are doing 
> something "strange" such as concatenating patches.

Best Regards,
J.

^ permalink raw reply	[flat|nested] 133+ messages in thread

* Re: [bug-patch] [BUG?] rename patch accepted with --dry-run, rejected without (Re: [PATCH V3] arm & sh: factorised duplicated clkdev.c)
@ 2010-09-04  3:21             ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 0 replies; 133+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2010-09-04  3:21 UTC (permalink / raw)
  To: Andreas Gruenbacher
  Cc: Jonathan Nieder, bug-patch, Uwe Kleine-König, linux-sh,
	Magnus Damm, linux-arm-kernel, git

> 
> So "git apply" and "patch --dry-run" seem to work only by accident.
> 
> How was this patch generated: with git itself?
I did as usual
git format-patch -M -B -C HEAD~
> 
> The fact that "patch --dry-run" may not work for patches that modify the same 
> file twice is a known defect.  I don't know how to solve this in a reasonably 
> elegant way.  Luckily the problem only triggers when people are doing 
> something "strange" such as concatenating patches.

Best Regards,
J.

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [bug-patch] [BUG?] rename patch accepted with --dry-run, rejected without (Re: [PATCH V3] arm & sh: factorised duplicated clkdev.c)
@ 2010-09-04  3:21             ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 0 replies; 133+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2010-09-04  3:21 UTC (permalink / raw)
  To: linux-arm-kernel

> 
> So "git apply" and "patch --dry-run" seem to work only by accident.
> 
> How was this patch generated: with git itself?
I did as usual
git format-patch -M -B -C HEAD~
> 
> The fact that "patch --dry-run" may not work for patches that modify the same 
> file twice is a known defect.  I don't know how to solve this in a reasonably 
> elegant way.  Luckily the problem only triggers when people are doing 
> something "strange" such as concatenating patches.

Best Regards,
J.

^ permalink raw reply	[flat|nested] 133+ messages in thread

* Re: [bug-patch] Re: [BUG?] rename patch accepted with --dry-run, rejected without (Re: [PATCH V3] ar
  2010-09-04  0:03               ` Russell King - ARM Linux
  (?)
@ 2010-09-04 21:33                 ` Andreas Gruenbacher
  -1 siblings, 0 replies; 133+ messages in thread
From: Andreas Gruenbacher @ 2010-09-04 21:33 UTC (permalink / raw)
  To: bug-patch
  Cc: Russell King - ARM Linux, Uwe Kleine-König, linux-sh,
	Magnus Damm, Jonathan Nieder, git,
	Jean-Christophe PLAGNIOL-VILLARD, linux-arm-kernel

On Saturday 04 September 2010 02:03:48 Russell King - ARM Linux wrote:
> As I say, it's because GNU patch doesn't (currently) understand GIT
> patches.  I wouldn't call that a bug in GNU patch.

GNU patch in the version used does understand GIT patch headers and does 
support things like renames.

The --dry-run option often will not work when the same file is modified more 
than once in the same patch, though.  This is because GNU patch doesn't 
remember the intermediary states of files.

In this case, the patch itself is broken.

Andreas

^ permalink raw reply	[flat|nested] 133+ messages in thread

* Re: [bug-patch] Re: [BUG?] rename patch accepted with --dry-run, rejected without (Re: [PATCH V3] arm & sh: factorised duplicated clkdev.c)
@ 2010-09-04 21:33                 ` Andreas Gruenbacher
  0 siblings, 0 replies; 133+ messages in thread
From: Andreas Gruenbacher @ 2010-09-04 21:33 UTC (permalink / raw)
  To: bug-patch
  Cc: Russell King - ARM Linux, Uwe Kleine-König, linux-sh,
	Magnus Damm, Jonathan Nieder, git,
	Jean-Christophe PLAGNIOL-VILLARD, linux-arm-kernel

On Saturday 04 September 2010 02:03:48 Russell King - ARM Linux wrote:
> As I say, it's because GNU patch doesn't (currently) understand GIT
> patches.  I wouldn't call that a bug in GNU patch.

GNU patch in the version used does understand GIT patch headers and does 
support things like renames.

The --dry-run option often will not work when the same file is modified more 
than once in the same patch, though.  This is because GNU patch doesn't 
remember the intermediary states of files.

In this case, the patch itself is broken.

Andreas

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [bug-patch] Re: [BUG?] rename patch accepted with --dry-run, rejected without (Re: [PATCH V3] arm & sh: factorised duplicated clkdev.c)
@ 2010-09-04 21:33                 ` Andreas Gruenbacher
  0 siblings, 0 replies; 133+ messages in thread
From: Andreas Gruenbacher @ 2010-09-04 21:33 UTC (permalink / raw)
  To: linux-arm-kernel

On Saturday 04 September 2010 02:03:48 Russell King - ARM Linux wrote:
> As I say, it's because GNU patch doesn't (currently) understand GIT
> patches.  I wouldn't call that a bug in GNU patch.

GNU patch in the version used does understand GIT patch headers and does 
support things like renames.

The --dry-run option often will not work when the same file is modified more 
than once in the same patch, though.  This is because GNU patch doesn't 
remember the intermediary states of files.

In this case, the patch itself is broken.

Andreas

^ permalink raw reply	[flat|nested] 133+ messages in thread

* Re: [bug-patch] Re: [BUG?] rename patch accepted with --dry-run,
  2010-09-04 21:33                 ` Andreas Gruenbacher
  (?)
@ 2010-09-04 21:45                   ` Russell King - ARM Linux
  -1 siblings, 0 replies; 133+ messages in thread
From: Russell King - ARM Linux @ 2010-09-04 21:45 UTC (permalink / raw)
  To: Andreas Gruenbacher
  Cc: bug-patch, Uwe Kleine-König, linux-sh, Magnus Damm,
	Jonathan Nieder, git, Jean-Christophe PLAGNIOL-VILLARD,
	linux-arm-kernel

On Sat, Sep 04, 2010 at 11:33:51PM +0200, Andreas Gruenbacher wrote:
> On Saturday 04 September 2010 02:03:48 Russell King - ARM Linux wrote:
> > As I say, it's because GNU patch doesn't (currently) understand GIT
> > patches.  I wouldn't call that a bug in GNU patch.
> 
> GNU patch in the version used does understand GIT patch headers and does 
> support things like renames.
> 
> The --dry-run option often will not work when the same file is modified more 
> than once in the same patch, though.  This is because GNU patch doesn't 
> remember the intermediary states of files.
> 
> In this case, the patch itself is broken.

GIT has many options to control how it produces patches, and -C or -M
allow it to reduce the size of patches making them more reviewable.  It
also makes them incompatible with GNU patch, whether or not GNU patch
understands the GIT headers.

As I've already said - if you want GNU compatible patches, don't generate
GIT patches using -C or -M.

Simples.

^ permalink raw reply	[flat|nested] 133+ messages in thread

* Re: [bug-patch] Re: [BUG?] rename patch accepted with --dry-run, rejected without (Re: [PATCH V3] arm & sh: factorised duplicated clkdev.c)
@ 2010-09-04 21:45                   ` Russell King - ARM Linux
  0 siblings, 0 replies; 133+ messages in thread
From: Russell King - ARM Linux @ 2010-09-04 21:45 UTC (permalink / raw)
  To: Andreas Gruenbacher
  Cc: bug-patch, Uwe Kleine-König, linux-sh, Magnus Damm,
	Jonathan Nieder, git, Jean-Christophe PLAGNIOL-VILLARD,
	linux-arm-kernel

On Sat, Sep 04, 2010 at 11:33:51PM +0200, Andreas Gruenbacher wrote:
> On Saturday 04 September 2010 02:03:48 Russell King - ARM Linux wrote:
> > As I say, it's because GNU patch doesn't (currently) understand GIT
> > patches.  I wouldn't call that a bug in GNU patch.
> 
> GNU patch in the version used does understand GIT patch headers and does 
> support things like renames.
> 
> The --dry-run option often will not work when the same file is modified more 
> than once in the same patch, though.  This is because GNU patch doesn't 
> remember the intermediary states of files.
> 
> In this case, the patch itself is broken.

GIT has many options to control how it produces patches, and -C or -M
allow it to reduce the size of patches making them more reviewable.  It
also makes them incompatible with GNU patch, whether or not GNU patch
understands the GIT headers.

As I've already said - if you want GNU compatible patches, don't generate
GIT patches using -C or -M.

Simples.

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [bug-patch] Re: [BUG?] rename patch accepted with --dry-run, rejected without (Re: [PATCH V3] arm & sh: factorised duplicated clkdev.c)
@ 2010-09-04 21:45                   ` Russell King - ARM Linux
  0 siblings, 0 replies; 133+ messages in thread
From: Russell King - ARM Linux @ 2010-09-04 21:45 UTC (permalink / raw)
  To: linux-arm-kernel

On Sat, Sep 04, 2010 at 11:33:51PM +0200, Andreas Gruenbacher wrote:
> On Saturday 04 September 2010 02:03:48 Russell King - ARM Linux wrote:
> > As I say, it's because GNU patch doesn't (currently) understand GIT
> > patches.  I wouldn't call that a bug in GNU patch.
> 
> GNU patch in the version used does understand GIT patch headers and does 
> support things like renames.
> 
> The --dry-run option often will not work when the same file is modified more 
> than once in the same patch, though.  This is because GNU patch doesn't 
> remember the intermediary states of files.
> 
> In this case, the patch itself is broken.

GIT has many options to control how it produces patches, and -C or -M
allow it to reduce the size of patches making them more reviewable.  It
also makes them incompatible with GNU patch, whether or not GNU patch
understands the GIT headers.

As I've already said - if you want GNU compatible patches, don't generate
GIT patches using -C or -M.

Simples.

^ permalink raw reply	[flat|nested] 133+ messages in thread

* Re: [bug-patch] Re: [BUG?] rename patch accepted with --dry-run, rejected without (Re: [PATCH V3] ar
  2010-09-04 21:45                   ` Russell King - ARM Linux
  (?)
@ 2010-09-04 21:46                     ` Andreas Gruenbacher
  -1 siblings, 0 replies; 133+ messages in thread
From: Andreas Gruenbacher @ 2010-09-04 21:46 UTC (permalink / raw)
  To: Russell King - ARM Linux
  Cc: bug-patch, Uwe Kleine-König, linux-sh, Magnus Damm,
	Jonathan Nieder, git, Jean-Christophe PLAGNIOL-VILLARD,
	linux-arm-kernel

On Saturday 04 September 2010 23:45:27 Russell King - ARM Linux wrote:
> It also makes them incompatible with GNU patch, whether or not GNU patch
> understands the GIT headers.

Aha?  Then why do you think GNU patch tries to understand the GIt patch 
headers?  So that it can be incompatible with GIT?

Andreas

^ permalink raw reply	[flat|nested] 133+ messages in thread

* Re: [bug-patch] Re: [BUG?] rename patch accepted with --dry-run, rejected without (Re: [PATCH V3] arm & sh: factorised duplicated clkdev.c)
@ 2010-09-04 21:46                     ` Andreas Gruenbacher
  0 siblings, 0 replies; 133+ messages in thread
From: Andreas Gruenbacher @ 2010-09-04 21:46 UTC (permalink / raw)
  To: Russell King - ARM Linux
  Cc: bug-patch, Uwe Kleine-König, linux-sh, Magnus Damm,
	Jonathan Nieder, git, Jean-Christophe PLAGNIOL-VILLARD,
	linux-arm-kernel

On Saturday 04 September 2010 23:45:27 Russell King - ARM Linux wrote:
> It also makes them incompatible with GNU patch, whether or not GNU patch
> understands the GIT headers.

Aha?  Then why do you think GNU patch tries to understand the GIt patch 
headers?  So that it can be incompatible with GIT?

Andreas

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [bug-patch] Re: [BUG?] rename patch accepted with --dry-run, rejected without (Re: [PATCH V3] arm & sh: factorised duplicated clkdev.c)
@ 2010-09-04 21:46                     ` Andreas Gruenbacher
  0 siblings, 0 replies; 133+ messages in thread
From: Andreas Gruenbacher @ 2010-09-04 21:46 UTC (permalink / raw)
  To: linux-arm-kernel

On Saturday 04 September 2010 23:45:27 Russell King - ARM Linux wrote:
> It also makes them incompatible with GNU patch, whether or not GNU patch
> understands the GIT headers.

Aha?  Then why do you think GNU patch tries to understand the GIt patch 
headers?  So that it can be incompatible with GIT?

Andreas

^ permalink raw reply	[flat|nested] 133+ messages in thread

* Re: [bug-patch] [BUG?] rename patch accepted with --dry-run, rejected without (Re: [PATCH V3] arm &
  2010-09-03 23:32             ` Jonathan Nieder
  (?)
@ 2010-09-04 21:57               ` Andreas Gruenbacher
  -1 siblings, 0 replies; 133+ messages in thread
From: Andreas Gruenbacher @ 2010-09-04 21:57 UTC (permalink / raw)
  To: Jonathan Nieder
  Cc: bug-patch, Uwe Kleine-König, linux-sh, Magnus Damm,
	linux-arm-kernel, Jean-Christophe PLAGNIOL-VILLARD, git

On Saturday 04 September 2010 01:32:52 Jonathan Nieder wrote:
> Andreas Gruenbacher wrote:
> 
> > something pretty bizarre is going on here.  The wget output modifies the same 
> > file twice, but both patches to this file have the same source sha1 (5645f35):
> 
> From the git v1.6.0-rc0~92 changelog entry:
> 
>     apply: fix copy/rename breakage
>     
>     7ebd52a (Merge branch 'dz/apply-again', 2008-07-01) taught "git-apply" to
>     grok a (non-git) patch that is a concatenation of separate patches that
>     touch the same file number of times, by recording the postimage of patch
>     application of previous round and using it as the preimage for later
>     rounds.
>     
>     This "incremental" mode of patch application fundamentally contradicts
>     with the way git rename/copy patches are designed.  When a git patch talks
>     about a file A getting modified, and a new file B created out of A, like
>     this:
>     
>         diff --git a/A b/A
>         --- a/A
>         +++ b/A
>         ... change text here ...
>         diff --git a/A b/B
>         copy from A
>         copy to B
>         --- a/A
>         +++ b/B
>         ... change text here ...
>     
>     the second change to produce B does not depend on what is done to A with
>     the first change in any way.  This is explicitly done so for reviewability
>     of individual patches.
>     
>     With this commit, we do not look at 'fn_table' that records the postimage
>     of previous round when applying a patch to produce a new file out of an
>     existing file.

Ouch ... this gets really messy when a user concatenates git style patches
and they are not applied to exactly the same source tree.

Thanks for digging out this commit message!

Andreas

^ permalink raw reply	[flat|nested] 133+ messages in thread

* Re: [bug-patch] [BUG?] rename patch accepted with --dry-run, rejected without (Re: [PATCH V3] arm & sh: factorised duplicated clkdev.c)
@ 2010-09-04 21:57               ` Andreas Gruenbacher
  0 siblings, 0 replies; 133+ messages in thread
From: Andreas Gruenbacher @ 2010-09-04 21:57 UTC (permalink / raw)
  To: Jonathan Nieder
  Cc: bug-patch, Uwe Kleine-König, linux-sh, Magnus Damm,
	linux-arm-kernel, Jean-Christophe PLAGNIOL-VILLARD, git

On Saturday 04 September 2010 01:32:52 Jonathan Nieder wrote:
> Andreas Gruenbacher wrote:
> 
> > something pretty bizarre is going on here.  The wget output modifies the same 
> > file twice, but both patches to this file have the same source sha1 (5645f35):
> 
> From the git v1.6.0-rc0~92 changelog entry:
> 
>     apply: fix copy/rename breakage
>     
>     7ebd52a (Merge branch 'dz/apply-again', 2008-07-01) taught "git-apply" to
>     grok a (non-git) patch that is a concatenation of separate patches that
>     touch the same file number of times, by recording the postimage of patch
>     application of previous round and using it as the preimage for later
>     rounds.
>     
>     This "incremental" mode of patch application fundamentally contradicts
>     with the way git rename/copy patches are designed.  When a git patch talks
>     about a file A getting modified, and a new file B created out of A, like
>     this:
>     
>         diff --git a/A b/A
>         --- a/A
>         +++ b/A
>         ... change text here ...
>         diff --git a/A b/B
>         copy from A
>         copy to B
>         --- a/A
>         +++ b/B
>         ... change text here ...
>     
>     the second change to produce B does not depend on what is done to A with
>     the first change in any way.  This is explicitly done so for reviewability
>     of individual patches.
>     
>     With this commit, we do not look at 'fn_table' that records the postimage
>     of previous round when applying a patch to produce a new file out of an
>     existing file.

Ouch ... this gets really messy when a user concatenates git style patches
and they are not applied to exactly the same source tree.

Thanks for digging out this commit message!

Andreas

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [bug-patch] [BUG?] rename patch accepted with --dry-run, rejected without (Re: [PATCH V3] arm & sh: factorised duplicated clkdev.c)
@ 2010-09-04 21:57               ` Andreas Gruenbacher
  0 siblings, 0 replies; 133+ messages in thread
From: Andreas Gruenbacher @ 2010-09-04 21:57 UTC (permalink / raw)
  To: linux-arm-kernel

On Saturday 04 September 2010 01:32:52 Jonathan Nieder wrote:
> Andreas Gruenbacher wrote:
> 
> > something pretty bizarre is going on here.  The wget output modifies the same 
> > file twice, but both patches to this file have the same source sha1 (5645f35):
> 
> From the git v1.6.0-rc0~92 changelog entry:
> 
>     apply: fix copy/rename breakage
>     
>     7ebd52a (Merge branch 'dz/apply-again', 2008-07-01) taught "git-apply" to
>     grok a (non-git) patch that is a concatenation of separate patches that
>     touch the same file number of times, by recording the postimage of patch
>     application of previous round and using it as the preimage for later
>     rounds.
>     
>     This "incremental" mode of patch application fundamentally contradicts
>     with the way git rename/copy patches are designed.  When a git patch talks
>     about a file A getting modified, and a new file B created out of A, like
>     this:
>     
>         diff --git a/A b/A
>         --- a/A
>         +++ b/A
>         ... change text here ...
>         diff --git a/A b/B
>         copy from A
>         copy to B
>         --- a/A
>         +++ b/B
>         ... change text here ...
>     
>     the second change to produce B does not depend on what is done to A with
>     the first change in any way.  This is explicitly done so for reviewability
>     of individual patches.
>     
>     With this commit, we do not look at 'fn_table' that records the postimage
>     of previous round when applying a patch to produce a new file out of an
>     existing file.

Ouch ... this gets really messy when a user concatenates git style patches
and they are not applied to exactly the same source tree.

Thanks for digging out this commit message!

Andreas

^ permalink raw reply	[flat|nested] 133+ messages in thread

* Re: [bug-patch] Re: [BUG?] rename patch accepted with --dry-run,
  2010-09-04 21:46                     ` Andreas Gruenbacher
  (?)
@ 2010-09-04 22:01                       ` Russell King - ARM Linux
  -1 siblings, 0 replies; 133+ messages in thread
From: Russell King - ARM Linux @ 2010-09-04 22:01 UTC (permalink / raw)
  To: Andreas Gruenbacher
  Cc: bug-patch, Uwe Kleine-König, linux-sh, Magnus Damm,
	Jonathan Nieder, git, Jean-Christophe PLAGNIOL-VILLARD,
	linux-arm-kernel

On Sat, Sep 04, 2010 at 11:46:11PM +0200, Andreas Gruenbacher wrote:
> On Saturday 04 September 2010 23:45:27 Russell King - ARM Linux wrote:
> > It also makes them incompatible with GNU patch, whether or not GNU patch
> > understands the GIT headers.
> 
> Aha?  Then why do you think GNU patch tries to understand the GIt patch 
> headers?  So that it can be incompatible with GIT?

Read what you said last time around.  "In this case, the patch itself is
broken."

So, because GNU patch doesn't understand the patch file, the patch file
must be broken?  No, the patch file is fine with GIT which can apply it
correctly, but incompatible with GNU patch because of the way GNU patch
works (as you yourself said, GNU patch doesn't keep the intermediate
states.)

I repeat - if you want maximum compatibility, want GNU patch to be able
to apply the patch with or without --dry-run, then don't use -C or -M
when generating patches with git.

Simples.

^ permalink raw reply	[flat|nested] 133+ messages in thread

* Re: [bug-patch] Re: [BUG?] rename patch accepted with --dry-run, rejected without (Re: [PATCH V3] arm & sh: factorised duplicated clkdev.c)
@ 2010-09-04 22:01                       ` Russell King - ARM Linux
  0 siblings, 0 replies; 133+ messages in thread
From: Russell King - ARM Linux @ 2010-09-04 22:01 UTC (permalink / raw)
  To: Andreas Gruenbacher
  Cc: bug-patch, Uwe Kleine-König, linux-sh, Magnus Damm,
	Jonathan Nieder, git, Jean-Christophe PLAGNIOL-VILLARD,
	linux-arm-kernel

On Sat, Sep 04, 2010 at 11:46:11PM +0200, Andreas Gruenbacher wrote:
> On Saturday 04 September 2010 23:45:27 Russell King - ARM Linux wrote:
> > It also makes them incompatible with GNU patch, whether or not GNU patch
> > understands the GIT headers.
> 
> Aha?  Then why do you think GNU patch tries to understand the GIt patch 
> headers?  So that it can be incompatible with GIT?

Read what you said last time around.  "In this case, the patch itself is
broken."

So, because GNU patch doesn't understand the patch file, the patch file
must be broken?  No, the patch file is fine with GIT which can apply it
correctly, but incompatible with GNU patch because of the way GNU patch
works (as you yourself said, GNU patch doesn't keep the intermediate
states.)

I repeat - if you want maximum compatibility, want GNU patch to be able
to apply the patch with or without --dry-run, then don't use -C or -M
when generating patches with git.

Simples.

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [bug-patch] Re: [BUG?] rename patch accepted with --dry-run, rejected without (Re: [PATCH V3] arm & sh: factorised duplicated clkdev.c)
@ 2010-09-04 22:01                       ` Russell King - ARM Linux
  0 siblings, 0 replies; 133+ messages in thread
From: Russell King - ARM Linux @ 2010-09-04 22:01 UTC (permalink / raw)
  To: linux-arm-kernel

On Sat, Sep 04, 2010 at 11:46:11PM +0200, Andreas Gruenbacher wrote:
> On Saturday 04 September 2010 23:45:27 Russell King - ARM Linux wrote:
> > It also makes them incompatible with GNU patch, whether or not GNU patch
> > understands the GIT headers.
> 
> Aha?  Then why do you think GNU patch tries to understand the GIt patch 
> headers?  So that it can be incompatible with GIT?

Read what you said last time around.  "In this case, the patch itself is
broken."

So, because GNU patch doesn't understand the patch file, the patch file
must be broken?  No, the patch file is fine with GIT which can apply it
correctly, but incompatible with GNU patch because of the way GNU patch
works (as you yourself said, GNU patch doesn't keep the intermediate
states.)

I repeat - if you want maximum compatibility, want GNU patch to be able
to apply the patch with or without --dry-run, then don't use -C or -M
when generating patches with git.

Simples.

^ permalink raw reply	[flat|nested] 133+ messages in thread

* Re: [bug-patch] Re: [BUG?] rename patch accepted with --dry-run, rejected without (Re: [PATCH V3] ar
  2010-09-04 22:01                       ` Russell King - ARM Linux
  (?)
@ 2010-09-04 22:26                         ` Andreas Gruenbacher
  -1 siblings, 0 replies; 133+ messages in thread
From: Andreas Gruenbacher @ 2010-09-04 22:26 UTC (permalink / raw)
  To: Russell King - ARM Linux
  Cc: bug-patch, Uwe Kleine-König, linux-sh, Magnus Damm,
	Jonathan Nieder, git, Jean-Christophe PLAGNIOL-VILLARD,
	linux-arm-kernel

On Sunday 05 September 2010 00:01:52 Russell King - ARM Linux wrote:
> On Sat, Sep 04, 2010 at 11:46:11PM +0200, Andreas Gruenbacher wrote:
> > On Saturday 04 September 2010 23:45:27 Russell King - ARM Linux wrote:
> > > It also makes them incompatible with GNU patch, whether or not GNU patch
> > > understands the GIT headers.
> > 
> > Aha?  Then why do you think GNU patch tries to understand the GIt patch 
> > headers?  So that it can be incompatible with GIT?
> 
> Read what you said last time around.  "In this case, the patch itself is
> broken."

I was corrected on that by Jonathan Nieder's mail which describes a detail of 
the GIT patch format that I didn't know about.  So it's a bug in the way GNU 
patch handles the git patch format and not an error in the patch.  Not nice 
and probably not easy to fix, but not fundamentally unfixable.

Andreas

^ permalink raw reply	[flat|nested] 133+ messages in thread

* Re: [bug-patch] Re: [BUG?] rename patch accepted with --dry-run, rejected without (Re: [PATCH V3] arm & sh: factorised duplicated clkdev.c)
@ 2010-09-04 22:26                         ` Andreas Gruenbacher
  0 siblings, 0 replies; 133+ messages in thread
From: Andreas Gruenbacher @ 2010-09-04 22:26 UTC (permalink / raw)
  To: Russell King - ARM Linux
  Cc: bug-patch, Uwe Kleine-König, linux-sh, Magnus Damm,
	Jonathan Nieder, git, Jean-Christophe PLAGNIOL-VILLARD,
	linux-arm-kernel

On Sunday 05 September 2010 00:01:52 Russell King - ARM Linux wrote:
> On Sat, Sep 04, 2010 at 11:46:11PM +0200, Andreas Gruenbacher wrote:
> > On Saturday 04 September 2010 23:45:27 Russell King - ARM Linux wrote:
> > > It also makes them incompatible with GNU patch, whether or not GNU patch
> > > understands the GIT headers.
> > 
> > Aha?  Then why do you think GNU patch tries to understand the GIt patch 
> > headers?  So that it can be incompatible with GIT?
> 
> Read what you said last time around.  "In this case, the patch itself is
> broken."

I was corrected on that by Jonathan Nieder's mail which describes a detail of 
the GIT patch format that I didn't know about.  So it's a bug in the way GNU 
patch handles the git patch format and not an error in the patch.  Not nice 
and probably not easy to fix, but not fundamentally unfixable.

Andreas

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [bug-patch] Re: [BUG?] rename patch accepted with --dry-run, rejected without (Re: [PATCH V3] arm & sh: factorised duplicated clkdev.c)
@ 2010-09-04 22:26                         ` Andreas Gruenbacher
  0 siblings, 0 replies; 133+ messages in thread
From: Andreas Gruenbacher @ 2010-09-04 22:26 UTC (permalink / raw)
  To: linux-arm-kernel

On Sunday 05 September 2010 00:01:52 Russell King - ARM Linux wrote:
> On Sat, Sep 04, 2010 at 11:46:11PM +0200, Andreas Gruenbacher wrote:
> > On Saturday 04 September 2010 23:45:27 Russell King - ARM Linux wrote:
> > > It also makes them incompatible with GNU patch, whether or not GNU patch
> > > understands the GIT headers.
> > 
> > Aha?  Then why do you think GNU patch tries to understand the GIt patch 
> > headers?  So that it can be incompatible with GIT?
> 
> Read what you said last time around.  "In this case, the patch itself is
> broken."

I was corrected on that by Jonathan Nieder's mail which describes a detail of 
the GIT patch format that I didn't know about.  So it's a bug in the way GNU 
patch handles the git patch format and not an error in the patch.  Not nice 
and probably not easy to fix, but not fundamentally unfixable.

Andreas

^ permalink raw reply	[flat|nested] 133+ messages in thread

* Re: [PATCH 1/5] ARM: omap/fb: move omap_init_fb to .init.text
  2010-09-02  8:03               ` Uwe Kleine-König
@ 2010-09-09  8:40                 ` Tomi Valkeinen
  -1 siblings, 0 replies; 133+ messages in thread
From: Tomi Valkeinen @ 2010-09-09  8:40 UTC (permalink / raw)
  To: ext Uwe Kleine-König; +Cc: linux-omap, linux-arm-kernel

Hi,

On Thu, 2010-09-02 at 10:03 +0200, ext Uwe Kleine-König wrote:
> omap_init_fb() is only called as arch_initcall and so can live in
> .init.text.
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

I picked patches 1, 2 and 3 from this patch set to my tree. They look
fine, thanks!

Patch 4 should probably go through Tony, and 5 was marked
work-in-progress.

 Tomi


--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [PATCH 1/5] ARM: omap/fb: move omap_init_fb to .init.text
@ 2010-09-09  8:40                 ` Tomi Valkeinen
  0 siblings, 0 replies; 133+ messages in thread
From: Tomi Valkeinen @ 2010-09-09  8:40 UTC (permalink / raw)
  To: linux-arm-kernel

Hi,

On Thu, 2010-09-02 at 10:03 +0200, ext Uwe Kleine-K?nig wrote:
> omap_init_fb() is only called as arch_initcall and so can live in
> .init.text.
> 
> Signed-off-by: Uwe Kleine-K?nig <u.kleine-koenig@pengutronix.de>

I picked patches 1, 2 and 3 from this patch set to my tree. They look
fine, thanks!

Patch 4 should probably go through Tony, and 5 was marked
work-in-progress.

 Tomi

^ permalink raw reply	[flat|nested] 133+ messages in thread

* Re: [PATCH V3] arm & sh: factorised duplicated clkdev.c
  2010-09-02 13:39     ` Jean-Christophe PLAGNIOL-VILLARD
@ 2010-09-09  9:53       ` Jean-Christophe PLAGNIOL-VILLARD
  -1 siblings, 0 replies; 133+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2010-09-09  9:53 UTC (permalink / raw)
  To: linux-sh

On 15:39 Thu 02 Sep     , Jean-Christophe PLAGNIOL-VILLARD wrote:
> factorise some generic infrastructure to assist looking up struct clks
> for the ARM & SH architecture.
> 
> as the code is identical at 99%
> 
> put the arch specific code for allocation as example in asm/clkdev.h
> 
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
is it ok?

Best Regards,
J.

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [PATCH V3] arm & sh: factorised duplicated clkdev.c
@ 2010-09-09  9:53       ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 0 replies; 133+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2010-09-09  9:53 UTC (permalink / raw)
  To: linux-arm-kernel

On 15:39 Thu 02 Sep     , Jean-Christophe PLAGNIOL-VILLARD wrote:
> factorise some generic infrastructure to assist looking up struct clks
> for the ARM & SH architecture.
> 
> as the code is identical at 99%
> 
> put the arch specific code for allocation as example in asm/clkdev.h
> 
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
is it ok?

Best Regards,
J.

^ permalink raw reply	[flat|nested] 133+ messages in thread

* Re: [PATCH V3] arm & sh: factorised duplicated clkdev.c
  2010-09-09  9:53       ` Jean-Christophe PLAGNIOL-VILLARD
@ 2010-09-14  7:59         ` Paul Mundt
  -1 siblings, 0 replies; 133+ messages in thread
From: Paul Mundt @ 2010-09-14  7:59 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Sep 09, 2010 at 11:53:47AM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> On 15:39 Thu 02 Sep     , Jean-Christophe PLAGNIOL-VILLARD wrote:
> > factorise some generic infrastructure to assist looking up struct clks
> > for the ARM & SH architecture.
> > 
> > as the code is identical at 99%
> > 
> > put the arch specific code for allocation as example in asm/clkdev.h
> > 
> > Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> is it ok?
> 
It's fine with me, but this will want to go via the ARM tree. You'll
probably want to submit this to the ARM patch tracker, and you can add my
Acked-by for the SH and SH-Mobile bits.

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [PATCH V3] arm & sh: factorised duplicated clkdev.c
@ 2010-09-14  7:59         ` Paul Mundt
  0 siblings, 0 replies; 133+ messages in thread
From: Paul Mundt @ 2010-09-14  7:59 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Sep 09, 2010 at 11:53:47AM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> On 15:39 Thu 02 Sep     , Jean-Christophe PLAGNIOL-VILLARD wrote:
> > factorise some generic infrastructure to assist looking up struct clks
> > for the ARM & SH architecture.
> > 
> > as the code is identical at 99%
> > 
> > put the arch specific code for allocation as example in asm/clkdev.h
> > 
> > Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> is it ok?
> 
It's fine with me, but this will want to go via the ARM tree. You'll
probably want to submit this to the ARM patch tracker, and you can add my
Acked-by for the SH and SH-Mobile bits.

^ permalink raw reply	[flat|nested] 133+ messages in thread

* Re: [PATCH V3] arm & sh: factorised duplicated clkdev.c
  2010-09-14  7:59         ` Paul Mundt
@ 2010-09-15  5:51           ` Jean-Christophe PLAGNIOL-VILLARD
  -1 siblings, 0 replies; 133+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2010-09-15  5:51 UTC (permalink / raw)
  To: linux-arm-kernel

On 16:59 Tue 14 Sep     , Paul Mundt wrote:
> On Thu, Sep 09, 2010 at 11:53:47AM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > On 15:39 Thu 02 Sep     , Jean-Christophe PLAGNIOL-VILLARD wrote:
> > > factorise some generic infrastructure to assist looking up struct clks
> > > for the ARM & SH architecture.
> > > 
> > > as the code is identical at 99%
> > > 
> > > put the arch specific code for allocation as example in asm/clkdev.h
> > > 
> > > Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> > is it ok?
> > 
> It's fine with me, but this will want to go via the ARM tree. You'll
> probably want to submit this to the ARM patch tracker, and you can add my
> Acked-by for the SH and SH-Mobile bits.
Add in patch tracket as 6390/1

Best Regards,
J.

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [PATCH V3] arm & sh: factorised duplicated clkdev.c
@ 2010-09-15  5:51           ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 0 replies; 133+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2010-09-15  5:51 UTC (permalink / raw)
  To: linux-arm-kernel

On 16:59 Tue 14 Sep     , Paul Mundt wrote:
> On Thu, Sep 09, 2010 at 11:53:47AM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > On 15:39 Thu 02 Sep     , Jean-Christophe PLAGNIOL-VILLARD wrote:
> > > factorise some generic infrastructure to assist looking up struct clks
> > > for the ARM & SH architecture.
> > > 
> > > as the code is identical at 99%
> > > 
> > > put the arch specific code for allocation as example in asm/clkdev.h
> > > 
> > > Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> > is it ok?
> > 
> It's fine with me, but this will want to go via the ARM tree. You'll
> probably want to submit this to the ARM patch tracker, and you can add my
> Acked-by for the SH and SH-Mobile bits.
Add in patch tracket as 6390/1

Best Regards,
J.

^ permalink raw reply	[flat|nested] 133+ messages in thread

* Re: [PATCH V3] arm & sh: factorised duplicated clkdev.c
  2010-09-09  9:53       ` Jean-Christophe PLAGNIOL-VILLARD
@ 2010-10-04 19:46         ` Russell King - ARM Linux
  -1 siblings, 0 replies; 133+ messages in thread
From: Russell King - ARM Linux @ 2010-10-04 19:46 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Sep 09, 2010 at 11:53:47AM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> On 15:39 Thu 02 Sep     , Jean-Christophe PLAGNIOL-VILLARD wrote:
> > factorise some generic infrastructure to assist looking up struct clks
> > for the ARM & SH architecture.
> > 
> > as the code is identical at 99%
> > 
> > put the arch specific code for allocation as example in asm/clkdev.h
> > 
> > Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> is it ok?

Just applied it and dropped it - it seems to miss deleting the old files.
Please resubmit with the old files removed.

BTW, patch system understands git -C and -M patches.

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [PATCH V3] arm & sh: factorised duplicated clkdev.c
@ 2010-10-04 19:46         ` Russell King - ARM Linux
  0 siblings, 0 replies; 133+ messages in thread
From: Russell King - ARM Linux @ 2010-10-04 19:46 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Sep 09, 2010 at 11:53:47AM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> On 15:39 Thu 02 Sep     , Jean-Christophe PLAGNIOL-VILLARD wrote:
> > factorise some generic infrastructure to assist looking up struct clks
> > for the ARM & SH architecture.
> > 
> > as the code is identical at 99%
> > 
> > put the arch specific code for allocation as example in asm/clkdev.h
> > 
> > Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> is it ok?

Just applied it and dropped it - it seems to miss deleting the old files.
Please resubmit with the old files removed.

BTW, patch system understands git -C and -M patches.

^ permalink raw reply	[flat|nested] 133+ messages in thread

* Re: [PATCH] ARM: omap1/nokia770: mark some functions __init
  2010-09-02  6:17           ` [PATCH] ARM: omap1/nokia770: mark some functions __init Uwe Kleine-König
@ 2011-02-03  8:15               ` Uwe Kleine-König
  2010-09-02  8:03               ` Uwe Kleine-König
                                 ` (4 subsequent siblings)
  5 siblings, 0 replies; 133+ messages in thread
From: Uwe Kleine-König @ 2011-02-03  8:15 UTC (permalink / raw)
  To: Tony Lindgren; +Cc: linux-omap, linux-arm-kernel

Hey Tony,

this patch below is now 4 months old and I didn't get any feedback.  (Though I
somehow missed to cc linux-omap@vger.kernel.org before, sorry for that.)

There are two more patches in this thread that are not yet
applied/commented.  Should I resend?

Best regards
Uwe

On Thu, Sep 02, 2010 at 08:17:10AM +0200, Uwe Kleine-König wrote:
> These are only called from omap_nokia770_init which is in .init.text, too.
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> ---
>  arch/arm/mach-omap1/board-nokia770.c |    6 +++---
>  1 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/arm/mach-omap1/board-nokia770.c b/arch/arm/mach-omap1/board-nokia770.c
> index 51a4539..09b3f46 100644
> --- a/arch/arm/mach-omap1/board-nokia770.c
> +++ b/arch/arm/mach-omap1/board-nokia770.c
> @@ -112,7 +112,7 @@ static struct mipid_platform_data nokia770_mipid_platform_data = {
>  	.shutdown = mipid_shutdown,
>  };
>  
> -static void mipid_dev_init(void)
> +static void __init mipid_dev_init(void)
>  {
>  	const struct omap_lcd_config *conf;
>  
> @@ -123,7 +123,7 @@ static void mipid_dev_init(void)
>  	}
>  }
>  
> -static void ads7846_dev_init(void)
> +static void __init ads7846_dev_init(void)
>  {
>  	if (gpio_request(ADS7846_PENDOWN_GPIO, "ADS7846 pendown") < 0)
>  		printk(KERN_ERR "can't get ads7846 pen down GPIO\n");
> @@ -167,7 +167,7 @@ static struct hwa742_platform_data nokia770_hwa742_platform_data = {
>  	.te_connected		= 1,
>  };
>  
> -static void hwa742_dev_init(void)
> +static void __init hwa742_dev_init(void)
>  {
>  	clk_add_alias("hwa_sys_ck", NULL, "bclk", NULL);
>  	omapfb_set_ctrl_platform_data(&nokia770_hwa742_platform_data);
> -- 
> 1.7.1

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [PATCH] ARM: omap1/nokia770: mark some functions __init
@ 2011-02-03  8:15               ` Uwe Kleine-König
  0 siblings, 0 replies; 133+ messages in thread
From: Uwe Kleine-König @ 2011-02-03  8:15 UTC (permalink / raw)
  To: linux-arm-kernel

Hey Tony,

this patch below is now 4 months old and I didn't get any feedback.  (Though I
somehow missed to cc linux-omap at vger.kernel.org before, sorry for that.)

There are two more patches in this thread that are not yet
applied/commented.  Should I resend?

Best regards
Uwe

On Thu, Sep 02, 2010 at 08:17:10AM +0200, Uwe Kleine-K?nig wrote:
> These are only called from omap_nokia770_init which is in .init.text, too.
> 
> Signed-off-by: Uwe Kleine-K?nig <u.kleine-koenig@pengutronix.de>
> ---
>  arch/arm/mach-omap1/board-nokia770.c |    6 +++---
>  1 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/arm/mach-omap1/board-nokia770.c b/arch/arm/mach-omap1/board-nokia770.c
> index 51a4539..09b3f46 100644
> --- a/arch/arm/mach-omap1/board-nokia770.c
> +++ b/arch/arm/mach-omap1/board-nokia770.c
> @@ -112,7 +112,7 @@ static struct mipid_platform_data nokia770_mipid_platform_data = {
>  	.shutdown = mipid_shutdown,
>  };
>  
> -static void mipid_dev_init(void)
> +static void __init mipid_dev_init(void)
>  {
>  	const struct omap_lcd_config *conf;
>  
> @@ -123,7 +123,7 @@ static void mipid_dev_init(void)
>  	}
>  }
>  
> -static void ads7846_dev_init(void)
> +static void __init ads7846_dev_init(void)
>  {
>  	if (gpio_request(ADS7846_PENDOWN_GPIO, "ADS7846 pendown") < 0)
>  		printk(KERN_ERR "can't get ads7846 pen down GPIO\n");
> @@ -167,7 +167,7 @@ static struct hwa742_platform_data nokia770_hwa742_platform_data = {
>  	.te_connected		= 1,
>  };
>  
> -static void hwa742_dev_init(void)
> +static void __init hwa742_dev_init(void)
>  {
>  	clk_add_alias("hwa_sys_ck", NULL, "bclk", NULL);
>  	omapfb_set_ctrl_platform_data(&nokia770_hwa742_platform_data);
> -- 
> 1.7.1

-- 
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

^ permalink raw reply	[flat|nested] 133+ messages in thread

* Re: [PATCH] ARM: omap1/nokia770: mark some functions __init
  2011-02-03  8:15               ` Uwe Kleine-König
@ 2011-02-08  9:59                 ` Uwe Kleine-König
  -1 siblings, 0 replies; 133+ messages in thread
From: Uwe Kleine-König @ 2011-02-08  9:59 UTC (permalink / raw)
  To: Tony Lindgren; +Cc: linux-omap, linux-arm-kernel

On Thu, Feb 03, 2011 at 09:15:08AM +0100, Uwe Kleine-König wrote:
> Hey Tony,
> 
> this patch below is now 4 months old and I didn't get any feedback.  (Though I
> somehow missed to cc linux-omap@vger.kernel.org before, sorry for that.)
> 
> There are two more patches in this thread that are not yet
> applied/commented.  Should I resend?
ping

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [PATCH] ARM: omap1/nokia770: mark some functions __init
@ 2011-02-08  9:59                 ` Uwe Kleine-König
  0 siblings, 0 replies; 133+ messages in thread
From: Uwe Kleine-König @ 2011-02-08  9:59 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Feb 03, 2011 at 09:15:08AM +0100, Uwe Kleine-K?nig wrote:
> Hey Tony,
> 
> this patch below is now 4 months old and I didn't get any feedback.  (Though I
> somehow missed to cc linux-omap at vger.kernel.org before, sorry for that.)
> 
> There are two more patches in this thread that are not yet
> applied/commented.  Should I resend?
ping

-- 
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

^ permalink raw reply	[flat|nested] 133+ messages in thread

* Re: [PATCH] ARM: omap1/nokia770: mark some functions __init
  2011-02-08  9:59                 ` Uwe Kleine-König
@ 2011-02-09 19:27                   ` Tony Lindgren
  -1 siblings, 0 replies; 133+ messages in thread
From: Tony Lindgren @ 2011-02-09 19:27 UTC (permalink / raw)
  To: Uwe Kleine-König; +Cc: linux-omap, linux-arm-kernel

* Uwe Kleine-König <u.kleine-koenig@pengutronix.de> [110208 01:58]:
> On Thu, Feb 03, 2011 at 09:15:08AM +0100, Uwe Kleine-König wrote:
> > Hey Tony,
> > 
> > this patch below is now 4 months old and I didn't get any feedback.  (Though I
> > somehow missed to cc linux-omap@vger.kernel.org before, sorry for that.)

Sorry I must have missed those.

> > There are two more patches in this thread that are not yet
> > applied/commented.  Should I resend?
> ping

Well I usually purge my mailing list archives after about a month
or so. Can you please resend or bounce the thread to me?

Regards,

Tony
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [PATCH] ARM: omap1/nokia770: mark some functions __init
@ 2011-02-09 19:27                   ` Tony Lindgren
  0 siblings, 0 replies; 133+ messages in thread
From: Tony Lindgren @ 2011-02-09 19:27 UTC (permalink / raw)
  To: linux-arm-kernel

* Uwe Kleine-K?nig <u.kleine-koenig@pengutronix.de> [110208 01:58]:
> On Thu, Feb 03, 2011 at 09:15:08AM +0100, Uwe Kleine-K?nig wrote:
> > Hey Tony,
> > 
> > this patch below is now 4 months old and I didn't get any feedback.  (Though I
> > somehow missed to cc linux-omap at vger.kernel.org before, sorry for that.)

Sorry I must have missed those.

> > There are two more patches in this thread that are not yet
> > applied/commented.  Should I resend?
> ping

Well I usually purge my mailing list archives after about a month
or so. Can you please resend or bounce the thread to me?

Regards,

Tony

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [PATCH 1/4] ARM: omap1/nokia770: mark some functions __init
  2011-02-09 19:27                   ` Tony Lindgren
@ 2011-02-09 20:40                     ` Uwe Kleine-König
  -1 siblings, 0 replies; 133+ messages in thread
From: Uwe Kleine-König @ 2011-02-09 20:40 UTC (permalink / raw)
  To: Tony Lindgren; +Cc: linux-omap, linux-arm-kernel

These are only called from omap_nokia770_init which is in .init.text, too.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 arch/arm/mach-omap1/board-nokia770.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/arm/mach-omap1/board-nokia770.c b/arch/arm/mach-omap1/board-nokia770.c
index d21f09d..cfd0849 100644
--- a/arch/arm/mach-omap1/board-nokia770.c
+++ b/arch/arm/mach-omap1/board-nokia770.c
@@ -115,7 +115,7 @@ static struct mipid_platform_data nokia770_mipid_platform_data = {
 	.shutdown = mipid_shutdown,
 };
 
-static void mipid_dev_init(void)
+static void __init mipid_dev_init(void)
 {
 	const struct omap_lcd_config *conf;
 
@@ -126,7 +126,7 @@ static void mipid_dev_init(void)
 	}
 }
 
-static void ads7846_dev_init(void)
+static void __init ads7846_dev_init(void)
 {
 	if (gpio_request(ADS7846_PENDOWN_GPIO, "ADS7846 pendown") < 0)
 		printk(KERN_ERR "can't get ads7846 pen down GPIO\n");
@@ -170,7 +170,7 @@ static struct hwa742_platform_data nokia770_hwa742_platform_data = {
 	.te_connected		= 1,
 };
 
-static void hwa742_dev_init(void)
+static void __init hwa742_dev_init(void)
 {
 	clk_add_alias("hwa_sys_ck", NULL, "bclk", NULL);
 	omapfb_set_ctrl_platform_data(&nokia770_hwa742_platform_data);
-- 
1.7.2.3

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [PATCH 1/4] ARM: omap1/nokia770: mark some functions __init
@ 2011-02-09 20:40                     ` Uwe Kleine-König
  0 siblings, 0 replies; 133+ messages in thread
From: Uwe Kleine-König @ 2011-02-09 20:40 UTC (permalink / raw)
  To: linux-arm-kernel

These are only called from omap_nokia770_init which is in .init.text, too.

Signed-off-by: Uwe Kleine-K?nig <u.kleine-koenig@pengutronix.de>
---
 arch/arm/mach-omap1/board-nokia770.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/arm/mach-omap1/board-nokia770.c b/arch/arm/mach-omap1/board-nokia770.c
index d21f09d..cfd0849 100644
--- a/arch/arm/mach-omap1/board-nokia770.c
+++ b/arch/arm/mach-omap1/board-nokia770.c
@@ -115,7 +115,7 @@ static struct mipid_platform_data nokia770_mipid_platform_data = {
 	.shutdown = mipid_shutdown,
 };
 
-static void mipid_dev_init(void)
+static void __init mipid_dev_init(void)
 {
 	const struct omap_lcd_config *conf;
 
@@ -126,7 +126,7 @@ static void mipid_dev_init(void)
 	}
 }
 
-static void ads7846_dev_init(void)
+static void __init ads7846_dev_init(void)
 {
 	if (gpio_request(ADS7846_PENDOWN_GPIO, "ADS7846 pendown") < 0)
 		printk(KERN_ERR "can't get ads7846 pen down GPIO\n");
@@ -170,7 +170,7 @@ static struct hwa742_platform_data nokia770_hwa742_platform_data = {
 	.te_connected		= 1,
 };
 
-static void hwa742_dev_init(void)
+static void __init hwa742_dev_init(void)
 {
 	clk_add_alias("hwa_sys_ck", NULL, "bclk", NULL);
 	omapfb_set_ctrl_platform_data(&nokia770_hwa742_platform_data);
-- 
1.7.2.3

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [PATCH 2/4] ARM: omap: move omap_get_config et al. to .init.text
  2011-02-09 19:27                   ` Tony Lindgren
@ 2011-02-09 20:40                     ` Uwe Kleine-König
  -1 siblings, 0 replies; 133+ messages in thread
From: Uwe Kleine-König @ 2011-02-09 20:40 UTC (permalink / raw)
  To: Tony Lindgren; +Cc: linux-omap, linux-arm-kernel

All callers of these functions live in .init.text, so these can go there,
too.  There they must not be exported anymore, this is no problem though,
as all callers are always built-in.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 arch/arm/plat-omap/common.c             |    6 ++----
 arch/arm/plat-omap/include/plat/board.h |    4 ++--
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/arch/arm/plat-omap/common.c b/arch/arm/plat-omap/common.c
index f047318..30c698e 100644
--- a/arch/arm/plat-omap/common.c
+++ b/arch/arm/plat-omap/common.c
@@ -49,17 +49,15 @@ static const void *get_config(u16 tag, size_t len, int skip, size_t *len_out)
 	return kinfo->data;
 }
 
-const void *__omap_get_config(u16 tag, size_t len, int nr)
+const void *__init __omap_get_config(u16 tag, size_t len, int nr)
 {
         return get_config(tag, len, nr, NULL);
 }
-EXPORT_SYMBOL(__omap_get_config);
 
-const void *omap_get_var_config(u16 tag, size_t *len)
+const void *__init omap_get_var_config(u16 tag, size_t *len)
 {
         return get_config(tag, NO_LENGTH_CHECK, 0, len);
 }
-EXPORT_SYMBOL(omap_get_var_config);
 
 void __init omap_reserve(void)
 {
diff --git a/arch/arm/plat-omap/include/plat/board.h b/arch/arm/plat-omap/include/plat/board.h
index 3cf4fa2..97126df 100644
--- a/arch/arm/plat-omap/include/plat/board.h
+++ b/arch/arm/plat-omap/include/plat/board.h
@@ -151,14 +151,14 @@ struct omap_board_config_kernel {
 	const void *data;
 };
 
-extern const void *__omap_get_config(u16 tag, size_t len, int nr);
+extern const void *__init __omap_get_config(u16 tag, size_t len, int nr);
 
 #define omap_get_config(tag, type) \
 	((const type *) __omap_get_config((tag), sizeof(type), 0))
 #define omap_get_nr_config(tag, type, nr) \
 	((const type *) __omap_get_config((tag), sizeof(type), (nr)))
 
-extern const void *omap_get_var_config(u16 tag, size_t *len);
+extern const void *__init omap_get_var_config(u16 tag, size_t *len);
 
 extern struct omap_board_config_kernel *omap_board_config;
 extern int omap_board_config_size;
-- 
1.7.2.3

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [PATCH 2/4] ARM: omap: move omap_get_config et al. to .init.text
@ 2011-02-09 20:40                     ` Uwe Kleine-König
  0 siblings, 0 replies; 133+ messages in thread
From: Uwe Kleine-König @ 2011-02-09 20:40 UTC (permalink / raw)
  To: linux-arm-kernel

All callers of these functions live in .init.text, so these can go there,
too.  There they must not be exported anymore, this is no problem though,
as all callers are always built-in.

Signed-off-by: Uwe Kleine-K?nig <u.kleine-koenig@pengutronix.de>
---
 arch/arm/plat-omap/common.c             |    6 ++----
 arch/arm/plat-omap/include/plat/board.h |    4 ++--
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/arch/arm/plat-omap/common.c b/arch/arm/plat-omap/common.c
index f047318..30c698e 100644
--- a/arch/arm/plat-omap/common.c
+++ b/arch/arm/plat-omap/common.c
@@ -49,17 +49,15 @@ static const void *get_config(u16 tag, size_t len, int skip, size_t *len_out)
 	return kinfo->data;
 }
 
-const void *__omap_get_config(u16 tag, size_t len, int nr)
+const void *__init __omap_get_config(u16 tag, size_t len, int nr)
 {
         return get_config(tag, len, nr, NULL);
 }
-EXPORT_SYMBOL(__omap_get_config);
 
-const void *omap_get_var_config(u16 tag, size_t *len)
+const void *__init omap_get_var_config(u16 tag, size_t *len)
 {
         return get_config(tag, NO_LENGTH_CHECK, 0, len);
 }
-EXPORT_SYMBOL(omap_get_var_config);
 
 void __init omap_reserve(void)
 {
diff --git a/arch/arm/plat-omap/include/plat/board.h b/arch/arm/plat-omap/include/plat/board.h
index 3cf4fa2..97126df 100644
--- a/arch/arm/plat-omap/include/plat/board.h
+++ b/arch/arm/plat-omap/include/plat/board.h
@@ -151,14 +151,14 @@ struct omap_board_config_kernel {
 	const void *data;
 };
 
-extern const void *__omap_get_config(u16 tag, size_t len, int nr);
+extern const void *__init __omap_get_config(u16 tag, size_t len, int nr);
 
 #define omap_get_config(tag, type) \
 	((const type *) __omap_get_config((tag), sizeof(type), 0))
 #define omap_get_nr_config(tag, type, nr) \
 	((const type *) __omap_get_config((tag), sizeof(type), (nr)))
 
-extern const void *omap_get_var_config(u16 tag, size_t *len);
+extern const void *__init omap_get_var_config(u16 tag, size_t *len);
 
 extern struct omap_board_config_kernel *omap_board_config;
 extern int omap_board_config_size;
-- 
1.7.2.3

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [PATCH 3/4] ARM: omap: move omap_board_config_kernel to .init.data
  2011-02-09 19:27                   ` Tony Lindgren
@ 2011-02-09 20:40                     ` Uwe Kleine-König
  -1 siblings, 0 replies; 133+ messages in thread
From: Uwe Kleine-König @ 2011-02-09 20:40 UTC (permalink / raw)
  To: Tony Lindgren; +Cc: linux-omap, linux-arm-kernel

This variable is only assigned in __init functions and never used later.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 arch/arm/plat-omap/common.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/arm/plat-omap/common.c b/arch/arm/plat-omap/common.c
index 30c698e..d9f10a3 100644
--- a/arch/arm/plat-omap/common.c
+++ b/arch/arm/plat-omap/common.c
@@ -24,10 +24,11 @@
 
 #define NO_LENGTH_CHECK 0xffffffff
 
-struct omap_board_config_kernel *omap_board_config;
+struct omap_board_config_kernel *omap_board_config __initdata;
 int omap_board_config_size;
 
-static const void *get_config(u16 tag, size_t len, int skip, size_t *len_out)
+static const void *__init get_config(u16 tag, size_t len,
+		int skip, size_t *len_out)
 {
 	struct omap_board_config_kernel *kinfo = NULL;
 	int i;
-- 
1.7.2.3

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [PATCH 3/4] ARM: omap: move omap_board_config_kernel to .init.data
@ 2011-02-09 20:40                     ` Uwe Kleine-König
  0 siblings, 0 replies; 133+ messages in thread
From: Uwe Kleine-König @ 2011-02-09 20:40 UTC (permalink / raw)
  To: linux-arm-kernel

This variable is only assigned in __init functions and never used later.

Signed-off-by: Uwe Kleine-K?nig <u.kleine-koenig@pengutronix.de>
---
 arch/arm/plat-omap/common.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/arm/plat-omap/common.c b/arch/arm/plat-omap/common.c
index 30c698e..d9f10a3 100644
--- a/arch/arm/plat-omap/common.c
+++ b/arch/arm/plat-omap/common.c
@@ -24,10 +24,11 @@
 
 #define NO_LENGTH_CHECK 0xffffffff
 
-struct omap_board_config_kernel *omap_board_config;
+struct omap_board_config_kernel *omap_board_config __initdata;
 int omap_board_config_size;
 
-static const void *get_config(u16 tag, size_t len, int skip, size_t *len_out)
+static const void *__init get_config(u16 tag, size_t len,
+		int skip, size_t *len_out)
 {
 	struct omap_board_config_kernel *kinfo = NULL;
 	int i;
-- 
1.7.2.3

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [PATCH 4/4] wip: fix section mismatches in omap1_defconfig
  2011-02-09 19:27                   ` Tony Lindgren
@ 2011-02-09 20:40                     ` Uwe Kleine-König
  -1 siblings, 0 replies; 133+ messages in thread
From: Uwe Kleine-König @ 2011-02-09 20:40 UTC (permalink / raw)
  To: Tony Lindgren; +Cc: linux-omap, linux-arm-kernel

after these changes omap1_defconfig and omap2plus_defconfig don't have any
section mismatches any more, making it plausible that the patches earlier
in this series are OK.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 arch/arm/mach-omap1/board-ams-delta.c |    4 ++--
 arch/arm/mach-omap1/board-fsample.c   |    2 +-
 drivers/usb/otg/isp1301_omap.c        |    2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/arm/mach-omap1/board-ams-delta.c b/arch/arm/mach-omap1/board-ams-delta.c
index 22cc8c8..560e33f 100644
--- a/arch/arm/mach-omap1/board-ams-delta.c
+++ b/arch/arm/mach-omap1/board-ams-delta.c
@@ -175,7 +175,7 @@ static struct omap_usb_config ams_delta_usb_config __initdata = {
 	.pins[0]	= 2,
 };
 
-static struct omap_board_config_kernel ams_delta_config[] = {
+static struct omap_board_config_kernel ams_delta_config[] __initdata = {
 	{ OMAP_TAG_LCD,		&ams_delta_lcd_config },
 };
 
@@ -259,7 +259,7 @@ static int ams_delta_camera_power(struct device *dev, int power)
 #define ams_delta_camera_power	NULL
 #endif
 
-static struct soc_camera_link __initdata ams_delta_iclink = {
+static struct soc_camera_link ams_delta_iclink = {
 	.bus_id         = 0,	/* OMAP1 SoC camera bus */
 	.i2c_adapter_id = 1,
 	.board_info     = &ams_delta_camera_board_info[0],
diff --git a/arch/arm/mach-omap1/board-fsample.c b/arch/arm/mach-omap1/board-fsample.c
index 0efb9db..6b98eef 100644
--- a/arch/arm/mach-omap1/board-fsample.c
+++ b/arch/arm/mach-omap1/board-fsample.c
@@ -291,7 +291,7 @@ static struct omap_lcd_config fsample_lcd_config __initdata = {
 	.ctrl_name	= "internal",
 };
 
-static struct omap_board_config_kernel fsample_config[] = {
+static struct omap_board_config_kernel fsample_config[] __initdata = {
 	{ OMAP_TAG_LCD,		&fsample_lcd_config },
 };
 
diff --git a/drivers/usb/otg/isp1301_omap.c b/drivers/usb/otg/isp1301_omap.c
index e00fa1b..8c6fdef 100644
--- a/drivers/usb/otg/isp1301_omap.c
+++ b/drivers/usb/otg/isp1301_omap.c
@@ -1510,7 +1510,7 @@ isp1301_start_hnp(struct otg_transceiver *dev)
 
 /*-------------------------------------------------------------------------*/
 
-static int __init
+static int __devinit
 isp1301_probe(struct i2c_client *i2c, const struct i2c_device_id *id)
 {
 	int			status;
-- 
1.7.2.3

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [PATCH 4/4] wip: fix section mismatches in omap1_defconfig
@ 2011-02-09 20:40                     ` Uwe Kleine-König
  0 siblings, 0 replies; 133+ messages in thread
From: Uwe Kleine-König @ 2011-02-09 20:40 UTC (permalink / raw)
  To: linux-arm-kernel

after these changes omap1_defconfig and omap2plus_defconfig don't have any
section mismatches any more, making it plausible that the patches earlier
in this series are OK.

Signed-off-by: Uwe Kleine-K?nig <u.kleine-koenig@pengutronix.de>
---
 arch/arm/mach-omap1/board-ams-delta.c |    4 ++--
 arch/arm/mach-omap1/board-fsample.c   |    2 +-
 drivers/usb/otg/isp1301_omap.c        |    2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/arm/mach-omap1/board-ams-delta.c b/arch/arm/mach-omap1/board-ams-delta.c
index 22cc8c8..560e33f 100644
--- a/arch/arm/mach-omap1/board-ams-delta.c
+++ b/arch/arm/mach-omap1/board-ams-delta.c
@@ -175,7 +175,7 @@ static struct omap_usb_config ams_delta_usb_config __initdata = {
 	.pins[0]	= 2,
 };
 
-static struct omap_board_config_kernel ams_delta_config[] = {
+static struct omap_board_config_kernel ams_delta_config[] __initdata = {
 	{ OMAP_TAG_LCD,		&ams_delta_lcd_config },
 };
 
@@ -259,7 +259,7 @@ static int ams_delta_camera_power(struct device *dev, int power)
 #define ams_delta_camera_power	NULL
 #endif
 
-static struct soc_camera_link __initdata ams_delta_iclink = {
+static struct soc_camera_link ams_delta_iclink = {
 	.bus_id         = 0,	/* OMAP1 SoC camera bus */
 	.i2c_adapter_id = 1,
 	.board_info     = &ams_delta_camera_board_info[0],
diff --git a/arch/arm/mach-omap1/board-fsample.c b/arch/arm/mach-omap1/board-fsample.c
index 0efb9db..6b98eef 100644
--- a/arch/arm/mach-omap1/board-fsample.c
+++ b/arch/arm/mach-omap1/board-fsample.c
@@ -291,7 +291,7 @@ static struct omap_lcd_config fsample_lcd_config __initdata = {
 	.ctrl_name	= "internal",
 };
 
-static struct omap_board_config_kernel fsample_config[] = {
+static struct omap_board_config_kernel fsample_config[] __initdata = {
 	{ OMAP_TAG_LCD,		&fsample_lcd_config },
 };
 
diff --git a/drivers/usb/otg/isp1301_omap.c b/drivers/usb/otg/isp1301_omap.c
index e00fa1b..8c6fdef 100644
--- a/drivers/usb/otg/isp1301_omap.c
+++ b/drivers/usb/otg/isp1301_omap.c
@@ -1510,7 +1510,7 @@ isp1301_start_hnp(struct otg_transceiver *dev)
 
 /*-------------------------------------------------------------------------*/
 
-static int __init
+static int __devinit
 isp1301_probe(struct i2c_client *i2c, const struct i2c_device_id *id)
 {
 	int			status;
-- 
1.7.2.3

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* Re: [PATCH] ARM: omap1/nokia770: mark some functions __init
  2011-02-09 19:27                   ` Tony Lindgren
@ 2011-02-10  0:43                     ` Tony Lindgren
  -1 siblings, 0 replies; 133+ messages in thread
From: Tony Lindgren @ 2011-02-10  0:43 UTC (permalink / raw)
  To: Uwe Kleine-König; +Cc: linux-omap, linux-arm-kernel

* Tony Lindgren <tony@atomide.com> [110209 11:26]:
> * Uwe Kleine-König <u.kleine-koenig@pengutronix.de> [110208 01:58]:
> 
> > > There are two more patches in this thread that are not yet
> > > applied/commented.  Should I resend?

Thanks Uwe, I've applied them into devel-cleanup branch for the
next merge window.

Regards,

Tony
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [PATCH] ARM: omap1/nokia770: mark some functions __init
@ 2011-02-10  0:43                     ` Tony Lindgren
  0 siblings, 0 replies; 133+ messages in thread
From: Tony Lindgren @ 2011-02-10  0:43 UTC (permalink / raw)
  To: linux-arm-kernel

* Tony Lindgren <tony@atomide.com> [110209 11:26]:
> * Uwe Kleine-K?nig <u.kleine-koenig@pengutronix.de> [110208 01:58]:
> 
> > > There are two more patches in this thread that are not yet
> > > applied/commented.  Should I resend?

Thanks Uwe, I've applied them into devel-cleanup branch for the
next merge window.

Regards,

Tony

^ permalink raw reply	[flat|nested] 133+ messages in thread

end of thread, other threads:[~2011-02-10  0:43 UTC | newest]

Thread overview: 133+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-31 11:16 [RFC] [PATCH] arm & sh: factorised duplicated clkdev.c Jean-Christophe PLAGNIOL-VILLARD
2010-08-31 11:16 ` Jean-Christophe PLAGNIOL-VILLARD
2010-09-01  9:12 ` Russell King - ARM Linux
2010-09-01  9:12   ` Russell King - ARM Linux
2010-09-01 11:13   ` Jean-Christophe PLAGNIOL-VILLARD
2010-09-01 11:13     ` Jean-Christophe PLAGNIOL-VILLARD
2010-09-01 23:17     ` Russell King - ARM Linux
2010-09-01 23:17       ` Russell King - ARM Linux
2010-09-02  2:37       ` Jean-Christophe PLAGNIOL-VILLARD
2010-09-02  2:37         ` Jean-Christophe PLAGNIOL-VILLARD
2010-09-02  2:42         ` Paul Mundt
2010-09-02  2:42           ` Paul Mundt
2010-09-01  9:51 ` 
2010-09-01  9:51   ` Uwe Kleine-König
2010-09-01 11:18   ` Jean-Christophe PLAGNIOL-VILLARD
2010-09-01 11:18     ` Jean-Christophe PLAGNIOL-VILLARD
2010-09-01 15:01     ` 
2010-09-01 15:01       ` Uwe Kleine-König
2010-09-01 15:27       ` Jean-Christophe PLAGNIOL-VILLARD
2010-09-01 15:27         ` Jean-Christophe PLAGNIOL-VILLARD
2010-09-01 15:40         ` 
2010-09-01 15:40           ` Uwe Kleine-König
2010-09-01 23:18       ` Russell King - ARM Linux
2010-09-01 23:18         ` Russell King - ARM Linux
2010-09-02  5:46         ` 
2010-09-02  5:46           ` Uwe Kleine-König
2010-09-02  6:17           ` [PATCH] ARM: omap1/nokia770: mark some functions __init Uwe Kleine-König
2010-09-02  8:03             ` [PATCH 1/5] ARM: omap/fb: move omap_init_fb to .init.text Uwe Kleine-König
2010-09-02  8:03               ` Uwe Kleine-König
2010-09-09  8:40               ` Tomi Valkeinen
2010-09-09  8:40                 ` Tomi Valkeinen
2010-09-02  8:03             ` [PATCH 2/5] ARM: omap/fb: move omapfb_reserve_sram " Uwe Kleine-König
2010-09-02  8:03               ` Uwe Kleine-König
2010-09-02  8:03             ` [PATCH 3/5] ARM: omap/fb: move get_fbmem_region() " Uwe Kleine-König
2010-09-02  8:03               ` Uwe Kleine-König
2010-09-02  8:03             ` [PATCH 4/5] ARM: omap: move omap_get_config et al. " Uwe Kleine-König
2010-09-02  8:03               ` Uwe Kleine-König
2010-09-02  8:03             ` [PATCH 5/5] wip: ARM: omap: move omap_board_config_kernel to .init.data Uwe Kleine-König
2010-09-02  8:03               ` Uwe Kleine-König
2011-02-03  8:15             ` [PATCH] ARM: omap1/nokia770: mark some functions __init Uwe Kleine-König
2011-02-03  8:15               ` Uwe Kleine-König
2011-02-08  9:59               ` Uwe Kleine-König
2011-02-08  9:59                 ` Uwe Kleine-König
2011-02-09 19:27                 ` Tony Lindgren
2011-02-09 19:27                   ` Tony Lindgren
2011-02-09 20:40                   ` [PATCH 1/4] " Uwe Kleine-König
2011-02-09 20:40                     ` Uwe Kleine-König
2011-02-09 20:40                   ` [PATCH 2/4] ARM: omap: move omap_get_config et al. to .init.text Uwe Kleine-König
2011-02-09 20:40                     ` Uwe Kleine-König
2011-02-09 20:40                   ` [PATCH 3/4] ARM: omap: move omap_board_config_kernel to .init.data Uwe Kleine-König
2011-02-09 20:40                     ` Uwe Kleine-König
2011-02-09 20:40                   ` [PATCH 4/4] wip: fix section mismatches in omap1_defconfig Uwe Kleine-König
2011-02-09 20:40                     ` Uwe Kleine-König
2011-02-10  0:43                   ` [PATCH] ARM: omap1/nokia770: mark some functions __init Tony Lindgren
2011-02-10  0:43                     ` Tony Lindgren
2010-09-02  8:45           ` [RFC] [PATCH] arm & sh: factorised duplicated clkdev.c Russell King - ARM Linux
2010-09-02  8:45             ` Russell King - ARM Linux
2010-09-01 10:01 ` Russell King - ARM Linux
2010-09-01 10:01   ` Russell King - ARM Linux
2010-09-01 11:12   ` Jean-Christophe PLAGNIOL-VILLARD
2010-09-01 11:12     ` Jean-Christophe PLAGNIOL-VILLARD
2010-09-02 12:48 ` [RFC] [PATCH v2] " Jean-Christophe PLAGNIOL-VILLARD
2010-09-02 12:48   ` Jean-Christophe PLAGNIOL-VILLARD
2010-09-02 13:06   ` Russell King - ARM Linux
2010-09-02 13:06     ` Russell King - ARM Linux
2010-09-02 13:26   ` 
2010-09-02 13:26     ` Uwe Kleine-König
2010-09-02 13:47     ` Russell King - ARM Linux
2010-09-02 13:47       ` Russell King - ARM Linux
2010-09-02 13:55       ` 
2010-09-02 13:55         ` Uwe Kleine-König
2010-09-02 13:39   ` [PATCH V3] " Jean-Christophe PLAGNIOL-VILLARD
2010-09-02 13:39     ` Jean-Christophe PLAGNIOL-VILLARD
2010-09-03 10:18     ` Magnus Damm
2010-09-03 10:18       ` Magnus Damm
2010-09-03 10:32     ` Jean-Christophe PLAGNIOL-VILLARD
2010-09-03 10:32       ` Jean-Christophe PLAGNIOL-VILLARD
2010-09-03 18:23     ` 
2010-09-03 18:23       ` Uwe Kleine-König
2010-09-03 18:23       ` Uwe Kleine-König
2010-09-03 18:43       ` [BUG?] rename patch accepted with --dry-run, rejected without (Re: Jonathan Nieder
2010-09-03 18:43         ` [BUG?] rename patch accepted with --dry-run, rejected without (Re: [PATCH V3] arm & sh: factorised duplicated clkdev.c) Jonathan Nieder
2010-09-03 18:43         ` Jonathan Nieder
2010-09-03 19:29         ` [BUG?] rename patch accepted with --dry-run, rejected without Russell King - ARM Linux
2010-09-03 19:29           ` [BUG?] rename patch accepted with --dry-run, rejected without (Re: [PATCH V3] arm & sh: factorised duplicated clkdev.c) Russell King - ARM Linux
2010-09-03 19:29           ` Russell King - ARM Linux
2010-09-03 19:33           ` [BUG?] rename patch accepted with --dry-run, rejected without 
2010-09-03 19:33             ` [BUG?] rename patch accepted with --dry-run, rejected without (Re: [PATCH V3] arm & sh: factorised duplicated clkdev.c) Uwe Kleine-König
2010-09-03 19:33             ` Uwe Kleine-König
2010-09-03 19:45             ` [BUG?] rename patch accepted with --dry-run, rejected without (Re: [PATCH V3] arm & sh: factoris Andreas Schwab
2010-09-03 19:45               ` [BUG?] rename patch accepted with --dry-run, rejected without (Re: [PATCH V3] arm & sh: factorised duplicated clkdev.c) Andreas Schwab
2010-09-03 19:45               ` Andreas Schwab
2010-09-04  0:03             ` [BUG?] rename patch accepted with --dry-run, rejected without Russell King - ARM Linux
2010-09-04  0:03               ` [BUG?] rename patch accepted with --dry-run, rejected without (Re: [PATCH V3] arm & sh: factorised duplicated clkdev.c) Russell King - ARM Linux
2010-09-04  0:03               ` Russell King - ARM Linux
2010-09-04 21:33               ` [bug-patch] Re: [BUG?] rename patch accepted with --dry-run, rejected without (Re: [PATCH V3] ar Andreas Gruenbacher
2010-09-04 21:33                 ` [bug-patch] Re: [BUG?] rename patch accepted with --dry-run, rejected without (Re: [PATCH V3] arm & sh: factorised duplicated clkdev.c) Andreas Gruenbacher
2010-09-04 21:33                 ` Andreas Gruenbacher
2010-09-04 21:45                 ` [bug-patch] Re: [BUG?] rename patch accepted with --dry-run, Russell King - ARM Linux
2010-09-04 21:45                   ` [bug-patch] Re: [BUG?] rename patch accepted with --dry-run, rejected without (Re: [PATCH V3] arm & sh: factorised duplicated clkdev.c) Russell King - ARM Linux
2010-09-04 21:45                   ` Russell King - ARM Linux
2010-09-04 21:46                   ` [bug-patch] Re: [BUG?] rename patch accepted with --dry-run, rejected without (Re: [PATCH V3] ar Andreas Gruenbacher
2010-09-04 21:46                     ` [bug-patch] Re: [BUG?] rename patch accepted with --dry-run, rejected without (Re: [PATCH V3] arm & sh: factorised duplicated clkdev.c) Andreas Gruenbacher
2010-09-04 21:46                     ` Andreas Gruenbacher
2010-09-04 22:01                     ` [bug-patch] Re: [BUG?] rename patch accepted with --dry-run, Russell King - ARM Linux
2010-09-04 22:01                       ` [bug-patch] Re: [BUG?] rename patch accepted with --dry-run, rejected without (Re: [PATCH V3] arm & sh: factorised duplicated clkdev.c) Russell King - ARM Linux
2010-09-04 22:01                       ` Russell King - ARM Linux
2010-09-04 22:26                       ` [bug-patch] Re: [BUG?] rename patch accepted with --dry-run, rejected without (Re: [PATCH V3] ar Andreas Gruenbacher
2010-09-04 22:26                         ` [bug-patch] Re: [BUG?] rename patch accepted with --dry-run, rejected without (Re: [PATCH V3] arm & sh: factorised duplicated clkdev.c) Andreas Gruenbacher
2010-09-04 22:26                         ` Andreas Gruenbacher
2010-09-03 19:34           ` [BUG?] rename patch accepted with --dry-run, rejected without (Re: [PATCH V3] arm & sh: factoris Matthieu Moy
2010-09-03 19:34             ` [BUG?] rename patch accepted with --dry-run, rejected without (Re: [PATCH V3] arm & sh: factorised duplicated clkdev.c) Matthieu Moy
2010-09-03 19:34             ` Matthieu Moy
2010-09-03 22:58         ` [bug-patch] [BUG?] rename patch accepted with --dry-run, rejected without (Re: [PATCH V3] arm & Andreas Gruenbacher
2010-09-03 22:58           ` [bug-patch] [BUG?] rename patch accepted with --dry-run, rejected without (Re: [PATCH V3] arm & sh: factorised duplicated clkdev.c) Andreas Gruenbacher
2010-09-03 22:58           ` Andreas Gruenbacher
2010-09-03 23:32           ` [bug-patch] [BUG?] rename patch accepted with --dry-run, Jonathan Nieder
2010-09-03 23:32             ` [bug-patch] [BUG?] rename patch accepted with --dry-run, rejected without (Re: [PATCH V3] arm & sh: factorised duplicated clkdev.c) Jonathan Nieder
2010-09-03 23:32             ` Jonathan Nieder
2010-09-04 21:57             ` [bug-patch] [BUG?] rename patch accepted with --dry-run, rejected without (Re: [PATCH V3] arm & Andreas Gruenbacher
2010-09-04 21:57               ` [bug-patch] [BUG?] rename patch accepted with --dry-run, rejected without (Re: [PATCH V3] arm & sh: factorised duplicated clkdev.c) Andreas Gruenbacher
2010-09-04 21:57               ` Andreas Gruenbacher
2010-09-04  3:21           ` [bug-patch] [BUG?] rename patch accepted with --dry-run, Jean-Christophe PLAGNIOL-VILLARD
2010-09-04  3:21             ` [bug-patch] [BUG?] rename patch accepted with --dry-run, rejected without (Re: [PATCH V3] arm & sh: factorised duplicated clkdev.c) Jean-Christophe PLAGNIOL-VILLARD
2010-09-04  3:21             ` Jean-Christophe PLAGNIOL-VILLARD
2010-09-09  9:53     ` [PATCH V3] arm & sh: factorised duplicated clkdev.c Jean-Christophe PLAGNIOL-VILLARD
2010-09-09  9:53       ` Jean-Christophe PLAGNIOL-VILLARD
2010-09-14  7:59       ` Paul Mundt
2010-09-14  7:59         ` Paul Mundt
2010-09-15  5:51         ` Jean-Christophe PLAGNIOL-VILLARD
2010-09-15  5:51           ` Jean-Christophe PLAGNIOL-VILLARD
2010-10-04 19:46       ` Russell King - ARM Linux
2010-10-04 19:46         ` Russell King - ARM Linux

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.