From: Tomer Maimon <tmaimon77@gmail.com>
To: broonie@kernel.org, dwmw2@infradead.org,
computersforpeace@gmail.com, marek.vasut@gmail.com,
miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com,
bbrezillon@kernel.org, yogeshnarayan.gaur@nxp.com,
tudor.ambarus@microchip.com, gregkh@linuxfoundation.org,
frieder.schrempf@exceet.de, tglx@linutronix.de
Cc: linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org,
Tomer Maimon <tmaimon77@gmail.com>,
linux-spi@vger.kernel.org
Subject: [RFC v1 1/3] spi: spi-mem: add spi-mem setup function
Date: Mon, 29 Jul 2019 17:25:02 +0300 [thread overview]
Message-ID: <20190729142504.188336-2-tmaimon77@gmail.com> (raw)
In-Reply-To: <20190729142504.188336-1-tmaimon77@gmail.com>
Add spi-mem setup function support SPI memory
operations the spi-mem setup function running
after the spi-mem probe function if the spi-mem
setup function implemented.
Signed-off-by: Tomer Maimon <tmaimon77@gmail.com>
---
drivers/spi/spi-mem.c | 27 ++++++++++++++++++++++++++-
include/linux/spi/spi-mem.h | 4 ++++
2 files changed, 30 insertions(+), 1 deletion(-)
diff --git a/drivers/spi/spi-mem.c b/drivers/spi/spi-mem.c
index 9f0fa9f3116d..21fe3a75d636 100644
--- a/drivers/spi/spi-mem.c
+++ b/drivers/spi/spi-mem.c
@@ -398,6 +398,26 @@ const char *spi_mem_get_name(struct spi_mem *mem)
}
EXPORT_SYMBOL_GPL(spi_mem_get_name);
+/**
+ * spi_mem_setup() - Execute spi memory setup
+ * @mem: the SPI memory
+ *
+ * This function allows SPI mem users to execute spi memory
+ * setup after the probe finished.
+ *
+ * Return: 0 in case of success, a negative error code otherwise.
+ */
+int spi_mem_setup(struct spi_mem *mem)
+{
+ struct spi_controller *ctlr = mem->spi->controller;
+
+ if (ctlr->mem_ops && ctlr->mem_ops->setup)
+ return ctlr->mem_ops->setup(mem);
+
+ return 0;
+}
+EXPORT_SYMBOL_GPL(spi_mem_setup);
+
/**
* spi_mem_adjust_op_size() - Adjust the data size of a SPI mem operation to
* match controller limitations
@@ -723,6 +743,7 @@ static int spi_mem_probe(struct spi_device *spi)
struct spi_mem_driver *memdrv = to_spi_mem_drv(spi->dev.driver);
struct spi_controller *ctlr = spi->controller;
struct spi_mem *mem;
+ int ret;
mem = devm_kzalloc(&spi->dev, sizeof(*mem), GFP_KERNEL);
if (!mem)
@@ -740,7 +761,11 @@ static int spi_mem_probe(struct spi_device *spi)
spi_set_drvdata(spi, mem);
- return memdrv->probe(mem);
+ ret = memdrv->probe(mem);
+ if (ret)
+ return ret;
+
+ return spi_mem_setup(mem);
}
static int spi_mem_remove(struct spi_device *spi)
diff --git a/include/linux/spi/spi-mem.h b/include/linux/spi/spi-mem.h
index af9ff2f0f1b2..5f7d20bd2b09 100644
--- a/include/linux/spi/spi-mem.h
+++ b/include/linux/spi/spi-mem.h
@@ -222,6 +222,7 @@ static inline void *spi_mem_get_drvdata(struct spi_mem *mem)
* Note that if the implementation of this function allocates memory
* dynamically, then it should do so with devm_xxx(), as we don't
* have a ->free_name() function.
+ * @setup: execute a SPI memory setup
* @dirmap_create: create a direct mapping descriptor that can later be used to
* access the memory device. This method is optional
* @dirmap_destroy: destroy a memory descriptor previous created by
@@ -256,6 +257,7 @@ struct spi_controller_mem_ops {
int (*exec_op)(struct spi_mem *mem,
const struct spi_mem_op *op);
const char *(*get_name)(struct spi_mem *mem);
+ int (*setup)(struct spi_mem *mem);
int (*dirmap_create)(struct spi_mem_dirmap_desc *desc);
void (*dirmap_destroy)(struct spi_mem_dirmap_desc *desc);
ssize_t (*dirmap_read)(struct spi_mem_dirmap_desc *desc,
@@ -334,6 +336,8 @@ int spi_mem_exec_op(struct spi_mem *mem,
const char *spi_mem_get_name(struct spi_mem *mem);
+int spi_mem_setup(struct spi_mem *mem);
+
struct spi_mem_dirmap_desc *
spi_mem_dirmap_create(struct spi_mem *mem,
const struct spi_mem_dirmap_info *info);
--
2.18.0
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
next prev parent reply other threads:[~2019-07-29 14:25 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-29 14:25 [RFC v1 0/3] *spi-mem: adding setup and callback function Tomer Maimon
2019-07-29 14:25 ` Tomer Maimon [this message]
2019-07-29 14:25 ` [RFC v1 2/3] spi: spi-mem: add callback function to spi-mem device Tomer Maimon
2019-07-29 14:25 ` [RFC v1 3/3] mtd: m25p80: add get Flash size callback support Tomer Maimon
2019-07-29 15:28 ` [RFC v1 0/3] *spi-mem: adding setup and callback function Boris Brezillon
[not found] ` <CAP6Zq1iPXDX_Gtz6ZWYm3JoHgHjdapotVLGw-Lq4tc2X-6eAug@mail.gmail.com>
2019-07-30 6:54 ` Boris Brezillon
2019-07-30 16:53 ` Sergei Shtylyov
2019-07-30 17:48 ` Vignesh Raghavendra
2019-07-30 18:04 ` Boris Brezillon
[not found] ` <CAP6Zq1hfVoS8+VU0rAtKAX7D22qTVHDMosiCRMKV8sQB_m0qOQ@mail.gmail.com>
2019-08-01 6:42 ` Vignesh Raghavendra
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190729142504.188336-2-tmaimon77@gmail.com \
--to=tmaimon77@gmail.com \
--cc=bbrezillon@kernel.org \
--cc=broonie@kernel.org \
--cc=computersforpeace@gmail.com \
--cc=dwmw2@infradead.org \
--cc=frieder.schrempf@exceet.de \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=linux-spi@vger.kernel.org \
--cc=marek.vasut@gmail.com \
--cc=miquel.raynal@bootlin.com \
--cc=richard@nod.at \
--cc=tglx@linutronix.de \
--cc=tudor.ambarus@microchip.com \
--cc=vigneshr@ti.com \
--cc=yogeshnarayan.gaur@nxp.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).