aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iio
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-09-25 11:59:04 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-09-25 11:59:04 -0400
commite2aad1d5716c5f7fa5deb4a96e6b6a4e9f24e78b (patch)
tree389fbdf161a3c28c9b2f98fdc1ccd89d474ef884 /drivers/iio
parent3ffdea3feca9e2c95c2e93e217d77c9c368f747a (diff)
parent4a10c2ac2f368583138b774ca41fac4207911983 (diff)
Merge 3.12-rc2 into staging-next.
This resolves the merge problem with two iio drivers that Stephen Rothwell pointed out. Reported-by: Stephen Rothwell <sfr@canb.auug.org.au> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/iio')
-rw-r--r--drivers/iio/accel/bma180.c4
-rw-r--r--drivers/iio/adc/at91_adc.c11
-rw-r--r--drivers/iio/buffer_cb.c2
-rw-r--r--drivers/iio/dac/mcp4725.c12
-rw-r--r--drivers/iio/iio_core.h4
-rw-r--r--drivers/iio/industrialio-buffer.c30
-rw-r--r--drivers/iio/industrialio-core.c31
-rw-r--r--drivers/iio/industrialio-event.c20
-rw-r--r--drivers/iio/temperature/tmp006.c6
9 files changed, 87 insertions, 33 deletions
diff --git a/drivers/iio/accel/bma180.c b/drivers/iio/accel/bma180.c
index bda7a8343ddd..28b39283bccf 100644
--- a/drivers/iio/accel/bma180.c
+++ b/drivers/iio/accel/bma180.c
@@ -617,7 +617,7 @@ static int bma180_remove(struct i2c_client *client)
617#ifdef CONFIG_PM_SLEEP 617#ifdef CONFIG_PM_SLEEP
618static int bma180_suspend(struct device *dev) 618static int bma180_suspend(struct device *dev)
619{ 619{
620 struct iio_dev *indio_dev = dev_to_iio_dev(dev); 620 struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
621 struct bma180_data *data = iio_priv(indio_dev); 621 struct bma180_data *data = iio_priv(indio_dev);
622 int ret; 622 int ret;
623 623
@@ -630,7 +630,7 @@ static int bma180_suspend(struct device *dev)
630 630
631static int bma180_resume(struct device *dev) 631static int bma180_resume(struct device *dev)
632{ 632{
633 struct iio_dev *indio_dev = dev_to_iio_dev(dev); 633 struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
634 struct bma180_data *data = iio_priv(indio_dev); 634 struct bma180_data *data = iio_priv(indio_dev);
635 int ret; 635 int ret;
636 636
diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c
index 5c8f690ce92f..78121949d6ef 100644
--- a/drivers/iio/adc/at91_adc.c
+++ b/drivers/iio/adc/at91_adc.c
@@ -550,7 +550,7 @@ static const struct iio_info at91_adc_info = {
550 550
551static int at91_adc_probe(struct platform_device *pdev) 551static int at91_adc_probe(struct platform_device *pdev)
552{ 552{
553 unsigned int prsc, mstrclk, ticks, adc_clk, shtim; 553 unsigned int prsc, mstrclk, ticks, adc_clk, adc_clk_khz, shtim;
554 int ret; 554 int ret;
555 struct iio_dev *idev; 555 struct iio_dev *idev;
556 struct at91_adc_state *st; 556 struct at91_adc_state *st;
@@ -643,6 +643,7 @@ static int at91_adc_probe(struct platform_device *pdev)
643 */ 643 */
644 mstrclk = clk_get_rate(st->clk); 644 mstrclk = clk_get_rate(st->clk);
645 adc_clk = clk_get_rate(st->adc_clk); 645 adc_clk = clk_get_rate(st->adc_clk);
646 adc_clk_khz = adc_clk / 1000;
646 prsc = (mstrclk / (2 * adc_clk)) - 1; 647 prsc = (mstrclk / (2 * adc_clk)) - 1;
647 648
648 if (!st->startup_time) { 649 if (!st->startup_time) {
@@ -656,15 +657,15 @@ static int at91_adc_probe(struct platform_device *pdev)
656 * defined in the electrical characteristics of the board, divided by 8. 657 * defined in the electrical characteristics of the board, divided by 8.
657 * The formula thus is : Startup Time = (ticks + 1) * 8 / ADC Clock 658 * The formula thus is : Startup Time = (ticks + 1) * 8 / ADC Clock
658 */ 659 */
659 ticks = round_up((st->startup_time * adc_clk / 660 ticks = round_up((st->startup_time * adc_clk_khz /
660 1000000) - 1, 8) / 8; 661 1000) - 1, 8) / 8;
661 /* 662 /*
662 * a minimal Sample and Hold Time is necessary for the ADC to guarantee 663 * a minimal Sample and Hold Time is necessary for the ADC to guarantee
663 * the best converted final value between two channels selection 664 * the best converted final value between two channels selection
664 * The formula thus is : Sample and Hold Time = (shtim + 1) / ADCClock 665 * The formula thus is : Sample and Hold Time = (shtim + 1) / ADCClock
665 */ 666 */
666 shtim = round_up((st->sample_hold_time * adc_clk / 667 shtim = round_up((st->sample_hold_time * adc_clk_khz /
667 1000000) - 1, 1); 668 1000) - 1, 1);
668 669
669 reg = AT91_ADC_PRESCAL_(prsc) & st->registers->mr_prescal_mask; 670 reg = AT91_ADC_PRESCAL_(prsc) & st->registers->mr_prescal_mask;
670 reg |= AT91_ADC_STARTUP_(ticks) & st->registers->mr_startup_mask; 671 reg |= AT91_ADC_STARTUP_(ticks) & st->registers->mr_startup_mask;
diff --git a/drivers/iio/buffer_cb.c b/drivers/iio/buffer_cb.c
index 578f7199ed51..841fec1e78b2 100644
--- a/drivers/iio/buffer_cb.c
+++ b/drivers/iio/buffer_cb.c
@@ -41,6 +41,8 @@ struct iio_cb_buffer *iio_channel_get_all_cb(struct device *dev,
41 goto error_ret; 41 goto error_ret;
42 } 42 }
43 43
44 iio_buffer_init(&cb_buff->buffer);
45
44 cb_buff->private = private; 46 cb_buff->private = private;
45 cb_buff->cb = cb; 47 cb_buff->cb = cb;
46 cb_buff->buffer.access = &iio_cb_access; 48 cb_buff->buffer.access = &iio_cb_access;
diff --git a/drivers/iio/dac/mcp4725.c b/drivers/iio/dac/mcp4725.c
index 6711a33b16ba..7a42d85269bb 100644
--- a/drivers/iio/dac/mcp4725.c
+++ b/drivers/iio/dac/mcp4725.c
@@ -37,21 +37,21 @@ struct mcp4725_data {
37 37
38static int mcp4725_suspend(struct device *dev) 38static int mcp4725_suspend(struct device *dev)
39{ 39{
40 struct iio_dev *indio_dev = dev_to_iio_dev(dev); 40 struct mcp4725_data *data = iio_priv(i2c_get_clientdata(
41 struct mcp4725_data *data = iio_priv(indio_dev); 41 to_i2c_client(dev)));
42 u8 outbuf[2]; 42 u8 outbuf[2];
43 43
44 outbuf[0] = (data->powerdown_mode + 1) << 4; 44 outbuf[0] = (data->powerdown_mode + 1) << 4;
45 outbuf[1] = 0; 45 outbuf[1] = 0;
46 data->powerdown = true; 46 data->powerdown = true;
47 47
48 return i2c_master_send(to_i2c_client(dev), outbuf, 2); 48 return i2c_master_send(data->client, outbuf, 2);
49} 49}
50 50
51static int mcp4725_resume(struct device *dev) 51static int mcp4725_resume(struct device *dev)
52{ 52{
53 struct iio_dev *indio_dev = dev_to_iio_dev(dev); 53 struct mcp4725_data *data = iio_priv(i2c_get_clientdata(
54 struct mcp4725_data *data = iio_priv(indio_dev); 54 to_i2c_client(dev)));
55 u8 outbuf[2]; 55 u8 outbuf[2];
56 56
57 /* restore previous DAC value */ 57 /* restore previous DAC value */
@@ -59,7 +59,7 @@ static int mcp4725_resume(struct device *dev)
59 outbuf[1] = data->dac_value & 0xff; 59 outbuf[1] = data->dac_value & 0xff;
60 data->powerdown = false; 60 data->powerdown = false;
61 61
62 return i2c_master_send(to_i2c_client(dev), outbuf, 2); 62 return i2c_master_send(data->client, outbuf, 2);
63} 63}
64 64
65#ifdef CONFIG_PM_SLEEP 65#ifdef CONFIG_PM_SLEEP
diff --git a/drivers/iio/iio_core.h b/drivers/iio/iio_core.h
index 6be5ab864b1a..9209f47b273a 100644
--- a/drivers/iio/iio_core.h
+++ b/drivers/iio/iio_core.h
@@ -49,11 +49,15 @@ ssize_t iio_buffer_read_first_n_outer(struct file *filp, char __user *buf,
49#define iio_buffer_poll_addr (&iio_buffer_poll) 49#define iio_buffer_poll_addr (&iio_buffer_poll)
50#define iio_buffer_read_first_n_outer_addr (&iio_buffer_read_first_n_outer) 50#define iio_buffer_read_first_n_outer_addr (&iio_buffer_read_first_n_outer)
51 51
52void iio_disable_all_buffers(struct iio_dev *indio_dev);
53
52#else 54#else
53 55
54#define iio_buffer_poll_addr NULL 56#define iio_buffer_poll_addr NULL
55#define iio_buffer_read_first_n_outer_addr NULL 57#define iio_buffer_read_first_n_outer_addr NULL
56 58
59static inline void iio_disable_all_buffers(struct iio_dev *indio_dev) {}
60
57#endif 61#endif
58 62
59int iio_device_register_eventset(struct iio_dev *indio_dev); 63int iio_device_register_eventset(struct iio_dev *indio_dev);
diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c
index 2361fbc74e33..e9f389b9da69 100644
--- a/drivers/iio/industrialio-buffer.c
+++ b/drivers/iio/industrialio-buffer.c
@@ -454,6 +454,25 @@ static int iio_compute_scan_bytes(struct iio_dev *indio_dev,
454 return bytes; 454 return bytes;
455} 455}
456 456
457void iio_disable_all_buffers(struct iio_dev *indio_dev)
458{
459 struct iio_buffer *buffer, *_buffer;
460
461 if (list_empty(&indio_dev->buffer_list))
462 return;
463
464 if (indio_dev->setup_ops->predisable)
465 indio_dev->setup_ops->predisable(indio_dev);
466
467 list_for_each_entry_safe(buffer, _buffer,
468 &indio_dev->buffer_list, buffer_list)
469 list_del_init(&buffer->buffer_list);
470
471 indio_dev->currentmode = INDIO_DIRECT_MODE;
472 if (indio_dev->setup_ops->postdisable)
473 indio_dev->setup_ops->postdisable(indio_dev);
474}
475
457int iio_update_buffers(struct iio_dev *indio_dev, 476int iio_update_buffers(struct iio_dev *indio_dev,
458 struct iio_buffer *insert_buffer, 477 struct iio_buffer *insert_buffer,
459 struct iio_buffer *remove_buffer) 478 struct iio_buffer *remove_buffer)
@@ -522,8 +541,15 @@ int iio_update_buffers(struct iio_dev *indio_dev,
522 * Note can only occur when adding a buffer. 541 * Note can only occur when adding a buffer.
523 */ 542 */
524 list_del_init(&insert_buffer->buffer_list); 543 list_del_init(&insert_buffer->buffer_list);
525 indio_dev->active_scan_mask = old_mask; 544 if (old_mask) {
526 success = -EINVAL; 545 indio_dev->active_scan_mask = old_mask;
546 success = -EINVAL;
547 }
548 else {
549 kfree(compound_mask);
550 ret = -EINVAL;
551 goto error_ret;
552 }
527 } 553 }
528 } else { 554 } else {
529 indio_dev->active_scan_mask = compound_mask; 555 indio_dev->active_scan_mask = compound_mask;
diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
index 24db1855dbab..863aa010ce5a 100644
--- a/drivers/iio/industrialio-core.c
+++ b/drivers/iio/industrialio-core.c
@@ -890,8 +890,6 @@ static void iio_device_unregister_sysfs(struct iio_dev *indio_dev)
890static void iio_dev_release(struct device *device) 890static void iio_dev_release(struct device *device)
891{ 891{
892 struct iio_dev *indio_dev = dev_to_iio_dev(device); 892 struct iio_dev *indio_dev = dev_to_iio_dev(device);
893 if (indio_dev->chrdev.dev)
894 cdev_del(&indio_dev->chrdev);
895 if (indio_dev->modes & INDIO_BUFFER_TRIGGERED) 893 if (indio_dev->modes & INDIO_BUFFER_TRIGGERED)
896 iio_device_unregister_trigger_consumer(indio_dev); 894 iio_device_unregister_trigger_consumer(indio_dev);
897 iio_device_unregister_eventset(indio_dev); 895 iio_device_unregister_eventset(indio_dev);
@@ -1012,6 +1010,8 @@ static int iio_chrdev_open(struct inode *inode, struct file *filp)
1012 if (test_and_set_bit(IIO_BUSY_BIT_POS, &indio_dev->flags)) 1010 if (test_and_set_bit(IIO_BUSY_BIT_POS, &indio_dev->flags))
1013 return -EBUSY; 1011 return -EBUSY;
1014 1012
1013 iio_device_get(indio_dev);
1014
1015 filp->private_data = indio_dev; 1015 filp->private_data = indio_dev;
1016 1016
1017 return 0; 1017 return 0;
@@ -1025,6 +1025,8 @@ static int iio_chrdev_release(struct inode *inode, struct file *filp)
1025 struct iio_dev *indio_dev = container_of(inode->i_cdev, 1025 struct iio_dev *indio_dev = container_of(inode->i_cdev,
1026 struct iio_dev, chrdev); 1026 struct iio_dev, chrdev);
1027 clear_bit(IIO_BUSY_BIT_POS, &indio_dev->flags); 1027 clear_bit(IIO_BUSY_BIT_POS, &indio_dev->flags);
1028 iio_device_put(indio_dev);
1029
1028 return 0; 1030 return 0;
1029} 1031}
1030 1032
@@ -1094,18 +1096,20 @@ int iio_device_register(struct iio_dev *indio_dev)
1094 indio_dev->setup_ops == NULL) 1096 indio_dev->setup_ops == NULL)
1095 indio_dev->setup_ops = &noop_ring_setup_ops; 1097 indio_dev->setup_ops = &noop_ring_setup_ops;
1096 1098
1097 ret = device_add(&indio_dev->dev);
1098 if (ret < 0)
1099 goto error_unreg_eventset;
1100 cdev_init(&indio_dev->chrdev, &iio_buffer_fileops); 1099 cdev_init(&indio_dev->chrdev, &iio_buffer_fileops);
1101 indio_dev->chrdev.owner = indio_dev->info->driver_module; 1100 indio_dev->chrdev.owner = indio_dev->info->driver_module;
1101 indio_dev->chrdev.kobj.parent = &indio_dev->dev.kobj;
1102 ret = cdev_add(&indio_dev->chrdev, indio_dev->dev.devt, 1); 1102 ret = cdev_add(&indio_dev->chrdev, indio_dev->dev.devt, 1);
1103 if (ret < 0) 1103 if (ret < 0)
1104 goto error_del_device; 1104 goto error_unreg_eventset;
1105 return 0;
1106 1105
1107error_del_device: 1106 ret = device_add(&indio_dev->dev);
1108 device_del(&indio_dev->dev); 1107 if (ret < 0)
1108 goto error_cdev_del;
1109
1110 return 0;
1111error_cdev_del:
1112 cdev_del(&indio_dev->chrdev);
1109error_unreg_eventset: 1113error_unreg_eventset:
1110 iio_device_unregister_eventset(indio_dev); 1114 iio_device_unregister_eventset(indio_dev);
1111error_free_sysfs: 1115error_free_sysfs:
@@ -1120,9 +1124,16 @@ EXPORT_SYMBOL(iio_device_register);
1120void iio_device_unregister(struct iio_dev *indio_dev) 1124void iio_device_unregister(struct iio_dev *indio_dev)
1121{ 1125{
1122 mutex_lock(&indio_dev->info_exist_lock); 1126 mutex_lock(&indio_dev->info_exist_lock);
1127
1128 device_del(&indio_dev->dev);
1129
1130 if (indio_dev->chrdev.dev)
1131 cdev_del(&indio_dev->chrdev);
1132
1133 iio_disable_all_buffers(indio_dev);
1134
1123 indio_dev->info = NULL; 1135 indio_dev->info = NULL;
1124 mutex_unlock(&indio_dev->info_exist_lock); 1136 mutex_unlock(&indio_dev->info_exist_lock);
1125 device_del(&indio_dev->dev);
1126} 1137}
1127EXPORT_SYMBOL(iio_device_unregister); 1138EXPORT_SYMBOL(iio_device_unregister);
1128subsys_initcall(iio_init); 1139subsys_initcall(iio_init);
diff --git a/drivers/iio/industrialio-event.c b/drivers/iio/industrialio-event.c
index 2390e3d08e48..36f0c8e0eb3d 100644
--- a/drivers/iio/industrialio-event.c
+++ b/drivers/iio/industrialio-event.c
@@ -72,7 +72,8 @@ EXPORT_SYMBOL(iio_push_event);
72static unsigned int iio_event_poll(struct file *filep, 72static unsigned int iio_event_poll(struct file *filep,
73 struct poll_table_struct *wait) 73 struct poll_table_struct *wait)
74{ 74{
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;
76 unsigned int events = 0; 77 unsigned int events = 0;
77 78
78 poll_wait(filep, &ev_int->wait, wait); 79 poll_wait(filep, &ev_int->wait, wait);
@@ -90,7 +91,8 @@ static ssize_t iio_event_chrdev_read(struct file *filep,
90 size_t count, 91 size_t count,
91 loff_t *f_ps) 92 loff_t *f_ps)
92{ 93{
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;
94 unsigned int copied; 96 unsigned int copied;
95 int ret; 97 int ret;
96 98
@@ -121,7 +123,8 @@ error_unlock:
121 123
122static int iio_event_chrdev_release(struct inode *inode, struct file *filep) 124static int iio_event_chrdev_release(struct inode *inode, struct file *filep)
123{ 125{
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;
125 128
126 spin_lock_irq(&ev_int->wait.lock); 129 spin_lock_irq(&ev_int->wait.lock);
127 __clear_bit(IIO_BUSY_BIT_POS, &ev_int->flags); 130 __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)
133 kfifo_reset_out(&ev_int->det_events); 136 kfifo_reset_out(&ev_int->det_events);
134 spin_unlock_irq(&ev_int->wait.lock); 137 spin_unlock_irq(&ev_int->wait.lock);
135 138
139 iio_device_put(indio_dev);
140
136 return 0; 141 return 0;
137} 142}
138 143
@@ -158,12 +163,15 @@ int iio_event_getfd(struct iio_dev *indio_dev)
158 return -EBUSY; 163 return -EBUSY;
159 } 164 }
160 spin_unlock_irq(&ev_int->wait.lock); 165 spin_unlock_irq(&ev_int->wait.lock);
161 fd = anon_inode_getfd("iio:event", 166 iio_device_get(indio_dev);
162 &iio_event_chrdev_fileops, ev_int, O_RDONLY | O_CLOEXEC); 167
168 fd = anon_inode_getfd("iio:event", &iio_event_chrdev_fileops,
169 indio_dev, O_RDONLY | O_CLOEXEC);
163 if (fd < 0) { 170 if (fd < 0) {
164 spin_lock_irq(&ev_int->wait.lock); 171 spin_lock_irq(&ev_int->wait.lock);
165 __clear_bit(IIO_BUSY_BIT_POS, &ev_int->flags); 172 __clear_bit(IIO_BUSY_BIT_POS, &ev_int->flags);
166 spin_unlock_irq(&ev_int->wait.lock); 173 spin_unlock_irq(&ev_int->wait.lock);
174 iio_device_put(indio_dev);
167 } 175 }
168 return fd; 176 return fd;
169} 177}
@@ -276,7 +284,7 @@ static int iio_device_add_event_sysfs(struct iio_dev *indio_dev,
276 goto error_ret; 284 goto error_ret;
277 } 285 }
278 if (chan->modified) 286 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,
280 i/IIO_EV_DIR_MAX, 288 i/IIO_EV_DIR_MAX,
281 i%IIO_EV_DIR_MAX); 289 i%IIO_EV_DIR_MAX);
282 else if (chan->differential) 290 else if (chan->differential)
diff --git a/drivers/iio/temperature/tmp006.c b/drivers/iio/temperature/tmp006.c
index 4e950979f43e..84a0789c3d96 100644
--- a/drivers/iio/temperature/tmp006.c
+++ b/drivers/iio/temperature/tmp006.c
@@ -252,12 +252,14 @@ static int tmp006_remove(struct i2c_client *client)
252#ifdef CONFIG_PM_SLEEP 252#ifdef CONFIG_PM_SLEEP
253static int tmp006_suspend(struct device *dev) 253static int tmp006_suspend(struct device *dev)
254{ 254{
255 return tmp006_powerdown(iio_priv(dev_to_iio_dev(dev))); 255 struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
256 return tmp006_powerdown(iio_priv(indio_dev));
256} 257}
257 258
258static int tmp006_resume(struct device *dev) 259static int tmp006_resume(struct device *dev)
259{ 260{
260 struct tmp006_data *data = iio_priv(dev_to_iio_dev(dev)); 261 struct tmp006_data *data = iio_priv(i2c_get_clientdata(
262 to_i2c_client(dev)));
261 return i2c_smbus_write_word_swapped(data->client, TMP006_CONFIG, 263 return i2c_smbus_write_word_swapped(data->client, TMP006_CONFIG,
262 data->config | TMP006_CONFIG_MOD_MASK); 264 data->config | TMP006_CONFIG_MOD_MASK);
263} 265}