static int __init sg2_pcmcia_init(void) { int ret; if (!machine_is_stargate2()) return -ENODEV; sg2_pcmcia_device = platform_device_alloc("pxa2xx-pcmcia", -1); if (!sg2_pcmcia_device) return -ENOMEM; ret = gpio_request_array(sg2_pcmcia_gpios, ARRAY_SIZE(sg2_pcmcia_gpios)); if (ret) goto error_put_platform_device; ret = platform_device_add_data(sg2_pcmcia_device, &sg2_pcmcia_ops, sizeof(sg2_pcmcia_ops)); if (ret) goto error_free_gpios; ret = platform_device_add(sg2_pcmcia_device); if (ret) goto error_free_gpios; return 0; error_free_gpios: gpio_free_array(sg2_pcmcia_gpios, ARRAY_SIZE(sg2_pcmcia_gpios)); error_put_platform_device: platform_device_put(sg2_pcmcia_device); return ret; }
static int __init sg2_pcmcia_init(void) { int ret; if (!machine_is_stargate2()) return -ENODEV; sg2_pcmcia_device = platform_device_alloc("pxa2xx-pcmcia", -1); if (!sg2_pcmcia_device) return -ENOMEM; ret = gpio_request(SG2_S0_BUFF_CTL, "SG2 CF buff ctl"); if (ret) goto error_put_platform_device; ret = gpio_request(SG2_S0_POWER_CTL, "SG2 CF power ctl"); if (ret) goto error_free_gpio_buff_ctl; ret = gpio_request(SG2_S0_GPIO_RESET, "SG2 CF reset"); if (ret) goto error_free_gpio_power_ctl; /* Set gpio directions */ gpio_direction_output(SG2_S0_BUFF_CTL, 0); gpio_direction_output(SG2_S0_POWER_CTL, 1); gpio_direction_output(SG2_S0_GPIO_RESET, 1); ret = platform_device_add_data(sg2_pcmcia_device, &sg2_pcmcia_ops, sizeof(sg2_pcmcia_ops)); if (ret) goto error_free_gpio_reset; ret = platform_device_add(sg2_pcmcia_device); if (ret) goto error_free_gpio_reset; return 0; error_free_gpio_reset: gpio_free(SG2_S0_GPIO_RESET); error_free_gpio_power_ctl: gpio_free(SG2_S0_POWER_CTL); error_free_gpio_buff_ctl: gpio_free(SG2_S0_BUFF_CTL); error_put_platform_device: platform_device_put(sg2_pcmcia_device); return ret; }