Skip to content
This repository was archived by the owner on Mar 3, 2026. It is now read-only.

Commit 62a3f4c

Browse files
committed
Merge remote-tracking branch 'android/android-msm-angler-3.10-oreo-r6' into kernvatore-angler-3.10-oreo-r6
2 parents 62d1b6a + 79df07b commit 62a3f4c

File tree

22 files changed

+308
-129
lines changed

22 files changed

+308
-129
lines changed

drivers/char/diag/diag_masks.c

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2008-2014, The Linux Foundation. All rights reserved.
1+
/* Copyright (c) 2008-2014, 2017 The Linux Foundation. All rights reserved.
22
*
33
* This program is free software; you can redistribute it and/or modify
44
* it under the terms of the GNU General Public License version 2 and
@@ -248,7 +248,7 @@ static void diag_send_msg_mask_update(struct diag_smd_info *smd_info,
248248
uint8_t *buf = msg_mask.update_buf;
249249
uint8_t *temp = NULL;
250250
uint32_t mask_size = 0;
251-
struct diag_msg_mask_t *mask = (struct diag_msg_mask_t *)msg_mask.ptr;
251+
struct diag_msg_mask_t *mask;
252252
struct diag_ctrl_msg_mask header;
253253

254254
if (!smd_info)
@@ -259,7 +259,8 @@ static void diag_send_msg_mask_update(struct diag_smd_info *smd_info,
259259
__func__, smd_info->peripheral);
260260
return;
261261
}
262-
262+
mutex_lock(&driver->msg_mask_lock);
263+
mask = (struct diag_msg_mask_t *)msg_mask.ptr;
263264
mutex_lock(&msg_mask.lock);
264265
switch (msg_mask.status) {
265266
case DIAG_CTRL_MASK_ALL_DISABLED:
@@ -328,6 +329,7 @@ static void diag_send_msg_mask_update(struct diag_smd_info *smd_info,
328329
}
329330
err:
330331
mutex_unlock(&msg_mask.lock);
332+
mutex_unlock(&driver->msg_mask_lock);
331333
}
332334

333335
static void diag_send_feature_mask_update(struct diag_smd_info *smd_info)
@@ -394,7 +396,7 @@ static int diag_cmd_get_ssid_range(unsigned char *src_buf, int src_len,
394396

395397
if (!diag_apps_responds())
396398
return 0;
397-
399+
mutex_lock(&driver->msg_mask_lock);
398400
rsp.cmd_code = DIAG_CMD_MSG_CONFIG;
399401
rsp.sub_cmd = DIAG_CMD_OP_GET_SSID_RANGE;
400402
rsp.status = MSG_STATUS_SUCCESS;
@@ -415,6 +417,7 @@ static int diag_cmd_get_ssid_range(unsigned char *src_buf, int src_len,
415417
memcpy(dest_buf + write_len, &ssid_range, sizeof(ssid_range));
416418
write_len += sizeof(ssid_range);
417419
}
420+
mutex_unlock(&driver->msg_mask_lock);
418421

419422
return write_len;
420423
}
@@ -439,6 +442,7 @@ static int diag_cmd_get_build_mask(unsigned char *src_buf, int src_len,
439442
if (!diag_apps_responds())
440443
return 0;
441444

445+
mutex_lock(&driver->msg_mask_lock);
442446
req = (struct diag_build_mask_req_t *)src_buf;
443447
rsp.cmd_code = DIAG_CMD_MSG_CONFIG;
444448
rsp.sub_cmd = DIAG_CMD_OP_GET_BUILD_MASK;
@@ -469,6 +473,7 @@ static int diag_cmd_get_build_mask(unsigned char *src_buf, int src_len,
469473
}
470474
memcpy(dest_buf, &rsp, sizeof(rsp));
471475
write_len += sizeof(rsp);
476+
mutex_unlock(&driver->msg_mask_lock);
472477

473478
return write_len;
474479
}
@@ -491,7 +496,7 @@ static int diag_cmd_get_msg_mask(unsigned char *src_buf, int src_len,
491496

492497
if (!diag_apps_responds())
493498
return 0;
494-
499+
mutex_lock(&driver->msg_mask_lock);
495500
req = (struct diag_build_mask_req_t *)src_buf;
496501
rsp.cmd_code = DIAG_CMD_MSG_CONFIG;
497502
rsp.sub_cmd = DIAG_CMD_OP_GET_MSG_MASK;
@@ -517,6 +522,7 @@ static int diag_cmd_get_msg_mask(unsigned char *src_buf, int src_len,
517522
}
518523
memcpy(dest_buf, &rsp, sizeof(rsp));
519524
write_len += sizeof(rsp);
525+
mutex_unlock(&driver->msg_mask_lock);
520526

521527
return write_len;
522528
}
@@ -541,7 +547,7 @@ static int diag_cmd_set_msg_mask(unsigned char *src_buf, int src_len,
541547
}
542548

543549
req = (struct diag_msg_build_mask_t *)src_buf;
544-
550+
mutex_lock(&driver->msg_mask_lock);
545551
mutex_lock(&msg_mask.lock);
546552
mask = (struct diag_msg_mask_t *)msg_mask.ptr;
547553
for (i = 0; i < driver->msg_mask_tbl_count; i++, mask++) {
@@ -574,6 +580,7 @@ static int diag_cmd_set_msg_mask(unsigned char *src_buf, int src_len,
574580
break;
575581
}
576582
mutex_unlock(&msg_mask.lock);
583+
mutex_unlock(&driver->msg_mask_lock);
577584

578585
diag_update_userspace_clients(MSG_MASKS_TYPE);
579586

@@ -620,7 +627,7 @@ static int diag_cmd_set_all_msg_mask(unsigned char *src_buf, int src_len,
620627
}
621628

622629
req = (struct diag_msg_config_rsp_t *)src_buf;
623-
630+
mutex_lock(&driver->msg_mask_lock);
624631
mutex_lock(&msg_mask.lock);
625632
msg_mask.status = (req->rt_mask) ? DIAG_CTRL_MASK_ALL_ENABLED :
626633
DIAG_CTRL_MASK_ALL_DISABLED;
@@ -629,6 +636,7 @@ static int diag_cmd_set_all_msg_mask(unsigned char *src_buf, int src_len,
629636
mask->range * sizeof(uint32_t));
630637
}
631638
mutex_unlock(&msg_mask.lock);
639+
mutex_unlock(&driver->msg_mask_lock);
632640

633641
diag_update_userspace_clients(MSG_MASKS_TYPE);
634642

@@ -1037,6 +1045,7 @@ static int diag_create_msg_mask_table(void)
10371045
struct diag_msg_mask_t *mask = (struct diag_msg_mask_t *)msg_mask.ptr;
10381046
struct diag_ssid_range_t range;
10391047

1048+
mutex_lock(&driver->msg_mask_lock);
10401049
mutex_lock(&msg_mask.lock);
10411050
driver->msg_mask_tbl_count = MSG_MASK_TBL_CNT;
10421051
for (i = 0; i < driver->msg_mask_tbl_count; i++, mask++) {
@@ -1047,6 +1056,8 @@ static int diag_create_msg_mask_table(void)
10471056
break;
10481057
}
10491058
mutex_unlock(&msg_mask.lock);
1059+
mutex_unlock(&driver->msg_mask_lock);
1060+
10501061
return err;
10511062
}
10521063

@@ -1059,6 +1070,7 @@ static int diag_create_build_time_mask(void)
10591070
struct diag_msg_mask_t *build_mask = NULL;
10601071
struct diag_ssid_range_t range;
10611072

1073+
mutex_lock(&driver->msg_mask_lock);
10621074
mutex_lock(&msg_bt_mask.lock);
10631075
build_mask = (struct diag_msg_mask_t *)msg_bt_mask.ptr;
10641076
for (i = 0; i < driver->msg_mask_tbl_count; i++, build_mask++) {
@@ -1172,6 +1184,7 @@ static int diag_create_build_time_mask(void)
11721184
memcpy(build_mask->ptr, tbl, tbl_size);
11731185
}
11741186
mutex_unlock(&msg_bt_mask.lock);
1187+
mutex_unlock(&driver->msg_mask_lock);
11751188

11761189
return err;
11771190
}
@@ -1242,10 +1255,12 @@ static int diag_msg_mask_init(void)
12421255
pr_err("diag: Unable to create msg masks, err: %d\n", err);
12431256
return err;
12441257
}
1258+
mutex_lock(&driver->msg_mask_lock);
12451259
driver->msg_mask = &msg_mask;
12461260

12471261
for (i = 0; i < NUM_SMD_CONTROL_CHANNELS; i++)
12481262
driver->max_ssid_count[i] = 0;
1263+
mutex_unlock(&driver->msg_mask_lock);
12491264

12501265
return 0;
12511266
}
@@ -1255,14 +1270,17 @@ static void diag_msg_mask_exit(void)
12551270
int i;
12561271
struct diag_msg_mask_t *mask = NULL;
12571272

1273+
mutex_lock(&driver->msg_mask_lock);
12581274
mask = (struct diag_msg_mask_t *)(msg_mask.ptr);
12591275
if (mask) {
12601276
for (i = 0; i < driver->msg_mask_tbl_count; i++, mask++)
12611277
kfree(mask->ptr);
12621278
kfree(msg_mask.ptr);
1279+
msg_mask.ptr = NULL;
12631280
}
1264-
12651281
kfree(msg_mask.update_buf);
1282+
msg_mask.update_buf = NULL;
1283+
mutex_unlock(&driver->msg_mask_lock);
12661284
}
12671285

12681286
static int diag_build_time_mask_init(void)
@@ -1287,13 +1305,15 @@ static void diag_build_time_mask_exit(void)
12871305
{
12881306
int i;
12891307
struct diag_msg_mask_t *mask = NULL;
1290-
1308+
mutex_lock(&driver->msg_mask_lock);
12911309
mask = (struct diag_msg_mask_t *)(msg_bt_mask.ptr);
12921310
if (mask) {
1293-
for (i = 0; i < driver->msg_mask_tbl_count; i++, mask++)
1311+
for (i = 0; i < driver->bt_msg_mask_tbl_count; i++, mask++)
12941312
kfree(mask->ptr);
1295-
kfree(msg_mask.ptr);
1313+
kfree(msg_bt_mask.ptr);
1314+
msg_bt_mask.ptr = NULL;
12961315
}
1316+
mutex_unlock(&driver->msg_mask_lock);
12971317
}
12981318

12991319
static int diag_log_mask_init(void)
@@ -1367,7 +1387,7 @@ int diag_copy_to_user_msg_mask(char __user *buf, size_t count)
13671387

13681388
if (!buf || count == 0)
13691389
return -EINVAL;
1370-
1390+
mutex_lock(&driver->msg_mask_lock);
13711391
mutex_lock(&msg_mask.lock);
13721392
mask = (struct diag_msg_mask_t *)(msg_mask.ptr);
13731393
for (i = 0; i < driver->msg_mask_tbl_count; i++, mask++) {
@@ -1402,6 +1422,7 @@ int diag_copy_to_user_msg_mask(char __user *buf, size_t count)
14021422
total_len += len;
14031423
}
14041424
mutex_unlock(&msg_mask.lock);
1425+
mutex_unlock(&driver->msg_mask_lock);
14051426

14061427
return err ? err : total_len;
14071428
}

drivers/char/diag/diagchar.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2008-2015, The Linux Foundation. All rights reserved.
1+
/* Copyright (c) 2008-2017, The Linux Foundation. All rights reserved.
22
*
33
* This program is free software; you can redistribute it and/or modify
44
* it under the terms of the GNU General Public License version 2 and
@@ -470,8 +470,10 @@ struct diagchar_dev {
470470
struct diag_mask_info *event_mask;
471471
struct diag_mask_info *build_time_mask;
472472
uint8_t msg_mask_tbl_count;
473+
uint8_t bt_msg_mask_tbl_count;
473474
uint16_t event_mask_size;
474475
uint16_t last_event_id;
476+
struct mutex msg_mask_lock;
475477
/* Variables for Mask Centralization */
476478
uint16_t num_event_id[NUM_SMD_CONTROL_CHANNELS];
477479
uint32_t num_equip_id[NUM_SMD_CONTROL_CHANNELS];

drivers/char/diag/diagchar_core.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2008-2015, The Linux Foundation. All rights reserved.
1+
/* Copyright (c) 2008-2015, 2017 The Linux Foundation. All rights reserved.
22
*
33
* This program is free software; you can redistribute it and/or modify
44
* it under the terms of the GNU General Public License version 2 and
@@ -2324,6 +2324,7 @@ static int __init diagchar_init(void)
23242324
buf_hdlc_ctxt = SET_BUF_CTXT(APPS_DATA, SMD_DATA_TYPE, 1);
23252325
mutex_init(&driver->diagchar_mutex);
23262326
mutex_init(&driver->delayed_rsp_mutex);
2327+
mutex_init(&driver->msg_mask_lock);
23272328
init_waitqueue_head(&driver->wait_q);
23282329
init_waitqueue_head(&driver->smd_wait_q);
23292330
INIT_WORK(&(driver->diag_drain_work), diag_drain_work_fn);

drivers/char/diag/diagfwd_cntl.c

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved.
1+
/* Copyright (c) 2011-2014, 2017 The Linux Foundation. All rights reserved.
22
*
33
* This program is free software; you can redistribute it and/or modify
44
* it under the terms of the GNU General Public License version 2 and
@@ -396,8 +396,7 @@ static void process_ssid_range_report(uint8_t *buf, uint32_t len,
396396
ptr += header_len;
397397
/* Don't account for pkt_id and length */
398398
read_len += header_len - (2 * sizeof(uint32_t));
399-
400-
mutex_lock(&msg_mask.lock);
399+
mutex_lock(&driver->msg_mask_lock);
401400
driver->max_ssid_count[smd_info->peripheral] = header->count;
402401
for (i = 0; i < header->count && read_len < len; i++) {
403402
ssid_range = (struct diag_ssid_range_t *)ptr;
@@ -439,7 +438,7 @@ static void process_ssid_range_report(uint8_t *buf, uint32_t len,
439438
}
440439
driver->msg_mask_tbl_count += 1;
441440
}
442-
mutex_unlock(&msg_mask.lock);
441+
mutex_unlock(&driver->msg_mask_lock);
443442
}
444443

445444
static void diag_build_time_mask_update(uint8_t *buf,
@@ -464,12 +463,11 @@ static void diag_build_time_mask_update(uint8_t *buf,
464463
__func__, range->ssid_first, range->ssid_last);
465464
return;
466465
}
467-
466+
mutex_lock(&driver->msg_mask_lock);
468467
build_mask = (struct diag_msg_mask_t *)(driver->build_time_mask->ptr);
469468
num_items = range->ssid_last - range->ssid_first + 1;
470469

471-
mutex_lock(&driver->build_time_mask->lock);
472-
for (i = 0; i < driver->msg_mask_tbl_count; i++, build_mask++) {
470+
for (i = 0; i < driver->bt_msg_mask_tbl_count; i++, build_mask++) {
473471
if (build_mask->ssid_first != range->ssid_first)
474472
continue;
475473
found = 1;
@@ -486,7 +484,7 @@ static void diag_build_time_mask_update(uint8_t *buf,
486484

487485
if (found)
488486
goto end;
489-
new_size = (driver->msg_mask_tbl_count + 1) *
487+
new_size = (driver->bt_msg_mask_tbl_count + 1) *
490488
sizeof(struct diag_msg_mask_t);
491489
temp = krealloc(driver->build_time_mask->ptr, new_size, GFP_KERNEL);
492490
if (!temp) {
@@ -501,9 +499,10 @@ static void diag_build_time_mask_update(uint8_t *buf,
501499
__func__, err);
502500
goto end;
503501
}
504-
driver->msg_mask_tbl_count += 1;
502+
driver->bt_msg_mask_tbl_count += 1;
505503
end:
506-
mutex_unlock(&driver->build_time_mask->lock);
504+
mutex_unlock(&driver->msg_mask_lock);
505+
return;
507506
}
508507

509508
static void process_build_mask_report(uint8_t *buf, uint32_t len,

0 commit comments

Comments
 (0)