From: Ben Whitten <ben.whitten@gmail.com>
To: afaerber@suse.de
Cc: starnight@g.ncu.edu.tw, hasnain.virk@arm.com,
netdev@vger.kernel.org, liuxuenetmail@gmail.com,
shess@hessware.de, Ben Whitten <ben.whitten@lairdtech.com>,
"David S. Miller" <davem@davemloft.net>,
linux-kernel@vger.kernel.org
Subject: [PATCH v3 lora-next 2/5] net: lora: sx1301: replace burst spi functions with regmap_noinc
Date: Fri, 12 Oct 2018 17:26:03 +0100 [thread overview]
Message-ID: <1539361567-3602-3-git-send-email-ben.whitten@lairdtech.com> (raw)
In-Reply-To: <1539361567-3602-1-git-send-email-ben.whitten@lairdtech.com>
We can now use to regmap_noinc API to allow reading and writing to
the internal FIFO register which controls processor memory.
We also remove the now defunct spi element from the structure as this
completes the move to regmap.
Signed-off-by: Ben Whitten <ben.whitten@lairdtech.com>
---
drivers/net/lora/sx1301.c | 22 ++--------------------
drivers/net/lora/sx1301.h | 2 --
2 files changed, 2 insertions(+), 22 deletions(-)
diff --git a/drivers/net/lora/sx1301.c b/drivers/net/lora/sx1301.c
index fd29258..9c85fe7 100644
--- a/drivers/net/lora/sx1301.c
+++ b/drivers/net/lora/sx1301.c
@@ -74,23 +74,6 @@ static struct regmap_config sx1301_regmap_config = {
.max_register = SX1301_MAX_REGISTER,
};
-static int sx1301_read_burst(struct sx1301_priv *priv, u8 reg, u8 *val, size_t len)
-{
- u8 addr = reg & 0x7f;
- return spi_write_then_read(priv->spi, &addr, 1, val, len);
-}
-
-static int sx1301_write_burst(struct sx1301_priv *priv, u8 reg, const u8 *val, size_t len)
-{
- u8 addr = reg | BIT(7);
- struct spi_transfer xfr[2] = {
- { .tx_buf = &addr, .len = 1 },
- { .tx_buf = val, .len = len },
- };
-
- return spi_sync_transfer(priv->spi, xfr, 2);
-}
-
static int sx1301_soft_reset(struct sx1301_priv *priv)
{
return regmap_write(priv->regmap, SX1301_PAGE, REG_PAGE_RESET_SOFT_RESET);
@@ -180,7 +163,7 @@ static int sx1301_load_firmware(struct sx1301_priv *priv, int mcu, const struct
return ret;
}
- ret = sx1301_write_burst(priv, SX1301_MPD, fw->data, fw->size);
+ ret = regmap_noinc_write(priv->regmap, SX1301_MPD, fw->data, fw->size);
if (ret) {
dev_err(priv->dev, "MCU prom data write failed\n");
return ret;
@@ -196,7 +179,7 @@ static int sx1301_load_firmware(struct sx1301_priv *priv, int mcu, const struct
if (!buf)
return -ENOMEM;
- ret = sx1301_read_burst(priv, SX1301_MPD, buf, fw->size);
+ ret = regmap_noinc_read(priv->regmap, SX1301_MPD, buf, fw->size);
if (ret) {
dev_err(priv->dev, "MCU prom data read failed\n");
kfree(buf);
@@ -566,7 +549,6 @@ static int sx1301_probe(struct spi_device *spi)
spi_set_drvdata(spi, netdev);
priv->dev = &spi->dev;
- priv->spi = spi;
priv->regmap = devm_regmap_init_spi(spi, &sx1301_regmap_config);
if (IS_ERR(priv->regmap)) {
diff --git a/drivers/net/lora/sx1301.h b/drivers/net/lora/sx1301.h
index e939c02..e6400f8 100644
--- a/drivers/net/lora/sx1301.h
+++ b/drivers/net/lora/sx1301.h
@@ -12,7 +12,6 @@
#include <linux/regmap.h>
#include <linux/gpio/consumer.h>
#include <linux/lora/dev.h>
-#include <linux/spi/spi.h>
#define SX1301_CHIP_VERSION 103
@@ -64,7 +63,6 @@
struct sx1301_priv {
struct lora_dev_priv lora;
struct device *dev;
- struct spi_device *spi;
struct gpio_desc *rst_gpio;
struct regmap *regmap;
};
--
2.7.4
next prev parent reply other threads:[~2018-10-12 16:26 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-12 16:26 [PATCH v3 lora-next 0/5] based on 4.19-rc7 migration to regmap and clk framewor Ben Whitten
2018-10-12 16:26 ` [PATCH v3 lora-next 1/5] regmap: Add regmap_noinc_write API Ben Whitten
2018-10-18 16:59 ` Andreas Färber
2018-10-18 17:18 ` Mark Brown
2018-10-12 16:26 ` Ben Whitten [this message]
2018-10-12 16:26 ` [PATCH v3 lora-next 3/5] net: lora: sx1301: convert to using regmap fields for bit ops Ben Whitten
2018-10-12 16:26 ` [PATCH v3 lora-next 4/5] net: lora: sx125x: convert to regmap fields Ben Whitten
2018-10-12 16:26 ` [PATCH v3 lora-next 5/5] net: lora: sx125x sx1301: allow radio to register as a clk provider Ben Whitten
2018-12-29 19:25 ` Andreas Färber
2018-12-29 20:16 ` Andreas Färber
2018-12-30 10:55 ` Andreas Färber
2018-12-30 19:40 ` [PATCH lora-next] net: lora: sx125x: Add error handling for clock-output-names Andreas Färber
2018-12-30 19:44 ` [PATCH lora-next] net: lora: sx1301: Fix clk32m handling Andreas Färber
2018-12-30 19:47 ` [PATCH lora-next] net: lora: sx125x: Clean up clock provider Andreas Färber
2018-12-31 13:27 ` [PATCH v3 lora-next 5/5] net: lora: sx125x sx1301: allow radio to register as a clk provider Andreas Färber
2018-12-31 17:50 ` Mark Brown
2018-12-31 22:56 ` Andreas Färber
2019-01-02 0:44 ` Andreas Färber
2019-01-03 12:37 ` Mark Brown
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=1539361567-3602-3-git-send-email-ben.whitten@lairdtech.com \
--to=ben.whitten@gmail.com \
--cc=afaerber@suse.de \
--cc=ben.whitten@lairdtech.com \
--cc=davem@davemloft.net \
--cc=hasnain.virk@arm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=liuxuenetmail@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=shess@hessware.de \
--cc=starnight@g.ncu.edu.tw \
/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).