Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
tc-driver.c
Go to the documentation of this file.
1 /*
2  * TURBOchannel driver services.
3  *
4  * Copyright (c) 2005 James Simmons
5  * Copyright (c) 2006 Maciej W. Rozycki
6  *
7  * Loosely based on drivers/dio/dio-driver.c and
8  * drivers/pci/pci-driver.c.
9  *
10  * This file is subject to the terms and conditions of the GNU
11  * General Public License. See the file "COPYING" in the main
12  * directory of this archive for more details.
13  */
14 
15 #include <linux/init.h>
16 #include <linux/module.h>
17 #include <linux/tc.h>
18 
28 int tc_register_driver(struct tc_driver *tdrv)
29 {
30  return driver_register(&tdrv->driver);
31 }
33 
43 void tc_unregister_driver(struct tc_driver *tdrv)
44 {
45  driver_unregister(&tdrv->driver);
46 }
48 
59 const struct tc_device_id *tc_match_device(struct tc_driver *tdrv,
60  struct tc_dev *tdev)
61 {
62  const struct tc_device_id *id = tdrv->id_table;
63 
64  if (id) {
65  while (id->name[0] || id->vendor[0]) {
66  if (strcmp(tdev->name, id->name) == 0 &&
67  strcmp(tdev->vendor, id->vendor) == 0)
68  return id;
69  id++;
70  }
71  }
72  return NULL;
73 }
75 
86 static int tc_bus_match(struct device *dev, struct device_driver *drv)
87 {
88  struct tc_dev *tdev = to_tc_dev(dev);
89  struct tc_driver *tdrv = to_tc_driver(drv);
90  const struct tc_device_id *id;
91 
92  id = tc_match_device(tdrv, tdev);
93  if (id)
94  return 1;
95 
96  return 0;
97 }
98 
100  .name = "tc",
101  .match = tc_bus_match,
102 };
103 EXPORT_SYMBOL(tc_bus_type);
104 
105 static int __init tc_driver_init(void)
106 {
107  return bus_register(&tc_bus_type);
108 }
109 
110 postcore_initcall(tc_driver_init);