Skip to content

Commit

Permalink
Merge tag 'staging-3.12-rc2' of git://git.kernel.org/pub/scm/linux/ke…
Browse files Browse the repository at this point in the history
…rnel/git/gregkh/staging

Pull staging fixes from Greg KH:
 "Here are a number of small staging tree and iio driver fixes.  Nothing
  major, just lots of little things"

* tag 'staging-3.12-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging: (34 commits)
  iio:buffer_cb: Add missing iio_buffer_init()
  iio: Prevent race between IIO chardev opening and IIO device free
  iio: fix: Keep a reference to the IIO device for open file descriptors
  iio: Stop sampling when the device is removed
  iio: Fix crash when scan_bytes is computed with active_scan_mask == NULL
  iio: Fix mcp4725 dev-to-indio_dev conversion in suspend/resume
  iio: Fix bma180 dev-to-indio_dev conversion in suspend/resume
  iio: Fix tmp006 dev-to-indio_dev conversion in suspend/resume
  iio: iio_device_add_event_sysfs() bugfix
  staging: iio: ade7854-spi: Fix return value
  staging:iio:hmc5843: Fix measurement conversion
  iio: isl29018: Fix uninitialized value
  staging:iio:dummy fix kfifo_buf kconfig dependency issue if kfifo modular and buffer enabled for built in dummy driver.
  iio: at91: fix adc_clk overflow
  staging: line6: add bounds check in snd_toneport_source_put()
  Staging: comedi: Fix dependencies for drivers misclassified as PCI
  staging: r8188eu: Adjust RX gain
  staging: r8188eu: Fix smatch warning in core/rtw_ieee80211.
  staging: r8188eu: Fix smatch error in core/rtw_mlme_ext.c
  staging: r8188eu: Fix Smatch off-by-one warning in hal/rtl8188e_hal_init.c
  ...
  • Loading branch information
torvalds committed Sep 23, 2013
2 parents e04a0a5 + 6174081 commit 9d23108
Show file tree
Hide file tree
Showing 35 changed files with 160 additions and 97 deletions.
4 changes: 2 additions & 2 deletions drivers/iio/accel/bma180.c
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ static int bma180_remove(struct i2c_client *client)
#ifdef CONFIG_PM_SLEEP
static int bma180_suspend(struct device *dev)
{
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
struct bma180_data *data = iio_priv(indio_dev);
int ret;

Expand All @@ -633,7 +633,7 @@ static int bma180_suspend(struct device *dev)

static int bma180_resume(struct device *dev)
{
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
struct bma180_data *data = iio_priv(indio_dev);
int ret;

Expand Down
11 changes: 6 additions & 5 deletions drivers/iio/adc/at91_adc.c
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ static const struct iio_info at91_adc_info = {

static int at91_adc_probe(struct platform_device *pdev)
{
unsigned int prsc, mstrclk, ticks, adc_clk, shtim;
unsigned int prsc, mstrclk, ticks, adc_clk, adc_clk_khz, shtim;
int ret;
struct iio_dev *idev;
struct at91_adc_state *st;
Expand Down Expand Up @@ -649,6 +649,7 @@ static int at91_adc_probe(struct platform_device *pdev)
*/
mstrclk = clk_get_rate(st->clk);
adc_clk = clk_get_rate(st->adc_clk);
adc_clk_khz = adc_clk / 1000;
prsc = (mstrclk / (2 * adc_clk)) - 1;

if (!st->startup_time) {
Expand All @@ -662,15 +663,15 @@ static int at91_adc_probe(struct platform_device *pdev)
* defined in the electrical characteristics of the board, divided by 8.
* The formula thus is : Startup Time = (ticks + 1) * 8 / ADC Clock
*/
ticks = round_up((st->startup_time * adc_clk /
1000000) - 1, 8) / 8;
ticks = round_up((st->startup_time * adc_clk_khz /
1000) - 1, 8) / 8;
/*
* a minimal Sample and Hold Time is necessary for the ADC to guarantee
* the best converted final value between two channels selection
* The formula thus is : Sample and Hold Time = (shtim + 1) / ADCClock
*/
shtim = round_up((st->sample_hold_time * adc_clk /
1000000) - 1, 1);
shtim = round_up((st->sample_hold_time * adc_clk_khz /
1000) - 1, 1);

reg = AT91_ADC_PRESCAL_(prsc) & st->registers->mr_prescal_mask;
reg |= AT91_ADC_STARTUP_(ticks) & st->registers->mr_startup_mask;
Expand Down
2 changes: 2 additions & 0 deletions drivers/iio/buffer_cb.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ struct iio_cb_buffer *iio_channel_get_all_cb(struct device *dev,
goto error_ret;
}

iio_buffer_init(&cb_buff->buffer);

cb_buff->private = private;
cb_buff->cb = cb;
cb_buff->buffer.access = &iio_cb_access;
Expand Down
12 changes: 6 additions & 6 deletions drivers/iio/dac/mcp4725.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,29 +37,29 @@ struct mcp4725_data {

static int mcp4725_suspend(struct device *dev)
{
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct mcp4725_data *data = iio_priv(indio_dev);
struct mcp4725_data *data = iio_priv(i2c_get_clientdata(
to_i2c_client(dev)));
u8 outbuf[2];

outbuf[0] = (data->powerdown_mode + 1) << 4;
outbuf[1] = 0;
data->powerdown = true;

return i2c_master_send(to_i2c_client(dev), outbuf, 2);
return i2c_master_send(data->client, outbuf, 2);
}

static int mcp4725_resume(struct device *dev)
{
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct mcp4725_data *data = iio_priv(indio_dev);
struct mcp4725_data *data = iio_priv(i2c_get_clientdata(
to_i2c_client(dev)));
u8 outbuf[2];

/* restore previous DAC value */
outbuf[0] = (data->dac_value >> 8) & 0xf;
outbuf[1] = data->dac_value & 0xff;
data->powerdown = false;

return i2c_master_send(to_i2c_client(dev), outbuf, 2);
return i2c_master_send(data->client, outbuf, 2);
}

#ifdef CONFIG_PM_SLEEP
Expand Down
4 changes: 4 additions & 0 deletions drivers/iio/iio_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,15 @@ ssize_t iio_buffer_read_first_n_outer(struct file *filp, char __user *buf,
#define iio_buffer_poll_addr (&iio_buffer_poll)
#define iio_buffer_read_first_n_outer_addr (&iio_buffer_read_first_n_outer)

void iio_disable_all_buffers(struct iio_dev *indio_dev);

#else

#define iio_buffer_poll_addr NULL
#define iio_buffer_read_first_n_outer_addr NULL

static inline void iio_disable_all_buffers(struct iio_dev *indio_dev) {}

#endif

int iio_device_register_eventset(struct iio_dev *indio_dev);
Expand Down
30 changes: 28 additions & 2 deletions drivers/iio/industrialio-buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,25 @@ static int iio_compute_scan_bytes(struct iio_dev *indio_dev, const long *mask,
return bytes;
}

void iio_disable_all_buffers(struct iio_dev *indio_dev)
{
struct iio_buffer *buffer, *_buffer;

if (list_empty(&indio_dev->buffer_list))
return;

if (indio_dev->setup_ops->predisable)
indio_dev->setup_ops->predisable(indio_dev);

list_for_each_entry_safe(buffer, _buffer,
&indio_dev->buffer_list, buffer_list)
list_del_init(&buffer->buffer_list);

indio_dev->currentmode = INDIO_DIRECT_MODE;
if (indio_dev->setup_ops->postdisable)
indio_dev->setup_ops->postdisable(indio_dev);
}

int iio_update_buffers(struct iio_dev *indio_dev,
struct iio_buffer *insert_buffer,
struct iio_buffer *remove_buffer)
Expand Down Expand Up @@ -528,8 +547,15 @@ int iio_update_buffers(struct iio_dev *indio_dev,
* Note can only occur when adding a buffer.
*/
list_del(&insert_buffer->buffer_list);
indio_dev->active_scan_mask = old_mask;
success = -EINVAL;
if (old_mask) {
indio_dev->active_scan_mask = old_mask;
success = -EINVAL;
}
else {
kfree(compound_mask);
ret = -EINVAL;
goto error_ret;
}
}
} else {
indio_dev->active_scan_mask = compound_mask;
Expand Down
31 changes: 21 additions & 10 deletions drivers/iio/industrialio-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -848,8 +848,6 @@ static void iio_device_unregister_sysfs(struct iio_dev *indio_dev)
static void iio_dev_release(struct device *device)
{
struct iio_dev *indio_dev = dev_to_iio_dev(device);
if (indio_dev->chrdev.dev)
cdev_del(&indio_dev->chrdev);
if (indio_dev->modes & INDIO_BUFFER_TRIGGERED)
iio_device_unregister_trigger_consumer(indio_dev);
iio_device_unregister_eventset(indio_dev);
Expand Down Expand Up @@ -970,6 +968,8 @@ static int iio_chrdev_open(struct inode *inode, struct file *filp)
if (test_and_set_bit(IIO_BUSY_BIT_POS, &indio_dev->flags))
return -EBUSY;

iio_device_get(indio_dev);

filp->private_data = indio_dev;

return 0;
Expand All @@ -983,6 +983,8 @@ static int iio_chrdev_release(struct inode *inode, struct file *filp)
struct iio_dev *indio_dev = container_of(inode->i_cdev,
struct iio_dev, chrdev);
clear_bit(IIO_BUSY_BIT_POS, &indio_dev->flags);
iio_device_put(indio_dev);

return 0;
}

Expand Down Expand Up @@ -1052,18 +1054,20 @@ int iio_device_register(struct iio_dev *indio_dev)
indio_dev->setup_ops == NULL)
indio_dev->setup_ops = &noop_ring_setup_ops;

ret = device_add(&indio_dev->dev);
if (ret < 0)
goto error_unreg_eventset;
cdev_init(&indio_dev->chrdev, &iio_buffer_fileops);
indio_dev->chrdev.owner = indio_dev->info->driver_module;
indio_dev->chrdev.kobj.parent = &indio_dev->dev.kobj;
ret = cdev_add(&indio_dev->chrdev, indio_dev->dev.devt, 1);
if (ret < 0)
goto error_del_device;
return 0;
goto error_unreg_eventset;

error_del_device:
device_del(&indio_dev->dev);
ret = device_add(&indio_dev->dev);
if (ret < 0)
goto error_cdev_del;

return 0;
error_cdev_del:
cdev_del(&indio_dev->chrdev);
error_unreg_eventset:
iio_device_unregister_eventset(indio_dev);
error_free_sysfs:
Expand All @@ -1078,9 +1082,16 @@ EXPORT_SYMBOL(iio_device_register);
void iio_device_unregister(struct iio_dev *indio_dev)
{
mutex_lock(&indio_dev->info_exist_lock);

device_del(&indio_dev->dev);

if (indio_dev->chrdev.dev)
cdev_del(&indio_dev->chrdev);

iio_disable_all_buffers(indio_dev);

indio_dev->info = NULL;
mutex_unlock(&indio_dev->info_exist_lock);
device_del(&indio_dev->dev);
}
EXPORT_SYMBOL(iio_device_unregister);
subsys_initcall(iio_init);
Expand Down
20 changes: 14 additions & 6 deletions drivers/iio/industrialio-event.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ EXPORT_SYMBOL(iio_push_event);
static unsigned int iio_event_poll(struct file *filep,
struct poll_table_struct *wait)
{
struct iio_event_interface *ev_int = filep->private_data;
struct iio_dev *indio_dev = filep->private_data;
struct iio_event_interface *ev_int = indio_dev->event_interface;
unsigned int events = 0;

poll_wait(filep, &ev_int->wait, wait);
Expand All @@ -90,7 +91,8 @@ static ssize_t iio_event_chrdev_read(struct file *filep,
size_t count,
loff_t *f_ps)
{
struct iio_event_interface *ev_int = filep->private_data;
struct iio_dev *indio_dev = filep->private_data;
struct iio_event_interface *ev_int = indio_dev->event_interface;
unsigned int copied;
int ret;

Expand Down Expand Up @@ -121,7 +123,8 @@ static ssize_t iio_event_chrdev_read(struct file *filep,

static int iio_event_chrdev_release(struct inode *inode, struct file *filep)
{
struct iio_event_interface *ev_int = filep->private_data;
struct iio_dev *indio_dev = filep->private_data;
struct iio_event_interface *ev_int = indio_dev->event_interface;

spin_lock_irq(&ev_int->wait.lock);
__clear_bit(IIO_BUSY_BIT_POS, &ev_int->flags);
Expand All @@ -133,6 +136,8 @@ static int iio_event_chrdev_release(struct inode *inode, struct file *filep)
kfifo_reset_out(&ev_int->det_events);
spin_unlock_irq(&ev_int->wait.lock);

iio_device_put(indio_dev);

return 0;
}

Expand All @@ -158,12 +163,15 @@ int iio_event_getfd(struct iio_dev *indio_dev)
return -EBUSY;
}
spin_unlock_irq(&ev_int->wait.lock);
fd = anon_inode_getfd("iio:event",
&iio_event_chrdev_fileops, ev_int, O_RDONLY);
iio_device_get(indio_dev);

fd = anon_inode_getfd("iio:event", &iio_event_chrdev_fileops,
indio_dev, O_RDONLY);
if (fd < 0) {
spin_lock_irq(&ev_int->wait.lock);
__clear_bit(IIO_BUSY_BIT_POS, &ev_int->flags);
spin_unlock_irq(&ev_int->wait.lock);
iio_device_put(indio_dev);
}
return fd;
}
Expand Down Expand Up @@ -276,7 +284,7 @@ static int iio_device_add_event_sysfs(struct iio_dev *indio_dev,
goto error_ret;
}
if (chan->modified)
mask = IIO_MOD_EVENT_CODE(chan->type, 0, chan->channel,
mask = IIO_MOD_EVENT_CODE(chan->type, 0, chan->channel2,
i/IIO_EV_DIR_MAX,
i%IIO_EV_DIR_MAX);
else if (chan->differential)
Expand Down
6 changes: 4 additions & 2 deletions drivers/iio/temperature/tmp006.c
Original file line number Diff line number Diff line change
Expand Up @@ -255,12 +255,14 @@ static int tmp006_remove(struct i2c_client *client)
#ifdef CONFIG_PM_SLEEP
static int tmp006_suspend(struct device *dev)
{
return tmp006_powerdown(iio_priv(dev_to_iio_dev(dev)));
struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
return tmp006_powerdown(iio_priv(indio_dev));
}

static int tmp006_resume(struct device *dev)
{
struct tmp006_data *data = iio_priv(dev_to_iio_dev(dev));
struct tmp006_data *data = iio_priv(i2c_get_clientdata(
to_i2c_client(dev)));
return i2c_smbus_write_word_swapped(data->client, TMP006_CONFIG,
data->config | TMP006_CONFIG_MOD_MASK);
}
Expand Down
33 changes: 17 additions & 16 deletions drivers/staging/comedi/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,15 @@ config COMEDI_SKEL
To compile this driver as a module, choose M here: the module will be
called skel.

config COMEDI_SSV_DNP
tristate "SSV Embedded Systems DIL/Net-PC support"
depends on X86_32 || COMPILE_TEST
---help---
Enable support for SSV Embedded Systems DIL/Net-PC

To compile this driver as a module, choose M here: the module will be
called ssv_dnp.

endif # COMEDI_MISC_DRIVERS

menuconfig COMEDI_ISA_DRIVERS
Expand Down Expand Up @@ -386,6 +395,14 @@ config COMEDI_DMM32AT
To compile this driver as a module, choose M here: the module will be
called dmm32at.

config COMEDI_UNIOXX5
tristate "Fastwel UNIOxx-5 analog and digital io board support"
---help---
Enable support for Fastwel UNIOxx-5 (analog and digital i/o) boards

To compile this driver as a module, choose M here: the module will be
called unioxx5.

config COMEDI_FL512
tristate "FL512 ISA card support"
---help---
Expand Down Expand Up @@ -855,14 +872,6 @@ config COMEDI_DYNA_PCI10XX
To compile this driver as a module, choose M here: the module will be
called dyna_pci10xx.

config COMEDI_UNIOXX5
tristate "Fastwel UNIOxx-5 analog and digital io board support"
---help---
Enable support for Fastwel UNIOxx-5 (analog and digital i/o) boards

To compile this driver as a module, choose M here: the module will be
called unioxx5.

config COMEDI_GSC_HPDI
tristate "General Standards PCI-HPDI32 / PMC-HPDI32 support"
select COMEDI_FC
Expand Down Expand Up @@ -1085,14 +1094,6 @@ config COMEDI_S626
To compile this driver as a module, choose M here: the module will be
called s626.

config COMEDI_SSV_DNP
tristate "SSV Embedded Systems DIL/Net-PC support"
---help---
Enable support for SSV Embedded Systems DIL/Net-PC

To compile this driver as a module, choose M here: the module will be
called ssv_dnp.

config COMEDI_MITE
depends on HAS_DMA
tristate
Expand Down
Loading

0 comments on commit 9d23108

Please sign in to comment.