+static int nvmem_cell_read_u32(struct device* dev, const char *cell_id, u32 *val)
+{
+ struct nvmem_cell *cell;
+ void *buf;
+ size_t len;
+
+ cell = nvmem_cell_get(dev, cell_id);
+ if (IS_ERR(cell))
+ return PTR_ERR(cell);
+
+ buf = nvmem_cell_read(cell, &len);
+ if (IS_ERR(buf)) {
+ nvmem_cell_put(cell);
+ return PTR_ERR(buf);
+ }
+ if (len != sizeof(*val)) {
+ kfree(buf);
+ nvmem_cell_put(cell);
+ return -EINVAL;
+ }
+ memcpy(val, buf, sizeof(*val));
Yep, this function looks generic, can be moved to nvmem layer.+The function looks nothing IMX specific, and could be a nvmem core
+ kfree(buf);
+ nvmem_cell_put(cell);
+ return 0;
+}
function?
@Srinivas, thoughts?