Skip to content

Commit 85b9df7

Browse files
committed
Merge tag 'staging-4.9-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging
Pull staging/IIO fixes from Grek KH: "Here are a few small staging and iio driver fixes for reported issues. The last one was cherry-picked from my -next branch to resolve a build warning that Arnd fixed, in his quest to be able to turn -Wmaybe-uninitialized back on again. That patch, and all of the others, have been in linux-next for a while with no reported issues" * tag 'staging-4.9-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging: iio: maxim_thermocouple: detect invalid storage size in read() staging: nvec: remove managed resource from PS2 driver Revert "staging: nvec: ps2: change serio type to passthrough" drivers: staging: nvec: remove bogus reset command for PS/2 interface staging: greybus: arche-platform: fix device reference leak staging: comedi: ni_tio: fix buggy ni_tio_clock_period_ps() return value staging: sm750fb: Fix bugs introduced by early commits iio: hid-sensors: Increase the precision of scale to fix wrong reading interpretation. iio: orientation: hid-sensor-rotation: Add PM function (fix non working driver) iio: st_sensors: fix scale configuration for h3lis331dl staging: iio: ad5933: avoid uninitialized variable in error case
2 parents befdfff + d70674e commit 85b9df7

File tree

10 files changed

+63
-53
lines changed

10 files changed

+63
-53
lines changed

drivers/iio/accel/st_accel_core.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -743,8 +743,8 @@ static int st_accel_read_raw(struct iio_dev *indio_dev,
743743

744744
return IIO_VAL_INT;
745745
case IIO_CHAN_INFO_SCALE:
746-
*val = 0;
747-
*val2 = adata->current_fullscale->gain;
746+
*val = adata->current_fullscale->gain / 1000000;
747+
*val2 = adata->current_fullscale->gain % 1000000;
748748
return IIO_VAL_INT_PLUS_MICRO;
749749
case IIO_CHAN_INFO_SAMP_FREQ:
750750
*val = adata->odr;
@@ -763,9 +763,13 @@ static int st_accel_write_raw(struct iio_dev *indio_dev,
763763
int err;
764764

765765
switch (mask) {
766-
case IIO_CHAN_INFO_SCALE:
767-
err = st_sensors_set_fullscale_by_gain(indio_dev, val2);
766+
case IIO_CHAN_INFO_SCALE: {
767+
int gain;
768+
769+
gain = val * 1000000 + val2;
770+
err = st_sensors_set_fullscale_by_gain(indio_dev, gain);
768771
break;
772+
}
769773
case IIO_CHAN_INFO_SAMP_FREQ:
770774
if (val2)
771775
return -EINVAL;

drivers/iio/common/hid-sensors/hid-sensor-attributes.c

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -30,34 +30,34 @@ static struct {
3030
u32 usage_id;
3131
int unit; /* 0 for default others from HID sensor spec */
3232
int scale_val0; /* scale, whole number */
33-
int scale_val1; /* scale, fraction in micros */
33+
int scale_val1; /* scale, fraction in nanos */
3434
} unit_conversion[] = {
35-
{HID_USAGE_SENSOR_ACCEL_3D, 0, 9, 806650},
35+
{HID_USAGE_SENSOR_ACCEL_3D, 0, 9, 806650000},
3636
{HID_USAGE_SENSOR_ACCEL_3D,
3737
HID_USAGE_SENSOR_UNITS_METERS_PER_SEC_SQRD, 1, 0},
3838
{HID_USAGE_SENSOR_ACCEL_3D,
39-
HID_USAGE_SENSOR_UNITS_G, 9, 806650},
39+
HID_USAGE_SENSOR_UNITS_G, 9, 806650000},
4040

41-
{HID_USAGE_SENSOR_GYRO_3D, 0, 0, 17453},
41+
{HID_USAGE_SENSOR_GYRO_3D, 0, 0, 17453293},
4242
{HID_USAGE_SENSOR_GYRO_3D,
4343
HID_USAGE_SENSOR_UNITS_RADIANS_PER_SECOND, 1, 0},
4444
{HID_USAGE_SENSOR_GYRO_3D,
45-
HID_USAGE_SENSOR_UNITS_DEGREES_PER_SECOND, 0, 17453},
45+
HID_USAGE_SENSOR_UNITS_DEGREES_PER_SECOND, 0, 17453293},
4646

47-
{HID_USAGE_SENSOR_COMPASS_3D, 0, 0, 1000},
47+
{HID_USAGE_SENSOR_COMPASS_3D, 0, 0, 1000000},
4848
{HID_USAGE_SENSOR_COMPASS_3D, HID_USAGE_SENSOR_UNITS_GAUSS, 1, 0},
4949

50-
{HID_USAGE_SENSOR_INCLINOMETER_3D, 0, 0, 17453},
50+
{HID_USAGE_SENSOR_INCLINOMETER_3D, 0, 0, 17453293},
5151
{HID_USAGE_SENSOR_INCLINOMETER_3D,
52-
HID_USAGE_SENSOR_UNITS_DEGREES, 0, 17453},
52+
HID_USAGE_SENSOR_UNITS_DEGREES, 0, 17453293},
5353
{HID_USAGE_SENSOR_INCLINOMETER_3D,
5454
HID_USAGE_SENSOR_UNITS_RADIANS, 1, 0},
5555

5656
{HID_USAGE_SENSOR_ALS, 0, 1, 0},
5757
{HID_USAGE_SENSOR_ALS, HID_USAGE_SENSOR_UNITS_LUX, 1, 0},
5858

5959
{HID_USAGE_SENSOR_PRESSURE, 0, 100, 0},
60-
{HID_USAGE_SENSOR_PRESSURE, HID_USAGE_SENSOR_UNITS_PASCAL, 0, 1000},
60+
{HID_USAGE_SENSOR_PRESSURE, HID_USAGE_SENSOR_UNITS_PASCAL, 0, 1000000},
6161
};
6262

6363
static int pow_10(unsigned power)
@@ -266,15 +266,15 @@ EXPORT_SYMBOL(hid_sensor_write_raw_hyst_value);
266266
/*
267267
* This fuction applies the unit exponent to the scale.
268268
* For example:
269-
* 9.806650 ->exp:2-> val0[980]val1[665000]
270-
* 9.000806 ->exp:2-> val0[900]val1[80600]
271-
* 0.174535 ->exp:2-> val0[17]val1[453500]
272-
* 1.001745 ->exp:0-> val0[1]val1[1745]
273-
* 1.001745 ->exp:2-> val0[100]val1[174500]
274-
* 1.001745 ->exp:4-> val0[10017]val1[450000]
275-
* 9.806650 ->exp:-2-> val0[0]val1[98066]
269+
* 9.806650000 ->exp:2-> val0[980]val1[665000000]
270+
* 9.000806000 ->exp:2-> val0[900]val1[80600000]
271+
* 0.174535293 ->exp:2-> val0[17]val1[453529300]
272+
* 1.001745329 ->exp:0-> val0[1]val1[1745329]
273+
* 1.001745329 ->exp:2-> val0[100]val1[174532900]
274+
* 1.001745329 ->exp:4-> val0[10017]val1[453290000]
275+
* 9.806650000 ->exp:-2-> val0[0]val1[98066500]
276276
*/
277-
static void adjust_exponent_micro(int *val0, int *val1, int scale0,
277+
static void adjust_exponent_nano(int *val0, int *val1, int scale0,
278278
int scale1, int exp)
279279
{
280280
int i;
@@ -285,32 +285,32 @@ static void adjust_exponent_micro(int *val0, int *val1, int scale0,
285285
if (exp > 0) {
286286
*val0 = scale0 * pow_10(exp);
287287
res = 0;
288-
if (exp > 6) {
288+
if (exp > 9) {
289289
*val1 = 0;
290290
return;
291291
}
292292
for (i = 0; i < exp; ++i) {
293-
x = scale1 / pow_10(5 - i);
293+
x = scale1 / pow_10(8 - i);
294294
res += (pow_10(exp - 1 - i) * x);
295-
scale1 = scale1 % pow_10(5 - i);
295+
scale1 = scale1 % pow_10(8 - i);
296296
}
297297
*val0 += res;
298298
*val1 = scale1 * pow_10(exp);
299299
} else if (exp < 0) {
300300
exp = abs(exp);
301-
if (exp > 6) {
301+
if (exp > 9) {
302302
*val0 = *val1 = 0;
303303
return;
304304
}
305305
*val0 = scale0 / pow_10(exp);
306306
rem = scale0 % pow_10(exp);
307307
res = 0;
308-
for (i = 0; i < (6 - exp); ++i) {
309-
x = scale1 / pow_10(5 - i);
310-
res += (pow_10(5 - exp - i) * x);
311-
scale1 = scale1 % pow_10(5 - i);
308+
for (i = 0; i < (9 - exp); ++i) {
309+
x = scale1 / pow_10(8 - i);
310+
res += (pow_10(8 - exp - i) * x);
311+
scale1 = scale1 % pow_10(8 - i);
312312
}
313-
*val1 = rem * pow_10(6 - exp) + res;
313+
*val1 = rem * pow_10(9 - exp) + res;
314314
} else {
315315
*val0 = scale0;
316316
*val1 = scale1;
@@ -332,14 +332,14 @@ int hid_sensor_format_scale(u32 usage_id,
332332
unit_conversion[i].unit == attr_info->units) {
333333
exp = hid_sensor_convert_exponent(
334334
attr_info->unit_expo);
335-
adjust_exponent_micro(val0, val1,
335+
adjust_exponent_nano(val0, val1,
336336
unit_conversion[i].scale_val0,
337337
unit_conversion[i].scale_val1, exp);
338338
break;
339339
}
340340
}
341341

342-
return IIO_VAL_INT_PLUS_MICRO;
342+
return IIO_VAL_INT_PLUS_NANO;
343343
}
344344
EXPORT_SYMBOL(hid_sensor_format_scale);
345345

drivers/iio/common/st_sensors/st_sensors_core.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,7 @@ EXPORT_SYMBOL(st_sensors_sysfs_sampling_frequency_avail);
612612
ssize_t st_sensors_sysfs_scale_avail(struct device *dev,
613613
struct device_attribute *attr, char *buf)
614614
{
615-
int i, len = 0;
615+
int i, len = 0, q, r;
616616
struct iio_dev *indio_dev = dev_get_drvdata(dev);
617617
struct st_sensor_data *sdata = iio_priv(indio_dev);
618618

@@ -621,8 +621,10 @@ ssize_t st_sensors_sysfs_scale_avail(struct device *dev,
621621
if (sdata->sensor_settings->fs.fs_avl[i].num == 0)
622622
break;
623623

624-
len += scnprintf(buf + len, PAGE_SIZE - len, "0.%06u ",
625-
sdata->sensor_settings->fs.fs_avl[i].gain);
624+
q = sdata->sensor_settings->fs.fs_avl[i].gain / 1000000;
625+
r = sdata->sensor_settings->fs.fs_avl[i].gain % 1000000;
626+
627+
len += scnprintf(buf + len, PAGE_SIZE - len, "%u.%06u ", q, r);
626628
}
627629
mutex_unlock(&indio_dev->mlock);
628630
buf[len - 1] = '\n';

drivers/iio/orientation/hid-sensor-rotation.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,7 @@ static struct platform_driver hid_dev_rot_platform_driver = {
335335
.id_table = hid_dev_rot_ids,
336336
.driver = {
337337
.name = KBUILD_MODNAME,
338+
.pm = &hid_sensor_pm_ops,
338339
},
339340
.probe = hid_dev_rot_probe,
340341
.remove = hid_dev_rot_remove,

drivers/iio/temperature/maxim_thermocouple.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ static int maxim_thermocouple_read(struct maxim_thermocouple_data *data,
136136
ret = spi_read(data->spi, (void *)&buf32, storage_bytes);
137137
*val = be32_to_cpu(buf32);
138138
break;
139+
default:
140+
ret = -EINVAL;
139141
}
140142

141143
if (ret)

drivers/staging/comedi/drivers/ni_tio.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,8 @@ static int ni_tio_clock_period_ps(const struct ni_gpct *counter,
207207
* clock period is specified by user with prescaling
208208
* already taken into account.
209209
*/
210-
return counter->clock_period_ps;
210+
*period_ps = counter->clock_period_ps;
211+
return 0;
211212
}
212213

213214
switch (generic_clock_source & NI_GPCT_PRESCALE_MODE_CLOCK_SRC_MASK) {

drivers/staging/greybus/arche-platform.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ int arche_platform_change_state(enum arche_platform_state state,
186186
exit:
187187
spin_unlock_irqrestore(&arche_pdata->wake_lock, flags);
188188
mutex_unlock(&arche_pdata->platform_state_mutex);
189+
put_device(&pdev->dev);
189190
of_node_put(np);
190191
return ret;
191192
}

drivers/staging/iio/impedance-analyzer/ad5933.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -655,26 +655,30 @@ static void ad5933_work(struct work_struct *work)
655655
__be16 buf[2];
656656
int val[2];
657657
unsigned char status;
658+
int ret;
658659

659660
mutex_lock(&indio_dev->mlock);
660661
if (st->state == AD5933_CTRL_INIT_START_FREQ) {
661662
/* start sweep */
662663
ad5933_cmd(st, AD5933_CTRL_START_SWEEP);
663664
st->state = AD5933_CTRL_START_SWEEP;
664665
schedule_delayed_work(&st->work, st->poll_time_jiffies);
665-
mutex_unlock(&indio_dev->mlock);
666-
return;
666+
goto out;
667667
}
668668

669-
ad5933_i2c_read(st->client, AD5933_REG_STATUS, 1, &status);
669+
ret = ad5933_i2c_read(st->client, AD5933_REG_STATUS, 1, &status);
670+
if (ret)
671+
goto out;
670672

671673
if (status & AD5933_STAT_DATA_VALID) {
672674
int scan_count = bitmap_weight(indio_dev->active_scan_mask,
673675
indio_dev->masklength);
674-
ad5933_i2c_read(st->client,
676+
ret = ad5933_i2c_read(st->client,
675677
test_bit(1, indio_dev->active_scan_mask) ?
676678
AD5933_REG_REAL_DATA : AD5933_REG_IMAG_DATA,
677679
scan_count * 2, (u8 *)buf);
680+
if (ret)
681+
goto out;
678682

679683
if (scan_count == 2) {
680684
val[0] = be16_to_cpu(buf[0]);
@@ -686,8 +690,7 @@ static void ad5933_work(struct work_struct *work)
686690
} else {
687691
/* no data available - try again later */
688692
schedule_delayed_work(&st->work, st->poll_time_jiffies);
689-
mutex_unlock(&indio_dev->mlock);
690-
return;
693+
goto out;
691694
}
692695

693696
if (status & AD5933_STAT_SWEEP_DONE) {
@@ -700,7 +703,7 @@ static void ad5933_work(struct work_struct *work)
700703
ad5933_cmd(st, AD5933_CTRL_INC_FREQ);
701704
schedule_delayed_work(&st->work, st->poll_time_jiffies);
702705
}
703-
706+
out:
704707
mutex_unlock(&indio_dev->mlock);
705708
}
706709

drivers/staging/nvec/nvec_ps2.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,12 @@ static int nvec_mouse_probe(struct platform_device *pdev)
106106
{
107107
struct nvec_chip *nvec = dev_get_drvdata(pdev->dev.parent);
108108
struct serio *ser_dev;
109-
char mouse_reset[] = { NVEC_PS2, SEND_COMMAND, PSMOUSE_RST, 3 };
110109

111-
ser_dev = devm_kzalloc(&pdev->dev, sizeof(struct serio), GFP_KERNEL);
110+
ser_dev = kzalloc(sizeof(struct serio), GFP_KERNEL);
112111
if (!ser_dev)
113112
return -ENOMEM;
114113

115-
ser_dev->id.type = SERIO_PS_PSTHRU;
114+
ser_dev->id.type = SERIO_8042;
116115
ser_dev->write = ps2_sendcommand;
117116
ser_dev->start = ps2_startstreaming;
118117
ser_dev->stop = ps2_stopstreaming;
@@ -127,9 +126,6 @@ static int nvec_mouse_probe(struct platform_device *pdev)
127126

128127
serio_register_port(ser_dev);
129128

130-
/* mouse reset */
131-
nvec_write_async(nvec, mouse_reset, sizeof(mouse_reset));
132-
133129
return 0;
134130
}
135131

drivers/staging/sm750fb/ddk750_reg.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -601,13 +601,13 @@
601601

602602
#define PANEL_PLANE_TL 0x08001C
603603
#define PANEL_PLANE_TL_TOP_SHIFT 16
604-
#define PANEL_PLANE_TL_TOP_MASK (0xeff << 16)
605-
#define PANEL_PLANE_TL_LEFT_MASK 0xeff
604+
#define PANEL_PLANE_TL_TOP_MASK (0x7ff << 16)
605+
#define PANEL_PLANE_TL_LEFT_MASK 0x7ff
606606

607607
#define PANEL_PLANE_BR 0x080020
608608
#define PANEL_PLANE_BR_BOTTOM_SHIFT 16
609-
#define PANEL_PLANE_BR_BOTTOM_MASK (0xeff << 16)
610-
#define PANEL_PLANE_BR_RIGHT_MASK 0xeff
609+
#define PANEL_PLANE_BR_BOTTOM_MASK (0x7ff << 16)
610+
#define PANEL_PLANE_BR_RIGHT_MASK 0x7ff
611611

612612
#define PANEL_HORIZONTAL_TOTAL 0x080024
613613
#define PANEL_HORIZONTAL_TOTAL_TOTAL_SHIFT 16

0 commit comments

Comments
 (0)