@@ -88,6 +88,7 @@ static int bnxt_re_hwrm_qcaps(struct bnxt_re_dev *rdev);
8888
8989static int bnxt_re_hwrm_qcfg (struct bnxt_re_dev * rdev , u32 * db_len ,
9090 u32 * offset );
91+ static void bnxt_re_setup_cc (struct bnxt_re_dev * rdev , bool enable );
9192static void bnxt_re_set_db_offset (struct bnxt_re_dev * rdev )
9293{
9394 struct bnxt_qplib_chip_ctx * cctx ;
@@ -1860,6 +1861,16 @@ static int bnxt_re_add_device(struct auxiliary_device *adev)
18601861 goto re_dev_uninit ;
18611862 }
18621863
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+
18631874 return 0 ;
18641875
18651876re_dev_uninit :
@@ -1947,34 +1958,40 @@ static int bnxt_re_netdev_event(struct notifier_block *notifier,
19471958
19481959#define BNXT_ADEV_NAME "bnxt_en"
19491960
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 )
19511963{
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-
19641964 if (rdev -> nb .notifier_call ) {
19651965 unregister_netdevice_notifier (& rdev -> nb );
19661966 rdev -> nb .notifier_call = NULL ;
19671967 } else {
19681968 /* If notifier is null, we should have already done a
19691969 * clean up before coming here.
19701970 */
1971- goto skip_remove ;
1971+ return ;
19721972 }
19731973 bnxt_re_setup_cc (rdev , false);
19741974 ib_unregister_device (& rdev -> ibdev );
19751975 bnxt_re_dev_uninit (rdev );
19761976 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 );
19781995 kfree (en_info );
19791996 mutex_unlock (& bnxt_re_mutex );
19801997}
@@ -1986,7 +2003,6 @@ static int bnxt_re_probe(struct auxiliary_device *adev,
19862003 container_of (adev , struct bnxt_aux_priv , aux_dev );
19872004 struct bnxt_re_en_dev_info * en_info ;
19882005 struct bnxt_en_dev * en_dev ;
1989- struct bnxt_re_dev * rdev ;
19902006 int rc ;
19912007
19922008 en_dev = aux_priv -> edev ;
@@ -2002,23 +2018,8 @@ static int bnxt_re_probe(struct auxiliary_device *adev,
20022018 auxiliary_set_drvdata (adev , en_info );
20032019
20042020 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 )
20182022 goto err ;
2019- }
2020-
2021- bnxt_re_setup_cc (rdev , true);
20222023 mutex_unlock (& bnxt_re_mutex );
20232024 return 0 ;
20242025
0 commit comments