Re: [PATCH try #4] Input/Joystick Driver: add support AD7142 joystick driver

From: Dmitry Torokhov
Date: Wed Oct 17 2007 - 12:12:56 EST


Hi Bryan,

On 10/17/07, Bryan Wu <bryan.wu@xxxxxxxxxx> wrote:
> Subject: [PATCH try #4] Input/Joystick Driver: add support AD7142 joystick driver
>

My comments are in addition to Jean's:

> +
> +static void ad7142_close(struct input_dev *dev)
> +{
> + struct ad7142_data *data = input_get_drvdata(dev);
> + struct i2c_client *client = &data->client;
> + unsigned short value;
> +

I think you need disable_irq() here

> + flush_scheduled_work();
> +
> + /*
> + * Turn AD7142 to full shutdown mode
> + * No CDC conversions
> + */
> + value = 0x0001;
> + ad7142_i2c_write(client, PWRCONVCTL, &value, 1);

and enable_irq() here. This way you can be sure that you will not
re-arm the work between flush_scheduled_work() and shutting off the
controller.

> +
> +static int ad7142_attach(struct i2c_adapter *adap)
> +{
> + return i2c_probe(adap, &addr_data, &ad7142_probe);
> +}
> +
> +static int ad7142_detach(struct i2c_client *client)
> +{
> + int rc;
> +
> + free_irq(CONFIG_BFIN_JOYSTICK_IRQ_PFX, ad7142_interrupt);
> +
> + flush_scheduled_work();
> +
> + rc = i2c_detach_client(client);
> + if (!rc)
> + kfree(i2c_get_clientdata(client));
> + return rc;
> +}
> +
> +
> +static int __init ad7142_init(void)
> +{
> + return i2c_add_driver(&ad7142_driver);
> +}
> +
> +static void __exit ad7142_exit(void)
> +{
> + i2c_del_driver(&ad7142_driver);
> +}
> +
> +module_init(ad7142_init);
> +module_exit(ad7142_exit);

Where did input_unregister_device() go? It still needs to be somewhere...

--
Dmitry
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/