~ubuntu-branches/ubuntu/quantal/linux-linaro-mx51/quantal

« back to all changes in this revision

Viewing changes to include/linux/device.h

  • Committer: Package Import Robot
  • Author(s): John Rigby, John Rigby
  • Date: 2011-09-26 10:44:23 UTC
  • Revision ID: package-import@ubuntu.com-20110926104423-3o58a3c1bj7x00rs
Tags: 3.0.0-1007.9
[ John Rigby ]

Enable crypto modules and remove crypto-modules from
exclude-module files
LP: #826021

Show diffs side-by-side

added added

removed removed

Lines of Context:
47
47
                                        struct bus_attribute *);
48
48
extern void bus_remove_file(struct bus_type *, struct bus_attribute *);
49
49
 
 
50
/**
 
51
 * struct bus_type - The bus type of the device
 
52
 *
 
53
 * @name:       The name of the bus.
 
54
 * @bus_attrs:  Default attributes of the bus.
 
55
 * @dev_attrs:  Default attributes of the devices on the bus.
 
56
 * @drv_attrs:  Default attributes of the device drivers on the bus.
 
57
 * @match:      Called, perhaps multiple times, whenever a new device or driver
 
58
 *              is added for this bus. It should return a nonzero value if the
 
59
 *              given device can be handled by the given driver.
 
60
 * @uevent:     Called when a device is added, removed, or a few other things
 
61
 *              that generate uevents to add the environment variables.
 
62
 * @probe:      Called when a new device or driver add to this bus, and callback
 
63
 *              the specific driver's probe to initial the matched device.
 
64
 * @remove:     Called when a device removed from this bus.
 
65
 * @shutdown:   Called at shut-down time to quiesce the device.
 
66
 * @suspend:    Called when a device on this bus wants to go to sleep mode.
 
67
 * @resume:     Called to bring a device on this bus out of sleep mode.
 
68
 * @pm:         Power management operations of this bus, callback the specific
 
69
 *              device driver's pm-ops.
 
70
 * @p:          The private data of the driver core, only the driver core can
 
71
 *              touch this.
 
72
 *
 
73
 * A bus is a channel between the processor and one or more devices. For the
 
74
 * purposes of the device model, all devices are connected via a bus, even if
 
75
 * it is an internal, virtual, "platform" bus. Buses can plug into each other.
 
76
 * A USB controller is usually a PCI device, for example. The device model
 
77
 * represents the actual connections between buses and the devices they control.
 
78
 * A bus is represented by the bus_type structure. It contains the name, the
 
79
 * default attributes, the bus' methods, PM operations, and the driver core's
 
80
 * private data.
 
81
 */
50
82
struct bus_type {
51
83
        const char              *name;
52
84
        struct bus_attribute    *bus_attrs;
119
151
extern struct kset *bus_get_kset(struct bus_type *bus);
120
152
extern struct klist *bus_get_device_klist(struct bus_type *bus);
121
153
 
 
154
/**
 
155
 * struct device_driver - The basic device driver structure
 
156
 * @name:       Name of the device driver.
 
157
 * @bus:        The bus which the device of this driver belongs to.
 
158
 * @owner:      The module owner.
 
159
 * @mod_name:   Used for built-in modules.
 
160
 * @suppress_bind_attrs: Disables bind/unbind via sysfs.
 
161
 * @of_match_table: The open firmware table.
 
162
 * @probe:      Called to query the existence of a specific device,
 
163
 *              whether this driver can work with it, and bind the driver
 
164
 *              to a specific device.
 
165
 * @remove:     Called when the device is removed from the system to
 
166
 *              unbind a device from this driver.
 
167
 * @shutdown:   Called at shut-down time to quiesce the device.
 
168
 * @suspend:    Called to put the device to sleep mode. Usually to a
 
169
 *              low power state.
 
170
 * @resume:     Called to bring a device from sleep mode.
 
171
 * @groups:     Default attributes that get created by the driver core
 
172
 *              automatically.
 
173
 * @pm:         Power management operations of the device which matched
 
174
 *              this driver.
 
175
 * @p:          Driver core's private data, no one other than the driver
 
176
 *              core can touch this.
 
177
 *
 
178
 * The device driver-model tracks all of the drivers known to the system.
 
179
 * The main reason for this tracking is to enable the driver core to match
 
180
 * up drivers with new devices. Once drivers are known objects within the
 
181
 * system, however, a number of other things become possible. Device drivers
 
182
 * can export information and configuration variables that are independent
 
183
 * of any specific device.
 
184
 */
122
185
struct device_driver {
123
186
        const char              *name;
124
187
        struct bus_type         *bus;
185
248
                                  struct device *start, void *data,
186
249
                                  int (*match)(struct device *dev, void *data));
187
250
 
188
 
/*
189
 
 * device classes
 
251
/**
 
252
 * struct class - device classes
 
253
 * @name:       Name of the class.
 
254
 * @owner:      The module owner.
 
255
 * @class_attrs: Default attributes of this class.
 
256
 * @dev_attrs:  Default attributes of the devices belong to the class.
 
257
 * @dev_bin_attrs: Default binary attributes of the devices belong to the class.
 
258
 * @dev_kobj:   The kobject that represents this class and links it into the hierarchy.
 
259
 * @dev_uevent: Called when a device is added, removed from this class, or a
 
260
 *              few other things that generate uevents to add the environment
 
261
 *              variables.
 
262
 * @devnode:    Callback to provide the devtmpfs.
 
263
 * @class_release: Called to release this class.
 
264
 * @dev_release: Called to release the device.
 
265
 * @suspend:    Used to put the device to sleep mode, usually to a low power
 
266
 *              state.
 
267
 * @resume:     Used to bring the device from the sleep mode.
 
268
 * @ns_type:    Callbacks so sysfs can detemine namespaces.
 
269
 * @namespace:  Namespace of the device belongs to this class.
 
270
 * @pm:         The default device power management operations of this class.
 
271
 * @p:          The private data of the driver core, no one other than the
 
272
 *              driver core can touch this.
 
273
 *
 
274
 * A class is a higher-level view of a device that abstracts out low-level
 
275
 * implementation details. Drivers may see a SCSI disk or an ATA disk, but,
 
276
 * at the class level, they are all simply disks. Classes allow user space
 
277
 * to work with devices based on what they do, rather than how they are
 
278
 * connected or how they work.
190
279
 */
191
280
struct class {
192
281
        const char              *name;
401
490
        unsigned long segment_boundary_mask;
402
491
};
403
492
 
 
493
/**
 
494
 * struct device - The basic device structure
 
495
 * @parent:     The device's "parent" device, the device to which it is attached.
 
496
 *              In most cases, a parent device is some sort of bus or host
 
497
 *              controller. If parent is NULL, the device, is a top-level device,
 
498
 *              which is not usually what you want.
 
499
 * @p:          Holds the private data of the driver core portions of the device.
 
500
 *              See the comment of the struct device_private for detail.
 
501
 * @kobj:       A top-level, abstract class from which other classes are derived.
 
502
 * @init_name:  Initial name of the device.
 
503
 * @type:       The type of device.
 
504
 *              This identifies the device type and carries type-specific
 
505
 *              information.
 
506
 * @mutex:      Mutex to synchronize calls to its driver.
 
507
 * @bus:        Type of bus device is on.
 
508
 * @driver:     Which driver has allocated this
 
509
 * @platform_data: Platform data specific to the device.
 
510
 *              Example: For devices on custom boards, as typical of embedded
 
511
 *              and SOC based hardware, Linux often uses platform_data to point
 
512
 *              to board-specific structures describing devices and how they
 
513
 *              are wired.  That can include what ports are available, chip
 
514
 *              variants, which GPIO pins act in what additional roles, and so
 
515
 *              on.  This shrinks the "Board Support Packages" (BSPs) and
 
516
 *              minimizes board-specific #ifdefs in drivers.
 
517
 * @power:      For device power management.
 
518
 *              See Documentation/power/devices.txt for details.
 
519
 * @pwr_domain: Provide callbacks that are executed during system suspend,
 
520
 *              hibernation, system resume and during runtime PM transitions
 
521
 *              along with subsystem-level and driver-level callbacks.
 
522
 * @numa_node:  NUMA node this device is close to.
 
523
 * @dma_mask:   Dma mask (if dma'ble device).
 
524
 * @coherent_dma_mask: Like dma_mask, but for alloc_coherent mapping as not all
 
525
 *              hardware supports 64-bit addresses for consistent allocations
 
526
 *              such descriptors.
 
527
 * @dma_parms:  A low level driver may set these to teach IOMMU code about
 
528
 *              segment limitations.
 
529
 * @dma_pools:  Dma pools (if dma'ble device).
 
530
 * @dma_mem:    Internal for coherent mem override.
 
531
 * @archdata:   For arch-specific additions.
 
532
 * @of_node:    Associated device tree node.
 
533
 * @devt:       For creating the sysfs "dev".
 
534
 * @devres_lock: Spinlock to protect the resource of the device.
 
535
 * @devres_head: The resources list of the device.
 
536
 * @knode_class: The node used to add the device to the class list.
 
537
 * @class:      The class of the device.
 
538
 * @groups:     Optional attribute groups.
 
539
 * @release:    Callback to free the device after all references have
 
540
 *              gone away. This should be set by the allocator of the
 
541
 *              device (i.e. the bus driver that discovered the device).
 
542
 *
 
543
 * At the lowest level, every device in a Linux system is represented by an
 
544
 * instance of struct device. The device structure contains the information
 
545
 * that the device model core needs to model the system. Most subsystems,
 
546
 * however, track additional information about the devices they host. As a
 
547
 * result, it is rare for devices to be represented by bare device structures;
 
548
 * instead, that structure, like kobject structures, is usually embedded within
 
549
 * a higher-level representation of the device.
 
550
 */
404
551
struct device {
405
552
        struct device           *parent;
406
553
 
408
555
 
409
556
        struct kobject kobj;
410
557
        const char              *init_name; /* initial name of the device */
411
 
        struct device_type      *type;
 
558
        const struct device_type *type;
412
559
 
413
560
        struct mutex            mutex;  /* mutex to synchronize calls to
414
561
                                         * its driver.
506
653
 
507
654
static inline void device_enable_async_suspend(struct device *dev)
508
655
{
509
 
        if (!dev->power.in_suspend)
 
656
        if (!dev->power.is_prepared)
510
657
                dev->power.async_suspend = true;
511
658
}
512
659
 
513
660
static inline void device_disable_async_suspend(struct device *dev)
514
661
{
515
 
        if (!dev->power.in_suspend)
 
662
        if (!dev->power.is_prepared)
516
663
                dev->power.async_suspend = false;
517
664
}
518
665
 
556
703
extern const char *device_get_devnode(struct device *dev,
557
704
                                      mode_t *mode, const char **tmp);
558
705
extern void *dev_get_drvdata(const struct device *dev);
559
 
extern void dev_set_drvdata(struct device *dev, void *data);
 
706
extern int dev_set_drvdata(struct device *dev, void *data);
560
707
 
561
708
/*
562
709
 * Root device objects for grouping under /sys/devices
610
757
extern int (*platform_notify_remove)(struct device *dev);
611
758
 
612
759
 
613
 
/**
 
760
/*
614
761
 * get_device - atomically increment the reference count for the device.
615
762
 *
616
763
 */
734
881
#endif
735
882
 
736
883
/*
737
 
 * dev_WARN() acts like dev_printk(), but with the key difference
 
884
 * dev_WARN*() acts like dev_printk(), but with the key difference
738
885
 * of using a WARN/WARN_ON to get the message out, including the
739
886
 * file/line information and a backtrace.
740
887
 */
741
888
#define dev_WARN(dev, format, arg...) \
742
889
        WARN(1, "Device: %s\n" format, dev_driver_string(dev), ## arg);
743
890
 
 
891
#define dev_WARN_ONCE(dev, condition, format, arg...) \
 
892
        WARN_ONCE(condition, "Device %s\n" format, \
 
893
                        dev_driver_string(dev), ## arg)
 
894
 
744
895
/* Create alias, so I can be autoloaded. */
745
896
#define MODULE_ALIAS_CHARDEV(major,minor) \
746
897
        MODULE_ALIAS("char-major-" __stringify(major) "-" __stringify(minor))