diff options
| -rw-r--r-- | drivers/pcmcia/pcmcia_ioctl.c | 90 | ||||
| -rw-r--r-- | drivers/pcmcia/rsrc_mgr.c | 86 | ||||
| -rw-r--r-- | drivers/pcmcia/rsrc_nonstatic.c | 18 | ||||
| -rw-r--r-- | include/pcmcia/ss.h | 10 |
4 files changed, 102 insertions, 102 deletions
diff --git a/drivers/pcmcia/pcmcia_ioctl.c b/drivers/pcmcia/pcmcia_ioctl.c index 5f186abca108..758ece8dc362 100644 --- a/drivers/pcmcia/pcmcia_ioctl.c +++ b/drivers/pcmcia/pcmcia_ioctl.c | |||
| @@ -138,6 +138,94 @@ static int proc_read_drivers(char *buf, char **start, off_t pos, | |||
| 138 | } | 138 | } |
| 139 | #endif | 139 | #endif |
| 140 | 140 | ||
| 141 | |||
| 142 | #ifdef CONFIG_PCMCIA_PROBE | ||
| 143 | |||
| 144 | static int adjust_irq(struct pcmcia_socket *s, adjust_t *adj) | ||
| 145 | { | ||
| 146 | int irq; | ||
| 147 | u32 mask; | ||
| 148 | |||
| 149 | irq = adj->resource.irq.IRQ; | ||
| 150 | if ((irq < 0) || (irq > 15)) | ||
| 151 | return CS_BAD_IRQ; | ||
| 152 | |||
| 153 | if (adj->Action != REMOVE_MANAGED_RESOURCE) | ||
| 154 | return 0; | ||
| 155 | |||
| 156 | mask = 1 << irq; | ||
| 157 | |||
| 158 | if (!(s->irq_mask & mask)) | ||
| 159 | return 0; | ||
| 160 | |||
| 161 | s->irq_mask &= ~mask; | ||
| 162 | |||
| 163 | return 0; | ||
| 164 | } | ||
| 165 | |||
| 166 | #else | ||
| 167 | |||
| 168 | static inline int adjust_irq(struct pcmcia_socket *s, adjust_t *adj) { | ||
| 169 | return CS_SUCCESS; | ||
| 170 | } | ||
| 171 | |||
| 172 | #endif | ||
| 173 | |||
| 174 | static int pcmcia_adjust_resource_info(adjust_t *adj) | ||
| 175 | { | ||
| 176 | struct pcmcia_socket *s; | ||
| 177 | int ret = CS_UNSUPPORTED_FUNCTION; | ||
| 178 | unsigned long flags; | ||
| 179 | |||
| 180 | down_read(&pcmcia_socket_list_rwsem); | ||
| 181 | list_for_each_entry(s, &pcmcia_socket_list, socket_list) { | ||
| 182 | |||
| 183 | if (adj->Resource == RES_IRQ) | ||
| 184 | ret = adjust_irq(s, adj); | ||
| 185 | |||
| 186 | else if (s->resource_ops->add_io) { | ||
| 187 | unsigned long begin, end; | ||
| 188 | |||
| 189 | /* you can't use the old interface if the new | ||
| 190 | * one was used before */ | ||
| 191 | spin_lock_irqsave(&s->lock, flags); | ||
| 192 | if ((s->resource_setup_new) && | ||
| 193 | !(s->resource_setup_old)) { | ||
| 194 | spin_unlock_irqrestore(&s->lock, flags); | ||
| 195 | continue; | ||
| 196 | } else if (!(s->resource_setup_old)) | ||
| 197 | s->resource_setup_old = 1; | ||
| 198 | spin_unlock_irqrestore(&s->lock, flags); | ||
| 199 | |||
| 200 | switch (adj->Resource) { | ||
| 201 | case RES_MEMORY_RANGE: | ||
| 202 | begin = adj->resource.memory.Base; | ||
| 203 | end = adj->resource.memory.Base + adj->resource.memory.Size - 1; | ||
| 204 | if (s->resource_ops->add_mem) | ||
| 205 | ret =s->resource_ops->add_mem(s, adj->Action, begin, end); | ||
| 206 | case RES_IO_RANGE: | ||
| 207 | begin = adj->resource.io.BasePort; | ||
| 208 | end = adj->resource.io.BasePort + adj->resource.io.NumPorts - 1; | ||
| 209 | if (s->resource_ops->add_io) | ||
| 210 | ret = s->resource_ops->add_io(s, adj->Action, begin, end); | ||
| 211 | } | ||
| 212 | if (!ret) { | ||
| 213 | /* as there's no way we know this is the | ||
| 214 | * last call to adjust_resource_info, we | ||
| 215 | * always need to assume this is the latest | ||
| 216 | * one... */ | ||
| 217 | spin_lock_irqsave(&s->lock, flags); | ||
| 218 | s->resource_setup_done = 1; | ||
| 219 | spin_unlock_irqrestore(&s->lock, flags); | ||
| 220 | } | ||
| 221 | } | ||
| 222 | } | ||
| 223 | up_read(&pcmcia_socket_list_rwsem); | ||
| 224 | |||
| 225 | return (ret); | ||
| 226 | } | ||
| 227 | |||
| 228 | |||
| 141 | /*====================================================================== | 229 | /*====================================================================== |
| 142 | 230 | ||
| 143 | These manage a ring buffer of events pending for one user process | 231 | These manage a ring buffer of events pending for one user process |
| @@ -546,8 +634,6 @@ static u_int ds_poll(struct file *file, poll_table *wait) | |||
| 546 | 634 | ||
| 547 | /*====================================================================*/ | 635 | /*====================================================================*/ |
| 548 | 636 | ||
| 549 | extern int pcmcia_adjust_resource_info(adjust_t *adj); | ||
| 550 | |||
| 551 | static int ds_ioctl(struct inode * inode, struct file * file, | 637 | static int ds_ioctl(struct inode * inode, struct file * file, |
| 552 | u_int cmd, u_long arg) | 638 | u_int cmd, u_long arg) |
| 553 | { | 639 | { |
diff --git a/drivers/pcmcia/rsrc_mgr.c b/drivers/pcmcia/rsrc_mgr.c index ce2226273aaa..c0e2afc79e3e 100644 --- a/drivers/pcmcia/rsrc_mgr.c +++ b/drivers/pcmcia/rsrc_mgr.c | |||
| @@ -21,86 +21,6 @@ | |||
| 21 | #include "cs_internal.h" | 21 | #include "cs_internal.h" |
| 22 | 22 | ||
| 23 | 23 | ||
| 24 | #ifdef CONFIG_PCMCIA_IOCTL | ||
| 25 | |||
| 26 | #ifdef CONFIG_PCMCIA_PROBE | ||
| 27 | |||
| 28 | static int adjust_irq(struct pcmcia_socket *s, adjust_t *adj) | ||
| 29 | { | ||
| 30 | int irq; | ||
| 31 | u32 mask; | ||
| 32 | |||
| 33 | irq = adj->resource.irq.IRQ; | ||
| 34 | if ((irq < 0) || (irq > 15)) | ||
| 35 | return CS_BAD_IRQ; | ||
| 36 | |||
| 37 | if (adj->Action != REMOVE_MANAGED_RESOURCE) | ||
| 38 | return 0; | ||
| 39 | |||
| 40 | mask = 1 << irq; | ||
| 41 | |||
| 42 | if (!(s->irq_mask & mask)) | ||
| 43 | return 0; | ||
| 44 | |||
| 45 | s->irq_mask &= ~mask; | ||
| 46 | |||
| 47 | return 0; | ||
| 48 | } | ||
| 49 | |||
| 50 | #else | ||
| 51 | |||
| 52 | static inline int adjust_irq(struct pcmcia_socket *s, adjust_t *adj) { | ||
| 53 | return CS_SUCCESS; | ||
| 54 | } | ||
| 55 | |||
| 56 | #endif | ||
| 57 | |||
| 58 | |||
| 59 | int pcmcia_adjust_resource_info(adjust_t *adj) | ||
| 60 | { | ||
| 61 | struct pcmcia_socket *s; | ||
| 62 | int ret = CS_UNSUPPORTED_FUNCTION; | ||
| 63 | unsigned long flags; | ||
| 64 | |||
| 65 | down_read(&pcmcia_socket_list_rwsem); | ||
| 66 | list_for_each_entry(s, &pcmcia_socket_list, socket_list) { | ||
| 67 | |||
| 68 | if (adj->Resource == RES_IRQ) | ||
| 69 | ret = adjust_irq(s, adj); | ||
| 70 | |||
| 71 | else if (s->resource_ops->adjust_resource) { | ||
| 72 | |||
| 73 | /* you can't use the old interface if the new | ||
| 74 | * one was used before */ | ||
| 75 | spin_lock_irqsave(&s->lock, flags); | ||
| 76 | if ((s->resource_setup_new) && | ||
| 77 | !(s->resource_setup_old)) { | ||
| 78 | spin_unlock_irqrestore(&s->lock, flags); | ||
| 79 | continue; | ||
| 80 | } else if (!(s->resource_setup_old)) | ||
| 81 | s->resource_setup_old = 1; | ||
| 82 | spin_unlock_irqrestore(&s->lock, flags); | ||
| 83 | |||
| 84 | ret = s->resource_ops->adjust_resource(s, adj); | ||
| 85 | if (!ret) { | ||
| 86 | /* as there's no way we know this is the | ||
| 87 | * last call to adjust_resource_info, we | ||
| 88 | * always need to assume this is the latest | ||
| 89 | * one... */ | ||
| 90 | spin_lock_irqsave(&s->lock, flags); | ||
| 91 | s->resource_setup_done = 1; | ||
| 92 | spin_unlock_irqrestore(&s->lock, flags); | ||
| 93 | } | ||
| 94 | } | ||
| 95 | } | ||
| 96 | up_read(&pcmcia_socket_list_rwsem); | ||
| 97 | |||
| 98 | return (ret); | ||
| 99 | } | ||
| 100 | EXPORT_SYMBOL(pcmcia_adjust_resource_info); | ||
| 101 | |||
| 102 | #endif | ||
| 103 | |||
| 104 | int pcmcia_validate_mem(struct pcmcia_socket *s) | 24 | int pcmcia_validate_mem(struct pcmcia_socket *s) |
| 105 | { | 25 | { |
| 106 | if (s->resource_ops->validate_mem) | 26 | if (s->resource_ops->validate_mem) |
| @@ -164,7 +84,8 @@ struct pccard_resource_ops pccard_static_ops = { | |||
| 164 | .adjust_io_region = NULL, | 84 | .adjust_io_region = NULL, |
| 165 | .find_io = NULL, | 85 | .find_io = NULL, |
| 166 | .find_mem = NULL, | 86 | .find_mem = NULL, |
| 167 | .adjust_resource = NULL, | 87 | .add_io = NULL, |
| 88 | .add_mem = NULL, | ||
| 168 | .init = static_init, | 89 | .init = static_init, |
| 169 | .exit = NULL, | 90 | .exit = NULL, |
| 170 | }; | 91 | }; |
| @@ -264,7 +185,8 @@ struct pccard_resource_ops pccard_iodyn_ops = { | |||
| 264 | .adjust_io_region = iodyn_adjust_io_region, | 185 | .adjust_io_region = iodyn_adjust_io_region, |
| 265 | .find_io = iodyn_find_io_region, | 186 | .find_io = iodyn_find_io_region, |
| 266 | .find_mem = NULL, | 187 | .find_mem = NULL, |
| 267 | .adjust_resource = NULL, | 188 | .add_io = NULL, |
| 189 | .add_mem = NULL, | ||
| 268 | .init = static_init, | 190 | .init = static_init, |
| 269 | .exit = NULL, | 191 | .exit = NULL, |
| 270 | }; | 192 | }; |
diff --git a/drivers/pcmcia/rsrc_nonstatic.c b/drivers/pcmcia/rsrc_nonstatic.c index 4123155e2f7a..162693480ed0 100644 --- a/drivers/pcmcia/rsrc_nonstatic.c +++ b/drivers/pcmcia/rsrc_nonstatic.c | |||
| @@ -766,21 +766,6 @@ static int adjust_io(struct pcmcia_socket *s, unsigned int action, unsigned long | |||
| 766 | } | 766 | } |
| 767 | 767 | ||
| 768 | 768 | ||
| 769 | static int nonstatic_adjust_resource_info(struct pcmcia_socket *s, adjust_t *adj) | ||
| 770 | { | ||
| 771 | unsigned long end; | ||
| 772 | |||
| 773 | switch (adj->Resource) { | ||
| 774 | case RES_MEMORY_RANGE: | ||
| 775 | end = adj->resource.memory.Base + adj->resource.memory.Size - 1; | ||
| 776 | return adjust_memory(s, adj->Action, adj->resource.memory.Base, end); | ||
| 777 | case RES_IO_RANGE: | ||
| 778 | end = adj->resource.io.BasePort + adj->resource.io.NumPorts - 1; | ||
| 779 | return adjust_io(s, adj->Action, adj->resource.io.BasePort, end); | ||
| 780 | } | ||
| 781 | return CS_UNSUPPORTED_FUNCTION; | ||
| 782 | } | ||
| 783 | |||
| 784 | #ifdef CONFIG_PCI | 769 | #ifdef CONFIG_PCI |
| 785 | static int nonstatic_autoadd_resources(struct pcmcia_socket *s) | 770 | static int nonstatic_autoadd_resources(struct pcmcia_socket *s) |
| 786 | { | 771 | { |
| @@ -889,7 +874,8 @@ struct pccard_resource_ops pccard_nonstatic_ops = { | |||
| 889 | .adjust_io_region = nonstatic_adjust_io_region, | 874 | .adjust_io_region = nonstatic_adjust_io_region, |
| 890 | .find_io = nonstatic_find_io_region, | 875 | .find_io = nonstatic_find_io_region, |
| 891 | .find_mem = nonstatic_find_mem_region, | 876 | .find_mem = nonstatic_find_mem_region, |
| 892 | .adjust_resource = nonstatic_adjust_resource_info, | 877 | .add_io = adjust_io, |
| 878 | .add_mem = adjust_memory, | ||
| 893 | .init = nonstatic_init, | 879 | .init = nonstatic_init, |
| 894 | .exit = nonstatic_release_resource_db, | 880 | .exit = nonstatic_release_resource_db, |
| 895 | }; | 881 | }; |
diff --git a/include/pcmcia/ss.h b/include/pcmcia/ss.h index 2edc7fa3bab3..e6a2338b370f 100644 --- a/include/pcmcia/ss.h +++ b/include/pcmcia/ss.h | |||
| @@ -136,8 +136,14 @@ struct pccard_resource_ops { | |||
| 136 | struct resource* (*find_mem) (unsigned long base, unsigned long num, | 136 | struct resource* (*find_mem) (unsigned long base, unsigned long num, |
| 137 | unsigned long align, int low, | 137 | unsigned long align, int low, |
| 138 | struct pcmcia_socket *s); | 138 | struct pcmcia_socket *s); |
| 139 | int (*adjust_resource) (struct pcmcia_socket *s, | 139 | int (*add_io) (struct pcmcia_socket *s, |
| 140 | adjust_t *adj); | 140 | unsigned int action, |
| 141 | unsigned long r_start, | ||
| 142 | unsigned long r_end); | ||
| 143 | int (*add_mem) (struct pcmcia_socket *s, | ||
| 144 | unsigned int action, | ||
| 145 | unsigned long r_start, | ||
| 146 | unsigned long r_end); | ||
| 141 | int (*init) (struct pcmcia_socket *s); | 147 | int (*init) (struct pcmcia_socket *s); |
| 142 | void (*exit) (struct pcmcia_socket *s); | 148 | void (*exit) (struct pcmcia_socket *s); |
| 143 | }; | 149 | }; |
