static inline void
ptp_ocp_nvmem_device_put(struct nvmem_device **nvmemp)
{
- if (*nvmemp != NULL) {
+ if (!IS_ERR_OR_NULL(*nvmemp))
nvmem_device_put(*nvmemp);
- *nvmemp = NULL;
- }
+ *nvmemp = NULL;
}
static void
}
if (!nvmem) {
nvmem = ptp_ocp_nvmem_device_get(bp, tag);
- if (!nvmem)
- goto out;
+ if (IS_ERR(nvmem)) {
+ ret = PTR_ERR(nvmem);
+ goto fail;
+ }
}
ret = nvmem_device_read(nvmem, map->off, map->len,
BP_MAP_ENTRY_ADDR(bp, map));
if (ret != map->len)
- goto read_fail;
+ goto fail;
}
bp->has_eeprom_data = true;
ptp_ocp_nvmem_device_put(&nvmem);
return;
-read_fail:
+fail:
dev_err(&bp->pdev->dev, "could not read eeprom: %d\n", ret);
goto out;
}