Commit bccd4cbc authored by Vaibhav Gupta's avatar Vaibhav Gupta

drivers: fmc: eeprom: Improve error checking

nvmem_device_get() may return an error pointed instead of NULL, thus
check for it.

Picked from the changes done by Mathis Marion for Oscimp-WRTD project.
Signed-off-by: 's avatarVaibhav Gupta <vaibhav.gupta@cern.ch>
parent a3bc508d
......@@ -105,12 +105,15 @@ ssize_t fmc_slot_eeprom_read(struct fmc_slot *slot,
snprintf(nvmem_name, len, "%s%d",
dev_name(&slot->eeprom->dev), idx);
nvmem = nvmem_device_get(&slot->dev, nvmem_name);
if (nvmem) {
if (!IS_ERR_OR_NULL(nvmem)) {
err = nvmem_device_read(nvmem, offset, count, buf);
#if KERNEL_VERSION(5, 1, 0) <= LINUX_VERSION_CODE
nvmem_device_put(nvmem);
#endif
}
else {
err = PTR_ERR(nvmem);
}
kfree(nvmem_name);
}
#else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment