@@ -88,6 +88,7 @@ static int bnxt_re_hwrm_qcaps(struct bnxt_re_dev *rdev);
88
88
89
89
static int bnxt_re_hwrm_qcfg (struct bnxt_re_dev * rdev , u32 * db_len ,
90
90
u32 * offset );
91
+ static void bnxt_re_setup_cc (struct bnxt_re_dev * rdev , bool enable );
91
92
static void bnxt_re_set_db_offset (struct bnxt_re_dev * rdev )
92
93
{
93
94
struct bnxt_qplib_chip_ctx * cctx ;
@@ -1860,6 +1861,16 @@ static int bnxt_re_add_device(struct auxiliary_device *adev)
1860
1861
goto re_dev_uninit ;
1861
1862
}
1862
1863
1864
+ rdev -> nb .notifier_call = bnxt_re_netdev_event ;
1865
+ rc = register_netdevice_notifier (& rdev -> nb );
1866
+ if (rc ) {
1867
+ rdev -> nb .notifier_call = NULL ;
1868
+ pr_err ("%s: Cannot register to netdevice_notifier" ,
1869
+ ROCE_DRV_MODULE_NAME );
1870
+ return rc ;
1871
+ }
1872
+ bnxt_re_setup_cc (rdev , true);
1873
+
1863
1874
return 0 ;
1864
1875
1865
1876
re_dev_uninit :
@@ -1947,34 +1958,40 @@ static int bnxt_re_netdev_event(struct notifier_block *notifier,
1947
1958
1948
1959
#define BNXT_ADEV_NAME "bnxt_en"
1949
1960
1950
- static void bnxt_re_remove (struct auxiliary_device * adev )
1961
+ static void bnxt_re_remove_device (struct bnxt_re_dev * rdev ,
1962
+ struct auxiliary_device * aux_dev )
1951
1963
{
1952
- struct bnxt_re_en_dev_info * en_info = auxiliary_get_drvdata (adev );
1953
- struct bnxt_re_dev * rdev ;
1954
-
1955
- mutex_lock (& bnxt_re_mutex );
1956
- if (!en_info ) {
1957
- mutex_unlock (& bnxt_re_mutex );
1958
- return ;
1959
- }
1960
- rdev = en_info -> rdev ;
1961
- if (!rdev )
1962
- goto skip_remove ;
1963
-
1964
1964
if (rdev -> nb .notifier_call ) {
1965
1965
unregister_netdevice_notifier (& rdev -> nb );
1966
1966
rdev -> nb .notifier_call = NULL ;
1967
1967
} else {
1968
1968
/* If notifier is null, we should have already done a
1969
1969
* clean up before coming here.
1970
1970
*/
1971
- goto skip_remove ;
1971
+ return ;
1972
1972
}
1973
1973
bnxt_re_setup_cc (rdev , false);
1974
1974
ib_unregister_device (& rdev -> ibdev );
1975
1975
bnxt_re_dev_uninit (rdev );
1976
1976
ib_dealloc_device (& rdev -> ibdev );
1977
- skip_remove :
1977
+ }
1978
+
1979
+ static void bnxt_re_remove (struct auxiliary_device * adev )
1980
+ {
1981
+ struct bnxt_re_en_dev_info * en_info = auxiliary_get_drvdata (adev );
1982
+ struct bnxt_en_dev * en_dev ;
1983
+ struct bnxt_re_dev * rdev ;
1984
+
1985
+ mutex_lock (& bnxt_re_mutex );
1986
+ if (!en_info ) {
1987
+ mutex_unlock (& bnxt_re_mutex );
1988
+ return ;
1989
+ }
1990
+ en_dev = en_info -> en_dev ;
1991
+ rdev = en_info -> rdev ;
1992
+
1993
+ if (rdev )
1994
+ bnxt_re_remove_device (rdev , adev );
1978
1995
kfree (en_info );
1979
1996
mutex_unlock (& bnxt_re_mutex );
1980
1997
}
@@ -1986,7 +2003,6 @@ static int bnxt_re_probe(struct auxiliary_device *adev,
1986
2003
container_of (adev , struct bnxt_aux_priv , aux_dev );
1987
2004
struct bnxt_re_en_dev_info * en_info ;
1988
2005
struct bnxt_en_dev * en_dev ;
1989
- struct bnxt_re_dev * rdev ;
1990
2006
int rc ;
1991
2007
1992
2008
en_dev = aux_priv -> edev ;
@@ -2002,23 +2018,8 @@ static int bnxt_re_probe(struct auxiliary_device *adev,
2002
2018
auxiliary_set_drvdata (adev , en_info );
2003
2019
2004
2020
rc = bnxt_re_add_device (adev );
2005
- if (rc ) {
2006
- mutex_unlock (& bnxt_re_mutex );
2007
- return rc ;
2008
- }
2009
-
2010
- rdev = en_info -> rdev ;
2011
-
2012
- rdev -> nb .notifier_call = bnxt_re_netdev_event ;
2013
- rc = register_netdevice_notifier (& rdev -> nb );
2014
- if (rc ) {
2015
- rdev -> nb .notifier_call = NULL ;
2016
- pr_err ("%s: Cannot register to netdevice_notifier" ,
2017
- ROCE_DRV_MODULE_NAME );
2021
+ if (rc )
2018
2022
goto err ;
2019
- }
2020
-
2021
- bnxt_re_setup_cc (rdev , true);
2022
2023
mutex_unlock (& bnxt_re_mutex );
2023
2024
return 0 ;
2024
2025
0 commit comments