hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/mfd/htc-i2cpld.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * htc-i2cpld.c
34 * Chip driver for an unknown CPLD chip found on omap850 HTC devices like
....@@ -9,25 +10,10 @@
910 *
1011 * Based on work done in the linwizard project
1112 * Copyright (C) 2008-2009 Angelo Arrifano <miknix@gmail.com>
12
- *
13
- * This program is free software; you can redistribute it and/or modify
14
- * it under the terms of the GNU General Public License as published by
15
- * the Free Software Foundation; either version 2 of the License, or
16
- * (at your option) any later version.
17
- *
18
- * This program is distributed in the hope that it will be useful,
19
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
- * GNU General Public License for more details.
22
- *
23
- * You should have received a copy of the GNU General Public License
24
- * along with this program; if not, write to the Free Software
25
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
2613 */
2714
2815 #include <linux/kernel.h>
2916 #include <linux/init.h>
30
-#include <linux/module.h>
3117 #include <linux/interrupt.h>
3218 #include <linux/platform_device.h>
3319 #include <linux/i2c.h>
....@@ -360,6 +346,7 @@
360346 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_READ_BYTE_DATA)) {
361347 dev_warn(dev, "i2c adapter %d non-functional\n",
362348 pdata->i2c_adapter_id);
349
+ i2c_put_adapter(adapter);
363350 return -EINVAL;
364351 }
365352
....@@ -369,12 +356,13 @@
369356 info.platform_data = chip;
370357
371358 /* Add the I2C device. This calls the probe() function. */
372
- client = i2c_new_device(adapter, &info);
373
- if (!client) {
359
+ client = i2c_new_client_device(adapter, &info);
360
+ if (IS_ERR(client)) {
374361 /* I2C device registration failed, contineu with the next */
375362 dev_warn(dev, "Unable to add I2C device for 0x%x\n",
376363 plat_chip_data->addr);
377
- return -ENODEV;
364
+ i2c_put_adapter(adapter);
365
+ return PTR_ERR(client);
378366 }
379367
380368 i2c_set_clientdata(client, chip);
....@@ -399,8 +387,7 @@
399387 htcpld = platform_get_drvdata(pdev);
400388 chip = &htcpld->chip[chip_index];
401389
402
- if (chip->client)
403
- i2c_unregister_device(chip->client);
390
+ i2c_unregister_device(chip->client);
404391 }
405392
406393 static int htcpld_register_chip_gpio(
....@@ -614,8 +601,6 @@
614601 { "htcpld-chip", 0 },
615602 { }
616603 };
617
-MODULE_DEVICE_TABLE(i2c, htcpld_chip_id);
618
-
619604
620605 static struct i2c_driver htcpld_chip_driver = {
621606 .driver = {
....@@ -643,17 +628,4 @@
643628 /* Probe for our chips */
644629 return platform_driver_probe(&htcpld_core_driver, htcpld_core_probe);
645630 }
646
-
647
-static void __exit htcpld_core_exit(void)
648
-{
649
- i2c_del_driver(&htcpld_chip_driver);
650
- platform_driver_unregister(&htcpld_core_driver);
651
-}
652
-
653
-module_init(htcpld_core_init);
654
-module_exit(htcpld_core_exit);
655
-
656
-MODULE_AUTHOR("Cory Maccarrone <darkstar6262@gmail.com>");
657
-MODULE_DESCRIPTION("I2C HTC PLD Driver");
658
-MODULE_LICENSE("GPL");
659
-
631
+device_initcall(htcpld_core_init);