Linux Audio

Check our new training course

Loading...
v6.8
 1// SPDX-License-Identifier: GPL-2.0
 2/*
 3 * Copyright (C) 2013 Intel Corporation. All rights reserved.
 4 *
 5 * HCI based Driver for Inside Secure microread NFC Chip
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 6 */
 7
 8#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 9
10#include <linux/module.h>
11#include <linux/mod_devicetable.h>
12#include <linux/nfc.h>
 
13#include <net/nfc/llc.h>
14
15#include "../mei_phy.h"
16#include "microread.h"
17
18#define MICROREAD_DRIVER_NAME "microread"
19
20static int microread_mei_probe(struct mei_cl_device *cldev,
21			       const struct mei_cl_device_id *id)
22{
23	struct nfc_mei_phy *phy;
24	int r;
25
 
 
26	phy = nfc_mei_phy_alloc(cldev);
27	if (!phy)
 
28		return -ENOMEM;
 
29
30	r = microread_probe(phy, &mei_phy_ops, LLC_NOP_NAME,
31			    MEI_NFC_HEADER_SIZE, 0, MEI_NFC_MAX_HCI_PAYLOAD,
32			    &phy->hdev);
33	if (r < 0) {
34		nfc_mei_phy_free(phy);
35
36		return r;
37	}
38
39	return 0;
40}
41
42static void microread_mei_remove(struct mei_cl_device *cldev)
43{
44	struct nfc_mei_phy *phy = mei_cldev_get_drvdata(cldev);
45
46	microread_remove(phy->hdev);
47
48	nfc_mei_phy_free(phy);
 
 
49}
50
51static struct mei_cl_device_id microread_mei_tbl[] = {
52	{ MICROREAD_DRIVER_NAME, MEI_NFC_UUID, MEI_CL_VERSION_ANY},
53
54	/* required last entry */
55	{ }
56};
57MODULE_DEVICE_TABLE(mei, microread_mei_tbl);
58
59static struct mei_cl_driver microread_driver = {
60	.id_table = microread_mei_tbl,
61	.name = MICROREAD_DRIVER_NAME,
62
63	.probe = microread_mei_probe,
64	.remove = microread_mei_remove,
65};
66
67module_mei_cl_driver(microread_driver);
68
69MODULE_LICENSE("GPL");
70MODULE_DESCRIPTION(DRIVER_DESC);
v4.10.11
 
 1/*
 
 
 2 * HCI based Driver for Inside Secure microread NFC Chip
 3 *
 4 * Copyright (C) 2013  Intel Corporation. All rights reserved.
 5 *
 6 * This program is free software; you can redistribute it and/or modify it
 7 * under the terms and conditions of the GNU General Public License,
 8 * version 2, as published by the Free Software Foundation.
 9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
20
21#include <linux/module.h>
22#include <linux/mod_devicetable.h>
23#include <linux/nfc.h>
24#include <net/nfc/hci.h>
25#include <net/nfc/llc.h>
26
27#include "../mei_phy.h"
28#include "microread.h"
29
30#define MICROREAD_DRIVER_NAME "microread"
31
32static int microread_mei_probe(struct mei_cl_device *cldev,
33			       const struct mei_cl_device_id *id)
34{
35	struct nfc_mei_phy *phy;
36	int r;
37
38	pr_info("Probing NFC microread\n");
39
40	phy = nfc_mei_phy_alloc(cldev);
41	if (!phy) {
42		pr_err("Cannot allocate memory for microread mei phy.\n");
43		return -ENOMEM;
44	}
45
46	r = microread_probe(phy, &mei_phy_ops, LLC_NOP_NAME,
47			    MEI_NFC_HEADER_SIZE, 0, MEI_NFC_MAX_HCI_PAYLOAD,
48			    &phy->hdev);
49	if (r < 0) {
50		nfc_mei_phy_free(phy);
51
52		return r;
53	}
54
55	return 0;
56}
57
58static int microread_mei_remove(struct mei_cl_device *cldev)
59{
60	struct nfc_mei_phy *phy = mei_cldev_get_drvdata(cldev);
61
62	microread_remove(phy->hdev);
63
64	nfc_mei_phy_free(phy);
65
66	return 0;
67}
68
69static struct mei_cl_device_id microread_mei_tbl[] = {
70	{ MICROREAD_DRIVER_NAME, MEI_NFC_UUID, MEI_CL_VERSION_ANY},
71
72	/* required last entry */
73	{ }
74};
75MODULE_DEVICE_TABLE(mei, microread_mei_tbl);
76
77static struct mei_cl_driver microread_driver = {
78	.id_table = microread_mei_tbl,
79	.name = MICROREAD_DRIVER_NAME,
80
81	.probe = microread_mei_probe,
82	.remove = microread_mei_remove,
83};
84
85module_mei_cl_driver(microread_driver);
86
87MODULE_LICENSE("GPL");
88MODULE_DESCRIPTION(DRIVER_DESC);