Skip to content

Commit

Permalink
NFC: microread: Fix mei physical layer
Browse files Browse the repository at this point in the history
The MEI bus API changed according to the latest comments from the char-misc
maintainers, and this patch fixes the microread mei physical layer code
according to those changes:
We pass the MEI id back to the probe routine, and the mei_driver takes a
table of MEI ids instead of one static id.
Also, mei_bus_driver got renamed to mei_driver, mei_bus_client to
mei_device, and mei_bus_set/get_clientdata to mei_set/get_clientdata.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
  • Loading branch information
Samuel Ortiz committed Feb 11, 2013
1 parent 8708aac commit cd48d8b
Showing 1 changed file with 24 additions and 19 deletions.
43 changes: 24 additions & 19 deletions drivers/nfc/microread/mei.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ struct mei_nfc_hdr {
#define MEI_NFC_MAX_READ (MEI_NFC_HEADER_SIZE + MEI_NFC_MAX_HCI_PAYLOAD)

struct microread_mei_phy {
struct mei_bus_client *client;
struct mei_device *mei_device;
struct nfc_hci_dev *hdev;

int powered;
Expand Down Expand Up @@ -105,30 +105,30 @@ static int microread_mei_write(void *phy_id, struct sk_buff *skb)

MEI_DUMP_SKB_OUT("mei frame sent", skb);

r = mei_bus_send(phy->client, skb->data, skb->len);
r = mei_send(phy->device, skb->data, skb->len);
if (r > 0)
r = 0;

return r;
}

static void microread_event_cb(struct mei_bus_client *client, u32 events,
static void microread_event_cb(struct mei_device *device, u32 events,
void *context)
{
struct microread_mei_phy *phy = context;

if (phy->hard_fault != 0)
return;

if (events & BIT(MEI_BUS_EVENT_RX)) {
if (events & BIT(MEI_EVENT_RX)) {
struct sk_buff *skb;
int reply_size;

skb = alloc_skb(MEI_NFC_MAX_READ, GFP_KERNEL);
if (!skb)
return;

reply_size = mei_bus_recv(client, skb->data, MEI_NFC_MAX_READ);
reply_size = mei_recv(device, skb->data, MEI_NFC_MAX_READ);
if (reply_size < MEI_NFC_HEADER_SIZE) {
kfree(skb);
return;
Expand All @@ -149,7 +149,8 @@ static struct nfc_phy_ops mei_phy_ops = {
.disable = microread_mei_disable,
};

static int microread_mei_probe(struct mei_bus_client *client)
static int microread_mei_probe(struct mei_device *device,
const struct mei_id *id)
{
struct microread_mei_phy *phy;
int r;
Expand All @@ -162,10 +163,10 @@ static int microread_mei_probe(struct mei_bus_client *client)
return -ENOMEM;
}

phy->client = client;
mei_bus_set_clientdata(client, phy);
phy->device = device;
mei_set_clientdata(device, phy);

r = mei_bus_register_event_cb(client, microread_event_cb, phy);
r = mei_register_event_cb(device, microread_event_cb, phy);
if (r) {
pr_err(MICROREAD_DRIVER_NAME ": event cb registration failed\n");
goto err_out;
Expand All @@ -185,9 +186,9 @@ static int microread_mei_probe(struct mei_bus_client *client)
return r;
}

static int microread_mei_remove(struct mei_bus_client *client)
static int microread_mei_remove(struct mei_device *device)
{
struct microread_mei_phy *phy = mei_bus_get_clientdata(client);
struct microread_mei_phy *phy = mei_get_clientdata(device);

pr_info("Removing microread\n");

Expand All @@ -201,14 +202,18 @@ static int microread_mei_remove(struct mei_bus_client *client)
return 0;
}

static struct mei_bus_driver microread_driver = {
.driver = {
.name = MICROREAD_DRIVER_NAME,
},
.id = {
.name = MICROREAD_DRIVER_NAME,
.uuid = MICROREAD_UUID,
},
static struct mei_id microread_mei_tbl[] = {
{ MICROREAD_DRIVER_NAME, MICROREAD_UUID },

/* required last entry */
{ }
};

MODULE_DEVICE_TABLE(mei, microread_mei_tbl);

static struct mei_driver microread_driver = {
.id_table = microread_mei_tbl,
.name = MICROREAD_DRIVER_NAME,

.probe = microread_mei_probe,
.remove = microread_mei_remove,
Expand Down

0 comments on commit cd48d8b

Please sign in to comment.