s)
{
memset(cdev, 0, sizeof *cdev);
INIT_LIST_HEAD(&cdev->list);
kobject_init(&cdev->kobj, &ktype_cdev_default);
cdev->ops = fops;
}
static struct kobject *base_probe(dev_t dev, int *part, void *data)
{
if (request_module("char-major-%d-%d", MAJOR(dev), MINOR(dev)) > 0)
/* Make old-style 2.4 aliases work */
request_module("char-major-%d", MAJOR(dev));
return NULL;
}
void __init chrdev_init(void)
{
cdev_map = kobj_map_init(base_probe, &chrdevs_lock);
bdi_init(&directly_mappable_cdev_bdi);
}
/* Let modules do char dev stuff */
EXPORT_SYMBOL(register_chrdev_region);
EXPORT_SYMBOL(unregister_chrdev_region);
EXPORT_SYMBOL(alloc_chrdev_region);
EXPORT_SYMBOL(cdev_init);
EXPORT_SYMBOL(cdev_alloc);
EXPORT_SYMBOL(cdev_del);
EXPORT_SYMBOL(cdev_add);
EXPORT_SYMBOL(cdev_index);
EXPORT_SYMBOL(__register_chrdev);
EXPORT_SYMBOL(__unregister_chrdev);
EXPORT_SYMBOL(directly_mappable_cdev_bdi);
/drivers/base/base.h
/**
003 * struct bus_type_private - structure to hold the private to the driver core portions of the bus_type structure.
004 *
005 * @subsys - the struct kset that defines this bus. This is the main kobject
006 * @drivers_kset - the list of drivers associated with this bus
007 * @devices_kset - the list of devices associated with this bus
008 * @klist_devices - the klist to iterate over the @devices_kset
009 * @klist_drivers - the klist to iterate over the @drivers_kset
010 * @bus_notifier - the bus notifier list for anything that cares about things
011 * on this bus.
012 * @bus - pointer back to the struct bus_type that this structure is associated
013 * with.
014 *
015 * This structure is the one that is the actual kobject allowing struct
016 * bus_type to be statically allocated safely. Nothing outside of the driver
017 * core should ever touch these fields.
018 */
019 struct bus_type_private {
020 struct kset subsys;
021 struct kset *drivers_kset;
022 struct kset *devices_kset;
023 struct klist klist_devices;
024 struct klist klist_drivers;
025 struct blocking_notifier_head bus_notifier;
026 unsigned int drivers_autoprobe:1;
027 struct bus_type *bus;
028 };
029
030 struct driver_private {
031 struct kobject kobj;
032 struct klist klist_devices;
033 struct klist_node knode_bus;
034 struct module_kobject *mkobj;
035 struct device_driver *driver;
036 };
037 #define to_driver(obj) container_of(obj, struct driver_private, kobj)
038
039
040 /**
041 * struct class_private - structure to hold the private to the driver core portions of the class structure.
042 *
043 * @class_subsys - the struct kset that defines this class. This is the main kobject
044 * @class_devices - list of devices associated with this class
045 * @class_interfaces - list of class_interfaces associated with this class
046 * @class_dirs - "glue" directory for virtual devices associated with this class
047 * @class_mutex - mutex to protect the children, devices, and interfaces lists.
048 * @class - pointer back to the struct class that this structure is associated
049 * with.
050 *
051 * This structure is the one that is the actual kobject allowing struct
052 * class to be statically allocated safely. Nothing outside of the driver
053 * core should ever touch these fields.
054 */
055 struct class_private {
056 struct kset class_subsys;
057 struct klist class_devices;
058 str