Skip to content

Commit 9d23108

Browse files
committed
Merge tag 'staging-3.12-rc2' of git://git.kernel.org/pub/scm/linux/kernel/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 ...
2 parents e04a0a5 + 6174081 commit 9d23108

File tree

35 files changed

+160
-97
lines changed

35 files changed

+160
-97
lines changed

drivers/iio/accel/bma180.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ static int bma180_remove(struct i2c_client *client)
620620
#ifdef CONFIG_PM_SLEEP
621621
static int bma180_suspend(struct device *dev)
622622
{
623-
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
623+
struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
624624
struct bma180_data *data = iio_priv(indio_dev);
625625
int ret;
626626

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

634634
static int bma180_resume(struct device *dev)
635635
{
636-
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
636+
struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
637637
struct bma180_data *data = iio_priv(indio_dev);
638638
int ret;
639639

drivers/iio/adc/at91_adc.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ static const struct iio_info at91_adc_info = {
556556

557557
static int at91_adc_probe(struct platform_device *pdev)
558558
{
559-
unsigned int prsc, mstrclk, ticks, adc_clk, shtim;
559+
unsigned int prsc, mstrclk, ticks, adc_clk, adc_clk_khz, shtim;
560560
int ret;
561561
struct iio_dev *idev;
562562
struct at91_adc_state *st;
@@ -649,6 +649,7 @@ static int at91_adc_probe(struct platform_device *pdev)
649649
*/
650650
mstrclk = clk_get_rate(st->clk);
651651
adc_clk = clk_get_rate(st->adc_clk);
652+
adc_clk_khz = adc_clk / 1000;
652653
prsc = (mstrclk / (2 * adc_clk)) - 1;
653654

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

675676
reg = AT91_ADC_PRESCAL_(prsc) & st->registers->mr_prescal_mask;
676677
reg |= AT91_ADC_STARTUP_(ticks) & st->registers->mr_startup_mask;

drivers/iio/buffer_cb.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ struct iio_cb_buffer *iio_channel_get_all_cb(struct device *dev,
4141
goto error_ret;
4242
}
4343

44+
iio_buffer_init(&cb_buff->buffer);
45+
4446
cb_buff->private = private;
4547
cb_buff->cb = cb;
4648
cb_buff->buffer.access = &iio_cb_access;

drivers/iio/dac/mcp4725.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,29 +37,29 @@ struct mcp4725_data {
3737

3838
static int mcp4725_suspend(struct device *dev)
3939
{
40-
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
41-
struct mcp4725_data *data = iio_priv(indio_dev);
40+
struct mcp4725_data *data = iio_priv(i2c_get_clientdata(
41+
to_i2c_client(dev)));
4242
u8 outbuf[2];
4343

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

48-
return i2c_master_send(to_i2c_client(dev), outbuf, 2);
48+
return i2c_master_send(data->client, outbuf, 2);
4949
}
5050

5151
static int mcp4725_resume(struct device *dev)
5252
{
53-
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
54-
struct mcp4725_data *data = iio_priv(indio_dev);
53+
struct mcp4725_data *data = iio_priv(i2c_get_clientdata(
54+
to_i2c_client(dev)));
5555
u8 outbuf[2];
5656

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

62-
return i2c_master_send(to_i2c_client(dev), outbuf, 2);
62+
return i2c_master_send(data->client, outbuf, 2);
6363
}
6464

6565
#ifdef CONFIG_PM_SLEEP

drivers/iio/iio_core.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,15 @@ ssize_t iio_buffer_read_first_n_outer(struct file *filp, char __user *buf,
4949
#define iio_buffer_poll_addr (&iio_buffer_poll)
5050
#define iio_buffer_read_first_n_outer_addr (&iio_buffer_read_first_n_outer)
5151

52+
void iio_disable_all_buffers(struct iio_dev *indio_dev);
53+
5254
#else
5355

5456
#define iio_buffer_poll_addr NULL
5557
#define iio_buffer_read_first_n_outer_addr NULL
5658

59+
static inline void iio_disable_all_buffers(struct iio_dev *indio_dev) {}
60+
5761
#endif
5862

5963
int iio_device_register_eventset(struct iio_dev *indio_dev);

drivers/iio/industrialio-buffer.c

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,25 @@ static int iio_compute_scan_bytes(struct iio_dev *indio_dev, const long *mask,
460460
return bytes;
461461
}
462462

463+
void iio_disable_all_buffers(struct iio_dev *indio_dev)
464+
{
465+
struct iio_buffer *buffer, *_buffer;
466+
467+
if (list_empty(&indio_dev->buffer_list))
468+
return;
469+
470+
if (indio_dev->setup_ops->predisable)
471+
indio_dev->setup_ops->predisable(indio_dev);
472+
473+
list_for_each_entry_safe(buffer, _buffer,
474+
&indio_dev->buffer_list, buffer_list)
475+
list_del_init(&buffer->buffer_list);
476+
477+
indio_dev->currentmode = INDIO_DIRECT_MODE;
478+
if (indio_dev->setup_ops->postdisable)
479+
indio_dev->setup_ops->postdisable(indio_dev);
480+
}
481+
463482
int iio_update_buffers(struct iio_dev *indio_dev,
464483
struct iio_buffer *insert_buffer,
465484
struct iio_buffer *remove_buffer)
@@ -528,8 +547,15 @@ int iio_update_buffers(struct iio_dev *indio_dev,
528547
* Note can only occur when adding a buffer.
529548
*/
530549
list_del(&insert_buffer->buffer_list);
531-
indio_dev->active_scan_mask = old_mask;
532-
success = -EINVAL;
550+
if (old_mask) {
551+
indio_dev->active_scan_mask = old_mask;
552+
success = -EINVAL;
553+
}
554+
else {
555+
kfree(compound_mask);
556+
ret = -EINVAL;
557+
goto error_ret;
558+
}
533559
}
534560
} else {
535561
indio_dev->active_scan_mask = compound_mask;

drivers/iio/industrialio-core.c

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -848,8 +848,6 @@ static void iio_device_unregister_sysfs(struct iio_dev *indio_dev)
848848
static void iio_dev_release(struct device *device)
849849
{
850850
struct iio_dev *indio_dev = dev_to_iio_dev(device);
851-
if (indio_dev->chrdev.dev)
852-
cdev_del(&indio_dev->chrdev);
853851
if (indio_dev->modes & INDIO_BUFFER_TRIGGERED)
854852
iio_device_unregister_trigger_consumer(indio_dev);
855853
iio_device_unregister_eventset(indio_dev);
@@ -970,6 +968,8 @@ static int iio_chrdev_open(struct inode *inode, struct file *filp)
970968
if (test_and_set_bit(IIO_BUSY_BIT_POS, &indio_dev->flags))
971969
return -EBUSY;
972970

971+
iio_device_get(indio_dev);
972+
973973
filp->private_data = indio_dev;
974974

975975
return 0;
@@ -983,6 +983,8 @@ static int iio_chrdev_release(struct inode *inode, struct file *filp)
983983
struct iio_dev *indio_dev = container_of(inode->i_cdev,
984984
struct iio_dev, chrdev);
985985
clear_bit(IIO_BUSY_BIT_POS, &indio_dev->flags);
986+
iio_device_put(indio_dev);
987+
986988
return 0;
987989
}
988990

@@ -1052,18 +1054,20 @@ int iio_device_register(struct iio_dev *indio_dev)
10521054
indio_dev->setup_ops == NULL)
10531055
indio_dev->setup_ops = &noop_ring_setup_ops;
10541056

1055-
ret = device_add(&indio_dev->dev);
1056-
if (ret < 0)
1057-
goto error_unreg_eventset;
10581057
cdev_init(&indio_dev->chrdev, &iio_buffer_fileops);
10591058
indio_dev->chrdev.owner = indio_dev->info->driver_module;
1059+
indio_dev->chrdev.kobj.parent = &indio_dev->dev.kobj;
10601060
ret = cdev_add(&indio_dev->chrdev, indio_dev->dev.devt, 1);
10611061
if (ret < 0)
1062-
goto error_del_device;
1063-
return 0;
1062+
goto error_unreg_eventset;
10641063

1065-
error_del_device:
1066-
device_del(&indio_dev->dev);
1064+
ret = device_add(&indio_dev->dev);
1065+
if (ret < 0)
1066+
goto error_cdev_del;
1067+
1068+
return 0;
1069+
error_cdev_del:
1070+
cdev_del(&indio_dev->chrdev);
10671071
error_unreg_eventset:
10681072
iio_device_unregister_eventset(indio_dev);
10691073
error_free_sysfs:
@@ -1078,9 +1082,16 @@ EXPORT_SYMBOL(iio_device_register);
10781082
void iio_device_unregister(struct iio_dev *indio_dev)
10791083
{
10801084
mutex_lock(&indio_dev->info_exist_lock);
1085+
1086+
device_del(&indio_dev->dev);
1087+
1088+
if (indio_dev->chrdev.dev)
1089+
cdev_del(&indio_dev->chrdev);
1090+
1091+
iio_disable_all_buffers(indio_dev);
1092+
10811093
indio_dev->info = NULL;
10821094
mutex_unlock(&indio_dev->info_exist_lock);
1083-
device_del(&indio_dev->dev);
10841095
}
10851096
EXPORT_SYMBOL(iio_device_unregister);
10861097
subsys_initcall(iio_init);

drivers/iio/industrialio-event.c

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ EXPORT_SYMBOL(iio_push_event);
7272
static unsigned int iio_event_poll(struct file *filep,
7373
struct poll_table_struct *wait)
7474
{
75-
struct iio_event_interface *ev_int = filep->private_data;
75+
struct iio_dev *indio_dev = filep->private_data;
76+
struct iio_event_interface *ev_int = indio_dev->event_interface;
7677
unsigned int events = 0;
7778

7879
poll_wait(filep, &ev_int->wait, wait);
@@ -90,7 +91,8 @@ static ssize_t iio_event_chrdev_read(struct file *filep,
9091
size_t count,
9192
loff_t *f_ps)
9293
{
93-
struct iio_event_interface *ev_int = filep->private_data;
94+
struct iio_dev *indio_dev = filep->private_data;
95+
struct iio_event_interface *ev_int = indio_dev->event_interface;
9496
unsigned int copied;
9597
int ret;
9698

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

122124
static int iio_event_chrdev_release(struct inode *inode, struct file *filep)
123125
{
124-
struct iio_event_interface *ev_int = filep->private_data;
126+
struct iio_dev *indio_dev = filep->private_data;
127+
struct iio_event_interface *ev_int = indio_dev->event_interface;
125128

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

139+
iio_device_put(indio_dev);
140+
136141
return 0;
137142
}
138143

@@ -158,12 +163,15 @@ int iio_event_getfd(struct iio_dev *indio_dev)
158163
return -EBUSY;
159164
}
160165
spin_unlock_irq(&ev_int->wait.lock);
161-
fd = anon_inode_getfd("iio:event",
162-
&iio_event_chrdev_fileops, ev_int, O_RDONLY);
166+
iio_device_get(indio_dev);
167+
168+
fd = anon_inode_getfd("iio:event", &iio_event_chrdev_fileops,
169+
indio_dev, O_RDONLY);
163170
if (fd < 0) {
164171
spin_lock_irq(&ev_int->wait.lock);
165172
__clear_bit(IIO_BUSY_BIT_POS, &ev_int->flags);
166173
spin_unlock_irq(&ev_int->wait.lock);
174+
iio_device_put(indio_dev);
167175
}
168176
return fd;
169177
}
@@ -276,7 +284,7 @@ static int iio_device_add_event_sysfs(struct iio_dev *indio_dev,
276284
goto error_ret;
277285
}
278286
if (chan->modified)
279-
mask = IIO_MOD_EVENT_CODE(chan->type, 0, chan->channel,
287+
mask = IIO_MOD_EVENT_CODE(chan->type, 0, chan->channel2,
280288
i/IIO_EV_DIR_MAX,
281289
i%IIO_EV_DIR_MAX);
282290
else if (chan->differential)

drivers/iio/temperature/tmp006.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,12 +255,14 @@ static int tmp006_remove(struct i2c_client *client)
255255
#ifdef CONFIG_PM_SLEEP
256256
static int tmp006_suspend(struct device *dev)
257257
{
258-
return tmp006_powerdown(iio_priv(dev_to_iio_dev(dev)));
258+
struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
259+
return tmp006_powerdown(iio_priv(indio_dev));
259260
}
260261

261262
static int tmp006_resume(struct device *dev)
262263
{
263-
struct tmp006_data *data = iio_priv(dev_to_iio_dev(dev));
264+
struct tmp006_data *data = iio_priv(i2c_get_clientdata(
265+
to_i2c_client(dev)));
264266
return i2c_smbus_write_word_swapped(data->client, TMP006_CONFIG,
265267
data->config | TMP006_CONFIG_MOD_MASK);
266268
}

drivers/staging/comedi/Kconfig

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,15 @@ config COMEDI_SKEL
9696
To compile this driver as a module, choose M here: the module will be
9797
called skel.
9898

99+
config COMEDI_SSV_DNP
100+
tristate "SSV Embedded Systems DIL/Net-PC support"
101+
depends on X86_32 || COMPILE_TEST
102+
---help---
103+
Enable support for SSV Embedded Systems DIL/Net-PC
104+
105+
To compile this driver as a module, choose M here: the module will be
106+
called ssv_dnp.
107+
99108
endif # COMEDI_MISC_DRIVERS
100109

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

398+
config COMEDI_UNIOXX5
399+
tristate "Fastwel UNIOxx-5 analog and digital io board support"
400+
---help---
401+
Enable support for Fastwel UNIOxx-5 (analog and digital i/o) boards
402+
403+
To compile this driver as a module, choose M here: the module will be
404+
called unioxx5.
405+
389406
config COMEDI_FL512
390407
tristate "FL512 ISA card support"
391408
---help---
@@ -855,14 +872,6 @@ config COMEDI_DYNA_PCI10XX
855872
To compile this driver as a module, choose M here: the module will be
856873
called dyna_pci10xx.
857874

858-
config COMEDI_UNIOXX5
859-
tristate "Fastwel UNIOxx-5 analog and digital io board support"
860-
---help---
861-
Enable support for Fastwel UNIOxx-5 (analog and digital i/o) boards
862-
863-
To compile this driver as a module, choose M here: the module will be
864-
called unioxx5.
865-
866875
config COMEDI_GSC_HPDI
867876
tristate "General Standards PCI-HPDI32 / PMC-HPDI32 support"
868877
select COMEDI_FC
@@ -1085,14 +1094,6 @@ config COMEDI_S626
10851094
To compile this driver as a module, choose M here: the module will be
10861095
called s626.
10871096

1088-
config COMEDI_SSV_DNP
1089-
tristate "SSV Embedded Systems DIL/Net-PC support"
1090-
---help---
1091-
Enable support for SSV Embedded Systems DIL/Net-PC
1092-
1093-
To compile this driver as a module, choose M here: the module will be
1094-
called ssv_dnp.
1095-
10961097
config COMEDI_MITE
10971098
depends on HAS_DMA
10981099
tristate

0 commit comments

Comments
 (0)