Skip to contentSkip to conversation

More cleanups

PATCH In review Felipe Balbi 3 participants 13 messages Feb 15, 2011 – Feb 16, 2011

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover More cleanups

We're almost there. retu.c looks very nice now.

The bulk effort is now on its children:

. retu-headset.c
. should use jack framework
. should use dev_pm_ops
. some cleanups wouldn't hurt

. retu-rtc.c
. needs suspend/resume (?)

. retu-wdt.c
. needs suspend/resume (?)

patches also available at [1] for convenience

[1] git://gitorious.org/usb/usb.git cbus

Felipe Balbi (15):
cbus: retu: drop retu_get_status
cbus: retu: replace BUG_ON with WARN
cbus: retu: drop the unnecessary spinlock_t
cbus: retu: drop unused PFX macro
arm: omap: cbus: add IDs for Retu and Tahvo
arm: omap: pass Retu ID via platform_data
cbus: retu: use the devid from platform_data
cbus: retu: introduce internal read/write functions
cbus: retu: search and replace
cbus: retu: pwrbutton: save device pointer on our structure
cbus: retu: pass the child device pointer to all retu functions
cbus: retu: headset: don't save pdev pointer
cbus: retu: replace EXPORT_SYMBOL with EXPORT_SYMBOL_GPL
cbus: retu: tabify retu initialization
cbus: retu: set pm_power_off to NULL when removing retu

 arch/arm/mach-omap1/board-nokia770.c   |    1 +
 arch/arm/mach-omap2/board-n8x0.c       |    1 +
 arch/arm/plat-omap/include/plat/cbus.h |    4 +
 drivers/cbus/retu-headset.c            |   35 ++++---
 drivers/cbus/retu-pwrbutton.c          |    4 +-
 drivers/cbus/retu-rtc.c                |   34 +++----
 drivers/cbus/retu-wdt.c                |   15 +---
 drivers/cbus/retu.c                    |  160 +++++++++++++++++++-------------
 drivers/cbus/retu.h                    |   10 +-
 9 files changed, 146 insertions(+), 118 deletions(-)
Signature · 1 line
1.7.4.rc2
#1 lore raw

PATCH 1/15 cbus: retu: drop retu_get_status

children are allocated after retu core probes,
so by the time children start to probe, parent
is initialized for sure.

---
 drivers/cbus/retu-rtc.c |    6 ------
 drivers/cbus/retu-wdt.c |    8 --------
 drivers/cbus/retu.c     |    6 ------
 drivers/cbus/retu.h     |    1 -
 4 files changed, 0 insertions(+), 21 deletions(-)
drivers/cbus/retu-rtc.c +0 -6
index 5f52edf..303a4a6 100644
@@ -215,12 +215,6 @@ static int __init retu_rtc_probe(struct platform_device *pdev)
 	platform_set_drvdata(pdev, rtc);
 	mutex_init(&rtc->mutex);
 
-	r = retu_get_status();
-	if (!r) {
-		dev_err(&pdev->dev, "retu not initialized\n");
-		goto err1;
-	}
-
 	rtc->alarm_expired = retu_read_reg(RETU_REG_IDR) &
 		(0x1 << RETU_INT_RTCA);
 
drivers/cbus/retu-wdt.c +0 -8
index 8b87ae9..423216c 100644
@@ -230,10 +230,6 @@ static int __devinit retu_wdt_ping(void)
 {
 	int r;
 
-	r = retu_get_status();
-	if (!r)
-		return -ENODEV;
-
 #ifdef CONFIG_WATCHDOG_NOWAYOUT
 	retu_modify_counter(RETU_WDT_MAX_TIMER);
 #else
@@ -258,10 +254,6 @@ static int __init 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;
drivers/cbus/retu.c +0 -6
index 6134781..5886b00 100644
@@ -74,12 +74,6 @@ struct retu {
 
 static struct retu *the_retu;
 
-int retu_get_status(void)
-{
-	return the_retu ? 1 : 0;
-}
-EXPORT_SYMBOL(retu_get_status);
-
 /**
  * retu_read_reg - Read a value from a register in Retu
  * @reg: the register to read from
drivers/cbus/retu.h +0 -1
index 1b05f3e..f2357a9 100644
@@ -57,7 +57,6 @@
 
 #define	MAX_RETU_IRQ_HANDLERS	16
 
-int retu_get_status(void);
 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);
Signature · 1 line
1.7.4.rc2
#2 lore raw

PATCH 2/15 cbus: retu: replace BUG_ON with WARN

In reply to Felipe Balbi

Instead of breaking the entire thing, just
WARN() about it.

---
 drivers/cbus/retu.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/cbus/retu.c +2 -2
index 5886b00..032864a 100644
@@ -82,7 +82,7 @@ static struct retu *the_retu;
  */
 int retu_read_reg(unsigned reg)
 {
-	BUG_ON(!the_retu);
+	WARN(!the_retu, "Retu not initialized\n");
 	return cbus_read_reg(RETU_ID, reg);
 }
 EXPORT_SYMBOL(retu_read_reg);
@@ -96,7 +96,7 @@ EXPORT_SYMBOL(retu_read_reg);
  */
 void retu_write_reg(unsigned reg, u16 val)
 {
-	BUG_ON(!the_retu);
+	WARN(!the_retu, "Retu not initialized\n");
 	cbus_write_reg(RETU_ID, reg, val);
 }
 EXPORT_SYMBOL(retu_write_reg);
Signature · 1 line
1.7.4.rc2
#3 lore raw

PATCH 3/15 cbus: retu: drop the unnecessary spinlock_t

In reply to Felipe Balbi

gpiolib functions can sleep, and we already have a mutex on the driver, so drop the spinlock_t and use the mutex.

While at that, also rename irq_lock to mutex since that's not used only for the IRQ path anymore.

---
 drivers/cbus/retu.c |   21 ++++++++-------------
 1 files changed, 8 insertions(+), 13 deletions(-)
drivers/cbus/retu.c +8 -13
index 032864a..82d22b8 100644
@@ -54,8 +54,7 @@
 
 struct retu {
 	/* Device lock */
-	spinlock_t		lock;
-	struct mutex		irq_lock;
+	struct mutex		mutex;
 	struct device		*dev;
 
 	int			irq_base;
@@ -104,15 +103,14 @@ EXPORT_SYMBOL(retu_write_reg);
 void retu_set_clear_reg_bits(unsigned reg, u16 set, u16 clear)
 {
 	struct retu		*retu = the_retu;
-	unsigned long		flags;
 	u16			w;
 
-	spin_lock_irqsave(&retu->lock, flags);
+	mutex_lock(&retu->mutex);
 	w = retu_read_reg(reg);
 	w &= ~clear;
 	w |= set;
 	retu_write_reg(reg, w);
-	spin_unlock_irqrestore(&retu->lock, flags);
+	mutex_unlock(&retu->mutex);
 }
 EXPORT_SYMBOL_GPL(retu_set_clear_reg_bits);
 
@@ -121,7 +119,6 @@ EXPORT_SYMBOL_GPL(retu_set_clear_reg_bits);
 int retu_read_adc(int channel)
 {
 	struct retu		*retu = the_retu;
-	unsigned long		flags;
 	int			res;
 
 	if (!retu)
@@ -130,7 +127,7 @@ int retu_read_adc(int channel)
 	if (channel < 0 || channel > ADC_MAX_CHAN_NUMBER)
 		return -EINVAL;
 
-	spin_lock_irqsave(&retu->lock, flags);
+	mutex_lock(&retu->mutex);
 
 	if ((channel == 8) && retu->is_vilma) {
 		int scr = retu_read_reg(RETU_REG_ADCSCR);
@@ -147,7 +144,7 @@ int retu_read_adc(int channel)
 		retu_write_reg(RETU_REG_ADCR, (1 << 13));
 
 	/* Unlock retu */
-	spin_unlock_irqrestore(&retu->lock, flags);
+	mutex_unlock(&retu->mutex);
 
 	return res;
 }
@@ -215,7 +212,7 @@ static void retu_bus_lock(struct irq_data *data)
 {
 	struct retu		*retu = irq_data_get_irq_chip_data(data);
 
-	mutex_lock(&retu->irq_lock);
+	mutex_lock(&retu->mutex);
 }
 
 static void retu_bus_sync_unlock(struct irq_data *data)
@@ -232,7 +229,7 @@ static void retu_bus_sync_unlock(struct irq_data *data)
 		retu->ack_pending = false;
 	}
 
-	mutex_unlock(&retu->irq_lock);
+	mutex_unlock(&retu->mutex);
 }
 
 static struct irq_chip retu_irq_chip = {
@@ -410,9 +407,7 @@ static int __init retu_probe(struct platform_device *pdev)
 	platform_set_drvdata(pdev, retu);
 	the_retu = retu;
 
-	/* Prepare tasklet */
-	spin_lock_init(&retu->lock);
-	mutex_init(&retu->irq_lock);
+	mutex_init(&retu->mutex);
 
 	irq = platform_get_irq(pdev, 0);
 
Signature · 1 line
1.7.4.rc2
#4 lore raw

PATCH 4/15 cbus: retu: drop unused PFX macro

In reply to Felipe Balbi

That's not used anywhere in the code,
so simply drop it.

---
 drivers/cbus/retu.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)
drivers/cbus/retu.c +0 -1
index 82d22b8..b1c8e57 100644
@@ -50,7 +50,6 @@
 #include "retu.h"
 
 #define RETU_ID			0x01
-#define PFX			"retu: "
 
 struct retu {
 	/* Device lock */
Signature · 1 line
1.7.4.rc2
#5 lore raw

PATCH 5/15 arm: omap: cbus: add IDs for Retu and Tahvo

In reply to Felipe Balbi

Each driver is defining it's own ID. Defining it
on the generic header will allow to pass those
via platform_data.

---
 arch/arm/plat-omap/include/plat/cbus.h |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
arch/arm/plat-omap/include/plat/cbus.h +3 -0
index 1f0e8be..e7ace57 100644
@@ -22,6 +22,9 @@
 #ifndef __PLAT_CBUS_H
 #define __PLAT_CBUS_H
 
+#define CBUS_RETU_DEVICE_ID	0x01
+#define CBUS_TAHVO_DEVICE_ID	0x02
+
 struct cbus_host_platform_data {
 	int	dat_gpio;
 	int	clk_gpio;
Signature · 1 line
1.7.4.rc2
#6 lore raw

PATCH 6/15 arm: omap: pass Retu ID via platform_data

In reply to Felipe Balbi

Instead of hardcoding on the driver, pass
that via platform_data instead.

---
 arch/arm/mach-omap1/board-nokia770.c   |    1 +
 arch/arm/mach-omap2/board-n8x0.c       |    1 +
 arch/arm/plat-omap/include/plat/cbus.h |    1 +
 3 files changed, 3 insertions(+), 0 deletions(-)
arch/arm/mach-omap1/board-nokia770.c +1 -0
index d939370..f2a92b5 100644
@@ -126,6 +126,7 @@ static struct resource retu_resource[] = {
 static struct cbus_retu_platform_data nokia770_retu_data = {
 	.irq_base	= CBUS_RETU_IRQ_BASE,
 	.irq_end	= CBUS_RETU_IRQ_END,
+	.devid		= CBUS_RETU_DEVICE_ID,
 };
 
 static struct platform_device retu_device = {
arch/arm/mach-omap2/board-n8x0.c +1 -0
index 1e4bfb2..e00c0fa 100644
@@ -223,6 +223,7 @@ static struct resource retu_resource[] = {
 static struct cbus_retu_platform_data n8x0_retu_data = {
 	.irq_base	= CBUS_RETU_IRQ_BASE,
 	.irq_end	= CBUS_RETU_IRQ_END,
+	.devid		= CBUS_RETU_DEVICE_ID,
 };
 
 static struct platform_device retu_device = {
arch/arm/plat-omap/include/plat/cbus.h +1 -0
index e7ace57..563b1c2 100644
@@ -34,6 +34,7 @@ struct cbus_host_platform_data {
 struct cbus_retu_platform_data {
 	int	irq_base;
 	int	irq_end;
+	int	devid;
 };
 
 #endif /* __PLAT_CBUS_H */
Signature · 1 line
1.7.4.rc2
#7 lore raw

PATCH 7/15 cbus: retu: use the devid from platform_data

In reply to Felipe Balbi

We are already passing the device ID via
platform_data, all we have to do know is
use it.

---
 drivers/cbus/retu.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)
drivers/cbus/retu.c +5 -4
index b1c8e57..d2326aa 100644
@@ -49,13 +49,13 @@
 #include "cbus.h"
 #include "retu.h"
 
-#define RETU_ID			0x01
-
 struct retu {
 	/* Device lock */
 	struct mutex		mutex;
 	struct device		*dev;
 
+	int			devid;
+
 	int			irq_base;
 	int			irq_end;
 
@@ -81,7 +81,7 @@ static struct retu *the_retu;
 int retu_read_reg(unsigned reg)
 {
 	WARN(!the_retu, "Retu not initialized\n");
-	return cbus_read_reg(RETU_ID, reg);
+	return cbus_read_reg(the_retu->devid, reg);
 }
 EXPORT_SYMBOL(retu_read_reg);
 
@@ -95,7 +95,7 @@ EXPORT_SYMBOL(retu_read_reg);
 void retu_write_reg(unsigned reg, u16 val)
 {
 	WARN(!the_retu, "Retu not initialized\n");
-	cbus_write_reg(RETU_ID, reg, val);
+	cbus_write_reg(the_retu->devid, reg, val);
 }
 EXPORT_SYMBOL(retu_write_reg);
 
@@ -413,6 +413,7 @@ static int __init retu_probe(struct platform_device *pdev)
 	retu->irq = irq;
 	retu->irq_base = pdata->irq_base;
 	retu->irq_end = pdata->irq_end;
+	retu->devid = pdata->devid;
 
 	retu_irq_init(retu);
 
Signature · 1 line
1.7.4.rc2
#8 lore raw

PATCH 8/15 cbus: retu: introduce internal read/write functions

In reply to Felipe Balbi

We already have the retu structure in others parts of the retu driver, so instead of accessing the_retu all over the place, we can start combining those accesses.

While at that fix a kerneldoc comment on
retu_write_reg()

---
 drivers/cbus/retu.c |   27 ++++++++++++++++++++++++---
 1 files changed, 24 insertions(+), 3 deletions(-)
drivers/cbus/retu.c +24 -3
index d2326aa..7e4b7e5 100644
@@ -73,6 +73,27 @@ struct retu {
 static struct retu *the_retu;
 
 /**
+ * __retu_read_reg - Read a value from a register in Retu
+ * @retu: pointer to retu structure
+ * @reg: the register address to read from
+ */
+static int __retu_read_reg(struct retu *retu, unsigned reg)
+{
+	return cbus_read_reg(retu->devid, reg);
+}
+
+/**
+ * __retu_write_reg - Writes a value to a register in Retu
+ * @retu: pointer to retu structure
+ * @reg: the register address to write to
+ * @val: the value to write to the register
+ */
+static void __retu_write_reg(struct retu *retu, unsigned reg, u16 val)
+{
+	cbus_write_reg(retu->devid, reg, val);
+}
+
+/**
  * retu_read_reg - Read a value from a register in Retu
  * @reg: the register to read from
  *
@@ -81,21 +102,21 @@ static struct retu *the_retu;
 int retu_read_reg(unsigned reg)
 {
 	WARN(!the_retu, "Retu not initialized\n");
-	return cbus_read_reg(the_retu->devid, reg);
+	return __retu_read_reg(the_retu, reg);
 }
 EXPORT_SYMBOL(retu_read_reg);
 
 /**
  * retu_write_reg - Write a value to a register in Retu
  * @reg: the register to write to
- * @reg: the value to write to the register
+ * @val: the value to write to the register
  *
  * This function writes a value to the specified register
  */
 void retu_write_reg(unsigned reg, u16 val)
 {
 	WARN(!the_retu, "Retu not initialized\n");
-	cbus_write_reg(the_retu->devid, reg, val);
+	__retu_write_reg(the_retu, reg, val);
 }
 EXPORT_SYMBOL(retu_write_reg);
 
Signature · 1 line
1.7.4.rc2
#9 lore raw

PATCH 9/15 cbus: retu: search and replace

In reply to Felipe Balbi

replace all occurrences of retu_read_reg
and retu_write_reg with the internal functions
__retu_read_reg and __retu_write_reg on retu.c

Achieved with the following vim command:

:%s/\<retu_\(read\|write\)_reg(/__retu_\1_reg(retu, /gc

---
 drivers/cbus/retu.c |   41 +++++++++++++++++++++++------------------
 1 files changed, 23 insertions(+), 18 deletions(-)
drivers/cbus/retu.c +23 -18
index 7e4b7e5..c798b58 100644
@@ -126,10 +126,10 @@ void retu_set_clear_reg_bits(unsigned reg, u16 set, u16 clear)
 	u16			w;
 
 	mutex_lock(&retu->mutex);
-	w = retu_read_reg(reg);
+	w = __retu_read_reg(retu, reg);
 	w &= ~clear;
 	w |= set;
-	retu_write_reg(reg, w);
+	__retu_write_reg(retu, reg, w);
 	mutex_unlock(&retu->mutex);
 }
 EXPORT_SYMBOL_GPL(retu_set_clear_reg_bits);
@@ -150,18 +150,18 @@ int retu_read_adc(int channel)
 	mutex_lock(&retu->mutex);
 
 	if ((channel == 8) && retu->is_vilma) {
-		int scr = retu_read_reg(RETU_REG_ADCSCR);
-		int ch = (retu_read_reg(RETU_REG_ADCR) >> 10) & 0xf;
+		int scr = __retu_read_reg(retu, RETU_REG_ADCSCR);
+		int ch = (__retu_read_reg(retu, RETU_REG_ADCR) >> 10) & 0xf;
 		if (((scr & 0xff) != 0) && (ch != 8))
-			retu_write_reg (RETU_REG_ADCSCR, (scr & ~0xff));
+			__retu_write_reg(retu, RETU_REG_ADCSCR, (scr & ~0xff));
 	}
 
 	/* Select the channel and read result */
-	retu_write_reg(RETU_REG_ADCR, channel << 10);
-	res = retu_read_reg(RETU_REG_ADCR) & 0x3ff;
+	__retu_write_reg(retu, RETU_REG_ADCR, channel << 10);
+	res = __retu_read_reg(retu, RETU_REG_ADCR) & 0x3ff;
 
 	if (retu->is_vilma)
-		retu_write_reg(RETU_REG_ADCR, (1 << 13));
+		__retu_write_reg(retu, RETU_REG_ADCR, (1 << 13));
 
 	/* Unlock retu */
 	mutex_unlock(&retu->mutex);
@@ -179,8 +179,8 @@ static irqreturn_t retu_irq_handler(int irq, void *_retu)
 	u16			idr;
 	u16			imr;
 
-	idr = retu_read_reg(RETU_REG_IDR);
-	imr = retu_read_reg(RETU_REG_IMR);
+	idr = __retu_read_reg(retu, RETU_REG_IDR);
+	imr = __retu_read_reg(retu, RETU_REG_IMR);
 	idr &= ~imr;
 
 	if (!idr) {
@@ -240,12 +240,12 @@ static void retu_bus_sync_unlock(struct irq_data *data)
 	struct retu		*retu = irq_data_get_irq_chip_data(data);
 
 	if (retu->mask_pending) {
-		retu_write_reg(RETU_REG_IMR, retu->mask);
+		__retu_write_reg(retu, RETU_REG_IMR, retu->mask);
 		retu->mask_pending = false;
 	}
 
 	if (retu->ack_pending) {
-		retu_write_reg(RETU_REG_IDR, retu->ack);
+		__retu_write_reg(retu, RETU_REG_IDR, retu->ack);
 		retu->ack_pending = false;
 	}
 
@@ -309,10 +309,15 @@ static void retu_irq_exit(struct retu *retu)
  */
 static void retu_power_off(void)
 {
+	struct retu		*retu = the_retu;
+	unsigned		reg;
+
+	reg = __retu_read_reg(retu, RETU_REG_CC1);
+
 	/* Ignore power button state */
-	retu_write_reg(RETU_REG_CC1, retu_read_reg(RETU_REG_CC1) | 2);
+	__retu_write_reg(retu, RETU_REG_CC1, reg | 2);
 	/* Expire watchdog immediately */
-	retu_write_reg(RETU_REG_WATCHDOG, 0);
+	__retu_write_reg(retu, RETU_REG_WATCHDOG, 0);
 	/* Wait for poweroff*/
 	for (;;);
 }
@@ -438,7 +443,7 @@ static int __init retu_probe(struct platform_device *pdev)
 
 	retu_irq_init(retu);
 
-	rev = retu_read_reg(RETU_REG_ASICR) & 0xff;
+	rev = __retu_read_reg(retu, RETU_REG_ASICR) & 0xff;
 	if (rev & (1 << 7))
 		retu->is_vilma = true;
 
@@ -447,7 +452,7 @@ static int __init retu_probe(struct platform_device *pdev)
 			(rev >> 4) & 0x07, rev & 0x0f);
 
 	/* Mask all RETU interrupts */
-	retu_write_reg(RETU_REG_IMR, 0xffff);
+	__retu_write_reg(retu, RETU_REG_IMR, 0xffff);
 
 	ret = request_threaded_irq(irq, NULL, retu_irq_handler, 0,
 			  "retu", retu);
@@ -470,7 +475,7 @@ static int __init retu_probe(struct platform_device *pdev)
 	return 0;
 
 err2:
-	retu_write_reg(RETU_REG_IMR, 0xffff);
+	__retu_write_reg(retu, RETU_REG_IMR, 0xffff);
 	free_irq(irq, retu);
 
 err1:
@@ -489,7 +494,7 @@ static int __exit retu_remove(struct platform_device *pdev)
 	irq = platform_get_irq(pdev, 0);
 
 	/* Mask all RETU interrupts */
-	retu_write_reg(RETU_REG_IMR, 0xffff);
+	__retu_write_reg(retu, RETU_REG_IMR, 0xffff);
 	free_irq(irq, retu);
 	retu_irq_exit(retu);
 	kfree(retu);
Signature · 1 line
1.7.4.rc2
#10 lore raw

PATCH 10/15 cbus: retu: pwrbutton: save device pointer on our structure

In reply to Felipe Balbi

We will start passing our device pointer to
read/write functions exported from retu so
we need to save the device pointer on our
context structure.

---
 drivers/cbus/retu-pwrbutton.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
drivers/cbus/retu-pwrbutton.c +2 -0
index 593a73a..77c655d 100644
@@ -47,6 +47,7 @@
 
 struct retu_pwrbutton {
 	struct input_dev	*idev;
+	struct device		*dev;
 
 	int			state;
 	int			irq;
@@ -83,6 +84,7 @@ static int __init retubutton_probe(struct platform_device *pdev)
 		goto err0;
 	}
 
+	pwr->dev = &pdev->dev;
 	pwr->irq = platform_get_irq(pdev, 0);
 	platform_set_drvdata(pdev, pwr);
 
Signature · 1 line
1.7.4.rc2
maintainer
#11 lore raw
In reply to Felipe Balbi

Hi,

Quoted 19 lines · Felipe Balbi

We're almost there. retu.c looks very nice now.

The bulk effort is now on its children:

. retu-headset.c
. should use jack framework
. should use dev_pm_ops
. some cleanups wouldn't hurt

. retu-rtc.c
. needs suspend/resume (?)

. retu-wdt.c
. needs suspend/resume (?)

patches also available at [1] for convenience

[1] git://gitorious.org/usb/usb.git cbus

Quoted 11 lines

Felipe Balbi (15):
cbus: retu: drop retu_get_status
cbus: retu: replace BUG_ON with WARN
cbus: retu: drop the unnecessary spinlock_t
cbus: retu: drop unused PFX macro
arm: omap: cbus: add IDs for Retu and Tahvo
arm: omap: pass Retu ID via platform_data
cbus: retu: use the devid from platform_data
cbus: retu: introduce internal read/write functions
cbus: retu: search and replace
cbus: retu: pwrbutton: save device pointer on our structure

Looks like some did not make it to the list. But pulled and did a git reset --hard at the patch above.

Quoted 1 line

cbus: retu: pass the child device pointer to all retu functions

As based on a quick test this one will oops:

[    2.925170] Internal error: Oops: 5 [#1] SMP
[    2.929656] last sysfs file:
[    2.932800] Modules linked in:
[    2.936035] CPU: 0    Not tainted  (2.6.38-rc4-00101-gbbb5d46 #113)
[    2.942657] PC is at retu_write_reg+0x8/0x24
[    2.947143] LR is at _retu_modify_counter+0x28/0x34
[    2.952301] pc : [<c0329ad4>]    lr : [<c032a23c>]    psr: a0000013
[    2.952331] sp : c7825ee8  ip : 22222222  fp : 00000000
[    2.964355] r10: 00000000  r9 : 00000000  r8 : c0b4e6f0
[    2.969848] r7 : c05f5598  r6 : 00000000  r5 : 0000003f  r4 : 00000017
[    2.976715] r3 : c0b4e6f0  r2 : 0000003f  r1 : 00000017  r0 : 00000000
[    2.983581] Flags: NzCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment kernel
[    2.991271] Control: 00c5387d  Table: 80004000  DAC: 00000017
[    2.997314] Process swapper (pid: 1, stack limit = 0xc78242f8)
[    3.003448] Stack: (0xc7825ee8 to 0xc7826000)
[    3.008056] 5ee0:                   c05f5598 0000003f 00000000 c032a23c c05f5598 c032a278
[    3.016693] 5f00: c7a96ea0 c7898008 00000000 c002ceb0 c7898008 c7898008 c05f55ac c7a96f20
[    3.025299] 5f20: c05e8b60 c0296c40 c7898008 c0295da8 c7898008 c789803c c05f55ac c0295ed0
[    3.033905] 5f40: 00000000 c0295e68 c05f55ac c02955c8 c7819658 c78bb790 c05f5598 c05f55ac
[    3.042541] 5f60: c05f55ac c0294efc c0532916 00000468 00000000 c05f5598 c059aaf8 c05f55ac
[    3.051147] 5f80: 00000013 c002cdb4 00000000 c02961c8 c05f5598 c059aaf8 c059aaf0 00000013
[    3.059753] 5fa0: c002cdb4 c0297048 c0034930 c059aaf8 c059aaf0 c0052554 00000000 00000000
[    3.068389] 5fc0: c0500122 000001a2 c059aaf8 c0034930 c059aaf8 c059aaf0 00000013 00000000
[    3.076995] 5fe0: 00000000 c00084f4 00000000 c00083a4 c005dd64 c005dd64 ffffffff ffffffff
[    3.085632] [<c0329ad4>] (retu_write_reg+0x8/0x24) from [<c032a23c>] (_retu_modify_counter+0x28/0x34)
[    3.095367] [<c032a23c>] (_retu_modify_counter+0x28/0x34) from [<c032a278>] (retu_modify_counter+0x30/0x44)
[    3.105651] [<c032a278>] (retu_modify_counter+0x30/0x44) from [<c002ceb0>] (retu_wdt_probe+0xe8/0x160)
[    3.115447] [<c002ceb0>] (retu_wdt_probe+0xe8/0x160) from [<c0296c40>] (platform_drv_probe+0x18/0x
[    3.125183] [<c0296c40>] (platform_drv_probe+0x18/0x1c) from [<c0295da8>] (driver_probe_device+0xc8/0x188)
[    3.135375] [<c0295da8>] (driver_probe_device+0xc8/0x188) from [<c0295ed0>] (__driver_attach+0x68/0x8c)
[    3.145263] [<c0295ed0>] (__driver_attach+0x68/0x8c) from [<c02955c8>] (bus_for_each_dev+0x44/0x74)
[    3.154815] [<c02955c8>] (bus_for_each_dev+0x44/0x74) from [<c0294efc>] (bus_add_driver+0xa0/0x228)
[    3.164337] [<c0294efc>] (bus_add_driver+0xa0/0x228) from [<c02961c8>] (driver_register+0xa8/0x130)
[    3.173889] [<c02961c8>] (driver_register+0xa8/0x130) from [<c0297048>] (platform_driver_probe+0x18/0x8c)
[    3.183990] [<c0297048>] (platform_driver_probe+0x18/0x8c) from [<c0052554>] (do_one_initcall+0xc8/0x1a0)
[    3.194061] [<c0052554>] (do_one_initcall+0xc8/0x1a0) from [<c00084f4>] (kernel_init+0x150/0x218)
[    3.203430] [<c00084f4>] (kernel_init+0x150/0x218) from [<c005dd64>] (kernel_thread_exit+0x0/0x8)
[    3.212768] Code: e8bd41f0 ea035b8e e92d4070 e1a04001 (e5900000)
[    3.219451] ---[ end trace 5cc53738ab810194 ]---
Quoted 4 lines

cbus: retu: headset: don't save pdev pointer
cbus: retu: replace EXPORT_SYMBOL with EXPORT_SYMBOL_GPL
cbus: retu: tabify retu initialization
cbus: retu: set pm_power_off to NULL when removing retu

So left these out too.

Tony

#12 lore raw

Hi,

Quoted 33 lines · Tony Lindgren

As based on a quick test this one will oops:

[    2.925170] Internal error: Oops: 5 [#1] SMP
[    2.929656] last sysfs file:
[    2.932800] Modules linked in:
[    2.936035] CPU: 0    Not tainted  (2.6.38-rc4-00101-gbbb5d46 #113)
[    2.942657] PC is at retu_write_reg+0x8/0x24
[    2.947143] LR is at _retu_modify_counter+0x28/0x34
[    2.952301] pc : [<c0329ad4>]    lr : [<c032a23c>]    psr: a0000013
[    2.952331] sp : c7825ee8  ip : 22222222  fp : 00000000
[    2.964355] r10: 00000000  r9 : 00000000  r8 : c0b4e6f0
[    2.969848] r7 : c05f5598  r6 : 00000000  r5 : 0000003f  r4 : 00000017
[    2.976715] r3 : c0b4e6f0  r2 : 0000003f  r1 : 00000017  r0 : 00000000
[    2.983581] Flags: NzCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment kernel
[    2.991271] Control: 00c5387d  Table: 80004000  DAC: 00000017
[    2.997314] Process swapper (pid: 1, stack limit = 0xc78242f8)
[    3.003448] Stack: (0xc7825ee8 to 0xc7826000)
[    3.008056] 5ee0:                   c05f5598 0000003f 00000000 c032a23c c05f5598 c032a278
[    3.016693] 5f00: c7a96ea0 c7898008 00000000 c002ceb0 c7898008 c7898008 c05f55ac c7a96f20
[    3.025299] 5f20: c05e8b60 c0296c40 c7898008 c0295da8 c7898008 c789803c c05f55ac c0295ed0
[    3.033905] 5f40: 00000000 c0295e68 c05f55ac c02955c8 c7819658 c78bb790 c05f5598 c05f55ac
[    3.042541] 5f60: c05f55ac c0294efc c0532916 00000468 00000000 c05f5598 c059aaf8 c05f55ac
[    3.051147] 5f80: 00000013 c002cdb4 00000000 c02961c8 c05f5598 c059aaf8 c059aaf0 00000013
[    3.059753] 5fa0: c002cdb4 c0297048 c0034930 c059aaf8 c059aaf0 c0052554 00000000 00000000
[    3.068389] 5fc0: c0500122 000001a2 c059aaf8 c0034930 c059aaf8 c059aaf0 00000013 00000000
[    3.076995] 5fe0: 00000000 c00084f4 00000000 c00083a4 c005dd64 c005dd64 ffffffff ffffffff
[    3.085632] [<c0329ad4>] (retu_write_reg+0x8/0x24) from [<c032a23c>] (_retu_modify_counter+0x28/0x34)
[    3.095367] [<c032a23c>] (_retu_modify_counter+0x28/0x34) from [<c032a278>] (retu_modify_counter+0x30/0x44)
[    3.105651] [<c032a278>] (retu_modify_counter+0x30/0x44) from [<c002ceb0>] (retu_wdt_probe+0xe8/0x160)
[    3.115447] [<c002ceb0>] (retu_wdt_probe+0xe8/0x160) from [<c0296c40>] (platform_drv_probe+0x18/0x
[    3.125183] [<c0296c40>] (platform_drv_probe+0x18/0x1c) from [<c0295da8>] (driver_probe_device+0xc8/0x188)
[    3.135375] [<c0295da8>] (driver_probe_device+0xc8/0x188) from [<c0295ed0>] (__driver_attach+0x68/0x8c)
[    3.145263] [<c0295ed0>] (__driver_attach+0x68/0x8c) from [<c02955c8>] (bus_for_each_dev+0x44/0x74)
Quoted 8 lines
[    3.154815] [<c02955c8>] (bus_for_each_dev+0x44/0x74) from [<c0294efc>] (bus_add_driver+0xa0/0x228)
[    3.164337] [<c0294efc>] (bus_add_driver+0xa0/0x228) from [<c02961c8>] (driver_register+0xa8/0x130)
[    3.173889] [<c02961c8>] (driver_register+0xa8/0x130) from [<c0297048>] (platform_driver_probe+0x18/0x8c)
[    3.183990] [<c0297048>] (platform_driver_probe+0x18/0x8c) from [<c0052554>] (do_one_initcall+0xc8/0x1a0)
[    3.194061] [<c0052554>] (do_one_initcall+0xc8/0x1a0) from [<c00084f4>] (kernel_init+0x150/0x218)
[    3.203430] [<c00084f4>] (kernel_init+0x150/0x218) from [<c005dd64>] (kernel_thread_exit+0x0/0x8)
[    3.212768] Code: e8bd41f0 ea035b8e e92d4070 e1a04001 (e5900000)
[    3.219451] ---[ end trace 5cc53738ab810194 ]---

found the problem, commit 6b8074b00d90b191227dc875b90b272c51f7d6eb never got to the point of saving struct device * in struct retu_wdt_dev.

Since it was there already, I was assuming it was working. Silly mistake. The remaining patches are coming in a few minutes.

Signature · 1 line
balbi