[PATCH 04/12] nfc: trf7970a: constify several pointers

From: Krzysztof Kozlowski
Date: Thu Jul 29 2021 - 06:41:27 EST


Several functions do not modify pointed data so arguments and local
variables can be const for correctness and safety.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@xxxxxxxxxxxxx>
---
drivers/nfc/trf7970a.c | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/nfc/trf7970a.c b/drivers/nfc/trf7970a.c
index 1aed44629aaa..8890fcd59c39 100644
--- a/drivers/nfc/trf7970a.c
+++ b/drivers/nfc/trf7970a.c
@@ -643,7 +643,7 @@ static void trf7970a_send_err_upstream(struct trf7970a *trf, int errno)
}

static int trf7970a_transmit(struct trf7970a *trf, struct sk_buff *skb,
- unsigned int len, u8 *prefix,
+ unsigned int len, const u8 *prefix,
unsigned int prefix_len)
{
struct spi_transfer t[2];
@@ -1387,9 +1387,10 @@ static int trf7970a_is_iso15693_write_or_lock(u8 cmd)
}
}

-static int trf7970a_per_cmd_config(struct trf7970a *trf, struct sk_buff *skb)
+static int trf7970a_per_cmd_config(struct trf7970a *trf,
+ const struct sk_buff *skb)
{
- u8 *req = skb->data;
+ const u8 *req = skb->data;
u8 special_fcn_reg1, iso_ctrl;
int ret;

@@ -1791,7 +1792,7 @@ static int _trf7970a_tg_listen(struct nfc_digital_dev *ddev, u16 timeout,
static int trf7970a_tg_listen(struct nfc_digital_dev *ddev, u16 timeout,
nfc_digital_cmd_complete_t cb, void *arg)
{
- struct trf7970a *trf = nfc_digital_get_drvdata(ddev);
+ const struct trf7970a *trf = nfc_digital_get_drvdata(ddev);

dev_dbg(trf->dev, "Listen - state: %d, timeout: %d ms\n",
trf->state, timeout);
@@ -1803,7 +1804,7 @@ static int trf7970a_tg_listen_md(struct nfc_digital_dev *ddev,
u16 timeout, nfc_digital_cmd_complete_t cb,
void *arg)
{
- struct trf7970a *trf = nfc_digital_get_drvdata(ddev);
+ const struct trf7970a *trf = nfc_digital_get_drvdata(ddev);
int ret;

dev_dbg(trf->dev, "Listen MD - state: %d, timeout: %d ms\n",
@@ -1824,7 +1825,7 @@ static int trf7970a_tg_listen_md(struct nfc_digital_dev *ddev,

static int trf7970a_tg_get_rf_tech(struct nfc_digital_dev *ddev, u8 *rf_tech)
{
- struct trf7970a *trf = nfc_digital_get_drvdata(ddev);
+ const struct trf7970a *trf = nfc_digital_get_drvdata(ddev);

dev_dbg(trf->dev, "Get RF Tech - state: %d, rf_tech: %d\n",
trf->state, trf->md_rf_tech);
@@ -1974,7 +1975,7 @@ static void trf7970a_shutdown(struct trf7970a *trf)
trf7970a_power_down(trf);
}

-static int trf7970a_get_autosuspend_delay(struct device_node *np)
+static int trf7970a_get_autosuspend_delay(const struct device_node *np)
{
int autosuspend_delay, ret;

@@ -1987,7 +1988,7 @@ static int trf7970a_get_autosuspend_delay(struct device_node *np)

static int trf7970a_probe(struct spi_device *spi)
{
- struct device_node *np = spi->dev.of_node;
+ const struct device_node *np = spi->dev.of_node;
struct trf7970a *trf;
int uvolts, autosuspend_delay, ret;
u32 clk_freq = TRF7970A_13MHZ_CLOCK_FREQUENCY;
--
2.27.0