diff options
author | Sebastian Ott <sebott@linux.vnet.ibm.com> | 2012-05-15 12:01:46 -0400 |
---|---|---|
committer | Martin Schwidefsky <schwidefsky@de.ibm.com> | 2012-05-16 08:42:48 -0400 |
commit | b7169c515bbdc139fadee5a98a866c5dc5bb98af (patch) | |
tree | 3b4b73904b4540d3708bd59d0a2d7548bfd637f8 /drivers/s390/net | |
parent | 2ced5514b3ffd4bd53588eee50c5cf8aa5f3fbcc (diff) |
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>
Diffstat (limited to 'drivers/s390/net')
-rw-r--r-- | drivers/s390/net/qeth_core.h | 7 | ||||
-rw-r--r-- | drivers/s390/net/qeth_core_main.c | 56 | ||||
-rw-r--r-- | drivers/s390/net/qeth_core_sys.c | 43 |
3 files changed, 35 insertions, 71 deletions
diff --git a/drivers/s390/net/qeth_core.h b/drivers/s390/net/qeth_core.h index ec7921b5138e..81d19db805ba 100644 --- a/drivers/s390/net/qeth_core.h +++ b/drivers/s390/net/qeth_core.h | |||
@@ -843,14 +843,13 @@ static inline int qeth_is_diagass_supported(struct qeth_card *card, | |||
843 | 843 | ||
844 | extern struct ccwgroup_driver qeth_l2_ccwgroup_driver; | 844 | extern struct ccwgroup_driver qeth_l2_ccwgroup_driver; |
845 | extern struct ccwgroup_driver qeth_l3_ccwgroup_driver; | 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 | const char *qeth_get_cardname_short(struct qeth_card *); | 849 | const char *qeth_get_cardname_short(struct qeth_card *); |
847 | int qeth_realloc_buffer_pool(struct qeth_card *, int); | 850 | int qeth_realloc_buffer_pool(struct qeth_card *, int); |
848 | int qeth_core_load_discipline(struct qeth_card *, enum qeth_discipline_id); | 851 | int qeth_core_load_discipline(struct qeth_card *, enum qeth_discipline_id); |
849 | void qeth_core_free_discipline(struct qeth_card *); | 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 | void qeth_buffer_reclaim_work(struct work_struct *); | 853 | void qeth_buffer_reclaim_work(struct work_struct *); |
855 | 854 | ||
856 | /* exports for qeth discipline device drivers */ | 855 | /* exports for qeth discipline device drivers */ |
diff --git a/drivers/s390/net/qeth_core_main.c b/drivers/s390/net/qeth_core_main.c index c146877e8b7b..1a6a3132cb4b 100644 --- a/drivers/s390/net/qeth_core_main.c +++ b/drivers/s390/net/qeth_core_main.c | |||
@@ -4739,13 +4739,6 @@ static struct ccw_driver qeth_ccw_driver = { | |||
4739 | .remove = ccwgroup_remove_ccwdev, | 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 | int qeth_core_hardsetup_card(struct qeth_card *card) | 4742 | int qeth_core_hardsetup_card(struct qeth_card *card) |
4750 | { | 4743 | { |
4751 | int retries = 0; | 4744 | int retries = 0; |
@@ -5074,6 +5067,15 @@ void qeth_core_free_discipline(struct qeth_card *card) | |||
5074 | card->discipline.ccwgdriver = NULL; | 5067 | card->discipline.ccwgdriver = NULL; |
5075 | } | 5068 | } |
5076 | 5069 | ||
5070 | static const struct device_type qeth_generic_devtype = { | ||
5071 | .name = "qeth_generic", | ||
5072 | .groups = qeth_generic_attr_groups, | ||
5073 | }; | ||
5074 | static const struct device_type qeth_osn_devtype = { | ||
5075 | .name = "qeth_osn", | ||
5076 | .groups = qeth_osn_attr_groups, | ||
5077 | }; | ||
5078 | |||
5077 | static int qeth_core_probe_device(struct ccwgroup_device *gdev) | 5079 | static int qeth_core_probe_device(struct ccwgroup_device *gdev) |
5078 | { | 5080 | { |
5079 | struct qeth_card *card; | 5081 | struct qeth_card *card; |
@@ -5128,17 +5130,16 @@ static int qeth_core_probe_device(struct ccwgroup_device *gdev) | |||
5128 | } | 5130 | } |
5129 | 5131 | ||
5130 | if (card->info.type == QETH_CARD_TYPE_OSN) | 5132 | if (card->info.type == QETH_CARD_TYPE_OSN) |
5131 | rc = qeth_core_create_osn_attributes(dev); | 5133 | gdev->dev.type = &qeth_osn_devtype; |
5132 | else | 5134 | else |
5133 | rc = qeth_core_create_device_attributes(dev); | 5135 | gdev->dev.type = &qeth_generic_devtype; |
5134 | if (rc) | 5136 | |
5135 | goto err_dbf; | ||
5136 | switch (card->info.type) { | 5137 | switch (card->info.type) { |
5137 | case QETH_CARD_TYPE_OSN: | 5138 | case QETH_CARD_TYPE_OSN: |
5138 | case QETH_CARD_TYPE_OSM: | 5139 | case QETH_CARD_TYPE_OSM: |
5139 | rc = qeth_core_load_discipline(card, QETH_DISCIPLINE_LAYER2); | 5140 | rc = qeth_core_load_discipline(card, QETH_DISCIPLINE_LAYER2); |
5140 | if (rc) | 5141 | if (rc) |
5141 | goto err_attr; | 5142 | goto err_dbf; |
5142 | rc = card->discipline.ccwgdriver->probe(card->gdev); | 5143 | rc = card->discipline.ccwgdriver->probe(card->gdev); |
5143 | if (rc) | 5144 | if (rc) |
5144 | goto err_disc; | 5145 | goto err_disc; |
@@ -5157,11 +5158,6 @@ static int qeth_core_probe_device(struct ccwgroup_device *gdev) | |||
5157 | 5158 | ||
5158 | err_disc: | 5159 | err_disc: |
5159 | qeth_core_free_discipline(card); | 5160 | qeth_core_free_discipline(card); |
5160 | err_attr: | ||
5161 | if (card->info.type == QETH_CARD_TYPE_OSN) | ||
5162 | qeth_core_remove_osn_attributes(dev); | ||
5163 | else | ||
5164 | qeth_core_remove_device_attributes(dev); | ||
5165 | err_dbf: | 5161 | err_dbf: |
5166 | debug_unregister(card->debug); | 5162 | debug_unregister(card->debug); |
5167 | err_card: | 5163 | err_card: |
@@ -5178,12 +5174,6 @@ static void qeth_core_remove_device(struct ccwgroup_device *gdev) | |||
5178 | 5174 | ||
5179 | QETH_DBF_TEXT(SETUP, 2, "removedv"); | 5175 | QETH_DBF_TEXT(SETUP, 2, "removedv"); |
5180 | 5176 | ||
5181 | if (card->info.type == QETH_CARD_TYPE_OSN) { | ||
5182 | qeth_core_remove_osn_attributes(&gdev->dev); | ||
5183 | } else { | ||
5184 | qeth_core_remove_device_attributes(&gdev->dev); | ||
5185 | } | ||
5186 | |||
5187 | if (card->discipline.ccwgdriver) { | 5177 | if (card->discipline.ccwgdriver) { |
5188 | card->discipline.ccwgdriver->remove(gdev); | 5178 | card->discipline.ccwgdriver->remove(gdev); |
5189 | qeth_core_free_discipline(card); | 5179 | qeth_core_free_discipline(card); |
@@ -5286,7 +5276,7 @@ static struct ccwgroup_driver qeth_core_ccwgroup_driver = { | |||
5286 | .name = "qeth", | 5276 | .name = "qeth", |
5287 | }, | 5277 | }, |
5288 | .driver_id = 0xD8C5E3C8, | 5278 | .driver_id = 0xD8C5E3C8, |
5289 | .probe = qeth_core_probe_device, | 5279 | .setup = qeth_core_probe_device, |
5290 | .remove = qeth_core_remove_device, | 5280 | .remove = qeth_core_remove_device, |
5291 | .set_online = qeth_core_set_online, | 5281 | .set_online = qeth_core_set_online, |
5292 | .set_offline = qeth_core_set_offline, | 5282 | .set_offline = qeth_core_set_offline, |
@@ -5298,19 +5288,17 @@ static struct ccwgroup_driver qeth_core_ccwgroup_driver = { | |||
5298 | .restore = qeth_core_restore, | 5288 | .restore = qeth_core_restore, |
5299 | }; | 5289 | }; |
5300 | 5290 | ||
5301 | static ssize_t | 5291 | static ssize_t qeth_core_driver_group_store(struct device_driver *ddrv, |
5302 | qeth_core_driver_group_store(struct device_driver *ddrv, const char *buf, | 5292 | const char *buf, size_t count) |
5303 | size_t count) | ||
5304 | { | 5293 | { |
5305 | int err; | 5294 | int err; |
5306 | err = qeth_core_driver_group(buf, qeth_core_root_dev, | ||
5307 | qeth_core_ccwgroup_driver.driver_id); | ||
5308 | if (err) | ||
5309 | return err; | ||
5310 | else | ||
5311 | return count; | ||
5312 | } | ||
5313 | 5295 | ||
5296 | err = ccwgroup_create_dev(qeth_core_root_dev, | ||
5297 | qeth_core_ccwgroup_driver.driver_id, | ||
5298 | &qeth_core_ccwgroup_driver, 3, buf); | ||
5299 | |||
5300 | return err ? err : count; | ||
5301 | } | ||
5314 | static DRIVER_ATTR(group, 0200, NULL, qeth_core_driver_group_store); | 5302 | static DRIVER_ATTR(group, 0200, NULL, qeth_core_driver_group_store); |
5315 | 5303 | ||
5316 | static struct { | 5304 | static struct { |
diff --git a/drivers/s390/net/qeth_core_sys.c b/drivers/s390/net/qeth_core_sys.c index 0a8e86c1b0ea..a6b49db9f2d2 100644 --- a/drivers/s390/net/qeth_core_sys.c +++ b/drivers/s390/net/qeth_core_sys.c | |||
@@ -693,7 +693,6 @@ static struct attribute *qeth_blkt_device_attrs[] = { | |||
693 | &dev_attr_inter_jumbo.attr, | 693 | &dev_attr_inter_jumbo.attr, |
694 | NULL, | 694 | NULL, |
695 | }; | 695 | }; |
696 | |||
697 | static struct attribute_group qeth_device_blkt_group = { | 696 | static struct attribute_group qeth_device_blkt_group = { |
698 | .name = "blkt", | 697 | .name = "blkt", |
699 | .attrs = qeth_blkt_device_attrs, | 698 | .attrs = qeth_blkt_device_attrs, |
@@ -716,11 +715,16 @@ static struct attribute *qeth_device_attrs[] = { | |||
716 | &dev_attr_hw_trap.attr, | 715 | &dev_attr_hw_trap.attr, |
717 | NULL, | 716 | NULL, |
718 | }; | 717 | }; |
719 | |||
720 | static struct attribute_group qeth_device_attr_group = { | 718 | static struct attribute_group qeth_device_attr_group = { |
721 | .attrs = qeth_device_attrs, | 719 | .attrs = qeth_device_attrs, |
722 | }; | 720 | }; |
723 | 721 | ||
722 | const struct attribute_group *qeth_generic_attr_groups[] = { | ||
723 | &qeth_device_attr_group, | ||
724 | &qeth_device_blkt_group, | ||
725 | NULL, | ||
726 | }; | ||
727 | |||
724 | static struct attribute *qeth_osn_device_attrs[] = { | 728 | static struct attribute *qeth_osn_device_attrs[] = { |
725 | &dev_attr_state.attr, | 729 | &dev_attr_state.attr, |
726 | &dev_attr_chpid.attr, | 730 | &dev_attr_chpid.attr, |
@@ -730,37 +734,10 @@ static struct attribute *qeth_osn_device_attrs[] = { | |||
730 | &dev_attr_recover.attr, | 734 | &dev_attr_recover.attr, |
731 | NULL, | 735 | NULL, |
732 | }; | 736 | }; |
733 | |||
734 | static struct attribute_group qeth_osn_device_attr_group = { | 737 | static struct attribute_group qeth_osn_device_attr_group = { |
735 | .attrs = qeth_osn_device_attrs, | 738 | .attrs = qeth_osn_device_attrs, |
736 | }; | 739 | }; |
737 | 740 | const struct attribute_group *qeth_osn_attr_groups[] = { | |
738 | int qeth_core_create_device_attributes(struct device *dev) | 741 | &qeth_osn_device_attr_group, |
739 | { | 742 | NULL, |
740 | int ret; | 743 | }; |
741 | ret = sysfs_create_group(&dev->kobj, &qeth_device_attr_group); | ||
742 | if (ret) | ||
743 | return ret; | ||
744 | ret = sysfs_create_group(&dev->kobj, &qeth_device_blkt_group); | ||
745 | if (ret) | ||
746 | sysfs_remove_group(&dev->kobj, &qeth_device_attr_group); | ||
747 | |||
748 | return 0; | ||
749 | } | ||
750 | |||
751 | void qeth_core_remove_device_attributes(struct device *dev) | ||
752 | { | ||
753 | sysfs_remove_group(&dev->kobj, &qeth_device_attr_group); | ||
754 | sysfs_remove_group(&dev->kobj, &qeth_device_blkt_group); | ||
755 | } | ||
756 | |||
757 | int qeth_core_create_osn_attributes(struct device *dev) | ||
758 | { | ||
759 | return sysfs_create_group(&dev->kobj, &qeth_osn_device_attr_group); | ||
760 | } | ||
761 | |||
762 | void qeth_core_remove_osn_attributes(struct device *dev) | ||
763 | { | ||
764 | sysfs_remove_group(&dev->kobj, &qeth_osn_device_attr_group); | ||
765 | return; | ||
766 | } | ||