| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright (C) 2007-2010 ST-Ericsson |
|---|
| 3 | | - * License terms: GNU General Public License (GPL) version 2 |
|---|
| 4 | 4 | * Low-level core for exclusive access to the AB3100 IC on the I2C bus |
|---|
| 5 | 5 | * and some basic chip-configuration. |
|---|
| 6 | 6 | * Author: Linus Walleij <linus.walleij@stericsson.com> |
|---|
| .. | .. |
|---|
| 498 | 498 | int i = 0; |
|---|
| 499 | 499 | |
|---|
| 500 | 500 | /* Get userspace string and assure termination */ |
|---|
| 501 | | - buf_size = min(count, (sizeof(buf)-1)); |
|---|
| 501 | + buf_size = min((ssize_t)count, (ssize_t)(sizeof(buf)-1)); |
|---|
| 502 | 502 | if (copy_from_user(buf, user_buf, buf_size)) |
|---|
| 503 | 503 | return -EFAULT; |
|---|
| 504 | 504 | buf[buf_size] = 0; |
|---|
| .. | .. |
|---|
| 575 | 575 | .llseek = noop_llseek, |
|---|
| 576 | 576 | }; |
|---|
| 577 | 577 | |
|---|
| 578 | | -static struct dentry *ab3100_dir; |
|---|
| 579 | | -static struct dentry *ab3100_reg_file; |
|---|
| 580 | 578 | static struct ab3100_get_set_reg_priv ab3100_get_priv; |
|---|
| 581 | | -static struct dentry *ab3100_get_reg_file; |
|---|
| 582 | 579 | static struct ab3100_get_set_reg_priv ab3100_set_priv; |
|---|
| 583 | | -static struct dentry *ab3100_set_reg_file; |
|---|
| 584 | 580 | |
|---|
| 585 | 581 | static void ab3100_setup_debugfs(struct ab3100 *ab3100) |
|---|
| 586 | 582 | { |
|---|
| 587 | | - int err; |
|---|
| 583 | + struct dentry *ab3100_dir; |
|---|
| 588 | 584 | |
|---|
| 589 | 585 | ab3100_dir = debugfs_create_dir("ab3100", NULL); |
|---|
| 590 | | - if (!ab3100_dir) |
|---|
| 591 | | - goto exit_no_debugfs; |
|---|
| 592 | 586 | |
|---|
| 593 | | - ab3100_reg_file = debugfs_create_file("registers", |
|---|
| 594 | | - S_IRUGO, ab3100_dir, ab3100, |
|---|
| 595 | | - &ab3100_registers_fops); |
|---|
| 596 | | - if (!ab3100_reg_file) { |
|---|
| 597 | | - err = -ENOMEM; |
|---|
| 598 | | - goto exit_destroy_dir; |
|---|
| 599 | | - } |
|---|
| 587 | + debugfs_create_file("registers", S_IRUGO, ab3100_dir, ab3100, |
|---|
| 588 | + &ab3100_registers_fops); |
|---|
| 600 | 589 | |
|---|
| 601 | 590 | ab3100_get_priv.ab3100 = ab3100; |
|---|
| 602 | 591 | ab3100_get_priv.mode = false; |
|---|
| 603 | | - ab3100_get_reg_file = debugfs_create_file("get_reg", |
|---|
| 604 | | - S_IWUSR, ab3100_dir, &ab3100_get_priv, |
|---|
| 605 | | - &ab3100_get_set_reg_fops); |
|---|
| 606 | | - if (!ab3100_get_reg_file) { |
|---|
| 607 | | - err = -ENOMEM; |
|---|
| 608 | | - goto exit_destroy_reg; |
|---|
| 609 | | - } |
|---|
| 592 | + debugfs_create_file("get_reg", S_IWUSR, ab3100_dir, &ab3100_get_priv, |
|---|
| 593 | + &ab3100_get_set_reg_fops); |
|---|
| 610 | 594 | |
|---|
| 611 | 595 | ab3100_set_priv.ab3100 = ab3100; |
|---|
| 612 | 596 | ab3100_set_priv.mode = true; |
|---|
| 613 | | - ab3100_set_reg_file = debugfs_create_file("set_reg", |
|---|
| 614 | | - S_IWUSR, ab3100_dir, &ab3100_set_priv, |
|---|
| 615 | | - &ab3100_get_set_reg_fops); |
|---|
| 616 | | - if (!ab3100_set_reg_file) { |
|---|
| 617 | | - err = -ENOMEM; |
|---|
| 618 | | - goto exit_destroy_get_reg; |
|---|
| 619 | | - } |
|---|
| 620 | | - return; |
|---|
| 621 | | - |
|---|
| 622 | | - exit_destroy_get_reg: |
|---|
| 623 | | - debugfs_remove(ab3100_get_reg_file); |
|---|
| 624 | | - exit_destroy_reg: |
|---|
| 625 | | - debugfs_remove(ab3100_reg_file); |
|---|
| 626 | | - exit_destroy_dir: |
|---|
| 627 | | - debugfs_remove(ab3100_dir); |
|---|
| 628 | | - exit_no_debugfs: |
|---|
| 629 | | - return; |
|---|
| 597 | + debugfs_create_file("set_reg", S_IWUSR, ab3100_dir, &ab3100_set_priv, |
|---|
| 598 | + &ab3100_get_set_reg_fops); |
|---|
| 630 | 599 | } |
|---|
| 631 | 600 | #else |
|---|
| 632 | 601 | static inline void ab3100_setup_debugfs(struct ab3100 *ab3100) |
|---|
| .. | .. |
|---|
| 896 | 865 | &ab3100->chip_name[0]); |
|---|
| 897 | 866 | |
|---|
| 898 | 867 | /* Attach a second dummy i2c_client to the test register address */ |
|---|
| 899 | | - ab3100->testreg_client = i2c_new_dummy(client->adapter, |
|---|
| 868 | + ab3100->testreg_client = i2c_new_dummy_device(client->adapter, |
|---|
| 900 | 869 | client->addr + 1); |
|---|
| 901 | | - if (!ab3100->testreg_client) { |
|---|
| 902 | | - err = -ENOMEM; |
|---|
| 870 | + if (IS_ERR(ab3100->testreg_client)) { |
|---|
| 871 | + err = PTR_ERR(ab3100->testreg_client); |
|---|
| 903 | 872 | goto exit_no_testreg_client; |
|---|
| 904 | 873 | } |
|---|
| 905 | 874 | |
|---|