@@ -458,18 +458,15 @@ struct iqs626_private {
458
458
459
459
static noinline_for_stack int
460
460
iqs626_parse_events (struct iqs626_private * iqs626 ,
461
- const struct fwnode_handle * ch_node ,
462
- enum iqs626_ch_id ch_id )
461
+ struct fwnode_handle * ch_node , enum iqs626_ch_id ch_id )
463
462
{
464
463
struct iqs626_sys_reg * sys_reg = & iqs626 -> sys_reg ;
465
464
struct i2c_client * client = iqs626 -> client ;
466
- const struct fwnode_handle * ev_node ;
465
+ struct fwnode_handle * ev_node ;
467
466
const char * ev_name ;
468
467
u8 * thresh , * hyst ;
469
- unsigned int thresh_tp [IQS626_NUM_CH_TP_3 ];
470
468
unsigned int val ;
471
- int num_ch = iqs626_channels [ch_id ].num_ch ;
472
- int error , i , j ;
469
+ int i ;
473
470
474
471
switch (ch_id ) {
475
472
case IQS626_CH_ULP_0 :
@@ -509,7 +506,7 @@ iqs626_parse_events(struct iqs626_private *iqs626,
509
506
* Trackpad touch events are simply described under the
510
507
* trackpad child node.
511
508
*/
512
- ev_node = ch_node ;
509
+ ev_node = fwnode_handle_get ( ch_node ) ;
513
510
} else {
514
511
ev_name = iqs626_events [i ].name ;
515
512
ev_node = fwnode_get_named_child_node (ch_node , ev_name );
@@ -533,6 +530,7 @@ iqs626_parse_events(struct iqs626_private *iqs626,
533
530
dev_err (& client -> dev ,
534
531
"Invalid input type: %u\n" ,
535
532
val );
533
+ fwnode_handle_put (ev_node );
536
534
return - EINVAL ;
537
535
}
538
536
@@ -547,6 +545,7 @@ iqs626_parse_events(struct iqs626_private *iqs626,
547
545
dev_err (& client -> dev ,
548
546
"Invalid %s channel hysteresis: %u\n" ,
549
547
fwnode_get_name (ch_node ), val );
548
+ fwnode_handle_put (ev_node );
550
549
return - EINVAL ;
551
550
}
552
551
@@ -567,56 +566,31 @@ iqs626_parse_events(struct iqs626_private *iqs626,
567
566
dev_err (& client -> dev ,
568
567
"Invalid %s channel threshold: %u\n" ,
569
568
fwnode_get_name (ch_node ), val );
569
+ fwnode_handle_put (ev_node );
570
570
return - EINVAL ;
571
571
}
572
572
573
573
if (ch_id == IQS626_CH_HALL )
574
574
* thresh = val ;
575
575
else
576
576
* (thresh + iqs626_events [i ].th_offs ) = val ;
577
-
578
- continue ;
579
- }
580
-
581
- if (!fwnode_property_present (ev_node , "azoteq,thresh" ))
582
- continue ;
583
-
584
- error = fwnode_property_read_u32_array (ev_node , "azoteq,thresh" ,
585
- thresh_tp , num_ch );
586
- if (error ) {
587
- dev_err (& client -> dev ,
588
- "Failed to read %s channel thresholds: %d\n" ,
589
- fwnode_get_name (ch_node ), error );
590
- return error ;
591
577
}
592
578
593
- for (j = 0 ; j < num_ch ; j ++ ) {
594
- if (thresh_tp [j ] > IQS626_CHx_THRESH_MAX ) {
595
- dev_err (& client -> dev ,
596
- "Invalid %s channel threshold: %u\n" ,
597
- fwnode_get_name (ch_node ), thresh_tp [j ]);
598
- return - EINVAL ;
599
- }
600
-
601
- sys_reg -> tp_grp_reg .ch_reg_tp [j ].thresh = thresh_tp [j ];
602
- }
579
+ fwnode_handle_put (ev_node );
603
580
}
604
581
605
582
return 0 ;
606
583
}
607
584
608
585
static noinline_for_stack int
609
586
iqs626_parse_ati_target (struct iqs626_private * iqs626 ,
610
- const struct fwnode_handle * ch_node ,
611
- enum iqs626_ch_id ch_id )
587
+ struct fwnode_handle * ch_node , enum iqs626_ch_id ch_id )
612
588
{
613
589
struct iqs626_sys_reg * sys_reg = & iqs626 -> sys_reg ;
614
590
struct i2c_client * client = iqs626 -> client ;
615
- unsigned int ati_base [IQS626_NUM_CH_TP_3 ];
616
591
unsigned int val ;
617
592
u8 * ati_target ;
618
- int num_ch = iqs626_channels [ch_id ].num_ch ;
619
- int error , i ;
593
+ int i ;
620
594
621
595
switch (ch_id ) {
622
596
case IQS626_CH_ULP_0 :
@@ -683,40 +657,13 @@ iqs626_parse_ati_target(struct iqs626_private *iqs626,
683
657
684
658
* ati_target &= ~IQS626_CHx_ATI_BASE_MASK ;
685
659
* ati_target |= val ;
686
-
687
- return 0 ;
688
- }
689
-
690
- if (!fwnode_property_present (ch_node , "azoteq,ati-base" ))
691
- return 0 ;
692
-
693
- error = fwnode_property_read_u32_array (ch_node , "azoteq,ati-base" ,
694
- ati_base , num_ch );
695
- if (error ) {
696
- dev_err (& client -> dev ,
697
- "Failed to read %s channel ATI bases: %d\n" ,
698
- fwnode_get_name (ch_node ), error );
699
- return error ;
700
- }
701
-
702
- for (i = 0 ; i < num_ch ; i ++ ) {
703
- if (ati_base [i ] < IQS626_TPx_ATI_BASE_MIN ||
704
- ati_base [i ] > IQS626_TPx_ATI_BASE_MAX ) {
705
- dev_err (& client -> dev ,
706
- "Invalid %s channel ATI base: %u\n" ,
707
- fwnode_get_name (ch_node ), ati_base [i ]);
708
- return - EINVAL ;
709
- }
710
-
711
- ati_base [i ] -= IQS626_TPx_ATI_BASE_MIN ;
712
- sys_reg -> tp_grp_reg .ch_reg_tp [i ].ati_base = ati_base [i ];
713
660
}
714
661
715
662
return 0 ;
716
663
}
717
664
718
665
static int iqs626_parse_pins (struct iqs626_private * iqs626 ,
719
- const struct fwnode_handle * ch_node ,
666
+ struct fwnode_handle * ch_node ,
720
667
const char * propname , u8 * enable )
721
668
{
722
669
struct i2c_client * client = iqs626 -> client ;
@@ -764,13 +711,14 @@ static int iqs626_parse_pins(struct iqs626_private *iqs626,
764
711
}
765
712
766
713
static int iqs626_parse_trackpad (struct iqs626_private * iqs626 ,
767
- const struct fwnode_handle * ch_node )
714
+ struct fwnode_handle * ch_node ,
715
+ enum iqs626_ch_id ch_id )
768
716
{
769
717
struct iqs626_sys_reg * sys_reg = & iqs626 -> sys_reg ;
770
718
struct i2c_client * client = iqs626 -> client ;
771
719
u8 * hyst = & sys_reg -> tp_grp_reg .hyst ;
720
+ int error , count , i ;
772
721
unsigned int val ;
773
- int error , count ;
774
722
775
723
if (!fwnode_property_read_u32 (ch_node , "azoteq,lta-update" , & val )) {
776
724
if (val > IQS626_MISC_A_TPx_LTA_UPDATE_MAX ) {
@@ -823,6 +771,48 @@ static int iqs626_parse_trackpad(struct iqs626_private *iqs626,
823
771
* hyst |= (val << IQS626_FILT_STR_LP_TPx_SHIFT );
824
772
}
825
773
774
+ for (i = 0 ; i < iqs626_channels [ch_id ].num_ch ; i ++ ) {
775
+ u8 * ati_base = & sys_reg -> tp_grp_reg .ch_reg_tp [i ].ati_base ;
776
+ u8 * thresh = & sys_reg -> tp_grp_reg .ch_reg_tp [i ].thresh ;
777
+ struct fwnode_handle * tc_node ;
778
+ char tc_name [10 ];
779
+
780
+ snprintf (tc_name , sizeof (tc_name ), "channel-%d" , i );
781
+
782
+ tc_node = fwnode_get_named_child_node (ch_node , tc_name );
783
+ if (!tc_node )
784
+ continue ;
785
+
786
+ if (!fwnode_property_read_u32 (tc_node , "azoteq,ati-base" ,
787
+ & val )) {
788
+ if (val < IQS626_TPx_ATI_BASE_MIN ||
789
+ val > IQS626_TPx_ATI_BASE_MAX ) {
790
+ dev_err (& client -> dev ,
791
+ "Invalid %s %s ATI base: %u\n" ,
792
+ fwnode_get_name (ch_node ), tc_name , val );
793
+ fwnode_handle_put (tc_node );
794
+ return - EINVAL ;
795
+ }
796
+
797
+ * ati_base = val - IQS626_TPx_ATI_BASE_MIN ;
798
+ }
799
+
800
+ if (!fwnode_property_read_u32 (tc_node , "azoteq,thresh" ,
801
+ & val )) {
802
+ if (val > IQS626_CHx_THRESH_MAX ) {
803
+ dev_err (& client -> dev ,
804
+ "Invalid %s %s threshold: %u\n" ,
805
+ fwnode_get_name (ch_node ), tc_name , val );
806
+ fwnode_handle_put (tc_node );
807
+ return - EINVAL ;
808
+ }
809
+
810
+ * thresh = val ;
811
+ }
812
+
813
+ fwnode_handle_put (tc_node );
814
+ }
815
+
826
816
if (!fwnode_property_present (ch_node , "linux,keycodes" ))
827
817
return 0 ;
828
818
@@ -889,8 +879,7 @@ static int iqs626_parse_trackpad(struct iqs626_private *iqs626,
889
879
890
880
static noinline_for_stack int
891
881
iqs626_parse_channel (struct iqs626_private * iqs626 ,
892
- const struct fwnode_handle * ch_node ,
893
- enum iqs626_ch_id ch_id )
882
+ struct fwnode_handle * ch_node , enum iqs626_ch_id ch_id )
894
883
{
895
884
struct iqs626_sys_reg * sys_reg = & iqs626 -> sys_reg ;
896
885
struct i2c_client * client = iqs626 -> client ;
@@ -924,6 +913,20 @@ iqs626_parse_channel(struct iqs626_private *iqs626,
924
913
return - EINVAL ;
925
914
}
926
915
916
+ error = iqs626_parse_ati_target (iqs626 , ch_node , ch_id );
917
+ if (error )
918
+ return error ;
919
+
920
+ error = iqs626_parse_events (iqs626 , ch_node , ch_id );
921
+ if (error )
922
+ return error ;
923
+
924
+ if (!fwnode_property_present (ch_node , "azoteq,ati-exclude" ))
925
+ sys_reg -> redo_ati |= iqs626_channels [ch_id ].active ;
926
+
927
+ if (!fwnode_property_present (ch_node , "azoteq,reseed-disable" ))
928
+ sys_reg -> reseed |= iqs626_channels [ch_id ].active ;
929
+
927
930
* engine |= IQS626_CHx_ENG_0_MEAS_CAP_SIZE ;
928
931
if (fwnode_property_present (ch_node , "azoteq,meas-cap-decrease" ))
929
932
* engine &= ~IQS626_CHx_ENG_0_MEAS_CAP_SIZE ;
@@ -1057,7 +1060,7 @@ iqs626_parse_channel(struct iqs626_private *iqs626,
1057
1060
* (engine + 1 ) |= IQS626_CHx_ENG_1_ATI_BAND_TIGHTEN ;
1058
1061
1059
1062
if (ch_id == IQS626_CH_TP_2 || ch_id == IQS626_CH_TP_3 )
1060
- return iqs626_parse_trackpad (iqs626 , ch_node );
1063
+ return iqs626_parse_trackpad (iqs626 , ch_node , ch_id );
1061
1064
1062
1065
if (ch_id == IQS626_CH_ULP_0 ) {
1063
1066
sys_reg -> ch_reg_ulp .hyst &= ~IQS626_ULP_PROJ_ENABLE ;
@@ -1378,23 +1381,10 @@ static int iqs626_parse_prop(struct iqs626_private *iqs626)
1378
1381
continue ;
1379
1382
1380
1383
error = iqs626_parse_channel (iqs626 , ch_node , i );
1384
+ fwnode_handle_put (ch_node );
1381
1385
if (error )
1382
1386
return error ;
1383
1387
1384
- error = iqs626_parse_ati_target (iqs626 , ch_node , i );
1385
- if (error )
1386
- return error ;
1387
-
1388
- error = iqs626_parse_events (iqs626 , ch_node , i );
1389
- if (error )
1390
- return error ;
1391
-
1392
- if (!fwnode_property_present (ch_node , "azoteq,ati-exclude" ))
1393
- sys_reg -> redo_ati |= iqs626_channels [i ].active ;
1394
-
1395
- if (!fwnode_property_present (ch_node , "azoteq,reseed-disable" ))
1396
- sys_reg -> reseed |= iqs626_channels [i ].active ;
1397
-
1398
1388
sys_reg -> active |= iqs626_channels [i ].active ;
1399
1389
}
1400
1390
0 commit comments