On Tue, May 15, 2007 at 05:36:04PM +0800, matt_hsu wrote:
> Log:
>       HXD8: Input device should be registered before request_irq.
>                       For HXD8, kernel would enter oops handling if 
> request_irq before

Thanks.  This took me some time to apply, since I had to fix the error
path.   IF you change the order of device initialization, you also have
to change the order of the error path.

Please see attached patch which I'll now apply


> input device.  

> Index: linux-2.6.21/drivers/i2c/chips/pcf50606.c
> ===================================================================
> --- linux-2.6.21.orig/drivers/i2c/chips/pcf50606.c    2007-05-15 
> 13:20:12.000000000 +0800
> +++ linux-2.6.21/drivers/i2c/chips/pcf50606.c 2007-05-15 13:22:07.000000000 
> +0800
> @@ -1613,6 +1613,24 @@
>  
>       /* create virtual charger 'device' */
>  
> +     /* input device registration */
> +     data->input_dev = input_allocate_device();
> +     if (!data->input_dev)
> +             goto exit_sysfs;
> +
> +     data->input_dev->name = "FIC Neo1973 PMU events";
> +     data->input_dev->phys = "FIXME";
> +     data->input_dev->id.bustype = BUS_I2C;
> +     data->input_dev->cdev.dev = &new_client->dev;
> +
> +     data->input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_PWR);
> +     set_bit(KEY_POWER, data->input_dev->keybit);
> +     set_bit(KEY_POWER2, data->input_dev->keybit);
> +     set_bit(KEY_BATTERY, data->input_dev->keybit);
> +
> +     input_register_device(data->input_dev);
> +     
> +
>       /* register power off handler with core power management */
>       pm_power_off = &pcf50606_go_standby;
>  
> @@ -1671,22 +1689,6 @@
>               backlight_update_status(data->backlight);
>       }
>  
> -     data->input_dev = input_allocate_device();
> -     if (!data->input_dev)
> -             goto exit_pwm;
> -
> -     data->input_dev->name = "FIC Neo1973 PMU events";
> -     data->input_dev->phys = "FIXME";
> -     data->input_dev->id.bustype = BUS_I2C;
> -     data->input_dev->cdev.dev = &new_client->dev;
> -
> -     data->input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_PWR);
> -     set_bit(KEY_POWER, data->input_dev->keybit);
> -     set_bit(KEY_POWER2, data->input_dev->keybit);
> -     set_bit(KEY_BATTERY, data->input_dev->keybit);
> -
> -     input_register_device(data->input_dev);
> -
>       apm_get_power_status = pcf50606_get_power_status;
>  
>  #ifdef CONFIG_MACH_NEO1973_GTA01


-- 
- Harald Welte <[EMAIL PROTECTED]>                      http://openmoko.org/
============================================================================
Software for the world's first truly open Free Software mobile phone
Index: gta01-pcf50606.patch
===================================================================
--- gta01-pcf50606.patch	(revision 1925)
+++ gta01-pcf50606.patch	(working copy)
@@ -4,7 +4,7 @@
 ===================================================================
 --- /dev/null
 +++ linux-2.6.21-moko/drivers/i2c/chips/pcf50606.c
-@@ -0,0 +1,1925 @@
+@@ -0,0 +1,1928 @@
 +/* Philips PCF50606 Power Management Unit (PMU) driver
 + *
 + * (C) 2006 by OpenMoko, Inc.
@@ -1620,6 +1620,23 @@
 +
 +	/* create virtual charger 'device' */
 +
++	/* input device registration */
++	data->input_dev = input_allocate_device();
++	if (!data->input_dev)
++		goto exit_sysfs;
++
++	data->input_dev->name = "FIC Neo1973 PMU events";
++	data->input_dev->phys = "FIXME";
++	data->input_dev->id.bustype = BUS_I2C;
++	data->input_dev->cdev.dev = &new_client->dev;
++
++	data->input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_PWR);
++	set_bit(KEY_POWER, data->input_dev->keybit);
++	set_bit(KEY_POWER2, data->input_dev->keybit);
++	set_bit(KEY_BATTERY, data->input_dev->keybit);
++
++	input_register_device(data->input_dev);
++	
 +	/* register power off handler with core power management */
 +	pm_power_off = &pcf50606_go_standby;
 +
@@ -1631,7 +1648,7 @@
 +	err = request_irq(irq, pcf50606_irq, SA_INTERRUPT,
 +			  "pcf50606", data);
 +	if (err < 0)
-+		goto exit_sysfs;
++		goto exit_input;
 +
 +	set_irq_type(irq, IRQT_FALLING);
 +
@@ -1678,22 +1695,6 @@
 +		backlight_update_status(data->backlight);
 +	}
 +
-+	data->input_dev = input_allocate_device();
-+	if (!data->input_dev)
-+		goto exit_pwm;
-+
-+	data->input_dev->name = "FIC Neo1973 PMU events";
-+	data->input_dev->phys = "FIXME";
-+	data->input_dev->id.bustype = BUS_I2C;
-+	data->input_dev->cdev.dev = &new_client->dev;
-+
-+	data->input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_PWR);
-+	set_bit(KEY_POWER, data->input_dev->keybit);
-+	set_bit(KEY_POWER2, data->input_dev->keybit);
-+	set_bit(KEY_BATTERY, data->input_dev->keybit);
-+
-+	input_register_device(data->input_dev);
-+
 +	apm_get_power_status = pcf50606_get_power_status;
 +
 +#ifdef CONFIG_MACH_NEO1973_GTA01
@@ -1730,6 +1731,8 @@
 +		rtc_device_unregister(pcf50606_global->rtc);
 +exit_irq:
 +	free_irq(pcf50606_global->irq, pcf50606_global);
++exit_input:
++	input_unregister_device(pcf->input_dev);
 +exit_sysfs:
 +	pm_power_off = NULL;
 +	sysfs_remove_group(&new_client->dev.kobj, &pcf_attr_group);

Reply via email to