mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
driver core: Convert some drivers to CLASS_ATTR_STRING
Convert some drivers who export a single string as class attribute to the new class_attr_string functions. This removes redundant code all over. Signed-off-by: Andi Kleen <ak@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
parent
869dfc875e
commit
0933e2d98d
6 changed files with 27 additions and 57 deletions
|
@ -497,12 +497,7 @@ static struct pci_driver phantom_pci_driver = {
|
|||
.resume = phantom_resume
|
||||
};
|
||||
|
||||
static ssize_t phantom_show_version(struct class *cls, struct class_attribute *attr, char *buf)
|
||||
{
|
||||
return sprintf(buf, PHANTOM_VERSION "\n");
|
||||
}
|
||||
|
||||
static CLASS_ATTR(version, 0444, phantom_show_version, NULL);
|
||||
static CLASS_ATTR_STRING(version, 0444, PHANTOM_VERSION);
|
||||
|
||||
static int __init phantom_init(void)
|
||||
{
|
||||
|
@ -515,7 +510,7 @@ static int __init phantom_init(void)
|
|||
printk(KERN_ERR "phantom: can't register phantom class\n");
|
||||
goto err;
|
||||
}
|
||||
retval = class_create_file(phantom_class, &class_attr_version);
|
||||
retval = class_create_file(phantom_class, &class_attr_version.attr);
|
||||
if (retval) {
|
||||
printk(KERN_ERR "phantom: can't create sysfs version file\n");
|
||||
goto err_class;
|
||||
|
@ -541,7 +536,7 @@ static int __init phantom_init(void)
|
|||
err_unchr:
|
||||
unregister_chrdev_region(dev, PHANTOM_MAX_MINORS);
|
||||
err_attr:
|
||||
class_remove_file(phantom_class, &class_attr_version);
|
||||
class_remove_file(phantom_class, &class_attr_version.attr);
|
||||
err_class:
|
||||
class_destroy(phantom_class);
|
||||
err:
|
||||
|
@ -554,7 +549,7 @@ static void __exit phantom_exit(void)
|
|||
|
||||
unregister_chrdev_region(MKDEV(phantom_major, 0), PHANTOM_MAX_MINORS);
|
||||
|
||||
class_remove_file(phantom_class, &class_attr_version);
|
||||
class_remove_file(phantom_class, &class_attr_version.attr);
|
||||
class_destroy(phantom_class);
|
||||
|
||||
pr_debug("phantom: module successfully removed\n");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue