2 * rsrc_nonstatic.c -- Resource management routines for !SS_CAP_STATIC_MAP sockets
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 * The initial developer of the original code is David A. Hinds
9 * <dahinds@users.sourceforge.net>. Portions created by David A. Hinds
10 * are Copyright (C) 1999 David A. Hinds. All Rights Reserved.
12 * (C) 1999 David A. Hinds
15 #include <linux/module.h>
16 #include <linux/moduleparam.h>
17 #include <linux/init.h>
18 #include <linux/interrupt.h>
19 #include <linux/kernel.h>
20 #include <linux/errno.h>
21 #include <linux/types.h>
22 #include <linux/slab.h>
23 #include <linux/ioport.h>
24 #include <linux/timer.h>
25 #include <linux/pci.h>
26 #include <linux/device.h>
31 #include <pcmcia/cs_types.h>
32 #include <pcmcia/ss.h>
33 #include <pcmcia/cs.h>
34 #include <pcmcia/bulkmem.h>
35 #include <pcmcia/cistpl.h>
36 #include "cs_internal.h"
38 MODULE_AUTHOR("David A. Hinds, Dominik Brodowski");
39 MODULE_LICENSE("GPL");
41 /* Parameters that can be set with 'insmod' */
43 #define INT_MODULE_PARM(n, v) static int n = v; module_param(n, int, 0444)
45 INT_MODULE_PARM(probe_mem, 1); /* memory probe? */
46 #ifdef CONFIG_PCMCIA_PROBE
47 INT_MODULE_PARM(probe_io, 1); /* IO port probe? */
48 INT_MODULE_PARM(mem_limit, 0x10000);
51 /* for io_db and mem_db */
54 struct resource_map *next;
58 struct resource_map mem_db;
59 struct resource_map io_db;
60 unsigned int rsrc_mem_probe;
63 static DEFINE_MUTEX(rsrc_mutex);
64 #define MEM_PROBE_LOW (1 << 0)
65 #define MEM_PROBE_HIGH (1 << 1)
68 /*======================================================================
70 Linux resource management extensions
72 ======================================================================*/
74 static struct resource *
75 make_resource(resource_size_t b, resource_size_t n, int flags, char *name)
77 struct resource *res = kzalloc(sizeof(*res), GFP_KERNEL);
88 static struct resource *
89 claim_region(struct pcmcia_socket *s, resource_size_t base,
90 resource_size_t size, int type, char *name)
92 struct resource *res, *parent;
94 parent = type & IORESOURCE_MEM ? &iomem_resource : &ioport_resource;
95 res = make_resource(base, size, type | IORESOURCE_BUSY, name);
100 parent = pci_find_parent_resource(s->cb_dev, res);
102 if (!parent || request_resource(parent, res)) {
110 static void free_region(struct resource *res)
113 release_resource(res);
118 /*======================================================================
120 These manage the internal databases of available resources.
122 ======================================================================*/
124 static int add_interval(struct resource_map *map, u_long base, u_long num)
126 struct resource_map *p, *q;
128 for (p = map; ; p = p->next) {
129 if ((p != map) && (p->base+p->num-1 >= base))
131 if ((p->next == map) || (p->next->base > base+num-1))
134 q = kmalloc(sizeof(struct resource_map), GFP_KERNEL);
135 if (!q) return CS_OUT_OF_RESOURCE;
136 q->base = base; q->num = num;
137 q->next = p->next; p->next = q;
141 /*====================================================================*/
143 static int sub_interval(struct resource_map *map, u_long base, u_long num)
145 struct resource_map *p, *q;
147 for (p = map; ; p = q) {
151 if ((q->base+q->num > base) && (base+num > q->base)) {
152 if (q->base >= base) {
153 if (q->base+q->num <= base+num) {
154 /* Delete whole block */
157 /* don't advance the pointer yet */
160 /* Cut off bit from the front */
161 q->num = q->base + q->num - base - num;
162 q->base = base + num;
164 } else if (q->base+q->num <= base+num) {
165 /* Cut off bit from the end */
166 q->num = base - q->base;
168 /* Split the block into two pieces */
169 p = kmalloc(sizeof(struct resource_map), GFP_KERNEL);
170 if (!p) return CS_OUT_OF_RESOURCE;
172 p->num = q->base+q->num - p->base;
173 q->num = base - q->base;
174 p->next = q->next ; q->next = p;
181 /*======================================================================
183 These routines examine a region of IO or memory addresses to
184 determine what ranges might be genuinely available.
186 ======================================================================*/
188 #ifdef CONFIG_PCMCIA_PROBE
189 static void do_io_probe(struct pcmcia_socket *s, unsigned int base,
192 struct resource *res;
193 struct socket_data *s_data = s->resource_data;
194 unsigned int i, j, bad;
196 u_char *b, hole, most;
198 printk(KERN_INFO "cs: IO port probe %#x-%#x:",
201 /* First, what does a floating port look like? */
202 b = kzalloc(256, GFP_KERNEL);
204 printk(KERN_ERR "do_io_probe: unable to kmalloc 256 bytes");
207 for (i = base, most = 0; i < base+num; i += 8) {
208 res = claim_region(NULL, i, 8, IORESOURCE_IO, "PCMCIA IO probe");
212 for (j = 1; j < 8; j++)
213 if (inb(i+j) != hole) break;
215 if ((j == 8) && (++b[hole] > b[most]))
217 if (b[most] == 127) break;
222 for (i = base; i < base+num; i += 8) {
223 res = claim_region(NULL, i, 8, IORESOURCE_IO, "PCMCIA IO probe");
226 for (j = 0; j < 8; j++)
227 if (inb(i+j) != most) break;
231 printk(" excluding");
236 sub_interval(&s_data->io_db, bad, i-bad);
237 printk(" %#x-%#x", bad, i-1);
243 if ((num > 16) && (bad == base) && (i == base+num)) {
244 printk(" nothing: probe failed.\n");
247 sub_interval(&s_data->io_db, bad, i-bad);
248 printk(" %#x-%#x", bad, i-1);
252 printk(any ? "\n" : " clean.\n");
256 /*======================================================================
258 This is tricky... when we set up CIS memory, we try to validate
259 the memory window space allocations.
261 ======================================================================*/
263 /* Validation function for cards with a valid CIS */
264 static int readable(struct pcmcia_socket *s, struct resource *res,
269 s->cis_mem.res = res;
270 s->cis_virt = ioremap(res->start, s->map_size);
272 ret = pccard_validate_cis(s, BIND_FN_ALL, count);
273 /* invalidate mapping and CIS cache */
274 iounmap(s->cis_virt);
276 destroy_cis_cache(s);
278 s->cis_mem.res = NULL;
279 if ((ret != 0) || (count == 0))
284 /* Validation function for simple memory cards */
285 static int checksum(struct pcmcia_socket *s, struct resource *res)
288 int i, a = 0, b = -1, d;
291 virt = ioremap(res->start, s->map_size);
294 map.flags = MAP_ACTIVE;
298 s->ops->set_mem_map(s, &map);
300 /* Don't bother checking every word... */
301 for (i = 0; i < s->map_size; i += 44) {
308 s->ops->set_mem_map(s, &map);
313 return (b == -1) ? -1 : (a>>1);
317 cis_readable(struct pcmcia_socket *s, unsigned long base, unsigned long size)
319 struct resource *res1, *res2;
320 unsigned int info1, info2;
323 res1 = claim_region(s, base, size/2, IORESOURCE_MEM, "cs memory probe");
324 res2 = claim_region(s, base + size/2, size/2, IORESOURCE_MEM, "cs memory probe");
327 ret = readable(s, res1, &info1);
328 ret += readable(s, res2, &info2);
334 return (ret == 2) && (info1 == info2);
338 checksum_match(struct pcmcia_socket *s, unsigned long base, unsigned long size)
340 struct resource *res1, *res2;
343 res1 = claim_region(s, base, size/2, IORESOURCE_MEM, "cs memory probe");
344 res2 = claim_region(s, base + size/2, size/2, IORESOURCE_MEM, "cs memory probe");
347 a = checksum(s, res1);
348 b = checksum(s, res2);
354 return (a == b) && (a >= 0);
357 /*======================================================================
359 The memory probe. If the memory list includes a 64K-aligned block
360 below 1MB, we probe in 64K chunks, and as soon as we accumulate at
361 least mem_limit free space, we quit.
363 ======================================================================*/
365 static int do_mem_probe(u_long base, u_long num, struct pcmcia_socket *s)
367 struct socket_data *s_data = s->resource_data;
368 u_long i, j, bad, fail, step;
370 printk(KERN_INFO "cs: memory probe 0x%06lx-0x%06lx:",
373 step = (num < 0x20000) ? 0x2000 : ((num>>4) & ~0x1fff);
374 /* don't allow too large steps */
377 /* cis_readable wants to map 2x map_size */
378 if (step < 2 * s->map_size)
379 step = 2 * s->map_size;
380 for (i = j = base; i < base+num; i = j + step) {
382 for (j = i; j < base+num; j += step) {
383 if (cis_readable(s, j, step))
386 fail = ((i == base) && (j == base+num));
389 for (j = i; j < base+num; j += 2*step)
390 if (checksum_match(s, j, step) &&
391 checksum_match(s, j + step, step))
395 if (!bad) printk(" excluding");
396 printk(" %#05lx-%#05lx", i, j-1);
397 sub_interval(&s_data->mem_db, i, j-i);
401 printk(bad ? "\n" : " clean.\n");
405 #ifdef CONFIG_PCMCIA_PROBE
407 static u_long inv_probe(struct resource_map *m, struct pcmcia_socket *s)
409 struct socket_data *s_data = s->resource_data;
411 if (m == &s_data->mem_db)
413 ok = inv_probe(m->next, s);
415 if (m->base >= 0x100000)
416 sub_interval(&s_data->mem_db, m->base, m->num);
419 if (m->base < 0x100000)
421 return do_mem_probe(m->base, m->num, s);
424 static int validate_mem(struct pcmcia_socket *s, unsigned int probe_mask)
426 struct resource_map *m, mm;
427 static unsigned char order[] = { 0xd0, 0xe0, 0xc0, 0xf0 };
428 unsigned long b, i, ok = 0;
429 struct socket_data *s_data = s->resource_data;
431 /* We do up to four passes through the list */
432 if (probe_mask & MEM_PROBE_HIGH) {
433 if (inv_probe(s_data->mem_db.next, s) > 0)
435 printk(KERN_NOTICE "cs: warning: no high memory space "
440 for (m = s_data->mem_db.next; m != &s_data->mem_db; m = mm.next) {
442 /* Only probe < 1 MB */
443 if (mm.base >= 0x100000)
445 if ((mm.base | mm.num) & 0xffff) {
446 ok += do_mem_probe(mm.base, mm.num, s);
449 /* Special probe for 64K-aligned block */
450 for (i = 0; i < 4; i++) {
452 if ((b >= mm.base) && (b+0x10000 <= mm.base+mm.num)) {
454 sub_interval(&s_data->mem_db, b, 0x10000);
456 ok += do_mem_probe(b, 0x10000, s);
467 #else /* CONFIG_PCMCIA_PROBE */
469 static int validate_mem(struct pcmcia_socket *s, unsigned int probe_mask)
471 struct resource_map *m, mm;
472 struct socket_data *s_data = s->resource_data;
473 unsigned long ok = 0;
475 for (m = s_data->mem_db.next; m != &s_data->mem_db; m = mm.next) {
477 ok += do_mem_probe(mm.base, mm.num, s);
484 #endif /* CONFIG_PCMCIA_PROBE */
488 * Locking note: Must be called with skt_mutex held!
490 static int pcmcia_nonstatic_validate_mem(struct pcmcia_socket *s)
492 struct socket_data *s_data = s->resource_data;
493 unsigned int probe_mask = MEM_PROBE_LOW;
499 mutex_lock(&rsrc_mutex);
501 if (s->features & SS_CAP_PAGE_REGS)
502 probe_mask = MEM_PROBE_HIGH;
504 if (probe_mask & ~s_data->rsrc_mem_probe) {
505 if (s->state & SOCKET_PRESENT)
506 ret = validate_mem(s, probe_mask);
508 s_data->rsrc_mem_probe |= probe_mask;
511 mutex_unlock(&rsrc_mutex);
516 struct pcmcia_align_data {
518 unsigned long offset;
519 struct resource_map *map;
523 pcmcia_common_align(void *align_data, struct resource *res,
524 resource_size_t size, resource_size_t align)
526 struct pcmcia_align_data *data = align_data;
527 resource_size_t start;
529 * Ensure that we have the correct start address
531 start = (res->start & ~data->mask) + data->offset;
532 if (start < res->start)
533 start += data->mask + 1;
538 pcmcia_align(void *align_data, struct resource *res, resource_size_t size,
539 resource_size_t align)
541 struct pcmcia_align_data *data = align_data;
542 struct resource_map *m;
544 pcmcia_common_align(data, res, size, align);
546 for (m = data->map->next; m != data->map; m = m->next) {
547 unsigned long start = m->base;
548 unsigned long end = m->base + m->num - 1;
551 * If the lower resources are not available, try aligning
552 * to this entry of the resource database to see if it'll
555 if (res->start < start) {
557 pcmcia_common_align(data, res, size, align);
561 * If we're above the area which was passed in, there's
562 * no point proceeding.
564 if (res->start >= res->end)
567 if ((res->start + size - 1) <= end)
572 * If we failed to find something suitable, ensure we fail.
575 res->start = res->end;
579 * Adjust an existing IO region allocation, but making sure that we don't
580 * encroach outside the resources which the user supplied.
582 static int nonstatic_adjust_io_region(struct resource *res, unsigned long r_start,
583 unsigned long r_end, struct pcmcia_socket *s)
585 struct resource_map *m;
586 struct socket_data *s_data = s->resource_data;
589 mutex_lock(&rsrc_mutex);
590 for (m = s_data->io_db.next; m != &s_data->io_db; m = m->next) {
591 unsigned long start = m->base;
592 unsigned long end = m->base + m->num - 1;
594 if (start > r_start || r_end > end)
597 ret = adjust_resource(res, r_start, r_end - r_start + 1);
600 mutex_unlock(&rsrc_mutex);
605 /*======================================================================
607 These find ranges of I/O ports or memory addresses that are not
608 currently allocated by other devices.
610 The 'align' field should reflect the number of bits of address
611 that need to be preserved from the initial value of *base. It
612 should be a power of two, greater than or equal to 'num'. A value
613 of 0 means that all bits of *base are significant. *base should
614 also be strictly less than 'align'.
616 ======================================================================*/
618 static struct resource *nonstatic_find_io_region(unsigned long base, int num,
619 unsigned long align, struct pcmcia_socket *s)
621 struct resource *res = make_resource(0, num, IORESOURCE_IO, s->dev.bus_id);
622 struct socket_data *s_data = s->resource_data;
623 struct pcmcia_align_data data;
624 unsigned long min = base;
630 data.mask = align - 1;
631 data.offset = base & data.mask;
632 data.map = &s_data->io_db;
634 mutex_lock(&rsrc_mutex);
637 ret = pci_bus_alloc_resource(s->cb_dev->bus, res, num, 1,
638 min, 0, pcmcia_align, &data);
641 ret = allocate_resource(&ioport_resource, res, num, min, ~0UL,
642 1, pcmcia_align, &data);
643 mutex_unlock(&rsrc_mutex);
652 static struct resource * nonstatic_find_mem_region(u_long base, u_long num,
653 u_long align, int low, struct pcmcia_socket *s)
655 struct resource *res = make_resource(0, num, IORESOURCE_MEM, s->dev.bus_id);
656 struct socket_data *s_data = s->resource_data;
657 struct pcmcia_align_data data;
658 unsigned long min, max;
661 low = low || !(s->features & SS_CAP_PAGE_REGS);
663 data.mask = align - 1;
664 data.offset = base & data.mask;
665 data.map = &s_data->mem_db;
667 for (i = 0; i < 2; i++) {
670 min = base < max ? base : 0;
673 min = 0x100000UL + base;
676 mutex_lock(&rsrc_mutex);
679 ret = pci_bus_alloc_resource(s->cb_dev->bus, res, num,
681 pcmcia_align, &data);
684 ret = allocate_resource(&iomem_resource, res, num, min,
685 max, 1, pcmcia_align, &data);
686 mutex_unlock(&rsrc_mutex);
700 static int adjust_memory(struct pcmcia_socket *s, unsigned int action, unsigned long start, unsigned long end)
702 struct socket_data *data = s->resource_data;
703 unsigned long size = end - start + 1;
709 mutex_lock(&rsrc_mutex);
711 case ADD_MANAGED_RESOURCE:
712 ret = add_interval(&data->mem_db, start, size);
714 case REMOVE_MANAGED_RESOURCE:
715 ret = sub_interval(&data->mem_db, start, size);
717 struct pcmcia_socket *socket;
718 down_read(&pcmcia_socket_list_rwsem);
719 list_for_each_entry(socket, &pcmcia_socket_list, socket_list)
720 release_cis_mem(socket);
721 up_read(&pcmcia_socket_list_rwsem);
727 mutex_unlock(&rsrc_mutex);
733 static int adjust_io(struct pcmcia_socket *s, unsigned int action, unsigned long start, unsigned long end)
735 struct socket_data *data = s->resource_data;
736 unsigned long size = end - start + 1;
742 if (end > IO_SPACE_LIMIT)
745 mutex_lock(&rsrc_mutex);
747 case ADD_MANAGED_RESOURCE:
748 if (add_interval(&data->io_db, start, size) != 0) {
752 #ifdef CONFIG_PCMCIA_PROBE
754 do_io_probe(s, start, size);
757 case REMOVE_MANAGED_RESOURCE:
758 sub_interval(&data->io_db, start, size);
764 mutex_unlock(&rsrc_mutex);
771 static int nonstatic_autoadd_resources(struct pcmcia_socket *s)
773 struct resource *res;
776 if (!s->cb_dev || !s->cb_dev->bus)
779 #if defined(CONFIG_X86)
780 /* If this is the root bus, the risk of hitting
781 * some strange system devices which aren't protected
782 * by either ACPI resource tables or properly requested
783 * resources is too big. Therefore, don't do auto-adding
784 * of resources at the moment.
786 if (s->cb_dev->bus->number == 0)
790 for (i=0; i < PCI_BUS_NUM_RESOURCES; i++) {
791 res = s->cb_dev->bus->resource[i];
795 if (res->flags & IORESOURCE_IO) {
796 if (res == &ioport_resource)
798 printk(KERN_INFO "pcmcia: parent PCI bridge I/O "
799 "window: 0x%llx - 0x%llx\n",
800 (unsigned long long)res->start,
801 (unsigned long long)res->end);
802 if (!adjust_io(s, ADD_MANAGED_RESOURCE, res->start, res->end))
803 done |= IORESOURCE_IO;
807 if (res->flags & IORESOURCE_MEM) {
808 if (res == &iomem_resource)
810 printk(KERN_INFO "pcmcia: parent PCI bridge Memory "
811 "window: 0x%llx - 0x%llx\n",
812 (unsigned long long)res->start,
813 (unsigned long long)res->end);
814 if (!adjust_memory(s, ADD_MANAGED_RESOURCE, res->start, res->end))
815 done |= IORESOURCE_MEM;
819 /* if we got at least one of IO, and one of MEM, we can be glad and
820 * activate the PCMCIA subsystem */
821 if (done == (IORESOURCE_MEM | IORESOURCE_IO))
822 s->resource_setup_done = 1;
829 static inline int nonstatic_autoadd_resources(struct pcmcia_socket *s)
837 static int nonstatic_init(struct pcmcia_socket *s)
839 struct socket_data *data;
841 data = kzalloc(sizeof(struct socket_data), GFP_KERNEL);
845 data->mem_db.next = &data->mem_db;
846 data->io_db.next = &data->io_db;
848 s->resource_data = (void *) data;
850 nonstatic_autoadd_resources(s);
855 static void nonstatic_release_resource_db(struct pcmcia_socket *s)
857 struct socket_data *data = s->resource_data;
858 struct resource_map *p, *q;
860 mutex_lock(&rsrc_mutex);
861 for (p = data->mem_db.next; p != &data->mem_db; p = q) {
865 for (p = data->io_db.next; p != &data->io_db; p = q) {
869 mutex_unlock(&rsrc_mutex);
873 struct pccard_resource_ops pccard_nonstatic_ops = {
874 .validate_mem = pcmcia_nonstatic_validate_mem,
875 .adjust_io_region = nonstatic_adjust_io_region,
876 .find_io = nonstatic_find_io_region,
877 .find_mem = nonstatic_find_mem_region,
879 .add_mem = adjust_memory,
880 .init = nonstatic_init,
881 .exit = nonstatic_release_resource_db,
883 EXPORT_SYMBOL(pccard_nonstatic_ops);
886 /* sysfs interface to the resource database */
888 static ssize_t show_io_db(struct device *dev,
889 struct device_attribute *attr, char *buf)
891 struct pcmcia_socket *s = dev_get_drvdata(dev);
892 struct socket_data *data;
893 struct resource_map *p;
896 mutex_lock(&rsrc_mutex);
897 data = s->resource_data;
899 for (p = data->io_db.next; p != &data->io_db; p = p->next) {
900 if (ret > (PAGE_SIZE - 10))
902 ret += snprintf (&buf[ret], (PAGE_SIZE - ret - 1),
903 "0x%08lx - 0x%08lx\n",
904 ((unsigned long) p->base),
905 ((unsigned long) p->base + p->num - 1));
908 mutex_unlock(&rsrc_mutex);
912 static ssize_t store_io_db(struct device *dev,
913 struct device_attribute *attr,
914 const char *buf, size_t count)
916 struct pcmcia_socket *s = dev_get_drvdata(dev);
917 unsigned long start_addr, end_addr;
918 unsigned int add = ADD_MANAGED_RESOURCE;
921 ret = sscanf (buf, "+ 0x%lx - 0x%lx", &start_addr, &end_addr);
923 ret = sscanf (buf, "- 0x%lx - 0x%lx", &start_addr, &end_addr);
924 add = REMOVE_MANAGED_RESOURCE;
926 ret = sscanf (buf, "0x%lx - 0x%lx", &start_addr, &end_addr);
927 add = ADD_MANAGED_RESOURCE;
932 if (end_addr < start_addr)
935 ret = adjust_io(s, add, start_addr, end_addr);
937 s->resource_setup_new = 1;
939 return ret ? ret : count;
941 static DEVICE_ATTR(available_resources_io, 0600, show_io_db, store_io_db);
943 static ssize_t show_mem_db(struct device *dev,
944 struct device_attribute *attr, char *buf)
946 struct pcmcia_socket *s = dev_get_drvdata(dev);
947 struct socket_data *data;
948 struct resource_map *p;
951 mutex_lock(&rsrc_mutex);
952 data = s->resource_data;
954 for (p = data->mem_db.next; p != &data->mem_db; p = p->next) {
955 if (ret > (PAGE_SIZE - 10))
957 ret += snprintf (&buf[ret], (PAGE_SIZE - ret - 1),
958 "0x%08lx - 0x%08lx\n",
959 ((unsigned long) p->base),
960 ((unsigned long) p->base + p->num - 1));
963 mutex_unlock(&rsrc_mutex);
967 static ssize_t store_mem_db(struct device *dev,
968 struct device_attribute *attr,
969 const char *buf, size_t count)
971 struct pcmcia_socket *s = dev_get_drvdata(dev);
972 unsigned long start_addr, end_addr;
973 unsigned int add = ADD_MANAGED_RESOURCE;
976 ret = sscanf (buf, "+ 0x%lx - 0x%lx", &start_addr, &end_addr);
978 ret = sscanf (buf, "- 0x%lx - 0x%lx", &start_addr, &end_addr);
979 add = REMOVE_MANAGED_RESOURCE;
981 ret = sscanf (buf, "0x%lx - 0x%lx", &start_addr, &end_addr);
982 add = ADD_MANAGED_RESOURCE;
987 if (end_addr < start_addr)
990 ret = adjust_memory(s, add, start_addr, end_addr);
992 s->resource_setup_new = 1;
994 return ret ? ret : count;
996 static DEVICE_ATTR(available_resources_mem, 0600, show_mem_db, store_mem_db);
998 static struct attribute *pccard_rsrc_attributes[] = {
999 &dev_attr_available_resources_io.attr,
1000 &dev_attr_available_resources_mem.attr,
1004 static const struct attribute_group rsrc_attributes = {
1005 .attrs = pccard_rsrc_attributes,
1008 static int __devinit pccard_sysfs_add_rsrc(struct device *dev,
1009 struct class_interface *class_intf)
1011 struct pcmcia_socket *s = dev_get_drvdata(dev);
1013 if (s->resource_ops != &pccard_nonstatic_ops)
1015 return sysfs_create_group(&dev->kobj, &rsrc_attributes);
1018 static void __devexit pccard_sysfs_remove_rsrc(struct device *dev,
1019 struct class_interface *class_intf)
1021 struct pcmcia_socket *s = dev_get_drvdata(dev);
1023 if (s->resource_ops != &pccard_nonstatic_ops)
1025 sysfs_remove_group(&dev->kobj, &rsrc_attributes);
1028 static struct class_interface pccard_rsrc_interface __refdata = {
1029 .class = &pcmcia_socket_class,
1030 .add_dev = &pccard_sysfs_add_rsrc,
1031 .remove_dev = __devexit_p(&pccard_sysfs_remove_rsrc),
1034 static int __init nonstatic_sysfs_init(void)
1036 return class_interface_register(&pccard_rsrc_interface);
1039 static void __exit nonstatic_sysfs_exit(void)
1041 class_interface_unregister(&pccard_rsrc_interface);
1044 module_init(nonstatic_sysfs_init);
1045 module_exit(nonstatic_sysfs_exit);