| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * htc-i2cpld.c |
|---|
| 3 | 4 | * Chip driver for an unknown CPLD chip found on omap850 HTC devices like |
|---|
| .. | .. |
|---|
| 9 | 10 | * |
|---|
| 10 | 11 | * Based on work done in the linwizard project |
|---|
| 11 | 12 | * 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. |
|---|
| 26 | 13 | */ |
|---|
| 27 | 14 | |
|---|
| 28 | 15 | #include <linux/kernel.h> |
|---|
| 29 | 16 | #include <linux/init.h> |
|---|
| 30 | | -#include <linux/module.h> |
|---|
| 31 | 17 | #include <linux/interrupt.h> |
|---|
| 32 | 18 | #include <linux/platform_device.h> |
|---|
| 33 | 19 | #include <linux/i2c.h> |
|---|
| .. | .. |
|---|
| 360 | 346 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_READ_BYTE_DATA)) { |
|---|
| 361 | 347 | dev_warn(dev, "i2c adapter %d non-functional\n", |
|---|
| 362 | 348 | pdata->i2c_adapter_id); |
|---|
| 349 | + i2c_put_adapter(adapter); |
|---|
| 363 | 350 | return -EINVAL; |
|---|
| 364 | 351 | } |
|---|
| 365 | 352 | |
|---|
| .. | .. |
|---|
| 369 | 356 | info.platform_data = chip; |
|---|
| 370 | 357 | |
|---|
| 371 | 358 | /* 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)) { |
|---|
| 374 | 361 | /* I2C device registration failed, contineu with the next */ |
|---|
| 375 | 362 | dev_warn(dev, "Unable to add I2C device for 0x%x\n", |
|---|
| 376 | 363 | plat_chip_data->addr); |
|---|
| 377 | | - return -ENODEV; |
|---|
| 364 | + i2c_put_adapter(adapter); |
|---|
| 365 | + return PTR_ERR(client); |
|---|
| 378 | 366 | } |
|---|
| 379 | 367 | |
|---|
| 380 | 368 | i2c_set_clientdata(client, chip); |
|---|
| .. | .. |
|---|
| 399 | 387 | htcpld = platform_get_drvdata(pdev); |
|---|
| 400 | 388 | chip = &htcpld->chip[chip_index]; |
|---|
| 401 | 389 | |
|---|
| 402 | | - if (chip->client) |
|---|
| 403 | | - i2c_unregister_device(chip->client); |
|---|
| 390 | + i2c_unregister_device(chip->client); |
|---|
| 404 | 391 | } |
|---|
| 405 | 392 | |
|---|
| 406 | 393 | static int htcpld_register_chip_gpio( |
|---|
| .. | .. |
|---|
| 614 | 601 | { "htcpld-chip", 0 }, |
|---|
| 615 | 602 | { } |
|---|
| 616 | 603 | }; |
|---|
| 617 | | -MODULE_DEVICE_TABLE(i2c, htcpld_chip_id); |
|---|
| 618 | | - |
|---|
| 619 | 604 | |
|---|
| 620 | 605 | static struct i2c_driver htcpld_chip_driver = { |
|---|
| 621 | 606 | .driver = { |
|---|
| .. | .. |
|---|
| 643 | 628 | /* Probe for our chips */ |
|---|
| 644 | 629 | return platform_driver_probe(&htcpld_core_driver, htcpld_core_probe); |
|---|
| 645 | 630 | } |
|---|
| 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); |
|---|