Skip to content

Commit f025336

Browse files
geertugregkh
authored andcommitted
memory: renesas-rpc-if: Pass device instead of rpcif to rpcif_*()
[ Upstream commit a198fcd ] Most rpcif_*() API functions do not need access to any other fields in the rpcif structure than the device pointer. Simplify dependencies by passing the device pointer instead. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Acked-by: Miquel Raynal <miquel.raynal@bootlin.com> Acked-by: Mark Brown <broonie@kernel.org> Acked-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Link: https://lore.kernel.org/r/0460fe82ba348cedec7a9a75a8eff762c50e817b.1669213027.git.geert+renesas@glider.be Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Stable-dep-of: 7d18957 ("mtd: hyperbus: rpc-if: Add missing MODULE_DEVICE_TABLE") Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent f7ef1b9 commit f025336

4 files changed

Lines changed: 40 additions & 40 deletions

File tree

drivers/memory/renesas-rpc-if.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -299,13 +299,13 @@ static void rpcif_rzg2l_timing_adjust_sdr(struct rpcif_priv *rpc)
299299
regmap_write(rpc->regmap, RPCIF_PHYADD, 0x80000032);
300300
}
301301

302-
int rpcif_hw_init(struct rpcif *rpcif, bool hyperflash)
302+
int rpcif_hw_init(struct device *dev, bool hyperflash)
303303
{
304-
struct rpcif_priv *rpc = dev_get_drvdata(rpcif->dev);
304+
struct rpcif_priv *rpc = dev_get_drvdata(dev);
305305
u32 dummy;
306306
int ret;
307307

308-
ret = pm_runtime_resume_and_get(rpc->dev);
308+
ret = pm_runtime_resume_and_get(dev);
309309
if (ret)
310310
return ret;
311311

@@ -355,7 +355,7 @@ int rpcif_hw_init(struct rpcif *rpcif, bool hyperflash)
355355
regmap_write(rpc->regmap, RPCIF_SSLDR, RPCIF_SSLDR_SPNDL(7) |
356356
RPCIF_SSLDR_SLNDL(7) | RPCIF_SSLDR_SCKDL(7));
357357

358-
pm_runtime_put(rpc->dev);
358+
pm_runtime_put(dev);
359359

360360
rpc->bus_size = hyperflash ? 2 : 1;
361361

@@ -385,10 +385,10 @@ static u8 rpcif_bit_size(u8 buswidth)
385385
return buswidth > 4 ? 2 : ilog2(buswidth);
386386
}
387387

388-
void rpcif_prepare(struct rpcif *rpcif, const struct rpcif_op *op, u64 *offs,
388+
void rpcif_prepare(struct device *dev, const struct rpcif_op *op, u64 *offs,
389389
size_t *len)
390390
{
391-
struct rpcif_priv *rpc = dev_get_drvdata(rpcif->dev);
391+
struct rpcif_priv *rpc = dev_get_drvdata(dev);
392392

393393
rpc->smcr = 0;
394394
rpc->smadr = 0;
@@ -473,13 +473,13 @@ void rpcif_prepare(struct rpcif *rpcif, const struct rpcif_op *op, u64 *offs,
473473
}
474474
EXPORT_SYMBOL(rpcif_prepare);
475475

476-
int rpcif_manual_xfer(struct rpcif *rpcif)
476+
int rpcif_manual_xfer(struct device *dev)
477477
{
478-
struct rpcif_priv *rpc = dev_get_drvdata(rpcif->dev);
478+
struct rpcif_priv *rpc = dev_get_drvdata(dev);
479479
u32 smenr, smcr, pos = 0, max = rpc->bus_size == 2 ? 8 : 4;
480480
int ret = 0;
481481

482-
ret = pm_runtime_resume_and_get(rpc->dev);
482+
ret = pm_runtime_resume_and_get(dev);
483483
if (ret < 0)
484484
return ret;
485485

@@ -591,13 +591,13 @@ int rpcif_manual_xfer(struct rpcif *rpcif)
591591
}
592592

593593
exit:
594-
pm_runtime_put(rpc->dev);
594+
pm_runtime_put(dev);
595595
return ret;
596596

597597
err_out:
598598
if (reset_control_reset(rpc->rstc))
599-
dev_err(rpc->dev, "Failed to reset HW\n");
600-
rpcif_hw_init(rpcif, rpc->bus_size == 2);
599+
dev_err(dev, "Failed to reset HW\n");
600+
rpcif_hw_init(dev, rpc->bus_size == 2);
601601
goto exit;
602602
}
603603
EXPORT_SYMBOL(rpcif_manual_xfer);
@@ -644,17 +644,17 @@ static void memcpy_fromio_readw(void *to,
644644
}
645645
}
646646

647-
ssize_t rpcif_dirmap_read(struct rpcif *rpcif, u64 offs, size_t len, void *buf)
647+
ssize_t rpcif_dirmap_read(struct device *dev, u64 offs, size_t len, void *buf)
648648
{
649-
struct rpcif_priv *rpc = dev_get_drvdata(rpcif->dev);
649+
struct rpcif_priv *rpc = dev_get_drvdata(dev);
650650
loff_t from = offs & (rpc->size - 1);
651651
size_t size = rpc->size - from;
652652
int ret;
653653

654654
if (len > size)
655655
len = size;
656656

657-
ret = pm_runtime_resume_and_get(rpc->dev);
657+
ret = pm_runtime_resume_and_get(dev);
658658
if (ret < 0)
659659
return ret;
660660

@@ -674,7 +674,7 @@ ssize_t rpcif_dirmap_read(struct rpcif *rpcif, u64 offs, size_t len, void *buf)
674674
else
675675
memcpy_fromio(buf, rpc->dirmap + from, len);
676676

677-
pm_runtime_put(rpc->dev);
677+
pm_runtime_put(dev);
678678

679679
return len;
680680
}

drivers/mtd/hyperbus/rpc-if.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ static void rpcif_hb_prepare_read(struct rpcif *rpc, void *to,
5656
op.data.nbytes = len;
5757
op.data.buf.in = to;
5858

59-
rpcif_prepare(rpc, &op, NULL, NULL);
59+
rpcif_prepare(rpc->dev, &op, NULL, NULL);
6060
}
6161

6262
static void rpcif_hb_prepare_write(struct rpcif *rpc, unsigned long to,
@@ -70,7 +70,7 @@ static void rpcif_hb_prepare_write(struct rpcif *rpc, unsigned long to,
7070
op.data.nbytes = len;
7171
op.data.buf.out = from;
7272

73-
rpcif_prepare(rpc, &op, NULL, NULL);
73+
rpcif_prepare(rpc->dev, &op, NULL, NULL);
7474
}
7575

7676
static u16 rpcif_hb_read16(struct hyperbus_device *hbdev, unsigned long addr)
@@ -81,7 +81,7 @@ static u16 rpcif_hb_read16(struct hyperbus_device *hbdev, unsigned long addr)
8181

8282
rpcif_hb_prepare_read(&hyperbus->rpc, &data, addr, 2);
8383

84-
rpcif_manual_xfer(&hyperbus->rpc);
84+
rpcif_manual_xfer(hyperbus->rpc.dev);
8585

8686
return data.x[0];
8787
}
@@ -94,7 +94,7 @@ static void rpcif_hb_write16(struct hyperbus_device *hbdev, unsigned long addr,
9494

9595
rpcif_hb_prepare_write(&hyperbus->rpc, addr, &data, 2);
9696

97-
rpcif_manual_xfer(&hyperbus->rpc);
97+
rpcif_manual_xfer(hyperbus->rpc.dev);
9898
}
9999

100100
static void rpcif_hb_copy_from(struct hyperbus_device *hbdev, void *to,
@@ -105,7 +105,7 @@ static void rpcif_hb_copy_from(struct hyperbus_device *hbdev, void *to,
105105

106106
rpcif_hb_prepare_read(&hyperbus->rpc, to, from, len);
107107

108-
rpcif_dirmap_read(&hyperbus->rpc, from, len, to);
108+
rpcif_dirmap_read(hyperbus->rpc.dev, from, len, to);
109109
}
110110

111111
static const struct hyperbus_ops rpcif_hb_ops = {
@@ -130,9 +130,9 @@ static int rpcif_hb_probe(struct platform_device *pdev)
130130

131131
platform_set_drvdata(pdev, hyperbus);
132132

133-
rpcif_enable_rpm(&hyperbus->rpc);
133+
rpcif_enable_rpm(hyperbus->rpc.dev);
134134

135-
error = rpcif_hw_init(&hyperbus->rpc, true);
135+
error = rpcif_hw_init(hyperbus->rpc.dev, true);
136136
if (error)
137137
goto out_disable_rpm;
138138

@@ -150,7 +150,7 @@ static int rpcif_hb_probe(struct platform_device *pdev)
150150
return 0;
151151

152152
out_disable_rpm:
153-
rpcif_disable_rpm(&hyperbus->rpc);
153+
rpcif_disable_rpm(hyperbus->rpc.dev);
154154
return error;
155155
}
156156

@@ -160,7 +160,7 @@ static int rpcif_hb_remove(struct platform_device *pdev)
160160

161161
hyperbus_unregister_device(&hyperbus->hbdev);
162162

163-
rpcif_disable_rpm(&hyperbus->rpc);
163+
rpcif_disable_rpm(hyperbus->rpc.dev);
164164

165165
return 0;
166166
}

drivers/spi/spi-rpc-if.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ static void rpcif_spi_mem_prepare(struct spi_device *spi_dev,
5858
rpc_op.data.dir = RPCIF_NO_DATA;
5959
}
6060

61-
rpcif_prepare(rpc, &rpc_op, offs, len);
61+
rpcif_prepare(rpc->dev, &rpc_op, offs, len);
6262
}
6363

6464
static bool rpcif_spi_mem_supports_op(struct spi_mem *mem,
@@ -86,7 +86,7 @@ static ssize_t rpcif_spi_mem_dirmap_read(struct spi_mem_dirmap_desc *desc,
8686

8787
rpcif_spi_mem_prepare(desc->mem->spi, &desc->info.op_tmpl, &offs, &len);
8888

89-
return rpcif_dirmap_read(rpc, offs, len, buf);
89+
return rpcif_dirmap_read(rpc->dev, offs, len, buf);
9090
}
9191

9292
static int rpcif_spi_mem_dirmap_create(struct spi_mem_dirmap_desc *desc)
@@ -117,7 +117,7 @@ static int rpcif_spi_mem_exec_op(struct spi_mem *mem,
117117

118118
rpcif_spi_mem_prepare(mem->spi, op, NULL, NULL);
119119

120-
return rpcif_manual_xfer(rpc);
120+
return rpcif_manual_xfer(rpc->dev);
121121
}
122122

123123
static const struct spi_controller_mem_ops rpcif_spi_mem_ops = {
@@ -147,7 +147,7 @@ static int rpcif_spi_probe(struct platform_device *pdev)
147147

148148
ctlr->dev.of_node = parent->of_node;
149149

150-
rpcif_enable_rpm(rpc);
150+
rpcif_enable_rpm(rpc->dev);
151151

152152
ctlr->num_chipselect = 1;
153153
ctlr->mem_ops = &rpcif_spi_mem_ops;
@@ -156,7 +156,7 @@ static int rpcif_spi_probe(struct platform_device *pdev)
156156
ctlr->mode_bits = SPI_CPOL | SPI_CPHA | SPI_TX_QUAD | SPI_RX_QUAD;
157157
ctlr->flags = SPI_CONTROLLER_HALF_DUPLEX;
158158

159-
error = rpcif_hw_init(rpc, false);
159+
error = rpcif_hw_init(rpc->dev, false);
160160
if (error)
161161
goto out_disable_rpm;
162162

@@ -169,7 +169,7 @@ static int rpcif_spi_probe(struct platform_device *pdev)
169169
return 0;
170170

171171
out_disable_rpm:
172-
rpcif_disable_rpm(rpc);
172+
rpcif_disable_rpm(rpc->dev);
173173
return error;
174174
}
175175

@@ -179,7 +179,7 @@ static int rpcif_spi_remove(struct platform_device *pdev)
179179
struct rpcif *rpc = spi_controller_get_devdata(ctlr);
180180

181181
spi_unregister_controller(ctlr);
182-
rpcif_disable_rpm(rpc);
182+
rpcif_disable_rpm(rpc->dev);
183183

184184
return 0;
185185
}

include/memory/renesas-rpc-if.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,20 +69,20 @@ struct rpcif {
6969
};
7070

7171
int rpcif_sw_init(struct rpcif *rpc, struct device *dev);
72-
int rpcif_hw_init(struct rpcif *rpc, bool hyperflash);
73-
void rpcif_prepare(struct rpcif *rpc, const struct rpcif_op *op, u64 *offs,
72+
int rpcif_hw_init(struct device *dev, bool hyperflash);
73+
void rpcif_prepare(struct device *dev, const struct rpcif_op *op, u64 *offs,
7474
size_t *len);
75-
int rpcif_manual_xfer(struct rpcif *rpc);
76-
ssize_t rpcif_dirmap_read(struct rpcif *rpc, u64 offs, size_t len, void *buf);
75+
int rpcif_manual_xfer(struct device *dev);
76+
ssize_t rpcif_dirmap_read(struct device *dev, u64 offs, size_t len, void *buf);
7777

78-
static inline void rpcif_enable_rpm(struct rpcif *rpc)
78+
static inline void rpcif_enable_rpm(struct device *dev)
7979
{
80-
pm_runtime_enable(rpc->dev);
80+
pm_runtime_enable(dev);
8181
}
8282

83-
static inline void rpcif_disable_rpm(struct rpcif *rpc)
83+
static inline void rpcif_disable_rpm(struct device *dev)
8484
{
85-
pm_runtime_disable(rpc->dev);
85+
pm_runtime_disable(dev);
8686
}
8787

8888
#endif // __RENESAS_RPC_IF_H

0 commit comments

Comments
 (0)