treewide: remove redundant IS_ERR() before error code check
[linux/fpc-iii.git] / drivers / pcmcia / pxa2xx_palmld.c
blobcfff41ac9ca29e47b594759241ef577528698785
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3 * linux/drivers/pcmcia/pxa2xx_palmld.c
5 * Driver for Palm LifeDrive PCMCIA
7 * Copyright (C) 2006 Alex Osborne <ato@meshy.org>
8 * Copyright (C) 2007-2011 Marek Vasut <marek.vasut@gmail.com>
9 */
11 #include <linux/module.h>
12 #include <linux/platform_device.h>
13 #include <linux/gpio.h>
15 #include <asm/mach-types.h>
16 #include <mach/palmld.h>
17 #include "soc_common.h"
19 static struct gpio palmld_pcmcia_gpios[] = {
20 { GPIO_NR_PALMLD_PCMCIA_POWER, GPIOF_INIT_LOW, "PCMCIA Power" },
21 { GPIO_NR_PALMLD_PCMCIA_RESET, GPIOF_INIT_HIGH,"PCMCIA Reset" },
24 static int palmld_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
26 int ret;
28 ret = gpio_request_array(palmld_pcmcia_gpios,
29 ARRAY_SIZE(palmld_pcmcia_gpios));
31 skt->stat[SOC_STAT_RDY].gpio = GPIO_NR_PALMLD_PCMCIA_READY;
32 skt->stat[SOC_STAT_RDY].name = "PCMCIA Ready";
34 return ret;
37 static void palmld_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
39 gpio_free_array(palmld_pcmcia_gpios, ARRAY_SIZE(palmld_pcmcia_gpios));
42 static void palmld_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
43 struct pcmcia_state *state)
45 state->detect = 1; /* always inserted */
46 state->vs_3v = 1;
47 state->vs_Xv = 0;
50 static int palmld_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
51 const socket_state_t *state)
53 gpio_set_value(GPIO_NR_PALMLD_PCMCIA_POWER, 1);
54 gpio_set_value(GPIO_NR_PALMLD_PCMCIA_RESET,
55 !!(state->flags & SS_RESET));
57 return 0;
60 static struct pcmcia_low_level palmld_pcmcia_ops = {
61 .owner = THIS_MODULE,
63 .first = 1,
64 .nr = 1,
66 .hw_init = palmld_pcmcia_hw_init,
67 .hw_shutdown = palmld_pcmcia_hw_shutdown,
69 .socket_state = palmld_pcmcia_socket_state,
70 .configure_socket = palmld_pcmcia_configure_socket,
73 static struct platform_device *palmld_pcmcia_device;
75 static int __init palmld_pcmcia_init(void)
77 int ret;
79 if (!machine_is_palmld())
80 return -ENODEV;
82 palmld_pcmcia_device = platform_device_alloc("pxa2xx-pcmcia", -1);
83 if (!palmld_pcmcia_device)
84 return -ENOMEM;
86 ret = platform_device_add_data(palmld_pcmcia_device, &palmld_pcmcia_ops,
87 sizeof(palmld_pcmcia_ops));
89 if (!ret)
90 ret = platform_device_add(palmld_pcmcia_device);
92 if (ret)
93 platform_device_put(palmld_pcmcia_device);
95 return ret;
98 static void __exit palmld_pcmcia_exit(void)
100 platform_device_unregister(palmld_pcmcia_device);
103 module_init(palmld_pcmcia_init);
104 module_exit(palmld_pcmcia_exit);
106 MODULE_AUTHOR("Alex Osborne <ato@meshy.org>,"
107 " Marek Vasut <marek.vasut@gmail.com>");
108 MODULE_DESCRIPTION("PCMCIA support for Palm LifeDrive");
109 MODULE_ALIAS("platform:pxa2xx-pcmcia");
110 MODULE_LICENSE("GPL");