Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
isp1301.c
Go to the documentation of this file.
1 /*
2  * NXP ISP1301 USB transceiver driver
3  *
4  * Copyright (C) 2012 Roland Stigge
5  *
6  * Author: Roland Stigge <[email protected]>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License version 2 as
10  * published by the Free Software Foundation.
11  */
12 
13 #include <linux/module.h>
14 #include <linux/i2c.h>
15 
16 #define DRV_NAME "isp1301"
17 
18 static const struct i2c_device_id isp1301_id[] = {
19  { "isp1301", 0 },
20  { }
21 };
22 
23 static struct i2c_client *isp1301_i2c_client;
24 
25 static int isp1301_probe(struct i2c_client *client,
26  const struct i2c_device_id *i2c_id)
27 {
28  isp1301_i2c_client = client;
29  return 0;
30 }
31 
32 static int isp1301_remove(struct i2c_client *client)
33 {
34  return 0;
35 }
36 
37 static struct i2c_driver isp1301_driver = {
38  .driver = {
39  .name = DRV_NAME,
40  },
41  .probe = isp1301_probe,
42  .remove = isp1301_remove,
43  .id_table = isp1301_id,
44 };
45 
46 module_i2c_driver(isp1301_driver);
47 
48 static int match(struct device *dev, void *data)
49 {
50  struct device_node *node = (struct device_node *)data;
51  return (dev->of_node == node) &&
52  (dev->driver == &isp1301_driver.driver);
53 }
54 
56 {
57  if (node) { /* reference of ISP1301 I2C node via DT */
58  struct device *dev = bus_find_device(&i2c_bus_type, NULL,
59  node, match);
60  if (!dev)
61  return NULL;
62  return to_i2c_client(dev);
63  } else { /* non-DT: only one ISP1301 chip supported */
64  return isp1301_i2c_client;
65  }
66 }
68 
69 MODULE_AUTHOR("Roland Stigge <[email protected]>");
70 MODULE_DESCRIPTION("NXP ISP1301 USB transceiver driver");
71 MODULE_LICENSE("GPL");