Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Input: iqs626a - drop unused device node references

Each call to device/fwnode_get_named_child_node() must be matched
with a call to fwnode_handle_put() once the corresponding node is
no longer in use. This ensures a reference count remains balanced
in the case of dynamic device tree support.

Currently, the driver never calls fwnode_handle_put(); this patch
adds the missing calls. Because fwnode_handle_put() does not take
a const *fwnode_handle, the const qualifier is removed across all
corresponding *fwnode_handle instances.

As part of this change, trackpad channel touch thresholds and ATI
base values are now specified under single trackpad channel child
nodes. This enhancement moves both properties to scalar values as
opposed to arrays, making their types consistent across bindings.

Fixes: f1d2809de97a ("Input: Add support for Azoteq IQS626A")
Signed-off-by: Jeff LaBundy <jeff@labundy.com>
Link: https://lore.kernel.org/r/Y9RQVe/V1Hnw1oly@nixie71
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

authored by

Jeff LaBundy and committed by
Dmitry Torokhov
4d3d2694 d9496240

+73 -83
+73 -83
drivers/input/misc/iqs626a.c
··· 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: ··· 506 509 * Trackpad touch events are simply described under the 507 510 * trackpad child node. 508 511 */ 509 - ev_node = ch_node; 512 + ev_node = fwnode_handle_get(ch_node); 510 513 } else { 511 514 ev_name = iqs626_events[i].name; 512 515 ev_node = fwnode_get_named_child_node(ch_node, ev_name); ··· 530 533 dev_err(&client->dev, 531 534 "Invalid input type: %u\n", 532 535 val); 536 + fwnode_handle_put(ev_node); 533 537 return -EINVAL; 534 538 } 535 539 ··· 545 547 dev_err(&client->dev, 546 548 "Invalid %s channel hysteresis: %u\n", 547 549 fwnode_get_name(ch_node), val); 550 + fwnode_handle_put(ev_node); 548 551 return -EINVAL; 549 552 } 550 553 ··· 566 567 dev_err(&client->dev, 567 568 "Invalid %s channel threshold: %u\n", 568 569 fwnode_get_name(ch_node), val); 570 + fwnode_handle_put(ev_node); 569 571 return -EINVAL; 570 572 } 571 573 ··· 574 574 *thresh = val; 575 575 else 576 576 *(thresh + iqs626_events[i].th_offs) = val; 577 - 578 - continue; 579 577 } 580 578 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 - } 592 - 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; ··· 584 607 585 608 static noinline_for_stack int 586 609 iqs626_parse_ati_target(struct iqs626_private *iqs626, 587 - const struct fwnode_handle *ch_node, 588 - enum iqs626_ch_id ch_id) 610 + struct fwnode_handle *ch_node, enum iqs626_ch_id ch_id) 589 611 { 590 612 struct iqs626_sys_reg *sys_reg = &iqs626->sys_reg; 591 613 struct i2c_client *client = iqs626->client; 592 - unsigned int ati_base[IQS626_NUM_CH_TP_3]; 593 614 unsigned int val; 594 615 u8 *ati_target; 595 - int num_ch = iqs626_channels[ch_id].num_ch; 596 - int error, i; 616 + int i; 597 617 598 618 switch (ch_id) { 599 619 case IQS626_CH_ULP_0: ··· 657 683 658 684 *ati_target &= ~IQS626_CHx_ATI_BASE_MASK; 659 685 *ati_target |= val; 660 - 661 - return 0; 662 - } 663 - 664 - if (!fwnode_property_present(ch_node, "azoteq,ati-base")) 665 - return 0; 666 - 667 - error = fwnode_property_read_u32_array(ch_node, "azoteq,ati-base", 668 - ati_base, num_ch); 669 - if (error) { 670 - dev_err(&client->dev, 671 - "Failed to read %s channel ATI bases: %d\n", 672 - fwnode_get_name(ch_node), error); 673 - return error; 674 - } 675 - 676 - for (i = 0; i < num_ch; i++) { 677 - if (ati_base[i] < IQS626_TPx_ATI_BASE_MIN || 678 - ati_base[i] > IQS626_TPx_ATI_BASE_MAX) { 679 - dev_err(&client->dev, 680 - "Invalid %s channel ATI base: %u\n", 681 - fwnode_get_name(ch_node), ati_base[i]); 682 - return -EINVAL; 683 - } 684 - 685 - ati_base[i] -= IQS626_TPx_ATI_BASE_MIN; 686 - sys_reg->tp_grp_reg.ch_reg_tp[i].ati_base = ati_base[i]; 687 686 } 688 687 689 688 return 0; 690 689 } 691 690 692 691 static int iqs626_parse_pins(struct iqs626_private *iqs626, 693 - const struct fwnode_handle *ch_node, 692 + struct fwnode_handle *ch_node, 694 693 const char *propname, u8 *enable) 695 694 { 696 695 struct i2c_client *client = iqs626->client; ··· 711 764 } 712 765 713 766 static int iqs626_parse_trackpad(struct iqs626_private *iqs626, 714 - const struct fwnode_handle *ch_node) 767 + struct fwnode_handle *ch_node, 768 + enum iqs626_ch_id ch_id) 715 769 { 716 770 struct iqs626_sys_reg *sys_reg = &iqs626->sys_reg; 717 771 struct i2c_client *client = iqs626->client; 718 772 u8 *hyst = &sys_reg->tp_grp_reg.hyst; 773 + int error, count, i; 719 774 unsigned int val; 720 - int error, count; 721 775 722 776 if (!fwnode_property_read_u32(ch_node, "azoteq,lta-update", &val)) { 723 777 if (val > IQS626_MISC_A_TPx_LTA_UPDATE_MAX) { ··· 769 821 770 822 *hyst &= ~IQS626_FILT_STR_LP_TPx_MASK; 771 823 *hyst |= (val << IQS626_FILT_STR_LP_TPx_SHIFT); 824 + } 825 + 826 + for (i = 0; i < iqs626_channels[ch_id].num_ch; i++) { 827 + u8 *ati_base = &sys_reg->tp_grp_reg.ch_reg_tp[i].ati_base; 828 + u8 *thresh = &sys_reg->tp_grp_reg.ch_reg_tp[i].thresh; 829 + struct fwnode_handle *tc_node; 830 + char tc_name[10]; 831 + 832 + snprintf(tc_name, sizeof(tc_name), "channel-%d", i); 833 + 834 + tc_node = fwnode_get_named_child_node(ch_node, tc_name); 835 + if (!tc_node) 836 + continue; 837 + 838 + if (!fwnode_property_read_u32(tc_node, "azoteq,ati-base", 839 + &val)) { 840 + if (val < IQS626_TPx_ATI_BASE_MIN || 841 + val > IQS626_TPx_ATI_BASE_MAX) { 842 + dev_err(&client->dev, 843 + "Invalid %s %s ATI base: %u\n", 844 + fwnode_get_name(ch_node), tc_name, val); 845 + fwnode_handle_put(tc_node); 846 + return -EINVAL; 847 + } 848 + 849 + *ati_base = val - IQS626_TPx_ATI_BASE_MIN; 850 + } 851 + 852 + if (!fwnode_property_read_u32(tc_node, "azoteq,thresh", 853 + &val)) { 854 + if (val > IQS626_CHx_THRESH_MAX) { 855 + dev_err(&client->dev, 856 + "Invalid %s %s threshold: %u\n", 857 + fwnode_get_name(ch_node), tc_name, val); 858 + fwnode_handle_put(tc_node); 859 + return -EINVAL; 860 + } 861 + 862 + *thresh = val; 863 + } 864 + 865 + fwnode_handle_put(tc_node); 772 866 } 773 867 774 868 if (!fwnode_property_present(ch_node, "linux,keycodes")) ··· 879 889 880 890 static noinline_for_stack int 881 891 iqs626_parse_channel(struct iqs626_private *iqs626, 882 - const struct fwnode_handle *ch_node, 883 - enum iqs626_ch_id ch_id) 892 + struct fwnode_handle *ch_node, enum iqs626_ch_id ch_id) 884 893 { 885 894 struct iqs626_sys_reg *sys_reg = &iqs626->sys_reg; 886 895 struct i2c_client *client = iqs626->client; ··· 912 923 default: 913 924 return -EINVAL; 914 925 } 926 + 927 + error = iqs626_parse_ati_target(iqs626, ch_node, ch_id); 928 + if (error) 929 + return error; 930 + 931 + error = iqs626_parse_events(iqs626, ch_node, ch_id); 932 + if (error) 933 + return error; 934 + 935 + if (!fwnode_property_present(ch_node, "azoteq,ati-exclude")) 936 + sys_reg->redo_ati |= iqs626_channels[ch_id].active; 937 + 938 + if (!fwnode_property_present(ch_node, "azoteq,reseed-disable")) 939 + sys_reg->reseed |= iqs626_channels[ch_id].active; 915 940 916 941 *engine |= IQS626_CHx_ENG_0_MEAS_CAP_SIZE; 917 942 if (fwnode_property_present(ch_node, "azoteq,meas-cap-decrease")) ··· 1060 1057 *(engine + 1) |= IQS626_CHx_ENG_1_ATI_BAND_TIGHTEN; 1061 1058 1062 1059 if (ch_id == IQS626_CH_TP_2 || ch_id == IQS626_CH_TP_3) 1063 - return iqs626_parse_trackpad(iqs626, ch_node); 1060 + return iqs626_parse_trackpad(iqs626, ch_node, ch_id); 1064 1061 1065 1062 if (ch_id == IQS626_CH_ULP_0) { 1066 1063 sys_reg->ch_reg_ulp.hyst &= ~IQS626_ULP_PROJ_ENABLE; ··· 1381 1378 continue; 1382 1379 1383 1380 error = iqs626_parse_channel(iqs626, ch_node, i); 1381 + fwnode_handle_put(ch_node); 1384 1382 if (error) 1385 1383 return error; 1386 - 1387 - error = iqs626_parse_ati_target(iqs626, ch_node, i); 1388 - if (error) 1389 - return error; 1390 - 1391 - error = iqs626_parse_events(iqs626, ch_node, i); 1392 - if (error) 1393 - return error; 1394 - 1395 - if (!fwnode_property_present(ch_node, "azoteq,ati-exclude")) 1396 - sys_reg->redo_ati |= iqs626_channels[i].active; 1397 - 1398 - if (!fwnode_property_present(ch_node, "azoteq,reseed-disable")) 1399 - sys_reg->reseed |= iqs626_channels[i].active; 1400 1384 1401 1385 sys_reg->active |= iqs626_channels[i].active; 1402 1386 }