Skip to content

Commit bab10bf

Browse files
Wer-Wolfgroeck
authored andcommitted
hwmon: (sch5627) Remove unnecessary error path
Calling remove() on error whould have only unregistered the watchdog, and since a failure in registering him is considered non-fatal and happens last, remove the error path and return the error codes directly. Signed-off-by: Armin Wolf <W_Armin@gmx.de> Link: https://lore.kernel.org/r/20210417210920.15496-3-W_Armin@gmx.de Signed-off-by: Guenter Roeck <linux@roeck-us.net>
1 parent 93a6fb2 commit bab10bf

1 file changed

Lines changed: 25 additions & 45 deletions

File tree

drivers/hwmon/sch5627.c

Lines changed: 25 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -383,72 +383,58 @@ static int sch5627_probe(struct platform_device *pdev)
383383
platform_set_drvdata(pdev, data);
384384

385385
val = sch56xx_read_virtual_reg(data->addr, SCH5627_REG_HWMON_ID);
386-
if (val < 0) {
387-
err = val;
388-
goto error;
389-
}
386+
if (val < 0)
387+
return val;
388+
390389
if (val != SCH5627_HWMON_ID) {
391390
pr_err("invalid %s id: 0x%02X (expected 0x%02X)\n", "hwmon",
392391
val, SCH5627_HWMON_ID);
393-
err = -ENODEV;
394-
goto error;
392+
return -ENODEV;
395393
}
396394

397395
val = sch56xx_read_virtual_reg(data->addr, SCH5627_REG_COMPANY_ID);
398-
if (val < 0) {
399-
err = val;
400-
goto error;
401-
}
396+
if (val < 0)
397+
return val;
398+
402399
if (val != SCH5627_COMPANY_ID) {
403400
pr_err("invalid %s id: 0x%02X (expected 0x%02X)\n", "company",
404401
val, SCH5627_COMPANY_ID);
405-
err = -ENODEV;
406-
goto error;
402+
return -ENODEV;
407403
}
408404

409405
val = sch56xx_read_virtual_reg(data->addr, SCH5627_REG_PRIMARY_ID);
410-
if (val < 0) {
411-
err = val;
412-
goto error;
413-
}
406+
if (val < 0)
407+
return val;
408+
414409
if (val != SCH5627_PRIMARY_ID) {
415410
pr_err("invalid %s id: 0x%02X (expected 0x%02X)\n", "primary",
416411
val, SCH5627_PRIMARY_ID);
417-
err = -ENODEV;
418-
goto error;
412+
return -ENODEV;
419413
}
420414

421415
build_code = sch56xx_read_virtual_reg(data->addr,
422416
SCH5627_REG_BUILD_CODE);
423-
if (build_code < 0) {
424-
err = build_code;
425-
goto error;
426-
}
417+
if (build_code < 0)
418+
return build_code;
427419

428420
build_id = sch56xx_read_virtual_reg16(data->addr,
429421
SCH5627_REG_BUILD_ID);
430-
if (build_id < 0) {
431-
err = build_id;
432-
goto error;
433-
}
422+
if (build_id < 0)
423+
return build_id;
434424

435425
hwmon_rev = sch56xx_read_virtual_reg(data->addr,
436426
SCH5627_REG_HWMON_REV);
437-
if (hwmon_rev < 0) {
438-
err = hwmon_rev;
439-
goto error;
440-
}
427+
if (hwmon_rev < 0)
428+
return hwmon_rev;
441429

442430
val = sch56xx_read_virtual_reg(data->addr, SCH5627_REG_CTRL);
443-
if (val < 0) {
444-
err = val;
445-
goto error;
446-
}
431+
if (val < 0)
432+
return val;
433+
447434
data->control = val;
448435
if (!(data->control & 0x01)) {
449436
pr_err("hardware monitoring not enabled\n");
450-
err = -ENODEV;
451-
goto error;
437+
return -ENODEV;
452438
}
453439
/* Trigger a Vbat voltage measurement, so that we get a valid reading
454440
the first time we read Vbat */
@@ -462,29 +448,23 @@ static int sch5627_probe(struct platform_device *pdev)
462448
*/
463449
err = sch5627_read_limits(data);
464450
if (err)
465-
goto error;
451+
return err;
466452

467453
pr_info("found %s chip at %#hx\n", DEVNAME, data->addr);
468454
pr_info("firmware build: code 0x%02X, id 0x%04X, hwmon: rev 0x%02X\n",
469455
build_code, build_id, hwmon_rev);
470456

471457
hwmon_dev = devm_hwmon_device_register_with_info(&pdev->dev, DEVNAME, data,
472458
&sch5627_chip_info, NULL);
473-
if (IS_ERR(hwmon_dev)) {
474-
err = PTR_ERR(hwmon_dev);
475-
goto error;
476-
}
459+
if (IS_ERR(hwmon_dev))
460+
return PTR_ERR(hwmon_dev);
477461

478462
/* Note failing to register the watchdog is not a fatal error */
479463
data->watchdog = sch56xx_watchdog_register(&pdev->dev, data->addr,
480464
(build_code << 24) | (build_id << 8) | hwmon_rev,
481465
&data->update_lock, 1);
482466

483467
return 0;
484-
485-
error:
486-
sch5627_remove(pdev);
487-
return err;
488468
}
489469

490470
static struct platform_driver sch5627_driver = {

0 commit comments

Comments
 (0)