Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

s390/qeth: switch to ccwgroup_create_dev

Switch to the new ccwgroup_create_dev interface. Also wrap device
attributes in a struct device_type and let the driver core create
these attributes automagically.

Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Sebastian Ott <sebott@linux.vnet.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>

authored by

Sebastian Ott and committed by
Martin Schwidefsky
b7169c51 2ced5514

+35 -71
+3 -4
drivers/s390/net/qeth_core.h
··· 843 843 844 844 extern struct ccwgroup_driver qeth_l2_ccwgroup_driver; 845 845 extern struct ccwgroup_driver qeth_l3_ccwgroup_driver; 846 + extern const struct attribute_group *qeth_generic_attr_groups[]; 847 + extern const struct attribute_group *qeth_osn_attr_groups[]; 848 + 846 849 const char *qeth_get_cardname_short(struct qeth_card *); 847 850 int qeth_realloc_buffer_pool(struct qeth_card *, int); 848 851 int qeth_core_load_discipline(struct qeth_card *, enum qeth_discipline_id); 849 852 void qeth_core_free_discipline(struct qeth_card *); 850 - int qeth_core_create_device_attributes(struct device *); 851 - void qeth_core_remove_device_attributes(struct device *); 852 - int qeth_core_create_osn_attributes(struct device *); 853 - void qeth_core_remove_osn_attributes(struct device *); 854 853 void qeth_buffer_reclaim_work(struct work_struct *); 855 854 856 855 /* exports for qeth discipline device drivers */
+22 -34
drivers/s390/net/qeth_core_main.c
··· 4739 4739 .remove = ccwgroup_remove_ccwdev, 4740 4740 }; 4741 4741 4742 - static int qeth_core_driver_group(const char *buf, struct device *root_dev, 4743 - unsigned long driver_id) 4744 - { 4745 - return ccwgroup_create_from_string(root_dev, driver_id, 4746 - &qeth_ccw_driver, 3, buf); 4747 - } 4748 - 4749 4742 int qeth_core_hardsetup_card(struct qeth_card *card) 4750 4743 { 4751 4744 int retries = 0; ··· 5067 5074 card->discipline.ccwgdriver = NULL; 5068 5075 } 5069 5076 5077 + static const struct device_type qeth_generic_devtype = { 5078 + .name = "qeth_generic", 5079 + .groups = qeth_generic_attr_groups, 5080 + }; 5081 + static const struct device_type qeth_osn_devtype = { 5082 + .name = "qeth_osn", 5083 + .groups = qeth_osn_attr_groups, 5084 + }; 5085 + 5070 5086 static int qeth_core_probe_device(struct ccwgroup_device *gdev) 5071 5087 { 5072 5088 struct qeth_card *card; ··· 5130 5128 } 5131 5129 5132 5130 if (card->info.type == QETH_CARD_TYPE_OSN) 5133 - rc = qeth_core_create_osn_attributes(dev); 5131 + gdev->dev.type = &qeth_osn_devtype; 5134 5132 else 5135 - rc = qeth_core_create_device_attributes(dev); 5136 - if (rc) 5137 - goto err_dbf; 5133 + gdev->dev.type = &qeth_generic_devtype; 5134 + 5138 5135 switch (card->info.type) { 5139 5136 case QETH_CARD_TYPE_OSN: 5140 5137 case QETH_CARD_TYPE_OSM: 5141 5138 rc = qeth_core_load_discipline(card, QETH_DISCIPLINE_LAYER2); 5142 5139 if (rc) 5143 - goto err_attr; 5140 + goto err_dbf; 5144 5141 rc = card->discipline.ccwgdriver->probe(card->gdev); 5145 5142 if (rc) 5146 5143 goto err_disc; ··· 5158 5157 5159 5158 err_disc: 5160 5159 qeth_core_free_discipline(card); 5161 - err_attr: 5162 - if (card->info.type == QETH_CARD_TYPE_OSN) 5163 - qeth_core_remove_osn_attributes(dev); 5164 - else 5165 - qeth_core_remove_device_attributes(dev); 5166 5160 err_dbf: 5167 5161 debug_unregister(card->debug); 5168 5162 err_card: ··· 5173 5177 struct qeth_card *card = dev_get_drvdata(&gdev->dev); 5174 5178 5175 5179 QETH_DBF_TEXT(SETUP, 2, "removedv"); 5176 - 5177 - if (card->info.type == QETH_CARD_TYPE_OSN) { 5178 - qeth_core_remove_osn_attributes(&gdev->dev); 5179 - } else { 5180 - qeth_core_remove_device_attributes(&gdev->dev); 5181 - } 5182 5180 5183 5181 if (card->discipline.ccwgdriver) { 5184 5182 card->discipline.ccwgdriver->remove(gdev); ··· 5276 5286 .name = "qeth", 5277 5287 }, 5278 5288 .driver_id = 0xD8C5E3C8, 5279 - .probe = qeth_core_probe_device, 5289 + .setup = qeth_core_probe_device, 5280 5290 .remove = qeth_core_remove_device, 5281 5291 .set_online = qeth_core_set_online, 5282 5292 .set_offline = qeth_core_set_offline, ··· 5288 5298 .restore = qeth_core_restore, 5289 5299 }; 5290 5300 5291 - static ssize_t 5292 - qeth_core_driver_group_store(struct device_driver *ddrv, const char *buf, 5293 - size_t count) 5301 + static ssize_t qeth_core_driver_group_store(struct device_driver *ddrv, 5302 + const char *buf, size_t count) 5294 5303 { 5295 5304 int err; 5296 - err = qeth_core_driver_group(buf, qeth_core_root_dev, 5297 - qeth_core_ccwgroup_driver.driver_id); 5298 - if (err) 5299 - return err; 5300 - else 5301 - return count; 5302 - } 5303 5305 5306 + err = ccwgroup_create_dev(qeth_core_root_dev, 5307 + qeth_core_ccwgroup_driver.driver_id, 5308 + &qeth_core_ccwgroup_driver, 3, buf); 5309 + 5310 + return err ? err : count; 5311 + } 5304 5312 static DRIVER_ATTR(group, 0200, NULL, qeth_core_driver_group_store); 5305 5313 5306 5314 static struct {
+10 -33
drivers/s390/net/qeth_core_sys.c
··· 693 693 &dev_attr_inter_jumbo.attr, 694 694 NULL, 695 695 }; 696 - 697 696 static struct attribute_group qeth_device_blkt_group = { 698 697 .name = "blkt", 699 698 .attrs = qeth_blkt_device_attrs, ··· 715 716 &dev_attr_hw_trap.attr, 716 717 NULL, 717 718 }; 718 - 719 719 static struct attribute_group qeth_device_attr_group = { 720 720 .attrs = qeth_device_attrs, 721 + }; 722 + 723 + const struct attribute_group *qeth_generic_attr_groups[] = { 724 + &qeth_device_attr_group, 725 + &qeth_device_blkt_group, 726 + NULL, 721 727 }; 722 728 723 729 static struct attribute *qeth_osn_device_attrs[] = { ··· 734 730 &dev_attr_recover.attr, 735 731 NULL, 736 732 }; 737 - 738 733 static struct attribute_group qeth_osn_device_attr_group = { 739 734 .attrs = qeth_osn_device_attrs, 740 735 }; 741 - 742 - int qeth_core_create_device_attributes(struct device *dev) 743 - { 744 - int ret; 745 - ret = sysfs_create_group(&dev->kobj, &qeth_device_attr_group); 746 - if (ret) 747 - return ret; 748 - ret = sysfs_create_group(&dev->kobj, &qeth_device_blkt_group); 749 - if (ret) 750 - sysfs_remove_group(&dev->kobj, &qeth_device_attr_group); 751 - 752 - return 0; 753 - } 754 - 755 - void qeth_core_remove_device_attributes(struct device *dev) 756 - { 757 - sysfs_remove_group(&dev->kobj, &qeth_device_attr_group); 758 - sysfs_remove_group(&dev->kobj, &qeth_device_blkt_group); 759 - } 760 - 761 - int qeth_core_create_osn_attributes(struct device *dev) 762 - { 763 - return sysfs_create_group(&dev->kobj, &qeth_osn_device_attr_group); 764 - } 765 - 766 - void qeth_core_remove_osn_attributes(struct device *dev) 767 - { 768 - sysfs_remove_group(&dev->kobj, &qeth_osn_device_attr_group); 769 - return; 770 - } 736 + const struct attribute_group *qeth_osn_attr_groups[] = { 737 + &qeth_osn_device_attr_group, 738 + NULL, 739 + };