selinux: remove secondary ops call to inode_setattr
[linux-2.6/linux-2.6-openrd.git] / drivers / pcmcia / pxa2xx_cm_x270.c
blob6c3aac3771260202e6c05325bc180ac9c64f32e4
1 /*
2 * linux/drivers/pcmcia/pxa/pxa_cm_x270.c
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
8 * Compulab Ltd., 2003, 2007, 2008
9 * Mike Rapoport <mike@compulab.co.il>
13 #include <linux/platform_device.h>
14 #include <linux/irq.h>
15 #include <linux/delay.h>
16 #include <linux/gpio.h>
18 #include <asm/mach-types.h>
19 #include <mach/pxa-regs.h>
21 #include "soc_common.h"
23 #define GPIO_PCMCIA_S0_CD_VALID (84)
24 #define GPIO_PCMCIA_S0_RDYINT (82)
25 #define GPIO_PCMCIA_RESET (53)
27 #define PCMCIA_S0_CD_VALID IRQ_GPIO(GPIO_PCMCIA_S0_CD_VALID)
28 #define PCMCIA_S0_RDYINT IRQ_GPIO(GPIO_PCMCIA_S0_RDYINT)
31 static struct pcmcia_irqs irqs[] = {
32 { 0, PCMCIA_S0_CD_VALID, "PCMCIA0 CD" },
35 static int cmx270_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
37 int ret = gpio_request(GPIO_PCMCIA_RESET, "PCCard reset");
38 if (ret)
39 return ret;
40 gpio_direction_output(GPIO_PCMCIA_RESET, 0);
42 skt->irq = PCMCIA_S0_RDYINT;
43 ret = soc_pcmcia_request_irqs(skt, irqs, ARRAY_SIZE(irqs));
44 if (!ret)
45 gpio_free(GPIO_PCMCIA_RESET);
47 return ret;
50 static void cmx270_pcmcia_shutdown(struct soc_pcmcia_socket *skt)
52 soc_pcmcia_free_irqs(skt, irqs, ARRAY_SIZE(irqs));
53 gpio_free(GPIO_PCMCIA_RESET);
57 static void cmx270_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
58 struct pcmcia_state *state)
60 state->detect = (gpio_get_value(GPIO_PCMCIA_S0_CD_VALID) == 0) ? 1 : 0;
61 state->ready = (gpio_get_value(GPIO_PCMCIA_S0_RDYINT) == 0) ? 0 : 1;
62 state->bvd1 = 1;
63 state->bvd2 = 1;
64 state->vs_3v = 0;
65 state->vs_Xv = 0;
66 state->wrprot = 0; /* not available */
70 static int cmx270_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
71 const socket_state_t *state)
73 switch (skt->nr) {
74 case 0:
75 if (state->flags & SS_RESET) {
76 gpio_set_value(GPIO_PCMCIA_RESET, 1);
77 udelay(10);
78 gpio_set_value(GPIO_PCMCIA_RESET, 0);
80 break;
83 return 0;
86 static void cmx270_pcmcia_socket_init(struct soc_pcmcia_socket *skt)
90 static void cmx270_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt)
95 static struct pcmcia_low_level cmx270_pcmcia_ops __initdata = {
96 .owner = THIS_MODULE,
97 .hw_init = cmx270_pcmcia_hw_init,
98 .hw_shutdown = cmx270_pcmcia_shutdown,
99 .socket_state = cmx270_pcmcia_socket_state,
100 .configure_socket = cmx270_pcmcia_configure_socket,
101 .socket_init = cmx270_pcmcia_socket_init,
102 .socket_suspend = cmx270_pcmcia_socket_suspend,
103 .nr = 1,
106 static struct platform_device *cmx270_pcmcia_device;
108 int __init cmx270_pcmcia_init(void)
110 int ret;
112 cmx270_pcmcia_device = platform_device_alloc("pxa2xx-pcmcia", -1);
114 if (!cmx270_pcmcia_device)
115 return -ENOMEM;
117 ret = platform_device_add_data(cmx270_pcmcia_device, &cmx270_pcmcia_ops,
118 sizeof(cmx270_pcmcia_ops));
120 if (ret == 0) {
121 printk(KERN_INFO "Registering cm-x270 PCMCIA interface.\n");
122 ret = platform_device_add(cmx270_pcmcia_device);
125 if (ret)
126 platform_device_put(cmx270_pcmcia_device);
128 return ret;
131 void __exit cmx270_pcmcia_exit(void)
133 platform_device_unregister(cmx270_pcmcia_device);