Skip to contentSkip to conversation

spi: check platform_device_register_simple() error

PATCH In review Akinobu Mita 3 participants 3 messages Nov 27, 2006 – Nov 28, 2006 SPI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 spi: check platform_device_register_simple() error

This patch checks the return value of platform_device_register_simple().

Cc David Brownell <[email protected]>
---
 drivers/spi/spi_butterfly.c |    2 ++
 1 file changed, 2 insertions(+)
drivers/spi/spi_butterfly.c +2 -0
Index: work-fault-inject/drivers/spi/spi_butterfly.c
===================================================================
@@ -250,6 +250,8 @@ static void butterfly_attach(struct parp
 	 * setting up a platform device like this is an ugly kluge...
 	 */
 	pdev = platform_device_register_simple("butterfly", -1, NULL, 0);
+	if (IS_ERR(pdev))
+		return;
 
 	master = spi_alloc_master(&pdev->dev, sizeof *pp);
 	if (!master) {
Acked-by on v1 1/1
#1 lore raw
Quoted 4 lines · Akinobu Mita

This patch checks the return value of platform_device_register_simple().

Cc David Brownell <[email protected]>

... thanks, good catch.

Quoted 19 lines
---
 drivers/spi/spi_butterfly.c |    2 ++
 1 file changed, 2 insertions(+)

Index: work-fault-inject/drivers/spi/spi_butterfly.c
===================================================================

drivers/spi/spi_butterfly.c +2 -0
@@ -250,6 +250,8 @@ static void butterfly_attach(struct parp
 	 * setting up a platform device like this is an ugly kluge...
 	 */
 	pdev = platform_device_register_simple("butterfly", -1, NULL, 0);
+	if (IS_ERR(pdev))
+		return;
 
 	master = spi_alloc_master(&pdev->dev, sizeof *pp);
 	if (!master) {
#2 lore raw
In reply to Akinobu Mita
Quoted 14 lines · On Mon, 27 Nov 2006 14:09:15 +0900 Akinobu Mita <[email protected]> wrote:

This patch checks the return value of platform_device_register_simple().

Cc David Brownell <[email protected]>
---
 drivers/spi/spi_butterfly.c |    2 ++
 1 file changed, 2 insertions(+)

Index: work-fault-inject/drivers/spi/spi_butterfly.c
===================================================================

drivers/spi/spi_butterfly.c static void butterfly_attach(struct parp · line 254

Quoted 5 lines
drivers/spi/spi_butterfly.c +2 -0
@@ -250,6 +250,8 @@ static void butterfly_attach(struct parp
 	 * setting up a platform device like this is an ugly kluge...
 	 */
 	pdev = platform_device_register_simple("butterfly", -1, NULL, 0);
+	if (IS_ERR(pdev))
+		return;

It'd be nice to at least print some (non-debug) message rather than simply mysteriously failing.

It'd be nicer if parport_driver.attach() didn't return void. Ho hum.