@@ -46,16 +46,6 @@ struct nvmem_device {
#define to_nvmem_device(d) container_of(d, struct nvmem_device, dev)
#define FLAG_COMPAT BIT(0)
-struct nvmem_cell_entry {
- const char *name;
- int offset;
- int bytes;
- int bit_offset;
- int nbits;
- struct device_node *np;
- struct nvmem_device *nvmem;
- struct list_head node;
-};
struct nvmem_cell {
struct nvmem_cell_entry *entry;
@@ -1416,24 +1406,21 @@ static int __nvmem_cell_read(struct nvmem_device *nvmem,
int rc;
rc = nvmem_reg_read(nvmem, cell->offset, buf, cell->bytes);
-
if (rc)
return rc;
+ if (len)
+ *len = cell->bytes;
/* shift bits in-place */
if (cell->bit_offset || cell->nbits)
nvmem_shift_read_buffer_in_place(cell, buf);
if (nvmem->cell_post_process) {
- rc = nvmem->cell_post_process(nvmem->priv, id,
- cell->offset, buf, cell->bytes);
+ rc = nvmem->cell_post_process(nvmem->priv, cell, id, buf, len);
if (rc)
return rc;
}
- if (len)
- *len = cell->bytes;
-
return 0;
}
@@ -222,8 +222,8 @@ static int imx_ocotp_read(void *context, unsigned int offset,
return ret;
}
-static int imx_ocotp_cell_pp(void *context, const char *id, unsigned int offset,
- void *data, size_t bytes)
+static int imx_ocotp_cell_pp(void *context, struct nvmem_cell_entry *cell,
+ const char *id, void *data, size_t *len)
{
struct ocotp_priv *priv = context;
@@ -233,8 +233,8 @@ static int imx_ocotp_cell_pp(void *context, const char *id, unsigned int offset,
u8 *buf = data;
int i;
- for (i = 0; i < bytes/2; i++)
- swap(buf[i], buf[bytes - i - 1]);
+ for (i = 0; i < cell->bytes / 2; i++)
+ swap(buf[i], buf[cell->bytes - i - 1]);
}
}
@@ -14,14 +14,25 @@
#include <linux/gpio/consumer.h>
struct nvmem_device;
-struct nvmem_cell_info;
+
+struct nvmem_cell_entry {
+ const char *name;
+ int offset;
+ int bytes;
+ int bit_offset;
+ int nbits;
+ struct device_node *np;
+ struct nvmem_device *nvmem;
+ struct list_head node;
+};
+
typedef int (*nvmem_reg_read_t)(void *priv, unsigned int offset,
void *val, size_t bytes);
typedef int (*nvmem_reg_write_t)(void *priv, unsigned int offset,
void *val, size_t bytes);
/* used for vendor specific post processing of cell data */
-typedef int (*nvmem_cell_post_process_t)(void *priv, const char *id, unsigned int offset,
- void *buf, size_t bytes);
+typedef int (*nvmem_cell_post_process_t)(void *priv, struct nvmem_cell_entry *cell, const char *id,
+ void *buf, size_t *len);
enum nvmem_type {
NVMEM_TYPE_UNKNOWN = 0,