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

staging: axis-fifo: avoid parsing ignored device tree properties

Some properties were parsed from the device tree and then ignored by the
driver. Some would return an error if absent from the device tree, then
return an error if they were found because they are unsupported by the
driver.

Avoid parsing unused properties and clearly explain in the documentation
the ignored / unsupported properties.

Signed-off-by: Quentin Deslandes <quentin.deslandes@itdev.co.uk>
Link: https://lore.kernel.org/r/20191101214232.16960-2-quentin.deslandes@itdev.co.uk
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Quentin Deslandes and committed by
Greg Kroah-Hartman
ed6daf2b 3bce4750

+74 -191
+63 -184
drivers/staging/axis-fifo/axis-fifo.c
··· 701 701 return 0; 702 702 } 703 703 704 + static int axis_fifo_parse_dt(struct axis_fifo *fifo) 705 + { 706 + int ret; 707 + unsigned int value; 708 + 709 + ret = get_dts_property(fifo, "xlnx,axi-str-rxd-tdata-width", &value); 710 + if (ret) { 711 + dev_err(fifo->dt_device, "missing xlnx,axi-str-rxd-tdata-width property\n"); 712 + goto end; 713 + } else if (value != 32) { 714 + dev_err(fifo->dt_device, "xlnx,axi-str-rxd-tdata-width only supports 32 bits\n"); 715 + ret = -EIO; 716 + goto end; 717 + } 718 + 719 + ret = get_dts_property(fifo, "xlnx,axi-str-txd-tdata-width", &value); 720 + if (ret) { 721 + dev_err(fifo->dt_device, "missing xlnx,axi-str-txd-tdata-width property\n"); 722 + goto end; 723 + } else if (value != 32) { 724 + dev_err(fifo->dt_device, "xlnx,axi-str-txd-tdata-width only supports 32 bits\n"); 725 + ret = -EIO; 726 + goto end; 727 + } 728 + 729 + ret = get_dts_property(fifo, "xlnx,rx-fifo-depth", 730 + &fifo->rx_fifo_depth); 731 + if (ret) { 732 + dev_err(fifo->dt_device, "missing xlnx,rx-fifo-depth property\n"); 733 + ret = -EIO; 734 + goto end; 735 + } 736 + 737 + ret = get_dts_property(fifo, "xlnx,tx-fifo-depth", 738 + &fifo->tx_fifo_depth); 739 + if (ret) { 740 + dev_err(fifo->dt_device, "missing xlnx,tx-fifo-depth property\n"); 741 + ret = -EIO; 742 + goto end; 743 + } 744 + 745 + /* IP sets TDFV to fifo depth - 4 so we will do the same */ 746 + fifo->tx_fifo_depth -= 4; 747 + 748 + ret = get_dts_property(fifo, "xlnx,use-rx-data", &fifo->has_rx_fifo); 749 + if (ret) { 750 + dev_err(fifo->dt_device, "missing xlnx,use-rx-data property\n"); 751 + ret = -EIO; 752 + goto end; 753 + } 754 + 755 + ret = get_dts_property(fifo, "xlnx,use-tx-data", &fifo->has_tx_fifo); 756 + if (ret) { 757 + dev_err(fifo->dt_device, "missing xlnx,use-tx-data property\n"); 758 + ret = -EIO; 759 + goto end; 760 + } 761 + 762 + end: 763 + return ret; 764 + } 765 + 704 766 static int axis_fifo_probe(struct platform_device *pdev) 705 767 { 706 768 struct resource *r_irq; /* interrupt resources */ ··· 773 711 char device_name[32]; 774 712 775 713 int rc = 0; /* error return value */ 776 - 777 - /* IP properties from device tree */ 778 - unsigned int rxd_tdata_width; 779 - unsigned int txc_tdata_width; 780 - unsigned int txd_tdata_width; 781 - unsigned int tdest_width; 782 - unsigned int tid_width; 783 - unsigned int tuser_width; 784 - unsigned int data_interface_type; 785 - unsigned int has_tdest; 786 - unsigned int has_tid; 787 - unsigned int has_tkeep; 788 - unsigned int has_tstrb; 789 - unsigned int has_tuser; 790 - unsigned int rx_fifo_depth; 791 - unsigned int rx_programmable_empty_threshold; 792 - unsigned int rx_programmable_full_threshold; 793 - unsigned int axi_id_width; 794 - unsigned int axi4_data_width; 795 - unsigned int select_xpm; 796 - unsigned int tx_fifo_depth; 797 - unsigned int tx_programmable_empty_threshold; 798 - unsigned int tx_programmable_full_threshold; 799 - unsigned int use_rx_cut_through; 800 - unsigned int use_rx_data; 801 - unsigned int use_tx_control; 802 - unsigned int use_tx_cut_through; 803 - unsigned int use_tx_data; 804 714 805 715 /* ---------------------------- 806 716 * init wrapper device ··· 840 806 * ---------------------------- 841 807 */ 842 808 843 - /* retrieve device tree properties */ 844 - rc = get_dts_property(fifo, "xlnx,axi-str-rxd-tdata-width", 845 - &rxd_tdata_width); 809 + rc = axis_fifo_parse_dt(fifo); 846 810 if (rc) 847 811 goto err_unmap; 848 - rc = get_dts_property(fifo, "xlnx,axi-str-txc-tdata-width", 849 - &txc_tdata_width); 850 - if (rc) 851 - goto err_unmap; 852 - rc = get_dts_property(fifo, "xlnx,axi-str-txd-tdata-width", 853 - &txd_tdata_width); 854 - if (rc) 855 - goto err_unmap; 856 - rc = get_dts_property(fifo, "xlnx,axis-tdest-width", &tdest_width); 857 - if (rc) 858 - goto err_unmap; 859 - rc = get_dts_property(fifo, "xlnx,axis-tid-width", &tid_width); 860 - if (rc) 861 - goto err_unmap; 862 - rc = get_dts_property(fifo, "xlnx,axis-tuser-width", &tuser_width); 863 - if (rc) 864 - goto err_unmap; 865 - rc = get_dts_property(fifo, "xlnx,data-interface-type", 866 - &data_interface_type); 867 - if (rc) 868 - goto err_unmap; 869 - rc = get_dts_property(fifo, "xlnx,has-axis-tdest", &has_tdest); 870 - if (rc) 871 - goto err_unmap; 872 - rc = get_dts_property(fifo, "xlnx,has-axis-tid", &has_tid); 873 - if (rc) 874 - goto err_unmap; 875 - rc = get_dts_property(fifo, "xlnx,has-axis-tkeep", &has_tkeep); 876 - if (rc) 877 - goto err_unmap; 878 - rc = get_dts_property(fifo, "xlnx,has-axis-tstrb", &has_tstrb); 879 - if (rc) 880 - goto err_unmap; 881 - rc = get_dts_property(fifo, "xlnx,has-axis-tuser", &has_tuser); 882 - if (rc) 883 - goto err_unmap; 884 - rc = get_dts_property(fifo, "xlnx,rx-fifo-depth", &rx_fifo_depth); 885 - if (rc) 886 - goto err_unmap; 887 - rc = get_dts_property(fifo, "xlnx,rx-fifo-pe-threshold", 888 - &rx_programmable_empty_threshold); 889 - if (rc) 890 - goto err_unmap; 891 - rc = get_dts_property(fifo, "xlnx,rx-fifo-pf-threshold", 892 - &rx_programmable_full_threshold); 893 - if (rc) 894 - goto err_unmap; 895 - rc = get_dts_property(fifo, "xlnx,s-axi-id-width", &axi_id_width); 896 - if (rc) 897 - goto err_unmap; 898 - rc = get_dts_property(fifo, "xlnx,s-axi4-data-width", &axi4_data_width); 899 - if (rc) 900 - goto err_unmap; 901 - rc = get_dts_property(fifo, "xlnx,select-xpm", &select_xpm); 902 - if (rc) 903 - goto err_unmap; 904 - rc = get_dts_property(fifo, "xlnx,tx-fifo-depth", &tx_fifo_depth); 905 - if (rc) 906 - goto err_unmap; 907 - rc = get_dts_property(fifo, "xlnx,tx-fifo-pe-threshold", 908 - &tx_programmable_empty_threshold); 909 - if (rc) 910 - goto err_unmap; 911 - rc = get_dts_property(fifo, "xlnx,tx-fifo-pf-threshold", 912 - &tx_programmable_full_threshold); 913 - if (rc) 914 - goto err_unmap; 915 - rc = get_dts_property(fifo, "xlnx,use-rx-cut-through", 916 - &use_rx_cut_through); 917 - if (rc) 918 - goto err_unmap; 919 - rc = get_dts_property(fifo, "xlnx,use-rx-data", &use_rx_data); 920 - if (rc) 921 - goto err_unmap; 922 - rc = get_dts_property(fifo, "xlnx,use-tx-ctrl", &use_tx_control); 923 - if (rc) 924 - goto err_unmap; 925 - rc = get_dts_property(fifo, "xlnx,use-tx-cut-through", 926 - &use_tx_cut_through); 927 - if (rc) 928 - goto err_unmap; 929 - rc = get_dts_property(fifo, "xlnx,use-tx-data", &use_tx_data); 930 - if (rc) 931 - goto err_unmap; 932 - 933 - /* check validity of device tree properties */ 934 - if (rxd_tdata_width != 32) { 935 - dev_err(fifo->dt_device, 936 - "rxd_tdata_width width [%u] unsupported\n", 937 - rxd_tdata_width); 938 - rc = -EIO; 939 - goto err_unmap; 940 - } 941 - if (txd_tdata_width != 32) { 942 - dev_err(fifo->dt_device, 943 - "txd_tdata_width width [%u] unsupported\n", 944 - txd_tdata_width); 945 - rc = -EIO; 946 - goto err_unmap; 947 - } 948 - if (has_tdest) { 949 - dev_err(fifo->dt_device, "tdest not supported\n"); 950 - rc = -EIO; 951 - goto err_unmap; 952 - } 953 - if (has_tid) { 954 - dev_err(fifo->dt_device, "tid not supported\n"); 955 - rc = -EIO; 956 - goto err_unmap; 957 - } 958 - if (has_tkeep) { 959 - dev_err(fifo->dt_device, "tkeep not supported\n"); 960 - rc = -EIO; 961 - goto err_unmap; 962 - } 963 - if (has_tstrb) { 964 - dev_err(fifo->dt_device, "tstrb not supported\n"); 965 - rc = -EIO; 966 - goto err_unmap; 967 - } 968 - if (has_tuser) { 969 - dev_err(fifo->dt_device, "tuser not supported\n"); 970 - rc = -EIO; 971 - goto err_unmap; 972 - } 973 - if (use_rx_cut_through) { 974 - dev_err(fifo->dt_device, "rx cut-through not supported\n"); 975 - rc = -EIO; 976 - goto err_unmap; 977 - } 978 - if (use_tx_cut_through) { 979 - dev_err(fifo->dt_device, "tx cut-through not supported\n"); 980 - rc = -EIO; 981 - goto err_unmap; 982 - } 983 - if (use_tx_control) { 984 - dev_err(fifo->dt_device, "tx control not supported\n"); 985 - rc = -EIO; 986 - goto err_unmap; 987 - } 988 - 989 - /* TODO 990 - * these exist in the device tree but it's unclear what they do 991 - * - select-xpm 992 - * - data-interface-type 993 - */ 994 - 995 - /* set device wrapper properties based on IP config */ 996 - fifo->rx_fifo_depth = rx_fifo_depth; 997 - /* IP sets TDFV to fifo depth - 4 so we will do the same */ 998 - fifo->tx_fifo_depth = tx_fifo_depth - 4; 999 - fifo->has_rx_fifo = use_rx_data; 1000 - fifo->has_tx_fifo = use_tx_data; 1001 812 1002 813 reset_ip_core(fifo); 1003 814
+11 -7
drivers/staging/axis-fifo/axis-fifo.txt
··· 25 25 - xlnx,axi-str-txc-tdata-width: Should be <0x20> 26 26 - xlnx,axi-str-txd-protocol: Should be "XIL_AXI_STREAM_ETH_DATA" 27 27 - xlnx,axi-str-txd-tdata-width: Should be <0x20> 28 - - xlnx,axis-tdest-width: AXI-Stream TDEST width 29 - - xlnx,axis-tid-width: AXI-Stream TID width 30 - - xlnx,axis-tuser-width: AXI-Stream TUSER width 31 - - xlnx,data-interface-type: Should be <0x0> 28 + - xlnx,axis-tdest-width: AXI-Stream TDEST width (ignored by the driver) 29 + - xlnx,axis-tid-width: AXI-Stream TID width (ignored by the driver) 30 + - xlnx,axis-tuser-width: AXI-Stream TUSER width (ignored by the driver) 31 + - xlnx,data-interface-type: Should be <0x0> (ignored by the driver) 32 32 - xlnx,has-axis-tdest: Should be <0x0> (this feature isn't supported) 33 33 - xlnx,has-axis-tid: Should be <0x0> (this feature isn't supported) 34 34 - xlnx,has-axis-tkeep: Should be <0x0> (this feature isn't supported) ··· 36 36 - xlnx,has-axis-tuser: Should be <0x0> (this feature isn't supported) 37 37 - xlnx,rx-fifo-depth: Depth of RX FIFO in words 38 38 - xlnx,rx-fifo-pe-threshold: RX programmable empty interrupt threshold 39 + (ignored by the driver) 39 40 - xlnx,rx-fifo-pf-threshold: RX programmable full interrupt threshold 40 - - xlnx,s-axi-id-width: Should be <0x4> 41 - - xlnx,s-axi4-data-width: Should be <0x20> 42 - - xlnx,select-xpm: Should be <0x0> 41 + (ignored by the driver) 42 + - xlnx,s-axi-id-width: Should be <0x4> (ignored by the driver) 43 + - xlnx,s-axi4-data-width: Should be <0x20> (ignored by the driver) 44 + - xlnx,select-xpm: Should be <0x0> (ignored by the driver) 43 45 - xlnx,tx-fifo-depth: Depth of TX FIFO in words 44 46 - xlnx,tx-fifo-pe-threshold: TX programmable empty interrupt threshold 47 + (ignored by the driver) 45 48 - xlnx,tx-fifo-pf-threshold: TX programmable full interrupt threshold 49 + (ignored by the driver) 46 50 - xlnx,use-rx-cut-through: Should be <0x0> (this feature isn't supported) 47 51 - xlnx,use-rx-data: <0x1> if RX FIFO is enabled, <0x0> otherwise 48 52 - xlnx,use-tx-ctrl: Should be <0x0> (this feature isn't supported)