ARM: sa11x0: convert set_xxx_data() to register_xxx()
Russell King [Tue, 6 Oct 2009 13:55:53 +0000 (14:55 +0100)]
Only register devices if we have platform data for those which require
platform data.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>

13 files changed:
arch/arm/mach-sa1100/assabet.c
arch/arm/mach-sa1100/badge4.c
arch/arm/mach-sa1100/cerf.c
arch/arm/mach-sa1100/collie.c
arch/arm/mach-sa1100/generic.c
arch/arm/mach-sa1100/generic.h
arch/arm/mach-sa1100/h3600.c
arch/arm/mach-sa1100/hackkit.c
arch/arm/mach-sa1100/jornada720.c
arch/arm/mach-sa1100/lart.c
arch/arm/mach-sa1100/pleb.c
arch/arm/mach-sa1100/shannon.c
arch/arm/mach-sa1100/simpad.c

index 55e6447..169e5b8 100644 (file)
@@ -249,10 +249,10 @@ static void __init assabet_init(void)
 #endif
        }
 
-       sa11x0_set_flash_data(&assabet_flash_data, assabet_flash_resources,
-                             ARRAY_SIZE(assabet_flash_resources));
-       sa11x0_set_irda_data(&assabet_irda_data);
-       sa11x0_set_mcp_data(&assabet_mcp_data);
+       sa11x0_register_mtd(&assabet_flash_data, assabet_flash_resources,
+                           ARRAY_SIZE(assabet_flash_resources));
+       sa11x0_register_irda(&assabet_irda_data);
+       sa11x0_register_mcp(&assabet_mcp_data);
 }
 
 /*
index ab5883b..051ec0f 100644 (file)
@@ -212,7 +212,7 @@ static int __init badge4_init(void)
        /* maybe turn on 5v0 from the start */
        badge4_set_5V(BADGE4_5V_INITIALLY, five_v_on);
 
-       sa11x0_set_flash_data(&badge4_flash_data, &badge4_flash_resource, 1);
+       sa11x0_register_mtd(&badge4_flash_data, &badge4_flash_resource, 1);
 
        return 0;
 }
index fd3ad9c..bc950ef 100644 (file)
@@ -129,8 +129,8 @@ static struct mcp_plat_data cerf_mcp_data = {
 static void __init cerf_init(void)
 {
        platform_add_devices(cerf_devices, ARRAY_SIZE(cerf_devices));
-       sa11x0_set_flash_data(&cerf_flash_data, &cerf_flash_resource, 1);
-       sa11x0_set_mcp_data(&cerf_mcp_data);
+       sa11x0_register_mtd(&cerf_flash_data, &cerf_flash_resource, 1);
+       sa11x0_register_mcp(&cerf_mcp_data);
 }
 
 MACHINE_START(CERF, "Intrinsyc CerfBoard/CerfCube")
index bbf2ebc..be7e5a3 100644 (file)
@@ -272,9 +272,9 @@ static void __init collie_init(void)
                printk(KERN_WARNING "collie: Unable to register LoCoMo device\n");
        }
 
-       sa11x0_set_flash_data(&collie_flash_data, collie_flash_resources,
-                             ARRAY_SIZE(collie_flash_resources));
-       sa11x0_set_mcp_data(&collie_mcp_data);
+       sa11x0_register_mtd(&collie_flash_data, collie_flash_resources,
+                           ARRAY_SIZE(collie_flash_resources));
+       sa11x0_register_mcp(&collie_mcp_data);
 
        sharpsl_save_param();
 }
index 23cfdd5..9faea15 100644 (file)
@@ -162,6 +162,17 @@ static void sa1100_power_off(void)
        PMCR = PMCR_SF;
 }
 
+static void sa11x0_register_device(struct platform_device *dev, void *data)
+{
+       int err;
+       dev->dev.platform_data = data;
+       err = platform_device_register(dev);
+       if (err)
+               printk(KERN_ERR "Unable to register device %s: %d\n",
+                       dev->name, err);
+}
+
+
 static struct resource sa11x0udc_resources[] = {
        [0] = {
                .start  = 0x80000000,
@@ -234,9 +245,9 @@ static struct platform_device sa11x0mcp_device = {
        .resource       = sa11x0mcp_resources,
 };
 
-void sa11x0_set_mcp_data(struct mcp_plat_data *data)
+void sa11x0_register_mcp(struct mcp_plat_data *data)
 {
-       sa11x0mcp_device.dev.platform_data = data;
+       sa11x0_register_device(&sa11x0mcp_device, data);
 }
 
 static struct resource sa11x0ssp_resources[] = {
@@ -293,13 +304,13 @@ static struct platform_device sa11x0mtd_device = {
        .id             = -1,
 };
 
-void sa11x0_set_flash_data(struct flash_platform_data *flash,
-                          struct resource *res, int nr)
+void sa11x0_register_mtd(struct flash_platform_data *flash,
+                        struct resource *res, int nr)
 {
        flash->name = "sa1100";
-       sa11x0mtd_device.dev.platform_data = flash;
        sa11x0mtd_device.resource = res;
        sa11x0mtd_device.num_resources = nr;
+       sa11x0_register_device(&sa11x0mtd_device, flash);
 }
 
 static struct resource sa11x0ir_resources[] = {
@@ -329,9 +340,9 @@ static struct platform_device sa11x0ir_device = {
        .resource       = sa11x0ir_resources,
 };
 
-void sa11x0_set_irda_data(struct irda_platform_data *irda)
+void sa11x0_register_irda(struct irda_platform_data *irda)
 {
-       sa11x0ir_device.dev.platform_data = irda;
+       sa11x0_register_device(&sa11x0ir_device, irda);
 }
 
 static struct platform_device sa11x0rtc_device = {
@@ -343,21 +354,15 @@ static struct platform_device *sa11x0_devices[] __initdata = {
        &sa11x0udc_device,
        &sa11x0uart1_device,
        &sa11x0uart3_device,
-       &sa11x0mcp_device,
        &sa11x0ssp_device,
        &sa11x0pcmcia_device,
        &sa11x0fb_device,
-       &sa11x0mtd_device,
        &sa11x0rtc_device,
 };
 
 static int __init sa1100_init(void)
 {
        pm_power_off = sa1100_power_off;
-
-       if (sa11x0ir_device.dev.platform_data)
-               platform_device_register(&sa11x0ir_device);
-
        return platform_add_devices(sa11x0_devices, ARRAY_SIZE(sa11x0_devices));
 }
 
index 793c2e6..ec03f18 100644 (file)
@@ -32,14 +32,11 @@ extern unsigned int sa11x0_ppcr_to_freq(unsigned int idx);
 struct flash_platform_data;
 struct resource;
 
-extern void sa11x0_set_flash_data(struct flash_platform_data *flash,
-                                 struct resource *res, int nr);
-
-struct sa11x0_ssp_plat_ops;
-extern void sa11x0_set_ssp_data(struct sa11x0_ssp_plat_ops *ops);
+void sa11x0_register_mtd(struct flash_platform_data *flash,
+                        struct resource *res, int nr);
 
 struct irda_platform_data;
-void sa11x0_set_irda_data(struct irda_platform_data *irda);
+void sa11x0_register_irda(struct irda_platform_data *irda);
 
 struct mcp_plat_data;
-void sa11x0_set_mcp_data(struct mcp_plat_data *data);
+void sa11x0_register_mcp(struct mcp_plat_data *data);
index 0eb2f15..0b4b870 100644 (file)
@@ -102,8 +102,8 @@ static struct irda_platform_data h3600_irda_data = {
 
 static void h3xxx_mach_init(void)
 {
-       sa11x0_set_flash_data(&h3xxx_flash_data, &h3xxx_flash_resource, 1);
-       sa11x0_set_irda_data(&h3600_irda_data);
+       sa11x0_register_mtd(&h3xxx_flash_data, &h3xxx_flash_resource, 1);
+       sa11x0_register_irda(&h3600_irda_data);
 }
 
 /*
index e7056c0..51568df 100644 (file)
@@ -187,7 +187,7 @@ static struct resource hackkit_flash_resource = {
 
 static void __init hackkit_init(void)
 {
-       sa11x0_set_flash_data(&hackkit_flash_data, &hackkit_flash_resource, 1);
+       sa11x0_register_mtd(&hackkit_flash_data, &hackkit_flash_resource, 1);
 }
 
 /**********************************************************************
index fd776bb..13ebd2d 100644 (file)
@@ -354,7 +354,7 @@ static struct resource jornada720_flash_resource = {
 
 static void __init jornada720_mach_init(void)
 {
-       sa11x0_set_flash_data(&jornada720_flash_data, &jornada720_flash_resource, 1);
+       sa11x0_register_mtd(&jornada720_flash_data, &jornada720_flash_resource, 1);
 }
 
 MACHINE_START(JORNADA720, "HP Jornada 720")
index 1f940df..68069d6 100644 (file)
@@ -28,7 +28,7 @@ static struct mcp_plat_data lart_mcp_data = {
 
 static void __init lart_init(void)
 {
-       sa11x0_set_mcp_data(&lart_mcp_data);
+       sa11x0_register_mcp(&lart_mcp_data);
 }
 
 static struct map_desc lart_io_desc[] __initdata = {
index e1458bc..1ccd601 100644 (file)
@@ -109,7 +109,7 @@ static struct flash_platform_data pleb_flash_data = {
 
 static void __init pleb_init(void)
 {
-       sa11x0_set_flash_data(&pleb_flash_data, pleb_flash_resources,
+       sa11x0_register_mtd(&pleb_flash_data, pleb_flash_resources,
                              ARRAY_SIZE(pleb_flash_resources));
 
 
index ddd917d..85e82bb 100644 (file)
@@ -59,8 +59,8 @@ static struct mcp_plat_data shannon_mcp_data = {
 
 static void __init shannon_init(void)
 {
-       sa11x0_set_flash_data(&shannon_flash_data, &shannon_flash_resource, 1);
-       sa11x0_set_mcp_data(&shannon_mcp_data);
+       sa11x0_register_mtd(&shannon_flash_data, &shannon_flash_resource, 1);
+       sa11x0_register_mcp(&shannon_mcp_data);
 }
 
 static void __init shannon_map_io(void)
index 3c74534..49cfd64 100644 (file)
@@ -166,9 +166,9 @@ static void __init simpad_map_io(void)
        PCFR = 0;
        PSDR = 0;
 
-       sa11x0_set_flash_data(&simpad_flash_data, simpad_flash_resources,
+       sa11x0_register_mtd(&simpad_flash_data, simpad_flash_resources,
                              ARRAY_SIZE(simpad_flash_resources));
-       sa11x0_set_mcp_data(&simpad_mcp_data);
+       sa11x0_register_mcp(&simpad_mcp_data);
 }
 
 static void simpad_power_off(void)