[PATCH] spi: Master driver for NXP SC18IS602/603

2012-08-18 Thread Guenter Roeck
This driver adds support for NXP SC18IS602/603 I2C to SPI bus bridge.

Signed-off-by: Guenter Roeck 
---
There is one checkatch warning:
WARNING: please write a paragraph that describes the config symbol fully
#101: FILE: drivers/spi/Kconfig:328:
+config SPI_SC18IS602
I ignored it to follow the description style of other SPI master drivers.

 .../devicetree/bindings/spi/spi-sc18is602.txt  |   23 ++
 Documentation/spi/spi-sc18is602|   36 ++
 drivers/spi/Kconfig|6 +
 drivers/spi/Makefile   |1 +
 drivers/spi/spi-sc18is602.c|  364 
 include/linux/platform_data/sc18is602.h|   19 +
 6 files changed, 449 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/spi/spi-sc18is602.txt
 create mode 100644 Documentation/spi/spi-sc18is602
 create mode 100644 drivers/spi/spi-sc18is602.c
 create mode 100644 include/linux/platform_data/sc18is602.h

diff --git a/Documentation/devicetree/bindings/spi/spi-sc18is602.txt 
b/Documentation/devicetree/bindings/spi/spi-sc18is602.txt
new file mode 100644
index 000..02f9033
--- /dev/null
+++ b/Documentation/devicetree/bindings/spi/spi-sc18is602.txt
@@ -0,0 +1,23 @@
+NXP SC18IS602/SCIS603
+
+Required properties:
+   - compatible : Should be one of
+   "nxp,sc18is602"
+   "nxp,sc18is602b"
+   "nxp,sc18is603"
+   - reg: I2C bus address
+
+Optional properties:
+   - clock-frequency : external oscillator clock frequency. If not
+ specified, the SC18IS602 default frequency (7372000) will be used.
+
+The clock-frequency property is relevant and needed only if the chip has an
+external oscillator (SC18IS603).
+
+Example:
+
+   sc18is603@28 {
+   compatible = "nxp,sc18is603";
+   reg = <0x28>;
+   clock-frequency = <14744000>;
+   }
diff --git a/Documentation/spi/spi-sc18is602 b/Documentation/spi/spi-sc18is602
new file mode 100644
index 000..a457028
--- /dev/null
+++ b/Documentation/spi/spi-sc18is602
@@ -0,0 +1,36 @@
+Kernel driver spi-sc18is602
+===
+
+Supported chips:
+  * NXP SI18IS602/602B/603
+Datasheet: http://www.nxp.com/documents/data_sheet/SC18IS602_602B_603.pdf
+
+Author:
+Guenter Roeck 
+
+
+Description
+---
+
+This driver provides connects a NXP SC18IS602/603 I2C-bus to SPI bridge to the
+kernel's SPI core subsystem.
+
+The driver does not probe for supported chips, since the SI18IS602/603 does not
+support Chip ID registers. You will have to instantiate the devices explicitly.
+Please see Documentation/i2c/instantiating-devices for details.
+
+
+Usage Notes
+---
+
+This driver requires the I2C adapter driver to support raw I2C messages. I2C
+adapter drivers which can only handle the SMBus protocol are not supported.
+
+The maximum SPI message size supported by SC18IS602/603 is 200 bytes. Attempts
+to initiate longer transfers will fail with -EINVAL. EEPROM read operations and
+similar large accesses have to be split into multiple chunks of no more than
+200 bytes per SPI message (128 bytes of data per message is recommended). This
+means that programs such as "cp" or "od", which automatically use large block
+sizes to access a device, can not be used directly to read data from EEPROM.
+Programs such as dd, where the block size can be specified, should be used
+instead.
diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig
index 5f84b55..920bb4d 100644
--- a/drivers/spi/Kconfig
+++ b/drivers/spi/Kconfig
@@ -325,6 +325,12 @@ config SPI_S3C64XX
help
  SPI driver for Samsung S3C64XX and newer SoCs.
 
+config SPI_SC18IS602
+   tristate "NXP SC18IS602/602B/603 I2C to SPI bridge"
+   depends on I2C
+   help
+ SPI driver for NXP SC18IS602/602B/603 I2C to SPI bridge.
+
 config SPI_SH_MSIOF
tristate "SuperH MSIOF SPI controller"
depends on SUPERH && HAVE_CLK
diff --git a/drivers/spi/Makefile b/drivers/spi/Makefile
index 3920dcf..7559c98 100644
--- a/drivers/spi/Makefile
+++ b/drivers/spi/Makefile
@@ -51,6 +51,7 @@ obj-$(CONFIG_SPI_S3C24XX) += spi-s3c24xx-hw.o
 spi-s3c24xx-hw-y   := spi-s3c24xx.o
 spi-s3c24xx-hw-$(CONFIG_SPI_S3C24XX_FIQ) += spi-s3c24xx-fiq.o
 obj-$(CONFIG_SPI_S3C64XX)  += spi-s3c64xx.o
+obj-$(CONFIG_SPI_SC18IS602)+= spi-sc18is602.o
 obj-$(CONFIG_SPI_SH)   += spi-sh.o
 obj-$(CONFIG_SPI_SH_HSPI)  += spi-sh-hspi.o
 obj-$(CONFIG_SPI_SH_MSIOF) += spi-sh-msiof.o
diff --git a/drivers/spi/spi-sc18is602.c b/drivers/spi/spi-sc18is602.c
new file mode 100644
index 000..dd98964
--- /dev/null
+++ b/drivers/spi/spi-sc18is602.c
@@ -0,0 +1,364 @@
+/*
+ * NXP SC18IS602/603 SPI driver
+ *
+ * Copyright (C) Guenter Roeck 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it u

72h à prix coutants dans tous les magasins

2012-08-18 Thread Cdiscount par Galeriedesmarques.fr
Pour voir le message, veuillez utiliser un lecteur de mail compatible HTML

Lien miroir : 
http://m10-fr.com/mc10_m/YT04JmI9MTgwNTMmYz0xOTYxNjQxJmQ9MjAxMi0wOC0xOCAxODoxMDowMSZlPTEmaD0xODA1MiZmPTE4MDUzJmc9MTgwNTM=

Lien de désinscription : 
http://m10-fr.com/mc10_unsub/YT04JmI9MTgwNTMmYz0xOTYxNjQxJmQ9MjAxMi0wOC0xOCAxODoxMDowMSZlPTEmaD0xODA1MiZmPTE4MDUzJmc9MTgwNTM=


--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


[PATCH 1/4] spi/mpc52xx: Fix error handling in probe function

2012-08-18 Thread Guenter Roeck
The call to spi_master_put() is needed to free device memory. It must be called
after spi_alloc_master, and must only be called after the device memory is no
longer used.

Signed-off-by: Guenter Roeck 
---
 drivers/spi/spi-mpc52xx.c |5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/spi/spi-mpc52xx.c b/drivers/spi/spi-mpc52xx.c
index cb3a383..a749589 100644
--- a/drivers/spi/spi-mpc52xx.c
+++ b/drivers/spi/spi-mpc52xx.c
@@ -454,7 +454,7 @@ static int __devinit mpc52xx_spi_probe(struct 
platform_device *op)
GFP_KERNEL);
if (!ms->gpio_cs) {
rc = -ENOMEM;
-   goto err_alloc;
+   goto err_alloc_gpio;
}
 
for (i = 0; i < ms->gpio_cs_count; i++) {
@@ -514,12 +514,13 @@ static int __devinit mpc52xx_spi_probe(struct 
platform_device *op)
 
  err_register:
dev_err(&ms->master->dev, "initialization failed\n");
-   spi_master_put(master);
  err_gpio:
while (i-- > 0)
gpio_free(ms->gpio_cs[i]);
 
kfree(ms->gpio_cs);
+ err_alloc_gpio:
+   spi_master_put(master);
  err_alloc:
  err_init:
iounmap(regs);
-- 
1.7.9.7


--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


[PATCH 3/4] spi/mpc52xx-psc: Avoid access to freed memory in device remove function

2012-08-18 Thread Guenter Roeck
The call to spi_unregister_master() in the device remove function frees device
memory, and with it any device local data. However, device local data is still
accessed after the call to spi_unregister_master().

Acquire a reference to the SPI master device and release it after cleanup is
complete to solve the problem.

Signed-off-by: Guenter Roeck 
---
 drivers/spi/spi-mpc52xx-psc.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/spi/spi-mpc52xx-psc.c b/drivers/spi/spi-mpc52xx-psc.c
index 6604715..bd47d26 100644
--- a/drivers/spi/spi-mpc52xx-psc.c
+++ b/drivers/spi/spi-mpc52xx-psc.c
@@ -481,7 +481,7 @@ static int __devinit mpc52xx_psc_spi_of_probe(struct 
platform_device *op)
 
 static int __devexit mpc52xx_psc_spi_of_remove(struct platform_device *op)
 {
-   struct spi_master *master = dev_get_drvdata(&op->dev);
+   struct spi_master *master = spi_master_get(dev_get_drvdata(&op->dev));
struct mpc52xx_psc_spi *mps = spi_master_get_devdata(master);
 
flush_workqueue(mps->workqueue);
@@ -490,6 +490,7 @@ static int __devexit mpc52xx_psc_spi_of_remove(struct 
platform_device *op)
free_irq(mps->irq, mps);
if (mps->psc)
iounmap(mps->psc);
+   spi_master_put(master);
 
return 0;
 }
-- 
1.7.9.7


--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


[PATCH 2/4] spi/mpc52xx: Fix device remove function

2012-08-18 Thread Guenter Roeck
The call sequence spi_alloc_master/spi_register_master/spi_unregister_master is
complete; it reduces the device reference count to zero, which results in
device memory being freed. An extra call to spi_master_put is unnecessary
and results in an access to free memory.

At the same time, since the call to spi_unregister_master results in device
memory being freed, it must no longer be accessed afterwards.

To fix both problems, call spi_master_get to get an extra reference to the
device, and call spi_master_put only after the last access to device data.

Signed-off-by: Guenter Roeck 
---
 drivers/spi/spi-mpc52xx.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/spi/spi-mpc52xx.c b/drivers/spi/spi-mpc52xx.c
index a749589..0454106 100644
--- a/drivers/spi/spi-mpc52xx.c
+++ b/drivers/spi/spi-mpc52xx.c
@@ -529,7 +529,7 @@ static int __devinit mpc52xx_spi_probe(struct 
platform_device *op)
 
 static int __devexit mpc52xx_spi_remove(struct platform_device *op)
 {
-   struct spi_master *master = dev_get_drvdata(&op->dev);
+   struct spi_master *master = spi_master_get(dev_get_drvdata(&op->dev));
struct mpc52xx_spi *ms = spi_master_get_devdata(master);
int i;
 
@@ -541,8 +541,8 @@ static int __devexit mpc52xx_spi_remove(struct 
platform_device *op)
 
kfree(ms->gpio_cs);
spi_unregister_master(master);
-   spi_master_put(master);
iounmap(ms->regs);
+   spi_master_put(master);
 
return 0;
 }
-- 
1.7.9.7


--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


[PATCH 4/4] spi/mpc512x-psc: Avoid access to freed memory in device remove function

2012-08-18 Thread Guenter Roeck
The call to spi_unregister_master() in the device remove function frees device
memory, and with it any device local data. However, device local data is still
accessed after the call to spi_unregister_master().

Acquire a reference to the SPI master device and release it after cleanup is
complete to solve the problem.

Signed-off-by: Guenter Roeck 
---
 drivers/spi/spi-mpc512x-psc.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/spi/spi-mpc512x-psc.c b/drivers/spi/spi-mpc512x-psc.c
index 4c63f77..0a1e39e 100644
--- a/drivers/spi/spi-mpc512x-psc.c
+++ b/drivers/spi/spi-mpc512x-psc.c
@@ -494,7 +494,7 @@ free_master:
 
 static int __devexit mpc512x_psc_spi_do_remove(struct device *dev)
 {
-   struct spi_master *master = dev_get_drvdata(dev);
+   struct spi_master *master = spi_master_get(dev_get_drvdata(dev));
struct mpc512x_psc_spi *mps = spi_master_get_devdata(master);
 
flush_workqueue(mps->workqueue);
@@ -503,6 +503,7 @@ static int __devexit mpc512x_psc_spi_do_remove(struct 
device *dev)
free_irq(mps->irq, mps);
if (mps->psc)
iounmap(mps->psc);
+   spi_master_put(master);
 
return 0;
 }
-- 
1.7.9.7


--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


Re: [PATCH] spi/pl022: Fill master->dev.of_node to get spi devices registered via DT

2012-08-18 Thread Linus Walleij
On Sat, Aug 18, 2012 at 4:25 AM, Viresh Kumar  wrote:

> spi_register_master() calls of_register_spi_devices() to register spi devices.
> This routine expects master->dev.of_node to be a valid pointer. This is
> responsibility of master driver to fill this field, which wasn't done for 
> pl022.
> Fix it to get devices added to pl022.

OK...

> master->rt = platform_info->rt;
> +   master->dev.of_node = dev->of_node;

Isn't this one of those things that *have* to be #ifdef CONFIG_OF?

Next iteration, remember to add Mark Brown on To: because je's taking
care of SPI patches for the moment.

Yours,
Linus Walleij

--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general