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

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>

authored by

Sebastian Ott and committed by
Martin Schwidefsky
2ced5514 00d5bdd1

+54 -78
+54 -78
drivers/s390/net/claw.c
··· 230 230 static ssize_t claw_rbuff_write(struct device *dev, 231 231 struct device_attribute *attr, 232 232 const char *buf, size_t count); 233 - static int claw_add_files(struct device *dev); 234 - static void claw_remove_files(struct device *dev); 235 233 236 234 /* Functions for System Validate */ 237 235 static int claw_process_control( struct net_device *dev, struct ccwbk * p_ccw); ··· 264 266 }, 265 267 .max_slaves = 2, 266 268 .driver_id = 0xC3D3C1E6, 267 - .probe = claw_probe, 269 + .setup = claw_probe, 268 270 .remove = claw_remove_device, 269 271 .set_online = claw_new_device, 270 272 .set_offline = claw_shutdown_device, ··· 288 290 .int_class = IOINT_CLW, 289 291 }; 290 292 291 - static ssize_t 292 - claw_driver_group_store(struct device_driver *ddrv, const char *buf, 293 - size_t count) 293 + static ssize_t claw_driver_group_store(struct device_driver *ddrv, 294 + const char *buf, size_t count) 294 295 { 295 296 int err; 296 - err = ccwgroup_create_from_string(claw_root_dev, 297 - claw_group_driver.driver_id, 298 - &claw_ccw_driver, 2, buf); 297 + err = ccwgroup_create_dev(claw_root_dev, claw_group_driver.driver_id, 298 + &claw_group_driver, 2, buf); 299 299 return err ? err : count; 300 300 } 301 - 302 301 static DRIVER_ATTR(group, 0200, NULL, claw_driver_group_store); 303 302 304 303 static struct attribute *claw_group_attrs[] = { ··· 315 320 /* 316 321 * Key functions 317 322 */ 318 - 319 - /*----------------------------------------------------------------* 320 - * claw_probe * 321 - * this function is called for each CLAW device. * 322 - *----------------------------------------------------------------*/ 323 - static int 324 - claw_probe(struct ccwgroup_device *cgdev) 325 - { 326 - int rc; 327 - struct claw_privbk *privptr=NULL; 328 - 329 - CLAW_DBF_TEXT(2, setup, "probe"); 330 - if (!get_device(&cgdev->dev)) 331 - return -ENODEV; 332 - privptr = kzalloc(sizeof(struct claw_privbk), GFP_KERNEL); 333 - dev_set_drvdata(&cgdev->dev, privptr); 334 - if (privptr == NULL) { 335 - probe_error(cgdev); 336 - put_device(&cgdev->dev); 337 - CLAW_DBF_TEXT_(2, setup, "probex%d", -ENOMEM); 338 - return -ENOMEM; 339 - } 340 - privptr->p_mtc_envelope= kzalloc( MAX_ENVELOPE_SIZE, GFP_KERNEL); 341 - privptr->p_env = kzalloc(sizeof(struct claw_env), GFP_KERNEL); 342 - if ((privptr->p_mtc_envelope==NULL) || (privptr->p_env==NULL)) { 343 - probe_error(cgdev); 344 - put_device(&cgdev->dev); 345 - CLAW_DBF_TEXT_(2, setup, "probex%d", -ENOMEM); 346 - return -ENOMEM; 347 - } 348 - memcpy(privptr->p_env->adapter_name,WS_NAME_NOT_DEF,8); 349 - memcpy(privptr->p_env->host_name,WS_NAME_NOT_DEF,8); 350 - memcpy(privptr->p_env->api_type,WS_NAME_NOT_DEF,8); 351 - privptr->p_env->packing = 0; 352 - privptr->p_env->write_buffers = 5; 353 - privptr->p_env->read_buffers = 5; 354 - privptr->p_env->read_size = CLAW_FRAME_SIZE; 355 - privptr->p_env->write_size = CLAW_FRAME_SIZE; 356 - rc = claw_add_files(&cgdev->dev); 357 - if (rc) { 358 - probe_error(cgdev); 359 - put_device(&cgdev->dev); 360 - dev_err(&cgdev->dev, "Creating the /proc files for a new" 361 - " CLAW device failed\n"); 362 - CLAW_DBF_TEXT_(2, setup, "probex%d", rc); 363 - return rc; 364 - } 365 - privptr->p_env->p_priv = privptr; 366 - cgdev->cdev[0]->handler = claw_irq_handler; 367 - cgdev->cdev[1]->handler = claw_irq_handler; 368 - CLAW_DBF_TEXT(2, setup, "prbext 0"); 369 - 370 - return 0; 371 - } /* end of claw_probe */ 372 323 373 324 /*-------------------------------------------------------------------* 374 325 * claw_tx * ··· 3031 3090 dev_info(&cgdev->dev, " will be removed.\n"); 3032 3091 if (cgdev->state == CCWGROUP_ONLINE) 3033 3092 claw_shutdown_device(cgdev); 3034 - claw_remove_files(&cgdev->dev); 3035 3093 kfree(priv->p_mtc_envelope); 3036 3094 priv->p_mtc_envelope=NULL; 3037 3095 kfree(priv->p_env); ··· 3258 3318 CLAW_DBF_TEXT_(2, setup, "RB=%d", p_env->read_buffers); 3259 3319 return count; 3260 3320 } 3261 - 3262 3321 static DEVICE_ATTR(read_buffer, 0644, claw_rbuff_show, claw_rbuff_write); 3263 3322 3264 3323 static struct attribute *claw_attr[] = { ··· 3268 3329 &dev_attr_host_name.attr, 3269 3330 NULL, 3270 3331 }; 3271 - 3272 3332 static struct attribute_group claw_attr_group = { 3273 3333 .attrs = claw_attr, 3274 3334 }; 3335 + static const struct attribute_group *claw_attr_groups[] = { 3336 + &claw_attr_group, 3337 + NULL, 3338 + }; 3339 + static const struct device_type claw_devtype = { 3340 + .name = "claw", 3341 + .groups = claw_attr_groups, 3342 + }; 3275 3343 3276 - static int 3277 - claw_add_files(struct device *dev) 3344 + /*----------------------------------------------------------------* 3345 + * claw_probe * 3346 + * this function is called for each CLAW device. * 3347 + *----------------------------------------------------------------*/ 3348 + static int claw_probe(struct ccwgroup_device *cgdev) 3278 3349 { 3279 - CLAW_DBF_TEXT(2, setup, "add_file"); 3280 - return sysfs_create_group(&dev->kobj, &claw_attr_group); 3281 - } 3350 + struct claw_privbk *privptr = NULL; 3282 3351 3283 - static void 3284 - claw_remove_files(struct device *dev) 3285 - { 3286 - CLAW_DBF_TEXT(2, setup, "rem_file"); 3287 - sysfs_remove_group(&dev->kobj, &claw_attr_group); 3288 - } 3352 + CLAW_DBF_TEXT(2, setup, "probe"); 3353 + if (!get_device(&cgdev->dev)) 3354 + return -ENODEV; 3355 + privptr = kzalloc(sizeof(struct claw_privbk), GFP_KERNEL); 3356 + dev_set_drvdata(&cgdev->dev, privptr); 3357 + if (privptr == NULL) { 3358 + probe_error(cgdev); 3359 + put_device(&cgdev->dev); 3360 + CLAW_DBF_TEXT_(2, setup, "probex%d", -ENOMEM); 3361 + return -ENOMEM; 3362 + } 3363 + privptr->p_mtc_envelope = kzalloc(MAX_ENVELOPE_SIZE, GFP_KERNEL); 3364 + privptr->p_env = kzalloc(sizeof(struct claw_env), GFP_KERNEL); 3365 + if ((privptr->p_mtc_envelope == NULL) || (privptr->p_env == NULL)) { 3366 + probe_error(cgdev); 3367 + put_device(&cgdev->dev); 3368 + CLAW_DBF_TEXT_(2, setup, "probex%d", -ENOMEM); 3369 + return -ENOMEM; 3370 + } 3371 + memcpy(privptr->p_env->adapter_name, WS_NAME_NOT_DEF, 8); 3372 + memcpy(privptr->p_env->host_name, WS_NAME_NOT_DEF, 8); 3373 + memcpy(privptr->p_env->api_type, WS_NAME_NOT_DEF, 8); 3374 + privptr->p_env->packing = 0; 3375 + privptr->p_env->write_buffers = 5; 3376 + privptr->p_env->read_buffers = 5; 3377 + privptr->p_env->read_size = CLAW_FRAME_SIZE; 3378 + privptr->p_env->write_size = CLAW_FRAME_SIZE; 3379 + privptr->p_env->p_priv = privptr; 3380 + cgdev->cdev[0]->handler = claw_irq_handler; 3381 + cgdev->cdev[1]->handler = claw_irq_handler; 3382 + cgdev->dev.type = &claw_devtype; 3383 + CLAW_DBF_TEXT(2, setup, "prbext 0"); 3384 + 3385 + return 0; 3386 + } /* end of claw_probe */ 3289 3387 3290 3388 /*--------------------------------------------------------------------* 3291 3389 * claw_init and cleanup *