@@ -697,19 +697,28 @@ static int gfar_parse_group(struct device_node *np,
697
697
grp -> priv = priv ;
698
698
spin_lock_init (& grp -> grplock );
699
699
if (priv -> mode == MQ_MG_MODE ) {
700
- u32 * rxq_mask , * txq_mask ;
701
- rxq_mask = (u32 * )of_get_property (np , "fsl,rx-bit-map" , NULL );
702
- txq_mask = (u32 * )of_get_property (np , "fsl,tx-bit-map" , NULL );
700
+ u32 rxq_mask , txq_mask ;
701
+ int ret ;
702
+
703
+ grp -> rx_bit_map = (DEFAULT_MAPPING >> priv -> num_grps );
704
+ grp -> tx_bit_map = (DEFAULT_MAPPING >> priv -> num_grps );
705
+
706
+ ret = of_property_read_u32 (np , "fsl,rx-bit-map" , & rxq_mask );
707
+ if (!ret ) {
708
+ grp -> rx_bit_map = rxq_mask ?
709
+ rxq_mask : (DEFAULT_MAPPING >> priv -> num_grps );
710
+ }
711
+
712
+ ret = of_property_read_u32 (np , "fsl,tx-bit-map" , & txq_mask );
713
+ if (!ret ) {
714
+ grp -> tx_bit_map = txq_mask ?
715
+ txq_mask : (DEFAULT_MAPPING >> priv -> num_grps );
716
+ }
703
717
704
718
if (priv -> poll_mode == GFAR_SQ_POLLING ) {
705
719
/* One Q per interrupt group: Q0 to G0, Q1 to G1 */
706
720
grp -> rx_bit_map = (DEFAULT_MAPPING >> priv -> num_grps );
707
721
grp -> tx_bit_map = (DEFAULT_MAPPING >> priv -> num_grps );
708
- } else { /* GFAR_MQ_POLLING */
709
- grp -> rx_bit_map = rxq_mask ?
710
- * rxq_mask : (DEFAULT_MAPPING >> priv -> num_grps );
711
- grp -> tx_bit_map = txq_mask ?
712
- * txq_mask : (DEFAULT_MAPPING >> priv -> num_grps );
713
722
}
714
723
} else {
715
724
grp -> rx_bit_map = 0xFF ;
@@ -770,11 +779,10 @@ static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev)
770
779
struct gfar_private * priv = NULL ;
771
780
struct device_node * np = ofdev -> dev .of_node ;
772
781
struct device_node * child = NULL ;
773
- const u32 * stash ;
774
- const u32 * stash_len ;
775
- const u32 * stash_idx ;
782
+ struct property * stash ;
783
+ u32 stash_len = 0 ;
784
+ u32 stash_idx = 0 ;
776
785
unsigned int num_tx_qs , num_rx_qs ;
777
- u32 * tx_queues , * rx_queues ;
778
786
unsigned short mode , poll_mode ;
779
787
780
788
if (!np )
@@ -788,10 +796,6 @@ static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev)
788
796
poll_mode = GFAR_SQ_POLLING ;
789
797
}
790
798
791
- /* parse the num of HW tx and rx queues */
792
- tx_queues = (u32 * )of_get_property (np , "fsl,num_tx_queues" , NULL );
793
- rx_queues = (u32 * )of_get_property (np , "fsl,num_rx_queues" , NULL );
794
-
795
799
if (mode == SQ_SG_MODE ) {
796
800
num_tx_qs = 1 ;
797
801
num_rx_qs = 1 ;
@@ -810,8 +814,17 @@ static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev)
810
814
num_tx_qs = num_grps ; /* one txq per int group */
811
815
num_rx_qs = num_grps ; /* one rxq per int group */
812
816
} else { /* GFAR_MQ_POLLING */
813
- num_tx_qs = tx_queues ? * tx_queues : 1 ;
814
- num_rx_qs = rx_queues ? * rx_queues : 1 ;
817
+ u32 tx_queues , rx_queues ;
818
+ int ret ;
819
+
820
+ /* parse the num of HW tx and rx queues */
821
+ ret = of_property_read_u32 (np , "fsl,num_tx_queues" ,
822
+ & tx_queues );
823
+ num_tx_qs = ret ? 1 : tx_queues ;
824
+
825
+ ret = of_property_read_u32 (np , "fsl,num_rx_queues" ,
826
+ & rx_queues );
827
+ num_rx_qs = ret ? 1 : rx_queues ;
815
828
}
816
829
}
817
830
@@ -852,13 +865,17 @@ static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev)
852
865
if (err )
853
866
goto rx_alloc_failed ;
854
867
868
+ err = of_property_read_string (np , "model" , & model );
869
+ if (err ) {
870
+ pr_err ("Device model property missing, aborting\n" );
871
+ goto rx_alloc_failed ;
872
+ }
873
+
855
874
/* Init Rx queue filer rule set linked list */
856
875
INIT_LIST_HEAD (& priv -> rx_list .list );
857
876
priv -> rx_list .count = 0 ;
858
877
mutex_init (& priv -> rx_queue_access );
859
878
860
- model = of_get_property (np , "model" , NULL );
861
-
862
879
for (i = 0 ; i < MAXGROUPS ; i ++ )
863
880
priv -> gfargrp [i ].regs = NULL ;
864
881
@@ -878,22 +895,22 @@ static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev)
878
895
goto err_grp_init ;
879
896
}
880
897
881
- stash = of_get_property (np , "bd-stash" , NULL );
898
+ stash = of_find_property (np , "bd-stash" , NULL );
882
899
883
900
if (stash ) {
884
901
priv -> device_flags |= FSL_GIANFAR_DEV_HAS_BD_STASHING ;
885
902
priv -> bd_stash_en = 1 ;
886
903
}
887
904
888
- stash_len = of_get_property (np , "rx-stash-len" , NULL );
905
+ err = of_property_read_u32 (np , "rx-stash-len" , & stash_len );
889
906
890
- if (stash_len )
891
- priv -> rx_stash_size = * stash_len ;
907
+ if (err == 0 )
908
+ priv -> rx_stash_size = stash_len ;
892
909
893
- stash_idx = of_get_property (np , "rx-stash-idx" , NULL );
910
+ err = of_property_read_u32 (np , "rx-stash-idx" , & stash_idx );
894
911
895
- if (stash_idx )
896
- priv -> rx_stash_index = * stash_idx ;
912
+ if (err == 0 )
913
+ priv -> rx_stash_index = stash_idx ;
897
914
898
915
if (stash_len || stash_idx )
899
916
priv -> device_flags |= FSL_GIANFAR_DEV_HAS_BUF_STASHING ;
@@ -920,15 +937,15 @@ static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev)
920
937
FSL_GIANFAR_DEV_HAS_EXTENDED_HASH |
921
938
FSL_GIANFAR_DEV_HAS_TIMER ;
922
939
923
- ctype = of_get_property (np , "phy-connection-type" , NULL );
940
+ err = of_property_read_string (np , "phy-connection-type" , & ctype );
924
941
925
942
/* We only care about rgmii-id. The rest are autodetected */
926
- if (ctype && !strcmp (ctype , "rgmii-id" ))
943
+ if (err == 0 && !strcmp (ctype , "rgmii-id" ))
927
944
priv -> interface = PHY_INTERFACE_MODE_RGMII_ID ;
928
945
else
929
946
priv -> interface = PHY_INTERFACE_MODE_MII ;
930
947
931
- if (of_get_property (np , "fsl,magic-packet" , NULL ))
948
+ if (of_find_property (np , "fsl,magic-packet" , NULL ))
932
949
priv -> device_flags |= FSL_GIANFAR_DEV_HAS_MAGIC_PACKET ;
933
950
934
951
priv -> phy_node = of_parse_phandle (np , "phy-handle" , 0 );
0 commit comments