![]() |
|
|||
0001 /* 0002 * TURBOchannel driver services. 0003 * 0004 * Copyright (c) 2005 James Simmons 0005 * Copyright (c) 2006 Maciej W. Rozycki 0006 * 0007 * Loosely based on drivers/dio/dio-driver.c and 0008 * drivers/pci/pci-driver.c. 0009 * 0010 * This file is subject to the terms and conditions of the GNU 0011 * General Public License. See the file "COPYING" in the main 0012 * directory of this archive for more details. 0013 */ 0014 0015 #include <linux/init.h> 0016 #include <linux/module.h> 0017 #include <linux/tc.h> 0018 0019 /** 0020 * tc_register_driver - register a new TC driver 0021 * @drv: the driver structure to register 0022 * 0023 * Adds the driver structure to the list of registered drivers 0024 * Returns a negative value on error, otherwise 0. 0025 * If no error occurred, the driver remains registered even if 0026 * no device was claimed during registration. 0027 */ 0028 int tc_register_driver(struct tc_driver *tdrv) 0029 { 0030 return driver_register(&tdrv->driver); 0031 } 0032 EXPORT_SYMBOL(tc_register_driver); 0033 0034 /** 0035 * tc_unregister_driver - unregister a TC driver 0036 * @drv: the driver structure to unregister 0037 * 0038 * Deletes the driver structure from the list of registered TC drivers, 0039 * gives it a chance to clean up by calling its remove() function for 0040 * each device it was responsible for, and marks those devices as 0041 * driverless. 0042 */ 0043 void tc_unregister_driver(struct tc_driver *tdrv) 0044 { 0045 driver_unregister(&tdrv->driver); 0046 } 0047 EXPORT_SYMBOL(tc_unregister_driver); 0048 0049 /** 0050 * tc_match_device - tell if a TC device structure has a matching 0051 * TC device ID structure 0052 * @tdrv: the TC driver to earch for matching TC device ID strings 0053 * @tdev: the TC device structure to match against 0054 * 0055 * Used by a driver to check whether a TC device present in the 0056 * system is in its list of supported devices. Returns the matching 0057 * tc_device_id structure or %NULL if there is no match. 0058 */ 0059 static const struct tc_device_id *tc_match_device(struct tc_driver *tdrv, 0060 struct tc_dev *tdev) 0061 { 0062 const struct tc_device_id *id = tdrv->id_table; 0063 0064 if (id) { 0065 while (id->name[0] || id->vendor[0]) { 0066 if (strcmp(tdev->name, id->name) == 0 && 0067 strcmp(tdev->vendor, id->vendor) == 0) 0068 return id; 0069 id++; 0070 } 0071 } 0072 return NULL; 0073 } 0074 0075 /** 0076 * tc_bus_match - Tell if a device structure has a matching 0077 * TC device ID structure 0078 * @dev: the device structure to match against 0079 * @drv: the device driver to search for matching TC device ID strings 0080 * 0081 * Used by a driver to check whether a TC device present in the 0082 * system is in its list of supported devices. Returns 1 if there 0083 * is a match or 0 otherwise. 0084 */ 0085 static int tc_bus_match(struct device *dev, struct device_driver *drv) 0086 { 0087 struct tc_dev *tdev = to_tc_dev(dev); 0088 struct tc_driver *tdrv = to_tc_driver(drv); 0089 const struct tc_device_id *id; 0090 0091 id = tc_match_device(tdrv, tdev); 0092 if (id) 0093 return 1; 0094 0095 return 0; 0096 } 0097 0098 struct bus_type tc_bus_type = { 0099 .name = "tc", 0100 .match = tc_bus_match, 0101 }; 0102 EXPORT_SYMBOL(tc_bus_type); 0103 0104 static int __init tc_driver_init(void) 0105 { 0106 return bus_register(&tc_bus_type); 0107 } 0108 0109 postcore_initcall(tc_driver_init);
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |