.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * Generic driver for NXP NCI NFC chips |
---|
3 | 4 | * |
---|
.. | .. |
---|
7 | 8 | * |
---|
8 | 9 | * Derived from PN544 device driver: |
---|
9 | 10 | * 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/>. |
---|
22 | 11 | */ |
---|
23 | 12 | |
---|
24 | 13 | #include <linux/delay.h> |
---|
25 | | -#include <linux/gpio.h> |
---|
26 | 14 | #include <linux/module.h> |
---|
27 | 15 | #include <linux/nfc.h> |
---|
28 | | -#include <linux/platform_data/nxp-nci.h> |
---|
29 | 16 | |
---|
30 | 17 | #include <net/nfc/nci_core.h> |
---|
31 | 18 | |
---|
.. | .. |
---|
83 | 70 | struct nxp_nci_info *info = nci_get_drvdata(ndev); |
---|
84 | 71 | int r; |
---|
85 | 72 | |
---|
86 | | - if (!info->phy_ops->write) { |
---|
87 | | - r = -ENOTSUPP; |
---|
88 | | - goto send_exit; |
---|
89 | | - } |
---|
| 73 | + if (!info->phy_ops->write) |
---|
| 74 | + return -EOPNOTSUPP; |
---|
90 | 75 | |
---|
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; |
---|
95 | 78 | |
---|
96 | 79 | r = info->phy_ops->write(info->phy_id, skb); |
---|
97 | | - if (r < 0) |
---|
| 80 | + if (r < 0) { |
---|
98 | 81 | kfree_skb(skb); |
---|
| 82 | + return r; |
---|
| 83 | + } |
---|
99 | 84 | |
---|
100 | | -send_exit: |
---|
101 | | - return r; |
---|
| 85 | + consume_skb(skb); |
---|
| 86 | + return 0; |
---|
102 | 87 | } |
---|
103 | 88 | |
---|
104 | 89 | static struct nci_ops nxp_nci_ops = { |
---|
.. | .. |
---|
117 | 102 | int r; |
---|
118 | 103 | |
---|
119 | 104 | 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; |
---|
124 | 107 | |
---|
125 | 108 | info->phy_id = phy_id; |
---|
126 | 109 | info->pdev = pdev; |
---|
.. | .. |
---|
133 | 116 | if (info->phy_ops->set_mode) { |
---|
134 | 117 | r = info->phy_ops->set_mode(info->phy_id, NXP_NCI_MODE_COLD); |
---|
135 | 118 | if (r < 0) |
---|
136 | | - goto probe_exit; |
---|
| 119 | + return r; |
---|
137 | 120 | } |
---|
138 | 121 | |
---|
139 | 122 | info->mode = NXP_NCI_MODE_COLD; |
---|
140 | 123 | |
---|
141 | 124 | info->ndev = nci_allocate_device(&nxp_nci_ops, NXP_NCI_NFC_PROTOCOLS, |
---|
142 | 125 | NXP_NCI_HDR_LEN, 0); |
---|
143 | | - if (!info->ndev) { |
---|
144 | | - r = -ENOMEM; |
---|
145 | | - goto probe_exit; |
---|
146 | | - } |
---|
| 126 | + if (!info->ndev) |
---|
| 127 | + return -ENOMEM; |
---|
147 | 128 | |
---|
148 | 129 | nci_set_parent_dev(info->ndev, pdev); |
---|
149 | 130 | nci_set_drvdata(info->ndev, info); |
---|
150 | 131 | 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 | + } |
---|
153 | 136 | |
---|
154 | 137 | *ndev = info->ndev; |
---|
155 | | - |
---|
156 | | - goto probe_exit; |
---|
157 | | - |
---|
158 | | -probe_exit_free_nci: |
---|
159 | | - nci_free_device(info->ndev); |
---|
160 | | -probe_exit: |
---|
161 | 138 | return r; |
---|
162 | 139 | } |
---|
163 | 140 | EXPORT_SYMBOL(nxp_nci_probe); |
---|