diff options
Diffstat (limited to 'drivers/s390/net/claw.c')
-rw-r--r-- | drivers/s390/net/claw.c | 165 |
1 files changed, 64 insertions, 101 deletions
diff --git a/drivers/s390/net/claw.c b/drivers/s390/net/claw.c index b41fae37d3af..6b1ff90d2f00 100644 --- a/drivers/s390/net/claw.c +++ b/drivers/s390/net/claw.c | |||
@@ -136,7 +136,6 @@ static inline void | |||
136 | claw_set_busy(struct net_device *dev) | 136 | claw_set_busy(struct net_device *dev) |
137 | { | 137 | { |
138 | ((struct claw_privbk *)dev->ml_priv)->tbusy = 1; | 138 | ((struct claw_privbk *)dev->ml_priv)->tbusy = 1; |
139 | eieio(); | ||
140 | } | 139 | } |
141 | 140 | ||
142 | static inline void | 141 | static inline void |
@@ -144,13 +143,11 @@ claw_clear_busy(struct net_device *dev) | |||
144 | { | 143 | { |
145 | clear_bit(0, &(((struct claw_privbk *) dev->ml_priv)->tbusy)); | 144 | clear_bit(0, &(((struct claw_privbk *) dev->ml_priv)->tbusy)); |
146 | netif_wake_queue(dev); | 145 | netif_wake_queue(dev); |
147 | eieio(); | ||
148 | } | 146 | } |
149 | 147 | ||
150 | static inline int | 148 | static inline int |
151 | claw_check_busy(struct net_device *dev) | 149 | claw_check_busy(struct net_device *dev) |
152 | { | 150 | { |
153 | eieio(); | ||
154 | return ((struct claw_privbk *) dev->ml_priv)->tbusy; | 151 | return ((struct claw_privbk *) dev->ml_priv)->tbusy; |
155 | } | 152 | } |
156 | 153 | ||
@@ -233,8 +230,6 @@ static ssize_t claw_rbuff_show(struct device *dev, | |||
233 | static ssize_t claw_rbuff_write(struct device *dev, | 230 | static ssize_t claw_rbuff_write(struct device *dev, |
234 | struct device_attribute *attr, | 231 | struct device_attribute *attr, |
235 | const char *buf, size_t count); | 232 | const char *buf, size_t count); |
236 | static int claw_add_files(struct device *dev); | ||
237 | static void claw_remove_files(struct device *dev); | ||
238 | 233 | ||
239 | /* Functions for System Validate */ | 234 | /* Functions for System Validate */ |
240 | static int claw_process_control( struct net_device *dev, struct ccwbk * p_ccw); | 235 | static int claw_process_control( struct net_device *dev, struct ccwbk * p_ccw); |
@@ -267,12 +262,10 @@ static struct ccwgroup_driver claw_group_driver = { | |||
267 | .owner = THIS_MODULE, | 262 | .owner = THIS_MODULE, |
268 | .name = "claw", | 263 | .name = "claw", |
269 | }, | 264 | }, |
270 | .max_slaves = 2, | 265 | .setup = claw_probe, |
271 | .driver_id = 0xC3D3C1E6, | 266 | .remove = claw_remove_device, |
272 | .probe = claw_probe, | 267 | .set_online = claw_new_device, |
273 | .remove = claw_remove_device, | 268 | .set_offline = claw_shutdown_device, |
274 | .set_online = claw_new_device, | ||
275 | .set_offline = claw_shutdown_device, | ||
276 | .prepare = claw_pm_prepare, | 269 | .prepare = claw_pm_prepare, |
277 | }; | 270 | }; |
278 | 271 | ||
@@ -293,30 +286,24 @@ static struct ccw_driver claw_ccw_driver = { | |||
293 | .int_class = IOINT_CLW, | 286 | .int_class = IOINT_CLW, |
294 | }; | 287 | }; |
295 | 288 | ||
296 | static ssize_t | 289 | static ssize_t claw_driver_group_store(struct device_driver *ddrv, |
297 | claw_driver_group_store(struct device_driver *ddrv, const char *buf, | 290 | const char *buf, size_t count) |
298 | size_t count) | ||
299 | { | 291 | { |
300 | int err; | 292 | int err; |
301 | err = ccwgroup_create_from_string(claw_root_dev, | 293 | err = ccwgroup_create_dev(claw_root_dev, &claw_group_driver, 2, buf); |
302 | claw_group_driver.driver_id, | ||
303 | &claw_ccw_driver, 2, buf); | ||
304 | return err ? err : count; | 294 | return err ? err : count; |
305 | } | 295 | } |
306 | |||
307 | static DRIVER_ATTR(group, 0200, NULL, claw_driver_group_store); | 296 | static DRIVER_ATTR(group, 0200, NULL, claw_driver_group_store); |
308 | 297 | ||
309 | static struct attribute *claw_group_attrs[] = { | 298 | static struct attribute *claw_drv_attrs[] = { |
310 | &driver_attr_group.attr, | 299 | &driver_attr_group.attr, |
311 | NULL, | 300 | NULL, |
312 | }; | 301 | }; |
313 | 302 | static struct attribute_group claw_drv_attr_group = { | |
314 | static struct attribute_group claw_group_attr_group = { | 303 | .attrs = claw_drv_attrs, |
315 | .attrs = claw_group_attrs, | ||
316 | }; | 304 | }; |
317 | 305 | static const struct attribute_group *claw_drv_attr_groups[] = { | |
318 | static const struct attribute_group *claw_group_attr_groups[] = { | 306 | &claw_drv_attr_group, |
319 | &claw_group_attr_group, | ||
320 | NULL, | 307 | NULL, |
321 | }; | 308 | }; |
322 | 309 | ||
@@ -324,60 +311,6 @@ static const struct attribute_group *claw_group_attr_groups[] = { | |||
324 | * Key functions | 311 | * Key functions |
325 | */ | 312 | */ |
326 | 313 | ||
327 | /*----------------------------------------------------------------* | ||
328 | * claw_probe * | ||
329 | * this function is called for each CLAW device. * | ||
330 | *----------------------------------------------------------------*/ | ||
331 | static int | ||
332 | claw_probe(struct ccwgroup_device *cgdev) | ||
333 | { | ||
334 | int rc; | ||
335 | struct claw_privbk *privptr=NULL; | ||
336 | |||
337 | CLAW_DBF_TEXT(2, setup, "probe"); | ||
338 | if (!get_device(&cgdev->dev)) | ||
339 | return -ENODEV; | ||
340 | privptr = kzalloc(sizeof(struct claw_privbk), GFP_KERNEL); | ||
341 | dev_set_drvdata(&cgdev->dev, privptr); | ||
342 | if (privptr == NULL) { | ||
343 | probe_error(cgdev); | ||
344 | put_device(&cgdev->dev); | ||
345 | CLAW_DBF_TEXT_(2, setup, "probex%d", -ENOMEM); | ||
346 | return -ENOMEM; | ||
347 | } | ||
348 | privptr->p_mtc_envelope= kzalloc( MAX_ENVELOPE_SIZE, GFP_KERNEL); | ||
349 | privptr->p_env = kzalloc(sizeof(struct claw_env), GFP_KERNEL); | ||
350 | if ((privptr->p_mtc_envelope==NULL) || (privptr->p_env==NULL)) { | ||
351 | probe_error(cgdev); | ||
352 | put_device(&cgdev->dev); | ||
353 | CLAW_DBF_TEXT_(2, setup, "probex%d", -ENOMEM); | ||
354 | return -ENOMEM; | ||
355 | } | ||
356 | memcpy(privptr->p_env->adapter_name,WS_NAME_NOT_DEF,8); | ||
357 | memcpy(privptr->p_env->host_name,WS_NAME_NOT_DEF,8); | ||
358 | memcpy(privptr->p_env->api_type,WS_NAME_NOT_DEF,8); | ||
359 | privptr->p_env->packing = 0; | ||
360 | privptr->p_env->write_buffers = 5; | ||
361 | privptr->p_env->read_buffers = 5; | ||
362 | privptr->p_env->read_size = CLAW_FRAME_SIZE; | ||
363 | privptr->p_env->write_size = CLAW_FRAME_SIZE; | ||
364 | rc = claw_add_files(&cgdev->dev); | ||
365 | if (rc) { | ||
366 | probe_error(cgdev); | ||
367 | put_device(&cgdev->dev); | ||
368 | dev_err(&cgdev->dev, "Creating the /proc files for a new" | ||
369 | " CLAW device failed\n"); | ||
370 | CLAW_DBF_TEXT_(2, setup, "probex%d", rc); | ||
371 | return rc; | ||
372 | } | ||
373 | privptr->p_env->p_priv = privptr; | ||
374 | cgdev->cdev[0]->handler = claw_irq_handler; | ||
375 | cgdev->cdev[1]->handler = claw_irq_handler; | ||
376 | CLAW_DBF_TEXT(2, setup, "prbext 0"); | ||
377 | |||
378 | return 0; | ||
379 | } /* end of claw_probe */ | ||
380 | |||
381 | /*-------------------------------------------------------------------* | 314 | /*-------------------------------------------------------------------* |
382 | * claw_tx * | 315 | * claw_tx * |
383 | *-------------------------------------------------------------------*/ | 316 | *-------------------------------------------------------------------*/ |
@@ -3093,7 +3026,6 @@ claw_remove_device(struct ccwgroup_device *cgdev) | |||
3093 | dev_info(&cgdev->dev, " will be removed.\n"); | 3026 | dev_info(&cgdev->dev, " will be removed.\n"); |
3094 | if (cgdev->state == CCWGROUP_ONLINE) | 3027 | if (cgdev->state == CCWGROUP_ONLINE) |
3095 | claw_shutdown_device(cgdev); | 3028 | claw_shutdown_device(cgdev); |
3096 | claw_remove_files(&cgdev->dev); | ||
3097 | kfree(priv->p_mtc_envelope); | 3029 | kfree(priv->p_mtc_envelope); |
3098 | priv->p_mtc_envelope=NULL; | 3030 | priv->p_mtc_envelope=NULL; |
3099 | kfree(priv->p_env); | 3031 | kfree(priv->p_env); |
@@ -3321,7 +3253,6 @@ claw_rbuff_write(struct device *dev, struct device_attribute *attr, | |||
3321 | CLAW_DBF_TEXT_(2, setup, "RB=%d", p_env->read_buffers); | 3253 | CLAW_DBF_TEXT_(2, setup, "RB=%d", p_env->read_buffers); |
3322 | return count; | 3254 | return count; |
3323 | } | 3255 | } |
3324 | |||
3325 | static DEVICE_ATTR(read_buffer, 0644, claw_rbuff_show, claw_rbuff_write); | 3256 | static DEVICE_ATTR(read_buffer, 0644, claw_rbuff_show, claw_rbuff_write); |
3326 | 3257 | ||
3327 | static struct attribute *claw_attr[] = { | 3258 | static struct attribute *claw_attr[] = { |
@@ -3332,40 +3263,73 @@ static struct attribute *claw_attr[] = { | |||
3332 | &dev_attr_host_name.attr, | 3263 | &dev_attr_host_name.attr, |
3333 | NULL, | 3264 | NULL, |
3334 | }; | 3265 | }; |
3335 | |||
3336 | static struct attribute_group claw_attr_group = { | 3266 | static struct attribute_group claw_attr_group = { |
3337 | .attrs = claw_attr, | 3267 | .attrs = claw_attr, |
3338 | }; | 3268 | }; |
3269 | static const struct attribute_group *claw_attr_groups[] = { | ||
3270 | &claw_attr_group, | ||
3271 | NULL, | ||
3272 | }; | ||
3273 | static const struct device_type claw_devtype = { | ||
3274 | .name = "claw", | ||
3275 | .groups = claw_attr_groups, | ||
3276 | }; | ||
3339 | 3277 | ||
3340 | static int | 3278 | /*----------------------------------------------------------------* |
3341 | claw_add_files(struct device *dev) | 3279 | * claw_probe * |
3280 | * this function is called for each CLAW device. * | ||
3281 | *----------------------------------------------------------------*/ | ||
3282 | static int claw_probe(struct ccwgroup_device *cgdev) | ||
3342 | { | 3283 | { |
3343 | CLAW_DBF_TEXT(2, setup, "add_file"); | 3284 | struct claw_privbk *privptr = NULL; |
3344 | return sysfs_create_group(&dev->kobj, &claw_attr_group); | ||
3345 | } | ||
3346 | 3285 | ||
3347 | static void | 3286 | CLAW_DBF_TEXT(2, setup, "probe"); |
3348 | claw_remove_files(struct device *dev) | 3287 | if (!get_device(&cgdev->dev)) |
3349 | { | 3288 | return -ENODEV; |
3350 | CLAW_DBF_TEXT(2, setup, "rem_file"); | 3289 | privptr = kzalloc(sizeof(struct claw_privbk), GFP_KERNEL); |
3351 | sysfs_remove_group(&dev->kobj, &claw_attr_group); | 3290 | dev_set_drvdata(&cgdev->dev, privptr); |
3352 | } | 3291 | if (privptr == NULL) { |
3292 | probe_error(cgdev); | ||
3293 | put_device(&cgdev->dev); | ||
3294 | CLAW_DBF_TEXT_(2, setup, "probex%d", -ENOMEM); | ||
3295 | return -ENOMEM; | ||
3296 | } | ||
3297 | privptr->p_mtc_envelope = kzalloc(MAX_ENVELOPE_SIZE, GFP_KERNEL); | ||
3298 | privptr->p_env = kzalloc(sizeof(struct claw_env), GFP_KERNEL); | ||
3299 | if ((privptr->p_mtc_envelope == NULL) || (privptr->p_env == NULL)) { | ||
3300 | probe_error(cgdev); | ||
3301 | put_device(&cgdev->dev); | ||
3302 | CLAW_DBF_TEXT_(2, setup, "probex%d", -ENOMEM); | ||
3303 | return -ENOMEM; | ||
3304 | } | ||
3305 | memcpy(privptr->p_env->adapter_name, WS_NAME_NOT_DEF, 8); | ||
3306 | memcpy(privptr->p_env->host_name, WS_NAME_NOT_DEF, 8); | ||
3307 | memcpy(privptr->p_env->api_type, WS_NAME_NOT_DEF, 8); | ||
3308 | privptr->p_env->packing = 0; | ||
3309 | privptr->p_env->write_buffers = 5; | ||
3310 | privptr->p_env->read_buffers = 5; | ||
3311 | privptr->p_env->read_size = CLAW_FRAME_SIZE; | ||
3312 | privptr->p_env->write_size = CLAW_FRAME_SIZE; | ||
3313 | privptr->p_env->p_priv = privptr; | ||
3314 | cgdev->cdev[0]->handler = claw_irq_handler; | ||
3315 | cgdev->cdev[1]->handler = claw_irq_handler; | ||
3316 | cgdev->dev.type = &claw_devtype; | ||
3317 | CLAW_DBF_TEXT(2, setup, "prbext 0"); | ||
3318 | |||
3319 | return 0; | ||
3320 | } /* end of claw_probe */ | ||
3353 | 3321 | ||
3354 | /*--------------------------------------------------------------------* | 3322 | /*--------------------------------------------------------------------* |
3355 | * claw_init and cleanup * | 3323 | * claw_init and cleanup * |
3356 | *---------------------------------------------------------------------*/ | 3324 | *---------------------------------------------------------------------*/ |
3357 | 3325 | ||
3358 | static void __exit | 3326 | static void __exit claw_cleanup(void) |
3359 | claw_cleanup(void) | ||
3360 | { | 3327 | { |
3361 | driver_remove_file(&claw_group_driver.driver, | ||
3362 | &driver_attr_group); | ||
3363 | ccwgroup_driver_unregister(&claw_group_driver); | 3328 | ccwgroup_driver_unregister(&claw_group_driver); |
3364 | ccw_driver_unregister(&claw_ccw_driver); | 3329 | ccw_driver_unregister(&claw_ccw_driver); |
3365 | root_device_unregister(claw_root_dev); | 3330 | root_device_unregister(claw_root_dev); |
3366 | claw_unregister_debug_facility(); | 3331 | claw_unregister_debug_facility(); |
3367 | pr_info("Driver unloaded\n"); | 3332 | pr_info("Driver unloaded\n"); |
3368 | |||
3369 | } | 3333 | } |
3370 | 3334 | ||
3371 | /** | 3335 | /** |
@@ -3374,8 +3338,7 @@ claw_cleanup(void) | |||
3374 | * | 3338 | * |
3375 | * @return 0 on success, !0 on error. | 3339 | * @return 0 on success, !0 on error. |
3376 | */ | 3340 | */ |
3377 | static int __init | 3341 | static int __init claw_init(void) |
3378 | claw_init(void) | ||
3379 | { | 3342 | { |
3380 | int ret = 0; | 3343 | int ret = 0; |
3381 | 3344 | ||
@@ -3394,7 +3357,7 @@ claw_init(void) | |||
3394 | ret = ccw_driver_register(&claw_ccw_driver); | 3357 | ret = ccw_driver_register(&claw_ccw_driver); |
3395 | if (ret) | 3358 | if (ret) |
3396 | goto ccw_err; | 3359 | goto ccw_err; |
3397 | claw_group_driver.driver.groups = claw_group_attr_groups; | 3360 | claw_group_driver.driver.groups = claw_drv_attr_groups; |
3398 | ret = ccwgroup_driver_register(&claw_group_driver); | 3361 | ret = ccwgroup_driver_register(&claw_group_driver); |
3399 | if (ret) | 3362 | if (ret) |
3400 | goto ccwgroup_err; | 3363 | goto ccwgroup_err; |