forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-10 37f49e37ab4cb5d0bc4c60eb5c6d4dd57db767bb
kernel/drivers/nfc/pn533/i2c.c
....@@ -1,23 +1,10 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Driver for NXP PN533 NFC Chip - I2C transport layer
34 *
45 * Copyright (C) 2011 Instituto Nokia de Tecnologia
56 * Copyright (C) 2012-2013 Tieto Poland
67 * Copyright (C) 2016 HALE electronic
7
- *
8
- *
9
- * This program is free software; you can redistribute it and/or modify
10
- * it under the terms of the GNU General Public License as published by
11
- * the Free Software Foundation; either version 2 of the License, or
12
- * (at your option) any later version.
13
- *
14
- * This program is distributed in the hope that it will be useful,
15
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
- * GNU General Public License for more details.
18
- *
19
- * You should have received a copy of the GNU General Public License
20
- * along with this program; if not, see <http://www.gnu.org/licenses/>.
218 */
229
2310 #include <linux/device.h>
....@@ -206,12 +193,10 @@
206193 phy->i2c_dev = client;
207194 i2c_set_clientdata(client, phy);
208195
209
- priv = pn533_register_device(PN533_DEVICE_PN532,
210
- PN533_NO_TYPE_B_PROTOCOLS,
211
- PN533_PROTO_REQ_ACK_RESP,
212
- phy, &i2c_phy_ops, NULL,
213
- &phy->i2c_dev->dev,
214
- &client->dev);
196
+ priv = pn53x_common_init(PN533_DEVICE_PN532,
197
+ PN533_PROTO_REQ_ACK_RESP,
198
+ phy, &i2c_phy_ops, NULL,
199
+ &phy->i2c_dev->dev);
215200
216201 if (IS_ERR(priv)) {
217202 r = PTR_ERR(priv);
....@@ -219,6 +204,9 @@
219204 }
220205
221206 phy->priv = priv;
207
+ r = pn532_i2c_nfc_alloc(priv, PN533_NO_TYPE_B_PROTOCOLS, &client->dev);
208
+ if (r)
209
+ goto nfc_alloc_err;
222210
223211 r = request_threaded_irq(client->irq, NULL, pn533_i2c_irq_thread_fn,
224212 IRQF_TRIGGER_FALLING |
....@@ -233,13 +221,20 @@
233221 if (r)
234222 goto fn_setup_err;
235223
236
- return 0;
224
+ r = nfc_register_device(priv->nfc_dev);
225
+ if (r)
226
+ goto fn_setup_err;
227
+
228
+ return r;
237229
238230 fn_setup_err:
239231 free_irq(client->irq, phy);
240232
241233 irq_rqst_err:
242
- pn533_unregister_device(phy->priv);
234
+ nfc_free_device(priv->nfc_dev);
235
+
236
+nfc_alloc_err:
237
+ pn53x_common_clean(phy->priv);
243238
244239 return r;
245240 }
....@@ -252,12 +247,18 @@
252247
253248 free_irq(client->irq, phy);
254249
255
- pn533_unregister_device(phy->priv);
250
+ pn53x_unregister_nfc(phy->priv);
251
+ pn53x_common_clean(phy->priv);
256252
257253 return 0;
258254 }
259255
260256 static const struct of_device_id of_pn533_i2c_match[] = {
257
+ { .compatible = "nxp,pn532", },
258
+ /*
259
+ * NOTE: The use of the compatibles with the trailing "...-i2c" is
260
+ * deprecated and will be removed.
261
+ */
261262 { .compatible = "nxp,pn533-i2c", },
262263 { .compatible = "nxp,pn532-i2c", },
263264 {},
....@@ -273,7 +274,6 @@
273274 static struct i2c_driver pn533_i2c_driver = {
274275 .driver = {
275276 .name = PN533_I2C_DRIVER_NAME,
276
- .owner = THIS_MODULE,
277277 .of_match_table = of_match_ptr(of_pn533_i2c_match),
278278 },
279279 .probe = pn533_i2c_probe,