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)
501 * @p: the cdev structure
505 * appropriately so the parent is not freed before the cdev. This
508 void cdev_set_parent(struct cdev *p, struct kobject *kobj)
518 * @cdev: the cdev structure
520 * cdev_device_add() adds the char device represented by @cdev to the system,
525 * all references to the cdev are released.
528 * it will not add the cdev and it will be equivalent to device_add.
530 * This function should be used whenever the struct cdev and the
534 * NOTE: Callers must assume that userspace was able to open the cdev and
535 * can call cdev fops callbacks at any time, even if this function fails.
537 int cdev_device_add(struct cdev *cdev, struct device *dev)
542 cdev_set_parent(cdev, &dev->kobj);
544 rc = cdev_add(cdev, dev->devt, 1);
551 cdev_del(cdev);
559 * @cdev: the cdev structure
564 * If dev->devt is not set it will not remove the cdev and will be equivalent
571 void cdev_device_del(struct cdev *cdev, struct device *dev)
575 cdev_del(cdev);
584 * cdev_del() - remove a cdev from the system
585 * @p: the cdev structure to be removed
590 * NOTE: This guarantees that cdev device will no longer be able to be
594 void cdev_del(struct cdev *p)
603 struct cdev *p = container_of(kobj, struct cdev, kobj);
612 struct cdev *p = container_of(kobj, struct cdev, kobj);
629 * cdev_alloc() - allocate a cdev structure
631 * Allocates and returns a cdev structure, or NULL on failure.
633 struct cdev *cdev_alloc(void)
635 struct cdev *p = kzalloc(sizeof(struct cdev), GFP_KERNEL);
644 * cdev_init() - initialize a cdev structure
645 * @cdev: the structure to initialize
648 * Initializes @cdev, remembering @fops, making it ready to add to the
651 void cdev_init(struct cdev *cdev, const struct file_operations *fops)
653 memset(cdev, 0, sizeof *cdev);
654 INIT_LIST_HEAD(&cdev->list);
655 kobject_init(&cdev->kobj, &ktype_cdev_default);
656 cdev->ops = fops;