ipv4: Kill spurious write to iph->daddr in ip_forward_options().
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / drivers / gpio / max7300.c
blob962f661c18c72d65a4f68a01e639e4b24159e0dd
1 /*
2 * drivers/gpio/max7300.c
4 * Copyright (C) 2009 Wolfram Sang, Pengutronix
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
10 * Check max730x.c for further details.
13 #include <linux/module.h>
14 #include <linux/init.h>
15 #include <linux/platform_device.h>
16 #include <linux/mutex.h>
17 #include <linux/i2c.h>
18 #include <linux/spi/max7301.h>
19 #include <linux/slab.h>
21 static int max7300_i2c_write(struct device *dev, unsigned int reg,
22 unsigned int val)
24 struct i2c_client *client = to_i2c_client(dev);
26 return i2c_smbus_write_byte_data(client, reg, val);
29 static int max7300_i2c_read(struct device *dev, unsigned int reg)
31 struct i2c_client *client = to_i2c_client(dev);
33 return i2c_smbus_read_byte_data(client, reg);
36 static int __devinit max7300_probe(struct i2c_client *client,
37 const struct i2c_device_id *id)
39 struct max7301 *ts;
40 int ret;
42 if (!i2c_check_functionality(client->adapter,
43 I2C_FUNC_SMBUS_BYTE_DATA))
44 return -EIO;
46 ts = kzalloc(sizeof(struct max7301), GFP_KERNEL);
47 if (!ts)
48 return -ENOMEM;
50 ts->read = max7300_i2c_read;
51 ts->write = max7300_i2c_write;
52 ts->dev = &client->dev;
54 ret = __max730x_probe(ts);
55 if (ret)
56 kfree(ts);
57 return ret;
60 static int __devexit max7300_remove(struct i2c_client *client)
62 return __max730x_remove(&client->dev);
65 static const struct i2c_device_id max7300_id[] = {
66 { "max7300", 0 },
67 { }
69 MODULE_DEVICE_TABLE(i2c, max7300_id);
71 static struct i2c_driver max7300_driver = {
72 .driver = {
73 .name = "max7300",
74 .owner = THIS_MODULE,
76 .probe = max7300_probe,
77 .remove = __devexit_p(max7300_remove),
78 .id_table = max7300_id,
81 static int __init max7300_init(void)
83 return i2c_add_driver(&max7300_driver);
85 subsys_initcall(max7300_init);
87 static void __exit max7300_exit(void)
89 i2c_del_driver(&max7300_driver);
91 module_exit(max7300_exit);
93 MODULE_AUTHOR("Wolfram Sang");
94 MODULE_LICENSE("GPL v2");
95 MODULE_DESCRIPTION("MAX7300 GPIO-Expander");