rc5t583.c (bc0868c62bb13834b20a864f684cced1f84a2412) rc5t583.c (b36c82724fa10da7cc73693c6c2c3ab9a6c8034b)
1/*
2 * Core driver access RC5T583 power management chip.
3 *
4 * Copyright (c) 2011-2012, NVIDIA CORPORATION. All rights reserved.
5 * Author: Laxman dewangan <ldewangan@nvidia.com>
6 *
7 * Based on code
8 * Copyright (C) 2011 RICOH COMPANY,LTD

--- 238 unchanged lines hidden (view full) ---

247};
248
249static int rc5t583_i2c_probe(struct i2c_client *i2c,
250 const struct i2c_device_id *id)
251{
252 struct rc5t583 *rc5t583;
253 struct rc5t583_platform_data *pdata = dev_get_platdata(&i2c->dev);
254 int ret;
1/*
2 * Core driver access RC5T583 power management chip.
3 *
4 * Copyright (c) 2011-2012, NVIDIA CORPORATION. All rights reserved.
5 * Author: Laxman dewangan <ldewangan@nvidia.com>
6 *
7 * Based on code
8 * Copyright (C) 2011 RICOH COMPANY,LTD

--- 238 unchanged lines hidden (view full) ---

247};
248
249static int rc5t583_i2c_probe(struct i2c_client *i2c,
250 const struct i2c_device_id *id)
251{
252 struct rc5t583 *rc5t583;
253 struct rc5t583_platform_data *pdata = dev_get_platdata(&i2c->dev);
254 int ret;
255 bool irq_init_success = false;
256
257 if (!pdata) {
258 dev_err(&i2c->dev, "Err: Platform data not found\n");
259 return -EINVAL;
260 }
261
262 rc5t583 = devm_kzalloc(&i2c->dev, sizeof(struct rc5t583), GFP_KERNEL);
263 if (!rc5t583) {

--- 15 unchanged lines hidden (view full) ---

279 if (ret < 0)
280 return ret;
281
282 if (i2c->irq) {
283 ret = rc5t583_irq_init(rc5t583, i2c->irq, pdata->irq_base);
284 /* Still continue with warning, if irq init fails */
285 if (ret)
286 dev_warn(&i2c->dev, "IRQ init failed: %d\n", ret);
255
256 if (!pdata) {
257 dev_err(&i2c->dev, "Err: Platform data not found\n");
258 return -EINVAL;
259 }
260
261 rc5t583 = devm_kzalloc(&i2c->dev, sizeof(struct rc5t583), GFP_KERNEL);
262 if (!rc5t583) {

--- 15 unchanged lines hidden (view full) ---

278 if (ret < 0)
279 return ret;
280
281 if (i2c->irq) {
282 ret = rc5t583_irq_init(rc5t583, i2c->irq, pdata->irq_base);
283 /* Still continue with warning, if irq init fails */
284 if (ret)
285 dev_warn(&i2c->dev, "IRQ init failed: %d\n", ret);
287 else
288 irq_init_success = true;
289 }
290
286 }
287
291 ret = mfd_add_devices(rc5t583->dev, -1, rc5t583_subdevs,
292 ARRAY_SIZE(rc5t583_subdevs), NULL, 0, NULL);
288 ret = devm_mfd_add_devices(rc5t583->dev, -1, rc5t583_subdevs,
289 ARRAY_SIZE(rc5t583_subdevs), NULL, 0, NULL);
293 if (ret) {
294 dev_err(&i2c->dev, "add mfd devices failed: %d\n", ret);
290 if (ret) {
291 dev_err(&i2c->dev, "add mfd devices failed: %d\n", ret);
295 goto err_add_devs;
292 return ret;
296 }
297
298 return 0;
293 }
294
295 return 0;
299
300err_add_devs:
301 if (irq_init_success)
302 rc5t583_irq_exit(rc5t583);
303 return ret;
304}
305
296}
297
306static int rc5t583_i2c_remove(struct i2c_client *i2c)
307{
308 struct rc5t583 *rc5t583 = i2c_get_clientdata(i2c);
309
310 mfd_remove_devices(rc5t583->dev);
311 rc5t583_irq_exit(rc5t583);
312 return 0;
313}
314
315static const struct i2c_device_id rc5t583_i2c_id[] = {
316 {.name = "rc5t583", .driver_data = 0},
317 {}
318};
319
320MODULE_DEVICE_TABLE(i2c, rc5t583_i2c_id);
321
322static struct i2c_driver rc5t583_i2c_driver = {
323 .driver = {
324 .name = "rc5t583",
325 },
326 .probe = rc5t583_i2c_probe,
298static const struct i2c_device_id rc5t583_i2c_id[] = {
299 {.name = "rc5t583", .driver_data = 0},
300 {}
301};
302
303MODULE_DEVICE_TABLE(i2c, rc5t583_i2c_id);
304
305static struct i2c_driver rc5t583_i2c_driver = {
306 .driver = {
307 .name = "rc5t583",
308 },
309 .probe = rc5t583_i2c_probe,
327 .remove = rc5t583_i2c_remove,
328 .id_table = rc5t583_i2c_id,
329};
330
331static int __init rc5t583_i2c_init(void)
332{
333 return i2c_add_driver(&rc5t583_i2c_driver);
334}
335subsys_initcall(rc5t583_i2c_init);
336
337static void __exit rc5t583_i2c_exit(void)
338{
339 i2c_del_driver(&rc5t583_i2c_driver);
340}
341
342module_exit(rc5t583_i2c_exit);
343
344MODULE_AUTHOR("Laxman Dewangan <ldewangan@nvidia.com>");
345MODULE_DESCRIPTION("RICOH RC5T583 power management system device driver");
346MODULE_LICENSE("GPL v2");
310 .id_table = rc5t583_i2c_id,
311};
312
313static int __init rc5t583_i2c_init(void)
314{
315 return i2c_add_driver(&rc5t583_i2c_driver);
316}
317subsys_initcall(rc5t583_i2c_init);
318
319static void __exit rc5t583_i2c_exit(void)
320{
321 i2c_del_driver(&rc5t583_i2c_driver);
322}
323
324module_exit(rc5t583_i2c_exit);
325
326MODULE_AUTHOR("Laxman Dewangan <ldewangan@nvidia.com>");
327MODULE_DESCRIPTION("RICOH RC5T583 power management system device driver");
328MODULE_LICENSE("GPL v2");