pktcdvd.c (cecdd52a3dd312564f81a39df08378b7b39a2654) | pktcdvd.c (75a2d4226b53710380d1017b3f4c88f937ddba78) |
---|---|
1/* 2 * Copyright (C) 2000 Jens Axboe <axboe@suse.de> 3 * Copyright (C) 2001-2004 Peter Osterlund <petero2@telia.com> 4 * Copyright (C) 2006 Thomas Maier <balagi@justmail.de> 5 * 6 * May be copied or modified under the terms of the GNU General Public 7 * License. See linux/COPYING for more information. 8 * --- 329 unchanged lines hidden (view full) --- 338 device_map show mappings 339 *******************************************************************/ 340 341static void class_pktcdvd_release(struct class *cls) 342{ 343 kfree(cls); 344} 345 | 1/* 2 * Copyright (C) 2000 Jens Axboe <axboe@suse.de> 3 * Copyright (C) 2001-2004 Peter Osterlund <petero2@telia.com> 4 * Copyright (C) 2006 Thomas Maier <balagi@justmail.de> 5 * 6 * May be copied or modified under the terms of the GNU General Public 7 * License. See linux/COPYING for more information. 8 * --- 329 unchanged lines hidden (view full) --- 338 device_map show mappings 339 *******************************************************************/ 340 341static void class_pktcdvd_release(struct class *cls) 342{ 343 kfree(cls); 344} 345 |
346static ssize_t device_map_show(struct class *c, struct class_attribute *attr, | 346static ssize_t device_map_show(const struct class *c, const struct class_attribute *attr, |
347 char *data) 348{ 349 int n = 0; 350 int idx; 351 mutex_lock_nested(&ctl_mutex, SINGLE_DEPTH_NESTING); 352 for (idx = 0; idx < MAX_WRITERS; idx++) { 353 struct pktcdvd_device *pd = pkt_devs[idx]; 354 if (!pd) --- 4 unchanged lines hidden (view full) --- 359 MAJOR(pd->bdev->bd_dev), 360 MINOR(pd->bdev->bd_dev)); 361 } 362 mutex_unlock(&ctl_mutex); 363 return n; 364} 365static CLASS_ATTR_RO(device_map); 366 | 347 char *data) 348{ 349 int n = 0; 350 int idx; 351 mutex_lock_nested(&ctl_mutex, SINGLE_DEPTH_NESTING); 352 for (idx = 0; idx < MAX_WRITERS; idx++) { 353 struct pktcdvd_device *pd = pkt_devs[idx]; 354 if (!pd) --- 4 unchanged lines hidden (view full) --- 359 MAJOR(pd->bdev->bd_dev), 360 MINOR(pd->bdev->bd_dev)); 361 } 362 mutex_unlock(&ctl_mutex); 363 return n; 364} 365static CLASS_ATTR_RO(device_map); 366 |
367static ssize_t add_store(struct class *c, struct class_attribute *attr, | 367static ssize_t add_store(const struct class *c, const struct class_attribute *attr, |
368 const char *buf, size_t count) 369{ 370 unsigned int major, minor; 371 372 if (sscanf(buf, "%u:%u", &major, &minor) == 2) { 373 /* pkt_setup_dev() expects caller to hold reference to self */ 374 if (!try_module_get(THIS_MODULE)) 375 return -ENODEV; --- 4 unchanged lines hidden (view full) --- 380 381 return count; 382 } 383 384 return -EINVAL; 385} 386static CLASS_ATTR_WO(add); 387 | 368 const char *buf, size_t count) 369{ 370 unsigned int major, minor; 371 372 if (sscanf(buf, "%u:%u", &major, &minor) == 2) { 373 /* pkt_setup_dev() expects caller to hold reference to self */ 374 if (!try_module_get(THIS_MODULE)) 375 return -ENODEV; --- 4 unchanged lines hidden (view full) --- 380 381 return count; 382 } 383 384 return -EINVAL; 385} 386static CLASS_ATTR_WO(add); 387 |
388static ssize_t remove_store(struct class *c, struct class_attribute *attr, | 388static ssize_t remove_store(const struct class *c, const struct class_attribute *attr, |
389 const char *buf, size_t count) 390{ 391 unsigned int major, minor; 392 if (sscanf(buf, "%u:%u", &major, &minor) == 2) { 393 pkt_remove_dev(MKDEV(major, minor)); 394 return count; 395 } 396 return -EINVAL; --- 15 unchanged lines hidden (view full) --- 412 /* 413 * create control files in sysfs 414 * /sys/class/pktcdvd/... 415 */ 416 class_pktcdvd = kzalloc(sizeof(*class_pktcdvd), GFP_KERNEL); 417 if (!class_pktcdvd) 418 return -ENOMEM; 419 class_pktcdvd->name = DRIVER_NAME; | 389 const char *buf, size_t count) 390{ 391 unsigned int major, minor; 392 if (sscanf(buf, "%u:%u", &major, &minor) == 2) { 393 pkt_remove_dev(MKDEV(major, minor)); 394 return count; 395 } 396 return -EINVAL; --- 15 unchanged lines hidden (view full) --- 412 /* 413 * create control files in sysfs 414 * /sys/class/pktcdvd/... 415 */ 416 class_pktcdvd = kzalloc(sizeof(*class_pktcdvd), GFP_KERNEL); 417 if (!class_pktcdvd) 418 return -ENOMEM; 419 class_pktcdvd->name = DRIVER_NAME; |
420 class_pktcdvd->owner = THIS_MODULE; | |
421 class_pktcdvd->class_release = class_pktcdvd_release; 422 class_pktcdvd->class_groups = class_pktcdvd_groups; 423 ret = class_register(class_pktcdvd); 424 if (ret) { 425 kfree(class_pktcdvd); 426 class_pktcdvd = NULL; 427 pr_err("failed to create class pktcdvd\n"); 428 return ret; --- 2518 unchanged lines hidden --- | 420 class_pktcdvd->class_release = class_pktcdvd_release; 421 class_pktcdvd->class_groups = class_pktcdvd_groups; 422 ret = class_register(class_pktcdvd); 423 if (ret) { 424 kfree(class_pktcdvd); 425 class_pktcdvd = NULL; 426 pr_err("failed to create class pktcdvd\n"); 427 return ret; --- 2518 unchanged lines hidden --- |