@@ -175,7 +175,7 @@ static int __ethtool_get_sset_count(struct net_device *dev, int sset)
175
175
if (sset == ETH_SS_FEATURES )
176
176
return ARRAY_SIZE (netdev_features_strings );
177
177
178
- if (ops && ops -> get_sset_count && ops -> get_strings )
178
+ if (ops -> get_sset_count && ops -> get_strings )
179
179
return ops -> get_sset_count (dev , sset );
180
180
else
181
181
return - EOPNOTSUPP ;
@@ -311,7 +311,7 @@ int __ethtool_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
311
311
{
312
312
ASSERT_RTNL ();
313
313
314
- if (!dev -> ethtool_ops || ! dev -> ethtool_ops -> get_settings )
314
+ if (!dev -> ethtool_ops -> get_settings )
315
315
return - EOPNOTSUPP ;
316
316
317
317
memset (cmd , 0 , sizeof (struct ethtool_cmd ));
@@ -355,7 +355,7 @@ static noinline_for_stack int ethtool_get_drvinfo(struct net_device *dev,
355
355
356
356
memset (& info , 0 , sizeof (info ));
357
357
info .cmd = ETHTOOL_GDRVINFO ;
358
- if (ops && ops -> get_drvinfo ) {
358
+ if (ops -> get_drvinfo ) {
359
359
ops -> get_drvinfo (dev , & info );
360
360
} else if (dev -> dev .parent && dev -> dev .parent -> driver ) {
361
361
strlcpy (info .bus_info , dev_name (dev -> dev .parent ),
@@ -370,7 +370,7 @@ static noinline_for_stack int ethtool_get_drvinfo(struct net_device *dev,
370
370
* this method of obtaining string set info is deprecated;
371
371
* Use ETHTOOL_GSSET_INFO instead.
372
372
*/
373
- if (ops && ops -> get_sset_count ) {
373
+ if (ops -> get_sset_count ) {
374
374
int rc ;
375
375
376
376
rc = ops -> get_sset_count (dev , ETH_SS_TEST );
@@ -383,9 +383,9 @@ static noinline_for_stack int ethtool_get_drvinfo(struct net_device *dev,
383
383
if (rc >= 0 )
384
384
info .n_priv_flags = rc ;
385
385
}
386
- if (ops && ops -> get_regs_len )
386
+ if (ops -> get_regs_len )
387
387
info .regdump_len = ops -> get_regs_len (dev );
388
- if (ops && ops -> get_eeprom_len )
388
+ if (ops -> get_eeprom_len )
389
389
info .eedump_len = ops -> get_eeprom_len (dev );
390
390
391
391
if (copy_to_user (useraddr , & info , sizeof (info )))
@@ -590,13 +590,14 @@ static noinline_for_stack int ethtool_set_rxfh_indir(struct net_device *dev,
590
590
struct ethtool_rxnfc rx_rings ;
591
591
u32 user_size , dev_size , i ;
592
592
u32 * indir ;
593
+ const struct ethtool_ops * ops = dev -> ethtool_ops ;
593
594
int ret ;
594
595
595
- if (!dev -> ethtool_ops -> get_rxfh_indir_size ||
596
- !dev -> ethtool_ops -> set_rxfh_indir ||
597
- !dev -> ethtool_ops -> get_rxnfc )
596
+ if (!ops -> get_rxfh_indir_size || !ops -> set_rxfh_indir ||
597
+ !ops -> get_rxnfc )
598
598
return - EOPNOTSUPP ;
599
- dev_size = dev -> ethtool_ops -> get_rxfh_indir_size (dev );
599
+
600
+ dev_size = ops -> get_rxfh_indir_size (dev );
600
601
if (dev_size == 0 )
601
602
return - EOPNOTSUPP ;
602
603
@@ -613,7 +614,7 @@ static noinline_for_stack int ethtool_set_rxfh_indir(struct net_device *dev,
613
614
return - ENOMEM ;
614
615
615
616
rx_rings .cmd = ETHTOOL_GRXRINGS ;
616
- ret = dev -> ethtool_ops -> get_rxnfc (dev , & rx_rings , NULL );
617
+ ret = ops -> get_rxnfc (dev , & rx_rings , NULL );
617
618
if (ret )
618
619
goto out ;
619
620
@@ -639,7 +640,7 @@ static noinline_for_stack int ethtool_set_rxfh_indir(struct net_device *dev,
639
640
}
640
641
}
641
642
642
- ret = dev -> ethtool_ops -> set_rxfh_indir (dev , indir );
643
+ ret = ops -> set_rxfh_indir (dev , indir );
643
644
644
645
out :
645
646
kfree (indir );
@@ -1082,9 +1083,10 @@ static int ethtool_phys_id(struct net_device *dev, void __user *useraddr)
1082
1083
{
1083
1084
struct ethtool_value id ;
1084
1085
static bool busy ;
1086
+ const struct ethtool_ops * ops = dev -> ethtool_ops ;
1085
1087
int rc ;
1086
1088
1087
- if (!dev -> ethtool_ops -> set_phys_id )
1089
+ if (!ops -> set_phys_id )
1088
1090
return - EOPNOTSUPP ;
1089
1091
1090
1092
if (busy )
@@ -1093,7 +1095,7 @@ static int ethtool_phys_id(struct net_device *dev, void __user *useraddr)
1093
1095
if (copy_from_user (& id , useraddr , sizeof (id )))
1094
1096
return - EFAULT ;
1095
1097
1096
- rc = dev -> ethtool_ops -> set_phys_id (dev , ETHTOOL_ID_ACTIVE );
1098
+ rc = ops -> set_phys_id (dev , ETHTOOL_ID_ACTIVE );
1097
1099
if (rc < 0 )
1098
1100
return rc ;
1099
1101
@@ -1118,7 +1120,7 @@ static int ethtool_phys_id(struct net_device *dev, void __user *useraddr)
1118
1120
i = n ;
1119
1121
do {
1120
1122
rtnl_lock ();
1121
- rc = dev -> ethtool_ops -> set_phys_id (dev ,
1123
+ rc = ops -> set_phys_id (dev ,
1122
1124
(i & 1 ) ? ETHTOOL_ID_OFF : ETHTOOL_ID_ON );
1123
1125
rtnl_unlock ();
1124
1126
if (rc )
@@ -1133,7 +1135,7 @@ static int ethtool_phys_id(struct net_device *dev, void __user *useraddr)
1133
1135
dev_put (dev );
1134
1136
busy = false;
1135
1137
1136
- (void )dev -> ethtool_ops -> set_phys_id (dev , ETHTOOL_ID_INACTIVE );
1138
+ (void ) ops -> set_phys_id (dev , ETHTOOL_ID_INACTIVE );
1137
1139
return rc ;
1138
1140
}
1139
1141
@@ -1275,7 +1277,7 @@ static int ethtool_get_dump_flag(struct net_device *dev,
1275
1277
struct ethtool_dump dump ;
1276
1278
const struct ethtool_ops * ops = dev -> ethtool_ops ;
1277
1279
1278
- if (!dev -> ethtool_ops -> get_dump_flag )
1280
+ if (!ops -> get_dump_flag )
1279
1281
return - EOPNOTSUPP ;
1280
1282
1281
1283
if (copy_from_user (& dump , useraddr , sizeof (dump )))
@@ -1299,8 +1301,7 @@ static int ethtool_get_dump_data(struct net_device *dev,
1299
1301
const struct ethtool_ops * ops = dev -> ethtool_ops ;
1300
1302
void * data = NULL ;
1301
1303
1302
- if (!dev -> ethtool_ops -> get_dump_data ||
1303
- !dev -> ethtool_ops -> get_dump_flag )
1304
+ if (!ops -> get_dump_data || !ops -> get_dump_flag )
1304
1305
return - EOPNOTSUPP ;
1305
1306
1306
1307
if (copy_from_user (& dump , useraddr , sizeof (dump )))
@@ -1346,13 +1347,9 @@ static int ethtool_get_ts_info(struct net_device *dev, void __user *useraddr)
1346
1347
info .cmd = ETHTOOL_GET_TS_INFO ;
1347
1348
1348
1349
if (phydev && phydev -> drv && phydev -> drv -> ts_info ) {
1349
-
1350
1350
err = phydev -> drv -> ts_info (phydev , & info );
1351
-
1352
- } else if (dev -> ethtool_ops && dev -> ethtool_ops -> get_ts_info ) {
1353
-
1351
+ } else if (ops -> get_ts_info ) {
1354
1352
err = ops -> get_ts_info (dev , & info );
1355
-
1356
1353
} else {
1357
1354
info .so_timestamping =
1358
1355
SOF_TIMESTAMPING_RX_SOFTWARE |
0 commit comments