Em Dom, 2009-05-03 às 20:53 +0300, Ilya Petrov escreveu:
> Hi!
> 
> Take a look at these two patches.
> ezx-eoc patch adds functions to check usb/ac connected state
> ezx.c patch adds pda-power platform device to use this functions to
> control charge process and tell usb/ac connection state to userspace via sysfs

See my comments. :)

> Signed-off-by: Ilya Petrov <ilya.muro...@gmail.com>
> diff --git a/drivers/i2c/chips/ezx-eoc.c b/drivers/i2c/chips/ezx-eoc.c
> index 1d32676..7e23322 100644
> --- a/drivers/i2c/chips/ezx-eoc.c
> +++ b/drivers/i2c/chips/ezx-eoc.c
> @@ -69,6 +69,8 @@
>  #define EMU_FET_OVRD_MASK           0x00000400
>  #define EMU_FET_CTRL_MASK           0x00000800
>  
> +static int sence_reg = 0;
> +
>  static struct i2c_client *eoc_i2c_client;
>  static const struct i2c_device_id eoc_id[] = {
>         { "ezx-eoc", 0 },
> @@ -76,6 +78,7 @@ static const struct i2c_device_id eoc_id[] = {
>  };
>  MODULE_DEVICE_TABLE(i2c, eoc_id);
>  struct work_struct work;
> +struct work_struct read_work;
>  
>  int eoc_reg_read(char reg, unsigned int *val)
>  {
> @@ -189,15 +192,31 @@ static irqreturn_t eoc_irq(int irq, void *arg)
>         return IRQ_HANDLED;
>  }
>  
> +static void eoc_read_sense(struct work_struct *_eoc)
> +{
> +        eoc_reg_read(EOC_REG_INT_SENSE, &sence_reg);
> +}
> +
> +int eoc_cable_connected(int cable)
> +{
> +
> +       schedule_work(&read_work);
> +
> +       if (!(sence_reg & 0xf))
> +               return 0;
> +
> +       return sence_reg & (1<<cable);
> +}

Not a good idea to do this polling, or to add another work_struct.
EOC will interrupt PXA when you connect the cable. With your code you
always get the previous state, not the current one. You should use the
main IRQ and the main work_struct to update the cable connection state,
this way you will get the correct state at any time.

The softirq handler still needs to be written, as currently it only
printk the IRQ names.

-- 
Daniel Ribeiro


Reply via email to