aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZhao Qiang <qiang.zhao@nxp.com>2019-06-12 17:06:30 +0800
committerDaniel Thompson <daniel@redfelineninja.org.uk>2019-09-17 16:03:04 +0100
commitd060c9b139365e16295a0daee604715e49b93857 (patch)
treed7932736a065273b524209030687c6026798d978
parentab3e61153cfa2ab473fe2650bd46174c14dfd073 (diff)
downloadlinux-d060c9b139365e16295a0daee604715e49b93857.tar.gz
spi: nxp-fspi: add "get_name" function
Signed-off-by: Zhao Qiang <qiang.zhao@nxp.com>
-rw-r--r--drivers/spi/spi-nxp-fspi.c22
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)