@@ -73,7 +73,7 @@ enum goodix_irq_pin_access_method {
73
73
struct goodix_chip_data {
74
74
u16 config_addr ;
75
75
int config_len ;
76
- int (* check_config )(struct goodix_ts_data * , const struct firmware * );
76
+ int (* check_config )(struct goodix_ts_data * ts , const u8 * cfg , int len );
77
77
void (* calc_config_checksum )(struct goodix_ts_data * ts );
78
78
};
79
79
@@ -103,9 +103,9 @@ struct goodix_ts_data {
103
103
};
104
104
105
105
static int goodix_check_cfg_8 (struct goodix_ts_data * ts ,
106
- const struct firmware * cfg );
106
+ const u8 * cfg , int len );
107
107
static int goodix_check_cfg_16 (struct goodix_ts_data * ts ,
108
- const struct firmware * cfg );
108
+ const u8 * cfg , int len );
109
109
static void goodix_calc_cfg_checksum_8 (struct goodix_ts_data * ts );
110
110
static void goodix_calc_cfg_checksum_16 (struct goodix_ts_data * ts );
111
111
@@ -444,22 +444,21 @@ static int goodix_request_irq(struct goodix_ts_data *ts)
444
444
ts -> irq_flags , ts -> client -> name , ts );
445
445
}
446
446
447
- static int goodix_check_cfg_8 (struct goodix_ts_data * ts ,
448
- const struct firmware * cfg )
447
+ static int goodix_check_cfg_8 (struct goodix_ts_data * ts , const u8 * cfg , int len )
449
448
{
450
- int i , raw_cfg_len = cfg -> size - 2 ;
449
+ int i , raw_cfg_len = len - 2 ;
451
450
u8 check_sum = 0 ;
452
451
453
452
for (i = 0 ; i < raw_cfg_len ; i ++ )
454
- check_sum += cfg -> data [i ];
453
+ check_sum += cfg [i ];
455
454
check_sum = (~check_sum ) + 1 ;
456
- if (check_sum != cfg -> data [raw_cfg_len ]) {
455
+ if (check_sum != cfg [raw_cfg_len ]) {
457
456
dev_err (& ts -> client -> dev ,
458
457
"The checksum of the config fw is not correct" );
459
458
return - EINVAL ;
460
459
}
461
460
462
- if (cfg -> data [raw_cfg_len + 1 ] != 1 ) {
461
+ if (cfg [raw_cfg_len + 1 ] != 1 ) {
463
462
dev_err (& ts -> client -> dev ,
464
463
"Config fw must have Config_Fresh register set" );
465
464
return - EINVAL ;
@@ -481,22 +480,22 @@ static void goodix_calc_cfg_checksum_8(struct goodix_ts_data *ts)
481
480
ts -> config [raw_cfg_len + 1 ] = 1 ; /* Set "config_fresh" bit */
482
481
}
483
482
484
- static int goodix_check_cfg_16 (struct goodix_ts_data * ts ,
485
- const struct firmware * cfg )
483
+ static int goodix_check_cfg_16 (struct goodix_ts_data * ts , const u8 * cfg ,
484
+ int len )
486
485
{
487
- int i , raw_cfg_len = cfg -> size - 3 ;
486
+ int i , raw_cfg_len = len - 3 ;
488
487
u16 check_sum = 0 ;
489
488
490
489
for (i = 0 ; i < raw_cfg_len ; i += 2 )
491
- check_sum += get_unaligned_be16 (& cfg -> data [i ]);
490
+ check_sum += get_unaligned_be16 (& cfg [i ]);
492
491
check_sum = (~check_sum ) + 1 ;
493
- if (check_sum != get_unaligned_be16 (& cfg -> data [raw_cfg_len ])) {
492
+ if (check_sum != get_unaligned_be16 (& cfg [raw_cfg_len ])) {
494
493
dev_err (& ts -> client -> dev ,
495
494
"The checksum of the config fw is not correct" );
496
495
return - EINVAL ;
497
496
}
498
497
499
- if (cfg -> data [raw_cfg_len + 2 ] != 1 ) {
498
+ if (cfg [raw_cfg_len + 2 ] != 1 ) {
500
499
dev_err (& ts -> client -> dev ,
501
500
"Config fw must have Config_Fresh register set" );
502
501
return - EINVAL ;
@@ -524,17 +523,16 @@ static void goodix_calc_cfg_checksum_16(struct goodix_ts_data *ts)
524
523
* @ts: goodix_ts_data pointer
525
524
* @cfg: firmware config data
526
525
*/
527
- static int goodix_check_cfg (struct goodix_ts_data * ts ,
528
- const struct firmware * cfg )
526
+ static int goodix_check_cfg (struct goodix_ts_data * ts , const u8 * cfg , int len )
529
527
{
530
- if (cfg -> size < GOODIX_CONFIG_MIN_LENGTH ||
531
- cfg -> size > GOODIX_CONFIG_MAX_LENGTH ) {
528
+ if (len < GOODIX_CONFIG_MIN_LENGTH ||
529
+ len > GOODIX_CONFIG_MAX_LENGTH ) {
532
530
dev_err (& ts -> client -> dev ,
533
531
"The length of the config fw is not correct" );
534
532
return - EINVAL ;
535
533
}
536
534
537
- return ts -> chip -> check_config (ts , cfg );
535
+ return ts -> chip -> check_config (ts , cfg , len );
538
536
}
539
537
540
538
/**
@@ -543,17 +541,15 @@ static int goodix_check_cfg(struct goodix_ts_data *ts,
543
541
* @ts: goodix_ts_data pointer
544
542
* @cfg: config firmware to write to device
545
543
*/
546
- static int goodix_send_cfg (struct goodix_ts_data * ts ,
547
- const struct firmware * cfg )
544
+ static int goodix_send_cfg (struct goodix_ts_data * ts , const u8 * cfg , int len )
548
545
{
549
546
int error ;
550
547
551
- error = goodix_check_cfg (ts , cfg );
548
+ error = goodix_check_cfg (ts , cfg , len );
552
549
if (error )
553
550
return error ;
554
551
555
- error = goodix_i2c_write (ts -> client , ts -> chip -> config_addr , cfg -> data ,
556
- cfg -> size );
552
+ error = goodix_i2c_write (ts -> client , ts -> chip -> config_addr , cfg , len );
557
553
if (error ) {
558
554
dev_err (& ts -> client -> dev , "Failed to write config data: %d" ,
559
555
error );
@@ -1094,7 +1090,7 @@ static void goodix_config_cb(const struct firmware *cfg, void *ctx)
1094
1090
1095
1091
if (cfg ) {
1096
1092
/* send device configuration to the firmware */
1097
- error = goodix_send_cfg (ts , cfg );
1093
+ error = goodix_send_cfg (ts , cfg -> data , cfg -> size );
1098
1094
if (error )
1099
1095
goto err_release_cfg ;
1100
1096
}
0 commit comments