Lines Matching defs:cdev

21 #include <linux/cdev.h>
40 struct cdev *cdev; /* will die */
248 * __register_chrdev() - create and register a cdev occupying a range of minors
273 struct cdev *cdev;
280 cdev = cdev_alloc();
281 if (!cdev)
284 cdev->owner = fops->owner;
285 cdev->ops = fops;
286 kobject_set_name(&cdev->kobj, "%s", name);
288 err = cdev_add(cdev, MKDEV(cd->major, baseminor), count);
292 cd->cdev = cdev;
296 kobject_put(&cdev->kobj);
325 * __unregister_chrdev - unregister and destroy a cdev
328 * @count: the number of minor numbers this cdev is occupying
331 * Unregister and destroy the cdev occupying the region described by
341 if (cd && cd->cdev)
342 cdev_del(cd->cdev);
348 static struct kobject *cdev_get(struct cdev *p)
361 void cdev_put(struct cdev *p)
376 struct cdev *p;
377 struct cdev *new = NULL;
389 new = container_of(kobj, struct cdev, kobj);
435 static void cdev_purge(struct cdev *cdev)
438 while (!list_empty(&cdev->list)) {
440 inode = container_of(cdev->list.next, struct inode, i_devices);
459 struct cdev *p = data;
465 struct cdev *p = data;
471 * @p: the cdev structure for the device
479 int cdev_add(struct cdev *p, dev_t dev, unsigned count)
508 * @p: the cdev structure
512 * appropriately so the parent is not freed before the cdev. This
515 void cdev_set_parent(struct cdev *p, struct kobject *kobj)
525 * @cdev: the cdev structure
527 * cdev_device_add() adds the char device represented by @cdev to the system,
532 * all references to the cdev are released.
535 * it will not add the cdev and it will be equivalent to device_add.
537 * This function should be used whenever the struct cdev and the
541 * NOTE: Callers must assume that userspace was able to open the cdev and
542 * can call cdev fops callbacks at any time, even if this function fails.
544 int cdev_device_add(struct cdev *cdev, struct device *dev)
549 cdev_set_parent(cdev, &dev->kobj);
551 rc = cdev_add(cdev, dev->devt, 1);
558 cdev_del(cdev);
566 * @cdev: the cdev structure
571 * If dev->devt is not set it will not remove the cdev and will be equivalent
578 void cdev_device_del(struct cdev *cdev, struct device *dev)
582 cdev_del(cdev);
591 * cdev_del() - remove a cdev from the system
592 * @p: the cdev structure to be removed
597 * NOTE: This guarantees that cdev device will no longer be able to be
601 void cdev_del(struct cdev *p)
610 struct cdev *p = container_of(kobj, struct cdev, kobj);
619 struct cdev *p = container_of(kobj, struct cdev, kobj);
636 * cdev_alloc() - allocate a cdev structure
638 * Allocates and returns a cdev structure, or NULL on failure.
640 struct cdev *cdev_alloc(void)
642 struct cdev *p = kzalloc(sizeof(struct cdev), GFP_KERNEL);
651 * cdev_init() - initialize a cdev structure
652 * @cdev: the structure to initialize
655 * Initializes @cdev, remembering @fops, making it ready to add to the
658 void cdev_init(struct cdev *cdev, const struct file_operations *fops)
660 memset(cdev, 0, sizeof *cdev);
661 INIT_LIST_HEAD(&cdev->list);
662 kobject_init(&cdev->kobj, &ktype_cdev_default);
663 cdev->ops = fops;