* [PATCH] spi: orion: cosmetics - alias long direct_access variables
@ 2018-08-06 18:51 Kosta Zertsekel
2018-08-06 19:09 ` Andrew Lunn
0 siblings, 1 reply; 3+ messages in thread
From: Kosta Zertsekel @ 2018-08-06 18:51 UTC (permalink / raw)
To: Mark Brown, Andrew Lunn, linux-spi, linux-kernel
Cc: Kosta Zertsekel, Jan Kundrát, Stefan Roese, Ken Wilson
This change increases the source code readability.
Instead of using `spi->child[cs].direct_access.XXX` use `dacc->XXX`.
Instead of using `orion_spi->child[cs].direct_access.vaddr` use `vaddr`.
Signed-off-by: Kosta Zertsekel <zertsekel@gmail.com>
---
drivers/spi/spi-orion.c | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/drivers/spi/spi-orion.c b/drivers/spi/spi-orion.c
index d01a6adc726e..1d6272fe5a34 100644
--- a/drivers/spi/spi-orion.c
+++ b/drivers/spi/spi-orion.c
@@ -430,6 +430,7 @@ orion_spi_write_read(struct spi_device *spi, struct spi_transfer *xfer)
int word_len;
struct orion_spi *orion_spi;
int cs = spi->chip_select;
+ void __iomem *vaddr;
word_len = spi->bits_per_word;
count = xfer->len;
@@ -440,8 +441,9 @@ orion_spi_write_read(struct spi_device *spi, struct spi_transfer *xfer)
* Use SPI direct write mode if base address is available. Otherwise
* fall back to PIO mode for this transfer.
*/
- if ((orion_spi->child[cs].direct_access.vaddr) && (xfer->tx_buf) &&
- (word_len == 8)) {
+ vaddr = orion_spi->child[cs].direct_access.vaddr;
+
+ if (vaddr && xfer->tx_buf && word_len == 8) {
unsigned int cnt = count / 4;
unsigned int rem = count % 4;
@@ -449,13 +451,11 @@ orion_spi_write_read(struct spi_device *spi, struct spi_transfer *xfer)
* Send the TX-data to the SPI device via the direct
* mapped address window
*/
- iowrite32_rep(orion_spi->child[cs].direct_access.vaddr,
- xfer->tx_buf, cnt);
+ iowrite32_rep(vaddr, xfer->tx_buf, cnt);
if (rem) {
u32 *buf = (u32 *)xfer->tx_buf;
- iowrite8_rep(orion_spi->child[cs].direct_access.vaddr,
- &buf[cnt], rem);
+ iowrite8_rep(vaddr, &buf[cnt], rem);
}
return count;
@@ -683,6 +683,7 @@ static int orion_spi_probe(struct platform_device *pdev)
/* Scan all SPI devices of this controller for direct mapped devices */
for_each_available_child_of_node(pdev->dev.of_node, np) {
+ struct orion_direct_acc *dacc;
u32 cs;
/* Get chip-select number from the "reg" property */
@@ -711,14 +712,13 @@ static int orion_spi_probe(struct platform_device *pdev)
* This needs to get extended for the direct SPI-NOR / SPI-NAND
* support, once this gets implemented.
*/
- spi->child[cs].direct_access.vaddr = devm_ioremap(&pdev->dev,
- r->start,
- PAGE_SIZE);
- if (!spi->child[cs].direct_access.vaddr) {
+ dacc = &spi->child[cs].direct_access;
+ dacc->vaddr = devm_ioremap(&pdev->dev, r->start, PAGE_SIZE);
+ if (!dacc->vaddr) {
status = -ENOMEM;
goto out_rel_axi_clk;
}
- spi->child[cs].direct_access.size = PAGE_SIZE;
+ dacc->size = PAGE_SIZE;
dev_info(&pdev->dev, "CS%d configured for direct access\n", cs);
}
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] spi: orion: cosmetics - alias long direct_access variables
2018-08-06 18:51 [PATCH] spi: orion: cosmetics - alias long direct_access variables Kosta Zertsekel
@ 2018-08-06 19:09 ` Andrew Lunn
2018-08-06 19:27 ` Kosta Zertsekel
0 siblings, 1 reply; 3+ messages in thread
From: Andrew Lunn @ 2018-08-06 19:09 UTC (permalink / raw)
To: Kosta Zertsekel
Cc: Mark Brown, linux-spi, linux-kernel, Jan Kundrát,
Stefan Roese, Ken Wilson
> @@ -683,6 +683,7 @@ static int orion_spi_probe(struct platform_device *pdev)
>
> /* Scan all SPI devices of this controller for direct mapped devices */
> for_each_available_child_of_node(pdev->dev.of_node, np) {
> + struct orion_direct_acc *dacc;
I would prefer direct_access, but it looks like this is too long to
put the devm_ioremap on one line. But it should be enough to fix the
odd indentation of r->start and PAGE_SIZE.
Andrew
> u32 cs;
>
> /* Get chip-select number from the "reg" property */
> @@ -711,14 +712,13 @@ static int orion_spi_probe(struct platform_device *pdev)
> * This needs to get extended for the direct SPI-NOR / SPI-NAND
> * support, once this gets implemented.
> */
> - spi->child[cs].direct_access.vaddr = devm_ioremap(&pdev->dev,
> - r->start,
> - PAGE_SIZE);
> - if (!spi->child[cs].direct_access.vaddr) {
> + dacc = &spi->child[cs].direct_access;
> + dacc->vaddr = devm_ioremap(&pdev->dev, r->start, PAGE_SIZE);
> + if (!dacc->vaddr) {
> status = -ENOMEM;
> goto out_rel_axi_clk;
> }
> - spi->child[cs].direct_access.size = PAGE_SIZE;
> + dacc->size = PAGE_SIZE;
>
> dev_info(&pdev->dev, "CS%d configured for direct access\n", cs);
> }
> --
> 2.17.1
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] spi: orion: cosmetics - alias long direct_access variables
2018-08-06 19:09 ` Andrew Lunn
@ 2018-08-06 19:27 ` Kosta Zertsekel
0 siblings, 0 replies; 3+ messages in thread
From: Kosta Zertsekel @ 2018-08-06 19:27 UTC (permalink / raw)
To: Andrew Lunn
Cc: Mark Brown, linux-spi, linux-kernel, Jan Kundrát,
Stefan Roese, Ken Wilson
On Mon, Aug 6, 2018 at 10:09 PM Andrew Lunn <andrew@lunn.ch> wrote:
>> @@ -683,6 +683,7 @@ static int orion_spi_probe(struct platform_device *pdev)
>>
>> /* Scan all SPI devices of this controller for direct mapped devices */
>> for_each_available_child_of_node(pdev->dev.of_node, np) {
>> + struct orion_direct_acc *dacc;
>
> I would prefer direct_access, but it looks like this is too long to
> put the devm_ioremap on one line. But it should be enough to fix the
> odd indentation of r->start and PAGE_SIZE.
Actually, the longest possible name to put devm_ioremap on one line is
`dir_acc`.
I think `dir_acc` is readable enough to ring the `direct_access` in
the mind of a reader.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-08-06 19:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-06 18:51 [PATCH] spi: orion: cosmetics - alias long direct_access variables Kosta Zertsekel
2018-08-06 19:09 ` Andrew Lunn
2018-08-06 19:27 ` Kosta Zertsekel
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.