提交 557e2e2e 编写于 作者: L Linus Torvalds

Merge tag 'staging-3.6-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging

Pull staging fixes from Greg Kroah-Hartman:
 "Here are some staging driver fixes (and iio driver fixes, they get
  lumped in with the staging stuff due to dependancies) for your 3.6-rc3
  tree.

  Nothing major, just a bunch of fixes that people have reported.

  Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>"

* tag 'staging-3.6-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging: (26 commits)
  iio: lm3533-als: Fix build warnings
  staging:iio:ad7780: Mark channels as unsigned
  staging:iio:ad7192: Report offset and scale for temperature channel
  staging:iio:ad7192: Report channel offset
  staging:iio:ad7192: Mark channels as unsigned
  staging:iio:ad7192: Fix setting ACX
  staging:iio:ad7192: Add missing break in switch statement
  staging:iio:ad7793: Fix internal reference value
  staging:iio:ad7793: Follow new IIO naming spec
  staging:iio:ad7793: Fix temperature scale and offset
  staging:iio:ad7793: Report channel offset
  staging:iio:ad7793: Mark channels as unsigned
  staging:iio:ad7793: Add missing break in switch statement
  iio/adjd_s311: Fix potential memory leak in adjd_s311_update_scan_mode()
  iio: frequency: ADF4350: Fix potential reference div factor overflow.
  iio: staging: ad7298_ring: Fix maybe-uninitialized warning
  staging: comedi: usbduxfast: Declare MODULE_FIRMWARE usage
  staging: comedi: usbdux: Declare MODULE_FIRMWARE usage
  staging: comedi: usbduxsigma: Declare MODULE_FIRMWARE usage
  staging: csr: add INET dependancy
  ...
...@@ -129,7 +129,7 @@ static int adf4350_set_freq(struct adf4350_state *st, unsigned long long freq) ...@@ -129,7 +129,7 @@ static int adf4350_set_freq(struct adf4350_state *st, unsigned long long freq)
{ {
struct adf4350_platform_data *pdata = st->pdata; struct adf4350_platform_data *pdata = st->pdata;
u64 tmp; u64 tmp;
u32 div_gcd, prescaler; u32 div_gcd, prescaler, chspc;
u16 mdiv, r_cnt = 0; u16 mdiv, r_cnt = 0;
u8 band_sel_div; u8 band_sel_div;
...@@ -158,14 +158,20 @@ static int adf4350_set_freq(struct adf4350_state *st, unsigned long long freq) ...@@ -158,14 +158,20 @@ static int adf4350_set_freq(struct adf4350_state *st, unsigned long long freq)
if (pdata->ref_div_factor) if (pdata->ref_div_factor)
r_cnt = pdata->ref_div_factor - 1; r_cnt = pdata->ref_div_factor - 1;
do { chspc = st->chspc;
r_cnt = adf4350_tune_r_cnt(st, r_cnt);
st->r1_mod = st->fpfd / st->chspc; do {
while (st->r1_mod > ADF4350_MAX_MODULUS) { do {
do {
r_cnt = adf4350_tune_r_cnt(st, r_cnt); r_cnt = adf4350_tune_r_cnt(st, r_cnt);
st->r1_mod = st->fpfd / st->chspc; st->r1_mod = st->fpfd / chspc;
if (r_cnt > ADF4350_MAX_R_CNT) {
/* try higher spacing values */
chspc++;
r_cnt = 0;
} }
} while ((st->r1_mod > ADF4350_MAX_MODULUS) && r_cnt);
} while (r_cnt == 0);
tmp = freq * (u64)st->r1_mod + (st->fpfd > 1); tmp = freq * (u64)st->r1_mod + (st->fpfd > 1);
do_div(tmp, st->fpfd); /* Div round closest (n + d/2)/d */ do_div(tmp, st->fpfd); /* Div round closest (n + d/2)/d */
...@@ -194,7 +200,7 @@ static int adf4350_set_freq(struct adf4350_state *st, unsigned long long freq) ...@@ -194,7 +200,7 @@ static int adf4350_set_freq(struct adf4350_state *st, unsigned long long freq)
st->regs[ADF4350_REG0] = ADF4350_REG0_INT(st->r0_int) | st->regs[ADF4350_REG0] = ADF4350_REG0_INT(st->r0_int) |
ADF4350_REG0_FRACT(st->r0_fract); ADF4350_REG0_FRACT(st->r0_fract);
st->regs[ADF4350_REG1] = ADF4350_REG1_PHASE(0) | st->regs[ADF4350_REG1] = ADF4350_REG1_PHASE(1) |
ADF4350_REG1_MOD(st->r1_mod) | ADF4350_REG1_MOD(st->r1_mod) |
prescaler; prescaler;
......
...@@ -271,9 +271,10 @@ static int adjd_s311_update_scan_mode(struct iio_dev *indio_dev, ...@@ -271,9 +271,10 @@ static int adjd_s311_update_scan_mode(struct iio_dev *indio_dev,
const unsigned long *scan_mask) const unsigned long *scan_mask)
{ {
struct adjd_s311_data *data = iio_priv(indio_dev); struct adjd_s311_data *data = iio_priv(indio_dev);
data->buffer = krealloc(data->buffer, indio_dev->scan_bytes,
GFP_KERNEL); kfree(data->buffer);
if (!data->buffer) data->buffer = kmalloc(indio_dev->scan_bytes, GFP_KERNEL);
if (data->buffer == NULL)
return -ENOMEM; return -ENOMEM;
return 0; return 0;
......
...@@ -404,7 +404,7 @@ static int lm3533_als_get_hysteresis(struct iio_dev *indio_dev, unsigned nr, ...@@ -404,7 +404,7 @@ static int lm3533_als_get_hysteresis(struct iio_dev *indio_dev, unsigned nr,
return ret; return ret;
} }
static int show_thresh_either_en(struct device *dev, static ssize_t show_thresh_either_en(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
char *buf) char *buf)
{ {
...@@ -424,7 +424,7 @@ static int show_thresh_either_en(struct device *dev, ...@@ -424,7 +424,7 @@ static int show_thresh_either_en(struct device *dev,
return scnprintf(buf, PAGE_SIZE, "%u\n", enable); return scnprintf(buf, PAGE_SIZE, "%u\n", enable);
} }
static int store_thresh_either_en(struct device *dev, static ssize_t store_thresh_either_en(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
const char *buf, size_t len) const char *buf, size_t len)
{ {
......
...@@ -168,7 +168,7 @@ int comedi_device_attach(struct comedi_device *dev, struct comedi_devconfig *it) ...@@ -168,7 +168,7 @@ int comedi_device_attach(struct comedi_device *dev, struct comedi_devconfig *it)
dev->board_ptr = comedi_recognize(driv, it->board_name); dev->board_ptr = comedi_recognize(driv, it->board_name);
if (dev->board_ptr) if (dev->board_ptr)
break; break;
} else if (strcmp(driv->driver_name, it->board_name)) } else if (strcmp(driv->driver_name, it->board_name) == 0)
break; break;
module_put(driv->module); module_put(driv->module);
} }
......
...@@ -1349,9 +1349,6 @@ static struct pci_dev *pci1710_find_pci_dev(struct comedi_device *dev, ...@@ -1349,9 +1349,6 @@ static struct pci_dev *pci1710_find_pci_dev(struct comedi_device *dev,
} }
if (pcidev->vendor != PCI_VENDOR_ID_ADVANTECH) if (pcidev->vendor != PCI_VENDOR_ID_ADVANTECH)
continue; continue;
if (pci_is_enabled(pcidev))
continue;
if (strcmp(this_board->name, DRV_NAME) == 0) { if (strcmp(this_board->name, DRV_NAME) == 0) {
for (i = 0; i < ARRAY_SIZE(boardtypes); ++i) { for (i = 0; i < ARRAY_SIZE(boardtypes); ++i) {
if (pcidev->device == boardtypes[i].device_id) { if (pcidev->device == boardtypes[i].device_id) {
......
...@@ -301,8 +301,6 @@ static struct pci_dev *pci1723_find_pci_dev(struct comedi_device *dev, ...@@ -301,8 +301,6 @@ static struct pci_dev *pci1723_find_pci_dev(struct comedi_device *dev,
} }
if (pcidev->vendor != PCI_VENDOR_ID_ADVANTECH) if (pcidev->vendor != PCI_VENDOR_ID_ADVANTECH)
continue; continue;
if (pci_is_enabled(pcidev))
continue;
return pcidev; return pcidev;
} }
dev_err(dev->class_dev, dev_err(dev->class_dev,
......
...@@ -1064,8 +1064,6 @@ static struct pci_dev *pci_dio_find_pci_dev(struct comedi_device *dev, ...@@ -1064,8 +1064,6 @@ static struct pci_dev *pci_dio_find_pci_dev(struct comedi_device *dev,
slot != PCI_SLOT(pcidev->devfn)) slot != PCI_SLOT(pcidev->devfn))
continue; continue;
} }
if (pci_is_enabled(pcidev))
continue;
for (i = 0; i < ARRAY_SIZE(boardtypes); ++i) { for (i = 0; i < ARRAY_SIZE(boardtypes); ++i) {
if (boardtypes[i].vendor_id != pcidev->vendor) if (boardtypes[i].vendor_id != pcidev->vendor)
continue; continue;
......
...@@ -718,7 +718,8 @@ static struct pci_dev *daqboard2000_find_pci_dev(struct comedi_device *dev, ...@@ -718,7 +718,8 @@ static struct pci_dev *daqboard2000_find_pci_dev(struct comedi_device *dev,
continue; continue;
} }
if (pcidev->vendor != PCI_VENDOR_ID_IOTECH || if (pcidev->vendor != PCI_VENDOR_ID_IOTECH ||
pcidev->device != 0x0409) pcidev->device != 0x0409 ||
pcidev->subsystem_device != PCI_VENDOR_ID_IOTECH)
continue; continue;
for (i = 0; i < ARRAY_SIZE(boardtypes); i++) { for (i = 0; i < ARRAY_SIZE(boardtypes); i++) {
...@@ -739,6 +740,7 @@ static int daqboard2000_attach(struct comedi_device *dev, ...@@ -739,6 +740,7 @@ static int daqboard2000_attach(struct comedi_device *dev,
{ {
struct pci_dev *pcidev; struct pci_dev *pcidev;
struct comedi_subdevice *s; struct comedi_subdevice *s;
resource_size_t pci_base;
void *aux_data; void *aux_data;
unsigned int aux_len; unsigned int aux_len;
int result; int result;
...@@ -758,11 +760,12 @@ static int daqboard2000_attach(struct comedi_device *dev, ...@@ -758,11 +760,12 @@ static int daqboard2000_attach(struct comedi_device *dev,
"failed to enable PCI device and request regions\n"); "failed to enable PCI device and request regions\n");
return -EIO; return -EIO;
} }
dev->iobase = pci_resource_start(pcidev, 2); dev->iobase = 1; /* the "detach" needs this */
devpriv->plx = pci_base = pci_resource_start(pcidev, 0);
ioremap(pci_resource_start(pcidev, 0), DAQBOARD2000_PLX_SIZE); devpriv->plx = ioremap(pci_base, DAQBOARD2000_PLX_SIZE);
devpriv->daq = ioremap(dev->iobase, DAQBOARD2000_DAQ_SIZE); pci_base = pci_resource_start(pcidev, 2);
devpriv->daq = ioremap(pci_base, DAQBOARD2000_DAQ_SIZE);
if (!devpriv->plx || !devpriv->daq) if (!devpriv->plx || !devpriv->daq)
return -ENOMEM; return -ENOMEM;
...@@ -799,8 +802,6 @@ static int daqboard2000_attach(struct comedi_device *dev, ...@@ -799,8 +802,6 @@ static int daqboard2000_attach(struct comedi_device *dev,
printk("Interrupt after is: %x\n", interrupt); printk("Interrupt after is: %x\n", interrupt);
*/ */
dev->iobase = (unsigned long)devpriv->daq;
dev->board_name = this_board->name; dev->board_name = this_board->name;
s = dev->subdevices + 0; s = dev->subdevices + 0;
...@@ -824,7 +825,7 @@ static int daqboard2000_attach(struct comedi_device *dev, ...@@ -824,7 +825,7 @@ static int daqboard2000_attach(struct comedi_device *dev,
s = dev->subdevices + 2; s = dev->subdevices + 2;
result = subdev_8255_init(dev, s, daqboard2000_8255_cb, result = subdev_8255_init(dev, s, daqboard2000_8255_cb,
(unsigned long)(dev->iobase + 0x40)); (unsigned long)(devpriv->daq + 0x40));
out: out:
return result; return result;
......
...@@ -804,6 +804,7 @@ static int dt3000_attach(struct comedi_device *dev, struct comedi_devconfig *it) ...@@ -804,6 +804,7 @@ static int dt3000_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{ {
struct pci_dev *pcidev; struct pci_dev *pcidev;
struct comedi_subdevice *s; struct comedi_subdevice *s;
resource_size_t pci_base;
int ret = 0; int ret = 0;
dev_dbg(dev->class_dev, "dt3000:\n"); dev_dbg(dev->class_dev, "dt3000:\n");
...@@ -820,9 +821,10 @@ static int dt3000_attach(struct comedi_device *dev, struct comedi_devconfig *it) ...@@ -820,9 +821,10 @@ static int dt3000_attach(struct comedi_device *dev, struct comedi_devconfig *it)
ret = comedi_pci_enable(pcidev, "dt3000"); ret = comedi_pci_enable(pcidev, "dt3000");
if (ret < 0) if (ret < 0)
return ret; return ret;
dev->iobase = 1; /* the "detach" needs this */
dev->iobase = pci_resource_start(pcidev, 0); pci_base = pci_resource_start(pcidev, 0);
devpriv->io_addr = ioremap(dev->iobase, DT3000_SIZE); devpriv->io_addr = ioremap(pci_base, DT3000_SIZE);
if (!devpriv->io_addr) if (!devpriv->io_addr)
return -ENOMEM; return -ENOMEM;
......
...@@ -1619,9 +1619,8 @@ static int rtd_attach(struct comedi_device *dev, struct comedi_devconfig *it) ...@@ -1619,9 +1619,8 @@ static int rtd_attach(struct comedi_device *dev, struct comedi_devconfig *it)
struct rtdPrivate *devpriv; struct rtdPrivate *devpriv;
struct pci_dev *pcidev; struct pci_dev *pcidev;
struct comedi_subdevice *s; struct comedi_subdevice *s;
resource_size_t pci_base;
int ret; int ret;
resource_size_t physLas1; /* data area */
resource_size_t physLcfg; /* PLX9080 */
#ifdef USE_DMA #ifdef USE_DMA
int index; int index;
#endif #endif
...@@ -1655,20 +1654,15 @@ static int rtd_attach(struct comedi_device *dev, struct comedi_devconfig *it) ...@@ -1655,20 +1654,15 @@ static int rtd_attach(struct comedi_device *dev, struct comedi_devconfig *it)
printk(KERN_INFO "Failed to enable PCI device and request regions.\n"); printk(KERN_INFO "Failed to enable PCI device and request regions.\n");
return ret; return ret;
} }
dev->iobase = 1; /* the "detach" needs this */
/* /* Initialize the base addresses */
* Initialize base addresses pci_base = pci_resource_start(pcidev, LAS0_PCIINDEX);
*/ devpriv->las0 = ioremap_nocache(pci_base, LAS0_PCISIZE);
/* Get the physical address from PCI config */ pci_base = pci_resource_start(pcidev, LAS1_PCIINDEX);
dev->iobase = pci_resource_start(pcidev, LAS0_PCIINDEX); devpriv->las1 = ioremap_nocache(pci_base, LAS1_PCISIZE);
physLas1 = pci_resource_start(pcidev, LAS1_PCIINDEX); pci_base = pci_resource_start(pcidev, LCFG_PCIINDEX);
physLcfg = pci_resource_start(pcidev, LCFG_PCIINDEX); devpriv->lcfg = ioremap_nocache(pci_base, LCFG_PCISIZE);
/* Now have the kernel map this into memory */
/* ASSUME page aligned */
devpriv->las0 = ioremap_nocache(dev->iobase, LAS0_PCISIZE);
devpriv->las1 = ioremap_nocache(physLas1, LAS1_PCISIZE);
devpriv->lcfg = ioremap_nocache(physLcfg, LCFG_PCISIZE);
if (!devpriv->las0 || !devpriv->las1 || !devpriv->lcfg) if (!devpriv->las0 || !devpriv->las1 || !devpriv->lcfg)
return -ENOMEM; return -ENOMEM;
......
...@@ -102,6 +102,7 @@ sampling rate. If you sample two channels you get 4kHz and so on. ...@@ -102,6 +102,7 @@ sampling rate. If you sample two channels you get 4kHz and so on.
#define BULK_TIMEOUT 1000 #define BULK_TIMEOUT 1000
/* constants for "firmware" upload and download */ /* constants for "firmware" upload and download */
#define FIRMWARE "usbdux_firmware.bin"
#define USBDUXSUB_FIRMWARE 0xA0 #define USBDUXSUB_FIRMWARE 0xA0
#define VENDOR_DIR_IN 0xC0 #define VENDOR_DIR_IN 0xC0
#define VENDOR_DIR_OUT 0x40 #define VENDOR_DIR_OUT 0x40
...@@ -2791,7 +2792,7 @@ static int usbdux_usb_probe(struct usb_interface *uinterf, ...@@ -2791,7 +2792,7 @@ static int usbdux_usb_probe(struct usb_interface *uinterf,
ret = request_firmware_nowait(THIS_MODULE, ret = request_firmware_nowait(THIS_MODULE,
FW_ACTION_HOTPLUG, FW_ACTION_HOTPLUG,
"usbdux_firmware.bin", FIRMWARE,
&udev->dev, &udev->dev,
GFP_KERNEL, GFP_KERNEL,
usbduxsub + index, usbduxsub + index,
...@@ -2850,3 +2851,4 @@ module_comedi_usb_driver(usbdux_driver, usbdux_usb_driver); ...@@ -2850,3 +2851,4 @@ module_comedi_usb_driver(usbdux_driver, usbdux_usb_driver);
MODULE_AUTHOR("Bernd Porr, BerndPorr@f2s.com"); MODULE_AUTHOR("Bernd Porr, BerndPorr@f2s.com");
MODULE_DESCRIPTION("Stirling/ITL USB-DUX -- Bernd.Porr@f2s.com"); MODULE_DESCRIPTION("Stirling/ITL USB-DUX -- Bernd.Porr@f2s.com");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_FIRMWARE(FIRMWARE);
...@@ -57,6 +57,7 @@ ...@@ -57,6 +57,7 @@
/* /*
* constants for "firmware" upload and download * constants for "firmware" upload and download
*/ */
#define FIRMWARE "usbduxfast_firmware.bin"
#define USBDUXFASTSUB_FIRMWARE 0xA0 #define USBDUXFASTSUB_FIRMWARE 0xA0
#define VENDOR_DIR_IN 0xC0 #define VENDOR_DIR_IN 0xC0
#define VENDOR_DIR_OUT 0x40 #define VENDOR_DIR_OUT 0x40
...@@ -1706,7 +1707,7 @@ static int usbduxfast_usb_probe(struct usb_interface *uinterf, ...@@ -1706,7 +1707,7 @@ static int usbduxfast_usb_probe(struct usb_interface *uinterf,
ret = request_firmware_nowait(THIS_MODULE, ret = request_firmware_nowait(THIS_MODULE,
FW_ACTION_HOTPLUG, FW_ACTION_HOTPLUG,
"usbduxfast_firmware.bin", FIRMWARE,
&udev->dev, &udev->dev,
GFP_KERNEL, GFP_KERNEL,
usbduxfastsub + index, usbduxfastsub + index,
...@@ -1774,3 +1775,4 @@ module_comedi_usb_driver(usbduxfast_driver, usbduxfast_usb_driver); ...@@ -1774,3 +1775,4 @@ module_comedi_usb_driver(usbduxfast_driver, usbduxfast_usb_driver);
MODULE_AUTHOR("Bernd Porr, BerndPorr@f2s.com"); MODULE_AUTHOR("Bernd Porr, BerndPorr@f2s.com");
MODULE_DESCRIPTION("USB-DUXfast, BerndPorr@f2s.com"); MODULE_DESCRIPTION("USB-DUXfast, BerndPorr@f2s.com");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_FIRMWARE(FIRMWARE);
...@@ -63,6 +63,7 @@ Status: testing ...@@ -63,6 +63,7 @@ Status: testing
#define BULK_TIMEOUT 1000 #define BULK_TIMEOUT 1000
/* constants for "firmware" upload and download */ /* constants for "firmware" upload and download */
#define FIRMWARE "usbduxsigma_firmware.bin"
#define USBDUXSUB_FIRMWARE 0xA0 #define USBDUXSUB_FIRMWARE 0xA0
#define VENDOR_DIR_IN 0xC0 #define VENDOR_DIR_IN 0xC0
#define VENDOR_DIR_OUT 0x40 #define VENDOR_DIR_OUT 0x40
...@@ -2780,7 +2781,7 @@ static int usbduxsigma_usb_probe(struct usb_interface *uinterf, ...@@ -2780,7 +2781,7 @@ static int usbduxsigma_usb_probe(struct usb_interface *uinterf,
ret = request_firmware_nowait(THIS_MODULE, ret = request_firmware_nowait(THIS_MODULE,
FW_ACTION_HOTPLUG, FW_ACTION_HOTPLUG,
"usbduxsigma_firmware.bin", FIRMWARE,
&udev->dev, &udev->dev,
GFP_KERNEL, GFP_KERNEL,
usbduxsub + index, usbduxsub + index,
...@@ -2845,3 +2846,4 @@ module_comedi_usb_driver(usbduxsigma_driver, usbduxsigma_usb_driver); ...@@ -2845,3 +2846,4 @@ module_comedi_usb_driver(usbduxsigma_driver, usbduxsigma_usb_driver);
MODULE_AUTHOR("Bernd Porr, BerndPorr@f2s.com"); MODULE_AUTHOR("Bernd Porr, BerndPorr@f2s.com");
MODULE_DESCRIPTION("Stirling/ITL USB-DUX SIGMA -- Bernd.Porr@f2s.com"); MODULE_DESCRIPTION("Stirling/ITL USB-DUX SIGMA -- Bernd.Porr@f2s.com");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_FIRMWARE(FIRMWARE);
config CSR_WIFI config CSR_WIFI
tristate "CSR wireless driver" tristate "CSR wireless driver"
depends on MMC && CFG80211_WEXT depends on MMC && CFG80211_WEXT && INET
select WIRELESS_EXT select WIRELESS_EXT
select WEXT_PRIV select WEXT_PRIV
help help
......
...@@ -754,7 +754,7 @@ static ssize_t ad7192_set(struct device *dev, ...@@ -754,7 +754,7 @@ static ssize_t ad7192_set(struct device *dev,
else else
st->mode &= ~AD7192_MODE_ACX; st->mode &= ~AD7192_MODE_ACX;
ad7192_write_reg(st, AD7192_REG_GPOCON, 3, st->mode); ad7192_write_reg(st, AD7192_REG_MODE, 3, st->mode);
break; break;
default: default:
ret = -EINVAL; ret = -EINVAL;
...@@ -798,6 +798,11 @@ static const struct attribute_group ad7195_attribute_group = { ...@@ -798,6 +798,11 @@ static const struct attribute_group ad7195_attribute_group = {
.attrs = ad7195_attributes, .attrs = ad7195_attributes,
}; };
static unsigned int ad7192_get_temp_scale(bool unipolar)
{
return unipolar ? 2815 * 2 : 2815;
}
static int ad7192_read_raw(struct iio_dev *indio_dev, static int ad7192_read_raw(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan, struct iio_chan_spec const *chan,
int *val, int *val,
...@@ -824,19 +829,6 @@ static int ad7192_read_raw(struct iio_dev *indio_dev, ...@@ -824,19 +829,6 @@ static int ad7192_read_raw(struct iio_dev *indio_dev,
*val = (smpl >> chan->scan_type.shift) & *val = (smpl >> chan->scan_type.shift) &
((1 << (chan->scan_type.realbits)) - 1); ((1 << (chan->scan_type.realbits)) - 1);
switch (chan->type) {
case IIO_VOLTAGE:
if (!unipolar)
*val -= (1 << (chan->scan_type.realbits - 1));
break;
case IIO_TEMP:
*val -= 0x800000;
*val /= 2815; /* temp Kelvin */
*val -= 273; /* temp Celsius */
break;
default:
return -EINVAL;
}
return IIO_VAL_INT; return IIO_VAL_INT;
case IIO_CHAN_INFO_SCALE: case IIO_CHAN_INFO_SCALE:
...@@ -848,11 +840,21 @@ static int ad7192_read_raw(struct iio_dev *indio_dev, ...@@ -848,11 +840,21 @@ static int ad7192_read_raw(struct iio_dev *indio_dev,
mutex_unlock(&indio_dev->mlock); mutex_unlock(&indio_dev->mlock);
return IIO_VAL_INT_PLUS_NANO; return IIO_VAL_INT_PLUS_NANO;
case IIO_TEMP: case IIO_TEMP:
*val = 1000; *val = 0;
return IIO_VAL_INT; *val2 = 1000000000 / ad7192_get_temp_scale(unipolar);
return IIO_VAL_INT_PLUS_NANO;
default: default:
return -EINVAL; return -EINVAL;
} }
case IIO_CHAN_INFO_OFFSET:
if (!unipolar)
*val = -(1 << (chan->scan_type.realbits - 1));
else
*val = 0;
/* Kelvin to Celsius */
if (chan->type == IIO_TEMP)
*val -= 273 * ad7192_get_temp_scale(unipolar);
return IIO_VAL_INT;
} }
return -EINVAL; return -EINVAL;
...@@ -890,7 +892,7 @@ static int ad7192_write_raw(struct iio_dev *indio_dev, ...@@ -890,7 +892,7 @@ static int ad7192_write_raw(struct iio_dev *indio_dev,
} }
ret = 0; ret = 0;
} }
break;
default: default:
ret = -EINVAL; ret = -EINVAL;
} }
...@@ -942,20 +944,22 @@ static const struct iio_info ad7195_info = { ...@@ -942,20 +944,22 @@ static const struct iio_info ad7195_info = {
.channel = _chan, \ .channel = _chan, \
.channel2 = _chan2, \ .channel2 = _chan2, \
.info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | \ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | \
IIO_CHAN_INFO_SCALE_SHARED_BIT, \ IIO_CHAN_INFO_SCALE_SHARED_BIT | \
IIO_CHAN_INFO_OFFSET_SHARED_BIT, \
.address = _address, \ .address = _address, \
.scan_index = _si, \ .scan_index = _si, \
.scan_type = IIO_ST('s', 24, 32, 0)} .scan_type = IIO_ST('u', 24, 32, 0)}
#define AD7192_CHAN(_chan, _address, _si) \ #define AD7192_CHAN(_chan, _address, _si) \
{ .type = IIO_VOLTAGE, \ { .type = IIO_VOLTAGE, \
.indexed = 1, \ .indexed = 1, \
.channel = _chan, \ .channel = _chan, \
.info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | \ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | \
IIO_CHAN_INFO_SCALE_SHARED_BIT, \ IIO_CHAN_INFO_SCALE_SHARED_BIT | \
IIO_CHAN_INFO_OFFSET_SHARED_BIT, \
.address = _address, \ .address = _address, \
.scan_index = _si, \ .scan_index = _si, \
.scan_type = IIO_ST('s', 24, 32, 0)} .scan_type = IIO_ST('u', 24, 32, 0)}
#define AD7192_CHAN_TEMP(_chan, _address, _si) \ #define AD7192_CHAN_TEMP(_chan, _address, _si) \
{ .type = IIO_TEMP, \ { .type = IIO_TEMP, \
...@@ -965,7 +969,7 @@ static const struct iio_info ad7195_info = { ...@@ -965,7 +969,7 @@ static const struct iio_info ad7195_info = {
IIO_CHAN_INFO_SCALE_SEPARATE_BIT, \ IIO_CHAN_INFO_SCALE_SEPARATE_BIT, \
.address = _address, \ .address = _address, \
.scan_index = _si, \ .scan_index = _si, \
.scan_type = IIO_ST('s', 24, 32, 0)} .scan_type = IIO_ST('u', 24, 32, 0)}
static struct iio_chan_spec ad7192_channels[] = { static struct iio_chan_spec ad7192_channels[] = {
AD7192_CHAN_DIFF(1, 2, NULL, AD7192_CH_AIN1P_AIN2M, 0), AD7192_CHAN_DIFF(1, 2, NULL, AD7192_CH_AIN1P_AIN2M, 0),
......
...@@ -76,7 +76,7 @@ static irqreturn_t ad7298_trigger_handler(int irq, void *p) ...@@ -76,7 +76,7 @@ static irqreturn_t ad7298_trigger_handler(int irq, void *p)
struct iio_dev *indio_dev = pf->indio_dev; struct iio_dev *indio_dev = pf->indio_dev;
struct ad7298_state *st = iio_priv(indio_dev); struct ad7298_state *st = iio_priv(indio_dev);
struct iio_buffer *ring = indio_dev->buffer; struct iio_buffer *ring = indio_dev->buffer;
s64 time_ns; s64 time_ns = 0;
__u16 buf[16]; __u16 buf[16];
int b_sent, i; int b_sent, i;
......
...@@ -131,9 +131,10 @@ static const struct ad7780_chip_info ad7780_chip_info_tbl[] = { ...@@ -131,9 +131,10 @@ static const struct ad7780_chip_info ad7780_chip_info_tbl[] = {
.indexed = 1, .indexed = 1,
.channel = 0, .channel = 0,
.info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SHARED_BIT, IIO_CHAN_INFO_SCALE_SHARED_BIT |
IIO_CHAN_INFO_OFFSET_SHARED_BIT,
.scan_type = { .scan_type = {
.sign = 's', .sign = 'u',
.realbits = 24, .realbits = 24,
.storagebits = 32, .storagebits = 32,
.shift = 8, .shift = 8,
...@@ -146,9 +147,10 @@ static const struct ad7780_chip_info ad7780_chip_info_tbl[] = { ...@@ -146,9 +147,10 @@ static const struct ad7780_chip_info ad7780_chip_info_tbl[] = {
.indexed = 1, .indexed = 1,
.channel = 0, .channel = 0,
.info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SHARED_BIT, IIO_CHAN_INFO_SCALE_SHARED_BIT |
IIO_CHAN_INFO_OFFSET_SHARED_BIT,
.scan_type = { .scan_type = {
.sign = 's', .sign = 'u',
.realbits = 20, .realbits = 20,
.storagebits = 32, .storagebits = 32,
.shift = 12, .shift = 12,
......
...@@ -563,8 +563,9 @@ static ssize_t ad7793_show_scale_available(struct device *dev, ...@@ -563,8 +563,9 @@ static ssize_t ad7793_show_scale_available(struct device *dev,
return len; return len;
} }
static IIO_DEVICE_ATTR_NAMED(in_m_in_scale_available, in-in_scale_available, static IIO_DEVICE_ATTR_NAMED(in_m_in_scale_available,
S_IRUGO, ad7793_show_scale_available, NULL, 0); in_voltage-voltage_scale_available, S_IRUGO,
ad7793_show_scale_available, NULL, 0);
static struct attribute *ad7793_attributes[] = { static struct attribute *ad7793_attributes[] = {
&iio_dev_attr_sampling_frequency.dev_attr.attr, &iio_dev_attr_sampling_frequency.dev_attr.attr,
...@@ -604,9 +605,6 @@ static int ad7793_read_raw(struct iio_dev *indio_dev, ...@@ -604,9 +605,6 @@ static int ad7793_read_raw(struct iio_dev *indio_dev,
*val = (smpl >> chan->scan_type.shift) & *val = (smpl >> chan->scan_type.shift) &
((1 << (chan->scan_type.realbits)) - 1); ((1 << (chan->scan_type.realbits)) - 1);
if (!unipolar)
*val -= (1 << (chan->scan_type.realbits - 1));
return IIO_VAL_INT; return IIO_VAL_INT;
case IIO_CHAN_INFO_SCALE: case IIO_CHAN_INFO_SCALE:
...@@ -620,25 +618,38 @@ static int ad7793_read_raw(struct iio_dev *indio_dev, ...@@ -620,25 +618,38 @@ static int ad7793_read_raw(struct iio_dev *indio_dev,
return IIO_VAL_INT_PLUS_NANO; return IIO_VAL_INT_PLUS_NANO;
} else { } else {
/* 1170mV / 2^23 * 6 */ /* 1170mV / 2^23 * 6 */
scale_uv = (1170ULL * 100000000ULL * 6ULL) scale_uv = (1170ULL * 100000000ULL * 6ULL);
>> (chan->scan_type.realbits -
(unipolar ? 0 : 1));
} }
break; break;
case IIO_TEMP: case IIO_TEMP:
/* Always uses unity gain and internal ref */ /* 1170mV / 0.81 mV/C / 2^23 */
scale_uv = (2500ULL * 100000000ULL) scale_uv = 1444444444444ULL;
>> (chan->scan_type.realbits -
(unipolar ? 0 : 1));
break; break;
default: default:
return -EINVAL; return -EINVAL;
} }
*val2 = do_div(scale_uv, 100000000) * 10; scale_uv >>= (chan->scan_type.realbits - (unipolar ? 0 : 1));
*val = scale_uv; *val = 0;
*val2 = scale_uv;
return IIO_VAL_INT_PLUS_NANO; return IIO_VAL_INT_PLUS_NANO;
case IIO_CHAN_INFO_OFFSET:
if (!unipolar)
*val = -(1 << (chan->scan_type.realbits - 1));
else
*val = 0;
/* Kelvin to Celsius */
if (chan->type == IIO_TEMP) {
unsigned long long offset;
unsigned int shift;
shift = chan->scan_type.realbits - (unipolar ? 0 : 1);
offset = 273ULL << shift;
do_div(offset, 1444);
*val -= offset;
}
return IIO_VAL_INT;
} }
return -EINVAL; return -EINVAL;
} }
...@@ -676,7 +687,7 @@ static int ad7793_write_raw(struct iio_dev *indio_dev, ...@@ -676,7 +687,7 @@ static int ad7793_write_raw(struct iio_dev *indio_dev,
} }
ret = 0; ret = 0;
} }
break;
default: default:
ret = -EINVAL; ret = -EINVAL;
} }
...@@ -720,9 +731,10 @@ static const struct ad7793_chip_info ad7793_chip_info_tbl[] = { ...@@ -720,9 +731,10 @@ static const struct ad7793_chip_info ad7793_chip_info_tbl[] = {
.channel2 = 0, .channel2 = 0,
.address = AD7793_CH_AIN1P_AIN1M, .address = AD7793_CH_AIN1P_AIN1M,
.info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SHARED_BIT, IIO_CHAN_INFO_SCALE_SHARED_BIT |
IIO_CHAN_INFO_OFFSET_SHARED_BIT,
.scan_index = 0, .scan_index = 0,
.scan_type = IIO_ST('s', 24, 32, 0) .scan_type = IIO_ST('u', 24, 32, 0)
}, },
.channel[1] = { .channel[1] = {
.type = IIO_VOLTAGE, .type = IIO_VOLTAGE,
...@@ -732,9 +744,10 @@ static const struct ad7793_chip_info ad7793_chip_info_tbl[] = { ...@@ -732,9 +744,10 @@ static const struct ad7793_chip_info ad7793_chip_info_tbl[] = {
.channel2 = 1, .channel2 = 1,
.address = AD7793_CH_AIN2P_AIN2M, .address = AD7793_CH_AIN2P_AIN2M,
.info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SHARED_BIT, IIO_CHAN_INFO_SCALE_SHARED_BIT |
IIO_CHAN_INFO_OFFSET_SHARED_BIT,
.scan_index = 1, .scan_index = 1,
.scan_type = IIO_ST('s', 24, 32, 0) .scan_type = IIO_ST('u', 24, 32, 0)
}, },
.channel[2] = { .channel[2] = {
.type = IIO_VOLTAGE, .type = IIO_VOLTAGE,
...@@ -744,9 +757,10 @@ static const struct ad7793_chip_info ad7793_chip_info_tbl[] = { ...@@ -744,9 +757,10 @@ static const struct ad7793_chip_info ad7793_chip_info_tbl[] = {
.channel2 = 2, .channel2 = 2,
.address = AD7793_CH_AIN3P_AIN3M, .address = AD7793_CH_AIN3P_AIN3M,
.info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SHARED_BIT, IIO_CHAN_INFO_SCALE_SHARED_BIT |
IIO_CHAN_INFO_OFFSET_SHARED_BIT,
.scan_index = 2, .scan_index = 2,
.scan_type = IIO_ST('s', 24, 32, 0) .scan_type = IIO_ST('u', 24, 32, 0)
}, },
.channel[3] = { .channel[3] = {
.type = IIO_VOLTAGE, .type = IIO_VOLTAGE,
...@@ -757,9 +771,10 @@ static const struct ad7793_chip_info ad7793_chip_info_tbl[] = { ...@@ -757,9 +771,10 @@ static const struct ad7793_chip_info ad7793_chip_info_tbl[] = {
.channel2 = 2, .channel2 = 2,
.address = AD7793_CH_AIN1M_AIN1M, .address = AD7793_CH_AIN1M_AIN1M,
.info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SHARED_BIT, IIO_CHAN_INFO_SCALE_SHARED_BIT |
IIO_CHAN_INFO_OFFSET_SHARED_BIT,
.scan_index = 3, .scan_index = 3,
.scan_type = IIO_ST('s', 24, 32, 0) .scan_type = IIO_ST('u', 24, 32, 0)
}, },
.channel[4] = { .channel[4] = {
.type = IIO_TEMP, .type = IIO_TEMP,
...@@ -769,7 +784,7 @@ static const struct ad7793_chip_info ad7793_chip_info_tbl[] = { ...@@ -769,7 +784,7 @@ static const struct ad7793_chip_info ad7793_chip_info_tbl[] = {
.info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SEPARATE_BIT, IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
.scan_index = 4, .scan_index = 4,
.scan_type = IIO_ST('s', 24, 32, 0), .scan_type = IIO_ST('u', 24, 32, 0),
}, },
.channel[5] = { .channel[5] = {
.type = IIO_VOLTAGE, .type = IIO_VOLTAGE,
...@@ -778,9 +793,10 @@ static const struct ad7793_chip_info ad7793_chip_info_tbl[] = { ...@@ -778,9 +793,10 @@ static const struct ad7793_chip_info ad7793_chip_info_tbl[] = {
.channel = 4, .channel = 4,
.address = AD7793_CH_AVDD_MONITOR, .address = AD7793_CH_AVDD_MONITOR,
.info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SEPARATE_BIT, IIO_CHAN_INFO_SCALE_SEPARATE_BIT |
IIO_CHAN_INFO_OFFSET_SHARED_BIT,
.scan_index = 5, .scan_index = 5,
.scan_type = IIO_ST('s', 24, 32, 0), .scan_type = IIO_ST('u', 24, 32, 0),
}, },
.channel[6] = IIO_CHAN_SOFT_TIMESTAMP(6), .channel[6] = IIO_CHAN_SOFT_TIMESTAMP(6),
}, },
...@@ -793,9 +809,10 @@ static const struct ad7793_chip_info ad7793_chip_info_tbl[] = { ...@@ -793,9 +809,10 @@ static const struct ad7793_chip_info ad7793_chip_info_tbl[] = {
.channel2 = 0, .channel2 = 0,
.address = AD7793_CH_AIN1P_AIN1M, .address = AD7793_CH_AIN1P_AIN1M,
.info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SHARED_BIT, IIO_CHAN_INFO_SCALE_SHARED_BIT |
IIO_CHAN_INFO_OFFSET_SHARED_BIT,
.scan_index = 0, .scan_index = 0,
.scan_type = IIO_ST('s', 16, 32, 0) .scan_type = IIO_ST('u', 16, 32, 0)
}, },
.channel[1] = { .channel[1] = {
.type = IIO_VOLTAGE, .type = IIO_VOLTAGE,
...@@ -805,9 +822,10 @@ static const struct ad7793_chip_info ad7793_chip_info_tbl[] = { ...@@ -805,9 +822,10 @@ static const struct ad7793_chip_info ad7793_chip_info_tbl[] = {
.channel2 = 1, .channel2 = 1,
.address = AD7793_CH_AIN2P_AIN2M, .address = AD7793_CH_AIN2P_AIN2M,
.info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SHARED_BIT, IIO_CHAN_INFO_SCALE_SHARED_BIT |
IIO_CHAN_INFO_OFFSET_SHARED_BIT,
.scan_index = 1, .scan_index = 1,
.scan_type = IIO_ST('s', 16, 32, 0) .scan_type = IIO_ST('u', 16, 32, 0)
}, },
.channel[2] = { .channel[2] = {
.type = IIO_VOLTAGE, .type = IIO_VOLTAGE,
...@@ -817,9 +835,10 @@ static const struct ad7793_chip_info ad7793_chip_info_tbl[] = { ...@@ -817,9 +835,10 @@ static const struct ad7793_chip_info ad7793_chip_info_tbl[] = {
.channel2 = 2, .channel2 = 2,
.address = AD7793_CH_AIN3P_AIN3M, .address = AD7793_CH_AIN3P_AIN3M,
.info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SHARED_BIT, IIO_CHAN_INFO_SCALE_SHARED_BIT |
IIO_CHAN_INFO_OFFSET_SHARED_BIT,
.scan_index = 2, .scan_index = 2,
.scan_type = IIO_ST('s', 16, 32, 0) .scan_type = IIO_ST('u', 16, 32, 0)
}, },
.channel[3] = { .channel[3] = {
.type = IIO_VOLTAGE, .type = IIO_VOLTAGE,
...@@ -830,9 +849,10 @@ static const struct ad7793_chip_info ad7793_chip_info_tbl[] = { ...@@ -830,9 +849,10 @@ static const struct ad7793_chip_info ad7793_chip_info_tbl[] = {
.channel2 = 2, .channel2 = 2,
.address = AD7793_CH_AIN1M_AIN1M, .address = AD7793_CH_AIN1M_AIN1M,
.info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SHARED_BIT, IIO_CHAN_INFO_SCALE_SHARED_BIT |
IIO_CHAN_INFO_OFFSET_SHARED_BIT,
.scan_index = 3, .scan_index = 3,
.scan_type = IIO_ST('s', 16, 32, 0) .scan_type = IIO_ST('u', 16, 32, 0)
}, },
.channel[4] = { .channel[4] = {
.type = IIO_TEMP, .type = IIO_TEMP,
...@@ -842,7 +862,7 @@ static const struct ad7793_chip_info ad7793_chip_info_tbl[] = { ...@@ -842,7 +862,7 @@ static const struct ad7793_chip_info ad7793_chip_info_tbl[] = {
.info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SEPARATE_BIT, IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
.scan_index = 4, .scan_index = 4,
.scan_type = IIO_ST('s', 16, 32, 0), .scan_type = IIO_ST('u', 16, 32, 0),
}, },
.channel[5] = { .channel[5] = {
.type = IIO_VOLTAGE, .type = IIO_VOLTAGE,
...@@ -851,9 +871,10 @@ static const struct ad7793_chip_info ad7793_chip_info_tbl[] = { ...@@ -851,9 +871,10 @@ static const struct ad7793_chip_info ad7793_chip_info_tbl[] = {
.channel = 4, .channel = 4,
.address = AD7793_CH_AVDD_MONITOR, .address = AD7793_CH_AVDD_MONITOR,
.info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SEPARATE_BIT, IIO_CHAN_INFO_SCALE_SEPARATE_BIT |
IIO_CHAN_INFO_OFFSET_SHARED_BIT,
.scan_index = 5, .scan_index = 5,
.scan_type = IIO_ST('s', 16, 32, 0), .scan_type = IIO_ST('u', 16, 32, 0),
}, },
.channel[6] = IIO_CHAN_SOFT_TIMESTAMP(6), .channel[6] = IIO_CHAN_SOFT_TIMESTAMP(6),
}, },
...@@ -901,7 +922,7 @@ static int __devinit ad7793_probe(struct spi_device *spi) ...@@ -901,7 +922,7 @@ static int __devinit ad7793_probe(struct spi_device *spi)
else if (voltage_uv) else if (voltage_uv)
st->int_vref_mv = voltage_uv / 1000; st->int_vref_mv = voltage_uv / 1000;
else else
st->int_vref_mv = 2500; /* Build-in ref */ st->int_vref_mv = 1170; /* Build-in ref */
spi_set_drvdata(spi, indio_dev); spi_set_drvdata(spi, indio_dev);
st->spi = spi; st->spi = spi;
......
...@@ -87,6 +87,8 @@ ...@@ -87,6 +87,8 @@
#define ADF4350_MAX_BANDSEL_CLK 125000 /* Hz */ #define ADF4350_MAX_BANDSEL_CLK 125000 /* Hz */
#define ADF4350_MAX_FREQ_REFIN 250000000 /* Hz */ #define ADF4350_MAX_FREQ_REFIN 250000000 /* Hz */
#define ADF4350_MAX_MODULUS 4095 #define ADF4350_MAX_MODULUS 4095
#define ADF4350_MAX_R_CNT 1023
/** /**
* struct adf4350_platform_data - platform specific information * struct adf4350_platform_data - platform specific information
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册