linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] spi/mpc52xx-spi: cleanups
@ 2009-11-17 14:31 Wolfram Sang
  2009-11-17 14:43 ` Luotao Fu
  0 siblings, 1 reply; 4+ messages in thread
From: Wolfram Sang @ 2009-11-17 14:31 UTC (permalink / raw)
  To: spi-devel-general; +Cc: linuxppc-dev, Luotao Fu

- drop own, obsolete include-file
- drop IRQF_SAMPLE_RANDOM (deprecated feature)
- drop 'if' above kfree()
- typos, braces & whitespaces

Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
Cc: Luotao Fu <l.fu@pengutronix.de>
Cc: Grant Likely <grant.likely@secretlab.ca>
---

This goes ontop of Grant's test-branch.

 drivers/spi/mpc52xx_spi.c       |   24 ++++++++++--------------
 include/linux/spi/mpc52xx_spi.h |   10 ----------
 2 files changed, 10 insertions(+), 24 deletions(-)
 delete mode 100644 include/linux/spi/mpc52xx_spi.h

diff --git a/drivers/spi/mpc52xx_spi.c b/drivers/spi/mpc52xx_spi.c
index 97beba2..7f4089c 100644
--- a/drivers/spi/mpc52xx_spi.c
+++ b/drivers/spi/mpc52xx_spi.c
@@ -18,7 +18,6 @@
 #include <linux/interrupt.h>
 #include <linux/delay.h>
 #include <linux/spi/spi.h>
-#include <linux/spi/mpc52xx_spi.h>
 #include <linux/of_spi.h>
 #include <linux/io.h>
 #include <linux/of_gpio.h>
@@ -54,7 +53,7 @@ MODULE_LICENSE("GPL");
 /* FSM state return values */
 #define FSM_STOP	0	/* Nothing more for the state machine to */
 				/* do.  If something interesting happens */
-				/* then and IRQ will be received */
+				/* then an IRQ will be received */
 #define FSM_POLL	1	/* need to poll for completion, an IRQ is */
 				/* not expected */
 #define FSM_CONTINUE	2	/* Keep iterating the state machine */
@@ -62,13 +61,12 @@ MODULE_LICENSE("GPL");
 /* Driver internal data */
 struct mpc52xx_spi {
 	struct spi_master *master;
-	u32 sysclk;
 	void __iomem *regs;
 	int irq0;	/* MODF irq */
 	int irq1;	/* SPIF irq */
-	int ipb_freq;
+	unsigned int ipb_freq;
 
-	/* Statistics */
+	/* Statistics; not used now, but will be reintroduced for debugfs */
 	int msg_count;
 	int wcol_count;
 	int wcol_ticks;
@@ -229,7 +227,7 @@ static int mpc52xx_spi_fsmstate_transfer(int irq, struct mpc52xx_spi *ms,
 		ms->wcol_tx_timestamp = get_tbl();
 		data = 0;
 		if (ms->tx_buf)
-			data = *(ms->tx_buf-1);
+			data = *(ms->tx_buf - 1);
 		out_8(ms->regs + SPI_DATA, data); /* try again */
 		return FSM_CONTINUE;
 	} else if (status & SPI_STATUS_MODF) {
@@ -481,8 +479,9 @@ static int __devinit mpc52xx_spi_probe(struct of_device *op,
 			gpio_direction_output(gpio_cs, 1);
 			ms->gpio_cs[i] = gpio_cs;
 		}
-	} else
+	} else {
 		master->num_chipselect = 1;
+	}
 
 	spin_lock_init(&ms->lock);
 	INIT_LIST_HEAD(&ms->queue);
@@ -490,9 +489,9 @@ static int __devinit mpc52xx_spi_probe(struct of_device *op,
 
 	/* Decide if interrupts can be used */
 	if (ms->irq0 && ms->irq1) {
-		rc = request_irq(ms->irq0, mpc52xx_spi_irq, IRQF_SAMPLE_RANDOM,
+		rc = request_irq(ms->irq0, mpc52xx_spi_irq, 0,
 				  "mpc5200-spi-modf", ms);
-		rc |= request_irq(ms->irq1, mpc52xx_spi_irq, IRQF_SAMPLE_RANDOM,
+		rc |= request_irq(ms->irq1, mpc52xx_spi_irq, 0,
 				  "mpc5200-spi-spiF", ms);
 		if (rc) {
 			free_irq(ms->irq0, ms);
@@ -524,8 +523,7 @@ static int __devinit mpc52xx_spi_probe(struct of_device *op,
 	while (i-- > 0)
 		gpio_free(ms->gpio_cs[i]);
 
-	if (ms->gpio_cs != NULL)
-		kfree(ms->gpio_cs);
+	kfree(ms->gpio_cs);
  err_alloc:
  err_init:
 	iounmap(regs);
@@ -544,9 +542,7 @@ static int __devexit mpc52xx_spi_remove(struct of_device *op)
 	for (i = 0; i < ms->gpio_cs_count; i++)
 		gpio_free(ms->gpio_cs[i]);
 
-	if (ms->gpio_cs != NULL)
-		kfree(ms->gpio_cs);
-
+	kfree(ms->gpio_cs);
 	spi_unregister_master(master);
 	spi_master_put(master);
 	iounmap(ms->regs);
diff --git a/include/linux/spi/mpc52xx_spi.h b/include/linux/spi/mpc52xx_spi.h
deleted file mode 100644
index d1004cf..0000000
--- a/include/linux/spi/mpc52xx_spi.h
+++ /dev/null
@@ -1,10 +0,0 @@
-
-#ifndef INCLUDE_MPC5200_SPI_H
-#define INCLUDE_MPC5200_SPI_H
-
-extern void mpc52xx_spi_set_premessage_hook(struct spi_master *master,
-					    void (*hook)(struct spi_message *m,
-							 void *context),
-					    void *hook_context);
-
-#endif
-- 
1.6.3.3

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] spi/mpc52xx-spi: cleanups
  2009-11-17 14:31 [PATCH] spi/mpc52xx-spi: cleanups Wolfram Sang
@ 2009-11-17 14:43 ` Luotao Fu
  2009-11-18  9:58   ` Wolfram Sang
  0 siblings, 1 reply; 4+ messages in thread
From: Luotao Fu @ 2009-11-17 14:43 UTC (permalink / raw)
  To: Wolfram Sang; +Cc: spi-devel-general, Luotao Fu, linuxppc-dev


[-- Attachment #1.1: Type: text/plain, Size: 4744 bytes --]

On Tue, Nov 17, 2009 at 03:31:08PM +0100, Wolfram Sang wrote:
> - drop own, obsolete include-file
> - drop IRQF_SAMPLE_RANDOM (deprecated feature)
> - drop 'if' above kfree()
> - typos, braces & whitespaces
> 
> Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
> Cc: Luotao Fu <l.fu@pengutronix.de>
> Cc: Grant Likely <grant.likely@secretlab.ca>

acked-by: Luotao Fu <l.fu@pengutronix.de>

minor comments see below,

> ---
> 
> This goes ontop of Grant's test-branch.
> 
>  drivers/spi/mpc52xx_spi.c       |   24 ++++++++++--------------
>  include/linux/spi/mpc52xx_spi.h |   10 ----------
>  2 files changed, 10 insertions(+), 24 deletions(-)
>  delete mode 100644 include/linux/spi/mpc52xx_spi.h
> 
> diff --git a/drivers/spi/mpc52xx_spi.c b/drivers/spi/mpc52xx_spi.c
> index 97beba2..7f4089c 100644
> --- a/drivers/spi/mpc52xx_spi.c
> +++ b/drivers/spi/mpc52xx_spi.c
> @@ -18,7 +18,6 @@
>  #include <linux/interrupt.h>
>  #include <linux/delay.h>
>  #include <linux/spi/spi.h>
> -#include <linux/spi/mpc52xx_spi.h>
>  #include <linux/of_spi.h>
>  #include <linux/io.h>
>  #include <linux/of_gpio.h>
> @@ -54,7 +53,7 @@ MODULE_LICENSE("GPL");
>  /* FSM state return values */
>  #define FSM_STOP	0	/* Nothing more for the state machine to */
>  				/* do.  If something interesting happens */
> -				/* then and IRQ will be received */
> +				/* then an IRQ will be received */
>  #define FSM_POLL	1	/* need to poll for completion, an IRQ is */
>  				/* not expected */
>  #define FSM_CONTINUE	2	/* Keep iterating the state machine */
> @@ -62,13 +61,12 @@ MODULE_LICENSE("GPL");
>  /* Driver internal data */
>  struct mpc52xx_spi {
>  	struct spi_master *master;
> -	u32 sysclk;
>  	void __iomem *regs;
>  	int irq0;	/* MODF irq */
>  	int irq1;	/* SPIF irq */
> -	int ipb_freq;
> +	unsigned int ipb_freq;
>  
> -	/* Statistics */
> +	/* Statistics; not used now, but will be reintroduced for debugfs */
>  	int msg_count;
>  	int wcol_count;
>  	int wcol_ticks;
> @@ -229,7 +227,7 @@ static int mpc52xx_spi_fsmstate_transfer(int irq, struct mpc52xx_spi *ms,
>  		ms->wcol_tx_timestamp = get_tbl();
>  		data = 0;
>  		if (ms->tx_buf)
> -			data = *(ms->tx_buf-1);
> +			data = *(ms->tx_buf - 1);
>  		out_8(ms->regs + SPI_DATA, data); /* try again */
>  		return FSM_CONTINUE;
>  	} else if (status & SPI_STATUS_MODF) {
> @@ -481,8 +479,9 @@ static int __devinit mpc52xx_spi_probe(struct of_device *op,
>  			gpio_direction_output(gpio_cs, 1);
>  			ms->gpio_cs[i] = gpio_cs;
>  		}
> -	} else
> +	} else {
>  		master->num_chipselect = 1;
> +	}
>  
>  	spin_lock_init(&ms->lock);
>  	INIT_LIST_HEAD(&ms->queue);
> @@ -490,9 +489,9 @@ static int __devinit mpc52xx_spi_probe(struct of_device *op,
>  
>  	/* Decide if interrupts can be used */
>  	if (ms->irq0 && ms->irq1) {
> -		rc = request_irq(ms->irq0, mpc52xx_spi_irq, IRQF_SAMPLE_RANDOM,
> +		rc = request_irq(ms->irq0, mpc52xx_spi_irq, 0,
>  				  "mpc5200-spi-modf", ms);
> -		rc |= request_irq(ms->irq1, mpc52xx_spi_irq, IRQF_SAMPLE_RANDOM,
> +		rc |= request_irq(ms->irq1, mpc52xx_spi_irq, 0,
>  				  "mpc5200-spi-spiF", ms);

The "spiF" here is probably also a typo.

>  		if (rc) {
>  			free_irq(ms->irq0, ms);
> @@ -524,8 +523,7 @@ static int __devinit mpc52xx_spi_probe(struct of_device *op,
>  	while (i-- > 0)
>  		gpio_free(ms->gpio_cs[i]);
>  
> -	if (ms->gpio_cs != NULL)
> -		kfree(ms->gpio_cs);
> +	kfree(ms->gpio_cs);
>   err_alloc:
>   err_init:
>  	iounmap(regs);
> @@ -544,9 +542,7 @@ static int __devexit mpc52xx_spi_remove(struct of_device *op)
>  	for (i = 0; i < ms->gpio_cs_count; i++)
>  		gpio_free(ms->gpio_cs[i]);
>  
> -	if (ms->gpio_cs != NULL)
> -		kfree(ms->gpio_cs);
> -
> +	kfree(ms->gpio_cs);
>  	spi_unregister_master(master);
>  	spi_master_put(master);
>  	iounmap(ms->regs);
> diff --git a/include/linux/spi/mpc52xx_spi.h b/include/linux/spi/mpc52xx_spi.h
> deleted file mode 100644
> index d1004cf..0000000
> --- a/include/linux/spi/mpc52xx_spi.h
> +++ /dev/null
> @@ -1,10 +0,0 @@
> -
> -#ifndef INCLUDE_MPC5200_SPI_H
> -#define INCLUDE_MPC5200_SPI_H
> -
> -extern void mpc52xx_spi_set_premessage_hook(struct spi_master *master,
> -					    void (*hook)(struct spi_message *m,
> -							 void *context),
> -					    void *hook_context);
> -
> -#endif
> -- 
> 1.6.3.3
> 

cheers
Luotao Fu
-- 
Pengutronix e.K.                           | Dipl.-Ing. Luotao Fu        |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

[-- Attachment #2: Type: text/plain, Size: 150 bytes --]

_______________________________________________
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] spi/mpc52xx-spi: cleanups
  2009-11-17 14:43 ` Luotao Fu
@ 2009-11-18  9:58   ` Wolfram Sang
  2009-11-20 21:46     ` Grant Likely
  0 siblings, 1 reply; 4+ messages in thread
From: Wolfram Sang @ 2009-11-18  9:58 UTC (permalink / raw)
  To: Luotao Fu; +Cc: spi-devel-general, linuxppc-dev


[-- Attachment #1.1: Type: text/plain, Size: 541 bytes --]

> > -		rc |= request_irq(ms->irq1, mpc52xx_spi_irq, IRQF_SAMPLE_RANDOM,
> > +		rc |= request_irq(ms->irq1, mpc52xx_spi_irq, 0,
> >  				  "mpc5200-spi-spiF", ms);
> 
> The "spiF" here is probably also a typo.

Ack. Grant, if you think it is worth you may modify my patch to avoid a resend.
If it is easier for you, I will do the resend, of course.

Regards,

   Wolfram

-- 
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

[-- Attachment #2: Type: text/plain, Size: 150 bytes --]

_______________________________________________
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] spi/mpc52xx-spi: cleanups
  2009-11-18  9:58   ` Wolfram Sang
@ 2009-11-20 21:46     ` Grant Likely
  0 siblings, 0 replies; 4+ messages in thread
From: Grant Likely @ 2009-11-20 21:46 UTC (permalink / raw)
  To: Wolfram Sang; +Cc: spi-devel-general, Luotao Fu, linuxppc-dev

On Wed, Nov 18, 2009 at 2:58 AM, Wolfram Sang <w.sang@pengutronix.de> wrote:
>> > -           rc |= request_irq(ms->irq1, mpc52xx_spi_irq, IRQF_SAMPLE_RANDOM,
>> > +           rc |= request_irq(ms->irq1, mpc52xx_spi_irq, 0,
>> >                               "mpc5200-spi-spiF", ms);
>>
>> The "spiF" here is probably also a typo.
>
> Ack. Grant, if you think it is worth you may modify my patch to avoid a resend.
> If it is easier for you, I will do the resend, of course.

Don't resend.  Patch looks okay.

g.

-- 
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-11-20 21:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-17 14:31 [PATCH] spi/mpc52xx-spi: cleanups Wolfram Sang
2009-11-17 14:43 ` Luotao Fu
2009-11-18  9:58   ` Wolfram Sang
2009-11-20 21:46     ` Grant Likely

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).