diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/base/class.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/drivers/base/class.c b/drivers/base/class.c index a3b006b6f2ba..479c12570881 100644 --- a/drivers/base/class.c +++ b/drivers/base/class.c | |||
@@ -173,6 +173,17 @@ static void class_device_create_release(struct class_device *class_dev) | |||
173 | kfree(class_dev); | 173 | kfree(class_dev); |
174 | } | 174 | } |
175 | 175 | ||
176 | /** | ||
177 | * class_create - create a struct class structure | ||
178 | * @owner: pointer to the module that is to "own" this struct class | ||
179 | * @name: pointer to a string for the name of this class. | ||
180 | * | ||
181 | * This is used to create a struct class pointer that can then be used | ||
182 | * in calls to class_device_create(). | ||
183 | * | ||
184 | * Note, the pointer created here is to be destroyed when finished by | ||
185 | * making a call to class_destroy(). | ||
186 | */ | ||
176 | struct class *class_create(struct module *owner, char *name) | 187 | struct class *class_create(struct module *owner, char *name) |
177 | { | 188 | { |
178 | struct class *cls; | 189 | struct class *cls; |
@@ -201,6 +212,13 @@ error: | |||
201 | return ERR_PTR(retval); | 212 | return ERR_PTR(retval); |
202 | } | 213 | } |
203 | 214 | ||
215 | /** | ||
216 | * class_destroy - destroys a struct class structure | ||
217 | * @cs: pointer to the struct class that is to be destroyed | ||
218 | * | ||
219 | * Note, the pointer to be destroyed must have been created with a call | ||
220 | * to class_create(). | ||
221 | */ | ||
204 | void class_destroy(struct class *cls) | 222 | void class_destroy(struct class *cls) |
205 | { | 223 | { |
206 | if ((cls == NULL) || (IS_ERR(cls))) | 224 | if ((cls == NULL) || (IS_ERR(cls))) |
@@ -505,6 +523,23 @@ int class_device_register(struct class_device *class_dev) | |||
505 | return class_device_add(class_dev); | 523 | return class_device_add(class_dev); |
506 | } | 524 | } |
507 | 525 | ||
526 | /** | ||
527 | * class_device_create - creates a class device and registers it with sysfs | ||
528 | * @cs: pointer to the struct class that this device should be registered to. | ||
529 | * @dev: the dev_t for the char device to be added. | ||
530 | * @device: a pointer to a struct device that is assiociated with this class device. | ||
531 | * @fmt: string for the class device's name | ||
532 | * | ||
533 | * This function can be used by char device classes. A struct | ||
534 | * class_device will be created in sysfs, registered to the specified | ||
535 | * class. A "dev" file will be created, showing the dev_t for the | ||
536 | * device. The pointer to the struct class_device will be returned from | ||
537 | * the call. Any further sysfs files that might be required can be | ||
538 | * created using this pointer. | ||
539 | * | ||
540 | * Note: the struct class passed to this function must have previously | ||
541 | * been created with a call to class_create(). | ||
542 | */ | ||
508 | struct class_device *class_device_create(struct class *cls, dev_t devt, | 543 | struct class_device *class_device_create(struct class *cls, dev_t devt, |
509 | struct device *device, char *fmt, ...) | 544 | struct device *device, char *fmt, ...) |
510 | { | 545 | { |
@@ -578,6 +613,14 @@ void class_device_unregister(struct class_device *class_dev) | |||
578 | class_device_put(class_dev); | 613 | class_device_put(class_dev); |
579 | } | 614 | } |
580 | 615 | ||
616 | /** | ||
617 | * class_device_destroy - removes a class device that was created with class_device_create() | ||
618 | * @cls: the pointer to the struct class that this device was registered * with. | ||
619 | * @dev: the dev_t of the device that was previously registered. | ||
620 | * | ||
621 | * This call unregisters and cleans up a class device that was created with a | ||
622 | * call to class_device_create() | ||
623 | */ | ||
581 | void class_device_destroy(struct class *cls, dev_t devt) | 624 | void class_device_destroy(struct class *cls, dev_t devt) |
582 | { | 625 | { |
583 | struct class_device *class_dev = NULL; | 626 | struct class_device *class_dev = NULL; |