* [PATCH] mpc52xx_psc_spi: Convert to cs_control callback
@ 2009-04-30 22:31 Anton Vorontsov
2009-05-22 5:07 ` Grant Likely
2009-05-22 13:29 ` Jon Smirl
0 siblings, 2 replies; 3+ messages in thread
From: Anton Vorontsov @ 2009-04-30 22:31 UTC (permalink / raw)
To: Grant Likely
Cc: linuxppc-dev, Andrew Morton, David Brownell, spi-devel-general
mpc52xx_psc_spi driver is the last user of the legacy activate_cs
and deactivate_cs callbacks, so convert the driver to the cs_control
hook and remove the legacy callbacks from fsl_spi_platform_data
struct.
Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
---
drivers/spi/mpc52xx_psc_spi.c | 22 +++++++++-------------
include/linux/fsl_devices.h | 4 ----
2 files changed, 9 insertions(+), 17 deletions(-)
diff --git a/drivers/spi/mpc52xx_psc_spi.c b/drivers/spi/mpc52xx_psc_spi.c
index 68c77a9..e1901fd 100644
--- a/drivers/spi/mpc52xx_psc_spi.c
+++ b/drivers/spi/mpc52xx_psc_spi.c
@@ -13,6 +13,7 @@
#include <linux/module.h>
#include <linux/init.h>
+#include <linux/types.h>
#include <linux/errno.h>
#include <linux/interrupt.h>
#include <linux/of_platform.h>
@@ -30,8 +31,7 @@
struct mpc52xx_psc_spi {
/* fsl_spi_platform data */
- void (*activate_cs)(u8, u8);
- void (*deactivate_cs)(u8, u8);
+ void (*cs_control)(struct spi_device *spi, bool on);
u32 sysclk;
/* driver internal data */
@@ -111,18 +111,16 @@ static void mpc52xx_psc_spi_activate_cs(struct spi_device *spi)
out_be16((u16 __iomem *)&psc->ccr, ccr);
mps->bits_per_word = cs->bits_per_word;
- if (mps->activate_cs)
- mps->activate_cs(spi->chip_select,
- (spi->mode & SPI_CS_HIGH) ? 1 : 0);
+ if (mps->cs_control)
+ mps->cs_control(spi, (spi->mode & SPI_CS_HIGH) ? 1 : 0);
}
static void mpc52xx_psc_spi_deactivate_cs(struct spi_device *spi)
{
struct mpc52xx_psc_spi *mps = spi_master_get_devdata(spi->master);
- if (mps->deactivate_cs)
- mps->deactivate_cs(spi->chip_select,
- (spi->mode & SPI_CS_HIGH) ? 1 : 0);
+ if (mps->cs_control)
+ mps->cs_control(spi, (spi->mode & SPI_CS_HIGH) ? 0 : 1);
}
#define MPC52xx_PSC_BUFSIZE (MPC52xx_PSC_RFNUM_MASK + 1)
@@ -388,15 +386,13 @@ static int __init mpc52xx_psc_spi_do_probe(struct device *dev, u32 regaddr,
mps->irq = irq;
if (pdata == NULL) {
dev_warn(dev, "probe called without platform data, no "
- "(de)activate_cs function will be called\n");
- mps->activate_cs = NULL;
- mps->deactivate_cs = NULL;
+ "cs_control function will be called\n");
+ mps->cs_control = NULL;
mps->sysclk = 0;
master->bus_num = bus_num;
master->num_chipselect = 255;
} else {
- mps->activate_cs = pdata->activate_cs;
- mps->deactivate_cs = pdata->deactivate_cs;
+ mps->cs_control = pdata->cs_control;
mps->sysclk = pdata->sysclk;
master->bus_num = pdata->bus_num;
master->num_chipselect = pdata->max_chipselect;
diff --git a/include/linux/fsl_devices.h b/include/linux/fsl_devices.h
index 244677c..43fc95d 100644
--- a/include/linux/fsl_devices.h
+++ b/include/linux/fsl_devices.h
@@ -79,10 +79,6 @@ struct fsl_spi_platform_data {
u16 max_chipselect;
void (*cs_control)(struct spi_device *spi, bool on);
u32 sysclk;
-
- /* Legacy hooks, used by mpc52xx_psc_spi driver. */
- void (*activate_cs)(u8 cs, u8 polarity);
- void (*deactivate_cs)(u8 cs, u8 polarity);
};
struct mpc8xx_pcmcia_ops {
--
1.6.2.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] mpc52xx_psc_spi: Convert to cs_control callback
2009-04-30 22:31 [PATCH] mpc52xx_psc_spi: Convert to cs_control callback Anton Vorontsov
@ 2009-05-22 5:07 ` Grant Likely
2009-05-22 13:29 ` Jon Smirl
1 sibling, 0 replies; 3+ messages in thread
From: Grant Likely @ 2009-05-22 5:07 UTC (permalink / raw)
To: Anton Vorontsov
Cc: linuxppc-dev, Andrew Morton, David Brownell, spi-devel-general
On Thu, Apr 30, 2009 at 4:31 PM, Anton Vorontsov
<avorontsov@ru.mvista.com> wrote:
> mpc52xx_psc_spi driver is the last user of the legacy activate_cs
> and deactivate_cs callbacks, so convert the driver to the cs_control
> hook and remove the legacy callbacks from fsl_spi_platform_data
> struct.
>
> Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
Acked-by: Grant Likely <grant.likely@secretlab.ca>
David, will you pick this one up, or can I put it into Ben's powerpc
-next tree (since it is a powerpc-only device driver).
g.
> ---
> =A0drivers/spi/mpc52xx_psc_spi.c | =A0 22 +++++++++-------------
> =A0include/linux/fsl_devices.h =A0 | =A0 =A04 ----
> =A02 files changed, 9 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/spi/mpc52xx_psc_spi.c b/drivers/spi/mpc52xx_psc_spi.=
c
> index 68c77a9..e1901fd 100644
> --- a/drivers/spi/mpc52xx_psc_spi.c
> +++ b/drivers/spi/mpc52xx_psc_spi.c
> @@ -13,6 +13,7 @@
>
> =A0#include <linux/module.h>
> =A0#include <linux/init.h>
> +#include <linux/types.h>
> =A0#include <linux/errno.h>
> =A0#include <linux/interrupt.h>
> =A0#include <linux/of_platform.h>
> @@ -30,8 +31,7 @@
>
> =A0struct mpc52xx_psc_spi {
> =A0 =A0 =A0 =A0/* fsl_spi_platform data */
> - =A0 =A0 =A0 void (*activate_cs)(u8, u8);
> - =A0 =A0 =A0 void (*deactivate_cs)(u8, u8);
> + =A0 =A0 =A0 void (*cs_control)(struct spi_device *spi, bool on);
> =A0 =A0 =A0 =A0u32 sysclk;
>
> =A0 =A0 =A0 =A0/* driver internal data */
> @@ -111,18 +111,16 @@ static void mpc52xx_psc_spi_activate_cs(struct spi_=
device *spi)
> =A0 =A0 =A0 =A0out_be16((u16 __iomem *)&psc->ccr, ccr);
> =A0 =A0 =A0 =A0mps->bits_per_word =3D cs->bits_per_word;
>
> - =A0 =A0 =A0 if (mps->activate_cs)
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 mps->activate_cs(spi->chip_select,
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (spi->mode =
& SPI_CS_HIGH) ? 1 : 0);
> + =A0 =A0 =A0 if (mps->cs_control)
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 mps->cs_control(spi, (spi->mode & SPI_CS_HI=
GH) ? 1 : 0);
> =A0}
>
> =A0static void mpc52xx_psc_spi_deactivate_cs(struct spi_device *spi)
> =A0{
> =A0 =A0 =A0 =A0struct mpc52xx_psc_spi *mps =3D spi_master_get_devdata(spi=
->master);
>
> - =A0 =A0 =A0 if (mps->deactivate_cs)
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 mps->deactivate_cs(spi->chip_select,
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (spi->mode =
& SPI_CS_HIGH) ? 1 : 0);
> + =A0 =A0 =A0 if (mps->cs_control)
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 mps->cs_control(spi, (spi->mode & SPI_CS_HI=
GH) ? 0 : 1);
> =A0}
>
> =A0#define MPC52xx_PSC_BUFSIZE (MPC52xx_PSC_RFNUM_MASK + 1)
> @@ -388,15 +386,13 @@ static int __init mpc52xx_psc_spi_do_probe(struct d=
evice *dev, u32 regaddr,
> =A0 =A0 =A0 =A0mps->irq =3D irq;
> =A0 =A0 =A0 =A0if (pdata =3D=3D NULL) {
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0dev_warn(dev, "probe called without platfo=
rm data, no "
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "(de)activa=
te_cs function will be called\n");
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 mps->activate_cs =3D NULL;
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 mps->deactivate_cs =3D NULL;
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "cs_control=
function will be called\n");
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 mps->cs_control =3D NULL;
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0mps->sysclk =3D 0;
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0master->bus_num =3D bus_num;
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0master->num_chipselect =3D 255;
> =A0 =A0 =A0 =A0} else {
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 mps->activate_cs =3D pdata->activate_cs;
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 mps->deactivate_cs =3D pdata->deactivate_cs=
;
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 mps->cs_control =3D pdata->cs_control;
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0mps->sysclk =3D pdata->sysclk;
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0master->bus_num =3D pdata->bus_num;
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0master->num_chipselect =3D pdata->max_chip=
select;
> diff --git a/include/linux/fsl_devices.h b/include/linux/fsl_devices.h
> index 244677c..43fc95d 100644
> --- a/include/linux/fsl_devices.h
> +++ b/include/linux/fsl_devices.h
> @@ -79,10 +79,6 @@ struct fsl_spi_platform_data {
> =A0 =A0 =A0 =A0u16 =A0 =A0 max_chipselect;
> =A0 =A0 =A0 =A0void =A0 =A0(*cs_control)(struct spi_device *spi, bool on)=
;
> =A0 =A0 =A0 =A0u32 =A0 =A0 sysclk;
> -
> - =A0 =A0 =A0 /* Legacy hooks, used by mpc52xx_psc_spi driver. */
> - =A0 =A0 =A0 void =A0 =A0(*activate_cs)(u8 cs, u8 polarity);
> - =A0 =A0 =A0 void =A0 =A0(*deactivate_cs)(u8 cs, u8 polarity);
> =A0};
>
> =A0struct mpc8xx_pcmcia_ops {
> --
> 1.6.2.2
>
--=20
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] mpc52xx_psc_spi: Convert to cs_control callback
2009-04-30 22:31 [PATCH] mpc52xx_psc_spi: Convert to cs_control callback Anton Vorontsov
2009-05-22 5:07 ` Grant Likely
@ 2009-05-22 13:29 ` Jon Smirl
1 sibling, 0 replies; 3+ messages in thread
From: Jon Smirl @ 2009-05-22 13:29 UTC (permalink / raw)
To: Anton Vorontsov
Cc: linuxppc-dev, Andrew Morton, David Brownell, spi-devel-general
On Thu, Apr 30, 2009 at 6:31 PM, Anton Vorontsov
<avorontsov@ru.mvista.com> wrote:
> mpc52xx_psc_spi driver is the last user of the legacy activate_cs
> and deactivate_cs callbacks, so convert the driver to the cs_control
This driver is missing a call to of_register_spi_devices(master, op->node);
Here's how I added it, but it could be done more cleanly.
diff --git a/drivers/spi/mpc52xx_psc_spi.c b/drivers/spi/mpc52xx_psc_spi.c
index 68c77a9..fe0658a 100644
--- a/drivers/spi/mpc52xx_psc_spi.c
+++ b/drivers/spi/mpc52xx_psc_spi.c
@@ -22,6 +22,7 @@
#include <linux/delay.h>
#include <linux/spi/spi.h>
#include <linux/fsl_devices.h>
+#include <linux/of_spi.h>
#include <asm/mpc52xx.h>
#include <asm/mpc52xx_psc.h>
@@ -370,24 +371,24 @@ static irqreturn_t mpc52xx_psc_spi_isr(int irq,
void *dev_id)
}
/* bus_num is used only for the case dev->platform_data == NULL */
-static int __init mpc52xx_psc_spi_do_probe(struct device *dev, u32 regaddr,
+static int __init mpc52xx_psc_spi_do_probe(struct of_device *op, u32 regaddr,
u32 size, unsigned int irq, s16 bus_num)
{
- struct fsl_spi_platform_data *pdata = dev->platform_data;
+ struct fsl_spi_platform_data *pdata = op->dev.platform_data;
struct mpc52xx_psc_spi *mps;
struct spi_master *master;
int ret;
- master = spi_alloc_master(dev, sizeof *mps);
+ master = spi_alloc_master(&op->dev, sizeof *mps);
if (master == NULL)
return -ENOMEM;
- dev_set_drvdata(dev, master);
+ dev_set_drvdata(&op->dev, master);
mps = spi_master_get_devdata(master);
mps->irq = irq;
if (pdata == NULL) {
- dev_warn(dev, "probe called without platform data, no "
+ dev_warn(&op->dev, "probe called without platform data, no "
"(de)activate_cs function will be called\n");
mps->activate_cs = NULL;
mps->deactivate_cs = NULL;
@@ -407,7 +408,7 @@ static int __init mpc52xx_psc_spi_do_probe(struct
device *dev, u32 regaddr,
mps->psc = ioremap(regaddr, size);
if (!mps->psc) {
- dev_err(dev, "could not ioremap I/O port range\n");
+ dev_err(&op->dev, "could not ioremap I/O port range\n");
ret = -EFAULT;
goto free_master;
}
@@ -439,6 +440,8 @@ static int __init mpc52xx_psc_spi_do_probe(struct
device *dev, u32 regaddr,
if (ret < 0)
goto unreg_master;
+ of_register_spi_devices(master, op->node);
+
return ret;
unreg_master:
@@ -495,7 +498,7 @@ static int __init mpc52xx_psc_spi_of_probe(struct
of_device *op,
id = *psc_nump + 1;
}
- return mpc52xx_psc_spi_do_probe(&op->dev, (u32)regaddr64, (u32)size64,
+ return mpc52xx_psc_spi_do_probe(op, (u32)regaddr64, (u32)size64,
irq_of_parse_and_map(op->node, 0), id);
}
--
Jon Smirl
jonsmirl@gmail.com
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-05-22 13:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-04-30 22:31 [PATCH] mpc52xx_psc_spi: Convert to cs_control callback Anton Vorontsov
2009-05-22 5:07 ` Grant Likely
2009-05-22 13:29 ` Jon Smirl
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).