@@ -1019,8 +1019,7 @@ static int flashnode_match_index(struct device *dev, void *data)
1019
1019
/**
1020
1020
* iscsi_get_flashnode_by_index -finds flashnode session entry by index
1021
1021
* @shost: pointer to host data
1022
- * @data: pointer to data containing value to use for comparison
1023
- * @fn: function pointer that does actual comparison
1022
+ * @idx: index to match
1024
1023
*
1025
1024
* Finds the flashnode session object for the passed index
1026
1025
*
@@ -1029,13 +1028,13 @@ static int flashnode_match_index(struct device *dev, void *data)
1029
1028
* %NULL on failure
1030
1029
*/
1031
1030
static struct iscsi_bus_flash_session *
1032
- iscsi_get_flashnode_by_index (struct Scsi_Host * shost , void * data ,
1033
- int (* fn )(struct device * dev , void * data ))
1031
+ iscsi_get_flashnode_by_index (struct Scsi_Host * shost , uint32_t idx )
1034
1032
{
1035
1033
struct iscsi_bus_flash_session * fnode_sess = NULL ;
1036
1034
struct device * dev ;
1037
1035
1038
- dev = device_find_child (& shost -> shost_gendev , data , fn );
1036
+ dev = device_find_child (& shost -> shost_gendev , & idx ,
1037
+ flashnode_match_index );
1039
1038
if (dev )
1040
1039
fnode_sess = iscsi_dev_to_flash_session (dev );
1041
1040
@@ -1059,18 +1058,13 @@ struct device *
1059
1058
iscsi_find_flashnode_sess (struct Scsi_Host * shost , void * data ,
1060
1059
int (* fn )(struct device * dev , void * data ))
1061
1060
{
1062
- struct device * dev ;
1063
-
1064
- dev = device_find_child (& shost -> shost_gendev , data , fn );
1065
- return dev ;
1061
+ return device_find_child (& shost -> shost_gendev , data , fn );
1066
1062
}
1067
1063
EXPORT_SYMBOL_GPL (iscsi_find_flashnode_sess );
1068
1064
1069
1065
/**
1070
1066
* iscsi_find_flashnode_conn - finds flashnode connection entry
1071
1067
* @fnode_sess: pointer to parent flashnode session entry
1072
- * @data: pointer to data containing value to use for comparison
1073
- * @fn: function pointer that does actual comparison
1074
1068
*
1075
1069
* Finds the flashnode connection object comparing the data passed using logic
1076
1070
* defined in passed function pointer
@@ -1080,14 +1074,10 @@ EXPORT_SYMBOL_GPL(iscsi_find_flashnode_sess);
1080
1074
* %NULL on failure
1081
1075
*/
1082
1076
struct device *
1083
- iscsi_find_flashnode_conn (struct iscsi_bus_flash_session * fnode_sess ,
1084
- void * data ,
1085
- int (* fn )(struct device * dev , void * data ))
1077
+ iscsi_find_flashnode_conn (struct iscsi_bus_flash_session * fnode_sess )
1086
1078
{
1087
- struct device * dev ;
1088
-
1089
- dev = device_find_child (& fnode_sess -> dev , data , fn );
1090
- return dev ;
1079
+ return device_find_child (& fnode_sess -> dev , NULL ,
1080
+ iscsi_is_flashnode_conn_dev );
1091
1081
}
1092
1082
EXPORT_SYMBOL_GPL (iscsi_find_flashnode_conn );
1093
1083
@@ -2808,7 +2798,7 @@ static int iscsi_set_flashnode_param(struct iscsi_transport *transport,
2808
2798
struct iscsi_bus_flash_session * fnode_sess ;
2809
2799
struct iscsi_bus_flash_conn * fnode_conn ;
2810
2800
struct device * dev ;
2811
- uint32_t * idx ;
2801
+ uint32_t idx ;
2812
2802
int err = 0 ;
2813
2803
2814
2804
if (!transport -> set_flashnode_param ) {
@@ -2824,25 +2814,27 @@ static int iscsi_set_flashnode_param(struct iscsi_transport *transport,
2824
2814
goto put_host ;
2825
2815
}
2826
2816
2827
- idx = & ev -> u .set_flashnode .flashnode_idx ;
2828
- fnode_sess = iscsi_get_flashnode_by_index (shost , idx ,
2829
- flashnode_match_index );
2817
+ idx = ev -> u .set_flashnode .flashnode_idx ;
2818
+ fnode_sess = iscsi_get_flashnode_by_index (shost , idx );
2830
2819
if (!fnode_sess ) {
2831
2820
pr_err ("%s could not find flashnode %u for host no %u\n" ,
2832
- __func__ , * idx , ev -> u .set_flashnode .host_no );
2821
+ __func__ , idx , ev -> u .set_flashnode .host_no );
2833
2822
err = - ENODEV ;
2834
2823
goto put_host ;
2835
2824
}
2836
2825
2837
- dev = iscsi_find_flashnode_conn (fnode_sess , NULL ,
2838
- iscsi_is_flashnode_conn_dev );
2826
+ dev = iscsi_find_flashnode_conn (fnode_sess );
2839
2827
if (!dev ) {
2840
2828
err = - ENODEV ;
2841
- goto put_host ;
2829
+ goto put_sess ;
2842
2830
}
2843
2831
2844
2832
fnode_conn = iscsi_dev_to_flash_conn (dev );
2845
2833
err = transport -> set_flashnode_param (fnode_sess , fnode_conn , data , len );
2834
+ put_device (dev );
2835
+
2836
+ put_sess :
2837
+ put_device (& fnode_sess -> dev );
2846
2838
2847
2839
put_host :
2848
2840
scsi_host_put (shost );
@@ -2891,7 +2883,7 @@ static int iscsi_del_flashnode(struct iscsi_transport *transport,
2891
2883
{
2892
2884
struct Scsi_Host * shost ;
2893
2885
struct iscsi_bus_flash_session * fnode_sess ;
2894
- uint32_t * idx ;
2886
+ uint32_t idx ;
2895
2887
int err = 0 ;
2896
2888
2897
2889
if (!transport -> del_flashnode ) {
@@ -2907,17 +2899,17 @@ static int iscsi_del_flashnode(struct iscsi_transport *transport,
2907
2899
goto put_host ;
2908
2900
}
2909
2901
2910
- idx = & ev -> u .del_flashnode .flashnode_idx ;
2911
- fnode_sess = iscsi_get_flashnode_by_index (shost , idx ,
2912
- flashnode_match_index );
2902
+ idx = ev -> u .del_flashnode .flashnode_idx ;
2903
+ fnode_sess = iscsi_get_flashnode_by_index (shost , idx );
2913
2904
if (!fnode_sess ) {
2914
2905
pr_err ("%s could not find flashnode %u for host no %u\n" ,
2915
- __func__ , * idx , ev -> u .del_flashnode .host_no );
2906
+ __func__ , idx , ev -> u .del_flashnode .host_no );
2916
2907
err = - ENODEV ;
2917
2908
goto put_host ;
2918
2909
}
2919
2910
2920
2911
err = transport -> del_flashnode (fnode_sess );
2912
+ put_device (& fnode_sess -> dev );
2921
2913
2922
2914
put_host :
2923
2915
scsi_host_put (shost );
@@ -2933,7 +2925,7 @@ static int iscsi_login_flashnode(struct iscsi_transport *transport,
2933
2925
struct iscsi_bus_flash_session * fnode_sess ;
2934
2926
struct iscsi_bus_flash_conn * fnode_conn ;
2935
2927
struct device * dev ;
2936
- uint32_t * idx ;
2928
+ uint32_t idx ;
2937
2929
int err = 0 ;
2938
2930
2939
2931
if (!transport -> login_flashnode ) {
@@ -2949,25 +2941,27 @@ static int iscsi_login_flashnode(struct iscsi_transport *transport,
2949
2941
goto put_host ;
2950
2942
}
2951
2943
2952
- idx = & ev -> u .login_flashnode .flashnode_idx ;
2953
- fnode_sess = iscsi_get_flashnode_by_index (shost , idx ,
2954
- flashnode_match_index );
2944
+ idx = ev -> u .login_flashnode .flashnode_idx ;
2945
+ fnode_sess = iscsi_get_flashnode_by_index (shost , idx );
2955
2946
if (!fnode_sess ) {
2956
2947
pr_err ("%s could not find flashnode %u for host no %u\n" ,
2957
- __func__ , * idx , ev -> u .login_flashnode .host_no );
2948
+ __func__ , idx , ev -> u .login_flashnode .host_no );
2958
2949
err = - ENODEV ;
2959
2950
goto put_host ;
2960
2951
}
2961
2952
2962
- dev = iscsi_find_flashnode_conn (fnode_sess , NULL ,
2963
- iscsi_is_flashnode_conn_dev );
2953
+ dev = iscsi_find_flashnode_conn (fnode_sess );
2964
2954
if (!dev ) {
2965
2955
err = - ENODEV ;
2966
- goto put_host ;
2956
+ goto put_sess ;
2967
2957
}
2968
2958
2969
2959
fnode_conn = iscsi_dev_to_flash_conn (dev );
2970
2960
err = transport -> login_flashnode (fnode_sess , fnode_conn );
2961
+ put_device (dev );
2962
+
2963
+ put_sess :
2964
+ put_device (& fnode_sess -> dev );
2971
2965
2972
2966
put_host :
2973
2967
scsi_host_put (shost );
@@ -2983,7 +2977,7 @@ static int iscsi_logout_flashnode(struct iscsi_transport *transport,
2983
2977
struct iscsi_bus_flash_session * fnode_sess ;
2984
2978
struct iscsi_bus_flash_conn * fnode_conn ;
2985
2979
struct device * dev ;
2986
- uint32_t * idx ;
2980
+ uint32_t idx ;
2987
2981
int err = 0 ;
2988
2982
2989
2983
if (!transport -> logout_flashnode ) {
@@ -2999,26 +2993,28 @@ static int iscsi_logout_flashnode(struct iscsi_transport *transport,
2999
2993
goto put_host ;
3000
2994
}
3001
2995
3002
- idx = & ev -> u .logout_flashnode .flashnode_idx ;
3003
- fnode_sess = iscsi_get_flashnode_by_index (shost , idx ,
3004
- flashnode_match_index );
2996
+ idx = ev -> u .logout_flashnode .flashnode_idx ;
2997
+ fnode_sess = iscsi_get_flashnode_by_index (shost , idx );
3005
2998
if (!fnode_sess ) {
3006
2999
pr_err ("%s could not find flashnode %u for host no %u\n" ,
3007
- __func__ , * idx , ev -> u .logout_flashnode .host_no );
3000
+ __func__ , idx , ev -> u .logout_flashnode .host_no );
3008
3001
err = - ENODEV ;
3009
3002
goto put_host ;
3010
3003
}
3011
3004
3012
- dev = iscsi_find_flashnode_conn (fnode_sess , NULL ,
3013
- iscsi_is_flashnode_conn_dev );
3005
+ dev = iscsi_find_flashnode_conn (fnode_sess );
3014
3006
if (!dev ) {
3015
3007
err = - ENODEV ;
3016
- goto put_host ;
3008
+ goto put_sess ;
3017
3009
}
3018
3010
3019
3011
fnode_conn = iscsi_dev_to_flash_conn (dev );
3020
3012
3021
3013
err = transport -> logout_flashnode (fnode_sess , fnode_conn );
3014
+ put_device (dev );
3015
+
3016
+ put_sess :
3017
+ put_device (& fnode_sess -> dev );
3022
3018
3023
3019
put_host :
3024
3020
scsi_host_put (shost );
0 commit comments