|
@@ -249,6 +249,59 @@ static int smsc95xx_eeprom_read ( struct smsc95xx_device *smsc95xx,
|
249
|
249
|
return 0;
|
250
|
250
|
}
|
251
|
251
|
|
|
252
|
+/******************************************************************************
|
|
253
|
+ *
|
|
254
|
+ * MAC address
|
|
255
|
+ *
|
|
256
|
+ ******************************************************************************
|
|
257
|
+ */
|
|
258
|
+
|
|
259
|
+/**
|
|
260
|
+ * Fetch MAC address from EEPROM
|
|
261
|
+ *
|
|
262
|
+ * @v smsc95xx SMSC95xx device
|
|
263
|
+ * @v hw_addr Hardware address to fill in
|
|
264
|
+ * @ret rc Return status code
|
|
265
|
+ */
|
|
266
|
+static int smsc95xx_fetch_mac_eeprom ( struct smsc95xx_device *smsc95xx,
|
|
267
|
+ uint8_t *hw_addr ) {
|
|
268
|
+ int rc;
|
|
269
|
+
|
|
270
|
+ /* Read MAC address from EEPROM */
|
|
271
|
+ if ( ( rc = smsc95xx_eeprom_read ( smsc95xx, SMSC95XX_EEPROM_MAC,
|
|
272
|
+ hw_addr, ETH_ALEN ) ) != 0 )
|
|
273
|
+ return rc;
|
|
274
|
+
|
|
275
|
+ /* Check that EEPROM is physically present */
|
|
276
|
+ if ( ! is_valid_ether_addr ( hw_addr ) ) {
|
|
277
|
+ DBGC ( smsc95xx, "SMSC95XX %p has no EEPROM (%s)\n",
|
|
278
|
+ smsc95xx, eth_ntoa ( hw_addr ) );
|
|
279
|
+ return -ENODEV;
|
|
280
|
+ }
|
|
281
|
+
|
|
282
|
+ return 0;
|
|
283
|
+}
|
|
284
|
+
|
|
285
|
+/**
|
|
286
|
+ * Fetch MAC address
|
|
287
|
+ *
|
|
288
|
+ * @v smsc95xx SMSC95xx device
|
|
289
|
+ * @v hw_addr Hardware address to fill in
|
|
290
|
+ * @ret rc Return status code
|
|
291
|
+ */
|
|
292
|
+static int smsc95xx_fetch_mac ( struct smsc95xx_device *smsc95xx,
|
|
293
|
+ uint8_t *hw_addr ) {
|
|
294
|
+ int rc;
|
|
295
|
+
|
|
296
|
+ /* Read MAC address from EEPROM, if present */
|
|
297
|
+ if ( ( rc = smsc95xx_fetch_mac_eeprom ( smsc95xx, hw_addr ) ) == 0 )
|
|
298
|
+ return 0;
|
|
299
|
+
|
|
300
|
+ /* Otherwise, generate a random MAC address */
|
|
301
|
+ eth_random_addr ( hw_addr );
|
|
302
|
+ return 0;
|
|
303
|
+}
|
|
304
|
+
|
252
|
305
|
/******************************************************************************
|
253
|
306
|
*
|
254
|
307
|
* MII access
|
|
@@ -980,16 +1033,8 @@ static int smsc95xx_probe ( struct usb_function *func,
|
980
|
1033
|
goto err_reset;
|
981
|
1034
|
|
982
|
1035
|
/* Read MAC address */
|
983
|
|
- if ( ( rc = smsc95xx_eeprom_read ( smsc95xx, SMSC95XX_EEPROM_MAC,
|
984
|
|
- netdev->hw_addr, ETH_ALEN ) ) != 0 )
|
985
|
|
- goto err_eeprom_read;
|
986
|
|
-
|
987
|
|
- /* Generate MAC address if EEPROM is not present */
|
988
|
|
- if ( ! is_valid_ether_addr ( netdev->hw_addr ) ) {
|
989
|
|
- DBGC ( smsc95xx, "SMSC95XX %p has no EEPROM (%s)\n",
|
990
|
|
- smsc95xx, eth_ntoa ( netdev->hw_addr ) );
|
991
|
|
- eth_random_addr ( netdev->hw_addr );
|
992
|
|
- }
|
|
1036
|
+ if ( ( rc = smsc95xx_fetch_mac ( smsc95xx, netdev->hw_addr ) ) != 0 )
|
|
1037
|
+ goto err_fetch_mac;
|
993
|
1038
|
|
994
|
1039
|
/* Register network device */
|
995
|
1040
|
if ( ( rc = register_netdev ( netdev ) ) != 0 )
|
|
@@ -1000,7 +1045,7 @@ static int smsc95xx_probe ( struct usb_function *func,
|
1000
|
1045
|
|
1001
|
1046
|
unregister_netdev ( netdev );
|
1002
|
1047
|
err_register:
|
1003
|
|
- err_eeprom_read:
|
|
1048
|
+ err_fetch_mac:
|
1004
|
1049
|
err_reset:
|
1005
|
1050
|
err_describe:
|
1006
|
1051
|
netdev_nullify ( netdev );
|