From: Marc Kleine-Budde <mkl@pengutronix.de>
To: linux-can@vger.kernel.org
Cc: kernel@pengutronix.de, Dan Murphy <dmurphy@ti.com>,
Sriram Dash <sriram.dash@samsung.com>,
Sean Nyekjaer <sean@geanix.com>,
Marc Kleine-Budde <mkl@pengutronix.de>
Subject: [can-next-rfc 10/16] can: tcan4x5x: tcan4x5x_regmap_init(): use spi as context pointer
Date: Wed, 16 Dec 2020 00:17:40 +0100 [thread overview]
Message-ID: <20201215231746.1132907-11-mkl@pengutronix.de> (raw)
In-Reply-To: <20201215231746.1132907-1-mkl@pengutronix.de>
This patch replaces the context pointer of the regmap callback functions by a
pointer to the spi_device. This saves one level of indirection in the
callbacks.
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
drivers/net/can/m_can/tcan4x5x-regmap.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/drivers/net/can/m_can/tcan4x5x-regmap.c b/drivers/net/can/m_can/tcan4x5x-regmap.c
index 6345bcb7704f..4d43c145fdec 100644
--- a/drivers/net/can/m_can/tcan4x5x-regmap.c
+++ b/drivers/net/can/m_can/tcan4x5x-regmap.c
@@ -18,8 +18,7 @@ static int tcan4x5x_regmap_gather_write(void *context, const void *reg,
size_t reg_len, const void *val,
size_t val_len)
{
- struct device *dev = context;
- struct spi_device *spi = to_spi_device(dev);
+ struct spi_device *spi = context;
struct spi_message m;
u32 addr;
struct spi_transfer t[2] = {
@@ -47,8 +46,7 @@ static int tcan4x5x_regmap_read(void *context,
const void *reg, size_t reg_size,
void *val, size_t val_size)
{
- struct device *dev = context;
- struct spi_device *spi = to_spi_device(dev);
+ struct spi_device *spi = context;
u32 addr = TCAN4X5X_READ_CMD | (*((u16 *)reg) << 8) | val_size >> 2;
@@ -73,6 +71,6 @@ static const struct regmap_bus tcan4x5x_bus = {
int tcan4x5x_regmap_init(struct tcan4x5x_priv *priv)
{
priv->regmap = devm_regmap_init(&priv->spi->dev, &tcan4x5x_bus,
- &priv->spi->dev, &tcan4x5x_regmap);
+ priv->spi, &tcan4x5x_regmap);
return PTR_ERR_OR_ZERO(priv->regmap);
}
--
2.29.2
next prev parent reply other threads:[~2020-12-16 0:05 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-15 23:17 [RFC]: tcan4x5x: rework regmap support Marc Kleine-Budde
2020-12-15 23:17 ` [can-next-rfc 01/16] can: tcan4x5x: replace DEVICE_NAME by KBUILD_MODNAME Marc Kleine-Budde
2020-12-15 23:17 ` [can-next-rfc 02/16] can: tcan4x5x: beautify indention of tcan4x5x_of_match and tcan4x5x_id_table Marc Kleine-Budde
2020-12-15 23:17 ` [can-next-rfc 03/16] can: tcan4x5x: rename tcan4x5x.c -> tcan4x5x-core.c Marc Kleine-Budde
2020-12-15 23:17 ` [can-next-rfc 04/16] can: tcan4x5x: move regmap code into seperate file Marc Kleine-Budde
2020-12-15 23:17 ` [can-next-rfc 05/16] can: tcan4x5x: mark struct regmap_bus tcan4x5x_bus as constant Marc Kleine-Budde
2020-12-15 23:17 ` [can-next-rfc 06/16] can: tcan4x5x: tcan4x5x_bus: remove not needed read_flag_mask Marc Kleine-Budde
2020-12-15 23:17 ` [can-next-rfc 07/16] can: tcan4x5x: remove regmap async support Marc Kleine-Budde
2020-12-15 23:17 ` [can-next-rfc 08/16] can: tcan4x5x: rename regmap_spi_gather_write() -> tcan4x5x_regmap_gather_write() Marc Kleine-Budde
2020-12-15 23:17 ` [can-next-rfc 09/16] can: tcan4x5x: tcan4x5x_regmap_write(): remove not needed casts and replace 4 by sizeof Marc Kleine-Budde
2020-12-15 23:17 ` Marc Kleine-Budde [this message]
2020-12-15 23:17 ` [can-next-rfc 11/16] can: tcan4x5x: fix max register value Marc Kleine-Budde
2020-12-15 23:17 ` [can-next-rfc 12/16] can: tcan4x5x: tcan4x5x_regmap: set reg_stride to 4 Marc Kleine-Budde
2020-12-15 23:17 ` [can-next-rfc 13/16] can: tcan4x5x: add max_raw_{read,write} of 256 Marc Kleine-Budde
2020-12-15 23:17 ` [can-next-rfc 14/16] can: tcan4x5x: add {wr,rd}_table Marc Kleine-Budde
2020-12-15 23:17 ` [can-next-rfc 15/16] can: tcan4x5x: rework SPI access Marc Kleine-Budde
2020-12-15 23:17 ` [can-next-rfc 16/16] can: tcan4x5x: add support for half-duplex controllers Marc Kleine-Budde
2020-12-17 15:33 ` [RFC]: tcan4x5x: rework regmap support Dan Murphy
2020-12-18 8:50 ` Sean Nyekjaer
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=20201215231746.1132907-11-mkl@pengutronix.de \
--to=mkl@pengutronix.de \
--cc=dmurphy@ti.com \
--cc=kernel@pengutronix.de \
--cc=linux-can@vger.kernel.org \
--cc=sean@geanix.com \
--cc=sriram.dash@samsung.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).