Commit 8a134fd9 authored by Michael Walle's avatar Michael Walle Committed by Greg Kroah-Hartman
Browse files

nvmem: core: provide own priv pointer in post process callback



It doesn't make any more sense to have a opaque pointer set up by the
nvmem device. Usually, the layout isn't associated with a particular
nvmem device. Instead, let the caller who set the post process callback
provide the priv pointer.

Signed-off-by: default avatarMichael Walle <michael@walle.cc>
Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: default avatarSrinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20230404172148.82422-21-srinivas.kandagatla@linaro.org


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 011e40a1
Loading
Loading
Loading
Loading
+3 −1
Original line number Original line Diff line number Diff line
@@ -54,6 +54,7 @@ struct nvmem_cell_entry {
	int			bit_offset;
	int			bit_offset;
	int			nbits;
	int			nbits;
	nvmem_cell_post_process_t read_post_process;
	nvmem_cell_post_process_t read_post_process;
	void			*priv;
	struct device_node	*np;
	struct device_node	*np;
	struct nvmem_device	*nvmem;
	struct nvmem_device	*nvmem;
	struct list_head	node;
	struct list_head	node;
@@ -471,6 +472,7 @@ static int nvmem_cell_info_to_nvmem_cell_entry_nodup(struct nvmem_device *nvmem,
	cell->bytes = info->bytes;
	cell->bytes = info->bytes;
	cell->name = info->name;
	cell->name = info->name;
	cell->read_post_process = info->read_post_process;
	cell->read_post_process = info->read_post_process;
	cell->priv = info->priv;


	cell->bit_offset = info->bit_offset;
	cell->bit_offset = info->bit_offset;
	cell->nbits = info->nbits;
	cell->nbits = info->nbits;
@@ -1568,7 +1570,7 @@ static int __nvmem_cell_read(struct nvmem_device *nvmem,
		nvmem_shift_read_buffer_in_place(cell, buf);
		nvmem_shift_read_buffer_in_place(cell, buf);


	if (cell->read_post_process) {
	if (cell->read_post_process) {
		rc = cell->read_post_process(nvmem->priv, id, index,
		rc = cell->read_post_process(cell->priv, id, index,
					     cell->offset, buf, cell->bytes);
					     cell->offset, buf, cell->bytes);
		if (rc)
		if (rc)
			return rc;
			return rc;
+4 −1
Original line number Original line Diff line number Diff line
@@ -20,7 +20,8 @@ typedef int (*nvmem_reg_write_t)(void *priv, unsigned int offset,
				 void *val, size_t bytes);
				 void *val, size_t bytes);
/* used for vendor specific post processing of cell data */
/* used for vendor specific post processing of cell data */
typedef int (*nvmem_cell_post_process_t)(void *priv, const char *id, int index,
typedef int (*nvmem_cell_post_process_t)(void *priv, const char *id, int index,
					 unsigned int offset, void *buf, size_t bytes);
					 unsigned int offset, void *buf,
					 size_t bytes);


enum nvmem_type {
enum nvmem_type {
	NVMEM_TYPE_UNKNOWN = 0,
	NVMEM_TYPE_UNKNOWN = 0,
@@ -56,6 +57,7 @@ struct nvmem_keepout {
 * @np:		Optional device_node pointer.
 * @np:		Optional device_node pointer.
 * @read_post_process:	Callback for optional post processing of cell data
 * @read_post_process:	Callback for optional post processing of cell data
 *			on reads.
 *			on reads.
 * @priv:	Opaque data passed to the read_post_process hook.
 */
 */
struct nvmem_cell_info {
struct nvmem_cell_info {
	const char		*name;
	const char		*name;
@@ -65,6 +67,7 @@ struct nvmem_cell_info {
	unsigned int		nbits;
	unsigned int		nbits;
	struct device_node	*np;
	struct device_node	*np;
	nvmem_cell_post_process_t read_post_process;
	nvmem_cell_post_process_t read_post_process;
	void			*priv;
};
};


/**
/**