forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-10 37f49e37ab4cb5d0bc4c60eb5c6d4dd57db767bb
kernel/drivers/nfc/nxp-nci/core.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Generic driver for NXP NCI NFC chips
34 *
....@@ -7,25 +8,11 @@
78 *
89 * Derived from PN544 device driver:
910 * Copyright (C) 2012 Intel Corporation. All rights reserved.
10
- *
11
- * This program is free software; you can redistribute it and/or modify it
12
- * under the terms and conditions of the GNU General Public License,
13
- * version 2, as published by the Free Software Foundation.
14
- *
15
- * This program is distributed in the hope that it will be useful,
16
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
- * GNU General Public License for more details.
19
- *
20
- * You should have received a copy of the GNU General Public License
21
- * along with this program; if not, see <http://www.gnu.org/licenses/>.
2211 */
2312
2413 #include <linux/delay.h>
25
-#include <linux/gpio.h>
2614 #include <linux/module.h>
2715 #include <linux/nfc.h>
28
-#include <linux/platform_data/nxp-nci.h>
2916
3017 #include <net/nfc/nci_core.h>
3118
....@@ -83,22 +70,20 @@
8370 struct nxp_nci_info *info = nci_get_drvdata(ndev);
8471 int r;
8572
86
- if (!info->phy_ops->write) {
87
- r = -ENOTSUPP;
88
- goto send_exit;
89
- }
73
+ if (!info->phy_ops->write)
74
+ return -EOPNOTSUPP;
9075
91
- if (info->mode != NXP_NCI_MODE_NCI) {
92
- r = -EINVAL;
93
- goto send_exit;
94
- }
76
+ if (info->mode != NXP_NCI_MODE_NCI)
77
+ return -EINVAL;
9578
9679 r = info->phy_ops->write(info->phy_id, skb);
97
- if (r < 0)
80
+ if (r < 0) {
9881 kfree_skb(skb);
82
+ return r;
83
+ }
9984
100
-send_exit:
101
- return r;
85
+ consume_skb(skb);
86
+ return 0;
10287 }
10388
10489 static struct nci_ops nxp_nci_ops = {
....@@ -117,10 +102,8 @@
117102 int r;
118103
119104 info = devm_kzalloc(pdev, sizeof(struct nxp_nci_info), GFP_KERNEL);
120
- if (!info) {
121
- r = -ENOMEM;
122
- goto probe_exit;
123
- }
105
+ if (!info)
106
+ return -ENOMEM;
124107
125108 info->phy_id = phy_id;
126109 info->pdev = pdev;
....@@ -133,31 +116,25 @@
133116 if (info->phy_ops->set_mode) {
134117 r = info->phy_ops->set_mode(info->phy_id, NXP_NCI_MODE_COLD);
135118 if (r < 0)
136
- goto probe_exit;
119
+ return r;
137120 }
138121
139122 info->mode = NXP_NCI_MODE_COLD;
140123
141124 info->ndev = nci_allocate_device(&nxp_nci_ops, NXP_NCI_NFC_PROTOCOLS,
142125 NXP_NCI_HDR_LEN, 0);
143
- if (!info->ndev) {
144
- r = -ENOMEM;
145
- goto probe_exit;
146
- }
126
+ if (!info->ndev)
127
+ return -ENOMEM;
147128
148129 nci_set_parent_dev(info->ndev, pdev);
149130 nci_set_drvdata(info->ndev, info);
150131 r = nci_register_device(info->ndev);
151
- if (r < 0)
152
- goto probe_exit_free_nci;
132
+ if (r < 0) {
133
+ nci_free_device(info->ndev);
134
+ return r;
135
+ }
153136
154137 *ndev = info->ndev;
155
-
156
- goto probe_exit;
157
-
158
-probe_exit_free_nci:
159
- nci_free_device(info->ndev);
160
-probe_exit:
161138 return r;
162139 }
163140 EXPORT_SYMBOL(nxp_nci_probe);