diff options
-rw-r--r-- | drivers/net/dsa/lan9303-core.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/drivers/net/dsa/lan9303-core.c b/drivers/net/dsa/lan9303-core.c index 2dead7fa1f93..6171c0853ff1 100644 --- a/drivers/net/dsa/lan9303-core.c +++ b/drivers/net/dsa/lan9303-core.c | |||
@@ -817,18 +817,16 @@ static void lan9303_bridge_ports(struct lan9303 *chip) | |||
817 | lan9303_alr_add_port(chip, eth_stp_addr, 0, true); | 817 | lan9303_alr_add_port(chip, eth_stp_addr, 0, true); |
818 | } | 818 | } |
819 | 819 | ||
820 | static int lan9303_handle_reset(struct lan9303 *chip) | 820 | static void lan9303_handle_reset(struct lan9303 *chip) |
821 | { | 821 | { |
822 | if (!chip->reset_gpio) | 822 | if (!chip->reset_gpio) |
823 | return 0; | 823 | return; |
824 | 824 | ||
825 | if (chip->reset_duration != 0) | 825 | if (chip->reset_duration != 0) |
826 | msleep(chip->reset_duration); | 826 | msleep(chip->reset_duration); |
827 | 827 | ||
828 | /* release (deassert) reset and activate the device */ | 828 | /* release (deassert) reset and activate the device */ |
829 | gpiod_set_value_cansleep(chip->reset_gpio, 0); | 829 | gpiod_set_value_cansleep(chip->reset_gpio, 0); |
830 | |||
831 | return 0; | ||
832 | } | 830 | } |
833 | 831 | ||
834 | /* stop processing packets for all ports */ | 832 | /* stop processing packets for all ports */ |
@@ -1294,15 +1292,17 @@ static int lan9303_register_switch(struct lan9303 *chip) | |||
1294 | return dsa_register_switch(chip->ds); | 1292 | return dsa_register_switch(chip->ds); |
1295 | } | 1293 | } |
1296 | 1294 | ||
1297 | static void lan9303_probe_reset_gpio(struct lan9303 *chip, | 1295 | static int lan9303_probe_reset_gpio(struct lan9303 *chip, |
1298 | struct device_node *np) | 1296 | struct device_node *np) |
1299 | { | 1297 | { |
1300 | chip->reset_gpio = devm_gpiod_get_optional(chip->dev, "reset", | 1298 | chip->reset_gpio = devm_gpiod_get_optional(chip->dev, "reset", |
1301 | GPIOD_OUT_LOW); | 1299 | GPIOD_OUT_LOW); |
1300 | if (IS_ERR(chip->reset_gpio)) | ||
1301 | return PTR_ERR(chip->reset_gpio); | ||
1302 | 1302 | ||
1303 | if (IS_ERR(chip->reset_gpio)) { | 1303 | if (!chip->reset_gpio) { |
1304 | dev_dbg(chip->dev, "No reset GPIO defined\n"); | 1304 | dev_dbg(chip->dev, "No reset GPIO defined\n"); |
1305 | return; | 1305 | return 0; |
1306 | } | 1306 | } |
1307 | 1307 | ||
1308 | chip->reset_duration = 200; | 1308 | chip->reset_duration = 200; |
@@ -1317,6 +1317,8 @@ static void lan9303_probe_reset_gpio(struct lan9303 *chip, | |||
1317 | /* A sane reset duration should not be longer than 1s */ | 1317 | /* A sane reset duration should not be longer than 1s */ |
1318 | if (chip->reset_duration > 1000) | 1318 | if (chip->reset_duration > 1000) |
1319 | chip->reset_duration = 1000; | 1319 | chip->reset_duration = 1000; |
1320 | |||
1321 | return 0; | ||
1320 | } | 1322 | } |
1321 | 1323 | ||
1322 | int lan9303_probe(struct lan9303 *chip, struct device_node *np) | 1324 | int lan9303_probe(struct lan9303 *chip, struct device_node *np) |
@@ -1326,12 +1328,12 @@ int lan9303_probe(struct lan9303 *chip, struct device_node *np) | |||
1326 | mutex_init(&chip->indirect_mutex); | 1328 | mutex_init(&chip->indirect_mutex); |
1327 | mutex_init(&chip->alr_mutex); | 1329 | mutex_init(&chip->alr_mutex); |
1328 | 1330 | ||
1329 | lan9303_probe_reset_gpio(chip, np); | 1331 | ret = lan9303_probe_reset_gpio(chip, np); |
1330 | |||
1331 | ret = lan9303_handle_reset(chip); | ||
1332 | if (ret) | 1332 | if (ret) |
1333 | return ret; | 1333 | return ret; |
1334 | 1334 | ||
1335 | lan9303_handle_reset(chip); | ||
1336 | |||
1335 | ret = lan9303_check_device(chip); | 1337 | ret = lan9303_check_device(chip); |
1336 | if (ret) | 1338 | if (ret) |
1337 | return ret; | 1339 | return ret; |