aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c/i2c-smbus.c
diff options
context:
space:
mode:
authorJonathan Herman <hermanjl@cs.unc.edu>2013-01-17 16:15:55 -0500
committerJonathan Herman <hermanjl@cs.unc.edu>2013-01-17 16:15:55 -0500
commit8dea78da5cee153b8af9c07a2745f6c55057fe12 (patch)
treea8f4d49d63b1ecc92f2fddceba0655b2472c5bd9 /drivers/i2c/i2c-smbus.c
parent406089d01562f1e2bf9f089fd7637009ebaad589 (diff)
Patched in Tegra support.
Diffstat (limited to 'drivers/i2c/i2c-smbus.c')
-rw-r--r--drivers/i2c/i2c-smbus.c27
1 files changed, 20 insertions, 7 deletions
diff --git a/drivers/i2c/i2c-smbus.c b/drivers/i2c/i2c-smbus.c
index 92cdd2323b0..f61ccc1e5ea 100644
--- a/drivers/i2c/i2c-smbus.c
+++ b/drivers/i2c/i2c-smbus.c
@@ -16,8 +16,7 @@
16 * 16 *
17 * You should have received a copy of the GNU General Public License 17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software 18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 * MA 02110-1301 USA.
21 */ 20 */
22 21
23#include <linux/kernel.h> 22#include <linux/kernel.h>
@@ -142,8 +141,7 @@ static int smbalert_probe(struct i2c_client *ara,
142 struct i2c_adapter *adapter = ara->adapter; 141 struct i2c_adapter *adapter = ara->adapter;
143 int res; 142 int res;
144 143
145 alert = devm_kzalloc(&ara->dev, sizeof(struct i2c_smbus_alert), 144 alert = kzalloc(sizeof(struct i2c_smbus_alert), GFP_KERNEL);
146 GFP_KERNEL);
147 if (!alert) 145 if (!alert)
148 return -ENOMEM; 146 return -ENOMEM;
149 147
@@ -155,8 +153,10 @@ static int smbalert_probe(struct i2c_client *ara,
155 if (setup->irq > 0) { 153 if (setup->irq > 0) {
156 res = devm_request_irq(&ara->dev, setup->irq, smbalert_irq, 154 res = devm_request_irq(&ara->dev, setup->irq, smbalert_irq,
157 0, "smbus_alert", alert); 155 0, "smbus_alert", alert);
158 if (res) 156 if (res) {
157 kfree(alert);
159 return res; 158 return res;
159 }
160 } 160 }
161 161
162 i2c_set_clientdata(ara, alert); 162 i2c_set_clientdata(ara, alert);
@@ -166,12 +166,14 @@ static int smbalert_probe(struct i2c_client *ara,
166 return 0; 166 return 0;
167} 167}
168 168
169/* IRQ and memory resources are managed so they are freed automatically */ 169/* IRQ resource is managed so it is freed automatically */
170static int smbalert_remove(struct i2c_client *ara) 170static int smbalert_remove(struct i2c_client *ara)
171{ 171{
172 struct i2c_smbus_alert *alert = i2c_get_clientdata(ara); 172 struct i2c_smbus_alert *alert = i2c_get_clientdata(ara);
173 173
174 cancel_work_sync(&alert->alert); 174 cancel_work_sync(&alert->alert);
175
176 kfree(alert);
175 return 0; 177 return 0;
176} 178}
177 179
@@ -242,7 +244,18 @@ int i2c_handle_smbus_alert(struct i2c_client *ara)
242} 244}
243EXPORT_SYMBOL_GPL(i2c_handle_smbus_alert); 245EXPORT_SYMBOL_GPL(i2c_handle_smbus_alert);
244 246
245module_i2c_driver(smbalert_driver); 247static int __init i2c_smbus_init(void)
248{
249 return i2c_add_driver(&smbalert_driver);
250}
251
252static void __exit i2c_smbus_exit(void)
253{
254 i2c_del_driver(&smbalert_driver);
255}
256
257module_init(i2c_smbus_init);
258module_exit(i2c_smbus_exit);
246 259
247MODULE_AUTHOR("Jean Delvare <khali@linux-fr.org>"); 260MODULE_AUTHOR("Jean Delvare <khali@linux-fr.org>");
248MODULE_DESCRIPTION("SMBus protocol extensions support"); 261MODULE_DESCRIPTION("SMBus protocol extensions support");