drivers/misc: add driver for Texas Instruments DAC7512
Subsystems (2)
PATCH 1/1 drivers/misc: add driver for Texas Instruments DAC7512
This is actually too trivial to publish, but to export the function of that chip to the userspace, a module like this is needed.
--- drivers/misc/Kconfig | 10 ++++ drivers/misc/Makefile | 1 + drivers/misc/ti_dac7512.c | 102 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 113 insertions(+), 0 deletions(-) create mode 100644 drivers/misc/ti_dac7512.c
drivers/misc/Kconfig +10 -0
@@ -246,6 +246,16 @@ config EP93XX_PWM To compile this driver as a module, choose M here: the module will be called ep93xx_pwm. +config TI_DAC7512 + tristate "Texas Instruments DAC7512" + depends on SPI && SYSFS + help + If you say yes here you get support for the Texas Instruments + DAC7512 16-bit digital-to-analog converter. + + This driver can also be built as a module. If so, the module + will be calles ti_dac7512. + source "drivers/misc/c2port/Kconfig" source "drivers/misc/eeprom/Kconfig" source "drivers/misc/cb710/Kconfig"
drivers/misc/Makefile +1 -0
@@ -20,6 +20,7 @@ obj-$(CONFIG_SGI_GRU) += sgi-gru/ obj-$(CONFIG_HP_ILO) += hpilo.o obj-$(CONFIG_ISL29003) += isl29003.o obj-$(CONFIG_EP93XX_PWM) += ep93xx_pwm.o +obj-$(CONFIG_TI_DAC7512) += ti_dac7512.o obj-$(CONFIG_C2PORT) += c2port/ obj-y += eeprom/ obj-y += cb710/
drivers/misc/ti_dac7512.c new file +102 -0
102 lines not on this page · raw message
Signature · 9 lines
1.6.0.4 ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference
RE: [spi-devel-general] [PATCH] drivers/misc: add driver for TexasInstruments DAC7512
Quoted 8 lines · Daniel Mack
This is actually too trivial to publish, but to export the function of that chip to the userspace, a module like this is needed.
Signed-off-by Daniel Mack <[email protected]>Cc Andrew Morton <akpm-de/[email protected]>Cc David Brownell <[email protected]>Cc spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org---
[snip]
Quoted 9 lines
drivers/misc/ti_dac7512.c new file +9
-0+static ssize_t dac7512_store_val (struct device *dev, +struct device_attribute *attr, +const char *buf,size_t count) +{ +struct spi_device *spi =to_spi_device (dev); +unsigned char tmp[2 ]; +unsigned long val; + +if (strict_strtoul (buf,10 , &val) <0 )
drivers/misc/ti_dac7512.c line 47
Quoted 10 lines
drivers/misc/ti_dac7512.c new file +10
-0+return -EINVAL ; + + tmp[0 ] = val >>8 ; + tmp[1 ] = val &0xff ; +spi_write (spi, tmp,sizeof (tmp)); +return count; +} + +static DEVICE_ATTR(value, S_IWUSR | S_IRUGO, + NULL, dac7512_store_val);
You have declared the "value" device attribute with mode S_IWUSR | S_IRUGO but have not provided a show callback.
Regards,
Hartley
------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
Re: [spi-devel-general] [PATCH] drivers/misc: add driver for TexasInstruments DAC7512
Quoted 26 lines · H Hartley Sweeten
Quoted 8 lines · Daniel Mack
This is actually too trivial to publish, but to export the function of that chip to the userspace, a module like this is needed.
Signed-off-by Daniel Mack <[email protected]>Cc Andrew Morton <akpm-de/[email protected]>Cc David Brownell <[email protected]>Cc spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org---
[snip]
Quoted 14 lines
drivers/misc/ti_dac7512.c new file +14
-0+static ssize_t dac7512_store_val (struct device *dev, +struct device_attribute *attr, +const char *buf,size_t count) +{ +struct spi_device *spi =to_spi_device (dev); +unsigned char tmp[2 ]; +unsigned long val; + +if (strict_strtoul (buf,10 , &val) <0 ) +return -EINVAL ; + + tmp[0 ] = val >>8 ; + tmp[1 ] = val &0xff ; +spi_write (spi, tmp,sizeof (tmp));
Quoted 8 lines
drivers/misc/ti_dac7512.c line 47
Quoted 5 lines
drivers/misc/ti_dac7512.c new file +5
-0+return count; +} + +static DEVICE_ATTR(value, S_IWUSR | S_IRUGO, + NULL, dac7512_store_val);You have declared the "value" device attribute with mode
S_IWUSR|S_IRUGObut have not provided a show callback.
That's true, and acutally on purpose. I would have needed a private data structure to allocate which I didn't do because I didn't need that. The approach is purely write-only, especially beacuse the hardware also does not provide a way to read back the current value.
Daniel
------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
Re: [spi-devel-general] [PATCH] drivers/misc: add driver for TexasInstruments DAC7512
In reply to H Hartley SweetenQuoted 26 lines · H Hartley Sweeten
Quoted 8 lines · Daniel Mack
This is actually too trivial to publish, but to export the function of that chip to the userspace, a module like this is needed.
Signed-off-by Daniel Mack <[email protected]>Cc Andrew Morton <[email protected]>Cc David Brownell <[email protected]>---
[snip]
Quoted 14 lines
(quoted diff) +14
-0+static ssize_t dac7512_store_val(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct spi_device *spi = to_spi_device(dev); + unsigned char tmp[2]; + unsigned long val; + + if (strict_strtoul(buf, 10, &val) < 0) + return -EINVAL; + + tmp[0] = val >> 8; + tmp[1] = val & 0xff; + spi_write(spi, tmp, sizeof(tmp));
Quoted 8 lines
Review
Quoted 5 lines
(quoted diff) +5
-0+ return count; +} + +static DEVICE_ATTR(value, S_IWUSR | S_IRUGO, + NULL, dac7512_store_val);You have declared the "value" device attribute with mode
S_IWUSR|S_IRUGObut have not provided a show callback.
Sorry, forget my last mail, I got you wrong. You're of course right, S_IRUGO shouldn't be set for write-only attributes. Updates patch below.
Thanks,
Daniel
Quoted 1 line
From
ab18a967e55d2bb1d39559333bca81a01c2838f0Mon Sep 17 00:00:00 2001
From: Daniel Mack <[email protected]>
Date: Thu, 8 Oct 2009 03:55:46 +0800
Subject: [PATCH] drivers/misc: add driver for Texas Instruments DAC7512
This is actually too trivial to publish, but to export the function of that chip to the userspace, a module like this is needed.
--- drivers/misc/Kconfig | 10 ++++ drivers/misc/Makefile | 1 + drivers/misc/ti_dac7512.c | 101 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 112 insertions(+), 0 deletions(-) create mode 100644 drivers/misc/ti_dac7512.c
drivers/misc/Kconfig +10 -0
@@ -246,6 +246,16 @@ config EP93XX_PWM To compile this driver as a module, choose M here: the module will be called ep93xx_pwm. +config TI_DAC7512 + tristate "Texas Instruments DAC7512" + depends on SPI && SYSFS + help + If you say yes here you get support for the Texas Instruments + DAC7512 16-bit digital-to-analog converter. + + This driver can also be built as a module. If so, the module + will be calles ti_dac7512. + source "drivers/misc/c2port/Kconfig" source "drivers/misc/eeprom/Kconfig" source "drivers/misc/cb710/Kconfig"
drivers/misc/Makefile +1 -0
@@ -20,6 +20,7 @@ obj-$(CONFIG_SGI_GRU) += sgi-gru/ obj-$(CONFIG_HP_ILO) += hpilo.o obj-$(CONFIG_ISL29003) += isl29003.o obj-$(CONFIG_EP93XX_PWM) += ep93xx_pwm.o +obj-$(CONFIG_TI_DAC7512) += ti_dac7512.o obj-$(CONFIG_C2PORT) += c2port/ obj-y += eeprom/ obj-y += cb710/
drivers/misc/ti_dac7512.c new file +101 -0
101 lines not on this page · raw message
Signature · 1 line
1.6.0.4