diff options
author | Zhao Qiang <qiang.zhao@nxp.com> | 2019-06-12 17:06:30 +0800 |
---|---|---|
committer | Daniel Thompson <daniel@redfelineninja.org.uk> | 2019-09-17 22:31:49 +0100 |
commit | 5c4bf2353a6525196d84e93ec8cfb192683c0443 (patch) | |
tree | f79df8ed6146b528597a23a0a0d0bca72ad5bc8c | |
parent | 64b78b18a00afbe21244190d8dc7620120ad3605 (diff) |
spi: nxp-fspi: add "get_name" function
Signed-off-by: Zhao Qiang <qiang.zhao@nxp.com>
-rw-r--r-- | drivers/spi/spi-nxp-fspi.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/drivers/spi/spi-nxp-fspi.c b/drivers/spi/spi-nxp-fspi.c index 8aa940b75019..a60fa8886c19 100644 --- a/drivers/spi/spi-nxp-fspi.c +++ b/drivers/spi/spi-nxp-fspi.c @@ -974,10 +974,32 @@ static int nxp_fspi_default_setup(struct nxp_fspi *f) return 0; } +static const char *nxp_fspi_get_name(struct spi_mem *mem) +{ + struct nxp_fspi *f = spi_controller_get_devdata(mem->spi->master); + struct device *dev = &mem->spi->dev; + const char *name; + + // Set custom name derived from the platform_device of the controller. + if (of_get_available_child_count(f->dev->of_node) == 1) + return dev_name(f->dev); + + name = devm_kasprintf(dev, GFP_KERNEL, + "%s-%d", dev_name(f->dev), + mem->spi->chip_select); + + if (!name) { + dev_err(dev, "failed to get memory for custom flash name\n"); + return ERR_PTR(-ENOMEM); + } + + return name; +} static const struct spi_controller_mem_ops nxp_fspi_mem_ops = { .adjust_op_size = nxp_fspi_adjust_op_size, .supports_op = nxp_fspi_supports_op, .exec_op = nxp_fspi_exec_op, + .get_name = nxp_fspi_get_name, }; static int nxp_fspi_probe(struct platform_device *pdev) |