Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge tag 'iio-fixes-for-3.9a' of git://git.kernel.org/pub/scm/linux/…

…kernel/git/jic23/iio into staging-linus

Jonathan writes:

"First round of iio fixes post the 3.9 merge window.

1) Some little fixes for the ad5064 dac driver.
2) A build warning 'fix' for a false positive in st_sensors
3) A couple of missing dependencies on IIO_BUFFER.

So nothing major and these mostly showed the advantages of the randconfig
builds various people have performed."
  • Loading branch information...
commit 1223ad3240487ba6c2304b887cfb4da5cada04d8 2 parents 6dbe51c + 852afe9
Greg Kroah-Hartman authored March 06, 2013
9  drivers/iio/common/st_sensors/st_sensors_core.c
@@ -62,7 +62,7 @@ static int st_sensors_match_odr(struct st_sensors *sensor,
62 62
 int st_sensors_set_odr(struct iio_dev *indio_dev, unsigned int odr)
63 63
 {
64 64
 	int err;
65  
-	struct st_sensor_odr_avl odr_out;
  65
+	struct st_sensor_odr_avl odr_out = {0, 0};
66 66
 	struct st_sensor_data *sdata = iio_priv(indio_dev);
67 67
 
68 68
 	err = st_sensors_match_odr(sdata->sensor, odr, &odr_out);
@@ -114,7 +114,7 @@ static int st_sensors_match_fs(struct st_sensors *sensor,
114 114
 
115 115
 static int st_sensors_set_fullscale(struct iio_dev *indio_dev, unsigned int fs)
116 116
 {
117  
-	int err, i;
  117
+	int err, i = 0;
118 118
 	struct st_sensor_data *sdata = iio_priv(indio_dev);
119 119
 
120 120
 	err = st_sensors_match_fs(sdata->sensor, fs, &i);
@@ -139,14 +139,13 @@ static int st_sensors_set_fullscale(struct iio_dev *indio_dev, unsigned int fs)
139 139
 
140 140
 int st_sensors_set_enable(struct iio_dev *indio_dev, bool enable)
141 141
 {
142  
-	bool found;
143 142
 	u8 tmp_value;
144 143
 	int err = -EINVAL;
145  
-	struct st_sensor_odr_avl odr_out;
  144
+	bool found = false;
  145
+	struct st_sensor_odr_avl odr_out = {0, 0};
146 146
 	struct st_sensor_data *sdata = iio_priv(indio_dev);
147 147
 
148 148
 	if (enable) {
149  
-		found = false;
150 149
 		tmp_value = sdata->sensor->pw.value_on;
151 150
 		if ((sdata->sensor->odr.addr == sdata->sensor->pw.addr) &&
152 151
 			(sdata->sensor->odr.mask == sdata->sensor->pw.mask)) {
64  drivers/iio/dac/ad5064.c
@@ -27,7 +27,6 @@
27 27
 #define AD5064_ADDR(x)				((x) << 20)
28 28
 #define AD5064_CMD(x)				((x) << 24)
29 29
 
30  
-#define AD5064_ADDR_DAC(chan)			(chan)
31 30
 #define AD5064_ADDR_ALL_DAC			0xF
32 31
 
33 32
 #define AD5064_CMD_WRITE_INPUT_N		0x0
@@ -131,15 +130,15 @@ static int ad5064_write(struct ad5064_state *st, unsigned int cmd,
131 130
 }
132 131
 
133 132
 static int ad5064_sync_powerdown_mode(struct ad5064_state *st,
134  
-	unsigned int channel)
  133
+	const struct iio_chan_spec *chan)
135 134
 {
136 135
 	unsigned int val;
137 136
 	int ret;
138 137
 
139  
-	val = (0x1 << channel);
  138
+	val = (0x1 << chan->address);
140 139
 
141  
-	if (st->pwr_down[channel])
142  
-		val |= st->pwr_down_mode[channel] << 8;
  140
+	if (st->pwr_down[chan->channel])
  141
+		val |= st->pwr_down_mode[chan->channel] << 8;
143 142
 
144 143
 	ret = ad5064_write(st, AD5064_CMD_POWERDOWN_DAC, 0, val, 0);
145 144
 
@@ -169,7 +168,7 @@ static int ad5064_set_powerdown_mode(struct iio_dev *indio_dev,
169 168
 	mutex_lock(&indio_dev->mlock);
170 169
 	st->pwr_down_mode[chan->channel] = mode + 1;
171 170
 
172  
-	ret = ad5064_sync_powerdown_mode(st, chan->channel);
  171
+	ret = ad5064_sync_powerdown_mode(st, chan);
173 172
 	mutex_unlock(&indio_dev->mlock);
174 173
 
175 174
 	return ret;
@@ -205,7 +204,7 @@ static ssize_t ad5064_write_dac_powerdown(struct iio_dev *indio_dev,
205 204
 	mutex_lock(&indio_dev->mlock);
206 205
 	st->pwr_down[chan->channel] = pwr_down;
207 206
 
208  
-	ret = ad5064_sync_powerdown_mode(st, chan->channel);
  207
+	ret = ad5064_sync_powerdown_mode(st, chan);
209 208
 	mutex_unlock(&indio_dev->mlock);
210 209
 	return ret ? ret : len;
211 210
 }
@@ -258,7 +257,7 @@ static int ad5064_write_raw(struct iio_dev *indio_dev,
258 257
 
259 258
 	switch (mask) {
260 259
 	case IIO_CHAN_INFO_RAW:
261  
-		if (val > (1 << chan->scan_type.realbits) || val < 0)
  260
+		if (val >= (1 << chan->scan_type.realbits) || val < 0)
262 261
 			return -EINVAL;
263 262
 
264 263
 		mutex_lock(&indio_dev->mlock);
@@ -292,34 +291,44 @@ static const struct iio_chan_spec_ext_info ad5064_ext_info[] = {
292 291
 	{ },
293 292
 };
294 293
 
295  
-#define AD5064_CHANNEL(chan, bits) {				\
  294
+#define AD5064_CHANNEL(chan, addr, bits) {			\
296 295
 	.type = IIO_VOLTAGE,					\
297 296
 	.indexed = 1,						\
298 297
 	.output = 1,						\
299 298
 	.channel = (chan),					\
300 299
 	.info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |		\
301 300
 	IIO_CHAN_INFO_SCALE_SEPARATE_BIT,			\
302  
-	.address = AD5064_ADDR_DAC(chan),			\
  301
+	.address = addr,					\
303 302
 	.scan_type = IIO_ST('u', (bits), 16, 20 - (bits)),	\
304 303
 	.ext_info = ad5064_ext_info,				\
305 304
 }
306 305
 
307 306
 #define DECLARE_AD5064_CHANNELS(name, bits) \
308 307
 const struct iio_chan_spec name[] = { \
309  
-	AD5064_CHANNEL(0, bits), \
310  
-	AD5064_CHANNEL(1, bits), \
311  
-	AD5064_CHANNEL(2, bits), \
312  
-	AD5064_CHANNEL(3, bits), \
313  
-	AD5064_CHANNEL(4, bits), \
314  
-	AD5064_CHANNEL(5, bits), \
315  
-	AD5064_CHANNEL(6, bits), \
316  
-	AD5064_CHANNEL(7, bits), \
  308
+	AD5064_CHANNEL(0, 0, bits), \
  309
+	AD5064_CHANNEL(1, 1, bits), \
  310
+	AD5064_CHANNEL(2, 2, bits), \
  311
+	AD5064_CHANNEL(3, 3, bits), \
  312
+	AD5064_CHANNEL(4, 4, bits), \
  313
+	AD5064_CHANNEL(5, 5, bits), \
  314
+	AD5064_CHANNEL(6, 6, bits), \
  315
+	AD5064_CHANNEL(7, 7, bits), \
  316
+}
  317
+
  318
+#define DECLARE_AD5065_CHANNELS(name, bits) \
  319
+const struct iio_chan_spec name[] = { \
  320
+	AD5064_CHANNEL(0, 0, bits), \
  321
+	AD5064_CHANNEL(1, 3, bits), \
317 322
 }
318 323
 
319 324
 static DECLARE_AD5064_CHANNELS(ad5024_channels, 12);
320 325
 static DECLARE_AD5064_CHANNELS(ad5044_channels, 14);
321 326
 static DECLARE_AD5064_CHANNELS(ad5064_channels, 16);
322 327
 
  328
+static DECLARE_AD5065_CHANNELS(ad5025_channels, 12);
  329
+static DECLARE_AD5065_CHANNELS(ad5045_channels, 14);
  330
+static DECLARE_AD5065_CHANNELS(ad5065_channels, 16);
  331
+
323 332
 static const struct ad5064_chip_info ad5064_chip_info_tbl[] = {
324 333
 	[ID_AD5024] = {
325 334
 		.shared_vref = false,
@@ -328,7 +337,7 @@ static const struct ad5064_chip_info ad5064_chip_info_tbl[] = {
328 337
 	},
329 338
 	[ID_AD5025] = {
330 339
 		.shared_vref = false,
331  
-		.channels = ad5024_channels,
  340
+		.channels = ad5025_channels,
332 341
 		.num_channels = 2,
333 342
 	},
334 343
 	[ID_AD5044] = {
@@ -338,7 +347,7 @@ static const struct ad5064_chip_info ad5064_chip_info_tbl[] = {
338 347
 	},
339 348
 	[ID_AD5045] = {
340 349
 		.shared_vref = false,
341  
-		.channels = ad5044_channels,
  350
+		.channels = ad5045_channels,
342 351
 		.num_channels = 2,
343 352
 	},
344 353
 	[ID_AD5064] = {
@@ -353,7 +362,7 @@ static const struct ad5064_chip_info ad5064_chip_info_tbl[] = {
353 362
 	},
354 363
 	[ID_AD5065] = {
355 364
 		.shared_vref = false,
356  
-		.channels = ad5064_channels,
  365
+		.channels = ad5065_channels,
357 366
 		.num_channels = 2,
358 367
 	},
359 368
 	[ID_AD5628_1] = {
@@ -429,6 +438,7 @@ static int ad5064_probe(struct device *dev, enum ad5064_type type,
429 438
 {
430 439
 	struct iio_dev *indio_dev;
431 440
 	struct ad5064_state *st;
  441
+	unsigned int midscale;
432 442
 	unsigned int i;
433 443
 	int ret;
434 444
 
@@ -465,11 +475,6 @@ static int ad5064_probe(struct device *dev, enum ad5064_type type,
465 475
 			goto error_free_reg;
466 476
 	}
467 477
 
468  
-	for (i = 0; i < st->chip_info->num_channels; ++i) {
469  
-		st->pwr_down_mode[i] = AD5064_LDAC_PWRDN_1K;
470  
-		st->dac_cache[i] = 0x8000;
471  
-	}
472  
-
473 478
 	indio_dev->dev.parent = dev;
474 479
 	indio_dev->name = name;
475 480
 	indio_dev->info = &ad5064_info;
@@ -477,6 +482,13 @@ static int ad5064_probe(struct device *dev, enum ad5064_type type,
477 482
 	indio_dev->channels = st->chip_info->channels;
478 483
 	indio_dev->num_channels = st->chip_info->num_channels;
479 484
 
  485
+	midscale = (1 << indio_dev->channels[0].scan_type.realbits) /  2;
  486
+
  487
+	for (i = 0; i < st->chip_info->num_channels; ++i) {
  488
+		st->pwr_down_mode[i] = AD5064_LDAC_PWRDN_1K;
  489
+		st->dac_cache[i] = midscale;
  490
+	}
  491
+
480 492
 	ret = iio_device_register(indio_dev);
481 493
 	if (ret)
482 494
 		goto error_disable_reg;
1  drivers/iio/imu/inv_mpu6050/Kconfig
@@ -5,6 +5,7 @@
5 5
 config INV_MPU6050_IIO
6 6
 	tristate "Invensense MPU6050 devices"
7 7
 	depends on I2C && SYSFS
  8
+	select IIO_BUFFER
8 9
 	select IIO_TRIGGERED_BUFFER
9 10
 	help
10 11
 	  This driver supports the Invensense MPU6050 devices.
9  include/linux/iio/common/st_sensors.h
@@ -227,14 +227,17 @@ struct st_sensor_data {
227 227
 };
228 228
 
229 229
 #ifdef CONFIG_IIO_BUFFER
  230
+irqreturn_t st_sensors_trigger_handler(int irq, void *p);
  231
+
  232
+int st_sensors_get_buffer_element(struct iio_dev *indio_dev, u8 *buf);
  233
+#endif
  234
+
  235
+#ifdef CONFIG_IIO_TRIGGER
230 236
 int st_sensors_allocate_trigger(struct iio_dev *indio_dev,
231 237
 				const struct iio_trigger_ops *trigger_ops);
232 238
 
233 239
 void st_sensors_deallocate_trigger(struct iio_dev *indio_dev);
234 240
 
235  
-irqreturn_t st_sensors_trigger_handler(int irq, void *p);
236  
-
237  
-int st_sensors_get_buffer_element(struct iio_dev *indio_dev, u8 *buf);
238 241
 #else
239 242
 static inline int st_sensors_allocate_trigger(struct iio_dev *indio_dev,
240 243
 				const struct iio_trigger_ops *trigger_ops)

0 notes on commit 1223ad3

Please sign in to comment.
Something went wrong with that request. Please try again.