aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/s390/net
diff options
context:
space:
mode:
authorSebastian Ott <sebott@linux.vnet.ibm.com>2012-05-15 12:00:49 -0400
committerMartin Schwidefsky <schwidefsky@de.ibm.com>2012-05-16 08:42:47 -0400
commit2ced5514b3ffd4bd53588eee50c5cf8aa5f3fbcc (patch)
treeeb3601a106c6c0aa98c50596d8a83f7724e812e7 /drivers/s390/net
parent00d5bdd17b6e2648ecff718e71c328864c9aae00 (diff)
s390/claw: 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/claw.c132
1 files changed, 54 insertions, 78 deletions
diff --git a/drivers/s390/net/claw.c b/drivers/s390/net/claw.c
index 4c3d4f675149..f7e7dcd74817 100644
--- a/drivers/s390/net/claw.c
+++ b/drivers/s390/net/claw.c
@@ -230,8 +230,6 @@ static ssize_t claw_rbuff_show(struct device *dev,
230static ssize_t claw_rbuff_write(struct device *dev, 230static ssize_t claw_rbuff_write(struct device *dev,
231 struct device_attribute *attr, 231 struct device_attribute *attr,
232 const char *buf, size_t count); 232 const char *buf, size_t count);
233static int claw_add_files(struct device *dev);
234static void claw_remove_files(struct device *dev);
235 233
236/* Functions for System Validate */ 234/* Functions for System Validate */
237static int claw_process_control( struct net_device *dev, struct ccwbk * p_ccw); 235static int claw_process_control( struct net_device *dev, struct ccwbk * p_ccw);
@@ -266,7 +264,7 @@ static struct ccwgroup_driver claw_group_driver = {
266 }, 264 },
267 .max_slaves = 2, 265 .max_slaves = 2,
268 .driver_id = 0xC3D3C1E6, 266 .driver_id = 0xC3D3C1E6,
269 .probe = claw_probe, 267 .setup = claw_probe,
270 .remove = claw_remove_device, 268 .remove = claw_remove_device,
271 .set_online = claw_new_device, 269 .set_online = claw_new_device,
272 .set_offline = claw_shutdown_device, 270 .set_offline = claw_shutdown_device,
@@ -290,17 +288,14 @@ static struct ccw_driver claw_ccw_driver = {
290 .int_class = IOINT_CLW, 288 .int_class = IOINT_CLW,
291}; 289};
292 290
293static ssize_t 291static ssize_t claw_driver_group_store(struct device_driver *ddrv,
294claw_driver_group_store(struct device_driver *ddrv, const char *buf, 292 const char *buf, size_t count)
295 size_t count)
296{ 293{
297 int err; 294 int err;
298 err = ccwgroup_create_from_string(claw_root_dev, 295 err = ccwgroup_create_dev(claw_root_dev, claw_group_driver.driver_id,
299 claw_group_driver.driver_id, 296 &claw_group_driver, 2, buf);
300 &claw_ccw_driver, 2, buf);
301 return err ? err : count; 297 return err ? err : count;
302} 298}
303
304static DRIVER_ATTR(group, 0200, NULL, claw_driver_group_store); 299static DRIVER_ATTR(group, 0200, NULL, claw_driver_group_store);
305 300
306static struct attribute *claw_group_attrs[] = { 301static struct attribute *claw_group_attrs[] = {
@@ -321,60 +316,6 @@ static const struct attribute_group *claw_group_attr_groups[] = {
321* Key functions 316* Key functions
322*/ 317*/
323 318
324/*----------------------------------------------------------------*
325 * claw_probe *
326 * this function is called for each CLAW device. *
327 *----------------------------------------------------------------*/
328static int
329claw_probe(struct ccwgroup_device *cgdev)
330{
331 int rc;
332 struct claw_privbk *privptr=NULL;
333
334 CLAW_DBF_TEXT(2, setup, "probe");
335 if (!get_device(&cgdev->dev))
336 return -ENODEV;
337 privptr = kzalloc(sizeof(struct claw_privbk), GFP_KERNEL);
338 dev_set_drvdata(&cgdev->dev, privptr);
339 if (privptr == NULL) {
340 probe_error(cgdev);
341 put_device(&cgdev->dev);
342 CLAW_DBF_TEXT_(2, setup, "probex%d", -ENOMEM);
343 return -ENOMEM;
344 }
345 privptr->p_mtc_envelope= kzalloc( MAX_ENVELOPE_SIZE, GFP_KERNEL);
346 privptr->p_env = kzalloc(sizeof(struct claw_env), GFP_KERNEL);
347 if ((privptr->p_mtc_envelope==NULL) || (privptr->p_env==NULL)) {
348 probe_error(cgdev);
349 put_device(&cgdev->dev);
350 CLAW_DBF_TEXT_(2, setup, "probex%d", -ENOMEM);
351 return -ENOMEM;
352 }
353 memcpy(privptr->p_env->adapter_name,WS_NAME_NOT_DEF,8);
354 memcpy(privptr->p_env->host_name,WS_NAME_NOT_DEF,8);
355 memcpy(privptr->p_env->api_type,WS_NAME_NOT_DEF,8);
356 privptr->p_env->packing = 0;
357 privptr->p_env->write_buffers = 5;
358 privptr->p_env->read_buffers = 5;
359 privptr->p_env->read_size = CLAW_FRAME_SIZE;
360 privptr->p_env->write_size = CLAW_FRAME_SIZE;
361 rc = claw_add_files(&cgdev->dev);
362 if (rc) {
363 probe_error(cgdev);
364 put_device(&cgdev->dev);
365 dev_err(&cgdev->dev, "Creating the /proc files for a new"
366 " CLAW device failed\n");
367 CLAW_DBF_TEXT_(2, setup, "probex%d", rc);
368 return rc;
369 }
370 privptr->p_env->p_priv = privptr;
371 cgdev->cdev[0]->handler = claw_irq_handler;
372 cgdev->cdev[1]->handler = claw_irq_handler;
373 CLAW_DBF_TEXT(2, setup, "prbext 0");
374
375 return 0;
376} /* end of claw_probe */
377
378/*-------------------------------------------------------------------* 319/*-------------------------------------------------------------------*
379 * claw_tx * 320 * claw_tx *
380 *-------------------------------------------------------------------*/ 321 *-------------------------------------------------------------------*/
@@ -3090,7 +3031,6 @@ claw_remove_device(struct ccwgroup_device *cgdev)
3090 dev_info(&cgdev->dev, " will be removed.\n"); 3031 dev_info(&cgdev->dev, " will be removed.\n");
3091 if (cgdev->state == CCWGROUP_ONLINE) 3032 if (cgdev->state == CCWGROUP_ONLINE)
3092 claw_shutdown_device(cgdev); 3033 claw_shutdown_device(cgdev);
3093 claw_remove_files(&cgdev->dev);
3094 kfree(priv->p_mtc_envelope); 3034 kfree(priv->p_mtc_envelope);
3095 priv->p_mtc_envelope=NULL; 3035 priv->p_mtc_envelope=NULL;
3096 kfree(priv->p_env); 3036 kfree(priv->p_env);
@@ -3318,7 +3258,6 @@ claw_rbuff_write(struct device *dev, struct device_attribute *attr,
3318 CLAW_DBF_TEXT_(2, setup, "RB=%d", p_env->read_buffers); 3258 CLAW_DBF_TEXT_(2, setup, "RB=%d", p_env->read_buffers);
3319 return count; 3259 return count;
3320} 3260}
3321
3322static DEVICE_ATTR(read_buffer, 0644, claw_rbuff_show, claw_rbuff_write); 3261static DEVICE_ATTR(read_buffer, 0644, claw_rbuff_show, claw_rbuff_write);
3323 3262
3324static struct attribute *claw_attr[] = { 3263static struct attribute *claw_attr[] = {
@@ -3329,24 +3268,61 @@ static struct attribute *claw_attr[] = {
3329 &dev_attr_host_name.attr, 3268 &dev_attr_host_name.attr,
3330 NULL, 3269 NULL,
3331}; 3270};
3332
3333static struct attribute_group claw_attr_group = { 3271static struct attribute_group claw_attr_group = {
3334 .attrs = claw_attr, 3272 .attrs = claw_attr,
3335}; 3273};
3274static const struct attribute_group *claw_attr_groups[] = {
3275 &claw_attr_group,
3276 NULL,
3277};
3278static const struct device_type claw_devtype = {
3279 .name = "claw",
3280 .groups = claw_attr_groups,
3281};
3336 3282
3337static int 3283/*----------------------------------------------------------------*
3338claw_add_files(struct device *dev) 3284 * claw_probe *
3285 * this function is called for each CLAW device. *
3286 *----------------------------------------------------------------*/
3287static int claw_probe(struct ccwgroup_device *cgdev)
3339{ 3288{
3340 CLAW_DBF_TEXT(2, setup, "add_file"); 3289 struct claw_privbk *privptr = NULL;
3341 return sysfs_create_group(&dev->kobj, &claw_attr_group);
3342}
3343 3290
3344static void 3291 CLAW_DBF_TEXT(2, setup, "probe");
3345claw_remove_files(struct device *dev) 3292 if (!get_device(&cgdev->dev))
3346{ 3293 return -ENODEV;
3347 CLAW_DBF_TEXT(2, setup, "rem_file"); 3294 privptr = kzalloc(sizeof(struct claw_privbk), GFP_KERNEL);
3348 sysfs_remove_group(&dev->kobj, &claw_attr_group); 3295 dev_set_drvdata(&cgdev->dev, privptr);
3349} 3296 if (privptr == NULL) {
3297 probe_error(cgdev);
3298 put_device(&cgdev->dev);
3299 CLAW_DBF_TEXT_(2, setup, "probex%d", -ENOMEM);
3300 return -ENOMEM;
3301 }
3302 privptr->p_mtc_envelope = kzalloc(MAX_ENVELOPE_SIZE, GFP_KERNEL);
3303 privptr->p_env = kzalloc(sizeof(struct claw_env), GFP_KERNEL);
3304 if ((privptr->p_mtc_envelope == NULL) || (privptr->p_env == NULL)) {
3305 probe_error(cgdev);
3306 put_device(&cgdev->dev);
3307 CLAW_DBF_TEXT_(2, setup, "probex%d", -ENOMEM);
3308 return -ENOMEM;
3309 }
3310 memcpy(privptr->p_env->adapter_name, WS_NAME_NOT_DEF, 8);
3311 memcpy(privptr->p_env->host_name, WS_NAME_NOT_DEF, 8);
3312 memcpy(privptr->p_env->api_type, WS_NAME_NOT_DEF, 8);
3313 privptr->p_env->packing = 0;
3314 privptr->p_env->write_buffers = 5;
3315 privptr->p_env->read_buffers = 5;
3316 privptr->p_env->read_size = CLAW_FRAME_SIZE;
3317 privptr->p_env->write_size = CLAW_FRAME_SIZE;
3318 privptr->p_env->p_priv = privptr;
3319 cgdev->cdev[0]->handler = claw_irq_handler;
3320 cgdev->cdev[1]->handler = claw_irq_handler;
3321 cgdev->dev.type = &claw_devtype;
3322 CLAW_DBF_TEXT(2, setup, "prbext 0");
3323
3324 return 0;
3325} /* end of claw_probe */
3350 3326
3351/*--------------------------------------------------------------------* 3327/*--------------------------------------------------------------------*
3352* claw_init and cleanup * 3328* claw_init and cleanup *