Skip to content

Commit 7f21739

Browse files
committed
Merge tag 'staging-4.4-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging
Pull staging/IIO fixes from Greg KH: "Here are some staging and iio driver fixes for 4.4-rc2. All of these are in response to issues that have been reported and have been in linux-next for a while" * tag 'staging-4.4-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging: Revert "Staging: wilc1000: coreconfigurator: Drop unneeded wrapper functions" iio: adc: xilinx: Fix VREFN scale iio: si7020: Swap data byte order iio: adc: vf610_adc: Fix division by zero error iio:ad7793: Fix ad7785 product ID iio: ad5064: Fix ad5629/ad5669 shift iio:ad5064: Make sure ad5064_i2c_write() returns 0 on success iio: lpc32xx_adc: fix warnings caused by enabling unprepared clock staging: iio: select IRQ_WORK for IIO_DUMMY_EVGEN vf610_adc: Fix internal temperature calculation
2 parents 6d2d91b + b57f9f3 commit 7f21739

File tree

8 files changed

+115
-64
lines changed

8 files changed

+115
-64
lines changed

drivers/iio/adc/ad7793.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@
101101
#define AD7795_CH_AIN1M_AIN1M 8 /* AIN1(-) - AIN1(-) */
102102

103103
/* ID Register Bit Designations (AD7793_REG_ID) */
104-
#define AD7785_ID 0xB
104+
#define AD7785_ID 0x3
105105
#define AD7792_ID 0xA
106106
#define AD7793_ID 0xB
107107
#define AD7794_ID 0xF

drivers/iio/adc/vf610_adc.c

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,13 @@
106106

107107
#define DEFAULT_SAMPLE_TIME 1000
108108

109+
/* V at 25°C of 696 mV */
110+
#define VF610_VTEMP25_3V0 950
111+
/* V at 25°C of 699 mV */
112+
#define VF610_VTEMP25_3V3 867
113+
/* Typical sensor slope coefficient at all temperatures */
114+
#define VF610_TEMP_SLOPE_COEFF 1840
115+
109116
enum clk_sel {
110117
VF610_ADCIOC_BUSCLK_SET,
111118
VF610_ADCIOC_ALTCLK_SET,
@@ -197,6 +204,8 @@ static inline void vf610_adc_calculate_rates(struct vf610_adc *info)
197204
adc_feature->clk_div = 8;
198205
}
199206

207+
adck_rate = ipg_rate / adc_feature->clk_div;
208+
200209
/*
201210
* Determine the long sample time adder value to be used based
202211
* on the default minimum sample time provided.
@@ -221,7 +230,6 @@ static inline void vf610_adc_calculate_rates(struct vf610_adc *info)
221230
* BCT (Base Conversion Time): fixed to 25 ADCK cycles for 12 bit mode
222231
* LSTAdder(Long Sample Time): 3, 5, 7, 9, 13, 17, 21, 25 ADCK cycles
223232
*/
224-
adck_rate = ipg_rate / info->adc_feature.clk_div;
225233
for (i = 0; i < ARRAY_SIZE(vf610_hw_avgs); i++)
226234
info->sample_freq_avail[i] =
227235
adck_rate / (6 + vf610_hw_avgs[i] *
@@ -663,11 +671,13 @@ static int vf610_read_raw(struct iio_dev *indio_dev,
663671
break;
664672
case IIO_TEMP:
665673
/*
666-
* Calculate in degree Celsius times 1000
667-
* Using sensor slope of 1.84 mV/°C and
668-
* V at 25°C of 696 mV
669-
*/
670-
*val = 25000 - ((int)info->value - 864) * 1000000 / 1840;
674+
* Calculate in degree Celsius times 1000
675+
* Using the typical sensor slope of 1.84 mV/°C
676+
* and VREFH_ADC at 3.3V, V at 25°C of 699 mV
677+
*/
678+
*val = 25000 - ((int)info->value - VF610_VTEMP25_3V3) *
679+
1000000 / VF610_TEMP_SLOPE_COEFF;
680+
671681
break;
672682
default:
673683
mutex_unlock(&indio_dev->mlock);

drivers/iio/adc/xilinx-xadc-core.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -841,6 +841,7 @@ static int xadc_read_raw(struct iio_dev *indio_dev,
841841
case XADC_REG_VCCINT:
842842
case XADC_REG_VCCAUX:
843843
case XADC_REG_VREFP:
844+
case XADC_REG_VREFN:
844845
case XADC_REG_VCCBRAM:
845846
case XADC_REG_VCCPINT:
846847
case XADC_REG_VCCPAUX:

drivers/iio/dac/ad5064.c

Lines changed: 64 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,16 @@ enum ad5064_type {
113113
ID_AD5065,
114114
ID_AD5628_1,
115115
ID_AD5628_2,
116+
ID_AD5629_1,
117+
ID_AD5629_2,
116118
ID_AD5648_1,
117119
ID_AD5648_2,
118120
ID_AD5666_1,
119121
ID_AD5666_2,
120122
ID_AD5668_1,
121123
ID_AD5668_2,
124+
ID_AD5669_1,
125+
ID_AD5669_2,
122126
};
123127

124128
static int ad5064_write(struct ad5064_state *st, unsigned int cmd,
@@ -291,7 +295,7 @@ static const struct iio_chan_spec_ext_info ad5064_ext_info[] = {
291295
{ },
292296
};
293297

294-
#define AD5064_CHANNEL(chan, addr, bits) { \
298+
#define AD5064_CHANNEL(chan, addr, bits, _shift) { \
295299
.type = IIO_VOLTAGE, \
296300
.indexed = 1, \
297301
.output = 1, \
@@ -303,36 +307,39 @@ static const struct iio_chan_spec_ext_info ad5064_ext_info[] = {
303307
.sign = 'u', \
304308
.realbits = (bits), \
305309
.storagebits = 16, \
306-
.shift = 20 - bits, \
310+
.shift = (_shift), \
307311
}, \
308312
.ext_info = ad5064_ext_info, \
309313
}
310314

311-
#define DECLARE_AD5064_CHANNELS(name, bits) \
315+
#define DECLARE_AD5064_CHANNELS(name, bits, shift) \
312316
const struct iio_chan_spec name[] = { \
313-
AD5064_CHANNEL(0, 0, bits), \
314-
AD5064_CHANNEL(1, 1, bits), \
315-
AD5064_CHANNEL(2, 2, bits), \
316-
AD5064_CHANNEL(3, 3, bits), \
317-
AD5064_CHANNEL(4, 4, bits), \
318-
AD5064_CHANNEL(5, 5, bits), \
319-
AD5064_CHANNEL(6, 6, bits), \
320-
AD5064_CHANNEL(7, 7, bits), \
317+
AD5064_CHANNEL(0, 0, bits, shift), \
318+
AD5064_CHANNEL(1, 1, bits, shift), \
319+
AD5064_CHANNEL(2, 2, bits, shift), \
320+
AD5064_CHANNEL(3, 3, bits, shift), \
321+
AD5064_CHANNEL(4, 4, bits, shift), \
322+
AD5064_CHANNEL(5, 5, bits, shift), \
323+
AD5064_CHANNEL(6, 6, bits, shift), \
324+
AD5064_CHANNEL(7, 7, bits, shift), \
321325
}
322326

323-
#define DECLARE_AD5065_CHANNELS(name, bits) \
327+
#define DECLARE_AD5065_CHANNELS(name, bits, shift) \
324328
const struct iio_chan_spec name[] = { \
325-
AD5064_CHANNEL(0, 0, bits), \
326-
AD5064_CHANNEL(1, 3, bits), \
329+
AD5064_CHANNEL(0, 0, bits, shift), \
330+
AD5064_CHANNEL(1, 3, bits, shift), \
327331
}
328332

329-
static DECLARE_AD5064_CHANNELS(ad5024_channels, 12);
330-
static DECLARE_AD5064_CHANNELS(ad5044_channels, 14);
331-
static DECLARE_AD5064_CHANNELS(ad5064_channels, 16);
333+
static DECLARE_AD5064_CHANNELS(ad5024_channels, 12, 8);
334+
static DECLARE_AD5064_CHANNELS(ad5044_channels, 14, 6);
335+
static DECLARE_AD5064_CHANNELS(ad5064_channels, 16, 4);
332336

333-
static DECLARE_AD5065_CHANNELS(ad5025_channels, 12);
334-
static DECLARE_AD5065_CHANNELS(ad5045_channels, 14);
335-
static DECLARE_AD5065_CHANNELS(ad5065_channels, 16);
337+
static DECLARE_AD5065_CHANNELS(ad5025_channels, 12, 8);
338+
static DECLARE_AD5065_CHANNELS(ad5045_channels, 14, 6);
339+
static DECLARE_AD5065_CHANNELS(ad5065_channels, 16, 4);
340+
341+
static DECLARE_AD5064_CHANNELS(ad5629_channels, 12, 4);
342+
static DECLARE_AD5064_CHANNELS(ad5669_channels, 16, 0);
336343

337344
static const struct ad5064_chip_info ad5064_chip_info_tbl[] = {
338345
[ID_AD5024] = {
@@ -382,6 +389,18 @@ static const struct ad5064_chip_info ad5064_chip_info_tbl[] = {
382389
.channels = ad5024_channels,
383390
.num_channels = 8,
384391
},
392+
[ID_AD5629_1] = {
393+
.shared_vref = true,
394+
.internal_vref = 2500000,
395+
.channels = ad5629_channels,
396+
.num_channels = 8,
397+
},
398+
[ID_AD5629_2] = {
399+
.shared_vref = true,
400+
.internal_vref = 5000000,
401+
.channels = ad5629_channels,
402+
.num_channels = 8,
403+
},
385404
[ID_AD5648_1] = {
386405
.shared_vref = true,
387406
.internal_vref = 2500000,
@@ -418,6 +437,18 @@ static const struct ad5064_chip_info ad5064_chip_info_tbl[] = {
418437
.channels = ad5064_channels,
419438
.num_channels = 8,
420439
},
440+
[ID_AD5669_1] = {
441+
.shared_vref = true,
442+
.internal_vref = 2500000,
443+
.channels = ad5669_channels,
444+
.num_channels = 8,
445+
},
446+
[ID_AD5669_2] = {
447+
.shared_vref = true,
448+
.internal_vref = 5000000,
449+
.channels = ad5669_channels,
450+
.num_channels = 8,
451+
},
421452
};
422453

423454
static inline unsigned int ad5064_num_vref(struct ad5064_state *st)
@@ -597,10 +628,16 @@ static int ad5064_i2c_write(struct ad5064_state *st, unsigned int cmd,
597628
unsigned int addr, unsigned int val)
598629
{
599630
struct i2c_client *i2c = to_i2c_client(st->dev);
631+
int ret;
600632

601633
st->data.i2c[0] = (cmd << 4) | addr;
602634
put_unaligned_be16(val, &st->data.i2c[1]);
603-
return i2c_master_send(i2c, st->data.i2c, 3);
635+
636+
ret = i2c_master_send(i2c, st->data.i2c, 3);
637+
if (ret < 0)
638+
return ret;
639+
640+
return 0;
604641
}
605642

606643
static int ad5064_i2c_probe(struct i2c_client *i2c,
@@ -616,12 +653,12 @@ static int ad5064_i2c_remove(struct i2c_client *i2c)
616653
}
617654

618655
static const struct i2c_device_id ad5064_i2c_ids[] = {
619-
{"ad5629-1", ID_AD5628_1},
620-
{"ad5629-2", ID_AD5628_2},
621-
{"ad5629-3", ID_AD5628_2}, /* similar enough to ad5629-2 */
622-
{"ad5669-1", ID_AD5668_1},
623-
{"ad5669-2", ID_AD5668_2},
624-
{"ad5669-3", ID_AD5668_2}, /* similar enough to ad5669-2 */
656+
{"ad5629-1", ID_AD5629_1},
657+
{"ad5629-2", ID_AD5629_2},
658+
{"ad5629-3", ID_AD5629_2}, /* similar enough to ad5629-2 */
659+
{"ad5669-1", ID_AD5669_1},
660+
{"ad5669-2", ID_AD5669_2},
661+
{"ad5669-3", ID_AD5669_2}, /* similar enough to ad5669-2 */
625662
{}
626663
};
627664
MODULE_DEVICE_TABLE(i2c, ad5064_i2c_ids);

drivers/iio/humidity/si7020.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ static int si7020_read_raw(struct iio_dev *indio_dev,
5050

5151
switch (mask) {
5252
case IIO_CHAN_INFO_RAW:
53-
ret = i2c_smbus_read_word_data(*client,
54-
chan->type == IIO_TEMP ?
55-
SI7020CMD_TEMP_HOLD :
56-
SI7020CMD_RH_HOLD);
53+
ret = i2c_smbus_read_word_swapped(*client,
54+
chan->type == IIO_TEMP ?
55+
SI7020CMD_TEMP_HOLD :
56+
SI7020CMD_RH_HOLD);
5757
if (ret < 0)
5858
return ret;
5959
*val = ret >> 2;

drivers/staging/iio/Kconfig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ source "drivers/staging/iio/resolver/Kconfig"
1818
source "drivers/staging/iio/trigger/Kconfig"
1919

2020
config IIO_DUMMY_EVGEN
21-
tristate
21+
tristate
22+
select IRQ_WORK
2223

2324
config IIO_SIMPLE_DUMMY
2425
tristate "An example driver with no hardware requirements"

drivers/staging/iio/adc/lpc32xx_adc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,15 @@ static int lpc32xx_read_raw(struct iio_dev *indio_dev,
7676

7777
if (mask == IIO_CHAN_INFO_RAW) {
7878
mutex_lock(&indio_dev->mlock);
79-
clk_enable(info->clk);
79+
clk_prepare_enable(info->clk);
8080
/* Measurement setup */
8181
__raw_writel(AD_INTERNAL | (chan->address) | AD_REFp | AD_REFm,
8282
LPC32XX_ADC_SELECT(info->adc_base));
8383
/* Trigger conversion */
8484
__raw_writel(AD_PDN_CTRL | AD_STROBE,
8585
LPC32XX_ADC_CTRL(info->adc_base));
8686
wait_for_completion(&info->completion); /* set by ISR */
87-
clk_disable(info->clk);
87+
clk_disable_unprepare(info->clk);
8888
*val = info->value;
8989
mutex_unlock(&indio_dev->mlock);
9090

drivers/staging/wilc1000/coreconfigurator.c

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,8 @@
1313
#include "wilc_wlan.h"
1414
#include <linux/errno.h>
1515
#include <linux/slab.h>
16-
#include <linux/etherdevice.h>
1716
#define TAG_PARAM_OFFSET (MAC_HDR_LEN + TIME_STAMP_LEN + \
1817
BEACON_INTERVAL_LEN + CAP_INFO_LEN)
19-
#define ADDR1 4
20-
#define ADDR2 10
21-
#define ADDR3 16
2218

2319
/* Basic Frame Type Codes (2-bit) */
2420
enum basic_frame_type {
@@ -175,32 +171,38 @@ static inline u8 get_from_ds(u8 *header)
175171
return ((header[1] & 0x02) >> 1);
176172
}
177173

174+
/* This function extracts the MAC Address in 'address1' field of the MAC */
175+
/* header and updates the MAC Address in the allocated 'addr' variable. */
176+
static inline void get_address1(u8 *pu8msa, u8 *addr)
177+
{
178+
memcpy(addr, pu8msa + 4, 6);
179+
}
180+
181+
/* This function extracts the MAC Address in 'address2' field of the MAC */
182+
/* header and updates the MAC Address in the allocated 'addr' variable. */
183+
static inline void get_address2(u8 *pu8msa, u8 *addr)
184+
{
185+
memcpy(addr, pu8msa + 10, 6);
186+
}
187+
188+
/* This function extracts the MAC Address in 'address3' field of the MAC */
189+
/* header and updates the MAC Address in the allocated 'addr' variable. */
190+
static inline void get_address3(u8 *pu8msa, u8 *addr)
191+
{
192+
memcpy(addr, pu8msa + 16, 6);
193+
}
194+
178195
/* This function extracts the BSSID from the incoming WLAN packet based on */
179-
/* the 'from ds' bit, and updates the MAC Address in the allocated 'data' */
196+
/* the 'from ds' bit, and updates the MAC Address in the allocated 'addr' */
180197
/* variable. */
181198
static inline void get_BSSID(u8 *data, u8 *bssid)
182199
{
183200
if (get_from_ds(data) == 1)
184-
/*
185-
* Extract the MAC Address in 'address2' field of the MAC
186-
* header and update the MAC Address in the allocated 'data'
187-
* variable.
188-
*/
189-
ether_addr_copy(data, bssid + ADDR2);
201+
get_address2(data, bssid);
190202
else if (get_to_ds(data) == 1)
191-
/*
192-
* Extract the MAC Address in 'address1' field of the MAC
193-
* header and update the MAC Address in the allocated 'data'
194-
* variable.
195-
*/
196-
ether_addr_copy(data, bssid + ADDR1);
203+
get_address1(data, bssid);
197204
else
198-
/*
199-
* Extract the MAC Address in 'address3' field of the MAC
200-
* header and update the MAC Address in the allocated 'data'
201-
* variable.
202-
*/
203-
ether_addr_copy(data, bssid + ADDR3);
205+
get_address3(data, bssid);
204206
}
205207

206208
/* This function extracts the SSID from a beacon/probe response frame */

0 commit comments

Comments
 (0)