linux-omap.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH 00/37] cbus patches
@ 2010-04-07 16:03 felipe.balbi
  2010-04-07 16:03 ` [RFC PATCH 01/37] cbus: convert u32 base to void __iomem *base felipe.balbi
                   ` (37 more replies)
  0 siblings, 38 replies; 41+ messages in thread
From: felipe.balbi @ 2010-04-07 16:03 UTC (permalink / raw)
  To: Linux OMAP Mailing List; +Cc: Felipe Balbi

From: Felipe Balbi <felipe.balbi@nokia.com>

Hi all,

I still have to test these patches, but I fell like it's
time to get some comments.

There's still a big TODO for the whole cbus drivers:

. cleanup all tahvo drivers
. instantiate platform_device on board-files
. pass platform_data to retu/tahvo and their children from board-files
. move retu-headset to jack abstraction layer (??)
. move retu-user.c to platform_driver
. move tahvo and retu to generic-irq
. move tahvo and retu to mfd
. move tahvo and retu to threaded irq (??)
. move all children drivers to proper locations
. move cbus.c to a common location (drivers/misc ??)
. allow any arch to use cbus.c by passing correct gpio numbers
. get it all into mainline.

anyways, these patches were lightly boot tested on n810 and
compile tested with n770_defconfig.

patches also available on cbus branch of git://gitorious.org/usb/usb.git

Felipe Balbi (37):
  cbus: convert u32 base to void __iomem *base
  cbus: NULL global variable on exit
  cbus: checkpatch.pl fix on cbus.c
  cbus: don't export the global cbus_host variable
  cbus: rely on gpiolib
  cbus: no ternary on return
  cbus: add read/write flag to cbus_transfer
  cbus: don't type case when issuing read/write
  cbus: fix a resource leakage
  cbus: move cbus_host definition to C source
  cbus: handle possible errors on cbus_send/receive_bit
  cbus: introduce cbus_send/receive_data wrappers
  cbus: add kerneldoc
  cbus: retu-wdt: fix compile breakage
  cbus: retu: fix compile breakage on retu-headset
  cbus: retu: split one MODULE_AUTHOR into several
  cbus: retu: don't assing ret inside the if ()
  cbus: retu: convert printk to dev_*
  cbus: retu: convert to a platform_driver
  cbus: tahvo: split MODULE_AUTHOR into several entries
  cbus: tahvo: move EXPORT_SYMBOL macros closer to functions
  cbus: tahvo: don't assign ret inside if ()
  cbus: tahvo: convert printk into dev_*
  cbus: tahvo: convert to platform_driver
  cbus: retu: allocate platform_device for Retu's children
  cbus: retu-pwrbutton: convert to platform_driver
  cbus: retu-headset: simplify module_init
  cbus: retu-rtc: remove platform_device code
  cbus: retu-rtc: convert to platform_driver
  cbus: retu-rtc: split MODULE_AUTHOR into several entries
  cbus: retu-rtc: get rid of globals
  cbus: retu-rtc: move retu_rtc_barrier up on source code
  cbus: retu-rtc: make checkpatch.pl happy
  cbus: retu-rtc: switch to rtc class device
  cbus: retu-wdt: remove the platform_device
  cbus: retu-wtd: convert to platform_driver
  cbus: retu-wdt: misc cleanup on retu-wdt driver

 drivers/cbus/Kconfig          |    2 +-
 drivers/cbus/cbus.c           |  272 +++++++++++---------
 drivers/cbus/cbus.h           |   11 +-
 drivers/cbus/retu-headset.c   |   10 +-
 drivers/cbus/retu-pwrbutton.c |  126 +++++++---
 drivers/cbus/retu-rtc.c       |  546 +++++++++++++++++------------------------
 drivers/cbus/retu-wdt.c       |  126 ++++------
 drivers/cbus/retu.c           |  145 +++++++++---
 drivers/cbus/retu.h           |    6 +-
 drivers/cbus/tahvo.c          |   76 +++---
 drivers/cbus/tahvo.h          |    6 +-
 11 files changed, 676 insertions(+), 650 deletions(-)


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

* [RFC PATCH 01/37] cbus: convert u32 base to void __iomem *base
  2010-04-07 16:03 [RFC PATCH 00/37] cbus patches felipe.balbi
@ 2010-04-07 16:03 ` felipe.balbi
  2010-04-07 16:03 ` [RFC PATCH 02/37] cbus: NULL global variable on exit felipe.balbi
                   ` (36 subsequent siblings)
  37 siblings, 0 replies; 41+ messages in thread
From: felipe.balbi @ 2010-04-07 16:03 UTC (permalink / raw)
  To: Linux OMAP Mailing List; +Cc: Felipe Balbi

From: Felipe Balbi <felipe.balbi@nokia.com>

to avoid casting later, pass the parameter of the
correct type already.

Signed-off-by: Felipe Balbi <felipe.balbi@nokia.com>
---
 drivers/cbus/cbus.c |   16 +++++++++-------
 drivers/cbus/cbus.h |   10 ++++++++--
 2 files changed, 17 insertions(+), 9 deletions(-)

diff --git a/drivers/cbus/cbus.c b/drivers/cbus/cbus.c
index 00c3c32..c0b4248 100644
--- a/drivers/cbus/cbus.c
+++ b/drivers/cbus/cbus.c
@@ -45,7 +45,8 @@ EXPORT_SYMBOL(cbus_host);
 #ifdef CONFIG_ARCH_OMAP1
 /* We use our own MPUIO functions to get closer to 1MHz bus speed */
 
-static inline void cbus_set_gpio_direction(u32 base, int mpuio, int is_input)
+static inline void cbus_set_gpio_direction(void __iomem *base,
+		int mpuio, int is_input)
 {
 	u16 w;
 
@@ -59,7 +60,8 @@ static inline void cbus_set_gpio_direction(u32 base, int mpuio, int is_input)
 
 }
 
-static inline void cbus_set_gpio_dataout(u32 base, int mpuio, int enable)
+static inline void cbus_set_gpio_dataout(void __iomem *base,
+		int mpuio, int enable)
 {
 	u16 w;
 
@@ -72,14 +74,14 @@ static inline void cbus_set_gpio_dataout(u32 base, int mpuio, int enable)
 	__raw_writew(w, base + OMAP_MPUIO_OUTPUT);
 }
 
-static inline int cbus_get_gpio_datain(u32 base, int mpuio)
+static inline int cbus_get_gpio_datain(void __iomem *base, int mpuio)
 {
 	mpuio &= 0x0f;
 
 	return (__raw_readw(base + OMAP_MPUIO_INPUT_LATCH) & (1 << mpuio)) != 0;
 }
 
-static void cbus_send_bit(struct cbus_host *host, u32 base, int bit,
+static void cbus_send_bit(struct cbus_host *host, void __iomem *base, int bit,
 			  int set_to_input)
 {
 	cbus_set_gpio_dataout(base, host->dat_gpio, bit ? 1 : 0);
@@ -92,7 +94,7 @@ static void cbus_send_bit(struct cbus_host *host, u32 base, int bit,
 	cbus_set_gpio_dataout(base, host->clk_gpio, 0);
 }
 
-static u8 cbus_receive_bit(struct cbus_host *host, u32 base)
+static u8 cbus_receive_bit(struct cbus_host *host, void __iomem *base)
 {
 	u8 ret;
 
@@ -144,12 +146,12 @@ static int cbus_transfer(struct cbus_host *host, int dev, int reg, int data)
 	int i;
 	int is_read = 0;
 	unsigned long flags;
-	u32 base;
+	void __iomem *base;
 
 #ifdef CONFIG_ARCH_OMAP1
 	base = OMAP1_IO_ADDRESS(OMAP1_MPUIO_BASE);
 #else
-	base = 0;
+	base = NULL;
 #endif
 
 	if (data < 0)
diff --git a/drivers/cbus/cbus.h b/drivers/cbus/cbus.h
index 957224c..90c7617 100644
--- a/drivers/cbus/cbus.h
+++ b/drivers/cbus/cbus.h
@@ -24,8 +24,14 @@
 #define __DRIVERS_CBUS_CBUS_H
 
 struct cbus_host {
-	int clk_gpio, dat_gpio, sel_gpio;
-        spinlock_t lock;
+	/* host lock */
+	spinlock_t lock;
+
+	void __iomem *base;
+
+	int	clk_gpio;
+	int	dat_gpio;
+	int	sel_gpio;
 };
 
 extern struct cbus_host *cbus_host;
-- 
1.7.0.rc0.33.g7c3932


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

* [RFC PATCH 02/37] cbus: NULL global variable on exit
  2010-04-07 16:03 [RFC PATCH 00/37] cbus patches felipe.balbi
  2010-04-07 16:03 ` [RFC PATCH 01/37] cbus: convert u32 base to void __iomem *base felipe.balbi
@ 2010-04-07 16:03 ` felipe.balbi
  2010-04-07 16:03 ` [RFC PATCH 03/37] cbus: checkpatch.pl fix on cbus.c felipe.balbi
                   ` (35 subsequent siblings)
  37 siblings, 0 replies; 41+ messages in thread
From: felipe.balbi @ 2010-04-07 16:03 UTC (permalink / raw)
  To: Linux OMAP Mailing List; +Cc: Felipe Balbi

From: Felipe Balbi <felipe.balbi@nokia.com>

just to be sure, let's set it to NULL.

Signed-off-by: Felipe Balbi <felipe.balbi@nokia.com>
---
 drivers/cbus/cbus.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/drivers/cbus/cbus.c b/drivers/cbus/cbus.c
index c0b4248..f454e77 100644
--- a/drivers/cbus/cbus.c
+++ b/drivers/cbus/cbus.c
@@ -279,7 +279,9 @@ static void __exit cbus_bus_remove(struct platform_device *pdev)
 
 	gpio_free(chost->dat_gpio);
 	gpio_free(chost->clk_gpio);
+
 	kfree(chost);
+	cbus_host = NULL;
 }
 
 static struct platform_driver cbus_driver = {
-- 
1.7.0.rc0.33.g7c3932


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

* [RFC PATCH 03/37] cbus: checkpatch.pl fix on cbus.c
  2010-04-07 16:03 [RFC PATCH 00/37] cbus patches felipe.balbi
  2010-04-07 16:03 ` [RFC PATCH 01/37] cbus: convert u32 base to void __iomem *base felipe.balbi
  2010-04-07 16:03 ` [RFC PATCH 02/37] cbus: NULL global variable on exit felipe.balbi
@ 2010-04-07 16:03 ` felipe.balbi
  2010-04-07 16:03 ` [RFC PATCH 04/37] cbus: don't export the global cbus_host variable felipe.balbi
                   ` (34 subsequent siblings)
  37 siblings, 0 replies; 41+ messages in thread
From: felipe.balbi @ 2010-04-07 16:03 UTC (permalink / raw)
  To: Linux OMAP Mailing List; +Cc: Felipe Balbi

From: Felipe Balbi <felipe.balbi@nokia.com>

make checkpatch.pl (almost) happy.

Signed-off-by: Felipe Balbi <felipe.balbi@nokia.com>
---
 drivers/cbus/cbus.c |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/cbus/cbus.c b/drivers/cbus/cbus.c
index f454e77..e1be8c7 100644
--- a/drivers/cbus/cbus.c
+++ b/drivers/cbus/cbus.c
@@ -136,7 +136,7 @@ static u8 _cbus_receive_bit(struct cbus_host *host)
 	return ret;
 }
 
-#define cbus_send_bit(host, base, bit, set_to_input) _cbus_send_bit(host, bit, set_to_input)
+#define cbus_send_bit(h, b, bit, i) _cbus_send_bit(h, bit, i)
 #define cbus_receive_bit(host, base) _cbus_receive_bit(host)
 
 #endif
@@ -232,7 +232,7 @@ static int __init cbus_bus_probe(struct platform_device *pdev)
 	struct cbus_host_platform_data *pdata = pdev->dev.platform_data;
 	int ret;
 
-	chost = kzalloc(sizeof (*chost), GFP_KERNEL);
+	chost = kzalloc(sizeof(*chost), GFP_KERNEL);
 	if (chost == NULL)
 		return -ENOMEM;
 
@@ -242,13 +242,16 @@ static int __init cbus_bus_probe(struct platform_device *pdev)
 	chost->dat_gpio = pdata->dat_gpio;
 	chost->sel_gpio = pdata->sel_gpio;
 
-	if ((ret = gpio_request(chost->clk_gpio, "CBUS clk")) < 0)
+	ret = gpio_request(chost->clk_gpio, "CBUS clk");
+	if (ret < 0)
 		goto exit1;
 
-	if ((ret = gpio_request(chost->dat_gpio, "CBUS data")) < 0)
+	ret = gpio_request(chost->dat_gpio, "CBUS data");
+	if (ret < 0)
 		goto exit2;
 
-	if ((ret = gpio_request(chost->sel_gpio, "CBUS sel")) < 0)
+	ret = gpio_request(chost->sel_gpio, "CBUS sel");
+	if (ret < 0)
 		goto exit3;
 
 	gpio_direction_output(chost->clk_gpio, 0);
-- 
1.7.0.rc0.33.g7c3932


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

* [RFC PATCH 04/37] cbus: don't export the global cbus_host variable
  2010-04-07 16:03 [RFC PATCH 00/37] cbus patches felipe.balbi
                   ` (2 preceding siblings ...)
  2010-04-07 16:03 ` [RFC PATCH 03/37] cbus: checkpatch.pl fix on cbus.c felipe.balbi
@ 2010-04-07 16:03 ` felipe.balbi
  2010-04-07 16:03 ` [RFC PATCH 05/37] cbus: rely on gpiolib felipe.balbi
                   ` (33 subsequent siblings)
  37 siblings, 0 replies; 41+ messages in thread
From: felipe.balbi @ 2010-04-07 16:03 UTC (permalink / raw)
  To: Linux OMAP Mailing List; +Cc: Felipe Balbi

From: Felipe Balbi <felipe.balbi@nokia.com>

we can keep it static to cbus.c and refer to it when
calling cbus_transfer().

Signed-off-by: Felipe Balbi <felipe.balbi@nokia.com>
---
 drivers/cbus/cbus.c  |   11 +++++------
 drivers/cbus/cbus.h  |    6 ++----
 drivers/cbus/retu.c  |    4 ++--
 drivers/cbus/tahvo.c |    4 ++--
 4 files changed, 11 insertions(+), 14 deletions(-)

diff --git a/drivers/cbus/cbus.c b/drivers/cbus/cbus.c
index e1be8c7..c976f49 100644
--- a/drivers/cbus/cbus.c
+++ b/drivers/cbus/cbus.c
@@ -39,8 +39,7 @@
 
 #include "cbus.h"
 
-struct cbus_host *cbus_host = NULL;
-EXPORT_SYMBOL(cbus_host);
+static struct cbus_host *cbus_host;
 
 #ifdef CONFIG_ARCH_OMAP1
 /* We use our own MPUIO functions to get closer to 1MHz bus speed */
@@ -211,18 +210,18 @@ static int cbus_transfer(struct cbus_host *host, int dev, int reg, int data)
 /*
  * Read a given register from the device
  */
-int cbus_read_reg(struct cbus_host *host, int dev, int reg)
+int cbus_read_reg(int dev, int reg)
 {
-	return cbus_host ? cbus_transfer(host, dev, reg, -1) : -ENODEV;
+	return cbus_transfer(cbus_host, dev, reg, -1);
 }
 EXPORT_SYMBOL(cbus_read_reg);
 
 /*
  * Write to a given register of the device
  */
-int cbus_write_reg(struct cbus_host *host, int dev, int reg, u16 val)
+int cbus_write_reg(int dev, int reg, int val)
 {
-	return cbus_host ? cbus_transfer(host, dev, reg, (int)val) : -ENODEV;
+	return cbus_transfer(cbus_host, dev, reg, val);
 }
 EXPORT_SYMBOL(cbus_write_reg);
 
diff --git a/drivers/cbus/cbus.h b/drivers/cbus/cbus.h
index 90c7617..4cd68fd 100644
--- a/drivers/cbus/cbus.h
+++ b/drivers/cbus/cbus.h
@@ -34,9 +34,7 @@ struct cbus_host {
 	int	sel_gpio;
 };
 
-extern struct cbus_host *cbus_host;
-
-extern int cbus_read_reg(struct cbus_host *host, int dev, int reg);
-extern int cbus_write_reg(struct cbus_host *host, int dev, int reg, u16 val);
+extern int cbus_read_reg(int dev, int reg);
+extern int cbus_write_reg(int dev, int reg, int val);
 
 #endif /* __DRIVERS_CBUS_CBUS_H */
diff --git a/drivers/cbus/retu.c b/drivers/cbus/retu.c
index c0e7cf3..35fdd11 100644
--- a/drivers/cbus/retu.c
+++ b/drivers/cbus/retu.c
@@ -81,7 +81,7 @@ EXPORT_SYMBOL(retu_get_status);
 int retu_read_reg(int reg)
 {
 	BUG_ON(!retu_initialized);
-	return cbus_read_reg(cbus_host, RETU_ID, reg);
+	return cbus_read_reg(RETU_ID, reg);
 }
 
 /**
@@ -94,7 +94,7 @@ int retu_read_reg(int reg)
 void retu_write_reg(int reg, u16 val)
 {
 	BUG_ON(!retu_initialized);
-	cbus_write_reg(cbus_host, RETU_ID, reg, val);
+	cbus_write_reg(RETU_ID, reg, val);
 }
 
 void retu_set_clear_reg_bits(int reg, u16 set, u16 clear)
diff --git a/drivers/cbus/tahvo.c b/drivers/cbus/tahvo.c
index 8bd5ede..6828acc 100644
--- a/drivers/cbus/tahvo.c
+++ b/drivers/cbus/tahvo.c
@@ -81,7 +81,7 @@ EXPORT_SYMBOL(tahvo_get_status);
 int tahvo_read_reg(int reg)
 {
 	BUG_ON(!tahvo_initialized);
-	return cbus_read_reg(cbus_host, TAHVO_ID, reg);
+	return cbus_read_reg(TAHVO_ID, reg);
 }
 
 /**
@@ -94,7 +94,7 @@ int tahvo_read_reg(int reg)
 void tahvo_write_reg(int reg, u16 val)
 {
 	BUG_ON(!tahvo_initialized);
-	cbus_write_reg(cbus_host, TAHVO_ID, reg, val);
+	cbus_write_reg(TAHVO_ID, reg, val);
 }
 
 /**
-- 
1.7.0.rc0.33.g7c3932


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

* [RFC PATCH 05/37] cbus: rely on gpiolib
  2010-04-07 16:03 [RFC PATCH 00/37] cbus patches felipe.balbi
                   ` (3 preceding siblings ...)
  2010-04-07 16:03 ` [RFC PATCH 04/37] cbus: don't export the global cbus_host variable felipe.balbi
@ 2010-04-07 16:03 ` felipe.balbi
  2010-04-07 16:03 ` [RFC PATCH 06/37] cbus: no ternary on return felipe.balbi
                   ` (32 subsequent siblings)
  37 siblings, 0 replies; 41+ messages in thread
From: felipe.balbi @ 2010-04-07 16:03 UTC (permalink / raw)
  To: Linux OMAP Mailing List; +Cc: Felipe Balbi

From: Felipe Balbi <felipe.balbi@nokia.com>

don't define our own concurrent accesses to gpio banks
if we already have gpiolib to handle that.

Signed-off-by: Felipe Balbi <felipe.balbi@nokia.com>
---
 drivers/cbus/cbus.c |  109 ++++++--------------------------------------------
 drivers/cbus/cbus.h |    2 -
 2 files changed, 13 insertions(+), 98 deletions(-)

diff --git a/drivers/cbus/cbus.c b/drivers/cbus/cbus.c
index c976f49..615f447 100644
--- a/drivers/cbus/cbus.c
+++ b/drivers/cbus/cbus.c
@@ -41,78 +41,7 @@
 
 static struct cbus_host *cbus_host;
 
-#ifdef CONFIG_ARCH_OMAP1
-/* We use our own MPUIO functions to get closer to 1MHz bus speed */
-
-static inline void cbus_set_gpio_direction(void __iomem *base,
-		int mpuio, int is_input)
-{
-	u16 w;
-
-	mpuio &= 0x0f;
-	w = __raw_readw(base + OMAP_MPUIO_IO_CNTL);
-	if (is_input)
-		w |= 1 << mpuio;
-	else
-		w &= ~(1 << mpuio);
-	__raw_writew(w, base + OMAP_MPUIO_IO_CNTL);
-
-}
-
-static inline void cbus_set_gpio_dataout(void __iomem *base,
-		int mpuio, int enable)
-{
-	u16 w;
-
-	mpuio &= 0x0f;
-	w = __raw_readw(base + OMAP_MPUIO_OUTPUT);
-	if (enable)
-		w |= 1 << mpuio;
-	else
-		w &= ~(1 << mpuio);
-	__raw_writew(w, base + OMAP_MPUIO_OUTPUT);
-}
-
-static inline int cbus_get_gpio_datain(void __iomem *base, int mpuio)
-{
-	mpuio &= 0x0f;
-
-	return (__raw_readw(base + OMAP_MPUIO_INPUT_LATCH) & (1 << mpuio)) != 0;
-}
-
-static void cbus_send_bit(struct cbus_host *host, void __iomem *base, int bit,
-			  int set_to_input)
-{
-	cbus_set_gpio_dataout(base, host->dat_gpio, bit ? 1 : 0);
-	cbus_set_gpio_dataout(base, host->clk_gpio, 1);
-
-	/* The data bit is read on the rising edge of CLK */
-	if (set_to_input)
-		cbus_set_gpio_direction(base, host->dat_gpio, 1);
-
-	cbus_set_gpio_dataout(base, host->clk_gpio, 0);
-}
-
-static u8 cbus_receive_bit(struct cbus_host *host, void __iomem *base)
-{
-	u8 ret;
-
-	cbus_set_gpio_dataout(base, host->clk_gpio, 1);
-	ret = cbus_get_gpio_datain(base, host->dat_gpio);
-	cbus_set_gpio_dataout(base, host->clk_gpio, 0);
-
-	return ret;
-}
-
-#define cbus_output(base, gpio, val)	cbus_set_gpio_direction(base, gpio, 0)
-
-#else
-
-#define cbus_output(base, gpio, val)	gpio_direction_output(gpio, val)
-#define cbus_set_gpio_dataout(base, gpio, enable) gpio_set_value(gpio, enable)
-#define cbus_get_gpio_datain(base, int, gpio) gpio_get_value(gpio)
-
-static void _cbus_send_bit(struct cbus_host *host, int bit, int set_to_input)
+static void cbus_send_bit(struct cbus_host *host, int bit, int set_to_input)
 {
 	gpio_set_value(host->dat_gpio, bit ? 1 : 0);
 	gpio_set_value(host->clk_gpio, 1);
@@ -124,7 +53,7 @@ static void _cbus_send_bit(struct cbus_host *host, int bit, int set_to_input)
 	gpio_set_value(host->clk_gpio, 0);
 }
 
-static u8 _cbus_receive_bit(struct cbus_host *host)
+static u8 cbus_receive_bit(struct cbus_host *host)
 {
 	u8 ret;
 
@@ -135,23 +64,11 @@ static u8 _cbus_receive_bit(struct cbus_host *host)
 	return ret;
 }
 
-#define cbus_send_bit(h, b, bit, i) _cbus_send_bit(h, bit, i)
-#define cbus_receive_bit(host, base) _cbus_receive_bit(host)
-
-#endif
-
 static int cbus_transfer(struct cbus_host *host, int dev, int reg, int data)
 {
 	int i;
 	int is_read = 0;
 	unsigned long flags;
-	void __iomem *base;
-
-#ifdef CONFIG_ARCH_OMAP1
-	base = OMAP1_IO_ADDRESS(OMAP1_MPUIO_BASE);
-#else
-	base = NULL;
-#endif
 
 	if (data < 0)
 		is_read = 1;
@@ -160,17 +77,17 @@ static int cbus_transfer(struct cbus_host *host, int dev, int reg, int data)
 	spin_lock_irqsave(&host->lock, flags);
 
 	/* Reset state and start of transfer, SEL stays down during transfer */
-	cbus_set_gpio_dataout(base, host->sel_gpio, 0);
+	gpio_set_value(host->sel_gpio, 0);
 
 	/* Set the DAT pin to output */
-	cbus_output(base, host->dat_gpio, 1);
+	gpio_direction_output(host->dat_gpio, 1);
 
 	/* Send the device address */
 	for (i = 3; i > 0; i--)
-		cbus_send_bit(host, base, dev & (1 << (i - 1)), 0);
+		cbus_send_bit(host, dev & (1 << (i - 1)), 0);
 
 	/* Send the rw flag */
-	cbus_send_bit(host, base, is_read, 0);
+	cbus_send_bit(host, is_read, 0);
 
 	/* Send the register address */
 	for (i = 5; i > 0; i--) {
@@ -179,18 +96,18 @@ static int cbus_transfer(struct cbus_host *host, int dev, int reg, int data)
 		if (is_read && i == 1)
 			set_to_input = 1;
 
-		cbus_send_bit(host, base, reg & (1 << (i - 1)), set_to_input);
+		cbus_send_bit(host, reg & (1 << (i - 1)), set_to_input);
 	}
 
 	if (!is_read) {
 		for (i = 16; i > 0; i--)
-			cbus_send_bit(host, base, data & (1 << (i - 1)), 0);
+			cbus_send_bit(host, data & (1 << (i - 1)), 0);
 	} else {
-		cbus_set_gpio_dataout(base, host->clk_gpio, 1);
+		gpio_set_value(host->clk_gpio, 1);
 		data = 0;
 
 		for (i = 16; i > 0; i--) {
-			u8 bit = cbus_receive_bit(host, base);
+			u8 bit = cbus_receive_bit(host);
 
 			if (bit)
 				data |= 1 << (i - 1);
@@ -198,9 +115,9 @@ static int cbus_transfer(struct cbus_host *host, int dev, int reg, int data)
 	}
 
 	/* Indicate end of transfer, SEL goes up until next transfer */
-	cbus_set_gpio_dataout(base, host->sel_gpio, 1);
-	cbus_set_gpio_dataout(base, host->clk_gpio, 1);
-	cbus_set_gpio_dataout(base, host->clk_gpio, 0);
+	gpio_set_value(host->sel_gpio, 1);
+	gpio_set_value(host->clk_gpio, 1);
+	gpio_set_value(host->clk_gpio, 0);
 
 	spin_unlock_irqrestore(&host->lock, flags);
 
diff --git a/drivers/cbus/cbus.h b/drivers/cbus/cbus.h
index 4cd68fd..fbaca09 100644
--- a/drivers/cbus/cbus.h
+++ b/drivers/cbus/cbus.h
@@ -27,8 +27,6 @@ struct cbus_host {
 	/* host lock */
 	spinlock_t lock;
 
-	void __iomem *base;
-
 	int	clk_gpio;
 	int	dat_gpio;
 	int	sel_gpio;
-- 
1.7.0.rc0.33.g7c3932


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

* [RFC PATCH 06/37] cbus: no ternary on return
  2010-04-07 16:03 [RFC PATCH 00/37] cbus patches felipe.balbi
                   ` (4 preceding siblings ...)
  2010-04-07 16:03 ` [RFC PATCH 05/37] cbus: rely on gpiolib felipe.balbi
@ 2010-04-07 16:03 ` felipe.balbi
  2010-04-07 16:03 ` [RFC PATCH 07/37] cbus: add read/write flag to cbus_transfer felipe.balbi
                   ` (31 subsequent siblings)
  37 siblings, 0 replies; 41+ messages in thread
From: felipe.balbi @ 2010-04-07 16:03 UTC (permalink / raw)
  To: Linux OMAP Mailing List; +Cc: Felipe Balbi

From: Felipe Balbi <felipe.balbi@nokia.com>

data is reset to 0 if is_read is true. No need
to use ternary operator before returning.

Signed-off-by: Felipe Balbi <felipe.balbi@nokia.com>
---
 drivers/cbus/cbus.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/cbus/cbus.c b/drivers/cbus/cbus.c
index 615f447..35f7c71 100644
--- a/drivers/cbus/cbus.c
+++ b/drivers/cbus/cbus.c
@@ -121,7 +121,7 @@ static int cbus_transfer(struct cbus_host *host, int dev, int reg, int data)
 
 	spin_unlock_irqrestore(&host->lock, flags);
 
-	return is_read ? data : 0;
+	return data;
 }
 
 /*
-- 
1.7.0.rc0.33.g7c3932


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

* [RFC PATCH 07/37] cbus: add read/write flag to cbus_transfer
  2010-04-07 16:03 [RFC PATCH 00/37] cbus patches felipe.balbi
                   ` (5 preceding siblings ...)
  2010-04-07 16:03 ` [RFC PATCH 06/37] cbus: no ternary on return felipe.balbi
@ 2010-04-07 16:03 ` felipe.balbi
  2010-04-07 16:03 ` [RFC PATCH 08/37] cbus: don't type case when issuing read/write felipe.balbi
                   ` (30 subsequent siblings)
  37 siblings, 0 replies; 41+ messages in thread
From: felipe.balbi @ 2010-04-07 16:03 UTC (permalink / raw)
  To: Linux OMAP Mailing List; +Cc: Felipe Balbi

From: Felipe Balbi <felipe.balbi@nokia.com>

don't do magic tricks with the data to be written, it's simpler
to pass down a flag which will for sure tell us if we're reading
or writing.

Signed-off-by: Felipe Balbi <felipe.balbi@nokia.com>
---
 drivers/cbus/cbus.c |   30 ++++++++++++++++--------------
 1 files changed, 16 insertions(+), 14 deletions(-)

diff --git a/drivers/cbus/cbus.c b/drivers/cbus/cbus.c
index 35f7c71..53b43e1 100644
--- a/drivers/cbus/cbus.c
+++ b/drivers/cbus/cbus.c
@@ -3,12 +3,15 @@
  *
  * Support functions for CBUS serial protocol
  *
- * Copyright (C) 2004, 2005 Nokia Corporation
+ * Copyright (C) 2004-2010 Nokia Corporation
+ * Contact: Felipe Balbi <felipe.balbi@nokia.com>
  *
  * Written by Juha Yrjölä <juha.yrjola@nokia.com>,
  *	      David Weinehall <david.weinehall@nokia.com>, and
  *	      Mikko Ylinen <mikko.k.ylinen@nokia.com>
  *
+ * Several updates and cleanups by Felipe Balbi <felipe.balbi@nokia.com>
+ *
  * This file is subject to the terms and conditions of the GNU General
  * Public License. See the file "COPYING" in the main directory of this
  * archive for more details.
@@ -39,6 +42,9 @@
 
 #include "cbus.h"
 
+#define CBUS_XFER_READ		1
+#define CBUS_XFER_WRITE		0
+
 static struct cbus_host *cbus_host;
 
 static void cbus_send_bit(struct cbus_host *host, int bit, int set_to_input)
@@ -64,14 +70,11 @@ static u8 cbus_receive_bit(struct cbus_host *host)
 	return ret;
 }
 
-static int cbus_transfer(struct cbus_host *host, int dev, int reg, int data)
+static int cbus_transfer(struct cbus_host *host, unsigned rw, unsigned dev,
+		unsigned reg, unsigned data)
 {
-	int i;
-	int is_read = 0;
 	unsigned long flags;
-
-	if (data < 0)
-		is_read = 1;
+	int i;
 
 	/* We don't want interrupts disturbing our transfer */
 	spin_lock_irqsave(&host->lock, flags);
@@ -87,24 +90,23 @@ static int cbus_transfer(struct cbus_host *host, int dev, int reg, int data)
 		cbus_send_bit(host, dev & (1 << (i - 1)), 0);
 
 	/* Send the rw flag */
-	cbus_send_bit(host, is_read, 0);
+	cbus_send_bit(host, rw, 0);
 
 	/* Send the register address */
 	for (i = 5; i > 0; i--) {
 		int set_to_input = 0;
 
-		if (is_read && i == 1)
+		if (rw && i == 1)
 			set_to_input = 1;
 
 		cbus_send_bit(host, reg & (1 << (i - 1)), set_to_input);
 	}
 
-	if (!is_read) {
+	if (!rw) {
 		for (i = 16; i > 0; i--)
 			cbus_send_bit(host, data & (1 << (i - 1)), 0);
 	} else {
 		gpio_set_value(host->clk_gpio, 1);
-		data = 0;
 
 		for (i = 16; i > 0; i--) {
 			u8 bit = cbus_receive_bit(host);
@@ -129,7 +131,7 @@ static int cbus_transfer(struct cbus_host *host, int dev, int reg, int data)
  */
 int cbus_read_reg(int dev, int reg)
 {
-	return cbus_transfer(cbus_host, dev, reg, -1);
+	return cbus_transfer(cbus_host, CBUS_XFER_READ, dev, reg, 0);
 }
 EXPORT_SYMBOL(cbus_read_reg);
 
@@ -138,7 +140,7 @@ EXPORT_SYMBOL(cbus_read_reg);
  */
 int cbus_write_reg(int dev, int reg, int val)
 {
-	return cbus_transfer(cbus_host, dev, reg, val);
+	return cbus_transfer(cbus_host, CBUS_XFER_WRITE, dev, reg, val);
 }
 EXPORT_SYMBOL(cbus_write_reg);
 
@@ -214,7 +216,6 @@ static int __init cbus_bus_init(void)
 {
 	return platform_driver_probe(&cbus_driver, cbus_bus_probe);
 }
-
 subsys_initcall(cbus_bus_init);
 
 static void __exit cbus_bus_exit(void)
@@ -228,4 +229,5 @@ MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Juha Yrjölä");
 MODULE_AUTHOR("David Weinehall");
 MODULE_AUTHOR("Mikko Ylinen");
+MODULE_AUTHOR("Felipe Balbi <felipe.balbi@nokia.com>");
 
-- 
1.7.0.rc0.33.g7c3932

--
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] 41+ messages in thread

* [RFC PATCH 08/37] cbus: don't type case when issuing read/write
  2010-04-07 16:03 [RFC PATCH 00/37] cbus patches felipe.balbi
                   ` (6 preceding siblings ...)
  2010-04-07 16:03 ` [RFC PATCH 07/37] cbus: add read/write flag to cbus_transfer felipe.balbi
@ 2010-04-07 16:03 ` felipe.balbi
  2010-04-07 16:04 ` [RFC PATCH 09/37] cbus: fix a resource leakage felipe.balbi
                   ` (29 subsequent siblings)
  37 siblings, 0 replies; 41+ messages in thread
From: felipe.balbi @ 2010-04-07 16:03 UTC (permalink / raw)
  To: Linux OMAP Mailing List; +Cc: Felipe Balbi

From: Felipe Balbi <felipe.balbi@nokia.com>

avoid type casting, fix the types used.

Signed-off-by: Felipe Balbi <felipe.balbi@nokia.com>
---
 drivers/cbus/cbus.c  |    4 ++--
 drivers/cbus/cbus.h  |    4 ++--
 drivers/cbus/retu.c  |    6 +++---
 drivers/cbus/retu.h  |    6 +++---
 drivers/cbus/tahvo.c |    6 +++---
 drivers/cbus/tahvo.h |    6 +++---
 6 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/drivers/cbus/cbus.c b/drivers/cbus/cbus.c
index 53b43e1..06ab81f 100644
--- a/drivers/cbus/cbus.c
+++ b/drivers/cbus/cbus.c
@@ -129,7 +129,7 @@ static int cbus_transfer(struct cbus_host *host, unsigned rw, unsigned dev,
 /*
  * Read a given register from the device
  */
-int cbus_read_reg(int dev, int reg)
+int cbus_read_reg(unsigned dev, unsigned reg)
 {
 	return cbus_transfer(cbus_host, CBUS_XFER_READ, dev, reg, 0);
 }
@@ -138,7 +138,7 @@ EXPORT_SYMBOL(cbus_read_reg);
 /*
  * Write to a given register of the device
  */
-int cbus_write_reg(int dev, int reg, int val)
+int cbus_write_reg(unsigned dev, unsigned reg, unsigned val)
 {
 	return cbus_transfer(cbus_host, CBUS_XFER_WRITE, dev, reg, val);
 }
diff --git a/drivers/cbus/cbus.h b/drivers/cbus/cbus.h
index fbaca09..62f1874 100644
--- a/drivers/cbus/cbus.h
+++ b/drivers/cbus/cbus.h
@@ -32,7 +32,7 @@ struct cbus_host {
 	int	sel_gpio;
 };
 
-extern int cbus_read_reg(int dev, int reg);
-extern int cbus_write_reg(int dev, int reg, int val);
+extern int cbus_read_reg(unsigned dev, unsigned reg);
+extern int cbus_write_reg(unsigned dev, unsigned reg, unsigned val);
 
 #endif /* __DRIVERS_CBUS_CBUS_H */
diff --git a/drivers/cbus/retu.c b/drivers/cbus/retu.c
index 35fdd11..80a2acc 100644
--- a/drivers/cbus/retu.c
+++ b/drivers/cbus/retu.c
@@ -78,7 +78,7 @@ EXPORT_SYMBOL(retu_get_status);
  *
  * This function returns the contents of the specified register
  */
-int retu_read_reg(int reg)
+int retu_read_reg(unsigned reg)
 {
 	BUG_ON(!retu_initialized);
 	return cbus_read_reg(RETU_ID, reg);
@@ -91,13 +91,13 @@ int retu_read_reg(int reg)
  *
  * This function writes a value to the specified register
  */
-void retu_write_reg(int reg, u16 val)
+void retu_write_reg(unsigned reg, u16 val)
 {
 	BUG_ON(!retu_initialized);
 	cbus_write_reg(RETU_ID, reg, val);
 }
 
-void retu_set_clear_reg_bits(int reg, u16 set, u16 clear)
+void retu_set_clear_reg_bits(unsigned reg, u16 set, u16 clear)
 {
 	unsigned long flags;
 	u16 w;
diff --git a/drivers/cbus/retu.h b/drivers/cbus/retu.h
index fbd1981..cf3cf20 100644
--- a/drivers/cbus/retu.h
+++ b/drivers/cbus/retu.h
@@ -58,9 +58,9 @@
 #define	MAX_RETU_IRQ_HANDLERS	16
 
 int retu_get_status(void);
-int retu_read_reg(int reg);
-void retu_write_reg(int reg, u16 val);
-void retu_set_clear_reg_bits(int reg, u16 set, u16 clear);
+int retu_read_reg(unsigned reg);
+void retu_write_reg(unsigned reg, u16 val);
+void retu_set_clear_reg_bits(unsigned reg, u16 set, u16 clear);
 int retu_read_adc(int channel);
 int retu_request_irq(int id, void *irq_handler, unsigned long arg, char *name);
 void retu_free_irq(int id);
diff --git a/drivers/cbus/tahvo.c b/drivers/cbus/tahvo.c
index 6828acc..d8fa90a 100644
--- a/drivers/cbus/tahvo.c
+++ b/drivers/cbus/tahvo.c
@@ -78,7 +78,7 @@ EXPORT_SYMBOL(tahvo_get_status);
  *
  * This function returns the contents of the specified register
  */
-int tahvo_read_reg(int reg)
+int tahvo_read_reg(unsigned reg)
 {
 	BUG_ON(!tahvo_initialized);
 	return cbus_read_reg(TAHVO_ID, reg);
@@ -91,7 +91,7 @@ int tahvo_read_reg(int reg)
  *
  * This function writes a value to the specified register
  */
-void tahvo_write_reg(int reg, u16 val)
+void tahvo_write_reg(unsigned reg, u16 val)
 {
 	BUG_ON(!tahvo_initialized);
 	cbus_write_reg(TAHVO_ID, reg, val);
@@ -104,7 +104,7 @@ void tahvo_write_reg(int reg, u16 val)
  *
  * This function sets and clears the specified Tahvo register bits atomically
  */
-void tahvo_set_clear_reg_bits(int reg, u16 set, u16 clear)
+void tahvo_set_clear_reg_bits(unsigned reg, u16 set, u16 clear)
 {
 	unsigned long flags;
 	u16 w;
diff --git a/drivers/cbus/tahvo.h b/drivers/cbus/tahvo.h
index b4c6f50..97d6583 100644
--- a/drivers/cbus/tahvo.h
+++ b/drivers/cbus/tahvo.h
@@ -40,9 +40,9 @@
 #define MAX_TAHVO_IRQ_HANDLERS	8
 
 int tahvo_get_status(void);
-int tahvo_read_reg(int reg);
-void tahvo_write_reg(int reg, u16 val);
-void tahvo_set_clear_reg_bits(int reg, u16 set, u16 clear);
+int tahvo_read_reg(unsigned reg);
+void tahvo_write_reg(unsigned reg, u16 val);
+void tahvo_set_clear_reg_bits(unsigned reg, u16 set, u16 clear);
 int tahvo_request_irq(int id, void *irq_handler, unsigned long arg, char *name);
 void tahvo_free_irq(int id);
 void tahvo_enable_irq(int id);
-- 
1.7.0.rc0.33.g7c3932


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

* [RFC PATCH 09/37] cbus: fix a resource leakage
  2010-04-07 16:03 [RFC PATCH 00/37] cbus patches felipe.balbi
                   ` (7 preceding siblings ...)
  2010-04-07 16:03 ` [RFC PATCH 08/37] cbus: don't type case when issuing read/write felipe.balbi
@ 2010-04-07 16:04 ` felipe.balbi
  2010-04-07 16:04 ` [RFC PATCH 10/37] cbus: move cbus_host definition to C source felipe.balbi
                   ` (28 subsequent siblings)
  37 siblings, 0 replies; 41+ messages in thread
From: felipe.balbi @ 2010-04-07 16:04 UTC (permalink / raw)
  To: Linux OMAP Mailing List; +Cc: Felipe Balbi

From: Felipe Balbi <felipe.balbi@nokia.com>

sel_gpio was never freed on previous code, free it.

Signed-off-by: Felipe Balbi <felipe.balbi@nokia.com>
---
 drivers/cbus/cbus.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/cbus/cbus.c b/drivers/cbus/cbus.c
index 06ab81f..c219d54 100644
--- a/drivers/cbus/cbus.c
+++ b/drivers/cbus/cbus.c
@@ -198,6 +198,7 @@ static void __exit cbus_bus_remove(struct platform_device *pdev)
 {
 	struct cbus_host	*chost = platform_get_drvdata(pdev);
 
+	gpio_free(chost->sel_gpio);
 	gpio_free(chost->dat_gpio);
 	gpio_free(chost->clk_gpio);
 
-- 
1.7.0.rc0.33.g7c3932


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

* [RFC PATCH 10/37] cbus: move cbus_host definition to C source
  2010-04-07 16:03 [RFC PATCH 00/37] cbus patches felipe.balbi
                   ` (8 preceding siblings ...)
  2010-04-07 16:04 ` [RFC PATCH 09/37] cbus: fix a resource leakage felipe.balbi
@ 2010-04-07 16:04 ` felipe.balbi
  2010-04-07 16:04 ` [RFC PATCH 11/37] cbus: handle possible errors on cbus_send/receive_bit felipe.balbi
                   ` (27 subsequent siblings)
  37 siblings, 0 replies; 41+ messages in thread
From: felipe.balbi @ 2010-04-07 16:04 UTC (permalink / raw)
  To: Linux OMAP Mailing List; +Cc: Felipe Balbi

From: Felipe Balbi <felipe.balbi@nokia.com>

no-one else besides cbus.c wants to deal with
struct cbus_host, so move the definition to
the C source interested in it.

Signed-off-by: Felipe Balbi <felipe.balbi@nokia.com>
---
 drivers/cbus/cbus.c |    9 +++++++++
 drivers/cbus/cbus.h |    9 ---------
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/cbus/cbus.c b/drivers/cbus/cbus.c
index c219d54..285bf23 100644
--- a/drivers/cbus/cbus.c
+++ b/drivers/cbus/cbus.c
@@ -45,6 +45,15 @@
 #define CBUS_XFER_READ		1
 #define CBUS_XFER_WRITE		0
 
+struct cbus_host {
+	/* host lock */
+	spinlock_t lock;
+
+	int	clk_gpio;
+	int	dat_gpio;
+	int	sel_gpio;
+};
+
 static struct cbus_host *cbus_host;
 
 static void cbus_send_bit(struct cbus_host *host, int bit, int set_to_input)
diff --git a/drivers/cbus/cbus.h b/drivers/cbus/cbus.h
index 62f1874..d53bb70 100644
--- a/drivers/cbus/cbus.h
+++ b/drivers/cbus/cbus.h
@@ -23,15 +23,6 @@
 #ifndef __DRIVERS_CBUS_CBUS_H
 #define __DRIVERS_CBUS_CBUS_H
 
-struct cbus_host {
-	/* host lock */
-	spinlock_t lock;
-
-	int	clk_gpio;
-	int	dat_gpio;
-	int	sel_gpio;
-};
-
 extern int cbus_read_reg(unsigned dev, unsigned reg);
 extern int cbus_write_reg(unsigned dev, unsigned reg, unsigned val);
 
-- 
1.7.0.rc0.33.g7c3932


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

* [RFC PATCH 11/37] cbus: handle possible errors on cbus_send/receive_bit
  2010-04-07 16:03 [RFC PATCH 00/37] cbus patches felipe.balbi
                   ` (9 preceding siblings ...)
  2010-04-07 16:04 ` [RFC PATCH 10/37] cbus: move cbus_host definition to C source felipe.balbi
@ 2010-04-07 16:04 ` felipe.balbi
  2010-04-07 16:04 ` [RFC PATCH 12/37] cbus: introduce cbus_send/receive_data wrappers felipe.balbi
                   ` (26 subsequent siblings)
  37 siblings, 0 replies; 41+ messages in thread
From: felipe.balbi @ 2010-04-07 16:04 UTC (permalink / raw)
  To: Linux OMAP Mailing List; +Cc: Felipe Balbi

From: Felipe Balbi <felipe.balbi@nokia.com>

gpio_direction_input might fail and we have
to handle that possibility. While at that,
also add the device pointer to struct cbus_host
and use that for printing debugging messages and
make cbus_receive_bit return int.

Signed-off-by: Felipe Balbi <felipe.balbi@nokia.com>
---
 drivers/cbus/cbus.c |   68 +++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 53 insertions(+), 15 deletions(-)

diff --git a/drivers/cbus/cbus.c b/drivers/cbus/cbus.c
index 285bf23..0791251 100644
--- a/drivers/cbus/cbus.c
+++ b/drivers/cbus/cbus.c
@@ -47,35 +47,44 @@
 
 struct cbus_host {
 	/* host lock */
-	spinlock_t lock;
+	spinlock_t	lock;
 
-	int	clk_gpio;
-	int	dat_gpio;
-	int	sel_gpio;
+	struct device	*dev;
+
+	int		clk_gpio;
+	int		dat_gpio;
+	int		sel_gpio;
 };
 
 static struct cbus_host *cbus_host;
 
-static void cbus_send_bit(struct cbus_host *host, int bit, int set_to_input)
+static int cbus_send_bit(struct cbus_host *host, int bit, int set_to_input)
 {
+	int ret = 0;
+
 	gpio_set_value(host->dat_gpio, bit ? 1 : 0);
 	gpio_set_value(host->clk_gpio, 1);
 
 	/* The data bit is read on the rising edge of CLK */
 	if (set_to_input)
-		gpio_direction_input(host->dat_gpio);
+		ret = gpio_direction_input(host->dat_gpio);
 
 	gpio_set_value(host->clk_gpio, 0);
+
+	return ret;
 }
 
-static u8 cbus_receive_bit(struct cbus_host *host)
+static int cbus_receive_bit(struct cbus_host *host)
 {
-	u8 ret;
+	int ret;
 
 	gpio_set_value(host->clk_gpio, 1);
 	ret = gpio_get_value(host->dat_gpio);
+	if (ret < 0)
+		goto out;
 	gpio_set_value(host->clk_gpio, 0);
 
+out:
 	return ret;
 }
 
@@ -83,6 +92,7 @@ static int cbus_transfer(struct cbus_host *host, unsigned rw, unsigned dev,
 		unsigned reg, unsigned data)
 {
 	unsigned long flags;
+	int ret = 0;
 	int i;
 
 	/* We don't want interrupts disturbing our transfer */
@@ -95,11 +105,20 @@ static int cbus_transfer(struct cbus_host *host, unsigned rw, unsigned dev,
 	gpio_direction_output(host->dat_gpio, 1);
 
 	/* Send the device address */
-	for (i = 3; i > 0; i--)
-		cbus_send_bit(host, dev & (1 << (i - 1)), 0);
+	for (i = 3; i > 0; i--) {
+		ret = cbus_send_bit(host, dev & (1 << (i - 1)), 0);
+		if (ret < 0) {
+			dev_dbg(host->dev, "failed sending device addr\n");
+			goto out;
+		}
+	}
 
 	/* Send the rw flag */
-	cbus_send_bit(host, rw, 0);
+	ret = cbus_send_bit(host, rw, 0);
+	if (ret < 0) {
+		dev_dbg(host->dev, "failed sending read/write flag\n");
+		goto out;
+	}
 
 	/* Send the register address */
 	for (i = 5; i > 0; i--) {
@@ -108,21 +127,38 @@ static int cbus_transfer(struct cbus_host *host, unsigned rw, unsigned dev,
 		if (rw && i == 1)
 			set_to_input = 1;
 
-		cbus_send_bit(host, reg & (1 << (i - 1)), set_to_input);
+		ret = cbus_send_bit(host, reg & (1 << (i - 1)), set_to_input);
+		if (ret < 0) {
+			dev_dbg(host->dev, "failed sending register addr\n");
+			goto out;
+		}
 	}
 
 	if (!rw) {
-		for (i = 16; i > 0; i--)
-			cbus_send_bit(host, data & (1 << (i - 1)), 0);
+		for (i = 16; i > 0; i--) {
+			ret = cbus_send_bit(host, data & (1 << (i - 1)), 0);
+			if (ret < 0) {
+				dev_dbg(host->dev, "failed sending data\n");
+				goto out;
+			}
+		}
 	} else {
 		gpio_set_value(host->clk_gpio, 1);
 
 		for (i = 16; i > 0; i--) {
 			u8 bit = cbus_receive_bit(host);
 
+			if (bit < 0) {
+				dev_dbg(host->dev, "failed receiving data\n");
+				goto out;
+			}
+
 			if (bit)
 				data |= 1 << (i - 1);
 		}
+
+		/* return the data received */
+		ret = data;
 	}
 
 	/* Indicate end of transfer, SEL goes up until next transfer */
@@ -130,9 +166,10 @@ static int cbus_transfer(struct cbus_host *host, unsigned rw, unsigned dev,
 	gpio_set_value(host->clk_gpio, 1);
 	gpio_set_value(host->clk_gpio, 0);
 
+out:
 	spin_unlock_irqrestore(&host->lock, flags);
 
-	return data;
+	return ret;
 }
 
 /*
@@ -168,6 +205,7 @@ static int __init cbus_bus_probe(struct platform_device *pdev)
 	chost->clk_gpio = pdata->clk_gpio;
 	chost->dat_gpio = pdata->dat_gpio;
 	chost->sel_gpio = pdata->sel_gpio;
+	chost->dev = &pdev->dev;
 
 	ret = gpio_request(chost->clk_gpio, "CBUS clk");
 	if (ret < 0)
-- 
1.7.0.rc0.33.g7c3932


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

* [RFC PATCH 12/37] cbus: introduce cbus_send/receive_data wrappers
  2010-04-07 16:03 [RFC PATCH 00/37] cbus patches felipe.balbi
                   ` (10 preceding siblings ...)
  2010-04-07 16:04 ` [RFC PATCH 11/37] cbus: handle possible errors on cbus_send/receive_bit felipe.balbi
@ 2010-04-07 16:04 ` felipe.balbi
  2010-04-07 16:04 ` [RFC PATCH 13/37] cbus: add kerneldoc felipe.balbi
                   ` (25 subsequent siblings)
  37 siblings, 0 replies; 41+ messages in thread
From: felipe.balbi @ 2010-04-07 16:04 UTC (permalink / raw)
  To: Linux OMAP Mailing List; +Cc: Felipe Balbi

From: Felipe Balbi <felipe.balbi@nokia.com>

encapsulate the for loop on those wrappers and
make the code easier to follow.

Signed-off-by: Felipe Balbi <felipe.balbi@nokia.com>
---
 drivers/cbus/cbus.c |   96 +++++++++++++++++++++++++++++++--------------------
 1 files changed, 58 insertions(+), 38 deletions(-)

diff --git a/drivers/cbus/cbus.c b/drivers/cbus/cbus.c
index 0791251..bae7b3e 100644
--- a/drivers/cbus/cbus.c
+++ b/drivers/cbus/cbus.c
@@ -58,7 +58,8 @@ struct cbus_host {
 
 static struct cbus_host *cbus_host;
 
-static int cbus_send_bit(struct cbus_host *host, int bit, int set_to_input)
+static int cbus_send_bit(struct cbus_host *host, unsigned bit,
+		unsigned input)
 {
 	int ret = 0;
 
@@ -66,7 +67,7 @@ static int cbus_send_bit(struct cbus_host *host, int bit, int set_to_input)
 	gpio_set_value(host->clk_gpio, 1);
 
 	/* The data bit is read on the rising edge of CLK */
-	if (set_to_input)
+	if (input)
 		ret = gpio_direction_input(host->dat_gpio);
 
 	gpio_set_value(host->clk_gpio, 0);
@@ -74,6 +75,23 @@ static int cbus_send_bit(struct cbus_host *host, int bit, int set_to_input)
 	return ret;
 }
 
+static int cbus_send_data(struct cbus_host *host, unsigned data, unsigned len,
+		unsigned input)
+{
+	int ret = 0;
+	int i;
+
+	for (i = len; i > 0; i--) {
+		ret = cbus_send_bit(host, data & (1 << (i - 1)),
+				input && (i == 1));
+		if (ret < 0)
+			goto out;
+	}
+
+out:
+	return ret;
+}
+
 static int cbus_receive_bit(struct cbus_host *host)
 {
 	int ret;
@@ -88,12 +106,31 @@ out:
 	return ret;
 }
 
+static int cbus_receive_data(struct cbus_host *host, unsigned len)
+{
+	int ret = 0;
+	int i;
+
+	for (i = 16; i > 0; i--) {
+		int bit = cbus_receive_bit(host);
+
+		if (bit < 0)
+			goto out;
+
+		if (bit)
+			ret |= 1 << (i - 1);
+	}
+
+out:
+	return ret;
+}
+
 static int cbus_transfer(struct cbus_host *host, unsigned rw, unsigned dev,
 		unsigned reg, unsigned data)
 {
 	unsigned long flags;
+	int input = 0;
 	int ret = 0;
-	int i;
 
 	/* We don't want interrupts disturbing our transfer */
 	spin_lock_irqsave(&host->lock, flags);
@@ -105,12 +142,10 @@ static int cbus_transfer(struct cbus_host *host, unsigned rw, unsigned dev,
 	gpio_direction_output(host->dat_gpio, 1);
 
 	/* Send the device address */
-	for (i = 3; i > 0; i--) {
-		ret = cbus_send_bit(host, dev & (1 << (i - 1)), 0);
-		if (ret < 0) {
-			dev_dbg(host->dev, "failed sending device addr\n");
-			goto out;
-		}
+	ret = cbus_send_data(host, dev, 3, 0);
+	if (ret < 0) {
+		dev_dbg(host->dev, "failed sending device addr\n");
+		goto out;
 	}
 
 	/* Send the rw flag */
@@ -121,44 +156,29 @@ static int cbus_transfer(struct cbus_host *host, unsigned rw, unsigned dev,
 	}
 
 	/* Send the register address */
-	for (i = 5; i > 0; i--) {
-		int set_to_input = 0;
-
-		if (rw && i == 1)
-			set_to_input = 1;
+	if (rw)
+		input = true;
 
-		ret = cbus_send_bit(host, reg & (1 << (i - 1)), set_to_input);
-		if (ret < 0) {
-			dev_dbg(host->dev, "failed sending register addr\n");
-			goto out;
-		}
+	ret = cbus_send_data(host, reg, 5, input);
+	if (ret < 0) {
+		dev_dbg(host->dev, "failed sending register addr\n");
+		goto out;
 	}
 
 	if (!rw) {
-		for (i = 16; i > 0; i--) {
-			ret = cbus_send_bit(host, data & (1 << (i - 1)), 0);
-			if (ret < 0) {
-				dev_dbg(host->dev, "failed sending data\n");
-				goto out;
-			}
+		ret = cbus_send_data(host, data, 16, 0);
+		if (ret < 0) {
+			dev_dbg(host->dev, "failed sending data\n");
+			goto out;
 		}
 	} else {
 		gpio_set_value(host->clk_gpio, 1);
 
-		for (i = 16; i > 0; i--) {
-			u8 bit = cbus_receive_bit(host);
-
-			if (bit < 0) {
-				dev_dbg(host->dev, "failed receiving data\n");
-				goto out;
-			}
-
-			if (bit)
-				data |= 1 << (i - 1);
+		ret = cbus_receive_data(host, 16);
+		if (ret < 0) {
+			dev_dbg(host->dev, "failed receiving data\n");
+			goto out;
 		}
-
-		/* return the data received */
-		ret = data;
 	}
 
 	/* Indicate end of transfer, SEL goes up until next transfer */
-- 
1.7.0.rc0.33.g7c3932


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

* [RFC PATCH 13/37] cbus: add kerneldoc
  2010-04-07 16:03 [RFC PATCH 00/37] cbus patches felipe.balbi
                   ` (11 preceding siblings ...)
  2010-04-07 16:04 ` [RFC PATCH 12/37] cbus: introduce cbus_send/receive_data wrappers felipe.balbi
@ 2010-04-07 16:04 ` felipe.balbi
  2010-04-07 16:04 ` [RFC PATCH 14/37] cbus: retu-wdt: fix compile breakage felipe.balbi
                   ` (24 subsequent siblings)
  37 siblings, 0 replies; 41+ messages in thread
From: felipe.balbi @ 2010-04-07 16:04 UTC (permalink / raw)
  To: Linux OMAP Mailing List; +Cc: Felipe Balbi

From: Felipe Balbi <felipe.balbi@nokia.com>

trivial patch, no functional changes.

Signed-off-by: Felipe Balbi <felipe.balbi@nokia.com>
---
 drivers/cbus/cbus.c |   43 +++++++++++++++++++++++++++++++++++++++----
 1 files changed, 39 insertions(+), 4 deletions(-)

diff --git a/drivers/cbus/cbus.c b/drivers/cbus/cbus.c
index bae7b3e..527780f 100644
--- a/drivers/cbus/cbus.c
+++ b/drivers/cbus/cbus.c
@@ -58,6 +58,12 @@ struct cbus_host {
 
 static struct cbus_host *cbus_host;
 
+/**
+ * cbus_send_bit - sends one bit over the bus
+ * @host: the host we're using
+ * @bit: one bit of information to send
+ * @input: whether to set data pin as input after sending
+ */
 static int cbus_send_bit(struct cbus_host *host, unsigned bit,
 		unsigned input)
 {
@@ -75,6 +81,13 @@ static int cbus_send_bit(struct cbus_host *host, unsigned bit,
 	return ret;
 }
 
+/**
+ * cbus_send_data - sends @len amount of data over the bus
+ * @host: the host we're using
+ * @data: the data to send
+ * @len: size of the transfer
+ * @input: whether to set data pin as input after sending
+ */
 static int cbus_send_data(struct cbus_host *host, unsigned data, unsigned len,
 		unsigned input)
 {
@@ -92,6 +105,10 @@ out:
 	return ret;
 }
 
+/**
+ * cbus_receive_bit - receives one bit from the bus
+ * @host: the host we're using
+ */
 static int cbus_receive_bit(struct cbus_host *host)
 {
 	int ret;
@@ -106,6 +123,11 @@ out:
 	return ret;
 }
 
+/**
+ * cbus_receive_data - receives @len data from the bus
+ * @host: the host we're using
+ * @len: the length of data to receive
+ */
 static int cbus_receive_data(struct cbus_host *host, unsigned len)
 {
 	int ret = 0;
@@ -125,6 +147,14 @@ out:
 	return ret;
 }
 
+/**
+ * cbus_transfer - transfers data over the bus
+ * @host: the host we're using
+ * @rw: read/write flag
+ * @dev: device address
+ * @reg: register address
+ * @data: if @rw == 0 data to send otherwise 0
+ */
 static int cbus_transfer(struct cbus_host *host, unsigned rw, unsigned dev,
 		unsigned reg, unsigned data)
 {
@@ -192,8 +222,10 @@ out:
 	return ret;
 }
 
-/*
- * Read a given register from the device
+/**
+ * cbus_read_reg - reads a given register from the device
+ * @dev: device address
+ * @reg: register address
  */
 int cbus_read_reg(unsigned dev, unsigned reg)
 {
@@ -201,8 +233,11 @@ int cbus_read_reg(unsigned dev, unsigned reg)
 }
 EXPORT_SYMBOL(cbus_read_reg);
 
-/*
- * Write to a given register of the device
+/**
+ * cbus_write_reg - writes to a given register of the device
+ * @dev: device address
+ * @reg: register address
+ * @val: data to be written to @reg
  */
 int cbus_write_reg(unsigned dev, unsigned reg, unsigned val)
 {
-- 
1.7.0.rc0.33.g7c3932


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

* [RFC PATCH 14/37] cbus: retu-wdt: fix compile breakage
  2010-04-07 16:03 [RFC PATCH 00/37] cbus patches felipe.balbi
                   ` (12 preceding siblings ...)
  2010-04-07 16:04 ` [RFC PATCH 13/37] cbus: add kerneldoc felipe.balbi
@ 2010-04-07 16:04 ` felipe.balbi
  2010-04-07 16:04 ` [RFC PATCH 15/37] cbus: retu: fix compile breakage on retu-headset felipe.balbi
                   ` (23 subsequent siblings)
  37 siblings, 0 replies; 41+ messages in thread
From: felipe.balbi @ 2010-04-07 16:04 UTC (permalink / raw)
  To: Linux OMAP Mailing List; +Cc: Felipe Balbi

From: Felipe Balbi <felipe.balbi@nokia.com>

fix compile breakage on retu-wdt driver.

Signed-off-by: Felipe Balbi <felipe.balbi@nokia.com>
---
 drivers/cbus/retu-wdt.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/cbus/retu-wdt.c b/drivers/cbus/retu-wdt.c
index 35932dd..380fae6 100644
--- a/drivers/cbus/retu-wdt.c
+++ b/drivers/cbus/retu-wdt.c
@@ -243,7 +243,6 @@ static int __init retu_wdt_ping(void)
 
 	return 0;
 }
-late_initcall(retu_wdt_ping);
 
 static const struct file_operations retu_wdt_fops = {
 	.owner = THIS_MODULE,
@@ -369,7 +368,8 @@ static int __init retu_wdt_init(void)
 	}
 
 	printk(KERN_INFO "Retu watchdog driver initialized\n");
-	return ret;
+
+	return retu_wdt_ping();
 
 exit1:
 	driver_unregister(&retu_wdt_driver);
-- 
1.7.0.rc0.33.g7c3932


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

* [RFC PATCH 15/37] cbus: retu: fix compile breakage on retu-headset
  2010-04-07 16:03 [RFC PATCH 00/37] cbus patches felipe.balbi
                   ` (13 preceding siblings ...)
  2010-04-07 16:04 ` [RFC PATCH 14/37] cbus: retu-wdt: fix compile breakage felipe.balbi
@ 2010-04-07 16:04 ` felipe.balbi
  2010-04-07 16:04 ` [RFC PATCH 16/37] cbus: retu: split one MODULE_AUTHOR into several felipe.balbi
                   ` (22 subsequent siblings)
  37 siblings, 0 replies; 41+ messages in thread
From: felipe.balbi @ 2010-04-07 16:04 UTC (permalink / raw)
  To: Linux OMAP Mailing List; +Cc: Felipe Balbi

From: Felipe Balbi <felipe.balbi@nokia.com>

when building retu-headset as a  module, we need to
export retu_set_clear_reg_bits() and retu_read_adc().

While at that, also move the EXPORT_SYMBOL() macros
closer to the function definitions.

Signed-off-by: Felipe Balbi <felipe.balbi@nokia.com>
---
 drivers/cbus/retu.c |   18 +++++++++---------
 1 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/cbus/retu.c b/drivers/cbus/retu.c
index 80a2acc..7f7a31b 100644
--- a/drivers/cbus/retu.c
+++ b/drivers/cbus/retu.c
@@ -83,6 +83,7 @@ int retu_read_reg(unsigned reg)
 	BUG_ON(!retu_initialized);
 	return cbus_read_reg(RETU_ID, reg);
 }
+EXPORT_SYMBOL(retu_read_reg);
 
 /**
  * retu_write_reg - Write a value to a register in Retu
@@ -96,6 +97,7 @@ void retu_write_reg(unsigned reg, u16 val)
 	BUG_ON(!retu_initialized);
 	cbus_write_reg(RETU_ID, reg, val);
 }
+EXPORT_SYMBOL(retu_write_reg);
 
 void retu_set_clear_reg_bits(unsigned reg, u16 set, u16 clear)
 {
@@ -109,6 +111,7 @@ void retu_set_clear_reg_bits(unsigned reg, u16 set, u16 clear)
 	retu_write_reg(reg, w);
 	spin_unlock_irqrestore(&retu_lock, flags);
 }
+EXPORT_SYMBOL_GPL(retu_set_clear_reg_bits);
 
 #define ADC_MAX_CHAN_NUMBER	13
 
@@ -141,7 +144,7 @@ int retu_read_adc(int channel)
 
 	return res;
 }
-
+EXPORT_SYMBOL(retu_read_adc);
 
 static u16 retu_disable_bogus_irqs(u16 mask)
 {
@@ -174,6 +177,7 @@ void retu_disable_irq(int id)
 	retu_write_reg(RETU_REG_IMR, mask);
 	spin_unlock_irqrestore(&retu_lock, flags);
 }
+EXPORT_SYMBOL(retu_disable_irq);
 
 /*
  * Enable given RETU interrupt
@@ -194,6 +198,7 @@ void retu_enable_irq(int id)
 	retu_write_reg(RETU_REG_IMR, mask);
 	spin_unlock_irqrestore(&retu_lock, flags);
 }
+EXPORT_SYMBOL(retu_enable_irq);
 
 /*
  * Acknowledge given RETU interrupt
@@ -202,6 +207,7 @@ void retu_ack_irq(int id)
 {
 	retu_write_reg(RETU_REG_IDR, 1 << id);
 }
+EXPORT_SYMBOL(retu_ack_irq);
 
 /*
  * RETU interrupt handler. Only schedules the tasklet.
@@ -283,6 +289,7 @@ int retu_request_irq(int id, void *irq_handler, unsigned long arg, char *name)
 
 	return 0;
 }
+EXPORT_SYMBOL(retu_request_irq);
 
 /*
  * Unregister the handler for a given RETU interrupt source.
@@ -305,6 +312,7 @@ void retu_free_irq(int id)
 	retu_disable_irq(id);
 	hnd->func = NULL;
 }
+EXPORT_SYMBOL(retu_free_irq);
 
 /**
  * retu_power_off - Shut down power to system
@@ -465,14 +473,6 @@ static void __exit retu_exit(void)
 	wait_for_completion(&device_release);
 }
 
-EXPORT_SYMBOL(retu_request_irq);
-EXPORT_SYMBOL(retu_free_irq);
-EXPORT_SYMBOL(retu_enable_irq);
-EXPORT_SYMBOL(retu_disable_irq);
-EXPORT_SYMBOL(retu_ack_irq);
-EXPORT_SYMBOL(retu_read_reg);
-EXPORT_SYMBOL(retu_write_reg);
-
 subsys_initcall(retu_init);
 module_exit(retu_exit);
 
-- 
1.7.0.rc0.33.g7c3932


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

* [RFC PATCH 16/37] cbus: retu: split one MODULE_AUTHOR into several
  2010-04-07 16:03 [RFC PATCH 00/37] cbus patches felipe.balbi
                   ` (14 preceding siblings ...)
  2010-04-07 16:04 ` [RFC PATCH 15/37] cbus: retu: fix compile breakage on retu-headset felipe.balbi
@ 2010-04-07 16:04 ` felipe.balbi
  2010-04-07 16:04 ` [RFC PATCH 17/37] cbus: retu: don't assing ret inside the if () felipe.balbi
                   ` (21 subsequent siblings)
  37 siblings, 0 replies; 41+ messages in thread
From: felipe.balbi @ 2010-04-07 16:04 UTC (permalink / raw)
  To: Linux OMAP Mailing List; +Cc: Felipe Balbi

From: Felipe Balbi <felipe.balbi@nokia.com>

it's easier to read anyways.

Signed-off-by: Felipe Balbi <felipe.balbi@nokia.com>
---
 drivers/cbus/retu.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/drivers/cbus/retu.c b/drivers/cbus/retu.c
index 7f7a31b..ae2e691 100644
--- a/drivers/cbus/retu.c
+++ b/drivers/cbus/retu.c
@@ -478,4 +478,6 @@ module_exit(retu_exit);
 
 MODULE_DESCRIPTION("Retu ASIC control");
 MODULE_LICENSE("GPL");
-MODULE_AUTHOR("Juha Yrjölä, David Weinehall, and Mikko Ylinen");
+MODULE_AUTHOR("Juha Yrjölä");
+MODULE_AUTHOR("David Weinehall");
+MODULE_AUTHOR("Mikko Ylinen");
-- 
1.7.0.rc0.33.g7c3932

--
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] 41+ messages in thread

* [RFC PATCH 17/37] cbus: retu: don't assing ret inside the if ()
  2010-04-07 16:03 [RFC PATCH 00/37] cbus patches felipe.balbi
                   ` (15 preceding siblings ...)
  2010-04-07 16:04 ` [RFC PATCH 16/37] cbus: retu: split one MODULE_AUTHOR into several felipe.balbi
@ 2010-04-07 16:04 ` felipe.balbi
  2010-04-07 16:04 ` [RFC PATCH 18/37] cbus: retu: convert printk to dev_* felipe.balbi
                   ` (20 subsequent siblings)
  37 siblings, 0 replies; 41+ messages in thread
From: felipe.balbi @ 2010-04-07 16:04 UTC (permalink / raw)
  To: Linux OMAP Mailing List; +Cc: Felipe Balbi

From: Felipe Balbi <felipe.balbi@nokia.com>

better coding style.

Change:
	if ((ret = driver_register(&retu_driver)))
into:
	ret = driver_register(&retu_driver);
	if (ret)

Signed-off-by: Felipe Balbi <felipe.balbi@nokia.com>
---
 drivers/cbus/retu.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/cbus/retu.c b/drivers/cbus/retu.c
index ae2e691..8382694 100644
--- a/drivers/cbus/retu.c
+++ b/drivers/cbus/retu.c
@@ -354,7 +354,8 @@ static int __devinit retu_probe(struct device *dev)
 		return -ENODEV;
 	}
 
-	if ((ret = gpio_request(retu_irq_pin, "RETU irq")) < 0) {
+	ret = gpio_request(retu_irq_pin, "RETU irq");
+	if (ret < 0) {
 		printk(KERN_ERR PFX "Unable to reserve IRQ GPIO\n");
 		return ret;
 	}
@@ -453,13 +454,16 @@ static int __init retu_init(void)
 
 	init_completion(&device_release);
 
-	if ((ret = driver_register(&retu_driver)) < 0)
+	ret = driver_register(&retu_driver);
+	if (ret < 0)
 		return ret;
 
-	if ((ret = platform_device_register(&retu_device)) < 0) {
+	ret = platform_device_register(&retu_device);
+	if (ret < 0) {
 		driver_unregister(&retu_driver);
 		return ret;
 	}
+
 	return 0;
 }
 
-- 
1.7.0.rc0.33.g7c3932


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

* [RFC PATCH 18/37] cbus: retu: convert printk to dev_*
  2010-04-07 16:03 [RFC PATCH 00/37] cbus patches felipe.balbi
                   ` (16 preceding siblings ...)
  2010-04-07 16:04 ` [RFC PATCH 17/37] cbus: retu: don't assing ret inside the if () felipe.balbi
@ 2010-04-07 16:04 ` felipe.balbi
  2010-04-07 16:04 ` [RFC PATCH 19/37] cbus: retu: convert to a platform_driver felipe.balbi
                   ` (19 subsequent siblings)
  37 siblings, 0 replies; 41+ messages in thread
From: felipe.balbi @ 2010-04-07 16:04 UTC (permalink / raw)
  To: Linux OMAP Mailing List; +Cc: Felipe Balbi

From: Felipe Balbi <felipe.balbi@nokia.com>

during probe(), we have a dev * available, and we
can use that for pretty printing with dev_* macros.

Signed-off-by: Felipe Balbi <felipe.balbi@nokia.com>
---
 drivers/cbus/retu.c |   12 +++++-------
 1 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/cbus/retu.c b/drivers/cbus/retu.c
index 8382694..8b85221 100644
--- a/drivers/cbus/retu.c
+++ b/drivers/cbus/retu.c
@@ -350,13 +350,13 @@ static int __devinit retu_probe(struct device *dev)
 			machine_is_nokia_n810_wimax()) {
 		retu_irq_pin = 108;
 	} else {
-		printk(KERN_ERR "cbus: Unsupported board for tahvo\n");
+		dev_err(dev, "cbus: Unsupported board for tahvo\n");
 		return -ENODEV;
 	}
 
 	ret = gpio_request(retu_irq_pin, "RETU irq");
 	if (ret < 0) {
-		printk(KERN_ERR PFX "Unable to reserve IRQ GPIO\n");
+		dev_err(dev, "Unable to reserve IRQ GPIO\n");
 		return ret;
 	}
 
@@ -372,7 +372,7 @@ static int __devinit retu_probe(struct device *dev)
 	if (rev & (1 << 7))
 		retu_is_vilma = 1;
 
-	printk(KERN_INFO "%s v%d.%d found\n", retu_is_vilma ? "Vilma" : "Retu",
+	dev_info(dev, "%s v%d.%d found\n", retu_is_vilma ? "Vilma" : "Retu",
 	       (rev >> 4) & 0x07, rev & 0x0f);
 
 	/* Mask all RETU interrupts */
@@ -381,7 +381,7 @@ static int __devinit retu_probe(struct device *dev)
 	ret = request_irq(gpio_to_irq(retu_irq_pin), retu_irq_handler, 0,
 			  "retu", 0);
 	if (ret < 0) {
-		printk(KERN_ERR PFX "Unable to register IRQ handler\n");
+		dev_err(dev, "Unable to register IRQ handler\n");
 		gpio_free(retu_irq_pin);
 		return ret;
 	}
@@ -393,7 +393,7 @@ static int __devinit retu_probe(struct device *dev)
 #ifdef CONFIG_CBUS_RETU_USER
 	/* Initialize user-space interface */
 	if (retu_user_init() < 0) {
-		printk(KERN_ERR "Unable to initialize driver\n");
+		dev_err(dev, "Unable to initialize driver\n");
 		free_irq(gpio_to_irq(retu_irq_pin), 0);
 		gpio_free(retu_irq_pin);
 		return ret;
@@ -450,8 +450,6 @@ static int __init retu_init(void)
 		machine_is_nokia_n810() || machine_is_nokia_n810_wimax()))
 			return -ENODEV;
 
-	printk(KERN_INFO "Retu/Vilma driver initialising\n");
-
 	init_completion(&device_release);
 
 	ret = driver_register(&retu_driver);
-- 
1.7.0.rc0.33.g7c3932


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

* [RFC PATCH 19/37] cbus: retu: convert to a platform_driver
  2010-04-07 16:03 [RFC PATCH 00/37] cbus patches felipe.balbi
                   ` (17 preceding siblings ...)
  2010-04-07 16:04 ` [RFC PATCH 18/37] cbus: retu: convert printk to dev_* felipe.balbi
@ 2010-04-07 16:04 ` felipe.balbi
  2010-04-07 16:04 ` [RFC PATCH 20/37] cbus: tahvo: split MODULE_AUTHOR into several entries felipe.balbi
                   ` (18 subsequent siblings)
  37 siblings, 0 replies; 41+ messages in thread
From: felipe.balbi @ 2010-04-07 16:04 UTC (permalink / raw)
  To: Linux OMAP Mailing List; +Cc: Felipe Balbi

From: Felipe Balbi <felipe.balbi@nokia.com>

preparing this driver for mainline. Convert into
a platform_driver and prepare to split platform_device
code from platform_driver code.

Signed-off-by: Felipe Balbi <felipe.balbi@nokia.com>
---
 drivers/cbus/retu.c |   29 +++++++++++++++--------------
 1 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/drivers/cbus/retu.c b/drivers/cbus/retu.c
index 8b85221..ea09c17 100644
--- a/drivers/cbus/retu.c
+++ b/drivers/cbus/retu.c
@@ -336,7 +336,7 @@ static void retu_power_off(void)
  * Probe for the Retu ASIC and allocate memory
  * for its device-struct if found
  */
-static int __devinit retu_probe(struct device *dev)
+static int __devinit retu_probe(struct platform_device *pdev)
 {
 	int rev, ret;
 
@@ -350,13 +350,13 @@ static int __devinit retu_probe(struct device *dev)
 			machine_is_nokia_n810_wimax()) {
 		retu_irq_pin = 108;
 	} else {
-		dev_err(dev, "cbus: Unsupported board for tahvo\n");
+		dev_err(&pdev->dev, "cbus: Unsupported board for tahvo\n");
 		return -ENODEV;
 	}
 
 	ret = gpio_request(retu_irq_pin, "RETU irq");
 	if (ret < 0) {
-		dev_err(dev, "Unable to reserve IRQ GPIO\n");
+		dev_err(&pdev->dev, "Unable to reserve IRQ GPIO\n");
 		return ret;
 	}
 
@@ -372,7 +372,7 @@ static int __devinit retu_probe(struct device *dev)
 	if (rev & (1 << 7))
 		retu_is_vilma = 1;
 
-	dev_info(dev, "%s v%d.%d found\n", retu_is_vilma ? "Vilma" : "Retu",
+	dev_info(&pdev->dev, "%s v%d.%d found\n", retu_is_vilma ? "Vilma" : "Retu",
 	       (rev >> 4) & 0x07, rev & 0x0f);
 
 	/* Mask all RETU interrupts */
@@ -381,7 +381,7 @@ static int __devinit retu_probe(struct device *dev)
 	ret = request_irq(gpio_to_irq(retu_irq_pin), retu_irq_handler, 0,
 			  "retu", 0);
 	if (ret < 0) {
-		dev_err(dev, "Unable to register IRQ handler\n");
+		dev_err(&pdev->dev, "Unable to register IRQ handler\n");
 		gpio_free(retu_irq_pin);
 		return ret;
 	}
@@ -393,7 +393,7 @@ static int __devinit retu_probe(struct device *dev)
 #ifdef CONFIG_CBUS_RETU_USER
 	/* Initialize user-space interface */
 	if (retu_user_init() < 0) {
-		dev_err(dev, "Unable to initialize driver\n");
+		dev_err(&pdev->dev, "Unable to initialize driver\n");
 		free_irq(gpio_to_irq(retu_irq_pin), 0);
 		gpio_free(retu_irq_pin);
 		return ret;
@@ -403,7 +403,7 @@ static int __devinit retu_probe(struct device *dev)
 	return 0;
 }
 
-static int retu_remove(struct device *dev)
+static int __devexit retu_remove(struct platform_device *pdev)
 {
 #ifdef CONFIG_CBUS_RETU_USER
 	retu_user_cleanup();
@@ -422,11 +422,12 @@ static void retu_device_release(struct device *dev)
 	complete(&device_release);
 }
 
-static struct device_driver retu_driver = {
-	.name		= "retu",
-	.bus		= &platform_bus_type,
+static struct platform_driver retu_driver = {
 	.probe		= retu_probe,
-	.remove		= retu_remove,
+	.remove		= __devexit_p(retu_remove),
+	.driver		= {
+		.name	= "retu",
+	},
 };
 
 static struct platform_device retu_device = {
@@ -452,13 +453,13 @@ static int __init retu_init(void)
 
 	init_completion(&device_release);
 
-	ret = driver_register(&retu_driver);
+	ret = platform_driver_register(&retu_driver);
 	if (ret < 0)
 		return ret;
 
 	ret = platform_device_register(&retu_device);
 	if (ret < 0) {
-		driver_unregister(&retu_driver);
+		platform_driver_unregister(&retu_driver);
 		return ret;
 	}
 
@@ -471,7 +472,7 @@ static int __init retu_init(void)
 static void __exit retu_exit(void)
 {
 	platform_device_unregister(&retu_device);
-	driver_unregister(&retu_driver);
+	platform_driver_unregister(&retu_driver);
 	wait_for_completion(&device_release);
 }
 
-- 
1.7.0.rc0.33.g7c3932


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

* [RFC PATCH 20/37] cbus: tahvo: split MODULE_AUTHOR into several entries
  2010-04-07 16:03 [RFC PATCH 00/37] cbus patches felipe.balbi
                   ` (18 preceding siblings ...)
  2010-04-07 16:04 ` [RFC PATCH 19/37] cbus: retu: convert to a platform_driver felipe.balbi
@ 2010-04-07 16:04 ` felipe.balbi
  2010-04-07 16:04 ` [RFC PATCH 21/37] cbus: tahvo: move EXPORT_SYMBOL macros closer to functions felipe.balbi
                   ` (17 subsequent siblings)
  37 siblings, 0 replies; 41+ messages in thread
From: felipe.balbi @ 2010-04-07 16:04 UTC (permalink / raw)
  To: Linux OMAP Mailing List; +Cc: Felipe Balbi

From: Felipe Balbi <felipe.balbi@nokia.com>

it's easier to read. No functional changes.

Signed-off-by: Felipe Balbi <felipe.balbi@nokia.com>
---
 drivers/cbus/tahvo.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/drivers/cbus/tahvo.c b/drivers/cbus/tahvo.c
index d8fa90a..20b6f15 100644
--- a/drivers/cbus/tahvo.c
+++ b/drivers/cbus/tahvo.c
@@ -450,4 +450,6 @@ module_exit(tahvo_exit);
 
 MODULE_DESCRIPTION("Tahvo ASIC control");
 MODULE_LICENSE("GPL");
-MODULE_AUTHOR("Juha Yrjölä, David Weinehall, and Mikko Ylinen");
+MODULE_AUTHOR("Juha Yrjölä");
+MODULE_AUTHOR("David Weinehall");
+MODULE_AUTHOR("Mikko Ylinen");
-- 
1.7.0.rc0.33.g7c3932

--
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] 41+ messages in thread

* [RFC PATCH 21/37] cbus: tahvo: move EXPORT_SYMBOL macros closer to functions
  2010-04-07 16:03 [RFC PATCH 00/37] cbus patches felipe.balbi
                   ` (19 preceding siblings ...)
  2010-04-07 16:04 ` [RFC PATCH 20/37] cbus: tahvo: split MODULE_AUTHOR into several entries felipe.balbi
@ 2010-04-07 16:04 ` felipe.balbi
  2010-04-07 16:04 ` [RFC PATCH 22/37] cbus: tahvo: don't assign ret inside if () felipe.balbi
                   ` (16 subsequent siblings)
  37 siblings, 0 replies; 41+ messages in thread
From: felipe.balbi @ 2010-04-07 16:04 UTC (permalink / raw)
  To: Linux OMAP Mailing List; +Cc: Felipe Balbi

From: Felipe Balbi <felipe.balbi@nokia.com>

No functional changes but it avoids having to look for which
symbols are exported.

Signed-off-by: Felipe Balbi <felipe.balbi@nokia.com>
---
 drivers/cbus/tahvo.c |   22 +++++++++++-----------
 1 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/cbus/tahvo.c b/drivers/cbus/tahvo.c
index 20b6f15..e14108f 100644
--- a/drivers/cbus/tahvo.c
+++ b/drivers/cbus/tahvo.c
@@ -83,6 +83,7 @@ int tahvo_read_reg(unsigned reg)
 	BUG_ON(!tahvo_initialized);
 	return cbus_read_reg(TAHVO_ID, reg);
 }
+EXPORT_SYMBOL(tahvo_read_reg);
 
 /**
  * tahvo_write_reg - Write a value to a register in Tahvo
@@ -96,6 +97,7 @@ void tahvo_write_reg(unsigned reg, u16 val)
 	BUG_ON(!tahvo_initialized);
 	cbus_write_reg(TAHVO_ID, reg, val);
 }
+EXPORT_SYMBOL(tahvo_write_reg);
 
 /**
  * tahvo_set_clear_reg_bits - set and clear register bits atomically
@@ -131,6 +133,7 @@ void tahvo_disable_irq(int id)
 	tahvo_write_reg(TAHVO_REG_IMR, mask);
 	spin_unlock_irqrestore(&tahvo_lock, flags);
 }
+EXPORT_SYMBOL(tahvo_disable_irq);
 
 /*
  * Enable given TAHVO interrupt
@@ -146,6 +149,7 @@ void tahvo_enable_irq(int id)
 	tahvo_write_reg(TAHVO_REG_IMR, mask);
 	spin_unlock_irqrestore(&tahvo_lock, flags);
 }
+EXPORT_SYMBOL(tahvo_enable_irq);
 
 /*
  * Acknowledge given TAHVO interrupt
@@ -154,6 +158,7 @@ void tahvo_ack_irq(int id)
 {
 	tahvo_write_reg(TAHVO_REG_IDR, 1 << id);
 }
+EXPORT_SYMBOL(tahvo_ack_irq);
 
 static int tahvo_7bit_backlight;
 
@@ -167,6 +172,7 @@ int tahvo_get_backlight_level(void)
 		mask = 0x0f;
 	return tahvo_read_reg(TAHVO_REG_LEDPWMR) & mask;
 }
+EXPORT_SYMBOL(tahvo_get_backlight_level);
 
 int tahvo_get_max_backlight_level(void)
 {
@@ -175,6 +181,7 @@ int tahvo_get_max_backlight_level(void)
 	else
 		return 0x0f;
 }
+EXPORT_SYMBOL(tahvo_get_max_backlight_level);
 
 void tahvo_set_backlight_level(int level)
 {
@@ -185,6 +192,7 @@ void tahvo_set_backlight_level(int level)
 		level = max_level;
 	tahvo_write_reg(TAHVO_REG_LEDPWMR, level);
 }
+EXPORT_SYMBOL(tahvo_set_backlight_level);
 
 /*
  * TAHVO interrupt handler. Only schedules the tasklet.
@@ -263,6 +271,7 @@ int tahvo_request_irq(int id, void *irq_handler, unsigned long arg, char *name)
 
 	return 0;
 }
+EXPORT_SYMBOL(tahvo_request_irq);
 
 /*
  * Unregister the handler for a given TAHVO interrupt source.
@@ -285,6 +294,7 @@ void tahvo_free_irq(int id)
 	tahvo_disable_irq(id);
 	hnd->func = NULL;
 }
+EXPORT_SYMBOL(tahvo_free_irq);
 
 /**
  * tahvo_probe - Probe for Tahvo ASIC
@@ -434,17 +444,6 @@ static void __exit tahvo_exit(void)
 	wait_for_completion(&device_release);
 }
 
-EXPORT_SYMBOL(tahvo_request_irq);
-EXPORT_SYMBOL(tahvo_free_irq);
-EXPORT_SYMBOL(tahvo_enable_irq);
-EXPORT_SYMBOL(tahvo_disable_irq);
-EXPORT_SYMBOL(tahvo_ack_irq);
-EXPORT_SYMBOL(tahvo_read_reg);
-EXPORT_SYMBOL(tahvo_write_reg);
-EXPORT_SYMBOL(tahvo_get_backlight_level);
-EXPORT_SYMBOL(tahvo_get_max_backlight_level);
-EXPORT_SYMBOL(tahvo_set_backlight_level);
-
 subsys_initcall(tahvo_init);
 module_exit(tahvo_exit);
 
@@ -453,3 +452,4 @@ MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Juha Yrjölä");
 MODULE_AUTHOR("David Weinehall");
 MODULE_AUTHOR("Mikko Ylinen");
+
-- 
1.7.0.rc0.33.g7c3932

--
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] 41+ messages in thread

* [RFC PATCH 22/37] cbus: tahvo: don't assign ret inside if ()
  2010-04-07 16:03 [RFC PATCH 00/37] cbus patches felipe.balbi
                   ` (20 preceding siblings ...)
  2010-04-07 16:04 ` [RFC PATCH 21/37] cbus: tahvo: move EXPORT_SYMBOL macros closer to functions felipe.balbi
@ 2010-04-07 16:04 ` felipe.balbi
  2010-04-07 16:04 ` [RFC PATCH 23/37] cbus: tahvo: convert printk into dev_* felipe.balbi
                   ` (15 subsequent siblings)
  37 siblings, 0 replies; 41+ messages in thread
From: felipe.balbi @ 2010-04-07 16:04 UTC (permalink / raw)
  To: Linux OMAP Mailing List; +Cc: Felipe Balbi

From: Felipe Balbi <felipe.balbi@nokia.com>

change codying style, no functional changes.

Signed-off-by: Felipe Balbi <felipe.balbi@nokia.com>
---
 drivers/cbus/tahvo.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/cbus/tahvo.c b/drivers/cbus/tahvo.c
index e14108f..fc25a89 100644
--- a/drivers/cbus/tahvo.c
+++ b/drivers/cbus/tahvo.c
@@ -340,7 +340,8 @@ static int __devinit tahvo_probe(struct device *dev)
 		return -ENODEV;
 	}
 
-	if ((ret = gpio_request(tahvo_irq_pin, "TAHVO irq")) < 0) {
+	ret = gpio_request(tahvo_irq_pin, "TAHVO irq");
+	if (ret) {
 		printk(KERN_ERR PFX "Unable to reserve IRQ GPIO\n");
 		return ret;
 	}
@@ -424,10 +425,12 @@ static int __init tahvo_init(void)
 
 	init_completion(&device_release);
 
-	if ((ret = driver_register(&tahvo_driver)) < 0)
+	ret = driver_register(&tahvo_driver);
+	if (ret)
 		return ret;
 
-	if ((ret = platform_device_register(&tahvo_device)) < 0) {
+	ret = platform_device_register(&tahvo_device);
+	if (ret) {
 		driver_unregister(&tahvo_driver);
 		return ret;
 	}
-- 
1.7.0.rc0.33.g7c3932


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

* [RFC PATCH 23/37] cbus: tahvo: convert printk into dev_*
  2010-04-07 16:03 [RFC PATCH 00/37] cbus patches felipe.balbi
                   ` (21 preceding siblings ...)
  2010-04-07 16:04 ` [RFC PATCH 22/37] cbus: tahvo: don't assign ret inside if () felipe.balbi
@ 2010-04-07 16:04 ` felipe.balbi
  2010-04-07 16:04 ` [RFC PATCH 24/37] cbus: tahvo: convert to platform_driver felipe.balbi
                   ` (14 subsequent siblings)
  37 siblings, 0 replies; 41+ messages in thread
From: felipe.balbi @ 2010-04-07 16:04 UTC (permalink / raw)
  To: Linux OMAP Mailing List; +Cc: Felipe Balbi

From: Felipe Balbi <felipe.balbi@nokia.com>

during probe() we have a device * available so we
can use dev_* macros instead of printk.

Signed-off-by: Felipe Balbi <felipe.balbi@nokia.com>
---
 drivers/cbus/tahvo.c |   14 ++++++--------
 1 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/cbus/tahvo.c b/drivers/cbus/tahvo.c
index fc25a89..9bc3f56 100644
--- a/drivers/cbus/tahvo.c
+++ b/drivers/cbus/tahvo.c
@@ -322,11 +322,11 @@ static int __devinit tahvo_probe(struct device *dev)
 		tahvo_is_betty = 1;
 		tahvo_7bit_backlight = 1;
 	} else {
-		printk(KERN_ERR "Tahvo/Betty chip not found");
+		dev_err(dev, "Tahvo/Betty chip not found");
 		return -ENODEV;
 	}
 
-	printk(KERN_INFO "%s v%d.%d found\n", tahvo_is_betty ? "Betty" : "Tahvo",
+	dev_err(dev, "%s v%d.%d found\n", tahvo_is_betty ? "Betty" : "Tahvo",
 	       (rev >> 4) & 0x0f, rev & 0x0f);
 
 	/* REVISIT: Pass these from board-*.c files in platform_data */
@@ -336,13 +336,13 @@ static int __devinit tahvo_probe(struct device *dev)
 			machine_is_nokia_n810_wimax()) {
 		tahvo_irq_pin = 111;
 	} else {
-		printk(KERN_ERR "cbus: Unsupported board for tahvo\n");
+		dev_err(dev, "cbus: Unsupported board for tahvo\n");
 		return -ENODEV;
 	}
 
 	ret = gpio_request(tahvo_irq_pin, "TAHVO irq");
 	if (ret) {
-		printk(KERN_ERR PFX "Unable to reserve IRQ GPIO\n");
+		dev_err(dev, "Unable to reserve IRQ GPIO\n");
 		return ret;
 	}
 
@@ -358,14 +358,14 @@ static int __devinit tahvo_probe(struct device *dev)
 	ret = request_irq(gpio_to_irq(tahvo_irq_pin), tahvo_irq_handler, 0,
 			  "tahvo", 0);
 	if (ret < 0) {
-		printk(KERN_ERR PFX "Unable to register IRQ handler\n");
+		dev_err(dev, "Unable to register IRQ handler\n");
 		gpio_free(tahvo_irq_pin);
 		return ret;
 	}
 #ifdef CONFIG_CBUS_TAHVO_USER
 	/* Initialize user-space interface */
 	if (tahvo_user_init() < 0) {
-		printk(KERN_ERR "Unable to initialize driver\n");
+		dev_err(dev, "Unable to initialize driver\n");
 		free_irq(gpio_to_irq(tahvo_irq_pin), 0);
 		gpio_free(tahvo_irq_pin);
 		return ret;
@@ -421,8 +421,6 @@ static int __init tahvo_init(void)
 		machine_is_nokia_n810() || machine_is_nokia_n810_wimax()))
 			return -ENODEV;
 
-	printk(KERN_INFO "Tahvo/Betty driver initialising\n");
-
 	init_completion(&device_release);
 
 	ret = driver_register(&tahvo_driver);
-- 
1.7.0.rc0.33.g7c3932


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

* [RFC PATCH 24/37] cbus: tahvo: convert to platform_driver
  2010-04-07 16:03 [RFC PATCH 00/37] cbus patches felipe.balbi
                   ` (22 preceding siblings ...)
  2010-04-07 16:04 ` [RFC PATCH 23/37] cbus: tahvo: convert printk into dev_* felipe.balbi
@ 2010-04-07 16:04 ` felipe.balbi
  2010-04-07 16:04 ` [RFC PATCH 25/37] cbus: retu: allocate platform_device for Retu's children felipe.balbi
                   ` (13 subsequent siblings)
  37 siblings, 0 replies; 41+ messages in thread
From: felipe.balbi @ 2010-04-07 16:04 UTC (permalink / raw)
  To: Linux OMAP Mailing List; +Cc: Felipe Balbi

From: Felipe Balbi <felipe.balbi@nokia.com>

cleanup a bit and start preparing for splitting
platform_device from platform_driver.

Signed-off-by: Felipe Balbi <felipe.balbi@nokia.com>
---
 drivers/cbus/tahvo.c |   31 ++++++++++++++++---------------
 1 files changed, 16 insertions(+), 15 deletions(-)

diff --git a/drivers/cbus/tahvo.c b/drivers/cbus/tahvo.c
index 9bc3f56..7d49252 100644
--- a/drivers/cbus/tahvo.c
+++ b/drivers/cbus/tahvo.c
@@ -303,7 +303,7 @@ EXPORT_SYMBOL(tahvo_free_irq);
  * Probe for the Tahvo ASIC and allocate memory
  * for its device-struct if found
  */
-static int __devinit tahvo_probe(struct device *dev)
+static int __devinit tahvo_probe(struct platform_device *pdev)
 {
 	int rev, id, ret;
 
@@ -322,11 +322,11 @@ static int __devinit tahvo_probe(struct device *dev)
 		tahvo_is_betty = 1;
 		tahvo_7bit_backlight = 1;
 	} else {
-		dev_err(dev, "Tahvo/Betty chip not found");
+		dev_err(&pdev->dev, "Tahvo/Betty chip not found");
 		return -ENODEV;
 	}
 
-	dev_err(dev, "%s v%d.%d found\n", tahvo_is_betty ? "Betty" : "Tahvo",
+	dev_err(&pdev->dev, "%s v%d.%d found\n", tahvo_is_betty ? "Betty" : "Tahvo",
 	       (rev >> 4) & 0x0f, rev & 0x0f);
 
 	/* REVISIT: Pass these from board-*.c files in platform_data */
@@ -336,13 +336,13 @@ static int __devinit tahvo_probe(struct device *dev)
 			machine_is_nokia_n810_wimax()) {
 		tahvo_irq_pin = 111;
 	} else {
-		dev_err(dev, "cbus: Unsupported board for tahvo\n");
+		dev_err(&pdev->dev, "cbus: Unsupported board for tahvo\n");
 		return -ENODEV;
 	}
 
 	ret = gpio_request(tahvo_irq_pin, "TAHVO irq");
 	if (ret) {
-		dev_err(dev, "Unable to reserve IRQ GPIO\n");
+		dev_err(&pdev->dev, "Unable to reserve IRQ GPIO\n");
 		return ret;
 	}
 
@@ -358,14 +358,14 @@ static int __devinit tahvo_probe(struct device *dev)
 	ret = request_irq(gpio_to_irq(tahvo_irq_pin), tahvo_irq_handler, 0,
 			  "tahvo", 0);
 	if (ret < 0) {
-		dev_err(dev, "Unable to register IRQ handler\n");
+		dev_err(&pdev->dev, "Unable to register IRQ handler\n");
 		gpio_free(tahvo_irq_pin);
 		return ret;
 	}
 #ifdef CONFIG_CBUS_TAHVO_USER
 	/* Initialize user-space interface */
 	if (tahvo_user_init() < 0) {
-		dev_err(dev, "Unable to initialize driver\n");
+		dev_err(&pdev->dev, "Unable to initialize driver\n");
 		free_irq(gpio_to_irq(tahvo_irq_pin), 0);
 		gpio_free(tahvo_irq_pin);
 		return ret;
@@ -374,7 +374,7 @@ static int __devinit tahvo_probe(struct device *dev)
 	return 0;
 }
 
-static int tahvo_remove(struct device *dev)
+static int __devexit tahvo_remove(struct platform_device *pdev)
 {
 #ifdef CONFIG_CBUS_TAHVO_USER
 	tahvo_user_cleanup();
@@ -393,11 +393,12 @@ static void tahvo_device_release(struct device *dev)
 	complete(&device_release);
 }
 
-static struct device_driver tahvo_driver = {
-	.name		= "tahvo",
-	.bus		= &platform_bus_type,
+static struct platform_driver tahvo_driver = {
 	.probe		= tahvo_probe,
-	.remove		= tahvo_remove,
+	.remove		= __devexit_p(tahvo_remove),
+	.driver		= {
+		.name	= "tahvo",
+	},
 };
 
 static struct platform_device tahvo_device = {
@@ -423,13 +424,13 @@ static int __init tahvo_init(void)
 
 	init_completion(&device_release);
 
-	ret = driver_register(&tahvo_driver);
+	ret = platform_driver_register(&tahvo_driver);
 	if (ret)
 		return ret;
 
 	ret = platform_device_register(&tahvo_device);
 	if (ret) {
-		driver_unregister(&tahvo_driver);
+		platform_driver_unregister(&tahvo_driver);
 		return ret;
 	}
 	return 0;
@@ -441,7 +442,7 @@ static int __init tahvo_init(void)
 static void __exit tahvo_exit(void)
 {
 	platform_device_unregister(&tahvo_device);
-	driver_unregister(&tahvo_driver);
+	platform_driver_unregister(&tahvo_driver);
 	wait_for_completion(&device_release);
 }
 
-- 
1.7.0.rc0.33.g7c3932


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

* [RFC PATCH 25/37] cbus: retu: allocate platform_device for Retu's children
  2010-04-07 16:03 [RFC PATCH 00/37] cbus patches felipe.balbi
                   ` (23 preceding siblings ...)
  2010-04-07 16:04 ` [RFC PATCH 24/37] cbus: tahvo: convert to platform_driver felipe.balbi
@ 2010-04-07 16:04 ` felipe.balbi
  2010-04-07 16:04 ` [RFC PATCH 26/37] cbus: retu-pwrbutton: convert to platform_driver felipe.balbi
                   ` (12 subsequent siblings)
  37 siblings, 0 replies; 41+ messages in thread
From: felipe.balbi @ 2010-04-07 16:04 UTC (permalink / raw)
  To: Linux OMAP Mailing List; +Cc: Felipe Balbi

From: Felipe Balbi <felipe.balbi@nokia.com>

after this patch, Retu's children can start moving to
platform_driver infrastructure.

Signed-off-by: Felipe Balbi <felipe.balbi@nokia.com>
---
 drivers/cbus/retu.c |   74 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 74 insertions(+), 0 deletions(-)

diff --git a/drivers/cbus/retu.c b/drivers/cbus/retu.c
index ea09c17..bc81a9b 100644
--- a/drivers/cbus/retu.c
+++ b/drivers/cbus/retu.c
@@ -330,6 +330,67 @@ static void retu_power_off(void)
 }
 
 /**
+ * retu_allocate_child - Allocates one Retu child
+ * @name: name of new child
+ * @parent: parent device for this child
+ */
+static struct device *retu_allocate_child(char *name, struct device *parent)
+{
+	struct platform_device		*pdev;
+	int				status;
+
+	pdev = platform_device_alloc(name, -1);
+	if (!pdev) {
+		dev_dbg(parent, "can't allocate %s\n", name);
+		goto err;
+	}
+
+	pdev->dev.parent = parent;
+
+	status = platform_device_add(pdev);
+	if (status < 0) {
+		dev_dbg(parent, "can't add %s\n", name);
+		goto err;
+	}
+
+	return &pdev->dev;
+
+err:
+	platform_device_put(pdev);
+	return NULL;
+}
+
+/**
+ * retu_allocate_children - Allocates Retu's children
+ */
+static int retu_allocate_children(struct device *parent)
+{
+	struct device	*child;
+
+	child = retu_allocate_child("retu-pwrbutton", parent);
+	if (!child)
+		return -ENOMEM;
+
+	child = retu_allocate_child("retu-headset", parent);
+	if (!child)
+		return -ENOMEM;
+
+	child = retu_allocate_child("retu-rtc", parent);
+	if (!child)
+		return -ENOMEM;
+
+	child = retu_allocate_child("retu-user", parent);
+	if (!child)
+		return -ENOMEM;
+
+	child = retu_allocate_child("retu-wdt", parent);
+	if (!child)
+		return -ENOMEM;
+
+	return 0;
+}
+
+/**
  * retu_probe - Probe for Retu ASIC
  * @dev: the Retu device
  *
@@ -400,6 +461,19 @@ static int __devinit retu_probe(struct platform_device *pdev)
 	}
 #endif
 
+	ret = retu_allocate_children(&pdev->dev);
+	if (ret < 0) {
+		dev_err(&pdev->dev, "Unable to allocate Retu children\n");
+#ifdef CONFIG_CBUS_RETU_USER
+		retu_user_cleanup();
+#endif
+		retu_write_reg(RETU_REG_IMR, 0xffff);
+		free_irq(gpio_to_irq(retu_irq_pin), 0);
+		gpio_free(retu_irq_pin);
+		tasklet_kill(&retu_tasklet);
+		return ret;
+	}
+
 	return 0;
 }
 
-- 
1.7.0.rc0.33.g7c3932


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

* [RFC PATCH 26/37] cbus: retu-pwrbutton: convert to platform_driver
  2010-04-07 16:03 [RFC PATCH 00/37] cbus patches felipe.balbi
                   ` (24 preceding siblings ...)
  2010-04-07 16:04 ` [RFC PATCH 25/37] cbus: retu: allocate platform_device for Retu's children felipe.balbi
@ 2010-04-07 16:04 ` felipe.balbi
  2010-04-07 16:04 ` [RFC PATCH 27/37] cbus: retu-headset: simplify module_init felipe.balbi
                   ` (11 subsequent siblings)
  37 siblings, 0 replies; 41+ messages in thread
From: felipe.balbi @ 2010-04-07 16:04 UTC (permalink / raw)
  To: Linux OMAP Mailing List; +Cc: Felipe Balbi

From: Felipe Balbi <felipe.balbi@nokia.com>

now that we allocate the platform_devices in retu.c
we can convert this driver to platform_driver.

Signed-off-by: Felipe Balbi <felipe.balbi@nokia.com>
---
 drivers/cbus/retu-pwrbutton.c |  126 +++++++++++++++++++++++++++++++----------
 1 files changed, 95 insertions(+), 31 deletions(-)

diff --git a/drivers/cbus/retu-pwrbutton.c b/drivers/cbus/retu-pwrbutton.c
index 38d7aa4..2d8cf40 100644
--- a/drivers/cbus/retu-pwrbutton.c
+++ b/drivers/cbus/retu-pwrbutton.c
@@ -3,11 +3,13 @@
  *
  * Driver for sending retu power button event to input-layer
  *
- * Copyright (C) 2004 Nokia Corporation
+ * Copyright (C) 2004-2010 Nokia Corporation
  *
- * Written by Ari Saastamoinen <ari.saastamoinen@elektrobit.com>
+ * Written by
+ *	Ari Saastamoinen <ari.saastamoinen@elektrobit.com>
+ *	Juha Yrjola <juha.yrjola@solidboot.com>
  *
- * Contact Juha Yrjölä <juha.yrjola@nokia.com>
+ * Contact: Felipe Balbi <felipe.balbi@nokia.com>
  *
  * This file is subject to the terms and conditions of the GNU General
  * Public License. See the file "COPYING" in the main directory of this
@@ -31,6 +33,7 @@
 #include <linux/timer.h>
 #include <linux/jiffies.h>
 #include <linux/bitops.h>
+#include <linux/platform_device.h>
 
 #include "retu.h"
 
@@ -40,12 +43,17 @@
 #define PWRBTN_UP		0
 #define PWRBTN_PRESSED		1
 
-static int pwrbtn_state;
-static struct input_dev *pwrbtn_dev;
-static struct timer_list pwrbtn_timer;
+struct retu_pwrbutton {
+	struct input_dev	*idev;
+	struct timer_list	timer;
+
+	int			state;
+	int			irq;
+};
 
 static void retubutton_timer_func(unsigned long arg)
 {
+	struct retu_pwrbutton *pwr = (struct retu_pwrbutton *) arg;
 	int state;
 
 	if (retu_read_reg(RETU_REG_STATUS) & RETU_STATUS_PWRONX)
@@ -53,9 +61,10 @@ static void retubutton_timer_func(unsigned long arg)
 	else
 		state = PWRBTN_PRESSED;
 
-	if (pwrbtn_state != state) {
-		input_report_key(pwrbtn_dev, KEY_POWER, state);
-		pwrbtn_state = state;
+	if (pwr->state != state) {
+		input_report_key(pwr->idev, KEY_POWER, state);
+		input_sync(pwr->idev);
+		pwr->state = state;
 	}
 }
 
@@ -65,54 +74,109 @@ static void retubutton_timer_func(unsigned long arg)
  */
 static void retubutton_irq(unsigned long arg)
 {
+	struct retu_pwrbutton *pwr = (struct retu_pwrbutton *) arg;
+
 	retu_ack_irq(RETU_INT_PWR);
-	mod_timer(&pwrbtn_timer, jiffies + msecs_to_jiffies(PWRBTN_DELAY));
+	mod_timer(&pwr->timer, jiffies + msecs_to_jiffies(PWRBTN_DELAY));
 }
 
 /**
  * Init function.
  * Allocates interrupt for power button and registers itself to input layer.
  */
-static int __init retubutton_init(void)
+static int __devinit retubutton_probe(struct platform_device *pdev)
 {
-	int irq;
+	struct retu_pwrbutton		*pwr;
+	int				ret = 0;
+
+	pwr = kzalloc(sizeof(*pwr), GFP_KERNEL);
+	if (!pwr) {
+		dev_err(&pdev->dev, "not enough memory\n");
+		ret = -ENOMEM;
+		goto err0;
+	}
 
-	printk(KERN_INFO "Retu power button driver initialized\n");
-	irq = RETU_INT_PWR;
+	pwr->irq = RETU_INT_PWR;
+	platform_set_drvdata(pdev, pwr);
+	setup_timer(&pwr->timer, retubutton_timer_func, (unsigned long) pwr);
 
-	init_timer(&pwrbtn_timer);
-	pwrbtn_timer.function = retubutton_timer_func;
+	ret = retu_request_irq(pwr->irq, retubutton_irq, (unsigned long) pwr,
+			"PwrOnX");
+	if (ret < 0) {
+		dev_err(&pdev->dev, "Cannot allocate irq\n");
+		goto err1;
+	}
 
-	if (retu_request_irq(irq, &retubutton_irq, 0, "PwrOnX") < 0) {
-		printk(KERN_ERR "%s@%s: Cannot allocate irq\n",
-		       __FUNCTION__, __FILE__);
-		return -EBUSY;
+	pwr->idev = input_allocate_device();
+	if (!pwr->idev) {
+		dev_err(&pdev->dev, "can't allocate input device\n");
+		ret = -ENOMEM;
+		goto err2;
 	}
 
-	pwrbtn_dev = input_allocate_device();
-	if (!pwrbtn_dev)
-		return -ENOMEM;
+	pwr->idev->evbit[0] = BIT_MASK(EV_KEY);
+	pwr->idev->keybit[BIT_WORD(KEY_POWER)] = BIT_MASK(KEY_POWER);
+	pwr->idev->name = "retu-pwrbutton";
 
-	pwrbtn_dev->evbit[0] = BIT_MASK(EV_KEY);
-	pwrbtn_dev->keybit[BIT_WORD(KEY_POWER)] = BIT_MASK(KEY_POWER);
-	pwrbtn_dev->name = "retu-pwrbutton";
+	ret = input_register_device(pwr->idev);
+	if (ret < 0) {
+		dev_err(&pdev->dev, "failed to register input device\n");
+		goto err3;
+	}
 
-	return input_register_device(pwrbtn_dev);
+	return 0;
+
+err3:
+	input_free_device(pwr->idev);
+
+err2:
+	retu_free_irq(pwr->irq);
+
+err1:
+	kfree(pwr);
+
+err0:
+	return ret;
 }
 
 /**
  * Cleanup function which is called when driver is unloaded
  */
-static void __exit retubutton_exit(void)
+static int __devexit retubutton_remove(struct platform_device *pdev)
 {
-	retu_free_irq(RETU_INT_PWR);
-	del_timer_sync(&pwrbtn_timer);
-	input_unregister_device(pwrbtn_dev);
+	struct retu_pwrbutton		*pwr = platform_get_drvdata(pdev);
+
+	retu_free_irq(pwr->irq);
+	del_timer_sync(&pwr->timer);
+	input_unregister_device(pwr->idev);
+	input_free_device(pwr->idev);
+	kfree(pwr);
+
+	return 0;
 }
 
+static struct platform_driver retu_pwrbutton_driver = {
+	.probe		= retubutton_probe,
+	.remove		= __devexit_p(retubutton_remove),
+	.driver		= {
+		.name	= "retu-pwrbutton",
+	},
+};
+
+static int __init retubutton_init(void)
+{
+	return platform_driver_register(&retu_pwrbutton_driver);
+}
 module_init(retubutton_init);
+
+static void __exit retubutton_exit(void)
+{
+	platform_driver_unregister(&retu_pwrbutton_driver);
+}
 module_exit(retubutton_exit);
 
 MODULE_DESCRIPTION("Retu Power Button");
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Ari Saastamoinen");
+MODULE_AUTHOR("Felipe Balbi <felipe.balbi@nokia.com>");
+
-- 
1.7.0.rc0.33.g7c3932

--
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] 41+ messages in thread

* [RFC PATCH 27/37] cbus: retu-headset: simplify module_init
  2010-04-07 16:03 [RFC PATCH 00/37] cbus patches felipe.balbi
                   ` (25 preceding siblings ...)
  2010-04-07 16:04 ` [RFC PATCH 26/37] cbus: retu-pwrbutton: convert to platform_driver felipe.balbi
@ 2010-04-07 16:04 ` felipe.balbi
  2010-04-07 16:04 ` [RFC PATCH 28/37] cbus: retu-rtc: remove platform_device code felipe.balbi
                   ` (10 subsequent siblings)
  37 siblings, 0 replies; 41+ messages in thread
From: felipe.balbi @ 2010-04-07 16:04 UTC (permalink / raw)
  To: Linux OMAP Mailing List; +Cc: Felipe Balbi

From: Felipe Balbi <felipe.balbi@nokia.com>

it's enough to have it as:

return platform_driver_register();

in case of failure, platform code should print
any necessary info.

Signed-off-by: Felipe Balbi <felipe.balbi@nokia.com>
---
 drivers/cbus/retu-headset.c |   10 +---------
 1 files changed, 1 insertions(+), 9 deletions(-)

diff --git a/drivers/cbus/retu-headset.c b/drivers/cbus/retu-headset.c
index e798bc2..1def743 100644
--- a/drivers/cbus/retu-headset.c
+++ b/drivers/cbus/retu-headset.c
@@ -331,15 +331,7 @@ static struct platform_driver retu_headset_driver = {
 
 static int __init retu_headset_init(void)
 {
-	int r;
-
-	printk(KERN_INFO "Retu/Vilma headset driver initializing\n");
-
-	r = platform_driver_register(&retu_headset_driver);
-	if (r < 0)
-		return r;
-
-	return 0;
+	return platform_driver_register(&retu_headset_driver);
 }
 
 static void __exit retu_headset_exit(void)
-- 
1.7.0.rc0.33.g7c3932


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

* [RFC PATCH 28/37] cbus: retu-rtc: remove platform_device code
  2010-04-07 16:03 [RFC PATCH 00/37] cbus patches felipe.balbi
                   ` (26 preceding siblings ...)
  2010-04-07 16:04 ` [RFC PATCH 27/37] cbus: retu-headset: simplify module_init felipe.balbi
@ 2010-04-07 16:04 ` felipe.balbi
  2010-04-07 16:04 ` [RFC PATCH 29/37] cbus: retu-rtc: convert to platform_driver felipe.balbi
                   ` (9 subsequent siblings)
  37 siblings, 0 replies; 41+ messages in thread
From: felipe.balbi @ 2010-04-07 16:04 UTC (permalink / raw)
  To: Linux OMAP Mailing List; +Cc: Felipe Balbi

From: Felipe Balbi <felipe.balbi@nokia.com>

that comes from retu.c now.

Signed-off-by: Felipe Balbi <felipe.balbi@nokia.com>
---
 drivers/cbus/retu-rtc.c |   33 +--------------------------------
 1 files changed, 1 insertions(+), 32 deletions(-)

diff --git a/drivers/cbus/retu-rtc.c b/drivers/cbus/retu-rtc.c
index f34780b..40a42f1 100644
--- a/drivers/cbus/retu-rtc.c
+++ b/drivers/cbus/retu-rtc.c
@@ -49,16 +49,10 @@ static struct mutex retu_rtc_mutex;
 static u16 retu_rtc_alarm_expired;
 static u16 retu_rtc_reset_occurred;
 
-static DECLARE_COMPLETION(retu_rtc_exited);
 static DECLARE_COMPLETION(retu_rtc_sync);
 
 static void retu_rtc_barrier(void);
 
-static void retu_rtc_device_release(struct device *dev)
-{
-	complete(&retu_rtc_exited);
-}
-
 static ssize_t retu_rtc_time_show(struct device *dev, struct device_attribute *attr,
 				  char *buf)
 {
@@ -428,14 +422,6 @@ static struct device_driver retu_rtc_driver = {
 	.remove		= __devexit_p(retu_rtc_remove),
 };
 
-static struct platform_device retu_rtc_device = {
-	.name		= "retu-rtc",
-	.id		= -1,
-	.dev		= {
-		.release	= retu_rtc_device_release,
-	},
-};
-
 /* This function provides syncronization with the RTCS interrupt handler */
 static void retu_rtc_barrier(void)
 {
@@ -448,29 +434,12 @@ static void retu_rtc_barrier(void)
 
 static int __init retu_rtc_init(void)
 {
-	int ret;
-
-	init_completion(&retu_rtc_exited);
-
-	if ((ret = driver_register(&retu_rtc_driver)) != 0)
-		return ret;
-
-	if ((ret = platform_device_register(&retu_rtc_device)) != 0)
-		goto err_unregister_driver;
-
-	return 0;
-
-err_unregister_driver:
-	driver_unregister(&retu_rtc_driver);
-	return ret;
+	return driver_register(&retu_rtc_driver);
 }
 
 static void __exit retu_rtc_exit(void)
 {
-	platform_device_unregister(&retu_rtc_device);
 	driver_unregister(&retu_rtc_driver);
-
-	wait_for_completion(&retu_rtc_exited);
 }
 
 module_init(retu_rtc_init);
-- 
1.7.0.rc0.33.g7c3932


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

* [RFC PATCH 29/37] cbus: retu-rtc: convert to platform_driver
  2010-04-07 16:03 [RFC PATCH 00/37] cbus patches felipe.balbi
                   ` (27 preceding siblings ...)
  2010-04-07 16:04 ` [RFC PATCH 28/37] cbus: retu-rtc: remove platform_device code felipe.balbi
@ 2010-04-07 16:04 ` felipe.balbi
  2010-04-07 16:04 ` [RFC PATCH 30/37] cbus: retu-rtc: split MODULE_AUTHOR into several entries felipe.balbi
                   ` (8 subsequent siblings)
  37 siblings, 0 replies; 41+ messages in thread
From: felipe.balbi @ 2010-04-07 16:04 UTC (permalink / raw)
  To: Linux OMAP Mailing List; +Cc: Felipe Balbi

From: Felipe Balbi <felipe.balbi@nokia.com>

still needs work, but it's now using platform_driver
structure.

Signed-off-by: Felipe Balbi <felipe.balbi@nokia.com>
---
 drivers/cbus/retu-rtc.c |   19 ++++++++++++-------
 1 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/drivers/cbus/retu-rtc.c b/drivers/cbus/retu-rtc.c
index 40a42f1..2947c80 100644
--- a/drivers/cbus/retu-rtc.c
+++ b/drivers/cbus/retu-rtc.c
@@ -355,8 +355,9 @@ static int retu_rtc_init_irq(void)
 }
 
 
-static int __devinit retu_rtc_probe(struct device *dev)
+static int __devinit retu_rtc_probe(struct platform_device *pdev)
 {
+	struct device		*dev = &pdev->dev;
 	int r;
 
 	r = retu_get_status();
@@ -402,8 +403,10 @@ err_unregister_time:
 	return r;
 }
 
-static int __devexit retu_rtc_remove(struct device *dev)
+static int __devexit retu_rtc_remove(struct platform_device *pdev)
 {
+	struct device		*dev = &pdev->dev;
+
 	retu_disable_irq(RETU_INT_RTCS);
 	retu_free_irq(RETU_INT_RTCS);
 	retu_free_irq(RETU_INT_RTCA);
@@ -412,14 +415,16 @@ static int __devexit retu_rtc_remove(struct device *dev)
 	device_remove_file(dev, &dev_attr_alarm);
 	device_remove_file(dev, &dev_attr_reset);
 	device_remove_file(dev, &dev_attr_time);
+
 	return 0;
 }
 
-static struct device_driver retu_rtc_driver = {
-	.name		= "retu-rtc",
-	.bus		= &platform_bus_type,
+static struct platform_driver retu_rtc_driver = {
 	.probe		= retu_rtc_probe,
 	.remove		= __devexit_p(retu_rtc_remove),
+	.driver		= {
+		.name	= "retu-rtc",
+	},
 };
 
 /* This function provides syncronization with the RTCS interrupt handler */
@@ -434,12 +439,12 @@ static void retu_rtc_barrier(void)
 
 static int __init retu_rtc_init(void)
 {
-	return driver_register(&retu_rtc_driver);
+	return platform_driver_register(&retu_rtc_driver);
 }
 
 static void __exit retu_rtc_exit(void)
 {
-	driver_unregister(&retu_rtc_driver);
+	platform_driver_unregister(&retu_rtc_driver);
 }
 
 module_init(retu_rtc_init);
-- 
1.7.0.rc0.33.g7c3932


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

* [RFC PATCH 30/37] cbus: retu-rtc: split MODULE_AUTHOR into several entries
  2010-04-07 16:03 [RFC PATCH 00/37] cbus patches felipe.balbi
                   ` (28 preceding siblings ...)
  2010-04-07 16:04 ` [RFC PATCH 29/37] cbus: retu-rtc: convert to platform_driver felipe.balbi
@ 2010-04-07 16:04 ` felipe.balbi
  2010-04-07 16:04 ` [RFC PATCH 31/37] cbus: retu-rtc: get rid of globals felipe.balbi
                   ` (7 subsequent siblings)
  37 siblings, 0 replies; 41+ messages in thread
From: felipe.balbi @ 2010-04-07 16:04 UTC (permalink / raw)
  To: Linux OMAP Mailing List; +Cc: Felipe Balbi

From: Felipe Balbi <felipe.balbi@nokia.com>

it's easier to read, no functional changes.

Signed-off-by: Felipe Balbi <felipe.balbi@nokia.com>
---
 drivers/cbus/retu-rtc.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/drivers/cbus/retu-rtc.c b/drivers/cbus/retu-rtc.c
index 2947c80..2a1623b 100644
--- a/drivers/cbus/retu-rtc.c
+++ b/drivers/cbus/retu-rtc.c
@@ -452,4 +452,6 @@ module_exit(retu_rtc_exit);
 
 MODULE_DESCRIPTION("Retu RTC");
 MODULE_LICENSE("GPL");
-MODULE_AUTHOR("Paul Mundt and Igor Stoppa");
+MODULE_AUTHOR("Paul Mundt");
+MODULE_AUTHOR("Igor Stoppa");
+
-- 
1.7.0.rc0.33.g7c3932


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

* [RFC PATCH 31/37] cbus: retu-rtc: get rid of globals
  2010-04-07 16:03 [RFC PATCH 00/37] cbus patches felipe.balbi
                   ` (29 preceding siblings ...)
  2010-04-07 16:04 ` [RFC PATCH 30/37] cbus: retu-rtc: split MODULE_AUTHOR into several entries felipe.balbi
@ 2010-04-07 16:04 ` felipe.balbi
  2010-04-07 16:04 ` [RFC PATCH 32/37] cbus: retu-rtc: move retu_rtc_barrier up on source code felipe.balbi
                   ` (6 subsequent siblings)
  37 siblings, 0 replies; 41+ messages in thread
From: felipe.balbi @ 2010-04-07 16:04 UTC (permalink / raw)
  To: Linux OMAP Mailing List; +Cc: Felipe Balbi

From: Felipe Balbi <felipe.balbi@nokia.com>

allocate everything we need on demand and get rid
of global variables.

Signed-off-by: Felipe Balbi <felipe.balbi@nokia.com>
---
 drivers/cbus/retu-rtc.c |  251 ++++++++++++++++++++++++++++-------------------
 1 files changed, 150 insertions(+), 101 deletions(-)

diff --git a/drivers/cbus/retu-rtc.c b/drivers/cbus/retu-rtc.c
index 2a1623b..b99c227 100644
--- a/drivers/cbus/retu-rtc.c
+++ b/drivers/cbus/retu-rtc.c
@@ -45,20 +45,27 @@
 #include "cbus.h"
 #include "retu.h"
 
-static struct mutex retu_rtc_mutex;
-static u16 retu_rtc_alarm_expired;
-static u16 retu_rtc_reset_occurred;
+struct retu_rtc {
+	struct mutex		mutex;
+	struct completion	sync;
+	struct work_struct	work;
+	struct device		*dev;
+
+	u16			alarm_expired;
+	u16			reset_occurred;
+};
 
-static DECLARE_COMPLETION(retu_rtc_sync);
+#define work_to_rtc(r)	(container_of(r, struct retu_rtc, work))
 
-static void retu_rtc_barrier(void);
+static void retu_rtc_barrier(struct retu_rtc *rtc);
 
 static ssize_t retu_rtc_time_show(struct device *dev, struct device_attribute *attr,
 				  char *buf)
 {
-	u16 dsr, hmr, dsr2;
+	struct retu_rtc		*rtc = dev_get_drvdata(dev);
+	u16			dsr, hmr, dsr2;
 
-	mutex_lock(&retu_rtc_mutex);
+	mutex_lock(&rtc->mutex);
 
 	do {
 		u16 dummy;
@@ -77,7 +84,7 @@ static ssize_t retu_rtc_time_show(struct device *dev, struct device_attribute *a
 		dsr2	= retu_read_reg(RETU_REG_RTCDSR);
 	} while ((dsr != dsr2));
 
-	mutex_unlock(&retu_rtc_mutex);
+	mutex_unlock(&rtc->mutex);
 
 	/*
 	 * Format a 32-bit date-string for userspace
@@ -99,7 +106,9 @@ static ssize_t retu_rtc_time_show(struct device *dev, struct device_attribute *a
 static ssize_t retu_rtc_time_store(struct device *dev, struct device_attribute *attr,
 				   const char *buf, size_t count)
 {
-	mutex_lock(&retu_rtc_mutex);
+	struct retu_rtc		*rtc = dev_get_drvdata(dev);
+
+	mutex_lock(&rtc->mutex);
 	/*
 	 * Writing anything to the day counter forces it to 0
 	 * The seconds counter would be cleared by resetting the minutes counter,
@@ -112,7 +121,7 @@ static ssize_t retu_rtc_time_store(struct device *dev, struct device_attribute *
 	retu_write_reg(RETU_REG_RTCDSR,
 		       retu_read_reg(RETU_REG_RTCDSR) & (1 << 6));
 
-	mutex_unlock(&retu_rtc_mutex);
+	mutex_unlock(&rtc->mutex);
 
 	return count;
 }
@@ -123,6 +132,8 @@ static DEVICE_ATTR(time, S_IRUGO | S_IWUSR, retu_rtc_time_show,
 
 static ssize_t retu_rtc_reset_show(struct device *dev, struct device_attribute *attr, char *buf)
 {
+	struct retu_rtc		*rtc = dev_get_drvdata(dev);
+
 	/*
 	 * Returns the status of the rtc
 	 *
@@ -132,10 +143,10 @@ static ssize_t retu_rtc_reset_show(struct device *dev, struct device_attribute *
 	 * RTC needs to be reset only when both main battery
 	 * _AND_ backup battery are discharged
 	 */
-	return sprintf(buf, "%u\n", retu_rtc_reset_occurred);
+	return sprintf(buf, "%u\n", rtc->reset_occurred);
 }
 
-static void retu_rtc_do_reset(void)
+static void retu_rtc_do_reset(struct retu_rtc *rtc)
 {
 	u16 ccr1;
 
@@ -145,29 +156,30 @@ static void retu_rtc_do_reset(void)
 	/* RTC in normal operating mode */
 	retu_write_reg(RETU_REG_CC1, ccr1 & ~0x0001);
 
-	retu_rtc_barrier();
+	retu_rtc_barrier(rtc);
 	/* Disable alarm and RTC WD */
 	retu_write_reg(RETU_REG_RTCHMAR, 0x7f3f);
 	/* Set Calibration register to default value */
 	retu_write_reg(RETU_REG_RTCCALR, 0x00c0);
 
-	retu_rtc_alarm_expired = 0;
-	retu_rtc_reset_occurred = 1;
+	rtc->alarm_expired = 0;
+	rtc->reset_occurred = 1;
 }
 
 static ssize_t retu_rtc_reset_store(struct device *dev, struct device_attribute *attr,
 				    const char *buf, size_t count)
 {
-	unsigned choice;
+	struct retu_rtc		*rtc = dev_get_drvdata(dev);
+	unsigned		choice;
 
 	if(sscanf(buf, "%u", &choice) != 1)
 		return count;
-	mutex_lock(&retu_rtc_mutex);
+	mutex_lock(&rtc->mutex);
 	if (choice == 0)
-		retu_rtc_reset_occurred = 0;
+		rtc->reset_occurred = 0;
 	else if (choice == 1)
-		retu_rtc_do_reset();
-	mutex_unlock(&retu_rtc_mutex);
+		retu_rtc_do_reset(rtc);
+	mutex_unlock(&rtc->mutex);
 	return count;
 }
 
@@ -177,10 +189,11 @@ static DEVICE_ATTR(reset, S_IRUGO | S_IWUSR, retu_rtc_reset_show,
 static ssize_t retu_rtc_alarm_show(struct device *dev, struct device_attribute *attr,
 				   char *buf)
 {
-	u16 chmar;
-	ssize_t retval;
+	struct retu_rtc		*rtc = dev_get_drvdata(dev);
+	ssize_t			retval;
+	u16			chmar;
 
-	mutex_lock(&retu_rtc_mutex);
+	mutex_lock(&rtc->mutex);
 	/*
 	 * Format a 16-bit date-string for userspace
 	 *
@@ -190,7 +203,7 @@ static ssize_t retu_rtc_alarm_show(struct device *dev, struct device_attribute *
 	chmar = retu_read_reg(RETU_REG_RTCHMAR);
 	/* No shifting needed, only masking unrelated bits */
 	retval = sprintf(buf, "0x%04x\n", chmar & 0x1f3f);
-	mutex_unlock(&retu_rtc_mutex);
+	mutex_unlock(&rtc->mutex);
 
 	return retval;
 }
@@ -198,12 +211,15 @@ static ssize_t retu_rtc_alarm_show(struct device *dev, struct device_attribute *
 static ssize_t retu_rtc_alarm_store(struct device *dev, struct device_attribute *attr,
 				    const char *buf, size_t count)
 {
-	u16 chmar;
-	unsigned alrm;
-	unsigned hours;
-	unsigned minutes;
+	struct retu_rtc		*rtc = dev_get_drvdata(dev);
+
+	unsigned		minutes;
+	unsigned		hours;
+	unsigned		alrm;
 
-	mutex_lock(&retu_rtc_mutex);
+	u16			chmar;
+
+	mutex_lock(&rtc->mutex);
 
 	if(sscanf(buf, "%x", &alrm) != 1)
 		return count;
@@ -217,18 +233,18 @@ static ssize_t retu_rtc_alarm_store(struct device *dev, struct device_attribute
 		/* Keeps the RTC watchdog status */
 		chmar = retu_read_reg(RETU_REG_RTCHMAR) & 0x6000;
 		chmar |= alrm & 0x1f3f;	/* Stores the requested alarm */
-		retu_rtc_barrier();
+		retu_rtc_barrier(rtc);
 		retu_write_reg(RETU_REG_RTCHMAR, chmar);
 		/* If the alarm is being disabled */
 		if (hours == 24 && minutes == 60) {
 			/* disable the interrupt */
 			retu_disable_irq(RETU_INT_RTCA);
-			retu_rtc_alarm_expired = 0;
+			rtc->alarm_expired = 0;
 		} else
 			/* enable the interrupt */
 			retu_enable_irq(RETU_INT_RTCA);
 	}
-	mutex_unlock(&retu_rtc_mutex);
+	mutex_unlock(&rtc->mutex);
 
 	return count;
 }
@@ -239,9 +255,10 @@ static DEVICE_ATTR(alarm, S_IRUGO | S_IWUSR, retu_rtc_alarm_show,
 static ssize_t retu_rtc_alarm_expired_show(struct device *dev, struct device_attribute *attr,
 					   char *buf)
 {
-	ssize_t retval;
+	struct retu_rtc		*rtc = dev_get_drvdata(dev);
+	ssize_t			retval;
 
-	retval = sprintf(buf, "%u\n", retu_rtc_alarm_expired);
+	retval = sprintf(buf, "%u\n", rtc->alarm_expired);
 
 	return retval;
 }
@@ -249,7 +266,9 @@ static ssize_t retu_rtc_alarm_expired_show(struct device *dev, struct device_att
 static ssize_t retu_rtc_alarm_expired_store(struct device *dev, struct device_attribute *attr,
 					    const char *buf, size_t count)
 {
-	retu_rtc_alarm_expired = 0;
+	struct retu_rtc		*rtc = dev_get_drvdata(dev);
+
+	rtc->alarm_expired = 0;
 
 	return count;
 }
@@ -261,11 +280,12 @@ static DEVICE_ATTR(alarm_expired, S_IRUGO | S_IWUSR, retu_rtc_alarm_expired_show
 static ssize_t retu_rtc_cal_show(struct device *dev, struct device_attribute *attr,
 				 char *buf)
 {
-	u16 rtccalr1;
+	struct retu_rtc		*rtc = dev_get_drvdata(dev);
+	u16			rtccalr1;
 
-	mutex_lock(&retu_rtc_mutex);
+	mutex_lock(&rtc->mutex);
 	rtccalr1 = retu_read_reg(RETU_REG_RTCCALR);
-	mutex_unlock(&retu_rtc_mutex);
+	mutex_unlock(&rtc->mutex);
 
 	/*
 	 * Shows the status of the Calibration Register.
@@ -281,15 +301,16 @@ static ssize_t retu_rtc_cal_show(struct device *dev, struct device_attribute *at
 static ssize_t retu_rtc_cal_store(struct device *dev, struct device_attribute *attr,
 				  const char *buf, size_t count)
 {
-	unsigned calibration_value;
+	struct retu_rtc		*rtc = dev_get_drvdata(dev);
+	unsigned		calibration_value;
 
 	if (sscanf(buf, "%x", &calibration_value) != 1)
 		return count;
 
-	mutex_lock(&retu_rtc_mutex);
-	retu_rtc_barrier();
+	mutex_lock(&rtc->mutex);
+	retu_rtc_barrier(rtc);
 	retu_write_reg(RETU_REG_RTCCALR, calibration_value & 0x00ff);
-	mutex_unlock(&retu_rtc_mutex);
+	mutex_unlock(&rtc->mutex);
 
 	return count;
 }
@@ -297,45 +318,62 @@ static ssize_t retu_rtc_cal_store(struct device *dev, struct device_attribute *a
 static DEVICE_ATTR(cal, S_IRUGO | S_IWUSR, retu_rtc_cal_show,
 		   retu_rtc_cal_store);
 
-static struct platform_device retu_rtc_device;
+static struct attribute *retu_rtc_attrs[] = {
+	&dev_attr_cal.attr,
+	&dev_attr_alarm_expired.attr,
+	&dev_attr_alarm.attr,
+	&dev_attr_reset.attr,
+	&dev_attr_time.attr,
+	NULL,
+};
+
+static const struct attribute_group retu_rtc_group = {
+	.attrs = retu_rtc_attrs,
+};
 
-static void retu_rtca_disable(void)
+static void retu_rtca_disable(struct retu_rtc *rtc)
 {
 	retu_disable_irq(RETU_INT_RTCA);
-	retu_rtc_alarm_expired = 1;
-	retu_rtc_barrier();
+	rtc->alarm_expired = 1;
+	retu_rtc_barrier(rtc);
 	retu_write_reg(RETU_REG_RTCHMAR, (24 << 8) | 60);
 }
 
-static void retu_rtca_expired(struct work_struct *unused)
+static void retu_rtca_expired(struct work_struct *work)
 {
-	retu_rtca_disable();
-	sysfs_notify(&retu_rtc_device.dev.kobj, NULL, "alarm_expired");
-}
+	struct retu_rtc		*rtc = work_to_rtc(work);
 
-DECLARE_WORK(retu_rtca_work, retu_rtca_expired);
+	retu_rtca_disable(rtc);
+
+	sysfs_notify(&rtc->dev->kobj, NULL, "alarm_expired");
+}
 
 /*
  * RTCHMR RTCHMAR RTCCAL must be accessed within 0.9 s since the seconds
  * interrupt has been signaled in the IDR register
  */
-static void retu_rtcs_interrupt(unsigned long unused)
+static void retu_rtcs_interrupt(unsigned long _rtc)
 {
+	struct retu_rtc		*rtc = (struct retu_rtc *) _rtc;
+
 	retu_ack_irq(RETU_INT_RTCS);
-	complete_all(&retu_rtc_sync);
+	complete_all(&rtc->sync);
 }
 
-static void retu_rtca_interrupt(unsigned long unused)
+static void retu_rtca_interrupt(unsigned long _rtc)
 {
+	struct retu_rtc		*rtc = (struct retu_rtc *) _rtc;
+
 	retu_ack_irq(RETU_INT_RTCA);
-	schedule_work(&retu_rtca_work);
+	schedule_work(&rtc->work);
 }
 
-static int retu_rtc_init_irq(void)
+static int retu_rtc_init_irq(struct retu_rtc *rtc)
 {
 	int ret;
 
-	ret = retu_request_irq(RETU_INT_RTCS, retu_rtcs_interrupt, 0, "RTCS");
+	ret = retu_request_irq(RETU_INT_RTCS, retu_rtcs_interrupt,
+			(unsigned long) rtc, "RTCS");
 	if (ret != 0)
 		return ret;
 	/*
@@ -344,7 +382,8 @@ static int retu_rtc_init_irq(void)
 	 */
 	retu_disable_irq(RETU_INT_RTCS);
 
-	ret = retu_request_irq(RETU_INT_RTCA, retu_rtca_interrupt, 0, "RTCA");
+	ret = retu_request_irq(RETU_INT_RTCA, retu_rtca_interrupt,
+			(unsigned long) rtc, "RTCA");
 	if (ret != 0) {
 		retu_free_irq(RETU_INT_RTCS);
 		return ret;
@@ -357,64 +396,74 @@ static int retu_rtc_init_irq(void)
 
 static int __devinit retu_rtc_probe(struct platform_device *pdev)
 {
-	struct device		*dev = &pdev->dev;
-	int r;
+	struct retu_rtc		*rtc;
+	int			r;
+
+	rtc = kzalloc(sizeof(*rtc), GFP_KERNEL);
+	if (!rtc) {
+		dev_err(&pdev->dev, "not enough memory\n");
+		r = -ENOMEM;
+		goto err0;
+	}
 
-	r = retu_get_status();
-	if (!r)
-		return -ENODEV;
+	rtc->dev = &pdev->dev;
+	platform_set_drvdata(pdev, rtc);
+	INIT_WORK(&rtc->work, retu_rtca_expired);
+	mutex_init(&rtc->mutex);
 
-	retu_rtc_alarm_expired = retu_read_reg(RETU_REG_IDR) &
-					       (0x1 << RETU_INT_RTCA);
+	r = retu_get_status();
+	if (!r) {
+		dev_err(&pdev->dev, "retu not initialized\n");
+		goto err1;
+	}
 
-	if ((r = retu_rtc_init_irq()) != 0)
-		return r;
+	rtc->alarm_expired = retu_read_reg(RETU_REG_IDR) &
+		(0x1 << RETU_INT_RTCA);
 
-	mutex_init(&retu_rtc_mutex);
+	r = retu_rtc_init_irq(rtc);
+	if (r < 0) {
+		dev_err(&pdev->dev, "failed to request retu irq\n");
+		goto err1;
+	}
 
 	/* If the calibration register is zero, we've probably lost
 	 * power */
 	if (retu_read_reg(RETU_REG_RTCCALR) & 0x00ff)
-		retu_rtc_reset_occurred = 0;
-	else
-		retu_rtc_do_reset();
-
-	if ((r = device_create_file(dev, &dev_attr_time)) != 0)
-		return r;
-	else if ((r = device_create_file(dev, &dev_attr_reset)) != 0)
-		goto err_unregister_time;
-	else if ((r = device_create_file(dev, &dev_attr_alarm)) != 0)
-		goto err_unregister_reset;
-	else if ((r = device_create_file(dev, &dev_attr_alarm_expired)) != 0)
-		goto err_unregister_alarm;
-	else if ((r = device_create_file(dev, &dev_attr_cal)) != 0)
-		goto err_unregister_alarm_expired;
+		rtc->reset_occurred = 0;
 	else
-		return r;
-
-err_unregister_alarm_expired:
-	device_remove_file(dev, &dev_attr_alarm_expired);
-err_unregister_alarm:
-	device_remove_file(dev, &dev_attr_alarm);
-err_unregister_reset:
-	device_remove_file(dev, &dev_attr_reset);
-err_unregister_time:
-	device_remove_file(dev, &dev_attr_time);
+		retu_rtc_do_reset(rtc);
+
+	r = sysfs_create_group(&pdev->dev.kobj, &retu_rtc_group);
+	if (r) {
+		dev_err(&pdev->dev, "couldn't create sysfs interface\n");
+		goto err2;
+	}
+
+	return 0;
+
+err2:
+	retu_disable_irq(RETU_INT_RTCS);
+	retu_disable_irq(RETU_INT_RTCA);
+	retu_free_irq(RETU_INT_RTCS);
+	retu_free_irq(RETU_INT_RTCA);
+
+err1:
+	kfree(rtc);
+
+err0:
 	return r;
 }
 
 static int __devexit retu_rtc_remove(struct platform_device *pdev)
 {
-	struct device		*dev = &pdev->dev;
+	struct retu_rtc		*rtc = platform_get_drvdata(pdev);
 
 	retu_disable_irq(RETU_INT_RTCS);
+	retu_disable_irq(RETU_INT_RTCA);
 	retu_free_irq(RETU_INT_RTCS);
 	retu_free_irq(RETU_INT_RTCA);
-	device_remove_file(dev, &dev_attr_cal);
-	device_remove_file(dev, &dev_attr_alarm_expired);
-	device_remove_file(dev, &dev_attr_alarm);
-	device_remove_file(dev, &dev_attr_reset);
-	device_remove_file(dev, &dev_attr_time);
+	sysfs_remove_group(&pdev->dev.kobj, &retu_rtc_group);
+	kfree(rtc);
 
 	return 0;
 }
@@ -428,12 +477,12 @@ static struct platform_driver retu_rtc_driver = {
 };
 
 /* This function provides syncronization with the RTCS interrupt handler */
-static void retu_rtc_barrier(void)
+static void retu_rtc_barrier(struct retu_rtc *rtc)
 {
-	INIT_COMPLETION(retu_rtc_sync);
+	INIT_COMPLETION(rtc->sync);
 	retu_ack_irq(RETU_INT_RTCS);
 	retu_enable_irq(RETU_INT_RTCS);
-	wait_for_completion(&retu_rtc_sync);
+	wait_for_completion(&rtc->sync);
 	retu_disable_irq(RETU_INT_RTCS);
 }
 
-- 
1.7.0.rc0.33.g7c3932


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

* [RFC PATCH 32/37] cbus: retu-rtc: move retu_rtc_barrier up on source code
  2010-04-07 16:03 [RFC PATCH 00/37] cbus patches felipe.balbi
                   ` (30 preceding siblings ...)
  2010-04-07 16:04 ` [RFC PATCH 31/37] cbus: retu-rtc: get rid of globals felipe.balbi
@ 2010-04-07 16:04 ` felipe.balbi
  2010-04-07 16:04 ` [RFC PATCH 33/37] cbus: retu-rtc: make checkpatch.pl happy felipe.balbi
                   ` (5 subsequent siblings)
  37 siblings, 0 replies; 41+ messages in thread
From: felipe.balbi @ 2010-04-07 16:04 UTC (permalink / raw)
  To: Linux OMAP Mailing List; +Cc: Felipe Balbi

From: Felipe Balbi <felipe.balbi@nokia.com>

... and drop the function prototype.

Signed-off-by: Felipe Balbi <felipe.balbi@nokia.com>
---
 drivers/cbus/retu-rtc.c |   20 +++++++++-----------
 1 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/drivers/cbus/retu-rtc.c b/drivers/cbus/retu-rtc.c
index b99c227..90d199e 100644
--- a/drivers/cbus/retu-rtc.c
+++ b/drivers/cbus/retu-rtc.c
@@ -57,7 +57,15 @@ struct retu_rtc {
 
 #define work_to_rtc(r)	(container_of(r, struct retu_rtc, work))
 
-static void retu_rtc_barrier(struct retu_rtc *rtc);
+/* This function provides syncronization with the RTCS interrupt handler */
+static void retu_rtc_barrier(struct retu_rtc *rtc)
+{
+	INIT_COMPLETION(rtc->sync);
+	retu_ack_irq(RETU_INT_RTCS);
+	retu_enable_irq(RETU_INT_RTCS);
+	wait_for_completion(&rtc->sync);
+	retu_disable_irq(RETU_INT_RTCS);
+}
 
 static ssize_t retu_rtc_time_show(struct device *dev, struct device_attribute *attr,
 				  char *buf)
@@ -476,16 +484,6 @@ static struct platform_driver retu_rtc_driver = {
 	},
 };
 
-/* This function provides syncronization with the RTCS interrupt handler */
-static void retu_rtc_barrier(struct retu_rtc *rtc)
-{
-	INIT_COMPLETION(rtc->sync);
-	retu_ack_irq(RETU_INT_RTCS);
-	retu_enable_irq(RETU_INT_RTCS);
-	wait_for_completion(&rtc->sync);
-	retu_disable_irq(RETU_INT_RTCS);
-}
-
 static int __init retu_rtc_init(void)
 {
 	return platform_driver_register(&retu_rtc_driver);
-- 
1.7.0.rc0.33.g7c3932


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

* [RFC PATCH 33/37] cbus: retu-rtc: make checkpatch.pl happy
  2010-04-07 16:03 [RFC PATCH 00/37] cbus patches felipe.balbi
                   ` (31 preceding siblings ...)
  2010-04-07 16:04 ` [RFC PATCH 32/37] cbus: retu-rtc: move retu_rtc_barrier up on source code felipe.balbi
@ 2010-04-07 16:04 ` felipe.balbi
  2010-04-07 16:04 ` [RFC PATCH 34/37] cbus: retu-rtc: switch to rtc class device felipe.balbi
                   ` (4 subsequent siblings)
  37 siblings, 0 replies; 41+ messages in thread
From: felipe.balbi @ 2010-04-07 16:04 UTC (permalink / raw)
  To: Linux OMAP Mailing List; +Cc: Felipe Balbi

From: Felipe Balbi <felipe.balbi@nokia.com>

trivial changes to make checkpatch.pl happy.
No functional changes.

Signed-off-by: Felipe Balbi <felipe.balbi@nokia.com>
---
 drivers/cbus/retu-rtc.c |   67 ++++++++++++++++++++++------------------------
 1 files changed, 32 insertions(+), 35 deletions(-)

diff --git a/drivers/cbus/retu-rtc.c b/drivers/cbus/retu-rtc.c
index 90d199e..1fe2b51 100644
--- a/drivers/cbus/retu-rtc.c
+++ b/drivers/cbus/retu-rtc.c
@@ -46,6 +46,7 @@
 #include "retu.h"
 
 struct retu_rtc {
+	/* device lock */
 	struct mutex		mutex;
 	struct completion	sync;
 	struct work_struct	work;
@@ -67,8 +68,8 @@ static void retu_rtc_barrier(struct retu_rtc *rtc)
 	retu_disable_irq(RETU_INT_RTCS);
 }
 
-static ssize_t retu_rtc_time_show(struct device *dev, struct device_attribute *attr,
-				  char *buf)
+static ssize_t retu_rtc_time_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
 {
 	struct retu_rtc		*rtc = dev_get_drvdata(dev);
 	u16			dsr, hmr, dsr2;
@@ -107,22 +108,22 @@ static ssize_t retu_rtc_time_show(struct device *dev, struct device_attribute *a
 	 * rather, none that will be reprinted here).
 	 */
 	return sprintf(buf, "0x%08x\n", (((dsr >> 8) & 0xff) << 24) |
-				        (((hmr >> 8) & 0x1f) << 16) |
-					 ((hmr & 0x3f) << 8) | (dsr & 0x3f));
+			(((hmr >> 8) & 0x1f) << 16) |
+			((hmr & 0x3f) << 8) | (dsr & 0x3f));
 }
 
-static ssize_t retu_rtc_time_store(struct device *dev, struct device_attribute *attr,
-				   const char *buf, size_t count)
+static ssize_t retu_rtc_time_store(struct device *dev,
+		struct device_attribute *attr, const char *buf, size_t count)
 {
 	struct retu_rtc		*rtc = dev_get_drvdata(dev);
 
 	mutex_lock(&rtc->mutex);
 	/*
 	 * Writing anything to the day counter forces it to 0
-	 * The seconds counter would be cleared by resetting the minutes counter,
-	 * however this won't happen, since we are using the hh:mm counters as
-	 * a set of free running counters and the day counter as a multiple
-	 * overflow holder.
+	 * The seconds counter would be cleared by resetting the minutes
+	 * counter, however this won't happen, since we are using the
+	 * hh:mm counters as a set of free running counters and the
+	 * day counter as a multiple overflow holder.
 	 */
 
 	/* Reset day counter, but keep Temperature Shutdown state */
@@ -133,12 +134,11 @@ static ssize_t retu_rtc_time_store(struct device *dev, struct device_attribute *
 
 	return count;
 }
-
 static DEVICE_ATTR(time, S_IRUGO | S_IWUSR, retu_rtc_time_show,
 		   retu_rtc_time_store);
 
-
-static ssize_t retu_rtc_reset_show(struct device *dev, struct device_attribute *attr, char *buf)
+static ssize_t retu_rtc_reset_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
 {
 	struct retu_rtc		*rtc = dev_get_drvdata(dev);
 
@@ -174,13 +174,13 @@ static void retu_rtc_do_reset(struct retu_rtc *rtc)
 	rtc->reset_occurred = 1;
 }
 
-static ssize_t retu_rtc_reset_store(struct device *dev, struct device_attribute *attr,
-				    const char *buf, size_t count)
+static ssize_t retu_rtc_reset_store(struct device *dev,
+		struct device_attribute *attr, const char *buf, size_t count)
 {
 	struct retu_rtc		*rtc = dev_get_drvdata(dev);
 	unsigned		choice;
 
-	if(sscanf(buf, "%u", &choice) != 1)
+	if (sscanf(buf, "%u", &choice) != 1)
 		return count;
 	mutex_lock(&rtc->mutex);
 	if (choice == 0)
@@ -190,12 +190,11 @@ static ssize_t retu_rtc_reset_store(struct device *dev, struct device_attribute
 	mutex_unlock(&rtc->mutex);
 	return count;
 }
-
 static DEVICE_ATTR(reset, S_IRUGO | S_IWUSR, retu_rtc_reset_show,
 		   retu_rtc_reset_store);
 
-static ssize_t retu_rtc_alarm_show(struct device *dev, struct device_attribute *attr,
-				   char *buf)
+static ssize_t retu_rtc_alarm_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
 {
 	struct retu_rtc		*rtc = dev_get_drvdata(dev);
 	ssize_t			retval;
@@ -216,8 +215,8 @@ static ssize_t retu_rtc_alarm_show(struct device *dev, struct device_attribute *
 	return retval;
 }
 
-static ssize_t retu_rtc_alarm_store(struct device *dev, struct device_attribute *attr,
-				    const char *buf, size_t count)
+static ssize_t retu_rtc_alarm_store(struct device *dev,
+		struct device_attribute *attr, const char *buf, size_t count)
 {
 	struct retu_rtc		*rtc = dev_get_drvdata(dev);
 
@@ -229,7 +228,7 @@ static ssize_t retu_rtc_alarm_store(struct device *dev, struct device_attribute
 
 	mutex_lock(&rtc->mutex);
 
-	if(sscanf(buf, "%x", &alrm) != 1)
+	if (sscanf(buf, "%x", &alrm) != 1)
 		return count;
 	hours = (alrm >> 8) & 0x001f;
 	minutes = (alrm >> 0) & 0x003f;
@@ -256,12 +255,11 @@ static ssize_t retu_rtc_alarm_store(struct device *dev, struct device_attribute
 
 	return count;
 }
-
 static DEVICE_ATTR(alarm, S_IRUGO | S_IWUSR, retu_rtc_alarm_show,
 		   retu_rtc_alarm_store);
 
-static ssize_t retu_rtc_alarm_expired_show(struct device *dev, struct device_attribute *attr,
-					   char *buf)
+static ssize_t retu_rtc_alarm_expired_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
 {
 	struct retu_rtc		*rtc = dev_get_drvdata(dev);
 	ssize_t			retval;
@@ -271,8 +269,8 @@ static ssize_t retu_rtc_alarm_expired_show(struct device *dev, struct device_att
 	return retval;
 }
 
-static ssize_t retu_rtc_alarm_expired_store(struct device *dev, struct device_attribute *attr,
-					    const char *buf, size_t count)
+static ssize_t retu_rtc_alarm_expired_store(struct device *dev,
+		struct device_attribute *attr, const char *buf, size_t count)
 {
 	struct retu_rtc		*rtc = dev_get_drvdata(dev);
 
@@ -280,13 +278,12 @@ static ssize_t retu_rtc_alarm_expired_store(struct device *dev, struct device_at
 
 	return count;
 }
-
-static DEVICE_ATTR(alarm_expired, S_IRUGO | S_IWUSR, retu_rtc_alarm_expired_show,
-		   retu_rtc_alarm_expired_store);
+static DEVICE_ATTR(alarm_expired, S_IRUGO | S_IWUSR,
+		retu_rtc_alarm_expired_show, retu_rtc_alarm_expired_store);
 
 
-static ssize_t retu_rtc_cal_show(struct device *dev, struct device_attribute *attr,
-				 char *buf)
+static ssize_t retu_rtc_cal_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
 {
 	struct retu_rtc		*rtc = dev_get_drvdata(dev);
 	u16			rtccalr1;
@@ -306,8 +303,8 @@ static ssize_t retu_rtc_cal_show(struct device *dev, struct device_attribute *at
 	return sprintf(buf, "0x%04x\n", rtccalr1 & 0x00ff);
 }
 
-static ssize_t retu_rtc_cal_store(struct device *dev, struct device_attribute *attr,
-				  const char *buf, size_t count)
+static ssize_t retu_rtc_cal_store(struct device *dev,
+		struct device_attribute *attr, const char *buf, size_t count)
 {
 	struct retu_rtc		*rtc = dev_get_drvdata(dev);
 	unsigned		calibration_value;
@@ -322,7 +319,6 @@ static ssize_t retu_rtc_cal_store(struct device *dev, struct device_attribute *a
 
 	return count;
 }
-
 static DEVICE_ATTR(cal, S_IRUGO | S_IWUSR, retu_rtc_cal_show,
 		   retu_rtc_cal_store);
 
@@ -501,4 +497,5 @@ MODULE_DESCRIPTION("Retu RTC");
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Paul Mundt");
 MODULE_AUTHOR("Igor Stoppa");
+MODULE_AUTHOR("Felipe Balbi <felipe.balbi@nokia.com>");
 
-- 
1.7.0.rc0.33.g7c3932


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

* [RFC PATCH 34/37] cbus: retu-rtc: switch to rtc class device
  2010-04-07 16:03 [RFC PATCH 00/37] cbus patches felipe.balbi
                   ` (32 preceding siblings ...)
  2010-04-07 16:04 ` [RFC PATCH 33/37] cbus: retu-rtc: make checkpatch.pl happy felipe.balbi
@ 2010-04-07 16:04 ` felipe.balbi
  2010-04-07 16:04 ` [RFC PATCH 35/37] cbus: retu-wdt: remove the platform_device felipe.balbi
                   ` (3 subsequent siblings)
  37 siblings, 0 replies; 41+ messages in thread
From: felipe.balbi @ 2010-04-07 16:04 UTC (permalink / raw)
  To: Linux OMAP Mailing List; +Cc: Felipe Balbi

From: Felipe Balbi <felipe.balbi@nokia.com>

remove the old syfs interface and move to rtc class
device registration.

Signed-off-by: Felipe Balbi <felipe.balbi@nokia.com>
---
 drivers/cbus/Kconfig    |    2 +-
 drivers/cbus/retu-rtc.c |  382 ++++++++++++++++-------------------------------
 2 files changed, 130 insertions(+), 254 deletions(-)

diff --git a/drivers/cbus/Kconfig b/drivers/cbus/Kconfig
index c344a99..c6b39fb 100644
--- a/drivers/cbus/Kconfig
+++ b/drivers/cbus/Kconfig
@@ -65,7 +65,7 @@ config CBUS_RETU_POWERBUTTON
 	  If you want support for the Retu power button, you should say Y here.
 
 config CBUS_RETU_RTC
-	depends on CBUS_RETU && SYSFS
+	depends on CBUS_RETU && RTC_CLASS
 	tristate "Support for Retu pseudo-RTC"
 	---help---
 	  Say Y here if you want support for the device that alleges to be an
diff --git a/drivers/cbus/retu-rtc.c b/drivers/cbus/retu-rtc.c
index 1fe2b51..b0a0f3d 100644
--- a/drivers/cbus/retu-rtc.c
+++ b/drivers/cbus/retu-rtc.c
@@ -40,6 +40,7 @@
 #include <linux/completion.h>
 #include <linux/platform_device.h>
 #include <linux/mutex.h>
+#include <linux/rtc.h>
 #include <linux/workqueue.h>
 
 #include "cbus.h"
@@ -51,6 +52,7 @@ struct retu_rtc {
 	struct completion	sync;
 	struct work_struct	work;
 	struct device		*dev;
+	struct rtc_device	*rtc;
 
 	u16			alarm_expired;
 	u16			reset_occurred;
@@ -68,92 +70,6 @@ static void retu_rtc_barrier(struct retu_rtc *rtc)
 	retu_disable_irq(RETU_INT_RTCS);
 }
 
-static ssize_t retu_rtc_time_show(struct device *dev,
-		struct device_attribute *attr, char *buf)
-{
-	struct retu_rtc		*rtc = dev_get_drvdata(dev);
-	u16			dsr, hmr, dsr2;
-
-	mutex_lock(&rtc->mutex);
-
-	do {
-		u16 dummy;
-
-		/*
-		 * Not being in_interrupt() for a retu rtc IRQ, we need to
-		 * read twice for consistency..
-		 */
-		dummy	= retu_read_reg(RETU_REG_RTCDSR);
-		dsr	= retu_read_reg(RETU_REG_RTCDSR);
-
-		dummy	= retu_read_reg(RETU_REG_RTCHMR);
-		hmr	= retu_read_reg(RETU_REG_RTCHMR);
-
-		dummy	= retu_read_reg(RETU_REG_RTCDSR);
-		dsr2	= retu_read_reg(RETU_REG_RTCDSR);
-	} while ((dsr != dsr2));
-
-	mutex_unlock(&rtc->mutex);
-
-	/*
-	 * Format a 32-bit date-string for userspace
-	 *
-	 * days | hours | minutes | seconds
-	 *
-	 * 8 bits for each.
-	 *
-	 * This mostly sucks because days and seconds are tracked in RTCDSR
-	 * while hours and minutes are tracked in RTCHMR. And yes, there
-	 * really are no words that can describe an 8 bit day register (or
-	 * rather, none that will be reprinted here).
-	 */
-	return sprintf(buf, "0x%08x\n", (((dsr >> 8) & 0xff) << 24) |
-			(((hmr >> 8) & 0x1f) << 16) |
-			((hmr & 0x3f) << 8) | (dsr & 0x3f));
-}
-
-static ssize_t retu_rtc_time_store(struct device *dev,
-		struct device_attribute *attr, const char *buf, size_t count)
-{
-	struct retu_rtc		*rtc = dev_get_drvdata(dev);
-
-	mutex_lock(&rtc->mutex);
-	/*
-	 * Writing anything to the day counter forces it to 0
-	 * The seconds counter would be cleared by resetting the minutes
-	 * counter, however this won't happen, since we are using the
-	 * hh:mm counters as a set of free running counters and the
-	 * day counter as a multiple overflow holder.
-	 */
-
-	/* Reset day counter, but keep Temperature Shutdown state */
-	retu_write_reg(RETU_REG_RTCDSR,
-		       retu_read_reg(RETU_REG_RTCDSR) & (1 << 6));
-
-	mutex_unlock(&rtc->mutex);
-
-	return count;
-}
-static DEVICE_ATTR(time, S_IRUGO | S_IWUSR, retu_rtc_time_show,
-		   retu_rtc_time_store);
-
-static ssize_t retu_rtc_reset_show(struct device *dev,
-		struct device_attribute *attr, char *buf)
-{
-	struct retu_rtc		*rtc = dev_get_drvdata(dev);
-
-	/*
-	 * Returns the status of the rtc
-	 *
-	 * 0: no reset has occurred or the status has been cleared
-	 * 1: a reset has occurred
-	 *
-	 * RTC needs to be reset only when both main battery
-	 * _AND_ backup battery are discharged
-	 */
-	return sprintf(buf, "%u\n", rtc->reset_occurred);
-}
-
 static void retu_rtc_do_reset(struct retu_rtc *rtc)
 {
 	u16 ccr1;
@@ -174,167 +90,6 @@ static void retu_rtc_do_reset(struct retu_rtc *rtc)
 	rtc->reset_occurred = 1;
 }
 
-static ssize_t retu_rtc_reset_store(struct device *dev,
-		struct device_attribute *attr, const char *buf, size_t count)
-{
-	struct retu_rtc		*rtc = dev_get_drvdata(dev);
-	unsigned		choice;
-
-	if (sscanf(buf, "%u", &choice) != 1)
-		return count;
-	mutex_lock(&rtc->mutex);
-	if (choice == 0)
-		rtc->reset_occurred = 0;
-	else if (choice == 1)
-		retu_rtc_do_reset(rtc);
-	mutex_unlock(&rtc->mutex);
-	return count;
-}
-static DEVICE_ATTR(reset, S_IRUGO | S_IWUSR, retu_rtc_reset_show,
-		   retu_rtc_reset_store);
-
-static ssize_t retu_rtc_alarm_show(struct device *dev,
-		struct device_attribute *attr, char *buf)
-{
-	struct retu_rtc		*rtc = dev_get_drvdata(dev);
-	ssize_t			retval;
-	u16			chmar;
-
-	mutex_lock(&rtc->mutex);
-	/*
-	 * Format a 16-bit date-string for userspace
-	 *
-	 * hours | minutes
-	 * 8 bits for each.
-	 */
-	chmar = retu_read_reg(RETU_REG_RTCHMAR);
-	/* No shifting needed, only masking unrelated bits */
-	retval = sprintf(buf, "0x%04x\n", chmar & 0x1f3f);
-	mutex_unlock(&rtc->mutex);
-
-	return retval;
-}
-
-static ssize_t retu_rtc_alarm_store(struct device *dev,
-		struct device_attribute *attr, const char *buf, size_t count)
-{
-	struct retu_rtc		*rtc = dev_get_drvdata(dev);
-
-	unsigned		minutes;
-	unsigned		hours;
-	unsigned		alrm;
-
-	u16			chmar;
-
-	mutex_lock(&rtc->mutex);
-
-	if (sscanf(buf, "%x", &alrm) != 1)
-		return count;
-	hours = (alrm >> 8) & 0x001f;
-	minutes = (alrm >> 0) & 0x003f;
-	if ((hours < 24 && minutes < 60) || (hours == 24 && minutes == 60)) {
-		/*
-		 * OK, the time format for the alarm is valid (including the
-		 * disabling values)
-		 */
-		/* Keeps the RTC watchdog status */
-		chmar = retu_read_reg(RETU_REG_RTCHMAR) & 0x6000;
-		chmar |= alrm & 0x1f3f;	/* Stores the requested alarm */
-		retu_rtc_barrier(rtc);
-		retu_write_reg(RETU_REG_RTCHMAR, chmar);
-		/* If the alarm is being disabled */
-		if (hours == 24 && minutes == 60) {
-			/* disable the interrupt */
-			retu_disable_irq(RETU_INT_RTCA);
-			rtc->alarm_expired = 0;
-		} else
-			/* enable the interrupt */
-			retu_enable_irq(RETU_INT_RTCA);
-	}
-	mutex_unlock(&rtc->mutex);
-
-	return count;
-}
-static DEVICE_ATTR(alarm, S_IRUGO | S_IWUSR, retu_rtc_alarm_show,
-		   retu_rtc_alarm_store);
-
-static ssize_t retu_rtc_alarm_expired_show(struct device *dev,
-		struct device_attribute *attr, char *buf)
-{
-	struct retu_rtc		*rtc = dev_get_drvdata(dev);
-	ssize_t			retval;
-
-	retval = sprintf(buf, "%u\n", rtc->alarm_expired);
-
-	return retval;
-}
-
-static ssize_t retu_rtc_alarm_expired_store(struct device *dev,
-		struct device_attribute *attr, const char *buf, size_t count)
-{
-	struct retu_rtc		*rtc = dev_get_drvdata(dev);
-
-	rtc->alarm_expired = 0;
-
-	return count;
-}
-static DEVICE_ATTR(alarm_expired, S_IRUGO | S_IWUSR,
-		retu_rtc_alarm_expired_show, retu_rtc_alarm_expired_store);
-
-
-static ssize_t retu_rtc_cal_show(struct device *dev,
-		struct device_attribute *attr, char *buf)
-{
-	struct retu_rtc		*rtc = dev_get_drvdata(dev);
-	u16			rtccalr1;
-
-	mutex_lock(&rtc->mutex);
-	rtccalr1 = retu_read_reg(RETU_REG_RTCCALR);
-	mutex_unlock(&rtc->mutex);
-
-	/*
-	 * Shows the status of the Calibration Register.
-	 *
-	 * Default, after power loss: 0x0000
-	 * Default, for R&D: 0x00C0
-	 * Default, for factory: 0x00??
-	 *
-	 */
-	return sprintf(buf, "0x%04x\n", rtccalr1 & 0x00ff);
-}
-
-static ssize_t retu_rtc_cal_store(struct device *dev,
-		struct device_attribute *attr, const char *buf, size_t count)
-{
-	struct retu_rtc		*rtc = dev_get_drvdata(dev);
-	unsigned		calibration_value;
-
-	if (sscanf(buf, "%x", &calibration_value) != 1)
-		return count;
-
-	mutex_lock(&rtc->mutex);
-	retu_rtc_barrier(rtc);
-	retu_write_reg(RETU_REG_RTCCALR, calibration_value & 0x00ff);
-	mutex_unlock(&rtc->mutex);
-
-	return count;
-}
-static DEVICE_ATTR(cal, S_IRUGO | S_IWUSR, retu_rtc_cal_show,
-		   retu_rtc_cal_store);
-
-static struct attribute *retu_rtc_attrs[] = {
-	&dev_attr_cal.attr,
-	&dev_attr_alarm_expired.attr,
-	&dev_attr_alarm.attr,
-	&dev_attr_reset.attr,
-	&dev_attr_time.attr,
-	NULL,
-};
-
-static const struct attribute_group retu_rtc_group = {
-	.attrs = retu_rtc_attrs,
-};
-
 static void retu_rtca_disable(struct retu_rtc *rtc)
 {
 	retu_disable_irq(RETU_INT_RTCA);
@@ -348,8 +103,6 @@ static void retu_rtca_expired(struct work_struct *work)
 	struct retu_rtc		*rtc = work_to_rtc(work);
 
 	retu_rtca_disable(rtc);
-
-	sysfs_notify(&rtc->dev->kobj, NULL, "alarm_expired");
 }
 
 /*
@@ -397,6 +150,127 @@ static int retu_rtc_init_irq(struct retu_rtc *rtc)
 	return 0;
 }
 
+static int retu_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alm)
+{
+	struct retu_rtc		*rtc = dev_get_drvdata(dev);
+	u16			chmar;
+
+	mutex_lock(&rtc->mutex);
+
+	chmar = ((alm->time.tm_hour & 0x1f) << 8) | (alm->time.tm_min & 0x3f);
+	retu_write_reg(RETU_REG_RTCHMAR, chmar);
+
+	mutex_unlock(&rtc->mutex);
+
+	return 0;
+}
+
+static int retu_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alm)
+{
+	struct retu_rtc		*rtc = dev_get_drvdata(dev);
+	u16			chmar;
+
+	mutex_lock(&rtc->mutex);
+
+	chmar = retu_read_reg(RETU_REG_RTCHMAR);
+
+	alm->time.tm_hour	= (chmar >> 8) & 0x1f;
+	alm->time.tm_min	= chmar & 0x3f;
+	alm->enabled		= !!rtc->alarm_expired;
+
+	mutex_unlock(&rtc->mutex);
+
+	return 0;
+}
+
+static int retu_rtc_set_time(struct device *dev, struct rtc_time *tm)
+{
+	struct retu_rtc		*rtc = dev_get_drvdata(dev);
+	u16			dsr;
+	u16			hmr;
+
+	dsr = ((tm->tm_mday & 0xff) << 8) | (tm->tm_hour & 0xff);
+	hmr = ((tm->tm_min & 0xff) << 8) | (tm->tm_sec & 0xff);
+
+	mutex_lock(&rtc->mutex);
+
+	retu_write_reg(RETU_REG_RTCDSR, dsr);
+	retu_write_reg(RETU_REG_RTCHMR, hmr);
+
+	mutex_unlock(&rtc->mutex);
+
+	return 0;
+}
+
+static int retu_rtc_read_time(struct device *dev, struct rtc_time *tm)
+{
+	struct retu_rtc		*rtc = dev_get_drvdata(dev);
+	u16			dsr;
+	u16			hmr;
+
+	/*
+	 * DSR holds days and hours
+	 * HMR hols minutes and seconds
+	 *
+	 * both are 16 bit registers with 8-bit for each field.
+	 */
+
+	mutex_lock(&rtc->mutex);
+
+	dsr	= retu_read_reg(RETU_REG_RTCDSR);
+	hmr	= retu_read_reg(RETU_REG_RTCHMR);
+
+	tm->tm_sec	= hmr & 0xff;
+	tm->tm_min	= hmr >> 8;
+	tm->tm_hour	= dsr & 0xff;
+	tm->tm_mday	= dsr >> 8;
+
+	mutex_unlock(&rtc->mutex);
+
+	return 0;
+}
+
+#ifdef CONFIG_RTC_INTF_DEV
+
+static int retu_rtc_ioctl(struct device *dev, unsigned int cmd,
+		unsigned long arg)
+{
+	struct retu_rtc		*rtc = dev_get_drvdata(dev);
+
+	mutex_lock(&rtc->mutex);
+
+	switch (cmd) {
+	case RTC_AIE_OFF:
+		retu_disable_irq(RETU_INT_RTCA);
+		break;
+	case RTC_AIE_ON:
+		retu_enable_irq(RETU_INT_RTCA);
+		break;
+	case RTC_UIE_OFF:
+		retu_disable_irq(RETU_INT_RTCS);
+		break;
+	case RTC_UIE_ON:
+		retu_enable_irq(RETU_INT_RTCS);
+		break;
+	default:
+		return -ENOIOCTLCMD;
+	}
+
+	mutex_unlock(&rtc->mutex);
+
+	return 0;
+}
+#else
+#define retu_rtc_ioctl	NULL
+#endif
+
+static struct rtc_class_ops retu_rtc_ops = {
+	.ioctl			= retu_rtc_ioctl,
+	.read_time		= retu_rtc_read_time,
+	.set_time		= retu_rtc_set_time,
+	.read_alarm		= retu_rtc_read_alarm,
+	.set_alarm		= retu_rtc_set_alarm,
+};
 
 static int __devinit retu_rtc_probe(struct platform_device *pdev)
 {
@@ -437,9 +311,11 @@ static int __devinit retu_rtc_probe(struct platform_device *pdev)
 	else
 		retu_rtc_do_reset(rtc);
 
-	r = sysfs_create_group(&pdev->dev.kobj, &retu_rtc_group);
-	if (r) {
-		dev_err(&pdev->dev, "couldn't create sysfs interface\n");
+
+	rtc->rtc = rtc_device_register(pdev->name, &pdev->dev, &
+			retu_rtc_ops, THIS_MODULE);
+	if (IS_ERR(rtc->rtc)) {
+		dev_err(&pdev->dev, "can't register RTC device\n");
 		goto err2;
 	}
 
@@ -466,7 +342,7 @@ static int __devexit retu_rtc_remove(struct platform_device *pdev)
 	retu_disable_irq(RETU_INT_RTCA);
 	retu_free_irq(RETU_INT_RTCS);
 	retu_free_irq(RETU_INT_RTCA);
-	sysfs_remove_group(&pdev->dev.kobj, &retu_rtc_group);
+	rtc_device_unregister(rtc->rtc);
 	kfree(rtc);
 
 	return 0;
-- 
1.7.0.rc0.33.g7c3932


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

* [RFC PATCH 35/37] cbus: retu-wdt: remove the platform_device
  2010-04-07 16:03 [RFC PATCH 00/37] cbus patches felipe.balbi
                   ` (33 preceding siblings ...)
  2010-04-07 16:04 ` [RFC PATCH 34/37] cbus: retu-rtc: switch to rtc class device felipe.balbi
@ 2010-04-07 16:04 ` felipe.balbi
  2010-04-07 16:04 ` [RFC PATCH 36/37] cbus: retu-wtd: convert to platform_driver felipe.balbi
                   ` (2 subsequent siblings)
  37 siblings, 0 replies; 41+ messages in thread
From: felipe.balbi @ 2010-04-07 16:04 UTC (permalink / raw)
  To: Linux OMAP Mailing List; +Cc: Felipe Balbi

From: Felipe Balbi <felipe.balbi@nokia.com>

it now comes from retu.c, so use that.

Signed-off-by: Felipe Balbi <felipe.balbi@nokia.com>
---
 drivers/cbus/retu-wdt.c |   34 +---------------------------------
 1 files changed, 1 insertions(+), 33 deletions(-)

diff --git a/drivers/cbus/retu-wdt.c b/drivers/cbus/retu-wdt.c
index 380fae6..763b34f 100644
--- a/drivers/cbus/retu-wdt.c
+++ b/drivers/cbus/retu-wdt.c
@@ -32,7 +32,6 @@
 #include <linux/completion.h>
 #include <linux/errno.h>
 #include <linux/moduleparam.h>
-#include <linux/platform_device.h>
 #include <linux/miscdevice.h>
 #include <linux/watchdog.h>
 
@@ -48,7 +47,6 @@
 #define RETU_WDT_DEFAULT_TIMER 32
 #define RETU_WDT_MAX_TIMER 63
 
-static struct completion retu_wdt_completion;
 static DEFINE_MUTEX(retu_wdt_mutex);
 
 /* Current period of watchdog */
@@ -321,21 +319,8 @@ static int __devexit retu_wdt_remove(struct device *dev)
 	return 0;
 }
 
-static void retu_wdt_device_release(struct device *dev)
-{
-	complete(&retu_wdt_completion);
-}
-
-static struct platform_device retu_wdt_device = {
-	.name = "retu-watchdog",
-	.id = -1,
-	.dev = {
-		.release = retu_wdt_device_release,
-	},
-};
-
 static struct device_driver retu_wdt_driver = {
-	.name = "retu-watchdog",
+	.name = "retu-wdt",
 	.bus = &platform_bus_type,
 	.probe = retu_wdt_probe,
 	.remove = __devexit_p(retu_wdt_remove),
@@ -349,16 +334,10 @@ static int __init retu_wdt_init(void)
 	if (!ret)
 		return -ENODEV;
 
-	init_completion(&retu_wdt_completion);
-
 	ret = driver_register(&retu_wdt_driver);
 	if (ret)
 		return ret;
 
-	ret = platform_device_register(&retu_wdt_device);
-	if (ret)
-		goto exit1;
-
 	/* passed as module parameter? */
 	ret = retu_modify_counter(counter_param);
 	if (ret == -EINVAL) {
@@ -367,23 +346,12 @@ static int __init retu_wdt_init(void)
 		       "retu_wdt_init: Intializing to default value\n");
 	}
 
-	printk(KERN_INFO "Retu watchdog driver initialized\n");
-
 	return retu_wdt_ping();
-
-exit1:
-	driver_unregister(&retu_wdt_driver);
-	wait_for_completion(&retu_wdt_completion);
-
-	return ret;
 }
 
 static void __exit retu_wdt_exit(void)
 {
-	platform_device_unregister(&retu_wdt_device);
 	driver_unregister(&retu_wdt_driver);
-
-	wait_for_completion(&retu_wdt_completion);
 }
 
 module_init(retu_wdt_init);
-- 
1.7.0.rc0.33.g7c3932


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

* [RFC PATCH 36/37] cbus: retu-wtd: convert to platform_driver
  2010-04-07 16:03 [RFC PATCH 00/37] cbus patches felipe.balbi
                   ` (34 preceding siblings ...)
  2010-04-07 16:04 ` [RFC PATCH 35/37] cbus: retu-wdt: remove the platform_device felipe.balbi
@ 2010-04-07 16:04 ` felipe.balbi
  2010-04-07 16:04 ` [RFC PATCH 37/37] cbus: retu-wdt: misc cleanup on retu-wdt driver felipe.balbi
  2010-04-08  9:23 ` [RFC PATCH 00/37] cbus patches Tony Lindgren
  37 siblings, 0 replies; 41+ messages in thread
From: felipe.balbi @ 2010-04-07 16:04 UTC (permalink / raw)
  To: Linux OMAP Mailing List; +Cc: Felipe Balbi

From: Felipe Balbi <felipe.balbi@nokia.com>

trivial patch converting a device_driver into
platform_driver.

Signed-off-by: Felipe Balbi <felipe.balbi@nokia.com>
---
 drivers/cbus/retu-wdt.c |   77 +++++++++++++++++++++++++----------------------
 1 files changed, 41 insertions(+), 36 deletions(-)

diff --git a/drivers/cbus/retu-wdt.c b/drivers/cbus/retu-wdt.c
index 763b34f..53bec32 100644
--- a/drivers/cbus/retu-wdt.c
+++ b/drivers/cbus/retu-wdt.c
@@ -252,34 +252,38 @@ static const struct file_operations retu_wdt_fops = {
 
 /*----------------------------------------------------------------------------*/
 
-static int __devinit retu_wdt_probe(struct device *dev)
+static int __devinit retu_wdt_probe(struct platform_device *pdev)
 {
 	struct retu_wdt_dev *wdev;
 	int ret;
 
+	ret = retu_get_status();
+	if (!ret)
+		return -ENODEV;
+
 	wdev = kzalloc(sizeof(struct retu_wdt_dev), GFP_KERNEL);
 	if (!wdev)
 		return -ENOMEM;
 
 	wdev->users = 0;
 
-	ret = device_create_file(dev, &dev_attr_period);
+	ret = device_create_file(&pdev->dev, &dev_attr_period);
 	if (ret) {
 		printk(KERN_ERR "retu_wdt_probe: Error creating "
 					"sys device file: period\n");
 		goto free1;
 	}
 
-	ret = device_create_file(dev, &dev_attr_counter);
+	ret = device_create_file(&pdev->dev, &dev_attr_counter);
 	if (ret) {
 		printk(KERN_ERR "retu_wdt_probe: Error creating "
 					"sys device file: counter\n");
 		goto free2;
 	}
 
-	dev_set_drvdata(dev, wdev);
+	platform_set_drvdata(pdev, wdev);
 	retu_wdt = wdev;
-	wdev->retu_wdt_miscdev.parent = dev;
+	wdev->retu_wdt_miscdev.parent = &pdev->dev;
 	wdev->retu_wdt_miscdev.minor = WATCHDOG_MINOR;
 	wdev->retu_wdt_miscdev.name = "watchdog";
 	wdev->retu_wdt_miscdev.fops = &retu_wdt_fops;
@@ -290,68 +294,69 @@ static int __devinit retu_wdt_probe(struct device *dev)
 
 	setup_timer(&wdev->ping_timer, retu_wdt_set_ping_timer, 1);
 
+	/* passed as module parameter? */
+	ret = retu_modify_counter(counter_param);
+	if (ret == -EINVAL) {
+		ret = retu_modify_counter(RETU_WDT_DEFAULT_TIMER);
+		printk(KERN_INFO
+		       "retu_wdt_init: Intializing to default value\n");
+	}
+
 	/* Kick the watchdog for kernel booting to finish */
 	retu_modify_counter(RETU_WDT_MAX_TIMER);
 
+	ret = retu_wdt_ping();
+	if (ret < 0) {
+		printk(KERN_INFO "retu_wdt_init: Failed to ping\n");
+		goto free4;
+	}
+
 	return 0;
 
+free4:
+	misc_deregister(&wdev->retu_wdt_miscdev);
+
 free3:
-	device_remove_file(dev, &dev_attr_counter);
+	device_remove_file(&pdev->dev, &dev_attr_counter);
 
 free2:
-	device_remove_file(dev, &dev_attr_period);
+	device_remove_file(&pdev->dev, &dev_attr_period);
+
 free1:
 	kfree(wdev);
 
 	return ret;
 }
 
-static int __devexit retu_wdt_remove(struct device *dev)
+static int __devexit retu_wdt_remove(struct platform_device *pdev)
 {
 	struct retu_wdt_dev *wdev;
 
-	wdev = dev_get_drvdata(dev);
+	wdev = platform_get_drvdata(pdev);
 	misc_deregister(&(wdev->retu_wdt_miscdev));
-	device_remove_file(dev, &dev_attr_period);
-	device_remove_file(dev, &dev_attr_counter);
+	device_remove_file(&pdev->dev, &dev_attr_period);
+	device_remove_file(&pdev->dev, &dev_attr_counter);
 	kfree(wdev);
 
 	return 0;
 }
 
-static struct device_driver retu_wdt_driver = {
-	.name = "retu-wdt",
-	.bus = &platform_bus_type,
-	.probe = retu_wdt_probe,
-	.remove = __devexit_p(retu_wdt_remove),
+static struct platform_driver retu_wdt_driver = {
+	.probe		= retu_wdt_probe,
+	.remove		= __devexit_p(retu_wdt_remove),
+	.driver		= {
+		.name	= "retu-wdt",
+	},
 };
 
 static int __init retu_wdt_init(void)
 {
-	int ret;
-
-	ret = retu_get_status();
-	if (!ret)
-		return -ENODEV;
-
-	ret = driver_register(&retu_wdt_driver);
-	if (ret)
-		return ret;
-
-	/* passed as module parameter? */
-	ret = retu_modify_counter(counter_param);
-	if (ret == -EINVAL) {
-		ret = retu_modify_counter(RETU_WDT_DEFAULT_TIMER);
-		printk(KERN_INFO
-		       "retu_wdt_init: Intializing to default value\n");
-	}
-
-	return retu_wdt_ping();
+	return platform_driver_register(&retu_wdt_driver);
 }
 
 static void __exit retu_wdt_exit(void)
 {
-	driver_unregister(&retu_wdt_driver);
+	platform_driver_unregister(&retu_wdt_driver);
 }
 
 module_init(retu_wdt_init);
-- 
1.7.0.rc0.33.g7c3932


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

* [RFC PATCH 37/37] cbus: retu-wdt: misc cleanup on retu-wdt driver
  2010-04-07 16:03 [RFC PATCH 00/37] cbus patches felipe.balbi
                   ` (35 preceding siblings ...)
  2010-04-07 16:04 ` [RFC PATCH 36/37] cbus: retu-wtd: convert to platform_driver felipe.balbi
@ 2010-04-07 16:04 ` felipe.balbi
  2010-04-08  9:23 ` [RFC PATCH 00/37] cbus patches Tony Lindgren
  37 siblings, 0 replies; 41+ messages in thread
From: felipe.balbi @ 2010-04-07 16:04 UTC (permalink / raw)
  To: Linux OMAP Mailing List; +Cc: Felipe Balbi

From: Felipe Balbi <felipe.balbi@nokia.com>

a trivial cleanup on the driver. No functional changes.

Signed-off-by: Felipe Balbi <felipe.balbi@nokia.com>
---
 drivers/cbus/retu-wdt.c |   25 +++++++++++--------------
 1 files changed, 11 insertions(+), 14 deletions(-)

diff --git a/drivers/cbus/retu-wdt.c b/drivers/cbus/retu-wdt.c
index 53bec32..1014165 100644
--- a/drivers/cbus/retu-wdt.c
+++ b/drivers/cbus/retu-wdt.c
@@ -225,7 +225,7 @@ static int retu_wdt_ioctl(struct inode *inode, struct file *file,
 }
 
 /* Start kicking retu watchdog until user space starts doing the kicking */
-static int __init retu_wdt_ping(void)
+static int __devinit retu_wdt_ping(void)
 {
 	int r;
 
@@ -243,11 +243,11 @@ static int __init retu_wdt_ping(void)
 }
 
 static const struct file_operations retu_wdt_fops = {
-	.owner = THIS_MODULE,
-	.write = retu_wdt_write,
-	.ioctl = retu_wdt_ioctl,
-	.open = retu_wdt_open,
-	.release = retu_wdt_release,
+	.owner		= THIS_MODULE,
+	.write		= retu_wdt_write,
+	.ioctl		= retu_wdt_ioctl,
+	.open		= retu_wdt_open,
+	.release	= retu_wdt_release,
 };
 
 /*----------------------------------------------------------------------------*/
@@ -269,15 +269,13 @@ static int __devinit retu_wdt_probe(struct platform_device *pdev)
 
 	ret = device_create_file(&pdev->dev, &dev_attr_period);
 	if (ret) {
-		printk(KERN_ERR "retu_wdt_probe: Error creating "
-					"sys device file: period\n");
+		dev_err(&pdev->dev, "Error creating sysfs period\n");
 		goto free1;
 	}
 
 	ret = device_create_file(&pdev->dev, &dev_attr_counter);
 	if (ret) {
-		printk(KERN_ERR "retu_wdt_probe: Error creating "
-					"sys device file: counter\n");
+		dev_err(&pdev->dev, "Error creating sysfs counter\n");
 		goto free2;
 	}
 
@@ -298,8 +296,7 @@ static int __devinit retu_wdt_probe(struct platform_device *pdev)
 	ret = retu_modify_counter(counter_param);
 	if (ret == -EINVAL) {
 		ret = retu_modify_counter(RETU_WDT_DEFAULT_TIMER);
-		printk(KERN_INFO
-		       "retu_wdt_init: Intializing to default value\n");
+		dev_dbg(&pdev->dev, "Initializing to default value\n");
 	}
 
 	/* Kick the watchdog for kernel booting to finish */
@@ -307,7 +304,7 @@ static int __devinit retu_wdt_probe(struct platform_device *pdev)
 
 	ret = retu_wdt_ping();
 	if (ret < 0) {
-		printk(KERN_INFO "retu_wdt_init: Failed to ping\n");
+		dev_err(&pdev->dev, "Failed to ping\n");
 		goto free4;
 	}
 
@@ -333,7 +330,7 @@ static int __devexit retu_wdt_remove(struct platform_device *pdev)
 	struct retu_wdt_dev *wdev;
 
 	wdev = platform_get_drvdata(pdev);
-	misc_deregister(&(wdev->retu_wdt_miscdev));
+	misc_deregister(&wdev->retu_wdt_miscdev);
 	device_remove_file(&pdev->dev, &dev_attr_period);
 	device_remove_file(&pdev->dev, &dev_attr_counter);
 	kfree(wdev);
-- 
1.7.0.rc0.33.g7c3932


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

* Re: [RFC PATCH 00/37] cbus patches
  2010-04-07 16:03 [RFC PATCH 00/37] cbus patches felipe.balbi
                   ` (36 preceding siblings ...)
  2010-04-07 16:04 ` [RFC PATCH 37/37] cbus: retu-wdt: misc cleanup on retu-wdt driver felipe.balbi
@ 2010-04-08  9:23 ` Tony Lindgren
  2010-04-24  0:45   ` Tony Lindgren
  37 siblings, 1 reply; 41+ messages in thread
From: Tony Lindgren @ 2010-04-08  9:23 UTC (permalink / raw)
  To: felipe.balbi; +Cc: Linux OMAP Mailing List

* felipe.balbi@nokia.com <felipe.balbi@nokia.com> [100407 09:05]:
> From: Felipe Balbi <felipe.balbi@nokia.com>
> 
> Hi all,
> 
> I still have to test these patches, but I fell like it's
> time to get some comments.
> 
> There's still a big TODO for the whole cbus drivers:
> 
> . cleanup all tahvo drivers
> . instantiate platform_device on board-files
> . pass platform_data to retu/tahvo and their children from board-files
> . move retu-headset to jack abstraction layer (??)
> . move retu-user.c to platform_driver
> . move tahvo and retu to generic-irq
> . move tahvo and retu to mfd
> . move tahvo and retu to threaded irq (??)
> . move all children drivers to proper locations
> . move cbus.c to a common location (drivers/misc ??)
> . allow any arch to use cbus.c by passing correct gpio numbers
> . get it all into mainline.
> 
> anyways, these patches were lightly boot tested on n810 and
> compile tested with n770_defconfig.
> 
> patches also available on cbus branch of git://gitorious.org/usb/usb.git

Great, let's make sure these work for 770 and N8x0 and then
merge. One step closer to getting rid of the last remaining
legacy branch..

Tony

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

* Re: [RFC PATCH 00/37] cbus patches
  2010-04-08  9:23 ` [RFC PATCH 00/37] cbus patches Tony Lindgren
@ 2010-04-24  0:45   ` Tony Lindgren
  2010-04-26  5:25     ` Felipe Balbi
  0 siblings, 1 reply; 41+ messages in thread
From: Tony Lindgren @ 2010-04-24  0:45 UTC (permalink / raw)
  To: felipe.balbi; +Cc: Linux OMAP Mailing List

* Tony Lindgren <tony@atomide.com> [100408 02:19]:
> * felipe.balbi@nokia.com <felipe.balbi@nokia.com> [100407 09:05]:
> > From: Felipe Balbi <felipe.balbi@nokia.com>
> > 
> > Hi all,
> > 
> > I still have to test these patches, but I fell like it's
> > time to get some comments.
> > 
> > There's still a big TODO for the whole cbus drivers:
> > 
> > . cleanup all tahvo drivers
> > . instantiate platform_device on board-files
> > . pass platform_data to retu/tahvo and their children from board-files
> > . move retu-headset to jack abstraction layer (??)
> > . move retu-user.c to platform_driver
> > . move tahvo and retu to generic-irq
> > . move tahvo and retu to mfd
> > . move tahvo and retu to threaded irq (??)
> > . move all children drivers to proper locations
> > . move cbus.c to a common location (drivers/misc ??)
> > . allow any arch to use cbus.c by passing correct gpio numbers
> > . get it all into mainline.
> > 
> > anyways, these patches were lightly boot tested on n810 and
> > compile tested with n770_defconfig.
> > 
> > patches also available on cbus branch of git://gitorious.org/usb/usb.git
> 
> Great, let's make sure these work for 770 and N8x0 and then
> merge. One step closer to getting rid of the last remaining
> legacy branch..

Well 770 does not stay up, but at least boots to root. Meaning
the watchdog is not getting kicked. Seems to just hang without
these patches. Will try to look further at some point.

N800 boots fine and stays up, so the watchdog is getting kicked.

So I've pulled this into the cbus branch.

Tony

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

* Re: [RFC PATCH 00/37] cbus patches
  2010-04-24  0:45   ` Tony Lindgren
@ 2010-04-26  5:25     ` Felipe Balbi
  0 siblings, 0 replies; 41+ messages in thread
From: Felipe Balbi @ 2010-04-26  5:25 UTC (permalink / raw)
  To: ext Tony Lindgren
  Cc: Balbi Felipe (Nokia-D/Helsinki), Linux OMAP Mailing List

On Sat, Apr 24, 2010 at 02:45:53AM +0200, ext Tony Lindgren wrote:
>Well 770 does not stay up, but at least boots to root. Meaning
>the watchdog is not getting kicked. Seems to just hang without
>these patches. Will try to look further at some point.
>
>N800 boots fine and stays up, so the watchdog is getting kicked.
>
>So I've pulled this into the cbus branch.

great, I'll try to get back to these this or next week.

-- 
balbi

DefectiveByDesign.org

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

end of thread, other threads:[~2010-04-26  5:26 UTC | newest]

Thread overview: 41+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-07 16:03 [RFC PATCH 00/37] cbus patches felipe.balbi
2010-04-07 16:03 ` [RFC PATCH 01/37] cbus: convert u32 base to void __iomem *base felipe.balbi
2010-04-07 16:03 ` [RFC PATCH 02/37] cbus: NULL global variable on exit felipe.balbi
2010-04-07 16:03 ` [RFC PATCH 03/37] cbus: checkpatch.pl fix on cbus.c felipe.balbi
2010-04-07 16:03 ` [RFC PATCH 04/37] cbus: don't export the global cbus_host variable felipe.balbi
2010-04-07 16:03 ` [RFC PATCH 05/37] cbus: rely on gpiolib felipe.balbi
2010-04-07 16:03 ` [RFC PATCH 06/37] cbus: no ternary on return felipe.balbi
2010-04-07 16:03 ` [RFC PATCH 07/37] cbus: add read/write flag to cbus_transfer felipe.balbi
2010-04-07 16:03 ` [RFC PATCH 08/37] cbus: don't type case when issuing read/write felipe.balbi
2010-04-07 16:04 ` [RFC PATCH 09/37] cbus: fix a resource leakage felipe.balbi
2010-04-07 16:04 ` [RFC PATCH 10/37] cbus: move cbus_host definition to C source felipe.balbi
2010-04-07 16:04 ` [RFC PATCH 11/37] cbus: handle possible errors on cbus_send/receive_bit felipe.balbi
2010-04-07 16:04 ` [RFC PATCH 12/37] cbus: introduce cbus_send/receive_data wrappers felipe.balbi
2010-04-07 16:04 ` [RFC PATCH 13/37] cbus: add kerneldoc felipe.balbi
2010-04-07 16:04 ` [RFC PATCH 14/37] cbus: retu-wdt: fix compile breakage felipe.balbi
2010-04-07 16:04 ` [RFC PATCH 15/37] cbus: retu: fix compile breakage on retu-headset felipe.balbi
2010-04-07 16:04 ` [RFC PATCH 16/37] cbus: retu: split one MODULE_AUTHOR into several felipe.balbi
2010-04-07 16:04 ` [RFC PATCH 17/37] cbus: retu: don't assing ret inside the if () felipe.balbi
2010-04-07 16:04 ` [RFC PATCH 18/37] cbus: retu: convert printk to dev_* felipe.balbi
2010-04-07 16:04 ` [RFC PATCH 19/37] cbus: retu: convert to a platform_driver felipe.balbi
2010-04-07 16:04 ` [RFC PATCH 20/37] cbus: tahvo: split MODULE_AUTHOR into several entries felipe.balbi
2010-04-07 16:04 ` [RFC PATCH 21/37] cbus: tahvo: move EXPORT_SYMBOL macros closer to functions felipe.balbi
2010-04-07 16:04 ` [RFC PATCH 22/37] cbus: tahvo: don't assign ret inside if () felipe.balbi
2010-04-07 16:04 ` [RFC PATCH 23/37] cbus: tahvo: convert printk into dev_* felipe.balbi
2010-04-07 16:04 ` [RFC PATCH 24/37] cbus: tahvo: convert to platform_driver felipe.balbi
2010-04-07 16:04 ` [RFC PATCH 25/37] cbus: retu: allocate platform_device for Retu's children felipe.balbi
2010-04-07 16:04 ` [RFC PATCH 26/37] cbus: retu-pwrbutton: convert to platform_driver felipe.balbi
2010-04-07 16:04 ` [RFC PATCH 27/37] cbus: retu-headset: simplify module_init felipe.balbi
2010-04-07 16:04 ` [RFC PATCH 28/37] cbus: retu-rtc: remove platform_device code felipe.balbi
2010-04-07 16:04 ` [RFC PATCH 29/37] cbus: retu-rtc: convert to platform_driver felipe.balbi
2010-04-07 16:04 ` [RFC PATCH 30/37] cbus: retu-rtc: split MODULE_AUTHOR into several entries felipe.balbi
2010-04-07 16:04 ` [RFC PATCH 31/37] cbus: retu-rtc: get rid of globals felipe.balbi
2010-04-07 16:04 ` [RFC PATCH 32/37] cbus: retu-rtc: move retu_rtc_barrier up on source code felipe.balbi
2010-04-07 16:04 ` [RFC PATCH 33/37] cbus: retu-rtc: make checkpatch.pl happy felipe.balbi
2010-04-07 16:04 ` [RFC PATCH 34/37] cbus: retu-rtc: switch to rtc class device felipe.balbi
2010-04-07 16:04 ` [RFC PATCH 35/37] cbus: retu-wdt: remove the platform_device felipe.balbi
2010-04-07 16:04 ` [RFC PATCH 36/37] cbus: retu-wtd: convert to platform_driver felipe.balbi
2010-04-07 16:04 ` [RFC PATCH 37/37] cbus: retu-wdt: misc cleanup on retu-wdt driver felipe.balbi
2010-04-08  9:23 ` [RFC PATCH 00/37] cbus patches Tony Lindgren
2010-04-24  0:45   ` Tony Lindgren
2010-04-26  5:25     ` Felipe Balbi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).