diff options
author | Ursula Braun <braunu@de.ibm.com> | 2008-04-24 04:15:20 -0400 |
---|---|---|
committer | Jeff Garzik <jgarzik@redhat.com> | 2008-04-29 01:56:29 -0400 |
commit | 022b660ae5d075ed9eaddef6f6fb7abb48bdf63b (patch) | |
tree | 9520e014a156da3d70f26e859d4e9b838602f79b /drivers/s390/net | |
parent | 8bbf84404b02f193c5422c252264d7b82ffe4443 (diff) |
ccwgroup: Unify parsing for group attribute.
Instead of having each driver for ccwgroup slave device parsing the
input itself and calling ccwgroup_create(), introduce a new function
ccwgroup_create_from_string() and handle parsing inside the ccwgroup
core.
Signed-off-by: Ursula Braun <braunu@de.ibm.com>
Signed-off-by: Frank Blaschka <frank.blaschka@de.ibm.com>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Diffstat (limited to 'drivers/s390/net')
-rw-r--r-- | drivers/s390/net/cu3088.c | 20 | ||||
-rw-r--r-- | drivers/s390/net/qeth_core_main.c | 23 |
2 files changed, 4 insertions, 39 deletions
diff --git a/drivers/s390/net/cu3088.c b/drivers/s390/net/cu3088.c index 76728ae4b843..8e7697305a4c 100644 --- a/drivers/s390/net/cu3088.c +++ b/drivers/s390/net/cu3088.c | |||
@@ -62,30 +62,14 @@ static struct device *cu3088_root_dev; | |||
62 | static ssize_t | 62 | static ssize_t |
63 | group_write(struct device_driver *drv, const char *buf, size_t count) | 63 | group_write(struct device_driver *drv, const char *buf, size_t count) |
64 | { | 64 | { |
65 | const char *start, *end; | ||
66 | char bus_ids[2][BUS_ID_SIZE], *argv[2]; | ||
67 | int i; | ||
68 | int ret; | 65 | int ret; |
69 | struct ccwgroup_driver *cdrv; | 66 | struct ccwgroup_driver *cdrv; |
70 | 67 | ||
71 | cdrv = to_ccwgroupdrv(drv); | 68 | cdrv = to_ccwgroupdrv(drv); |
72 | if (!cdrv) | 69 | if (!cdrv) |
73 | return -EINVAL; | 70 | return -EINVAL; |
74 | start = buf; | 71 | ret = ccwgroup_create_from_string(cu3088_root_dev, cdrv->driver_id, |
75 | for (i=0; i<2; i++) { | 72 | &cu3088_driver, 2, buf); |
76 | static const char delim[] = {',', '\n'}; | ||
77 | int len; | ||
78 | |||
79 | if (!(end = strchr(start, delim[i]))) | ||
80 | return -EINVAL; | ||
81 | len = min_t(ptrdiff_t, BUS_ID_SIZE, end - start + 1); | ||
82 | strlcpy (bus_ids[i], start, len); | ||
83 | argv[i] = bus_ids[i]; | ||
84 | start = end + 1; | ||
85 | } | ||
86 | |||
87 | ret = ccwgroup_create(cu3088_root_dev, cdrv->driver_id, | ||
88 | &cu3088_driver, 2, argv); | ||
89 | 73 | ||
90 | return (ret == 0) ? count : ret; | 74 | return (ret == 0) ? count : ret; |
91 | } | 75 | } |
diff --git a/drivers/s390/net/qeth_core_main.c b/drivers/s390/net/qeth_core_main.c index 055f5c3e7b56..231d18c3b6f7 100644 --- a/drivers/s390/net/qeth_core_main.c +++ b/drivers/s390/net/qeth_core_main.c | |||
@@ -3827,27 +3827,8 @@ static struct ccw_driver qeth_ccw_driver = { | |||
3827 | static int qeth_core_driver_group(const char *buf, struct device *root_dev, | 3827 | static int qeth_core_driver_group(const char *buf, struct device *root_dev, |
3828 | unsigned long driver_id) | 3828 | unsigned long driver_id) |
3829 | { | 3829 | { |
3830 | const char *start, *end; | 3830 | return ccwgroup_create_from_string(root_dev, driver_id, |
3831 | char bus_ids[3][BUS_ID_SIZE], *argv[3]; | 3831 | &qeth_ccw_driver, 3, buf); |
3832 | int i; | ||
3833 | |||
3834 | start = buf; | ||
3835 | for (i = 0; i < 3; i++) { | ||
3836 | static const char delim[] = { ',', ',', '\n' }; | ||
3837 | int len; | ||
3838 | |||
3839 | end = strchr(start, delim[i]); | ||
3840 | if (!end) | ||
3841 | return -EINVAL; | ||
3842 | len = min_t(ptrdiff_t, BUS_ID_SIZE, end - start); | ||
3843 | strncpy(bus_ids[i], start, len); | ||
3844 | bus_ids[i][len] = '\0'; | ||
3845 | start = end + 1; | ||
3846 | argv[i] = bus_ids[i]; | ||
3847 | } | ||
3848 | |||
3849 | return (ccwgroup_create(root_dev, driver_id, | ||
3850 | &qeth_ccw_driver, 3, argv)); | ||
3851 | } | 3832 | } |
3852 | 3833 | ||
3853 | int qeth_core_hardsetup_card(struct qeth_card *card) | 3834 | int qeth_core_hardsetup_card(struct qeth_card *card) |