aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorFrieder Schrempf <frieder.schrempf@exceet.de>2018-08-02 08:53:53 -0400
committerMark Brown <broonie@kernel.org>2018-08-02 10:35:41 -0400
commit5d27a9c8ea9e967d00b92a76d4bb242bf7692f2b (patch)
tree81c1eee84492a7b65a991d5069838b86227414c0 /include
parent06bcb5168d7d49aa3ed449ff13a6d13c30afc3f0 (diff)
spi: spi-mem: Extend the SPI mem interface to set a custom memory name
When porting (Q)SPI controller drivers from the MTD layer to the SPI layer, the naming scheme for the memory devices changes. To be able to keep compatibility with the old drivers naming scheme, a name field is added to struct spi_mem and a hook is added to let controller drivers set a custom name for the memory device. Example for the FSL QSPI driver: Name with the old driver: 21e0000.qspi, or with multiple devices: 21e0000.qspi-0, 21e0000.qspi-1, ... Name with the new driver without spi_mem_get_name: spi4.0 Suggested-by: Boris Brezillon <boris.brezillon@bootlin.com> Signed-off-by: Frieder Schrempf <frieder.schrempf@exceet.de> Reviewed-by: Boris Brezillon <boris.brezillon@bootlin.com> Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'include')
-rw-r--r--include/linux/spi/spi-mem.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/include/linux/spi/spi-mem.h b/include/linux/spi/spi-mem.h
index 951a2e949d5f..0d64ccc4e584 100644
--- a/include/linux/spi/spi-mem.h
+++ b/include/linux/spi/spi-mem.h
@@ -123,6 +123,7 @@ struct spi_mem_op {
123 * struct spi_mem - describes a SPI memory device 123 * struct spi_mem - describes a SPI memory device
124 * @spi: the underlying SPI device 124 * @spi: the underlying SPI device
125 * @drvpriv: spi_mem_driver private data 125 * @drvpriv: spi_mem_driver private data
126 * @name: name of the SPI memory device
126 * 127 *
127 * Extra information that describe the SPI memory device and may be needed by 128 * Extra information that describe the SPI memory device and may be needed by
128 * the controller to properly handle this device should be placed here. 129 * the controller to properly handle this device should be placed here.
@@ -133,6 +134,7 @@ struct spi_mem_op {
133struct spi_mem { 134struct spi_mem {
134 struct spi_device *spi; 135 struct spi_device *spi;
135 void *drvpriv; 136 void *drvpriv;
137 char *name;
136}; 138};
137 139
138/** 140/**
@@ -165,6 +167,13 @@ static inline void *spi_mem_get_drvdata(struct spi_mem *mem)
165 * limitations) 167 * limitations)
166 * @supports_op: check if an operation is supported by the controller 168 * @supports_op: check if an operation is supported by the controller
167 * @exec_op: execute a SPI memory operation 169 * @exec_op: execute a SPI memory operation
170 * @get_name: get a custom name for the SPI mem device from the controller.
171 * This might be needed if the controller driver has been ported
172 * to use the SPI mem layer and a custom name is used to keep
173 * mtdparts compatible.
174 * Note that if the implementation of this function allocates memory
175 * dynamically, then it should do so with devm_xxx(), as we don't
176 * have a ->free_name() function.
168 * 177 *
169 * This interface should be implemented by SPI controllers providing an 178 * This interface should be implemented by SPI controllers providing an
170 * high-level interface to execute SPI memory operation, which is usually the 179 * high-level interface to execute SPI memory operation, which is usually the
@@ -176,6 +185,7 @@ struct spi_controller_mem_ops {
176 const struct spi_mem_op *op); 185 const struct spi_mem_op *op);
177 int (*exec_op)(struct spi_mem *mem, 186 int (*exec_op)(struct spi_mem *mem,
178 const struct spi_mem_op *op); 187 const struct spi_mem_op *op);
188 const char *(*get_name)(struct spi_mem *mem);
179}; 189};
180 190
181/** 191/**
@@ -234,6 +244,8 @@ bool spi_mem_supports_op(struct spi_mem *mem,
234int spi_mem_exec_op(struct spi_mem *mem, 244int spi_mem_exec_op(struct spi_mem *mem,
235 const struct spi_mem_op *op); 245 const struct spi_mem_op *op);
236 246
247const char *spi_mem_get_name(struct spi_mem *mem);
248
237int spi_mem_driver_register_with_owner(struct spi_mem_driver *drv, 249int spi_mem_driver_register_with_owner(struct spi_mem_driver *drv,
238 struct module *owner); 250 struct module *owner);
239 251