Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2)  *	TURBOchannel driver services.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *	Copyright (c) 2005  James Simmons
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  *	Copyright (c) 2006  Maciej W. Rozycki
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  *	Loosely based on drivers/dio/dio-driver.c and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  *	drivers/pci/pci-driver.c.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  *	This file is subject to the terms and conditions of the GNU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  *	General Public License.  See the file "COPYING" in the main
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12)  *	directory of this archive for more details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include <linux/tc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20)  * tc_register_driver - register a new TC driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21)  * @drv: the driver structure to register
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23)  * Adds the driver structure to the list of registered drivers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24)  * Returns a negative value on error, otherwise 0.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25)  * If no error occurred, the driver remains registered even if
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26)  * no device was claimed during registration.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) int tc_register_driver(struct tc_driver *tdrv)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 	return driver_register(&tdrv->driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) EXPORT_SYMBOL(tc_register_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35)  * tc_unregister_driver - unregister a TC driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36)  * @drv: the driver structure to unregister
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38)  * Deletes the driver structure from the list of registered TC drivers,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39)  * gives it a chance to clean up by calling its remove() function for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40)  * each device it was responsible for, and marks those devices as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41)  * driverless.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) void tc_unregister_driver(struct tc_driver *tdrv)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	driver_unregister(&tdrv->driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) EXPORT_SYMBOL(tc_unregister_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50)  * tc_match_device - tell if a TC device structure has a matching
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51)  *                   TC device ID structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52)  * @tdrv: the TC driver to earch for matching TC device ID strings
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53)  * @tdev: the TC device structure to match against
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55)  * Used by a driver to check whether a TC device present in the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56)  * system is in its list of supported devices.  Returns the matching
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57)  * tc_device_id structure or %NULL if there is no match.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) static const struct tc_device_id *tc_match_device(struct tc_driver *tdrv,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 						  struct tc_dev *tdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	const struct tc_device_id *id = tdrv->id_table;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	if (id) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 		while (id->name[0] || id->vendor[0]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 			if (strcmp(tdev->name, id->name) == 0 &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 			    strcmp(tdev->vendor, id->vendor) == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 				return id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 			id++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76)  * tc_bus_match - Tell if a device structure has a matching
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77)  *                TC device ID structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78)  * @dev: the device structure to match against
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79)  * @drv: the device driver to search for matching TC device ID strings
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81)  * Used by a driver to check whether a TC device present in the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82)  * system is in its list of supported devices.  Returns 1 if there
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83)  * is a match or 0 otherwise.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) static int tc_bus_match(struct device *dev, struct device_driver *drv)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	struct tc_dev *tdev = to_tc_dev(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	struct tc_driver *tdrv = to_tc_driver(drv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	const struct tc_device_id *id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	id = tc_match_device(tdrv, tdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	if (id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 		return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) struct bus_type tc_bus_type = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	.name	= "tc",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	.match	= tc_bus_match,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) EXPORT_SYMBOL(tc_bus_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) static int __init tc_driver_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	return bus_register(&tc_bus_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) postcore_initcall(tc_driver_init);