.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * |
---|
3 | 4 | * keyboard input driver for i2c IR remote controls |
---|
.. | .. |
---|
32 | 33 | * Mark Weaver <mark@npsl.co.uk> |
---|
33 | 34 | * Jarod Wilson <jarod@redhat.com> |
---|
34 | 35 | * Copyright (C) 2011 Andy Walls <awalls@md.metrocast.net> |
---|
35 | | - * |
---|
36 | | - * This program is free software; you can redistribute it and/or modify |
---|
37 | | - * it under the terms of the GNU General Public License as published by |
---|
38 | | - * the Free Software Foundation; either version 2 of the License, or |
---|
39 | | - * (at your option) any later version. |
---|
40 | | - * |
---|
41 | | - * This program is distributed in the hope that it will be useful, |
---|
42 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
43 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
44 | | - * GNU General Public License for more details. |
---|
45 | | - * |
---|
46 | 36 | */ |
---|
47 | 37 | |
---|
48 | 38 | #include <asm/unaligned.h> |
---|
.. | .. |
---|
896 | 886 | INIT_DELAYED_WORK(&ir->work, ir_work); |
---|
897 | 887 | |
---|
898 | 888 | if (probe_tx) { |
---|
899 | | - ir->tx_c = i2c_new_dummy(client->adapter, 0x70); |
---|
900 | | - if (!ir->tx_c) { |
---|
| 889 | + ir->tx_c = i2c_new_dummy_device(client->adapter, 0x70); |
---|
| 890 | + if (IS_ERR(ir->tx_c)) { |
---|
901 | 891 | dev_err(&client->dev, "failed to setup tx i2c address"); |
---|
| 892 | + err = PTR_ERR(ir->tx_c); |
---|
| 893 | + goto err_out_free; |
---|
902 | 894 | } else if (!zilog_init(ir)) { |
---|
903 | 895 | ir->carrier = 38000; |
---|
904 | 896 | ir->duty_cycle = 40; |
---|
.. | .. |
---|
915 | 907 | return 0; |
---|
916 | 908 | |
---|
917 | 909 | err_out_free: |
---|
918 | | - if (ir->tx_c) |
---|
| 910 | + if (!IS_ERR(ir->tx_c)) |
---|
919 | 911 | i2c_unregister_device(ir->tx_c); |
---|
920 | 912 | |
---|
921 | 913 | /* Only frees rc if it were allocated internally */ |
---|
.. | .. |
---|
927 | 919 | { |
---|
928 | 920 | struct IR_i2c *ir = i2c_get_clientdata(client); |
---|
929 | 921 | |
---|
930 | | - /* kill outstanding polls */ |
---|
931 | 922 | cancel_delayed_work_sync(&ir->work); |
---|
932 | 923 | |
---|
933 | | - if (ir->tx_c) |
---|
934 | | - i2c_unregister_device(ir->tx_c); |
---|
| 924 | + i2c_unregister_device(ir->tx_c); |
---|
935 | 925 | |
---|
936 | | - /* unregister device */ |
---|
937 | 926 | rc_unregister_device(ir->rc); |
---|
938 | 927 | |
---|
939 | | - /* free memory */ |
---|
940 | 928 | return 0; |
---|
941 | 929 | } |
---|
942 | 930 | |
---|