linux/drivers/nfc/microread/mei.c
<<
>>
Prefs
   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/hci.h>
  14#include <net/nfc/llc.h>
  15
  16#include "../mei_phy.h"
  17#include "microread.h"
  18
  19#define MICROREAD_DRIVER_NAME "microread"
  20
  21static int microread_mei_probe(struct mei_cl_device *cldev,
  22                               const struct mei_cl_device_id *id)
  23{
  24        struct nfc_mei_phy *phy;
  25        int r;
  26
  27        pr_info("Probing NFC microread\n");
  28
  29        phy = nfc_mei_phy_alloc(cldev);
  30        if (!phy) {
  31                pr_err("Cannot allocate memory for microread mei phy.\n");
  32                return -ENOMEM;
  33        }
  34
  35        r = microread_probe(phy, &mei_phy_ops, LLC_NOP_NAME,
  36                            MEI_NFC_HEADER_SIZE, 0, MEI_NFC_MAX_HCI_PAYLOAD,
  37                            &phy->hdev);
  38        if (r < 0) {
  39                nfc_mei_phy_free(phy);
  40
  41                return r;
  42        }
  43
  44        return 0;
  45}
  46
  47static void microread_mei_remove(struct mei_cl_device *cldev)
  48{
  49        struct nfc_mei_phy *phy = mei_cldev_get_drvdata(cldev);
  50
  51        microread_remove(phy->hdev);
  52
  53        nfc_mei_phy_free(phy);
  54}
  55
  56static struct mei_cl_device_id microread_mei_tbl[] = {
  57        { MICROREAD_DRIVER_NAME, MEI_NFC_UUID, MEI_CL_VERSION_ANY},
  58
  59        /* required last entry */
  60        { }
  61};
  62MODULE_DEVICE_TABLE(mei, microread_mei_tbl);
  63
  64static struct mei_cl_driver microread_driver = {
  65        .id_table = microread_mei_tbl,
  66        .name = MICROREAD_DRIVER_NAME,
  67
  68        .probe = microread_mei_probe,
  69        .remove = microread_mei_remove,
  70};
  71
  72module_mei_cl_driver(microread_driver);
  73
  74MODULE_LICENSE("GPL");
  75MODULE_DESCRIPTION(DRIVER_DESC);
  76