@@ -3125,7 +3125,7 @@ static int sh_eth_drv_probe(struct platform_device *pdev)
3125
3125
const struct platform_device_id * id = platform_get_device_id (pdev );
3126
3126
struct sh_eth_private * mdp ;
3127
3127
struct net_device * ndev ;
3128
- int ret , devno ;
3128
+ int ret ;
3129
3129
3130
3130
/* get base addr */
3131
3131
res = platform_get_resource (pdev , IORESOURCE_MEM , 0 );
@@ -3137,10 +3137,6 @@ static int sh_eth_drv_probe(struct platform_device *pdev)
3137
3137
pm_runtime_enable (& pdev -> dev );
3138
3138
pm_runtime_get_sync (& pdev -> dev );
3139
3139
3140
- devno = pdev -> id ;
3141
- if (devno < 0 )
3142
- devno = 0 ;
3143
-
3144
3140
ret = platform_get_irq (pdev , 0 );
3145
3141
if (ret < 0 )
3146
3142
goto out_release ;
@@ -3222,8 +3218,8 @@ static int sh_eth_drv_probe(struct platform_device *pdev)
3222
3218
eth_hw_addr_random (ndev );
3223
3219
}
3224
3220
3225
- /* ioremap the TSU registers */
3226
3221
if (mdp -> cd -> tsu ) {
3222
+ int port = pdev -> id < 0 ? 0 : pdev -> id % 2 ;
3227
3223
struct resource * rtsu ;
3228
3224
3229
3225
rtsu = platform_get_resource (pdev , IORESOURCE_MEM , 1 );
@@ -3235,31 +3231,30 @@ static int sh_eth_drv_probe(struct platform_device *pdev)
3235
3231
/* We can only request the TSU region for the first port
3236
3232
* of the two sharing this TSU for the probe to succeed...
3237
3233
*/
3238
- if (devno % 2 == 0 &&
3234
+ if (port == 0 &&
3239
3235
!devm_request_mem_region (& pdev -> dev , rtsu -> start ,
3240
3236
resource_size (rtsu ),
3241
3237
dev_name (& pdev -> dev ))) {
3242
3238
dev_err (& pdev -> dev , "can't request TSU resource.\n" );
3243
3239
ret = - EBUSY ;
3244
3240
goto out_release ;
3245
3241
}
3242
+ /* ioremap the TSU registers */
3246
3243
mdp -> tsu_addr = devm_ioremap (& pdev -> dev , rtsu -> start ,
3247
3244
resource_size (rtsu ));
3248
3245
if (!mdp -> tsu_addr ) {
3249
3246
dev_err (& pdev -> dev , "TSU region ioremap() failed.\n" );
3250
3247
ret = - ENOMEM ;
3251
3248
goto out_release ;
3252
3249
}
3253
- mdp -> port = devno % 2 ;
3250
+ mdp -> port = port ;
3254
3251
ndev -> features = NETIF_F_HW_VLAN_CTAG_FILTER ;
3255
- }
3256
3252
3257
- /* Need to init only the first port of the two sharing a TSU */
3258
- if (devno % 2 == 0 ) {
3259
- if (mdp -> cd -> chip_reset )
3260
- mdp -> cd -> chip_reset (ndev );
3253
+ /* Need to init only the first port of the two sharing a TSU */
3254
+ if (port == 0 ) {
3255
+ if (mdp -> cd -> chip_reset )
3256
+ mdp -> cd -> chip_reset (ndev );
3261
3257
3262
- if (mdp -> cd -> tsu ) {
3263
3258
/* TSU init (Init only)*/
3264
3259
sh_eth_tsu_init (mdp );
3265
3260
}
0 commit comments