From: Lars-Peter Clausen <lars@metafoo.de>
To: anish kumar <anish198519851985@gmail.com>
Cc: cw00.choi@samsung.com, myungjoo.ham@samsung.com, jic23@cam.ac.uk,
linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org,
anish kumar <anish.singh@samsung.com>
Subject: Re: Extcon: adc_jack: adc-jack driver to support 3.5 pi or simliar devices
Date: Mon, 06 Aug 2012 19:45:02 +0200 [thread overview]
Message-ID: <5020029E.6090607@metafoo.de> (raw)
In-Reply-To: <1344272343-23953-1-git-send-email-anish198519851985@gmail.com>
On 08/06/2012 06:59 PM, anish kumar wrote:
> From: anish kumar <anish198519851985@gmail.com>
>
> External connector devices that decides connection information based on
> ADC values may use adc-jack device driver. The user simply needs to
> provide a table of adc range and connection states. Then, extcon
> framework will automatically notify others.
>
> Changes in this version:
> added Lars-Peter Clausen suggested changes:
> Using macros to get rid of boiler plate code such as devm_kzalloc
> and module_platform_driver.Other changes suggested are related to
> coding guidelines.
Looks mostly good.
>
> Signed-off-by: anish kumar <anish.singh@samsung.com>
> Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
> ---
> [...]
> +
> +static int adc_jack_probe(struct platform_device *pdev)
__devinit
> +{
> [...]
> +
> + data->irq = platform_get_irq(pdev, 0);
platform_get_irq may return an error, you should check that.
> +
> + err = request_any_context_irq(data->irq, adc_jack_irq_thread,
> + pdata->irq_flags, pdata->name, data);
> +
> + if (err) {
> + dev_err(&pdev->dev, "error: irq %d\n", data->irq);
> + err = -EINVAL;
> + goto err_irq;
> + }
> +
> + goto out;
> +
> +err_irq:
> + extcon_dev_unregister(&data->edev);
> +err_initwork:
> + cancel_delayed_work_sync(&data->handler);
It does not hurt, but since the work is only scheduled from the interrupt
handler this should not be necessary.
> +err_alloc:
> + kfree(data);
Since it is allocated with devm_kzalloc now you shouldn't manually free it.
> +out:
> + return err;
> +}
> +
> +static int __devexit adc_jack_remove(struct platform_device *pdev)
> +{
> + struct adc_jack_data *data = platform_get_drvdata(pdev);
> +
> + extcon_dev_unregister(&data->edev);
> + if (data->irq)
Since the IRQ is now requested unconditionally this check can also be remove.
> + free_irq(data->irq, data);
Since you access the extcon device from within the IRQ handler it makes
sense to free the IRQ handler before the extcon device.
> +
> + return 0;
> +}
> +
[...]
> diff --git a/include/linux/extcon/adc_jack.h b/include/linux/extcon/adc_jack.h
> new file mode 100644
> index 0000000..ca4d1cd
> --- /dev/null
> +++ b/include/linux/extcon/adc_jack.h
> @@ -0,0 +1,77 @@
> +/*
> [...]
> +struct adc_jack_pdata {
> + const char *name;
> + const char *consumer_channel;
> + /*
> + * NULL if standard extcon names are used.
> + * The last entry should be NULL
> + */
> + const char **cable_names;
> + /* The last entry's state should be 0 */
> + struct adc_jack_cond *adc_condition;
> +
> + unsigned long irq_flags;
> + unsigned long handling_delay_ms; /* in ms */
> +
> + /* When we have ADC subsystem, this can be generalized. */
> + int (*get_adc)(u32 *value);
Huh, looks like it sneaked in again.
> +};
> +
> +#endif /* _EXTCON_ADC_JACK_H */
prev parent reply other threads:[~2012-08-06 17:45 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-06 16:59 anish kumar
2012-08-06 17:05 ` Maarten Lankhorst
2012-08-06 17:06 ` [PATCH V1]Extcon: adc_jack: adc-jack driver to support 3.5 pi or simliar devices anish kumar
2012-08-06 17:45 ` Lars-Peter Clausen [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5020029E.6090607@metafoo.de \
--to=lars@metafoo.de \
--cc=anish.singh@samsung.com \
--cc=anish198519851985@gmail.com \
--cc=cw00.choi@samsung.com \
--cc=jic23@cam.ac.uk \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=myungjoo.ham@samsung.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).