Skip to content

Commit b20eb4c

Browse files
committed
eeprom: at24: drop unnecessary label
If we move the nvmem registration above the pm enable calls and the test read, we can drop the error label and make the code more readable as there's now only a single place where we must call pm_runtime_disable() in error path. Signed-off-by: Bartosz Golaszewski <[email protected]>
1 parent e730862 commit b20eb4c

File tree

1 file changed

+18
-25
lines changed

1 file changed

+18
-25
lines changed

drivers/misc/eeprom/at24.c

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -685,23 +685,6 @@ static int at24_probe(struct i2c_client *client)
685685
return err;
686686
}
687687

688-
i2c_set_clientdata(client, at24);
689-
690-
/* enable runtime pm */
691-
pm_runtime_set_active(dev);
692-
pm_runtime_enable(dev);
693-
694-
/*
695-
* Perform a one-byte test read to verify that the
696-
* chip is functional.
697-
*/
698-
err = at24_read(at24, 0, &test_byte, 1);
699-
pm_runtime_idle(dev);
700-
if (err) {
701-
err = -ENODEV;
702-
goto err_runtime_pm;
703-
}
704-
705688
nvmem_config.name = dev_name(dev);
706689
nvmem_config.dev = dev;
707690
nvmem_config.read_only = !writable;
@@ -717,21 +700,31 @@ static int at24_probe(struct i2c_client *client)
717700
nvmem_config.size = byte_len;
718701

719702
at24->nvmem = devm_nvmem_register(dev, &nvmem_config);
720-
if (IS_ERR(at24->nvmem)) {
721-
err = PTR_ERR(at24->nvmem);
722-
goto err_runtime_pm;
703+
if (IS_ERR(at24->nvmem))
704+
return PTR_ERR(at24->nvmem);
705+
706+
i2c_set_clientdata(client, at24);
707+
708+
/* enable runtime pm */
709+
pm_runtime_set_active(dev);
710+
pm_runtime_enable(dev);
711+
712+
/*
713+
* Perform a one-byte test read to verify that the
714+
* chip is functional.
715+
*/
716+
err = at24_read(at24, 0, &test_byte, 1);
717+
pm_runtime_idle(dev);
718+
if (err) {
719+
pm_runtime_disable(dev);
720+
return -ENODEV;
723721
}
724722

725723
dev_info(dev, "%u byte %s EEPROM, %s, %u bytes/write\n",
726724
byte_len, client->name,
727725
writable ? "writable" : "read-only", at24->write_max);
728726

729727
return 0;
730-
731-
err_runtime_pm:
732-
pm_runtime_disable(dev);
733-
734-
return err;
735728
}
736729

737730
static int at24_remove(struct i2c_client *client)

0 commit comments

Comments
 (0)