aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/pcmcia/cs.c13
-rw-r--r--drivers/pcmcia/cs_internal.h3
-rw-r--r--drivers/pcmcia/socket_sysfs.c52
3 files changed, 28 insertions, 40 deletions
diff --git a/drivers/pcmcia/cs.c b/drivers/pcmcia/cs.c
index 56230dbd347a..29276bd28295 100644
--- a/drivers/pcmcia/cs.c
+++ b/drivers/pcmcia/cs.c
@@ -652,6 +652,9 @@ static int pccardd(void *__skt)
652 complete(&skt->thread_done); 652 complete(&skt->thread_done);
653 return 0; 653 return 0;
654 } 654 }
655 ret = pccard_sysfs_add_socket(&skt->dev);
656 if (ret)
657 dev_warn(&skt->dev, "err %d adding socket attributes\n", ret);
655 658
656 add_wait_queue(&skt->thread_wait, &wait); 659 add_wait_queue(&skt->thread_wait, &wait);
657 complete(&skt->thread_done); 660 complete(&skt->thread_done);
@@ -694,6 +697,7 @@ static int pccardd(void *__skt)
694 remove_wait_queue(&skt->thread_wait, &wait); 697 remove_wait_queue(&skt->thread_wait, &wait);
695 698
696 /* remove from the device core */ 699 /* remove from the device core */
700 pccard_sysfs_remove_socket(&skt->dev);
697 device_unregister(&skt->dev); 701 device_unregister(&skt->dev);
698 702
699 return 0; 703 return 0;
@@ -940,20 +944,13 @@ EXPORT_SYMBOL(pcmcia_socket_class);
940 944
941static int __init init_pcmcia_cs(void) 945static int __init init_pcmcia_cs(void)
942{ 946{
943 int ret;
944
945 init_completion(&pcmcia_unload); 947 init_completion(&pcmcia_unload);
946 ret = class_register(&pcmcia_socket_class); 948 return class_register(&pcmcia_socket_class);
947 if (ret)
948 return (ret);
949 return class_interface_register(&pccard_sysfs_interface);
950} 949}
951 950
952static void __exit exit_pcmcia_cs(void) 951static void __exit exit_pcmcia_cs(void)
953{ 952{
954 class_interface_unregister(&pccard_sysfs_interface);
955 class_unregister(&pcmcia_socket_class); 953 class_unregister(&pcmcia_socket_class);
956
957 wait_for_completion(&pcmcia_unload); 954 wait_for_completion(&pcmcia_unload);
958} 955}
959 956
diff --git a/drivers/pcmcia/cs_internal.h b/drivers/pcmcia/cs_internal.h
index 9fa207e3c7b3..e7d5d141f24d 100644
--- a/drivers/pcmcia/cs_internal.h
+++ b/drivers/pcmcia/cs_internal.h
@@ -121,7 +121,8 @@ struct resource *pcmcia_find_mem_region(u_long base, u_long num, u_long align,
121void release_resource_db(struct pcmcia_socket *s); 121void release_resource_db(struct pcmcia_socket *s);
122 122
123/* In socket_sysfs.c */ 123/* In socket_sysfs.c */
124extern struct class_interface pccard_sysfs_interface; 124extern int pccard_sysfs_add_socket(struct device *dev);
125extern void pccard_sysfs_remove_socket(struct device *dev);
125 126
126/* In cs.c */ 127/* In cs.c */
127extern struct rw_semaphore pcmcia_socket_list_rwsem; 128extern struct rw_semaphore pcmcia_socket_list_rwsem;
diff --git a/drivers/pcmcia/socket_sysfs.c b/drivers/pcmcia/socket_sysfs.c
index b4409002b7f8..562384d6f321 100644
--- a/drivers/pcmcia/socket_sysfs.c
+++ b/drivers/pcmcia/socket_sysfs.c
@@ -356,19 +356,23 @@ static ssize_t pccard_store_cis(struct kobject *kobj,
356} 356}
357 357
358 358
359static struct device_attribute *pccard_socket_attributes[] = { 359static struct attribute *pccard_socket_attributes[] = {
360 &dev_attr_card_type, 360 &dev_attr_card_type.attr,
361 &dev_attr_card_voltage, 361 &dev_attr_card_voltage.attr,
362 &dev_attr_card_vpp, 362 &dev_attr_card_vpp.attr,
363 &dev_attr_card_vcc, 363 &dev_attr_card_vcc.attr,
364 &dev_attr_card_insert, 364 &dev_attr_card_insert.attr,
365 &dev_attr_card_pm_state, 365 &dev_attr_card_pm_state.attr,
366 &dev_attr_card_eject, 366 &dev_attr_card_eject.attr,
367 &dev_attr_card_irq_mask, 367 &dev_attr_card_irq_mask.attr,
368 &dev_attr_available_resources_setup_done, 368 &dev_attr_available_resources_setup_done.attr,
369 NULL, 369 NULL,
370}; 370};
371 371
372static const struct attribute_group socket_attrs = {
373 .attrs = pccard_socket_attributes,
374};
375
372static struct bin_attribute pccard_cis_attr = { 376static struct bin_attribute pccard_cis_attr = {
373 .attr = { .name = "cis", .mode = S_IRUGO | S_IWUSR }, 377 .attr = { .name = "cis", .mode = S_IRUGO | S_IWUSR },
374 .size = 0x200, 378 .size = 0x200,
@@ -376,35 +380,21 @@ static struct bin_attribute pccard_cis_attr = {
376 .write = pccard_store_cis, 380 .write = pccard_store_cis,
377}; 381};
378 382
379static int __devinit pccard_sysfs_add_socket(struct device *dev, 383int pccard_sysfs_add_socket(struct device *dev)
380 struct class_interface *class_intf)
381{ 384{
382 struct device_attribute **attr;
383 int ret = 0; 385 int ret = 0;
384 386
385 for (attr = pccard_socket_attributes; *attr; attr++) { 387 ret = sysfs_create_group(&dev->kobj, &socket_attrs);
386 ret = device_create_file(dev, *attr); 388 if (!ret) {
389 ret = sysfs_create_bin_file(&dev->kobj, &pccard_cis_attr);
387 if (ret) 390 if (ret)
388 break; 391 sysfs_remove_group(&dev->kobj, &socket_attrs);
389 } 392 }
390 if (!ret)
391 ret = sysfs_create_bin_file(&dev->kobj, &pccard_cis_attr);
392
393 return ret; 393 return ret;
394} 394}
395 395
396static void __devexit pccard_sysfs_remove_socket(struct device *dev, 396void pccard_sysfs_remove_socket(struct device *dev)
397 struct class_interface *class_intf)
398{ 397{
399 struct device_attribute **attr;
400
401 sysfs_remove_bin_file(&dev->kobj, &pccard_cis_attr); 398 sysfs_remove_bin_file(&dev->kobj, &pccard_cis_attr);
402 for (attr = pccard_socket_attributes; *attr; attr++) 399 sysfs_remove_group(&dev->kobj, &socket_attrs);
403 device_remove_file(dev, *attr);
404} 400}
405
406struct class_interface pccard_sysfs_interface = {
407 .class = &pcmcia_socket_class,
408 .add_dev = &pccard_sysfs_add_socket,
409 .remove_dev = __devexit_p(&pccard_sysfs_remove_socket),
410};