diff options
Diffstat (limited to 'include/linux/device.h')
| -rw-r--r-- | include/linux/device.h | 135 |
1 files changed, 81 insertions, 54 deletions
diff --git a/include/linux/device.h b/include/linux/device.h index 055a69dbcd18..8f882549edee 100644 --- a/include/linux/device.h +++ b/include/linux/device.h | |||
| @@ -90,7 +90,7 @@ extern void bus_remove_file(struct bus_type *, struct bus_attribute *); | |||
| 90 | * @num_vf: Called to find out how many virtual functions a device on this | 90 | * @num_vf: Called to find out how many virtual functions a device on this |
| 91 | * bus supports. | 91 | * bus supports. |
| 92 | * @dma_configure: Called to setup DMA configuration on a device on | 92 | * @dma_configure: Called to setup DMA configuration on a device on |
| 93 | this bus. | 93 | * this bus. |
| 94 | * @pm: Power management operations of this bus, callback the specific | 94 | * @pm: Power management operations of this bus, callback the specific |
| 95 | * device driver's pm-ops. | 95 | * device driver's pm-ops. |
| 96 | * @iommu_ops: IOMMU specific operations for this bus, used to attach IOMMU | 96 | * @iommu_ops: IOMMU specific operations for this bus, used to attach IOMMU |
| @@ -339,6 +339,8 @@ struct device *driver_find_device(struct device_driver *drv, | |||
| 339 | struct device *start, void *data, | 339 | struct device *start, void *data, |
| 340 | int (*match)(struct device *dev, void *data)); | 340 | int (*match)(struct device *dev, void *data)); |
| 341 | 341 | ||
| 342 | int driver_deferred_probe_check_state(struct device *dev); | ||
| 343 | |||
| 342 | /** | 344 | /** |
| 343 | * struct subsys_interface - interfaces to device functions | 345 | * struct subsys_interface - interfaces to device functions |
| 344 | * @name: name of the device function | 346 | * @name: name of the device function |
| @@ -384,6 +386,9 @@ int subsys_virtual_register(struct bus_type *subsys, | |||
| 384 | * @shutdown_pre: Called at shut-down time before driver shutdown. | 386 | * @shutdown_pre: Called at shut-down time before driver shutdown. |
| 385 | * @ns_type: Callbacks so sysfs can detemine namespaces. | 387 | * @ns_type: Callbacks so sysfs can detemine namespaces. |
| 386 | * @namespace: Namespace of the device belongs to this class. | 388 | * @namespace: Namespace of the device belongs to this class. |
| 389 | * @get_ownership: Allows class to specify uid/gid of the sysfs directories | ||
| 390 | * for the devices belonging to the class. Usually tied to | ||
| 391 | * device's namespace. | ||
| 387 | * @pm: The default device power management operations of this class. | 392 | * @pm: The default device power management operations of this class. |
| 388 | * @p: The private data of the driver core, no one other than the | 393 | * @p: The private data of the driver core, no one other than the |
| 389 | * driver core can touch this. | 394 | * driver core can touch this. |
| @@ -413,6 +418,8 @@ struct class { | |||
| 413 | const struct kobj_ns_type_operations *ns_type; | 418 | const struct kobj_ns_type_operations *ns_type; |
| 414 | const void *(*namespace)(struct device *dev); | 419 | const void *(*namespace)(struct device *dev); |
| 415 | 420 | ||
| 421 | void (*get_ownership)(struct device *dev, kuid_t *uid, kgid_t *gid); | ||
| 422 | |||
| 416 | const struct dev_pm_ops *pm; | 423 | const struct dev_pm_ops *pm; |
| 417 | 424 | ||
| 418 | struct subsys_private *p; | 425 | struct subsys_private *p; |
| @@ -696,6 +703,10 @@ extern void devm_free_pages(struct device *dev, unsigned long addr); | |||
| 696 | 703 | ||
| 697 | void __iomem *devm_ioremap_resource(struct device *dev, struct resource *res); | 704 | void __iomem *devm_ioremap_resource(struct device *dev, struct resource *res); |
| 698 | 705 | ||
| 706 | void __iomem *devm_of_iomap(struct device *dev, | ||
| 707 | struct device_node *node, int index, | ||
| 708 | resource_size_t *size); | ||
| 709 | |||
| 699 | /* allows to add/remove a custom action to devres stack */ | 710 | /* allows to add/remove a custom action to devres stack */ |
| 700 | int devm_add_action(struct device *dev, void (*action)(void *), void *data); | 711 | int devm_add_action(struct device *dev, void (*action)(void *), void *data); |
| 701 | void devm_remove_action(struct device *dev, void (*action)(void *), void *data); | 712 | void devm_remove_action(struct device *dev, void (*action)(void *), void *data); |
| @@ -784,14 +795,16 @@ enum device_link_state { | |||
| 784 | * Device link flags. | 795 | * Device link flags. |
| 785 | * | 796 | * |
| 786 | * STATELESS: The core won't track the presence of supplier/consumer drivers. | 797 | * STATELESS: The core won't track the presence of supplier/consumer drivers. |
| 787 | * AUTOREMOVE: Remove this link automatically on consumer driver unbind. | 798 | * AUTOREMOVE_CONSUMER: Remove the link automatically on consumer driver unbind. |
| 788 | * PM_RUNTIME: If set, the runtime PM framework will use this link. | 799 | * PM_RUNTIME: If set, the runtime PM framework will use this link. |
| 789 | * RPM_ACTIVE: Run pm_runtime_get_sync() on the supplier during link creation. | 800 | * RPM_ACTIVE: Run pm_runtime_get_sync() on the supplier during link creation. |
| 801 | * AUTOREMOVE_SUPPLIER: Remove the link automatically on supplier driver unbind. | ||
| 790 | */ | 802 | */ |
| 791 | #define DL_FLAG_STATELESS BIT(0) | 803 | #define DL_FLAG_STATELESS BIT(0) |
| 792 | #define DL_FLAG_AUTOREMOVE BIT(1) | 804 | #define DL_FLAG_AUTOREMOVE_CONSUMER BIT(1) |
| 793 | #define DL_FLAG_PM_RUNTIME BIT(2) | 805 | #define DL_FLAG_PM_RUNTIME BIT(2) |
| 794 | #define DL_FLAG_RPM_ACTIVE BIT(3) | 806 | #define DL_FLAG_RPM_ACTIVE BIT(3) |
| 807 | #define DL_FLAG_AUTOREMOVE_SUPPLIER BIT(4) | ||
| 795 | 808 | ||
| 796 | /** | 809 | /** |
| 797 | * struct device_link - Device link representation. | 810 | * struct device_link - Device link representation. |
| @@ -886,6 +899,8 @@ struct dev_links_info { | |||
| 886 | * @coherent_dma_mask: Like dma_mask, but for alloc_coherent mapping as not all | 899 | * @coherent_dma_mask: Like dma_mask, but for alloc_coherent mapping as not all |
| 887 | * hardware supports 64-bit addresses for consistent allocations | 900 | * hardware supports 64-bit addresses for consistent allocations |
| 888 | * such descriptors. | 901 | * such descriptors. |
| 902 | * @bus_dma_mask: Mask of an upstream bridge or bus which imposes a smaller DMA | ||
| 903 | * limit than the device itself supports. | ||
| 889 | * @dma_pfn_offset: offset of DMA memory range relatively of RAM | 904 | * @dma_pfn_offset: offset of DMA memory range relatively of RAM |
| 890 | * @dma_parms: A low level driver may set these to teach IOMMU code about | 905 | * @dma_parms: A low level driver may set these to teach IOMMU code about |
| 891 | * segment limitations. | 906 | * segment limitations. |
| @@ -912,8 +927,6 @@ struct dev_links_info { | |||
| 912 | * @offline: Set after successful invocation of bus type's .offline(). | 927 | * @offline: Set after successful invocation of bus type's .offline(). |
| 913 | * @of_node_reused: Set if the device-tree node is shared with an ancestor | 928 | * @of_node_reused: Set if the device-tree node is shared with an ancestor |
| 914 | * device. | 929 | * device. |
| 915 | * @dma_32bit_limit: bridge limited to 32bit DMA even if the device itself | ||
| 916 | * indicates support for a higher limit in the dma_mask field. | ||
| 917 | * | 930 | * |
| 918 | * At the lowest level, every device in a Linux system is represented by an | 931 | * At the lowest level, every device in a Linux system is represented by an |
| 919 | * instance of struct device. The device structure contains the information | 932 | * instance of struct device. The device structure contains the information |
| @@ -967,6 +980,7 @@ struct device { | |||
| 967 | not all hardware supports | 980 | not all hardware supports |
| 968 | 64 bit addresses for consistent | 981 | 64 bit addresses for consistent |
| 969 | allocations such descriptors. */ | 982 | allocations such descriptors. */ |
| 983 | u64 bus_dma_mask; /* upstream dma_mask constraint */ | ||
| 970 | unsigned long dma_pfn_offset; | 984 | unsigned long dma_pfn_offset; |
| 971 | 985 | ||
| 972 | struct device_dma_parameters *dma_parms; | 986 | struct device_dma_parameters *dma_parms; |
| @@ -1002,7 +1016,6 @@ struct device { | |||
| 1002 | bool offline_disabled:1; | 1016 | bool offline_disabled:1; |
| 1003 | bool offline:1; | 1017 | bool offline:1; |
| 1004 | bool of_node_reused:1; | 1018 | bool of_node_reused:1; |
| 1005 | bool dma_32bit_limit:1; | ||
| 1006 | }; | 1019 | }; |
| 1007 | 1020 | ||
| 1008 | static inline struct device *kobj_to_dev(struct kobject *kobj) | 1021 | static inline struct device *kobj_to_dev(struct kobject *kobj) |
| @@ -1316,31 +1329,36 @@ extern const char *dev_driver_string(const struct device *dev); | |||
| 1316 | struct device_link *device_link_add(struct device *consumer, | 1329 | struct device_link *device_link_add(struct device *consumer, |
| 1317 | struct device *supplier, u32 flags); | 1330 | struct device *supplier, u32 flags); |
| 1318 | void device_link_del(struct device_link *link); | 1331 | void device_link_del(struct device_link *link); |
| 1332 | void device_link_remove(void *consumer, struct device *supplier); | ||
| 1333 | |||
| 1334 | #ifndef dev_fmt | ||
| 1335 | #define dev_fmt(fmt) fmt | ||
| 1336 | #endif | ||
| 1319 | 1337 | ||
| 1320 | #ifdef CONFIG_PRINTK | 1338 | #ifdef CONFIG_PRINTK |
| 1321 | 1339 | ||
| 1322 | extern __printf(3, 0) | 1340 | __printf(3, 0) |
| 1323 | int dev_vprintk_emit(int level, const struct device *dev, | 1341 | int dev_vprintk_emit(int level, const struct device *dev, |
| 1324 | const char *fmt, va_list args); | 1342 | const char *fmt, va_list args); |
| 1325 | extern __printf(3, 4) | 1343 | __printf(3, 4) |
| 1326 | int dev_printk_emit(int level, const struct device *dev, const char *fmt, ...); | 1344 | int dev_printk_emit(int level, const struct device *dev, const char *fmt, ...); |
| 1327 | 1345 | ||
| 1328 | extern __printf(3, 4) | 1346 | __printf(3, 4) |
| 1329 | void dev_printk(const char *level, const struct device *dev, | 1347 | void dev_printk(const char *level, const struct device *dev, |
| 1330 | const char *fmt, ...); | 1348 | const char *fmt, ...); |
| 1331 | extern __printf(2, 3) | 1349 | __printf(2, 3) |
| 1332 | void dev_emerg(const struct device *dev, const char *fmt, ...); | 1350 | void _dev_emerg(const struct device *dev, const char *fmt, ...); |
| 1333 | extern __printf(2, 3) | 1351 | __printf(2, 3) |
| 1334 | void dev_alert(const struct device *dev, const char *fmt, ...); | 1352 | void _dev_alert(const struct device *dev, const char *fmt, ...); |
| 1335 | extern __printf(2, 3) | 1353 | __printf(2, 3) |
| 1336 | void dev_crit(const struct device *dev, const char *fmt, ...); | 1354 | void _dev_crit(const struct device *dev, const char *fmt, ...); |
| 1337 | extern __printf(2, 3) | 1355 | __printf(2, 3) |
| 1338 | void dev_err(const struct device *dev, const char *fmt, ...); | 1356 | void _dev_err(const struct device *dev, const char *fmt, ...); |
| 1339 | extern __printf(2, 3) | 1357 | __printf(2, 3) |
| 1340 | void dev_warn(const struct device *dev, const char *fmt, ...); | 1358 | void _dev_warn(const struct device *dev, const char *fmt, ...); |
| 1341 | extern __printf(2, 3) | 1359 | __printf(2, 3) |
| 1342 | void dev_notice(const struct device *dev, const char *fmt, ...); | 1360 | void _dev_notice(const struct device *dev, const char *fmt, ...); |
| 1343 | extern __printf(2, 3) | 1361 | __printf(2, 3) |
| 1344 | void _dev_info(const struct device *dev, const char *fmt, ...); | 1362 | void _dev_info(const struct device *dev, const char *fmt, ...); |
| 1345 | 1363 | ||
| 1346 | #else | 1364 | #else |
| @@ -1358,26 +1376,26 @@ static inline void __dev_printk(const char *level, const struct device *dev, | |||
| 1358 | {} | 1376 | {} |
| 1359 | static inline __printf(3, 4) | 1377 | static inline __printf(3, 4) |
| 1360 | void dev_printk(const char *level, const struct device *dev, | 1378 | void dev_printk(const char *level, const struct device *dev, |
| 1361 | const char *fmt, ...) | 1379 | const char *fmt, ...) |
| 1362 | {} | 1380 | {} |
| 1363 | 1381 | ||
| 1364 | static inline __printf(2, 3) | 1382 | static inline __printf(2, 3) |
| 1365 | void dev_emerg(const struct device *dev, const char *fmt, ...) | 1383 | void _dev_emerg(const struct device *dev, const char *fmt, ...) |
| 1366 | {} | 1384 | {} |
| 1367 | static inline __printf(2, 3) | 1385 | static inline __printf(2, 3) |
| 1368 | void dev_crit(const struct device *dev, const char *fmt, ...) | 1386 | void _dev_crit(const struct device *dev, const char *fmt, ...) |
| 1369 | {} | 1387 | {} |
| 1370 | static inline __printf(2, 3) | 1388 | static inline __printf(2, 3) |
| 1371 | void dev_alert(const struct device *dev, const char *fmt, ...) | 1389 | void _dev_alert(const struct device *dev, const char *fmt, ...) |
| 1372 | {} | 1390 | {} |
| 1373 | static inline __printf(2, 3) | 1391 | static inline __printf(2, 3) |
| 1374 | void dev_err(const struct device *dev, const char *fmt, ...) | 1392 | void _dev_err(const struct device *dev, const char *fmt, ...) |
| 1375 | {} | 1393 | {} |
| 1376 | static inline __printf(2, 3) | 1394 | static inline __printf(2, 3) |
| 1377 | void dev_warn(const struct device *dev, const char *fmt, ...) | 1395 | void _dev_warn(const struct device *dev, const char *fmt, ...) |
| 1378 | {} | 1396 | {} |
| 1379 | static inline __printf(2, 3) | 1397 | static inline __printf(2, 3) |
| 1380 | void dev_notice(const struct device *dev, const char *fmt, ...) | 1398 | void _dev_notice(const struct device *dev, const char *fmt, ...) |
| 1381 | {} | 1399 | {} |
| 1382 | static inline __printf(2, 3) | 1400 | static inline __printf(2, 3) |
| 1383 | void _dev_info(const struct device *dev, const char *fmt, ...) | 1401 | void _dev_info(const struct device *dev, const char *fmt, ...) |
| @@ -1386,27 +1404,36 @@ void _dev_info(const struct device *dev, const char *fmt, ...) | |||
| 1386 | #endif | 1404 | #endif |
| 1387 | 1405 | ||
| 1388 | /* | 1406 | /* |
| 1389 | * Stupid hackaround for existing uses of non-printk uses dev_info | 1407 | * #defines for all the dev_<level> macros to prefix with whatever |
| 1390 | * | 1408 | * possible use of #define dev_fmt(fmt) ... |
| 1391 | * Note that the definition of dev_info below is actually _dev_info | ||
| 1392 | * and a macro is used to avoid redefining dev_info | ||
| 1393 | */ | 1409 | */ |
| 1394 | 1410 | ||
| 1395 | #define dev_info(dev, fmt, arg...) _dev_info(dev, fmt, ##arg) | 1411 | #define dev_emerg(dev, fmt, ...) \ |
| 1412 | _dev_emerg(dev, dev_fmt(fmt), ##__VA_ARGS__) | ||
| 1413 | #define dev_crit(dev, fmt, ...) \ | ||
| 1414 | _dev_crit(dev, dev_fmt(fmt), ##__VA_ARGS__) | ||
| 1415 | #define dev_alert(dev, fmt, ...) \ | ||
| 1416 | _dev_alert(dev, dev_fmt(fmt), ##__VA_ARGS__) | ||
| 1417 | #define dev_err(dev, fmt, ...) \ | ||
| 1418 | _dev_err(dev, dev_fmt(fmt), ##__VA_ARGS__) | ||
| 1419 | #define dev_warn(dev, fmt, ...) \ | ||
| 1420 | _dev_warn(dev, dev_fmt(fmt), ##__VA_ARGS__) | ||
| 1421 | #define dev_notice(dev, fmt, ...) \ | ||
| 1422 | _dev_notice(dev, dev_fmt(fmt), ##__VA_ARGS__) | ||
| 1423 | #define dev_info(dev, fmt, ...) \ | ||
| 1424 | _dev_info(dev, dev_fmt(fmt), ##__VA_ARGS__) | ||
| 1396 | 1425 | ||
| 1397 | #if defined(CONFIG_DYNAMIC_DEBUG) | 1426 | #if defined(CONFIG_DYNAMIC_DEBUG) |
| 1398 | #define dev_dbg(dev, format, ...) \ | 1427 | #define dev_dbg(dev, fmt, ...) \ |
| 1399 | do { \ | 1428 | dynamic_dev_dbg(dev, dev_fmt(fmt), ##__VA_ARGS__) |
| 1400 | dynamic_dev_dbg(dev, format, ##__VA_ARGS__); \ | ||
| 1401 | } while (0) | ||
| 1402 | #elif defined(DEBUG) | 1429 | #elif defined(DEBUG) |
| 1403 | #define dev_dbg(dev, format, arg...) \ | 1430 | #define dev_dbg(dev, fmt, ...) \ |
| 1404 | dev_printk(KERN_DEBUG, dev, format, ##arg) | 1431 | dev_printk(KERN_DEBUG, dev, dev_fmt(fmt), ##__VA_ARGS__) |
| 1405 | #else | 1432 | #else |
| 1406 | #define dev_dbg(dev, format, arg...) \ | 1433 | #define dev_dbg(dev, fmt, ...) \ |
| 1407 | ({ \ | 1434 | ({ \ |
| 1408 | if (0) \ | 1435 | if (0) \ |
| 1409 | dev_printk(KERN_DEBUG, dev, format, ##arg); \ | 1436 | dev_printk(KERN_DEBUG, dev, dev_fmt(fmt), ##__VA_ARGS__); \ |
| 1410 | }) | 1437 | }) |
| 1411 | #endif | 1438 | #endif |
| 1412 | 1439 | ||
| @@ -1478,7 +1505,7 @@ do { \ | |||
| 1478 | DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt); \ | 1505 | DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt); \ |
| 1479 | if (unlikely(descriptor.flags & _DPRINTK_FLAGS_PRINT) && \ | 1506 | if (unlikely(descriptor.flags & _DPRINTK_FLAGS_PRINT) && \ |
| 1480 | __ratelimit(&_rs)) \ | 1507 | __ratelimit(&_rs)) \ |
| 1481 | __dynamic_dev_dbg(&descriptor, dev, fmt, \ | 1508 | __dynamic_dev_dbg(&descriptor, dev, dev_fmt(fmt), \ |
| 1482 | ##__VA_ARGS__); \ | 1509 | ##__VA_ARGS__); \ |
| 1483 | } while (0) | 1510 | } while (0) |
| 1484 | #elif defined(DEBUG) | 1511 | #elif defined(DEBUG) |
| @@ -1488,23 +1515,23 @@ do { \ | |||
| 1488 | DEFAULT_RATELIMIT_INTERVAL, \ | 1515 | DEFAULT_RATELIMIT_INTERVAL, \ |
| 1489 | DEFAULT_RATELIMIT_BURST); \ | 1516 | DEFAULT_RATELIMIT_BURST); \ |
| 1490 | if (__ratelimit(&_rs)) \ | 1517 | if (__ratelimit(&_rs)) \ |
| 1491 | dev_printk(KERN_DEBUG, dev, fmt, ##__VA_ARGS__); \ | 1518 | dev_printk(KERN_DEBUG, dev, dev_fmt(fmt), ##__VA_ARGS__); \ |
| 1492 | } while (0) | 1519 | } while (0) |
| 1493 | #else | 1520 | #else |
| 1494 | #define dev_dbg_ratelimited(dev, fmt, ...) \ | 1521 | #define dev_dbg_ratelimited(dev, fmt, ...) \ |
| 1495 | do { \ | 1522 | do { \ |
| 1496 | if (0) \ | 1523 | if (0) \ |
| 1497 | dev_printk(KERN_DEBUG, dev, fmt, ##__VA_ARGS__); \ | 1524 | dev_printk(KERN_DEBUG, dev, dev_fmt(fmt), ##__VA_ARGS__); \ |
| 1498 | } while (0) | 1525 | } while (0) |
| 1499 | #endif | 1526 | #endif |
| 1500 | 1527 | ||
| 1501 | #ifdef VERBOSE_DEBUG | 1528 | #ifdef VERBOSE_DEBUG |
| 1502 | #define dev_vdbg dev_dbg | 1529 | #define dev_vdbg dev_dbg |
| 1503 | #else | 1530 | #else |
| 1504 | #define dev_vdbg(dev, format, arg...) \ | 1531 | #define dev_vdbg(dev, fmt, ...) \ |
| 1505 | ({ \ | 1532 | ({ \ |
| 1506 | if (0) \ | 1533 | if (0) \ |
| 1507 | dev_printk(KERN_DEBUG, dev, format, ##arg); \ | 1534 | dev_printk(KERN_DEBUG, dev, dev_fmt(fmt), ##__VA_ARGS__); \ |
| 1508 | }) | 1535 | }) |
| 1509 | #endif | 1536 | #endif |
| 1510 | 1537 | ||
