* [PATCH 0/5] spi: rspi: cleanups
@ 2013-12-24 9:49 ` Geert Uytterhoeven
0 siblings, 0 replies; 23+ messages in thread
From: Geert Uytterhoeven @ 2013-12-24 9:49 UTC (permalink / raw)
To: Mark Brown; +Cc: linux-spi, linux-sh
Hi Mark,
This is a series of small cleanups for the Renesas RSPI driver:
[1/5] spi: rspi: Use dev_get_platdata() instead of raw
[2/5] spi: rspi: Remove casts
[3/5] spi: rspi: Make more pointers const
[4/5] spi: rspi: Use DUMMY_DATA macro instead of hardcoded
[5/5] spi: rspi: Use u8 for 8-bit register values
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH 0/5] spi: rspi: cleanups
@ 2013-12-24 9:49 ` Geert Uytterhoeven
0 siblings, 0 replies; 23+ messages in thread
From: Geert Uytterhoeven @ 2013-12-24 9:49 UTC (permalink / raw)
To: Mark Brown; +Cc: linux-spi, linux-sh
Hi Mark,
This is a series of small cleanups for the Renesas RSPI driver:
[1/5] spi: rspi: Use dev_get_platdata() instead of raw
[2/5] spi: rspi: Remove casts
[3/5] spi: rspi: Make more pointers const
[4/5] spi: rspi: Use DUMMY_DATA macro instead of hardcoded
[5/5] spi: rspi: Use u8 for 8-bit register values
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH 1/5] spi: rspi: Use dev_get_platdata() instead of raw dev.platform_data access
[not found] ` <1387878574-21445-1-git-send-email-geert+renesas-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org>
@ 2013-12-24 9:49 ` Geert Uytterhoeven
2013-12-24 9:49 ` Geert Uytterhoeven
` (3 subsequent siblings)
4 siblings, 0 replies; 23+ messages in thread
From: Geert Uytterhoeven @ 2013-12-24 9:49 UTC (permalink / raw)
To: Mark Brown
Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA,
linux-sh-u79uwXL29TY76Z2rM5mHXA, Geert Uytterhoeven
Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org>
---
drivers/spi/spi-rspi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/spi/spi-rspi.c b/drivers/spi/spi-rspi.c
index b04835d809f5..08861b5db893 100644
--- a/drivers/spi/spi-rspi.c
+++ b/drivers/spi/spi-rspi.c
@@ -899,7 +899,7 @@ static int rspi_probe(struct platform_device *pdev)
struct rspi_data *rspi;
int ret, irq;
char clk_name[16];
- struct rspi_plat_data *rspi_pd = pdev->dev.platform_data;
+ struct rspi_plat_data *rspi_pd = dev_get_platdata(&pdev->dev);
const struct spi_ops *ops;
const struct platform_device_id *id_entry = pdev->id_entry;
--
1.7.9.5
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH 1/5] spi: rspi: Use dev_get_platdata() instead of raw dev.platform_data access
@ 2013-12-24 9:49 ` Geert Uytterhoeven
0 siblings, 0 replies; 23+ messages in thread
From: Geert Uytterhoeven @ 2013-12-24 9:49 UTC (permalink / raw)
To: Mark Brown
Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA,
linux-sh-u79uwXL29TY76Z2rM5mHXA, Geert Uytterhoeven
Signed-off-by: Geert Uytterhoeven <geert+renesas-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org>
---
drivers/spi/spi-rspi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/spi/spi-rspi.c b/drivers/spi/spi-rspi.c
index b04835d809f5..08861b5db893 100644
--- a/drivers/spi/spi-rspi.c
+++ b/drivers/spi/spi-rspi.c
@@ -899,7 +899,7 @@ static int rspi_probe(struct platform_device *pdev)
struct rspi_data *rspi;
int ret, irq;
char clk_name[16];
- struct rspi_plat_data *rspi_pd = pdev->dev.platform_data;
+ struct rspi_plat_data *rspi_pd = dev_get_platdata(&pdev->dev);
const struct spi_ops *ops;
const struct platform_device_id *id_entry = pdev->id_entry;
--
1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH 2/5] spi: rspi: Remove casts
[not found] ` <1387878574-21445-1-git-send-email-geert+renesas-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org>
@ 2013-12-24 9:49 ` Geert Uytterhoeven
2013-12-24 9:49 ` Geert Uytterhoeven
` (3 subsequent siblings)
4 siblings, 0 replies; 23+ messages in thread
From: Geert Uytterhoeven @ 2013-12-24 9:49 UTC (permalink / raw)
To: Mark Brown
Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA,
linux-sh-u79uwXL29TY76Z2rM5mHXA, Geert Uytterhoeven
Remove useless casts, and do not cast away const.
Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org>
---
drivers/spi/spi-rspi.c | 29 ++++++++++++++---------------
1 file changed, 14 insertions(+), 15 deletions(-)
diff --git a/drivers/spi/spi-rspi.c b/drivers/spi/spi-rspi.c
index 08861b5db893..a0038687a8fd 100644
--- a/drivers/spi/spi-rspi.c
+++ b/drivers/spi/spi-rspi.c
@@ -330,9 +330,7 @@ static int rspi_send_pio(struct rspi_data *rspi, struct spi_message *mesg,
struct spi_transfer *t)
{
int remain = t->len;
- u8 *data;
-
- data = (u8 *)t->tx_buf;
+ const u8 *data = t->tx_buf;
while (remain > 0) {
rspi_write8(rspi, rspi_read8(rspi, RSPI_SPCR) | SPCR_TXMD,
RSPI_SPCR);
@@ -358,12 +356,11 @@ static int qspi_send_pio(struct rspi_data *rspi, struct spi_message *mesg,
struct spi_transfer *t)
{
int remain = t->len;
- u8 *data;
+ const u8 *data = t->tx_buf;
rspi_write8(rspi, SPBFCR_TXRST, QSPI_SPBFCR);
rspi_write8(rspi, 0x00, QSPI_SPBFCR);
- data = (u8 *)t->tx_buf;
while (remain > 0) {
if (rspi_wait_for_interrupt(rspi, SPSR_SPTEF, SPCR_SPTIE) < 0) {
@@ -399,8 +396,8 @@ static void rspi_dma_complete(void *arg)
wake_up_interruptible(&rspi->wait);
}
-static int rspi_dma_map_sg(struct scatterlist *sg, void *buf, unsigned len,
- struct dma_chan *chan,
+static int rspi_dma_map_sg(struct scatterlist *sg, const void *buf,
+ unsigned len, struct dma_chan *chan,
enum dma_transfer_direction dir)
{
sg_init_table(sg, 1);
@@ -440,12 +437,13 @@ static void rspi_memory_from_8bit(void *buf, const void *data, unsigned len)
static int rspi_send_dma(struct rspi_data *rspi, struct spi_transfer *t)
{
struct scatterlist sg;
- void *buf = NULL;
+ const void *buf = NULL;
struct dma_async_tx_descriptor *desc;
unsigned len;
int ret = 0;
if (rspi->dma_width_16bit) {
+ void *tmp;
/*
* If DMAC bus width is 16-bit, the driver allocates a dummy
* buffer. And, the driver converts original data into the
@@ -454,13 +452,14 @@ static int rspi_send_dma(struct rspi_data *rspi, struct spi_transfer *t)
* DMAC data: 1st byte, dummy, 2nd byte, dummy ...
*/
len = t->len * 2;
- buf = kmalloc(len, GFP_KERNEL);
- if (!buf)
+ tmp = kmalloc(len, GFP_KERNEL);
+ if (!tmp)
return -ENOMEM;
- rspi_memory_to_8bit(buf, t->tx_buf, t->len);
+ rspi_memory_to_8bit(tmp, t->tx_buf, t->len);
+ buf = tmp;
} else {
len = t->len;
- buf = (void *)t->tx_buf;
+ buf = t->tx_buf;
}
if (!rspi_dma_map_sg(&sg, buf, len, rspi->chan_tx, DMA_TO_DEVICE)) {
@@ -528,7 +527,7 @@ static int rspi_receive_pio(struct rspi_data *rspi, struct spi_message *mesg,
rspi_receive_init(rspi);
- data = (u8 *)t->rx_buf;
+ data = t->rx_buf;
while (remain > 0) {
rspi_write8(rspi, rspi_read8(rspi, RSPI_SPCR) & ~SPCR_TXMD,
RSPI_SPCR);
@@ -575,7 +574,7 @@ static int qspi_receive_pio(struct rspi_data *rspi, struct spi_message *mesg,
qspi_receive_init(rspi);
- data = (u8 *)t->rx_buf;
+ data = t->rx_buf;
while (remain > 0) {
if (rspi_wait_for_interrupt(rspi, SPSR_SPTEF, SPCR_SPTIE) < 0) {
@@ -802,7 +801,7 @@ static void rspi_cleanup(struct spi_device *spi)
static irqreturn_t rspi_irq(int irq, void *_sr)
{
- struct rspi_data *rspi = (struct rspi_data *)_sr;
+ struct rspi_data *rspi = _sr;
unsigned long spsr;
irqreturn_t ret = IRQ_NONE;
unsigned char disable_irq = 0;
--
1.7.9.5
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH 2/5] spi: rspi: Remove casts
@ 2013-12-24 9:49 ` Geert Uytterhoeven
0 siblings, 0 replies; 23+ messages in thread
From: Geert Uytterhoeven @ 2013-12-24 9:49 UTC (permalink / raw)
To: Mark Brown
Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA,
linux-sh-u79uwXL29TY76Z2rM5mHXA, Geert Uytterhoeven
Remove useless casts, and do not cast away const.
Signed-off-by: Geert Uytterhoeven <geert+renesas-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org>
---
drivers/spi/spi-rspi.c | 29 ++++++++++++++---------------
1 file changed, 14 insertions(+), 15 deletions(-)
diff --git a/drivers/spi/spi-rspi.c b/drivers/spi/spi-rspi.c
index 08861b5db893..a0038687a8fd 100644
--- a/drivers/spi/spi-rspi.c
+++ b/drivers/spi/spi-rspi.c
@@ -330,9 +330,7 @@ static int rspi_send_pio(struct rspi_data *rspi, struct spi_message *mesg,
struct spi_transfer *t)
{
int remain = t->len;
- u8 *data;
-
- data = (u8 *)t->tx_buf;
+ const u8 *data = t->tx_buf;
while (remain > 0) {
rspi_write8(rspi, rspi_read8(rspi, RSPI_SPCR) | SPCR_TXMD,
RSPI_SPCR);
@@ -358,12 +356,11 @@ static int qspi_send_pio(struct rspi_data *rspi, struct spi_message *mesg,
struct spi_transfer *t)
{
int remain = t->len;
- u8 *data;
+ const u8 *data = t->tx_buf;
rspi_write8(rspi, SPBFCR_TXRST, QSPI_SPBFCR);
rspi_write8(rspi, 0x00, QSPI_SPBFCR);
- data = (u8 *)t->tx_buf;
while (remain > 0) {
if (rspi_wait_for_interrupt(rspi, SPSR_SPTEF, SPCR_SPTIE) < 0) {
@@ -399,8 +396,8 @@ static void rspi_dma_complete(void *arg)
wake_up_interruptible(&rspi->wait);
}
-static int rspi_dma_map_sg(struct scatterlist *sg, void *buf, unsigned len,
- struct dma_chan *chan,
+static int rspi_dma_map_sg(struct scatterlist *sg, const void *buf,
+ unsigned len, struct dma_chan *chan,
enum dma_transfer_direction dir)
{
sg_init_table(sg, 1);
@@ -440,12 +437,13 @@ static void rspi_memory_from_8bit(void *buf, const void *data, unsigned len)
static int rspi_send_dma(struct rspi_data *rspi, struct spi_transfer *t)
{
struct scatterlist sg;
- void *buf = NULL;
+ const void *buf = NULL;
struct dma_async_tx_descriptor *desc;
unsigned len;
int ret = 0;
if (rspi->dma_width_16bit) {
+ void *tmp;
/*
* If DMAC bus width is 16-bit, the driver allocates a dummy
* buffer. And, the driver converts original data into the
@@ -454,13 +452,14 @@ static int rspi_send_dma(struct rspi_data *rspi, struct spi_transfer *t)
* DMAC data: 1st byte, dummy, 2nd byte, dummy ...
*/
len = t->len * 2;
- buf = kmalloc(len, GFP_KERNEL);
- if (!buf)
+ tmp = kmalloc(len, GFP_KERNEL);
+ if (!tmp)
return -ENOMEM;
- rspi_memory_to_8bit(buf, t->tx_buf, t->len);
+ rspi_memory_to_8bit(tmp, t->tx_buf, t->len);
+ buf = tmp;
} else {
len = t->len;
- buf = (void *)t->tx_buf;
+ buf = t->tx_buf;
}
if (!rspi_dma_map_sg(&sg, buf, len, rspi->chan_tx, DMA_TO_DEVICE)) {
@@ -528,7 +527,7 @@ static int rspi_receive_pio(struct rspi_data *rspi, struct spi_message *mesg,
rspi_receive_init(rspi);
- data = (u8 *)t->rx_buf;
+ data = t->rx_buf;
while (remain > 0) {
rspi_write8(rspi, rspi_read8(rspi, RSPI_SPCR) & ~SPCR_TXMD,
RSPI_SPCR);
@@ -575,7 +574,7 @@ static int qspi_receive_pio(struct rspi_data *rspi, struct spi_message *mesg,
qspi_receive_init(rspi);
- data = (u8 *)t->rx_buf;
+ data = t->rx_buf;
while (remain > 0) {
if (rspi_wait_for_interrupt(rspi, SPSR_SPTEF, SPCR_SPTIE) < 0) {
@@ -802,7 +801,7 @@ static void rspi_cleanup(struct spi_device *spi)
static irqreturn_t rspi_irq(int irq, void *_sr)
{
- struct rspi_data *rspi = (struct rspi_data *)_sr;
+ struct rspi_data *rspi = _sr;
unsigned long spsr;
irqreturn_t ret = IRQ_NONE;
unsigned char disable_irq = 0;
--
1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH 3/5] spi: rspi: Make more pointers const
2013-12-24 9:49 ` Geert Uytterhoeven
@ 2013-12-24 9:49 ` Geert Uytterhoeven
-1 siblings, 0 replies; 23+ messages in thread
From: Geert Uytterhoeven @ 2013-12-24 9:49 UTC (permalink / raw)
To: Mark Brown; +Cc: linux-spi, linux-sh, Geert Uytterhoeven
Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org>
---
drivers/spi/spi-rspi.c | 37 ++++++++++++++++++++-----------------
1 file changed, 20 insertions(+), 17 deletions(-)
diff --git a/drivers/spi/spi-rspi.c b/drivers/spi/spi-rspi.c
index a0038687a8fd..4e376db1ca4f 100644
--- a/drivers/spi/spi-rspi.c
+++ b/drivers/spi/spi-rspi.c
@@ -170,34 +170,35 @@ struct rspi_data {
unsigned dma_callbacked:1;
};
-static void rspi_write8(struct rspi_data *rspi, u8 data, u16 offset)
+static void rspi_write8(const struct rspi_data *rspi, u8 data, u16 offset)
{
iowrite8(data, rspi->addr + offset);
}
-static void rspi_write16(struct rspi_data *rspi, u16 data, u16 offset)
+static void rspi_write16(const struct rspi_data *rspi, u16 data, u16 offset)
{
iowrite16(data, rspi->addr + offset);
}
-static void rspi_write32(struct rspi_data *rspi, u32 data, u16 offset)
+static void rspi_write32(const struct rspi_data *rspi, u32 data, u16 offset)
{
iowrite32(data, rspi->addr + offset);
}
-static u8 rspi_read8(struct rspi_data *rspi, u16 offset)
+static u8 rspi_read8(const struct rspi_data *rspi, u16 offset)
{
return ioread8(rspi->addr + offset);
}
-static u16 rspi_read16(struct rspi_data *rspi, u16 offset)
+static u16 rspi_read16(const struct rspi_data *rspi, u16 offset)
{
return ioread16(rspi->addr + offset);
}
/* optional functions */
struct spi_ops {
- int (*set_config_register)(struct rspi_data *rspi, int access_size);
+ int (*set_config_register)(const struct rspi_data *rspi,
+ int access_size);
int (*send_pio)(struct rspi_data *rspi, struct spi_message *mesg,
struct spi_transfer *t);
int (*receive_pio)(struct rspi_data *rspi, struct spi_message *mesg,
@@ -208,7 +209,8 @@ struct spi_ops {
/*
* functions for RSPI
*/
-static int rspi_set_config_register(struct rspi_data *rspi, int access_size)
+static int rspi_set_config_register(const struct rspi_data *rspi,
+ int access_size)
{
int spbr;
@@ -243,7 +245,8 @@ static int rspi_set_config_register(struct rspi_data *rspi, int access_size)
/*
* functions for QSPI
*/
-static int qspi_set_config_register(struct rspi_data *rspi, int access_size)
+static int qspi_set_config_register(const struct rspi_data *rspi,
+ int access_size)
{
u16 spcmd;
int spbr;
@@ -292,12 +295,12 @@ static int qspi_set_config_register(struct rspi_data *rspi, int access_size)
#define set_config_register(spi, n) spi->ops->set_config_register(spi, n)
-static void rspi_enable_irq(struct rspi_data *rspi, u8 enable)
+static void rspi_enable_irq(const struct rspi_data *rspi, u8 enable)
{
rspi_write8(rspi, rspi_read8(rspi, RSPI_SPCR) | enable, RSPI_SPCR);
}
-static void rspi_disable_irq(struct rspi_data *rspi, u8 disable)
+static void rspi_disable_irq(const struct rspi_data *rspi, u8 disable)
{
rspi_write8(rspi, rspi_read8(rspi, RSPI_SPCR) & ~disable, RSPI_SPCR);
}
@@ -316,12 +319,12 @@ static int rspi_wait_for_interrupt(struct rspi_data *rspi, u8 wait_mask,
return 0;
}
-static void rspi_assert_ssl(struct rspi_data *rspi)
+static void rspi_assert_ssl(const struct rspi_data *rspi)
{
rspi_write8(rspi, rspi_read8(rspi, RSPI_SPCR) | SPCR_SPE, RSPI_SPCR);
}
-static void rspi_negate_ssl(struct rspi_data *rspi)
+static void rspi_negate_ssl(const struct rspi_data *rspi)
{
rspi_write8(rspi, rspi_read8(rspi, RSPI_SPCR) & ~SPCR_SPE, RSPI_SPCR);
}
@@ -507,7 +510,7 @@ end_nomap:
return ret;
}
-static void rspi_receive_init(struct rspi_data *rspi)
+static void rspi_receive_init(const struct rspi_data *rspi)
{
unsigned char spsr;
@@ -555,7 +558,7 @@ static int rspi_receive_pio(struct rspi_data *rspi, struct spi_message *mesg,
return 0;
}
-static void qspi_receive_init(struct rspi_data *rspi)
+static void qspi_receive_init(const struct rspi_data *rspi)
{
unsigned char spsr;
@@ -703,7 +706,7 @@ end_nomap:
return ret;
}
-static int rspi_is_dma(struct rspi_data *rspi, struct spi_transfer *t)
+static int rspi_is_dma(const struct rspi_data *rspi, struct spi_transfer *t)
{
if (t->tx_buf && rspi->chan_tx)
return 1;
@@ -824,7 +827,7 @@ static irqreturn_t rspi_irq(int irq, void *_sr)
static int rspi_request_dma(struct rspi_data *rspi,
struct platform_device *pdev)
{
- struct rspi_plat_data *rspi_pd = dev_get_platdata(&pdev->dev);
+ const struct rspi_plat_data *rspi_pd = dev_get_platdata(&pdev->dev);
struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
dma_cap_mask_t mask;
struct dma_slave_config cfg;
@@ -898,7 +901,7 @@ static int rspi_probe(struct platform_device *pdev)
struct rspi_data *rspi;
int ret, irq;
char clk_name[16];
- struct rspi_plat_data *rspi_pd = dev_get_platdata(&pdev->dev);
+ const struct rspi_plat_data *rspi_pd = dev_get_platdata(&pdev->dev);
const struct spi_ops *ops;
const struct platform_device_id *id_entry = pdev->id_entry;
--
1.7.9.5
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH 3/5] spi: rspi: Make more pointers const
@ 2013-12-24 9:49 ` Geert Uytterhoeven
0 siblings, 0 replies; 23+ messages in thread
From: Geert Uytterhoeven @ 2013-12-24 9:49 UTC (permalink / raw)
To: Mark Brown; +Cc: linux-spi, linux-sh, Geert Uytterhoeven
Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org>
---
drivers/spi/spi-rspi.c | 37 ++++++++++++++++++++-----------------
1 file changed, 20 insertions(+), 17 deletions(-)
diff --git a/drivers/spi/spi-rspi.c b/drivers/spi/spi-rspi.c
index a0038687a8fd..4e376db1ca4f 100644
--- a/drivers/spi/spi-rspi.c
+++ b/drivers/spi/spi-rspi.c
@@ -170,34 +170,35 @@ struct rspi_data {
unsigned dma_callbacked:1;
};
-static void rspi_write8(struct rspi_data *rspi, u8 data, u16 offset)
+static void rspi_write8(const struct rspi_data *rspi, u8 data, u16 offset)
{
iowrite8(data, rspi->addr + offset);
}
-static void rspi_write16(struct rspi_data *rspi, u16 data, u16 offset)
+static void rspi_write16(const struct rspi_data *rspi, u16 data, u16 offset)
{
iowrite16(data, rspi->addr + offset);
}
-static void rspi_write32(struct rspi_data *rspi, u32 data, u16 offset)
+static void rspi_write32(const struct rspi_data *rspi, u32 data, u16 offset)
{
iowrite32(data, rspi->addr + offset);
}
-static u8 rspi_read8(struct rspi_data *rspi, u16 offset)
+static u8 rspi_read8(const struct rspi_data *rspi, u16 offset)
{
return ioread8(rspi->addr + offset);
}
-static u16 rspi_read16(struct rspi_data *rspi, u16 offset)
+static u16 rspi_read16(const struct rspi_data *rspi, u16 offset)
{
return ioread16(rspi->addr + offset);
}
/* optional functions */
struct spi_ops {
- int (*set_config_register)(struct rspi_data *rspi, int access_size);
+ int (*set_config_register)(const struct rspi_data *rspi,
+ int access_size);
int (*send_pio)(struct rspi_data *rspi, struct spi_message *mesg,
struct spi_transfer *t);
int (*receive_pio)(struct rspi_data *rspi, struct spi_message *mesg,
@@ -208,7 +209,8 @@ struct spi_ops {
/*
* functions for RSPI
*/
-static int rspi_set_config_register(struct rspi_data *rspi, int access_size)
+static int rspi_set_config_register(const struct rspi_data *rspi,
+ int access_size)
{
int spbr;
@@ -243,7 +245,8 @@ static int rspi_set_config_register(struct rspi_data *rspi, int access_size)
/*
* functions for QSPI
*/
-static int qspi_set_config_register(struct rspi_data *rspi, int access_size)
+static int qspi_set_config_register(const struct rspi_data *rspi,
+ int access_size)
{
u16 spcmd;
int spbr;
@@ -292,12 +295,12 @@ static int qspi_set_config_register(struct rspi_data *rspi, int access_size)
#define set_config_register(spi, n) spi->ops->set_config_register(spi, n)
-static void rspi_enable_irq(struct rspi_data *rspi, u8 enable)
+static void rspi_enable_irq(const struct rspi_data *rspi, u8 enable)
{
rspi_write8(rspi, rspi_read8(rspi, RSPI_SPCR) | enable, RSPI_SPCR);
}
-static void rspi_disable_irq(struct rspi_data *rspi, u8 disable)
+static void rspi_disable_irq(const struct rspi_data *rspi, u8 disable)
{
rspi_write8(rspi, rspi_read8(rspi, RSPI_SPCR) & ~disable, RSPI_SPCR);
}
@@ -316,12 +319,12 @@ static int rspi_wait_for_interrupt(struct rspi_data *rspi, u8 wait_mask,
return 0;
}
-static void rspi_assert_ssl(struct rspi_data *rspi)
+static void rspi_assert_ssl(const struct rspi_data *rspi)
{
rspi_write8(rspi, rspi_read8(rspi, RSPI_SPCR) | SPCR_SPE, RSPI_SPCR);
}
-static void rspi_negate_ssl(struct rspi_data *rspi)
+static void rspi_negate_ssl(const struct rspi_data *rspi)
{
rspi_write8(rspi, rspi_read8(rspi, RSPI_SPCR) & ~SPCR_SPE, RSPI_SPCR);
}
@@ -507,7 +510,7 @@ end_nomap:
return ret;
}
-static void rspi_receive_init(struct rspi_data *rspi)
+static void rspi_receive_init(const struct rspi_data *rspi)
{
unsigned char spsr;
@@ -555,7 +558,7 @@ static int rspi_receive_pio(struct rspi_data *rspi, struct spi_message *mesg,
return 0;
}
-static void qspi_receive_init(struct rspi_data *rspi)
+static void qspi_receive_init(const struct rspi_data *rspi)
{
unsigned char spsr;
@@ -703,7 +706,7 @@ end_nomap:
return ret;
}
-static int rspi_is_dma(struct rspi_data *rspi, struct spi_transfer *t)
+static int rspi_is_dma(const struct rspi_data *rspi, struct spi_transfer *t)
{
if (t->tx_buf && rspi->chan_tx)
return 1;
@@ -824,7 +827,7 @@ static irqreturn_t rspi_irq(int irq, void *_sr)
static int rspi_request_dma(struct rspi_data *rspi,
struct platform_device *pdev)
{
- struct rspi_plat_data *rspi_pd = dev_get_platdata(&pdev->dev);
+ const struct rspi_plat_data *rspi_pd = dev_get_platdata(&pdev->dev);
struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
dma_cap_mask_t mask;
struct dma_slave_config cfg;
@@ -898,7 +901,7 @@ static int rspi_probe(struct platform_device *pdev)
struct rspi_data *rspi;
int ret, irq;
char clk_name[16];
- struct rspi_plat_data *rspi_pd = dev_get_platdata(&pdev->dev);
+ const struct rspi_plat_data *rspi_pd = dev_get_platdata(&pdev->dev);
const struct spi_ops *ops;
const struct platform_device_id *id_entry = pdev->id_entry;
--
1.7.9.5
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH 4/5] spi: rspi: Use DUMMY_DATA macro instead of hardcoded value
[not found] ` <1387878574-21445-1-git-send-email-geert+renesas-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org>
@ 2013-12-24 9:49 ` Geert Uytterhoeven
2013-12-24 9:49 ` Geert Uytterhoeven
` (3 subsequent siblings)
4 siblings, 0 replies; 23+ messages in thread
From: Geert Uytterhoeven @ 2013-12-24 9:49 UTC (permalink / raw)
To: Mark Brown
Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA,
linux-sh-u79uwXL29TY76Z2rM5mHXA, Geert Uytterhoeven
Make it more obvious that this value is dummy data.
Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org>
---
drivers/spi/spi-rspi.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/spi/spi-rspi.c b/drivers/spi/spi-rspi.c
index 4e376db1ca4f..51fe3bdacb18 100644
--- a/drivers/spi/spi-rspi.c
+++ b/drivers/spi/spi-rspi.c
@@ -149,6 +149,8 @@
#define SPBFCR_TXRST 0x80 /* qspi only */
#define SPBFCR_RXRST 0x40 /* qspi only */
+#define DUMMY_DATA 0x00
+
struct rspi_data {
void __iomem *addr;
u32 max_speed_hz;
@@ -541,7 +543,7 @@ static int rspi_receive_pio(struct rspi_data *rspi, struct spi_message *mesg,
return -ETIMEDOUT;
}
/* dummy write for generate clock */
- rspi_write16(rspi, 0x00, RSPI_SPDR);
+ rspi_write16(rspi, DUMMY_DATA, RSPI_SPDR);
if (rspi_wait_for_interrupt(rspi, SPSR_SPRF, SPCR_SPRIE) < 0) {
dev_err(&rspi->master->dev,
@@ -586,7 +588,7 @@ static int qspi_receive_pio(struct rspi_data *rspi, struct spi_message *mesg,
return -ETIMEDOUT;
}
/* dummy write for generate clock */
- rspi_write8(rspi, 0x00, RSPI_SPDR);
+ rspi_write8(rspi, DUMMY_DATA, RSPI_SPDR);
if (rspi_wait_for_interrupt(rspi, SPSR_SPRF, SPCR_SPRIE) < 0) {
dev_err(&rspi->master->dev,
--
1.7.9.5
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH 4/5] spi: rspi: Use DUMMY_DATA macro instead of hardcoded value
@ 2013-12-24 9:49 ` Geert Uytterhoeven
0 siblings, 0 replies; 23+ messages in thread
From: Geert Uytterhoeven @ 2013-12-24 9:49 UTC (permalink / raw)
To: Mark Brown
Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA,
linux-sh-u79uwXL29TY76Z2rM5mHXA, Geert Uytterhoeven
Make it more obvious that this value is dummy data.
Signed-off-by: Geert Uytterhoeven <geert+renesas-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org>
---
drivers/spi/spi-rspi.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/spi/spi-rspi.c b/drivers/spi/spi-rspi.c
index 4e376db1ca4f..51fe3bdacb18 100644
--- a/drivers/spi/spi-rspi.c
+++ b/drivers/spi/spi-rspi.c
@@ -149,6 +149,8 @@
#define SPBFCR_TXRST 0x80 /* qspi only */
#define SPBFCR_RXRST 0x40 /* qspi only */
+#define DUMMY_DATA 0x00
+
struct rspi_data {
void __iomem *addr;
u32 max_speed_hz;
@@ -541,7 +543,7 @@ static int rspi_receive_pio(struct rspi_data *rspi, struct spi_message *mesg,
return -ETIMEDOUT;
}
/* dummy write for generate clock */
- rspi_write16(rspi, 0x00, RSPI_SPDR);
+ rspi_write16(rspi, DUMMY_DATA, RSPI_SPDR);
if (rspi_wait_for_interrupt(rspi, SPSR_SPRF, SPCR_SPRIE) < 0) {
dev_err(&rspi->master->dev,
@@ -586,7 +588,7 @@ static int qspi_receive_pio(struct rspi_data *rspi, struct spi_message *mesg,
return -ETIMEDOUT;
}
/* dummy write for generate clock */
- rspi_write8(rspi, 0x00, RSPI_SPDR);
+ rspi_write8(rspi, DUMMY_DATA, RSPI_SPDR);
if (rspi_wait_for_interrupt(rspi, SPSR_SPRF, SPCR_SPRIE) < 0) {
dev_err(&rspi->master->dev,
--
1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH 5/5] spi: rspi: Use u8 for 8-bit register values
[not found] ` <1387878574-21445-1-git-send-email-geert+renesas-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org>
@ 2013-12-24 9:49 ` Geert Uytterhoeven
2013-12-24 9:49 ` Geert Uytterhoeven
` (3 subsequent siblings)
4 siblings, 0 replies; 23+ messages in thread
From: Geert Uytterhoeven @ 2013-12-24 9:49 UTC (permalink / raw)
To: Mark Brown
Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA,
linux-sh-u79uwXL29TY76Z2rM5mHXA, Geert Uytterhoeven
Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org>
---
drivers/spi/spi-rspi.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/spi/spi-rspi.c b/drivers/spi/spi-rspi.c
index 51fe3bdacb18..239354618eac 100644
--- a/drivers/spi/spi-rspi.c
+++ b/drivers/spi/spi-rspi.c
@@ -160,7 +160,7 @@ struct rspi_data {
wait_queue_head_t wait;
spinlock_t lock;
struct clk *clk;
- unsigned char spsr;
+ u8 spsr;
const struct spi_ops *ops;
/* for dmaengine */
@@ -514,7 +514,7 @@ end_nomap:
static void rspi_receive_init(const struct rspi_data *rspi)
{
- unsigned char spsr;
+ u8 spsr;
spsr = rspi_read8(rspi, RSPI_SPSR);
if (spsr & SPSR_SPRF)
@@ -562,7 +562,7 @@ static int rspi_receive_pio(struct rspi_data *rspi, struct spi_message *mesg,
static void qspi_receive_init(const struct rspi_data *rspi)
{
- unsigned char spsr;
+ u8 spsr;
spsr = rspi_read8(rspi, RSPI_SPSR);
if (spsr & SPSR_SPRF)
@@ -807,9 +807,9 @@ static void rspi_cleanup(struct spi_device *spi)
static irqreturn_t rspi_irq(int irq, void *_sr)
{
struct rspi_data *rspi = _sr;
- unsigned long spsr;
+ u8 spsr;
irqreturn_t ret = IRQ_NONE;
- unsigned char disable_irq = 0;
+ u8 disable_irq = 0;
rspi->spsr = spsr = rspi_read8(rspi, RSPI_SPSR);
if (spsr & SPSR_SPRF)
--
1.7.9.5
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH 5/5] spi: rspi: Use u8 for 8-bit register values
@ 2013-12-24 9:49 ` Geert Uytterhoeven
0 siblings, 0 replies; 23+ messages in thread
From: Geert Uytterhoeven @ 2013-12-24 9:49 UTC (permalink / raw)
To: Mark Brown
Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA,
linux-sh-u79uwXL29TY76Z2rM5mHXA, Geert Uytterhoeven
Signed-off-by: Geert Uytterhoeven <geert+renesas-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org>
---
drivers/spi/spi-rspi.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/spi/spi-rspi.c b/drivers/spi/spi-rspi.c
index 51fe3bdacb18..239354618eac 100644
--- a/drivers/spi/spi-rspi.c
+++ b/drivers/spi/spi-rspi.c
@@ -160,7 +160,7 @@ struct rspi_data {
wait_queue_head_t wait;
spinlock_t lock;
struct clk *clk;
- unsigned char spsr;
+ u8 spsr;
const struct spi_ops *ops;
/* for dmaengine */
@@ -514,7 +514,7 @@ end_nomap:
static void rspi_receive_init(const struct rspi_data *rspi)
{
- unsigned char spsr;
+ u8 spsr;
spsr = rspi_read8(rspi, RSPI_SPSR);
if (spsr & SPSR_SPRF)
@@ -562,7 +562,7 @@ static int rspi_receive_pio(struct rspi_data *rspi, struct spi_message *mesg,
static void qspi_receive_init(const struct rspi_data *rspi)
{
- unsigned char spsr;
+ u8 spsr;
spsr = rspi_read8(rspi, RSPI_SPSR);
if (spsr & SPSR_SPRF)
@@ -807,9 +807,9 @@ static void rspi_cleanup(struct spi_device *spi)
static irqreturn_t rspi_irq(int irq, void *_sr)
{
struct rspi_data *rspi = _sr;
- unsigned long spsr;
+ u8 spsr;
irqreturn_t ret = IRQ_NONE;
- unsigned char disable_irq = 0;
+ u8 disable_irq = 0;
rspi->spsr = spsr = rspi_read8(rspi, RSPI_SPSR);
if (spsr & SPSR_SPRF)
--
1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 23+ messages in thread
* Re: [PATCH 0/5] spi: rspi: cleanups
[not found] ` <1387878574-21445-1-git-send-email-geert+renesas-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org>
@ 2013-12-24 13:20 ` Mark Brown
2013-12-24 9:49 ` Geert Uytterhoeven
` (3 subsequent siblings)
4 siblings, 0 replies; 23+ messages in thread
From: Mark Brown @ 2013-12-24 13:20 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA, linux-sh-u79uwXL29TY76Z2rM5mHXA
On Tue, Dec 24, 2013 at 10:49:29AM +0100, Geert Uytterhoeven wrote:
> Hi Mark,
>
> This is a series of small cleanups for the Renesas RSPI driver:
Applied all, thanks.
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 0/5] spi: rspi: cleanups
@ 2013-12-24 13:20 ` Mark Brown
0 siblings, 0 replies; 23+ messages in thread
From: Mark Brown @ 2013-12-24 13:20 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA, linux-sh-u79uwXL29TY76Z2rM5mHXA
On Tue, Dec 24, 2013 at 10:49:29AM +0100, Geert Uytterhoeven wrote:
> Hi Mark,
>
> This is a series of small cleanups for the Renesas RSPI driver:
Applied all, thanks.
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 2/5] spi: rspi: Remove casts
2013-12-24 9:49 ` Geert Uytterhoeven
@ 2013-12-27 14:33 ` Laurent Pinchart
-1 siblings, 0 replies; 23+ messages in thread
From: Laurent Pinchart @ 2013-12-27 14:33 UTC (permalink / raw)
To: Geert Uytterhoeven; +Cc: Mark Brown, linux-spi, linux-sh
Hi Geert,
Thank you for the patch.
On Tuesday 24 December 2013 10:49:31 Geert Uytterhoeven wrote:
> Remove useless casts, and do not cast away const.
>
> Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org>
> ---
> drivers/spi/spi-rspi.c | 29 ++++++++++++++---------------
> 1 file changed, 14 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/spi/spi-rspi.c b/drivers/spi/spi-rspi.c
> index 08861b5db893..a0038687a8fd 100644
> --- a/drivers/spi/spi-rspi.c
> +++ b/drivers/spi/spi-rspi.c
> @@ -330,9 +330,7 @@ static int rspi_send_pio(struct rspi_data *rspi, struct
> spi_message *mesg, struct spi_transfer *t)
> {
> int remain = t->len;
> - u8 *data;
> -
> - data = (u8 *)t->tx_buf;
> + const u8 *data = t->tx_buf;
> while (remain > 0) {
> rspi_write8(rspi, rspi_read8(rspi, RSPI_SPCR) | SPCR_TXMD,
> RSPI_SPCR);
> @@ -358,12 +356,11 @@ static int qspi_send_pio(struct rspi_data *rspi,
> struct spi_message *mesg, struct spi_transfer *t)
> {
> int remain = t->len;
> - u8 *data;
> + const u8 *data = t->tx_buf;
>
> rspi_write8(rspi, SPBFCR_TXRST, QSPI_SPBFCR);
> rspi_write8(rspi, 0x00, QSPI_SPBFCR);
>
> - data = (u8 *)t->tx_buf;
> while (remain > 0) {
>
> if (rspi_wait_for_interrupt(rspi, SPSR_SPTEF, SPCR_SPTIE) < 0) {
> @@ -399,8 +396,8 @@ static void rspi_dma_complete(void *arg)
> wake_up_interruptible(&rspi->wait);
> }
>
> -static int rspi_dma_map_sg(struct scatterlist *sg, void *buf, unsigned len,
> - struct dma_chan *chan,
> +static int rspi_dma_map_sg(struct scatterlist *sg, const void *buf,
> + unsigned len, struct dma_chan *chan,
> enum dma_transfer_direction dir)
> {
> sg_init_table(sg, 1);
> @@ -440,12 +437,13 @@ static void rspi_memory_from_8bit(void *buf, const
> void *data, unsigned len) static int rspi_send_dma(struct rspi_data *rspi,
> struct spi_transfer *t) {
> struct scatterlist sg;
> - void *buf = NULL;
> + const void *buf = NULL;
> struct dma_async_tx_descriptor *desc;
> unsigned len;
> int ret = 0;
>
> if (rspi->dma_width_16bit) {
> + void *tmp;
I really dislike tmp as a variable name, as it can mean pretty much anything.
What about calling it tx_buf instead ?
> /*
> * If DMAC bus width is 16-bit, the driver allocates a dummy
> * buffer. And, the driver converts original data into the
> @@ -454,13 +452,14 @@ static int rspi_send_dma(struct rspi_data *rspi,
> struct spi_transfer *t) * DMAC data: 1st byte, dummy, 2nd byte, dummy
> ...
> */
> len = t->len * 2;
> - buf = kmalloc(len, GFP_KERNEL);
> - if (!buf)
> + tmp = kmalloc(len, GFP_KERNEL);
> + if (!tmp)
> return -ENOMEM;
> - rspi_memory_to_8bit(buf, t->tx_buf, t->len);
> + rspi_memory_to_8bit(tmp, t->tx_buf, t->len);
> + buf = tmp;
> } else {
> len = t->len;
> - buf = (void *)t->tx_buf;
> + buf = t->tx_buf;
> }
>
> if (!rspi_dma_map_sg(&sg, buf, len, rspi->chan_tx, DMA_TO_DEVICE)) {
> @@ -528,7 +527,7 @@ static int rspi_receive_pio(struct rspi_data *rspi,
> struct spi_message *mesg,
>
> rspi_receive_init(rspi);
>
> - data = (u8 *)t->rx_buf;
> + data = t->rx_buf;
> while (remain > 0) {
> rspi_write8(rspi, rspi_read8(rspi, RSPI_SPCR) & ~SPCR_TXMD,
> RSPI_SPCR);
> @@ -575,7 +574,7 @@ static int qspi_receive_pio(struct rspi_data *rspi,
> struct spi_message *mesg,
>
> qspi_receive_init(rspi);
>
> - data = (u8 *)t->rx_buf;
> + data = t->rx_buf;
> while (remain > 0) {
>
> if (rspi_wait_for_interrupt(rspi, SPSR_SPTEF, SPCR_SPTIE) < 0) {
> @@ -802,7 +801,7 @@ static void rspi_cleanup(struct spi_device *spi)
>
> static irqreturn_t rspi_irq(int irq, void *_sr)
> {
> - struct rspi_data *rspi = (struct rspi_data *)_sr;
> + struct rspi_data *rspi = _sr;
> unsigned long spsr;
> irqreturn_t ret = IRQ_NONE;
> unsigned char disable_irq = 0;
--
Regards,
Laurent Pinchart
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 2/5] spi: rspi: Remove casts
@ 2013-12-27 14:33 ` Laurent Pinchart
0 siblings, 0 replies; 23+ messages in thread
From: Laurent Pinchart @ 2013-12-27 14:33 UTC (permalink / raw)
To: Geert Uytterhoeven; +Cc: Mark Brown, linux-spi, linux-sh
Hi Geert,
Thank you for the patch.
On Tuesday 24 December 2013 10:49:31 Geert Uytterhoeven wrote:
> Remove useless casts, and do not cast away const.
>
> Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org>
> ---
> drivers/spi/spi-rspi.c | 29 ++++++++++++++---------------
> 1 file changed, 14 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/spi/spi-rspi.c b/drivers/spi/spi-rspi.c
> index 08861b5db893..a0038687a8fd 100644
> --- a/drivers/spi/spi-rspi.c
> +++ b/drivers/spi/spi-rspi.c
> @@ -330,9 +330,7 @@ static int rspi_send_pio(struct rspi_data *rspi, struct
> spi_message *mesg, struct spi_transfer *t)
> {
> int remain = t->len;
> - u8 *data;
> -
> - data = (u8 *)t->tx_buf;
> + const u8 *data = t->tx_buf;
> while (remain > 0) {
> rspi_write8(rspi, rspi_read8(rspi, RSPI_SPCR) | SPCR_TXMD,
> RSPI_SPCR);
> @@ -358,12 +356,11 @@ static int qspi_send_pio(struct rspi_data *rspi,
> struct spi_message *mesg, struct spi_transfer *t)
> {
> int remain = t->len;
> - u8 *data;
> + const u8 *data = t->tx_buf;
>
> rspi_write8(rspi, SPBFCR_TXRST, QSPI_SPBFCR);
> rspi_write8(rspi, 0x00, QSPI_SPBFCR);
>
> - data = (u8 *)t->tx_buf;
> while (remain > 0) {
>
> if (rspi_wait_for_interrupt(rspi, SPSR_SPTEF, SPCR_SPTIE) < 0) {
> @@ -399,8 +396,8 @@ static void rspi_dma_complete(void *arg)
> wake_up_interruptible(&rspi->wait);
> }
>
> -static int rspi_dma_map_sg(struct scatterlist *sg, void *buf, unsigned len,
> - struct dma_chan *chan,
> +static int rspi_dma_map_sg(struct scatterlist *sg, const void *buf,
> + unsigned len, struct dma_chan *chan,
> enum dma_transfer_direction dir)
> {
> sg_init_table(sg, 1);
> @@ -440,12 +437,13 @@ static void rspi_memory_from_8bit(void *buf, const
> void *data, unsigned len) static int rspi_send_dma(struct rspi_data *rspi,
> struct spi_transfer *t) {
> struct scatterlist sg;
> - void *buf = NULL;
> + const void *buf = NULL;
> struct dma_async_tx_descriptor *desc;
> unsigned len;
> int ret = 0;
>
> if (rspi->dma_width_16bit) {
> + void *tmp;
I really dislike tmp as a variable name, as it can mean pretty much anything.
What about calling it tx_buf instead ?
> /*
> * If DMAC bus width is 16-bit, the driver allocates a dummy
> * buffer. And, the driver converts original data into the
> @@ -454,13 +452,14 @@ static int rspi_send_dma(struct rspi_data *rspi,
> struct spi_transfer *t) * DMAC data: 1st byte, dummy, 2nd byte, dummy
> ...
> */
> len = t->len * 2;
> - buf = kmalloc(len, GFP_KERNEL);
> - if (!buf)
> + tmp = kmalloc(len, GFP_KERNEL);
> + if (!tmp)
> return -ENOMEM;
> - rspi_memory_to_8bit(buf, t->tx_buf, t->len);
> + rspi_memory_to_8bit(tmp, t->tx_buf, t->len);
> + buf = tmp;
> } else {
> len = t->len;
> - buf = (void *)t->tx_buf;
> + buf = t->tx_buf;
> }
>
> if (!rspi_dma_map_sg(&sg, buf, len, rspi->chan_tx, DMA_TO_DEVICE)) {
> @@ -528,7 +527,7 @@ static int rspi_receive_pio(struct rspi_data *rspi,
> struct spi_message *mesg,
>
> rspi_receive_init(rspi);
>
> - data = (u8 *)t->rx_buf;
> + data = t->rx_buf;
> while (remain > 0) {
> rspi_write8(rspi, rspi_read8(rspi, RSPI_SPCR) & ~SPCR_TXMD,
> RSPI_SPCR);
> @@ -575,7 +574,7 @@ static int qspi_receive_pio(struct rspi_data *rspi,
> struct spi_message *mesg,
>
> qspi_receive_init(rspi);
>
> - data = (u8 *)t->rx_buf;
> + data = t->rx_buf;
> while (remain > 0) {
>
> if (rspi_wait_for_interrupt(rspi, SPSR_SPTEF, SPCR_SPTIE) < 0) {
> @@ -802,7 +801,7 @@ static void rspi_cleanup(struct spi_device *spi)
>
> static irqreturn_t rspi_irq(int irq, void *_sr)
> {
> - struct rspi_data *rspi = (struct rspi_data *)_sr;
> + struct rspi_data *rspi = _sr;
> unsigned long spsr;
> irqreturn_t ret = IRQ_NONE;
> unsigned char disable_irq = 0;
--
Regards,
Laurent Pinchart
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 4/5] spi: rspi: Use DUMMY_DATA macro instead of hardcoded value
[not found] ` <1387878574-21445-5-git-send-email-geert+renesas-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org>
@ 2013-12-27 14:36 ` Laurent Pinchart
0 siblings, 0 replies; 23+ messages in thread
From: Laurent Pinchart @ 2013-12-27 14:36 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: Mark Brown, linux-spi-u79uwXL29TY76Z2rM5mHXA,
linux-sh-u79uwXL29TY76Z2rM5mHXA
Hi Geert,
Thank you for the patch.
On Tuesday 24 December 2013 10:49:33 Geert Uytterhoeven wrote:
> Make it more obvious that this value is dummy data.
>
> Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org>
> ---
> drivers/spi/spi-rspi.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/spi/spi-rspi.c b/drivers/spi/spi-rspi.c
> index 4e376db1ca4f..51fe3bdacb18 100644
> --- a/drivers/spi/spi-rspi.c
> +++ b/drivers/spi/spi-rspi.c
> @@ -149,6 +149,8 @@
> #define SPBFCR_TXRST 0x80 /* qspi only */
> #define SPBFCR_RXRST 0x40 /* qspi only */
>
> +#define DUMMY_DATA 0x00
> +
> struct rspi_data {
> void __iomem *addr;
> u32 max_speed_hz;
> @@ -541,7 +543,7 @@ static int rspi_receive_pio(struct rspi_data *rspi,
> struct spi_message *mesg, return -ETIMEDOUT;
> }
> /* dummy write for generate clock */
> - rspi_write16(rspi, 0x00, RSPI_SPDR);
> + rspi_write16(rspi, DUMMY_DATA, RSPI_SPDR);
Doesn't the comment make it obvious already ?
> if (rspi_wait_for_interrupt(rspi, SPSR_SPRF, SPCR_SPRIE) < 0) {
> dev_err(&rspi->master->dev,
> @@ -586,7 +588,7 @@ static int qspi_receive_pio(struct rspi_data *rspi,
> struct spi_message *mesg, return -ETIMEDOUT;
> }
> /* dummy write for generate clock */
> - rspi_write8(rspi, 0x00, RSPI_SPDR);
> + rspi_write8(rspi, DUMMY_DATA, RSPI_SPDR);
>
> if (rspi_wait_for_interrupt(rspi, SPSR_SPRF, SPCR_SPRIE) < 0) {
> dev_err(&rspi->master->dev,
--
Regards,
Laurent Pinchart
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 4/5] spi: rspi: Use DUMMY_DATA macro instead of hardcoded value
@ 2013-12-27 14:36 ` Laurent Pinchart
0 siblings, 0 replies; 23+ messages in thread
From: Laurent Pinchart @ 2013-12-27 14:36 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: Mark Brown, linux-spi-u79uwXL29TY76Z2rM5mHXA,
linux-sh-u79uwXL29TY76Z2rM5mHXA
Hi Geert,
Thank you for the patch.
On Tuesday 24 December 2013 10:49:33 Geert Uytterhoeven wrote:
> Make it more obvious that this value is dummy data.
>
> Signed-off-by: Geert Uytterhoeven <geert+renesas-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org>
> ---
> drivers/spi/spi-rspi.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/spi/spi-rspi.c b/drivers/spi/spi-rspi.c
> index 4e376db1ca4f..51fe3bdacb18 100644
> --- a/drivers/spi/spi-rspi.c
> +++ b/drivers/spi/spi-rspi.c
> @@ -149,6 +149,8 @@
> #define SPBFCR_TXRST 0x80 /* qspi only */
> #define SPBFCR_RXRST 0x40 /* qspi only */
>
> +#define DUMMY_DATA 0x00
> +
> struct rspi_data {
> void __iomem *addr;
> u32 max_speed_hz;
> @@ -541,7 +543,7 @@ static int rspi_receive_pio(struct rspi_data *rspi,
> struct spi_message *mesg, return -ETIMEDOUT;
> }
> /* dummy write for generate clock */
> - rspi_write16(rspi, 0x00, RSPI_SPDR);
> + rspi_write16(rspi, DUMMY_DATA, RSPI_SPDR);
Doesn't the comment make it obvious already ?
> if (rspi_wait_for_interrupt(rspi, SPSR_SPRF, SPCR_SPRIE) < 0) {
> dev_err(&rspi->master->dev,
> @@ -586,7 +588,7 @@ static int qspi_receive_pio(struct rspi_data *rspi,
> struct spi_message *mesg, return -ETIMEDOUT;
> }
> /* dummy write for generate clock */
> - rspi_write8(rspi, 0x00, RSPI_SPDR);
> + rspi_write8(rspi, DUMMY_DATA, RSPI_SPDR);
>
> if (rspi_wait_for_interrupt(rspi, SPSR_SPRF, SPCR_SPRIE) < 0) {
> dev_err(&rspi->master->dev,
--
Regards,
Laurent Pinchart
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 2/5] spi: rspi: Remove casts
2013-12-27 14:33 ` Laurent Pinchart
@ 2013-12-27 18:38 ` Geert Uytterhoeven
-1 siblings, 0 replies; 23+ messages in thread
From: Geert Uytterhoeven @ 2013-12-27 18:38 UTC (permalink / raw)
To: Laurent Pinchart; +Cc: Geert Uytterhoeven, Mark Brown, linux-spi, Linux-sh list
On Fri, Dec 27, 2013 at 3:33 PM, Laurent Pinchart
<laurent.pinchart@ideasonboard.com> wrote:
>> @@ -440,12 +437,13 @@ static void rspi_memory_from_8bit(void *buf, const
>> void *data, unsigned len) static int rspi_send_dma(struct rspi_data *rspi,
>> struct spi_transfer *t) {
>> struct scatterlist sg;
>> - void *buf = NULL;
>> + const void *buf = NULL;
>> struct dma_async_tx_descriptor *desc;
>> unsigned len;
>> int ret = 0;
>>
>> if (rspi->dma_width_16bit) {
>> + void *tmp;
>
> I really dislike tmp as a variable name, as it can mean pretty much anything.
> What about calling it tx_buf instead ?
Thanks, that would indeed be a better name.
However, Mark has already applied it to spi/for-next, so I'm not sure we
can still change it, without sending a complete new patch.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 2/5] spi: rspi: Remove casts
@ 2013-12-27 18:38 ` Geert Uytterhoeven
0 siblings, 0 replies; 23+ messages in thread
From: Geert Uytterhoeven @ 2013-12-27 18:38 UTC (permalink / raw)
To: Laurent Pinchart; +Cc: Geert Uytterhoeven, Mark Brown, linux-spi, Linux-sh list
On Fri, Dec 27, 2013 at 3:33 PM, Laurent Pinchart
<laurent.pinchart@ideasonboard.com> wrote:
>> @@ -440,12 +437,13 @@ static void rspi_memory_from_8bit(void *buf, const
>> void *data, unsigned len) static int rspi_send_dma(struct rspi_data *rspi,
>> struct spi_transfer *t) {
>> struct scatterlist sg;
>> - void *buf = NULL;
>> + const void *buf = NULL;
>> struct dma_async_tx_descriptor *desc;
>> unsigned len;
>> int ret = 0;
>>
>> if (rspi->dma_width_16bit) {
>> + void *tmp;
>
> I really dislike tmp as a variable name, as it can mean pretty much anything.
> What about calling it tx_buf instead ?
Thanks, that would indeed be a better name.
However, Mark has already applied it to spi/for-next, so I'm not sure we
can still change it, without sending a complete new patch.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 2/5] spi: rspi: Remove casts
[not found] ` <CAMuHMdXyeRdgFJF0MzJkJ5jf1pSWfO98mdn-JSF0ze2iuTbLug-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2013-12-28 11:44 ` Laurent Pinchart
0 siblings, 0 replies; 23+ messages in thread
From: Laurent Pinchart @ 2013-12-28 11:44 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: Geert Uytterhoeven, Mark Brown, linux-spi-u79uwXL29TY76Z2rM5mHXA,
Linux-sh list
Hi Geert,
On Friday 27 December 2013 19:38:43 Geert Uytterhoeven wrote:
> On Fri, Dec 27, 2013 at 3:33 PM, Laurent Pinchart wrote:
> >> @@ -440,12 +437,13 @@ static void rspi_memory_from_8bit(void *buf, const
> >> void *data, unsigned len) static int rspi_send_dma(struct rspi_data
> >> *rspi,
> >> struct spi_transfer *t) {
> >>
> >> struct scatterlist sg;
> >>
> >> - void *buf = NULL;
> >> + const void *buf = NULL;
> >>
> >> struct dma_async_tx_descriptor *desc;
> >> unsigned len;
> >> int ret = 0;
> >>
> >> if (rspi->dma_width_16bit) {
> >>
> >> + void *tmp;
> >
> > I really dislike tmp as a variable name, as it can mean pretty much
> > anything. What about calling it tx_buf instead ?
>
> Thanks, that would indeed be a better name.
> However, Mark has already applied it to spi/for-next, so I'm not sure we
> can still change it, without sending a complete new patch.
I've noticed that after sending the reply. I think we can live with tmp for
now.
--
Regards,
Laurent Pinchart
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 2/5] spi: rspi: Remove casts
@ 2013-12-28 11:44 ` Laurent Pinchart
0 siblings, 0 replies; 23+ messages in thread
From: Laurent Pinchart @ 2013-12-28 11:44 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: Geert Uytterhoeven, Mark Brown, linux-spi-u79uwXL29TY76Z2rM5mHXA,
Linux-sh list
Hi Geert,
On Friday 27 December 2013 19:38:43 Geert Uytterhoeven wrote:
> On Fri, Dec 27, 2013 at 3:33 PM, Laurent Pinchart wrote:
> >> @@ -440,12 +437,13 @@ static void rspi_memory_from_8bit(void *buf, const
> >> void *data, unsigned len) static int rspi_send_dma(struct rspi_data
> >> *rspi,
> >> struct spi_transfer *t) {
> >>
> >> struct scatterlist sg;
> >>
> >> - void *buf = NULL;
> >> + const void *buf = NULL;
> >>
> >> struct dma_async_tx_descriptor *desc;
> >> unsigned len;
> >> int ret = 0;
> >>
> >> if (rspi->dma_width_16bit) {
> >>
> >> + void *tmp;
> >
> > I really dislike tmp as a variable name, as it can mean pretty much
> > anything. What about calling it tx_buf instead ?
>
> Thanks, that would indeed be a better name.
> However, Mark has already applied it to spi/for-next, so I'm not sure we
> can still change it, without sending a complete new patch.
I've noticed that after sending the reply. I think we can live with tmp for
now.
--
Regards,
Laurent Pinchart
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 4/5] spi: rspi: Use DUMMY_DATA macro instead of hardcoded value
2013-12-27 14:36 ` Laurent Pinchart
(?)
@ 2013-12-30 11:54 ` Mark Brown
-1 siblings, 0 replies; 23+ messages in thread
From: Mark Brown @ 2013-12-30 11:54 UTC (permalink / raw)
To: Laurent Pinchart; +Cc: Geert Uytterhoeven, linux-spi, linux-sh
[-- Attachment #1: Type: text/plain, Size: 424 bytes --]
On Fri, Dec 27, 2013 at 03:36:12PM +0100, Laurent Pinchart wrote:
> On Tuesday 24 December 2013 10:49:33 Geert Uytterhoeven wrote:
> > /* dummy write for generate clock */
> > - rspi_write16(rspi, 0x00, RSPI_SPDR);
> > + rspi_write16(rspi, DUMMY_DATA, RSPI_SPDR);
> Doesn't the comment make it obvious already ?
To be honest that had been my thought as well but if it makes the people
working on the driver happy...
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 23+ messages in thread
end of thread, other threads:[~2013-12-30 11:54 UTC | newest]
Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-12-24 9:49 [PATCH 0/5] spi: rspi: cleanups Geert Uytterhoeven
2013-12-24 9:49 ` Geert Uytterhoeven
2013-12-24 9:49 ` [PATCH 3/5] spi: rspi: Make more pointers const Geert Uytterhoeven
2013-12-24 9:49 ` Geert Uytterhoeven
[not found] ` <1387878574-21445-1-git-send-email-geert+renesas-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org>
2013-12-24 9:49 ` [PATCH 1/5] spi: rspi: Use dev_get_platdata() instead of raw dev.platform_data access Geert Uytterhoeven
2013-12-24 9:49 ` Geert Uytterhoeven
2013-12-24 9:49 ` [PATCH 2/5] spi: rspi: Remove casts Geert Uytterhoeven
2013-12-24 9:49 ` Geert Uytterhoeven
2013-12-27 14:33 ` Laurent Pinchart
2013-12-27 14:33 ` Laurent Pinchart
2013-12-27 18:38 ` Geert Uytterhoeven
2013-12-27 18:38 ` Geert Uytterhoeven
[not found] ` <CAMuHMdXyeRdgFJF0MzJkJ5jf1pSWfO98mdn-JSF0ze2iuTbLug-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-12-28 11:44 ` Laurent Pinchart
2013-12-28 11:44 ` Laurent Pinchart
2013-12-24 9:49 ` [PATCH 4/5] spi: rspi: Use DUMMY_DATA macro instead of hardcoded value Geert Uytterhoeven
2013-12-24 9:49 ` Geert Uytterhoeven
[not found] ` <1387878574-21445-5-git-send-email-geert+renesas-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org>
2013-12-27 14:36 ` Laurent Pinchart
2013-12-27 14:36 ` Laurent Pinchart
2013-12-30 11:54 ` Mark Brown
2013-12-24 9:49 ` [PATCH 5/5] spi: rspi: Use u8 for 8-bit register values Geert Uytterhoeven
2013-12-24 9:49 ` Geert Uytterhoeven
2013-12-24 13:20 ` [PATCH 0/5] spi: rspi: cleanups Mark Brown
2013-12-24 13:20 ` Mark Brown
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.