[PATCH 1/1] staging/comedi/drivers: add driver for ad7739 analog to digital converter chip on an spi bus

Greg KH gregkh at linuxfoundation.org
Thu Mar 15 15:08:46 UTC 2012


On Thu, Mar 15, 2012 at 07:17:05PM +0600, Alexander Pazdnikov wrote:
>    Add support for an ad7739 chip.
> 
> Signed-off-by: Alexander Pazdnikov <pazdnikov at list.ru>
> ---
>  drivers/staging/comedi/Kconfig          |   25 ++
>  drivers/staging/comedi/drivers/Makefile |    3 +
>  drivers/staging/comedi/drivers/ad7739.c |  443 +++++++++++++++++++++++++++++++
>  drivers/staging/comedi/drivers/ad7739.h |    9 +
>  4 files changed, 480 insertions(+), 0 deletions(-)
>  create mode 100644 drivers/staging/comedi/drivers/ad7739.c
>  create mode 100644 drivers/staging/comedi/drivers/ad7739.h
> 
> diff --git a/drivers/staging/comedi/Kconfig b/drivers/staging/comedi/Kconfig
> index 4c77e50..c4bcab6 100644
> --- a/drivers/staging/comedi/Kconfig
> +++ b/drivers/staging/comedi/Kconfig
> @@ -1381,3 +1381,28 @@ config COMEDI_FC
>  
>  	  To compile this driver as a module, choose M here: the module will be
>  	  called comedi_fc.
> +
> +menuconfig COMEDI_SPI_DRIVERS
> +	tristate "Comedi SPI drivers"
> +	depends on COMEDI && SPI
> +	default N
> +	---help---
> +	  Enable comedi SPI drivers to be built
> +
> +	  Note that the answer to this question won't directly affect the
> +	  kernel: saying N will just cause the configurator to skip all
> +	  the questions about SPI comedi drivers.
> +
> +if COMEDI_SPI_DRIVERS && SPI

&& SPI is redundant here, right?

> +config COMEDI_AD7739
> +	tristate "AD7739 driver"
> +	select SPI_SPIDEV
> +	default N

You could just make this depends on COMEDI_SPI_DRIVERS, to get rid of
the above if as well.

> +	---help---
> +	  Enable support for AD7739 A/D converter.
> +
> +	  To compile this driver as a module, choose M here: the module will be
> +	  called ad7739.
> +
> +endif # COMEDI_SPI_DRIVERS
> diff --git a/drivers/staging/comedi/drivers/Makefile b/drivers/staging/comedi/drivers/Makefile
> index 170da60..844d51c 100644
> --- a/drivers/staging/comedi/drivers/Makefile
> +++ b/drivers/staging/comedi/drivers/Makefile
> @@ -138,3 +138,6 @@ obj-$(CONFIG_COMEDI_NI_LABPC)		+= ni_labpc.o
>  obj-$(CONFIG_COMEDI_8255)		+= 8255.o
>  obj-$(CONFIG_COMEDI_DAS08)		+= das08.o
>  obj-$(CONFIG_COMEDI_FC)			+= comedi_fc.o
> +
> +# Comedi SPI drivers
> +obj-$(CONFIG_COMEDI_AD7739)		+= ad7739.o
> diff --git a/drivers/staging/comedi/drivers/ad7739.c b/drivers/staging/comedi/drivers/ad7739.c
> new file mode 100644
> index 0000000..a9fe4dd
> --- /dev/null
> +++ b/drivers/staging/comedi/drivers/ad7739.c
> @@ -0,0 +1,443 @@
> +/*
> +    comedi/drivers/ad7739.c
> +    Driver for AD7739 A/D converter chip on an SPI bus
> +
> +    Copyright (C) 2011 Prosoft Systems Ltd. <http://www.prosoftsystems.ru/>
> +
> +    COMEDI - Linux Control and Measurement Device Interface
> +    Copyright (C) 1998,2000 David A. Schleef <ds at schleef.org>
> +
> +    This program is free software; you can redistribute it and/or modify
> +    it under the terms of the GNU General Public License as published by
> +    the Free Software Foundation; either version 2 of the License, or
> +    (at your option) any later version.

Do you really mean "any later version"?

> +
> +    This program is distributed in the hope that it will be useful,
> +    but WITHOUT ANY WARRANTY; without even the implied warranty of
> +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +    GNU General Public License for more details.
> +
> +    You should have received a copy of the GNU General Public License
> +    along with this program; if not, write to the Free Software
> +    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

Unless you wish to keep tabs on where the FSF has their offices for the
next 40 years, and send me patches updating it, I suggest just removing
this paragraph.  And the previous one as well, that's not needed either.

> +*/
> +/*
> +Driver: ad7739
> +Description: Analog Devices AD7739
> +Author: Alexander Pazdnikov <pazdnikov at prosoftsystems.ru> <pazdnikov at list.ru>
> +Devices: AD7739
> +Updated: Thu, 15 Mar 2012 16:20:29 +0600
> +Status: experimental
> +
> +Supports:
> +
> +  - ai_insn read
> +       24 bit mode support only
> +       using max measurement time only
> +
> +Configuration Options:
> +  [0] - Bits: 0-7 - ChipSelect, 8-16 - SPI Bus Number
> +
> +*/
> +/*
> +    Usage example through board-setup.
> +
> +static const struct ad7739_platform_data dd11_adc =.
> +{
> +    .chanselect_p0p1 = 1,
> +};
> +
> +static struct spi_board_info spi_devices[] = {
> +    {
> +        .modalias = "spidev",
> +        .irq = AT91_PIN_PC7,
> +        .chip_select = 5,
> +        .max_speed_hz = 0,
> +        .bus_num = 1,
> +        .platform_data = &dd11_adc,
> +    },
> +};
> +
> +*/
> +
> +//#define DEBUG 1

<snip>

Please run your patch through the scripts/checkpatch.pl tool and fix the
errors and warnings it shows you.  That way no one else has to come
along and fix them up afterward.

> --- /dev/null
> +++ b/drivers/staging/comedi/drivers/ad7739.h
> @@ -0,0 +1,9 @@
> +#ifndef AD7739_H
> +#define AD7739_H
> +
> +struct ad7739_platform_data 
> +{
> +        u8 chanselect_p0p1; // multiplex switch chans
> +};
> +
> +#endif // AD7739_H

Why is this .h file even needed?  Can't you put it into the .c file?

thanks,

greg k-h



More information about the devel mailing list