Re: [PATCH] [PATCH V4]Extcon: adc_jack: adc-jack driver to support 3.5 pi or simliar devices

2012-08-10 Thread anish kumar
Hello Jonathan,

Please refer the latest patch.

Thanks,
On Fri, 2012-08-10 at 22:01 +0100, Jonathan Cameron wrote:
> On 08/08/2012 02:04 AM, anish kumar wrote:
> > From: anish kumar 
> >
> > 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.
> 
> Couple of utterly trivial points inline.
> Otherwise looks fine to me.
> >
> > Changes in V1:
> > 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.
> >
> > Changes in V2:
> > Removed some unnecessary checks and changed the way we are un-regitering
> > extcon and freeing the irq while removing.
> >
> > Changes in V3:
> > Renamed the files to comply with extcon naming.
> >
> > Changes in this version:
> > Added the cancel_work_sync during removing of driver.
> >
> > Reviewed-by: Lars-Peter Clausen 
> > Signed-off-by: anish kumar 
> > Signed-off-by: MyungJoo Ham 
> Don't these normally go in order of when they occured?
> Hence first sign offs are the authors, any acks / reviewed-bys
> after that and final sign offs for the merges.
> > ---
> >  drivers/extcon/Kconfig |5 +
> >  drivers/extcon/Makefile|1 +
> >  drivers/extcon/extcon-adc-jack.c   |  194 
> > 
> >  include/linux/extcon/extcon-adc-jack.h |   73 
> >  4 files changed, 273 insertions(+), 0 deletions(-)
> >  create mode 100644 drivers/extcon/extcon-adc-jack.c
> >  create mode 100644 include/linux/extcon/extcon-adc-jack.h
> >
> > diff --git a/drivers/extcon/Kconfig b/drivers/extcon/Kconfig
> > index e175c8e..596e277 100644
> > --- a/drivers/extcon/Kconfig
> > +++ b/drivers/extcon/Kconfig
> > @@ -21,6 +21,11 @@ config EXTCON_GPIO
> >   Say Y here to enable GPIO based extcon support. Note that GPIO
> >   extcon supports single state per extcon instance.
> >
> > +config EXTCON_ADC_JACK
> > +tristate "ADC Jack extcon support"
> > +help
> > +  Say Y here to enable extcon device driver based on ADC values.
> > +
> >  config EXTCON_MAX77693
> > tristate "MAX77693 EXTCON Support"
> > depends on MFD_MAX77693
> > diff --git a/drivers/extcon/Makefile b/drivers/extcon/Makefile
> > index 88961b3..bc7111e 100644
> > --- a/drivers/extcon/Makefile
> > +++ b/drivers/extcon/Makefile
> > @@ -4,6 +4,7 @@
> >
> >  obj-$(CONFIG_EXTCON)   += extcon_class.o
> >  obj-$(CONFIG_EXTCON_GPIO)  += extcon_gpio.o
> > +obj-$(CONFIG_EXTCON_ADC_JACK)   += extcon-adc-jack.o
> >  obj-$(CONFIG_EXTCON_MAX77693)  += extcon-max77693.o
> >  obj-$(CONFIG_EXTCON_MAX8997)   += extcon-max8997.o
> >  obj-$(CONFIG_EXTCON_ARIZONA)   += extcon-arizona.o
> > diff --git a/drivers/extcon/extcon-adc-jack.c 
> > b/drivers/extcon/extcon-adc-jack.c
> > new file mode 100644
> > index 000..cfc8c59
> > --- /dev/null
> > +++ b/drivers/extcon/extcon-adc-jack.c
> > @@ -0,0 +1,194 @@
> > +/*
> > + * drivers/extcon/extcon-adc-jack.c
> > + *
> > + * Analog Jack extcon driver with ADC-based detection capability.
> > + *
> > + * Copyright (C) 2012 Samsung Electronics
> > + * MyungJoo Ham 
> > + *
> > + * Modified for calling to IIO to get adc by 
> > + *
> > + * This program is free software; you can redistribute it and/or modify
> > + * it under the terms of the GNU General Public License version 2 as
> > + * published by the Free Software Foundation.
> > + *
> > + */
> > +
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +
> > +/**
> > + * struct adc_jack_data - internal data for adc_jack device driver
> > + * @edev- extcon device.
> > + * @cable_names - list of supported cables.
> > + * @num_cables  - size of cable_names.
> > + * @adc_condition   - list of adc value conditions.
> > + * @num_condition   - size of adc_condition.
> > + * @irq - irq number of attach/detach event (0 if not exist).
> > + * @handling_delay  - interrupt handler will schedule extcon event
> > + *  handling at handling_delay jiffies.
> > + * @handler - extcon event handler called by interrupt handler.
> > + * @chan   - iio channel being queried.
> > + */
> > +struct adc_jack_data {
> > +   struct extcon_dev edev;
> > +
> > +   const char **cable_names;
> > +   int num_cables;
> > +   struct adc_jack_cond *adc_condition;
> > +   int num_conditions;
> > +
> > +   int irq;
> > +   unsigned long handling_delay; /* in jiffies */
> > +   struct delayed_work handler;
> > +
> > +   struct iio_channel *chan;
> > +};
> > +
> > +static void adc_jack_handler(struct work_struct *work)
> > +{
> > +   struct adc_jack_data *data = container_of(to_delayed_work(work),
> > +  

Re: [PATCH] [PATCH V4]Extcon: adc_jack: adc-jack driver to support 3.5 pi or simliar devices

2012-08-10 Thread Jonathan Cameron
On 08/08/2012 02:04 AM, anish kumar wrote:
> From: anish kumar 
>
> 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.

Couple of utterly trivial points inline.
Otherwise looks fine to me.
>
> Changes in V1:
> 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.
>
> Changes in V2:
> Removed some unnecessary checks and changed the way we are un-regitering
> extcon and freeing the irq while removing.
>
> Changes in V3:
> Renamed the files to comply with extcon naming.
>
> Changes in this version:
> Added the cancel_work_sync during removing of driver.
>
> Reviewed-by: Lars-Peter Clausen 
> Signed-off-by: anish kumar 
> Signed-off-by: MyungJoo Ham 
Don't these normally go in order of when they occured?
Hence first sign offs are the authors, any acks / reviewed-bys
after that and final sign offs for the merges.
> ---
>  drivers/extcon/Kconfig |5 +
>  drivers/extcon/Makefile|1 +
>  drivers/extcon/extcon-adc-jack.c   |  194 
> 
>  include/linux/extcon/extcon-adc-jack.h |   73 
>  4 files changed, 273 insertions(+), 0 deletions(-)
>  create mode 100644 drivers/extcon/extcon-adc-jack.c
>  create mode 100644 include/linux/extcon/extcon-adc-jack.h
>
> diff --git a/drivers/extcon/Kconfig b/drivers/extcon/Kconfig
> index e175c8e..596e277 100644
> --- a/drivers/extcon/Kconfig
> +++ b/drivers/extcon/Kconfig
> @@ -21,6 +21,11 @@ config EXTCON_GPIO
> Say Y here to enable GPIO based extcon support. Note that GPIO
> extcon supports single state per extcon instance.
>
> +config EXTCON_ADC_JACK
> +tristate "ADC Jack extcon support"
> +help
> +  Say Y here to enable extcon device driver based on ADC values.
> +
>  config EXTCON_MAX77693
>   tristate "MAX77693 EXTCON Support"
>   depends on MFD_MAX77693
> diff --git a/drivers/extcon/Makefile b/drivers/extcon/Makefile
> index 88961b3..bc7111e 100644
> --- a/drivers/extcon/Makefile
> +++ b/drivers/extcon/Makefile
> @@ -4,6 +4,7 @@
>
>  obj-$(CONFIG_EXTCON) += extcon_class.o
>  obj-$(CONFIG_EXTCON_GPIO)+= extcon_gpio.o
> +obj-$(CONFIG_EXTCON_ADC_JACK)   += extcon-adc-jack.o
>  obj-$(CONFIG_EXTCON_MAX77693)+= extcon-max77693.o
>  obj-$(CONFIG_EXTCON_MAX8997) += extcon-max8997.o
>  obj-$(CONFIG_EXTCON_ARIZONA) += extcon-arizona.o
> diff --git a/drivers/extcon/extcon-adc-jack.c 
> b/drivers/extcon/extcon-adc-jack.c
> new file mode 100644
> index 000..cfc8c59
> --- /dev/null
> +++ b/drivers/extcon/extcon-adc-jack.c
> @@ -0,0 +1,194 @@
> +/*
> + * drivers/extcon/extcon-adc-jack.c
> + *
> + * Analog Jack extcon driver with ADC-based detection capability.
> + *
> + * Copyright (C) 2012 Samsung Electronics
> + * MyungJoo Ham 
> + *
> + * Modified for calling to IIO to get adc by 
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + *
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +/**
> + * struct adc_jack_data - internal data for adc_jack device driver
> + * @edev- extcon device.
> + * @cable_names - list of supported cables.
> + * @num_cables  - size of cable_names.
> + * @adc_condition   - list of adc value conditions.
> + * @num_condition   - size of adc_condition.
> + * @irq - irq number of attach/detach event (0 if not exist).
> + * @handling_delay  - interrupt handler will schedule extcon event
> + *  handling at handling_delay jiffies.
> + * @handler - extcon event handler called by interrupt handler.
> + * @chan - iio channel being queried.
> + */
> +struct adc_jack_data {
> + struct extcon_dev edev;
> +
> + const char **cable_names;
> + int num_cables;
> + struct adc_jack_cond *adc_condition;
> + int num_conditions;
> +
> + int irq;
> + unsigned long handling_delay; /* in jiffies */
> + struct delayed_work handler;
> +
> + struct iio_channel *chan;
> +};
> +
> +static void adc_jack_handler(struct work_struct *work)
> +{
> + struct adc_jack_data *data = container_of(to_delayed_work(work),
> +   struct adc_jack_data,
> +   handler);
> + u32 state = 0;
> + int ret, adc_val;
> + int i;
> +
> + ret = iio_read_channel_raw(data->chan, _val);
> + if (ret < 0) {
> + dev_err(data->edev.dev, "read channel() error: %d\n", ret);
> + return;
> 

Re: [PATCH] [PATCH V4]Extcon: adc_jack: adc-jack driver to support 3.5 pi or simliar devices

2012-08-10 Thread Jonathan Cameron
On 08/08/2012 02:04 AM, anish kumar wrote:
 From: anish kumar anish198519851...@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.

Couple of utterly trivial points inline.
Otherwise looks fine to me.

 Changes in V1:
 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.

 Changes in V2:
 Removed some unnecessary checks and changed the way we are un-regitering
 extcon and freeing the irq while removing.

 Changes in V3:
 Renamed the files to comply with extcon naming.

 Changes in this version:
 Added the cancel_work_sync during removing of driver.

 Reviewed-by: Lars-Peter Clausen l...@metafoo.de
 Signed-off-by: anish kumar anish.si...@samsung.com
 Signed-off-by: MyungJoo Ham myungjoo@samsung.com
Don't these normally go in order of when they occured?
Hence first sign offs are the authors, any acks / reviewed-bys
after that and final sign offs for the merges.
 ---
  drivers/extcon/Kconfig |5 +
  drivers/extcon/Makefile|1 +
  drivers/extcon/extcon-adc-jack.c   |  194 
 
  include/linux/extcon/extcon-adc-jack.h |   73 
  4 files changed, 273 insertions(+), 0 deletions(-)
  create mode 100644 drivers/extcon/extcon-adc-jack.c
  create mode 100644 include/linux/extcon/extcon-adc-jack.h

 diff --git a/drivers/extcon/Kconfig b/drivers/extcon/Kconfig
 index e175c8e..596e277 100644
 --- a/drivers/extcon/Kconfig
 +++ b/drivers/extcon/Kconfig
 @@ -21,6 +21,11 @@ config EXTCON_GPIO
 Say Y here to enable GPIO based extcon support. Note that GPIO
 extcon supports single state per extcon instance.

 +config EXTCON_ADC_JACK
 +tristate ADC Jack extcon support
 +help
 +  Say Y here to enable extcon device driver based on ADC values.
 +
  config EXTCON_MAX77693
   tristate MAX77693 EXTCON Support
   depends on MFD_MAX77693
 diff --git a/drivers/extcon/Makefile b/drivers/extcon/Makefile
 index 88961b3..bc7111e 100644
 --- a/drivers/extcon/Makefile
 +++ b/drivers/extcon/Makefile
 @@ -4,6 +4,7 @@

  obj-$(CONFIG_EXTCON) += extcon_class.o
  obj-$(CONFIG_EXTCON_GPIO)+= extcon_gpio.o
 +obj-$(CONFIG_EXTCON_ADC_JACK)   += extcon-adc-jack.o
  obj-$(CONFIG_EXTCON_MAX77693)+= extcon-max77693.o
  obj-$(CONFIG_EXTCON_MAX8997) += extcon-max8997.o
  obj-$(CONFIG_EXTCON_ARIZONA) += extcon-arizona.o
 diff --git a/drivers/extcon/extcon-adc-jack.c 
 b/drivers/extcon/extcon-adc-jack.c
 new file mode 100644
 index 000..cfc8c59
 --- /dev/null
 +++ b/drivers/extcon/extcon-adc-jack.c
 @@ -0,0 +1,194 @@
 +/*
 + * drivers/extcon/extcon-adc-jack.c
 + *
 + * Analog Jack extcon driver with ADC-based detection capability.
 + *
 + * Copyright (C) 2012 Samsung Electronics
 + * MyungJoo Ham myungjoo@samsung.com
 + *
 + * Modified for calling to IIO to get adc by anish.si...@samsung.com
 + *
 + * This program is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License version 2 as
 + * published by the Free Software Foundation.
 + *
 + */
 +
 +#include linux/slab.h
 +#include linux/device.h
 +#include linux/platform_device.h
 +#include linux/interrupt.h
 +#include linux/workqueue.h
 +#include linux/iio/consumer.h
 +#include linux/extcon/extcon-adc-jack.h
 +#include linux/extcon.h
 +
 +/**
 + * struct adc_jack_data - internal data for adc_jack device driver
 + * @edev- extcon device.
 + * @cable_names - list of supported cables.
 + * @num_cables  - size of cable_names.
 + * @adc_condition   - list of adc value conditions.
 + * @num_condition   - size of adc_condition.
 + * @irq - irq number of attach/detach event (0 if not exist).
 + * @handling_delay  - interrupt handler will schedule extcon event
 + *  handling at handling_delay jiffies.
 + * @handler - extcon event handler called by interrupt handler.
 + * @chan - iio channel being queried.
 + */
 +struct adc_jack_data {
 + struct extcon_dev edev;
 +
 + const char **cable_names;
 + int num_cables;
 + struct adc_jack_cond *adc_condition;
 + int num_conditions;
 +
 + int irq;
 + unsigned long handling_delay; /* in jiffies */
 + struct delayed_work handler;
 +
 + struct iio_channel *chan;
 +};
 +
 +static void adc_jack_handler(struct work_struct *work)
 +{
 + struct adc_jack_data *data = container_of(to_delayed_work(work),
 +   struct adc_jack_data,
 +   handler);
 + u32 state = 0;
 + int ret, adc_val;
 + int i;
 +
 + ret = 

Re: [PATCH] [PATCH V4]Extcon: adc_jack: adc-jack driver to support 3.5 pi or simliar devices

2012-08-10 Thread anish kumar
Hello Jonathan,

Please refer the latest patch.

Thanks,
On Fri, 2012-08-10 at 22:01 +0100, Jonathan Cameron wrote:
 On 08/08/2012 02:04 AM, anish kumar wrote:
  From: anish kumar anish198519851...@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.
 
 Couple of utterly trivial points inline.
 Otherwise looks fine to me.
 
  Changes in V1:
  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.
 
  Changes in V2:
  Removed some unnecessary checks and changed the way we are un-regitering
  extcon and freeing the irq while removing.
 
  Changes in V3:
  Renamed the files to comply with extcon naming.
 
  Changes in this version:
  Added the cancel_work_sync during removing of driver.
 
  Reviewed-by: Lars-Peter Clausen l...@metafoo.de
  Signed-off-by: anish kumar anish.si...@samsung.com
  Signed-off-by: MyungJoo Ham myungjoo@samsung.com
 Don't these normally go in order of when they occured?
 Hence first sign offs are the authors, any acks / reviewed-bys
 after that and final sign offs for the merges.
  ---
   drivers/extcon/Kconfig |5 +
   drivers/extcon/Makefile|1 +
   drivers/extcon/extcon-adc-jack.c   |  194 
  
   include/linux/extcon/extcon-adc-jack.h |   73 
   4 files changed, 273 insertions(+), 0 deletions(-)
   create mode 100644 drivers/extcon/extcon-adc-jack.c
   create mode 100644 include/linux/extcon/extcon-adc-jack.h
 
  diff --git a/drivers/extcon/Kconfig b/drivers/extcon/Kconfig
  index e175c8e..596e277 100644
  --- a/drivers/extcon/Kconfig
  +++ b/drivers/extcon/Kconfig
  @@ -21,6 +21,11 @@ config EXTCON_GPIO
Say Y here to enable GPIO based extcon support. Note that GPIO
extcon supports single state per extcon instance.
 
  +config EXTCON_ADC_JACK
  +tristate ADC Jack extcon support
  +help
  +  Say Y here to enable extcon device driver based on ADC values.
  +
   config EXTCON_MAX77693
  tristate MAX77693 EXTCON Support
  depends on MFD_MAX77693
  diff --git a/drivers/extcon/Makefile b/drivers/extcon/Makefile
  index 88961b3..bc7111e 100644
  --- a/drivers/extcon/Makefile
  +++ b/drivers/extcon/Makefile
  @@ -4,6 +4,7 @@
 
   obj-$(CONFIG_EXTCON)   += extcon_class.o
   obj-$(CONFIG_EXTCON_GPIO)  += extcon_gpio.o
  +obj-$(CONFIG_EXTCON_ADC_JACK)   += extcon-adc-jack.o
   obj-$(CONFIG_EXTCON_MAX77693)  += extcon-max77693.o
   obj-$(CONFIG_EXTCON_MAX8997)   += extcon-max8997.o
   obj-$(CONFIG_EXTCON_ARIZONA)   += extcon-arizona.o
  diff --git a/drivers/extcon/extcon-adc-jack.c 
  b/drivers/extcon/extcon-adc-jack.c
  new file mode 100644
  index 000..cfc8c59
  --- /dev/null
  +++ b/drivers/extcon/extcon-adc-jack.c
  @@ -0,0 +1,194 @@
  +/*
  + * drivers/extcon/extcon-adc-jack.c
  + *
  + * Analog Jack extcon driver with ADC-based detection capability.
  + *
  + * Copyright (C) 2012 Samsung Electronics
  + * MyungJoo Ham myungjoo@samsung.com
  + *
  + * Modified for calling to IIO to get adc by anish.si...@samsung.com
  + *
  + * This program is free software; you can redistribute it and/or modify
  + * it under the terms of the GNU General Public License version 2 as
  + * published by the Free Software Foundation.
  + *
  + */
  +
  +#include linux/slab.h
  +#include linux/device.h
  +#include linux/platform_device.h
  +#include linux/interrupt.h
  +#include linux/workqueue.h
  +#include linux/iio/consumer.h
  +#include linux/extcon/extcon-adc-jack.h
  +#include linux/extcon.h
  +
  +/**
  + * struct adc_jack_data - internal data for adc_jack device driver
  + * @edev- extcon device.
  + * @cable_names - list of supported cables.
  + * @num_cables  - size of cable_names.
  + * @adc_condition   - list of adc value conditions.
  + * @num_condition   - size of adc_condition.
  + * @irq - irq number of attach/detach event (0 if not exist).
  + * @handling_delay  - interrupt handler will schedule extcon event
  + *  handling at handling_delay jiffies.
  + * @handler - extcon event handler called by interrupt handler.
  + * @chan   - iio channel being queried.
  + */
  +struct adc_jack_data {
  +   struct extcon_dev edev;
  +
  +   const char **cable_names;
  +   int num_cables;
  +   struct adc_jack_cond *adc_condition;
  +   int num_conditions;
  +
  +   int irq;
  +   unsigned long handling_delay; /* in jiffies */
  +   struct delayed_work handler;
  +
  +   struct iio_channel *chan;
  +};
  +
  +static void adc_jack_handler(struct work_struct *work)
  +{
  +   struct adc_jack_data *data = 

Re: [PATCH] [PATCH V4]Extcon: adc_jack: adc-jack driver to support 3.5 pi or simliar devices

2012-08-09 Thread anish kumar
On Fri, 2012-08-10 at 04:39 +, MyungJoo Ham wrote:
> > From: anish kumar 
> > 
> > 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.
> 
> 1. Missing header: #include
I didn't come across any problem when I compiled.Is this really needed?

> 2. Missing dependency to IIO. (please add IIO dependency at Kconfig)
Ya forgot that.Sending in some time.
> 
> 
> Cheers!
> MyungJoo
> 
> > 
> > Changes in V1:
> > 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.
> > 
> > Changes in V2:
> > Removed some unnecessary checks and changed the way we are un-regitering
> > extcon and freeing the irq while removing.
> > 
> > Changes in V3:
> > Renamed the files to comply with extcon naming.
> > 
> > Changes in this version:
> > Added the cancel_work_sync during removing of driver.
> > 
> > Reviewed-by: Lars-Peter Clausen 
> > Signed-off-by: anish kumar 
> > Signed-off-by: MyungJoo Ham 
> > ---
> >  drivers/extcon/Kconfig |5 +
> >  drivers/extcon/Makefile|1 +
> >  drivers/extcon/extcon-adc-jack.c   |  194 
> > 
> >  include/linux/extcon/extcon-adc-jack.h |   73 
> >  4 files changed, 273 insertions(+), 0 deletions(-)
> >  create mode 100644 drivers/extcon/extcon-adc-jack.c
> >  create mode 100644 include/linux/extcon/extcon-adc-jack.h
> > 
> > diff --git a/drivers/extcon/Kconfig b/drivers/extcon/Kconfig
> > index e175c8e..596e277 100644
> > --- a/drivers/extcon/Kconfig
> > +++ b/drivers/extcon/Kconfig
> > @@ -21,6 +21,11 @@ config EXTCON_GPIO
> >   Say Y here to enable GPIO based extcon support. Note that GPIO
> >   extcon supports single state per extcon instance.
> >  
> > +config EXTCON_ADC_JACK
> > +tristate "ADC Jack extcon support"
> > +help
> > +  Say Y here to enable extcon device driver based on ADC values.
> > +
> >  config EXTCON_MAX77693
> > tristate "MAX77693 EXTCON Support"
> > depends on MFD_MAX77693
> > diff --git a/drivers/extcon/Makefile b/drivers/extcon/Makefile
> > index 88961b3..bc7111e 100644
> > --- a/drivers/extcon/Makefile
> > +++ b/drivers/extcon/Makefile
> > @@ -4,6 +4,7 @@
> >  
> >  obj-$(CONFIG_EXTCON)   += extcon_class.o
> >  obj-$(CONFIG_EXTCON_GPIO)  += extcon_gpio.o
> > +obj-$(CONFIG_EXTCON_ADC_JACK)   += extcon-adc-jack.o
> >  obj-$(CONFIG_EXTCON_MAX77693)  += extcon-max77693.o
> >  obj-$(CONFIG_EXTCON_MAX8997)   += extcon-max8997.o
> >  obj-$(CONFIG_EXTCON_ARIZONA)   += extcon-arizona.o
> > diff --git a/drivers/extcon/extcon-adc-jack.c 
> > b/drivers/extcon/extcon-adc-jack.c
> > new file mode 100644
> > index 000..cfc8c59
> > --- /dev/null
> > +++ b/drivers/extcon/extcon-adc-jack.c
> > @@ -0,0 +1,194 @@
> > +/*
> > + * drivers/extcon/extcon-adc-jack.c
> > + *
> > + * Analog Jack extcon driver with ADC-based detection capability.
> > + *
> > + * Copyright (C) 2012 Samsung Electronics
> > + * MyungJoo Ham 
> > + *
> > + * Modified for calling to IIO to get adc by 
> > + *
> > + * This program is free software; you can redistribute it and/or modify
> > + * it under the terms of the GNU General Public License version 2 as
> > + * published by the Free Software Foundation.
> > + *
> > + */
> > +
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +
> > +/**
> > + * struct adc_jack_data - internal data for adc_jack device driver
> > + * @edev- extcon device.
> > + * @cable_names - list of supported cables.
> > + * @num_cables  - size of cable_names.
> > + * @adc_condition   - list of adc value conditions.
> > + * @num_condition   - size of adc_condition.
> > + * @irq - irq number of attach/detach event (0 if not exist).
> > + * @handling_delay  - interrupt handler will schedule extcon event
> > + *  handling at handling_delay jiffies.
> > + * @handler - extcon event handler called by interrupt handler.
> > + * @chan   - iio channel being queried.
> > + */
> > +struct adc_jack_data {
> > +   struct extcon_dev edev;
> > +
> > +   const char **cable_names;
> > +   int num_cables;
> > +   struct adc_jack_cond *adc_condition;
> > +   int num_conditions;
> > +
> > +   int irq;
> > +   unsigned long handling_delay; /* in jiffies */
> > +   struct delayed_work handler;
> > +
> > +   struct iio_channel *chan;
> > +};
> > +
> > +static void adc_jack_handler(struct work_struct *work)
> > +{
> > +   struct adc_jack_data *data = container_of(to_delayed_work(work),
> > + struct adc_jack_data,
> > +

Re: [PATCH] [PATCH V4]Extcon: adc_jack: adc-jack driver to support 3.5 pi or simliar devices

2012-08-09 Thread MyungJoo Ham
> From: anish kumar 
> 
> 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.

1. Missing header: #include
2. Missing dependency to IIO. (please add IIO dependency at Kconfig)


Cheers!
MyungJoo

> 
> Changes in V1:
> 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.
> 
> Changes in V2:
> Removed some unnecessary checks and changed the way we are un-regitering
> extcon and freeing the irq while removing.
> 
> Changes in V3:
> Renamed the files to comply with extcon naming.
> 
> Changes in this version:
> Added the cancel_work_sync during removing of driver.
> 
> Reviewed-by: Lars-Peter Clausen 
> Signed-off-by: anish kumar 
> Signed-off-by: MyungJoo Ham 
> ---
>  drivers/extcon/Kconfig |5 +
>  drivers/extcon/Makefile|1 +
>  drivers/extcon/extcon-adc-jack.c   |  194 
> 
>  include/linux/extcon/extcon-adc-jack.h |   73 
>  4 files changed, 273 insertions(+), 0 deletions(-)
>  create mode 100644 drivers/extcon/extcon-adc-jack.c
>  create mode 100644 include/linux/extcon/extcon-adc-jack.h
> 
> diff --git a/drivers/extcon/Kconfig b/drivers/extcon/Kconfig
> index e175c8e..596e277 100644
> --- a/drivers/extcon/Kconfig
> +++ b/drivers/extcon/Kconfig
> @@ -21,6 +21,11 @@ config EXTCON_GPIO
> Say Y here to enable GPIO based extcon support. Note that GPIO
> extcon supports single state per extcon instance.
>  
> +config EXTCON_ADC_JACK
> +tristate "ADC Jack extcon support"
> +help
> +  Say Y here to enable extcon device driver based on ADC values.
> +
>  config EXTCON_MAX77693
>   tristate "MAX77693 EXTCON Support"
>   depends on MFD_MAX77693
> diff --git a/drivers/extcon/Makefile b/drivers/extcon/Makefile
> index 88961b3..bc7111e 100644
> --- a/drivers/extcon/Makefile
> +++ b/drivers/extcon/Makefile
> @@ -4,6 +4,7 @@
>  
>  obj-$(CONFIG_EXTCON) += extcon_class.o
>  obj-$(CONFIG_EXTCON_GPIO)+= extcon_gpio.o
> +obj-$(CONFIG_EXTCON_ADC_JACK)   += extcon-adc-jack.o
>  obj-$(CONFIG_EXTCON_MAX77693)+= extcon-max77693.o
>  obj-$(CONFIG_EXTCON_MAX8997) += extcon-max8997.o
>  obj-$(CONFIG_EXTCON_ARIZONA) += extcon-arizona.o
> diff --git a/drivers/extcon/extcon-adc-jack.c 
> b/drivers/extcon/extcon-adc-jack.c
> new file mode 100644
> index 000..cfc8c59
> --- /dev/null
> +++ b/drivers/extcon/extcon-adc-jack.c
> @@ -0,0 +1,194 @@
> +/*
> + * drivers/extcon/extcon-adc-jack.c
> + *
> + * Analog Jack extcon driver with ADC-based detection capability.
> + *
> + * Copyright (C) 2012 Samsung Electronics
> + * MyungJoo Ham 
> + *
> + * Modified for calling to IIO to get adc by 
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + *
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +/**
> + * struct adc_jack_data - internal data for adc_jack device driver
> + * @edev- extcon device.
> + * @cable_names - list of supported cables.
> + * @num_cables  - size of cable_names.
> + * @adc_condition   - list of adc value conditions.
> + * @num_condition   - size of adc_condition.
> + * @irq - irq number of attach/detach event (0 if not exist).
> + * @handling_delay  - interrupt handler will schedule extcon event
> + *  handling at handling_delay jiffies.
> + * @handler - extcon event handler called by interrupt handler.
> + * @chan - iio channel being queried.
> + */
> +struct adc_jack_data {
> + struct extcon_dev edev;
> +
> + const char **cable_names;
> + int num_cables;
> + struct adc_jack_cond *adc_condition;
> + int num_conditions;
> +
> + int irq;
> + unsigned long handling_delay; /* in jiffies */
> + struct delayed_work handler;
> +
> + struct iio_channel *chan;
> +};
> +
> +static void adc_jack_handler(struct work_struct *work)
> +{
> + struct adc_jack_data *data = container_of(to_delayed_work(work),
> +   struct adc_jack_data,
> +   handler);
> + u32 state = 0;
> + int ret, adc_val;
> + int i;
> +
> + ret = iio_read_channel_raw(data->chan, _val);
> + if (ret < 0) {
> + dev_err(data->edev.dev, "read channel() error: %d\n", ret);
> + return;
> + }
> +
> + /* Get state from adc value with adc_condition */
> + for (i = 0; i < data->num_conditions; i++) {
> + struct 

Re: [PATCH] [PATCH V4]Extcon: adc_jack: adc-jack driver to support 3.5 pi or simliar devices

2012-08-09 Thread MyungJoo Ham
 From: anish kumar anish198519851...@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.

1. Missing header: #includelinux/err.h
2. Missing dependency to IIO. (please add IIO dependency at Kconfig)


Cheers!
MyungJoo

 
 Changes in V1:
 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.
 
 Changes in V2:
 Removed some unnecessary checks and changed the way we are un-regitering
 extcon and freeing the irq while removing.
 
 Changes in V3:
 Renamed the files to comply with extcon naming.
 
 Changes in this version:
 Added the cancel_work_sync during removing of driver.
 
 Reviewed-by: Lars-Peter Clausen l...@metafoo.de
 Signed-off-by: anish kumar anish.si...@samsung.com
 Signed-off-by: MyungJoo Ham myungjoo@samsung.com
 ---
  drivers/extcon/Kconfig |5 +
  drivers/extcon/Makefile|1 +
  drivers/extcon/extcon-adc-jack.c   |  194 
 
  include/linux/extcon/extcon-adc-jack.h |   73 
  4 files changed, 273 insertions(+), 0 deletions(-)
  create mode 100644 drivers/extcon/extcon-adc-jack.c
  create mode 100644 include/linux/extcon/extcon-adc-jack.h
 
 diff --git a/drivers/extcon/Kconfig b/drivers/extcon/Kconfig
 index e175c8e..596e277 100644
 --- a/drivers/extcon/Kconfig
 +++ b/drivers/extcon/Kconfig
 @@ -21,6 +21,11 @@ config EXTCON_GPIO
 Say Y here to enable GPIO based extcon support. Note that GPIO
 extcon supports single state per extcon instance.
  
 +config EXTCON_ADC_JACK
 +tristate ADC Jack extcon support
 +help
 +  Say Y here to enable extcon device driver based on ADC values.
 +
  config EXTCON_MAX77693
   tristate MAX77693 EXTCON Support
   depends on MFD_MAX77693
 diff --git a/drivers/extcon/Makefile b/drivers/extcon/Makefile
 index 88961b3..bc7111e 100644
 --- a/drivers/extcon/Makefile
 +++ b/drivers/extcon/Makefile
 @@ -4,6 +4,7 @@
  
  obj-$(CONFIG_EXTCON) += extcon_class.o
  obj-$(CONFIG_EXTCON_GPIO)+= extcon_gpio.o
 +obj-$(CONFIG_EXTCON_ADC_JACK)   += extcon-adc-jack.o
  obj-$(CONFIG_EXTCON_MAX77693)+= extcon-max77693.o
  obj-$(CONFIG_EXTCON_MAX8997) += extcon-max8997.o
  obj-$(CONFIG_EXTCON_ARIZONA) += extcon-arizona.o
 diff --git a/drivers/extcon/extcon-adc-jack.c 
 b/drivers/extcon/extcon-adc-jack.c
 new file mode 100644
 index 000..cfc8c59
 --- /dev/null
 +++ b/drivers/extcon/extcon-adc-jack.c
 @@ -0,0 +1,194 @@
 +/*
 + * drivers/extcon/extcon-adc-jack.c
 + *
 + * Analog Jack extcon driver with ADC-based detection capability.
 + *
 + * Copyright (C) 2012 Samsung Electronics
 + * MyungJoo Ham myungjoo@samsung.com
 + *
 + * Modified for calling to IIO to get adc by anish.si...@samsung.com
 + *
 + * This program is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License version 2 as
 + * published by the Free Software Foundation.
 + *
 + */
 +
 +#include linux/slab.h
 +#include linux/device.h
 +#include linux/platform_device.h
 +#include linux/interrupt.h
 +#include linux/workqueue.h
 +#include linux/iio/consumer.h
 +#include linux/extcon/extcon-adc-jack.h
 +#include linux/extcon.h
 +
 +/**
 + * struct adc_jack_data - internal data for adc_jack device driver
 + * @edev- extcon device.
 + * @cable_names - list of supported cables.
 + * @num_cables  - size of cable_names.
 + * @adc_condition   - list of adc value conditions.
 + * @num_condition   - size of adc_condition.
 + * @irq - irq number of attach/detach event (0 if not exist).
 + * @handling_delay  - interrupt handler will schedule extcon event
 + *  handling at handling_delay jiffies.
 + * @handler - extcon event handler called by interrupt handler.
 + * @chan - iio channel being queried.
 + */
 +struct adc_jack_data {
 + struct extcon_dev edev;
 +
 + const char **cable_names;
 + int num_cables;
 + struct adc_jack_cond *adc_condition;
 + int num_conditions;
 +
 + int irq;
 + unsigned long handling_delay; /* in jiffies */
 + struct delayed_work handler;
 +
 + struct iio_channel *chan;
 +};
 +
 +static void adc_jack_handler(struct work_struct *work)
 +{
 + struct adc_jack_data *data = container_of(to_delayed_work(work),
 +   struct adc_jack_data,
 +   handler);
 + u32 state = 0;
 + int ret, adc_val;
 + int i;
 +
 + ret = iio_read_channel_raw(data-chan, adc_val);
 + if (ret  0) {
 + dev_err(data-edev.dev, read channel() error: %d\n, ret);
 + return;

Re: [PATCH] [PATCH V4]Extcon: adc_jack: adc-jack driver to support 3.5 pi or simliar devices

2012-08-09 Thread anish kumar
On Fri, 2012-08-10 at 04:39 +, MyungJoo Ham wrote:
  From: anish kumar anish198519851...@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.
 
 1. Missing header: #includelinux/err.h
I didn't come across any problem when I compiled.Is this really needed?

 2. Missing dependency to IIO. (please add IIO dependency at Kconfig)
Ya forgot that.Sending in some time.
 
 
 Cheers!
 MyungJoo
 
  
  Changes in V1:
  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.
  
  Changes in V2:
  Removed some unnecessary checks and changed the way we are un-regitering
  extcon and freeing the irq while removing.
  
  Changes in V3:
  Renamed the files to comply with extcon naming.
  
  Changes in this version:
  Added the cancel_work_sync during removing of driver.
  
  Reviewed-by: Lars-Peter Clausen l...@metafoo.de
  Signed-off-by: anish kumar anish.si...@samsung.com
  Signed-off-by: MyungJoo Ham myungjoo@samsung.com
  ---
   drivers/extcon/Kconfig |5 +
   drivers/extcon/Makefile|1 +
   drivers/extcon/extcon-adc-jack.c   |  194 
  
   include/linux/extcon/extcon-adc-jack.h |   73 
   4 files changed, 273 insertions(+), 0 deletions(-)
   create mode 100644 drivers/extcon/extcon-adc-jack.c
   create mode 100644 include/linux/extcon/extcon-adc-jack.h
  
  diff --git a/drivers/extcon/Kconfig b/drivers/extcon/Kconfig
  index e175c8e..596e277 100644
  --- a/drivers/extcon/Kconfig
  +++ b/drivers/extcon/Kconfig
  @@ -21,6 +21,11 @@ config EXTCON_GPIO
Say Y here to enable GPIO based extcon support. Note that GPIO
extcon supports single state per extcon instance.
   
  +config EXTCON_ADC_JACK
  +tristate ADC Jack extcon support
  +help
  +  Say Y here to enable extcon device driver based on ADC values.
  +
   config EXTCON_MAX77693
  tristate MAX77693 EXTCON Support
  depends on MFD_MAX77693
  diff --git a/drivers/extcon/Makefile b/drivers/extcon/Makefile
  index 88961b3..bc7111e 100644
  --- a/drivers/extcon/Makefile
  +++ b/drivers/extcon/Makefile
  @@ -4,6 +4,7 @@
   
   obj-$(CONFIG_EXTCON)   += extcon_class.o
   obj-$(CONFIG_EXTCON_GPIO)  += extcon_gpio.o
  +obj-$(CONFIG_EXTCON_ADC_JACK)   += extcon-adc-jack.o
   obj-$(CONFIG_EXTCON_MAX77693)  += extcon-max77693.o
   obj-$(CONFIG_EXTCON_MAX8997)   += extcon-max8997.o
   obj-$(CONFIG_EXTCON_ARIZONA)   += extcon-arizona.o
  diff --git a/drivers/extcon/extcon-adc-jack.c 
  b/drivers/extcon/extcon-adc-jack.c
  new file mode 100644
  index 000..cfc8c59
  --- /dev/null
  +++ b/drivers/extcon/extcon-adc-jack.c
  @@ -0,0 +1,194 @@
  +/*
  + * drivers/extcon/extcon-adc-jack.c
  + *
  + * Analog Jack extcon driver with ADC-based detection capability.
  + *
  + * Copyright (C) 2012 Samsung Electronics
  + * MyungJoo Ham myungjoo@samsung.com
  + *
  + * Modified for calling to IIO to get adc by anish.si...@samsung.com
  + *
  + * This program is free software; you can redistribute it and/or modify
  + * it under the terms of the GNU General Public License version 2 as
  + * published by the Free Software Foundation.
  + *
  + */
  +
  +#include linux/slab.h
  +#include linux/device.h
  +#include linux/platform_device.h
  +#include linux/interrupt.h
  +#include linux/workqueue.h
  +#include linux/iio/consumer.h
  +#include linux/extcon/extcon-adc-jack.h
  +#include linux/extcon.h
  +
  +/**
  + * struct adc_jack_data - internal data for adc_jack device driver
  + * @edev- extcon device.
  + * @cable_names - list of supported cables.
  + * @num_cables  - size of cable_names.
  + * @adc_condition   - list of adc value conditions.
  + * @num_condition   - size of adc_condition.
  + * @irq - irq number of attach/detach event (0 if not exist).
  + * @handling_delay  - interrupt handler will schedule extcon event
  + *  handling at handling_delay jiffies.
  + * @handler - extcon event handler called by interrupt handler.
  + * @chan   - iio channel being queried.
  + */
  +struct adc_jack_data {
  +   struct extcon_dev edev;
  +
  +   const char **cable_names;
  +   int num_cables;
  +   struct adc_jack_cond *adc_condition;
  +   int num_conditions;
  +
  +   int irq;
  +   unsigned long handling_delay; /* in jiffies */
  +   struct delayed_work handler;
  +
  +   struct iio_channel *chan;
  +};
  +
  +static void adc_jack_handler(struct work_struct *work)
  +{
  +   struct adc_jack_data *data = container_of(to_delayed_work(work),
  + struct adc_jack_data,
  +