Skip to content

Commit 8891063

Browse files
committed
Merge tag 'staging-3.18-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging
Pull staging/IIO driver fixes from Greg KH: "Here are some staging and IIO driver fixes for 3.18-rc7 that resolve a number of reported issues, and a new device id for a staging wireless driver. All of these have been in linux-next" * tag 'staging-3.18-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging: staging: r8188eu: Add new device ID for DLink GO-USB-N150 staging: r8188eu: Fix scheduling while atomic error introduced in commit fadbe0c iio: accel: bmc150: set low default thresholds iio: accel: bmc150: Fix iio_event_spec direction iio: accel: bmc150: Send x, y and z motion separately iio: accel: bmc150: Error handling when mode set fails iio: gyro: bmg160: Fix iio_event_spec direction iio: gyro: bmg160: Send x, y and z motion separately iio: gyro: bmg160: Don't let interrupt mode to be open drain iio: gyro: bmg160: Error handling when mode set fails iio: adc: men_z188_adc: Add terminating entry for men_z188_ids iio: accel: kxcjk-1013: Fix kxcjk10013_set_range iio: Fix IIO_EVENT_CODE_EXTRACT_DIR bit mask
2 parents 6f93840 + 6d4556f commit 8891063

File tree

9 files changed

+105
-30
lines changed

9 files changed

+105
-30
lines changed

drivers/iio/accel/bmc150-accel.c

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@
4444

4545
#define BMC150_ACCEL_REG_INT_STATUS_2 0x0B
4646
#define BMC150_ACCEL_ANY_MOTION_MASK 0x07
47+
#define BMC150_ACCEL_ANY_MOTION_BIT_X BIT(0)
48+
#define BMC150_ACCEL_ANY_MOTION_BIT_Y BIT(1)
49+
#define BMC150_ACCEL_ANY_MOTION_BIT_Z BIT(2)
4750
#define BMC150_ACCEL_ANY_MOTION_BIT_SIGN BIT(3)
4851

4952
#define BMC150_ACCEL_REG_PMU_LPW 0x11
@@ -92,9 +95,9 @@
9295
#define BMC150_ACCEL_SLOPE_THRES_MASK 0xFF
9396

9497
/* Slope duration in terms of number of samples */
95-
#define BMC150_ACCEL_DEF_SLOPE_DURATION 2
98+
#define BMC150_ACCEL_DEF_SLOPE_DURATION 1
9699
/* in terms of multiples of g's/LSB, based on range */
97-
#define BMC150_ACCEL_DEF_SLOPE_THRESHOLD 5
100+
#define BMC150_ACCEL_DEF_SLOPE_THRESHOLD 1
98101

99102
#define BMC150_ACCEL_REG_XOUT_L 0x02
100103

@@ -536,6 +539,9 @@ static int bmc150_accel_set_power_state(struct bmc150_accel_data *data, bool on)
536539
if (ret < 0) {
537540
dev_err(&data->client->dev,
538541
"Failed: bmc150_accel_set_power_state for %d\n", on);
542+
if (on)
543+
pm_runtime_put_noidle(&data->client->dev);
544+
539545
return ret;
540546
}
541547

@@ -811,6 +817,7 @@ static int bmc150_accel_write_event_config(struct iio_dev *indio_dev,
811817

812818
ret = bmc150_accel_setup_any_motion_interrupt(data, state);
813819
if (ret < 0) {
820+
bmc150_accel_set_power_state(data, false);
814821
mutex_unlock(&data->mutex);
815822
return ret;
816823
}
@@ -846,7 +853,7 @@ static const struct attribute_group bmc150_accel_attrs_group = {
846853

847854
static const struct iio_event_spec bmc150_accel_event = {
848855
.type = IIO_EV_TYPE_ROC,
849-
.dir = IIO_EV_DIR_RISING | IIO_EV_DIR_FALLING,
856+
.dir = IIO_EV_DIR_EITHER,
850857
.mask_separate = BIT(IIO_EV_INFO_VALUE) |
851858
BIT(IIO_EV_INFO_ENABLE) |
852859
BIT(IIO_EV_INFO_PERIOD)
@@ -1054,6 +1061,7 @@ static int bmc150_accel_data_rdy_trigger_set_state(struct iio_trigger *trig,
10541061
else
10551062
ret = bmc150_accel_setup_new_data_interrupt(data, state);
10561063
if (ret < 0) {
1064+
bmc150_accel_set_power_state(data, false);
10571065
mutex_unlock(&data->mutex);
10581066
return ret;
10591067
}
@@ -1092,12 +1100,26 @@ static irqreturn_t bmc150_accel_event_handler(int irq, void *private)
10921100
else
10931101
dir = IIO_EV_DIR_RISING;
10941102

1095-
if (ret & BMC150_ACCEL_ANY_MOTION_MASK)
1103+
if (ret & BMC150_ACCEL_ANY_MOTION_BIT_X)
1104+
iio_push_event(indio_dev, IIO_MOD_EVENT_CODE(IIO_ACCEL,
1105+
0,
1106+
IIO_MOD_X,
1107+
IIO_EV_TYPE_ROC,
1108+
dir),
1109+
data->timestamp);
1110+
if (ret & BMC150_ACCEL_ANY_MOTION_BIT_Y)
10961111
iio_push_event(indio_dev, IIO_MOD_EVENT_CODE(IIO_ACCEL,
10971112
0,
1098-
IIO_MOD_X_OR_Y_OR_Z,
1113+
IIO_MOD_Y,
10991114
IIO_EV_TYPE_ROC,
1100-
IIO_EV_DIR_EITHER),
1115+
dir),
1116+
data->timestamp);
1117+
if (ret & BMC150_ACCEL_ANY_MOTION_BIT_Z)
1118+
iio_push_event(indio_dev, IIO_MOD_EVENT_CODE(IIO_ACCEL,
1119+
0,
1120+
IIO_MOD_Z,
1121+
IIO_EV_TYPE_ROC,
1122+
dir),
11011123
data->timestamp);
11021124
ack_intr_status:
11031125
if (!data->dready_trigger_on)
@@ -1354,10 +1376,14 @@ static int bmc150_accel_runtime_suspend(struct device *dev)
13541376
{
13551377
struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
13561378
struct bmc150_accel_data *data = iio_priv(indio_dev);
1379+
int ret;
13571380

13581381
dev_dbg(&data->client->dev, __func__);
1382+
ret = bmc150_accel_set_mode(data, BMC150_ACCEL_SLEEP_MODE_SUSPEND, 0);
1383+
if (ret < 0)
1384+
return -EAGAIN;
13591385

1360-
return bmc150_accel_set_mode(data, BMC150_ACCEL_SLEEP_MODE_SUSPEND, 0);
1386+
return 0;
13611387
}
13621388

13631389
static int bmc150_accel_runtime_resume(struct device *dev)

drivers/iio/accel/kxcjk-1013.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,8 @@ static int kxcjk1013_set_range(struct kxcjk1013_data *data, int range_index)
269269
return ret;
270270
}
271271

272+
ret &= ~(KXCJK1013_REG_CTRL1_BIT_GSEL0 |
273+
KXCJK1013_REG_CTRL1_BIT_GSEL1);
272274
ret |= (KXCJK1013_scale_table[range_index].gsel_0 << 3);
273275
ret |= (KXCJK1013_scale_table[range_index].gsel_1 << 4);
274276

drivers/iio/adc/men_z188_adc.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ static void men_z188_remove(struct mcb_device *dev)
152152

153153
static const struct mcb_device_id men_z188_ids[] = {
154154
{ .device = 0xbc },
155+
{ }
155156
};
156157
MODULE_DEVICE_TABLE(mcb, men_z188_ids);
157158

drivers/iio/gyro/bmg160.c

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@
6767
#define BMG160_REG_INT_EN_0 0x15
6868
#define BMG160_DATA_ENABLE_INT BIT(7)
6969

70+
#define BMG160_REG_INT_EN_1 0x16
71+
#define BMG160_INT1_BIT_OD BIT(1)
72+
7073
#define BMG160_REG_XOUT_L 0x02
7174
#define BMG160_AXIS_TO_REG(axis) (BMG160_REG_XOUT_L + (axis * 2))
7275

@@ -82,6 +85,9 @@
8285

8386
#define BMG160_REG_INT_STATUS_2 0x0B
8487
#define BMG160_ANY_MOTION_MASK 0x07
88+
#define BMG160_ANY_MOTION_BIT_X BIT(0)
89+
#define BMG160_ANY_MOTION_BIT_Y BIT(1)
90+
#define BMG160_ANY_MOTION_BIT_Z BIT(2)
8591

8692
#define BMG160_REG_TEMP 0x08
8793
#define BMG160_TEMP_CENTER_VAL 23
@@ -222,6 +228,19 @@ static int bmg160_chip_init(struct bmg160_data *data)
222228
data->slope_thres = ret;
223229

224230
/* Set default interrupt mode */
231+
ret = i2c_smbus_read_byte_data(data->client, BMG160_REG_INT_EN_1);
232+
if (ret < 0) {
233+
dev_err(&data->client->dev, "Error reading reg_int_en_1\n");
234+
return ret;
235+
}
236+
ret &= ~BMG160_INT1_BIT_OD;
237+
ret = i2c_smbus_write_byte_data(data->client,
238+
BMG160_REG_INT_EN_1, ret);
239+
if (ret < 0) {
240+
dev_err(&data->client->dev, "Error writing reg_int_en_1\n");
241+
return ret;
242+
}
243+
225244
ret = i2c_smbus_write_byte_data(data->client,
226245
BMG160_REG_INT_RST_LATCH,
227246
BMG160_INT_MODE_LATCH_INT |
@@ -250,6 +269,9 @@ static int bmg160_set_power_state(struct bmg160_data *data, bool on)
250269
if (ret < 0) {
251270
dev_err(&data->client->dev,
252271
"Failed: bmg160_set_power_state for %d\n", on);
272+
if (on)
273+
pm_runtime_put_noidle(&data->client->dev);
274+
253275
return ret;
254276
}
255277
#endif
@@ -705,6 +727,7 @@ static int bmg160_write_event_config(struct iio_dev *indio_dev,
705727

706728
ret = bmg160_setup_any_motion_interrupt(data, state);
707729
if (ret < 0) {
730+
bmg160_set_power_state(data, false);
708731
mutex_unlock(&data->mutex);
709732
return ret;
710733
}
@@ -743,7 +766,7 @@ static const struct attribute_group bmg160_attrs_group = {
743766

744767
static const struct iio_event_spec bmg160_event = {
745768
.type = IIO_EV_TYPE_ROC,
746-
.dir = IIO_EV_DIR_RISING | IIO_EV_DIR_FALLING,
769+
.dir = IIO_EV_DIR_EITHER,
747770
.mask_shared_by_type = BIT(IIO_EV_INFO_VALUE) |
748771
BIT(IIO_EV_INFO_ENABLE)
749772
};
@@ -871,6 +894,7 @@ static int bmg160_data_rdy_trigger_set_state(struct iio_trigger *trig,
871894
else
872895
ret = bmg160_setup_new_data_interrupt(data, state);
873896
if (ret < 0) {
897+
bmg160_set_power_state(data, false);
874898
mutex_unlock(&data->mutex);
875899
return ret;
876900
}
@@ -908,10 +932,24 @@ static irqreturn_t bmg160_event_handler(int irq, void *private)
908932
else
909933
dir = IIO_EV_DIR_FALLING;
910934

911-
if (ret & BMG160_ANY_MOTION_MASK)
935+
if (ret & BMG160_ANY_MOTION_BIT_X)
912936
iio_push_event(indio_dev, IIO_MOD_EVENT_CODE(IIO_ANGL_VEL,
913937
0,
914-
IIO_MOD_X_OR_Y_OR_Z,
938+
IIO_MOD_X,
939+
IIO_EV_TYPE_ROC,
940+
dir),
941+
data->timestamp);
942+
if (ret & BMG160_ANY_MOTION_BIT_Y)
943+
iio_push_event(indio_dev, IIO_MOD_EVENT_CODE(IIO_ANGL_VEL,
944+
0,
945+
IIO_MOD_Y,
946+
IIO_EV_TYPE_ROC,
947+
dir),
948+
data->timestamp);
949+
if (ret & BMG160_ANY_MOTION_BIT_Z)
950+
iio_push_event(indio_dev, IIO_MOD_EVENT_CODE(IIO_ANGL_VEL,
951+
0,
952+
IIO_MOD_Z,
915953
IIO_EV_TYPE_ROC,
916954
dir),
917955
data->timestamp);
@@ -1169,8 +1207,15 @@ static int bmg160_runtime_suspend(struct device *dev)
11691207
{
11701208
struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
11711209
struct bmg160_data *data = iio_priv(indio_dev);
1210+
int ret;
1211+
1212+
ret = bmg160_set_mode(data, BMG160_MODE_SUSPEND);
1213+
if (ret < 0) {
1214+
dev_err(&data->client->dev, "set mode failed\n");
1215+
return -EAGAIN;
1216+
}
11721217

1173-
return bmg160_set_mode(data, BMG160_MODE_SUSPEND);
1218+
return 0;
11741219
}
11751220

11761221
static int bmg160_runtime_resume(struct device *dev)

drivers/staging/rtl8188eu/core/rtw_cmd.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -275,11 +275,11 @@ u8 rtw_sitesurvey_cmd(struct adapter *padapter, struct ndis_802_11_ssid *ssid,
275275
if (check_fwstate(pmlmepriv, _FW_LINKED) == true)
276276
rtw_lps_ctrl_wk_cmd(padapter, LPS_CTRL_SCAN, 1);
277277

278-
ph2c = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL);
278+
ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC);
279279
if (ph2c == NULL)
280280
return _FAIL;
281281

282-
psurveyPara = kzalloc(sizeof(struct sitesurvey_parm), GFP_KERNEL);
282+
psurveyPara = kzalloc(sizeof(struct sitesurvey_parm), GFP_ATOMIC);
283283
if (psurveyPara == NULL) {
284284
kfree(ph2c);
285285
return _FAIL;
@@ -405,7 +405,7 @@ u8 rtw_joinbss_cmd(struct adapter *padapter, struct wlan_network *pnetwork)
405405
else
406406
RT_TRACE(_module_rtl871x_cmd_c_, _drv_notice_, ("+Join cmd: SSid =[%s]\n", pmlmepriv->assoc_ssid.Ssid));
407407

408-
pcmd = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL);
408+
pcmd = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC);
409409
if (pcmd == NULL) {
410410
res = _FAIL;
411411
RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("rtw_joinbss_cmd: memory allocate for cmd_obj fail!!!\n"));
@@ -755,13 +755,13 @@ u8 rtw_dynamic_chk_wk_cmd(struct adapter *padapter)
755755
u8 res = _SUCCESS;
756756

757757

758-
ph2c = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL);
758+
ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC);
759759
if (ph2c == NULL) {
760760
res = _FAIL;
761761
goto exit;
762762
}
763763

764-
pdrvextra_cmd_parm = kzalloc(sizeof(struct drvextra_cmd_parm), GFP_KERNEL);
764+
pdrvextra_cmd_parm = kzalloc(sizeof(struct drvextra_cmd_parm), GFP_ATOMIC);
765765
if (pdrvextra_cmd_parm == NULL) {
766766
kfree(ph2c);
767767
res = _FAIL;
@@ -967,13 +967,13 @@ u8 rtw_lps_ctrl_wk_cmd(struct adapter *padapter, u8 lps_ctrl_type, u8 enqueue)
967967
u8 res = _SUCCESS;
968968

969969
if (enqueue) {
970-
ph2c = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL);
970+
ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC);
971971
if (ph2c == NULL) {
972972
res = _FAIL;
973973
goto exit;
974974
}
975975

976-
pdrvextra_cmd_parm = kzalloc(sizeof(struct drvextra_cmd_parm), GFP_KERNEL);
976+
pdrvextra_cmd_parm = kzalloc(sizeof(struct drvextra_cmd_parm), GFP_ATOMIC);
977977
if (pdrvextra_cmd_parm == NULL) {
978978
kfree(ph2c);
979979
res = _FAIL;
@@ -1010,13 +1010,13 @@ u8 rtw_rpt_timer_cfg_cmd(struct adapter *padapter, u16 min_time)
10101010

10111011
u8 res = _SUCCESS;
10121012

1013-
ph2c = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL);
1013+
ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC);
10141014
if (ph2c == NULL) {
10151015
res = _FAIL;
10161016
goto exit;
10171017
}
10181018

1019-
pdrvextra_cmd_parm = kzalloc(sizeof(struct drvextra_cmd_parm), GFP_KERNEL);
1019+
pdrvextra_cmd_parm = kzalloc(sizeof(struct drvextra_cmd_parm), GFP_ATOMIC);
10201020
if (pdrvextra_cmd_parm == NULL) {
10211021
kfree(ph2c);
10221022
res = _FAIL;
@@ -1088,13 +1088,13 @@ u8 rtw_ps_cmd(struct adapter *padapter)
10881088

10891089
u8 res = _SUCCESS;
10901090

1091-
ppscmd = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL);
1091+
ppscmd = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC);
10921092
if (ppscmd == NULL) {
10931093
res = _FAIL;
10941094
goto exit;
10951095
}
10961096

1097-
pdrvextra_cmd_parm = kzalloc(sizeof(struct drvextra_cmd_parm), GFP_KERNEL);
1097+
pdrvextra_cmd_parm = kzalloc(sizeof(struct drvextra_cmd_parm), GFP_ATOMIC);
10981098
if (pdrvextra_cmd_parm == NULL) {
10991099
kfree(ppscmd);
11001100
res = _FAIL;

drivers/staging/rtl8188eu/core/rtw_mlme_ext.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4241,12 +4241,12 @@ void report_survey_event(struct adapter *padapter,
42414241
pcmdpriv = &padapter->cmdpriv;
42424242

42434243

4244-
pcmd_obj = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL);
4244+
pcmd_obj = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC);
42454245
if (pcmd_obj == NULL)
42464246
return;
42474247

42484248
cmdsz = (sizeof(struct survey_event) + sizeof(struct C2HEvent_Header));
4249-
pevtcmd = kzalloc(cmdsz, GFP_KERNEL);
4249+
pevtcmd = kzalloc(cmdsz, GFP_ATOMIC);
42504250
if (pevtcmd == NULL) {
42514251
kfree(pcmd_obj);
42524252
return;
@@ -4339,12 +4339,12 @@ void report_join_res(struct adapter *padapter, int res)
43394339
struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
43404340
struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
43414341

4342-
pcmd_obj = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL);
4342+
pcmd_obj = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC);
43434343
if (pcmd_obj == NULL)
43444344
return;
43454345

43464346
cmdsz = (sizeof(struct joinbss_event) + sizeof(struct C2HEvent_Header));
4347-
pevtcmd = kzalloc(cmdsz, GFP_KERNEL);
4347+
pevtcmd = kzalloc(cmdsz, GFP_ATOMIC);
43484348
if (pevtcmd == NULL) {
43494349
kfree(pcmd_obj);
43504350
return;
@@ -4854,11 +4854,11 @@ void survey_timer_hdl(void *function_context)
48544854
pmlmeext->scan_abort = false;/* reset */
48554855
}
48564856

4857-
ph2c = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL);
4857+
ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC);
48584858
if (ph2c == NULL)
48594859
goto exit_survey_timer_hdl;
48604860

4861-
psurveyPara = kzalloc(sizeof(struct sitesurvey_parm), GFP_KERNEL);
4861+
psurveyPara = kzalloc(sizeof(struct sitesurvey_parm), GFP_ATOMIC);
48624862
if (psurveyPara == NULL) {
48634863
kfree(ph2c);
48644864
goto exit_survey_timer_hdl;

drivers/staging/rtl8188eu/core/rtw_wlan_util.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -935,7 +935,7 @@ int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len)
935935
return true;
936936
}
937937

938-
bssid = kzalloc(sizeof(struct wlan_bssid_ex), GFP_KERNEL);
938+
bssid = kzalloc(sizeof(struct wlan_bssid_ex), GFP_ATOMIC);
939939

940940
subtype = GetFrameSubType(pframe) >> 4;
941941

drivers/staging/rtl8188eu/os_dep/usb_intf.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ static struct usb_device_id rtw_usb_id_tbl[] = {
4747
{USB_DEVICE(0x07b8, 0x8179)}, /* Abocom - Abocom */
4848
{USB_DEVICE(0x2001, 0x330F)}, /* DLink DWA-125 REV D1 */
4949
{USB_DEVICE(0x2001, 0x3310)}, /* Dlink DWA-123 REV D1 */
50+
{USB_DEVICE(0x2001, 0x3311)}, /* DLink GO-USB-N150 REV B1 */
5051
{USB_DEVICE(0x0df6, 0x0076)}, /* Sitecom N150 v2 */
5152
{} /* Terminating entry */
5253
};

include/linux/iio/events.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ struct iio_event_data {
7272

7373
#define IIO_EVENT_CODE_EXTRACT_TYPE(mask) ((mask >> 56) & 0xFF)
7474

75-
#define IIO_EVENT_CODE_EXTRACT_DIR(mask) ((mask >> 48) & 0xCF)
75+
#define IIO_EVENT_CODE_EXTRACT_DIR(mask) ((mask >> 48) & 0x7F)
7676

7777
#define IIO_EVENT_CODE_EXTRACT_CHAN_TYPE(mask) ((mask >> 32) & 0xFF)
7878

0 commit comments

Comments
 (0)