Skip to content

Commit

Permalink
Merge tag 'nfc-next-4.15-1' of git://git.kernel.org/pub/scm/linux/ker…
Browse files Browse the repository at this point in the history
…nel/git/sameo/nfc-next

Samuel Ortiz says:

====================
NFC 4.15 pull request

This is the NFC pull request for 4.15. We have:

- A new netlink command for explicitly deactivating NFC targets
- i2c constification for all NFC drivers
- One NFC device allocation error path fix
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David S. Miller committed Nov 13, 2017
2 parents fd9080a + 4d63adf commit 6afce19
Show file tree
Hide file tree
Showing 17 changed files with 64 additions and 42 deletions.
2 changes: 1 addition & 1 deletion drivers/nfc/fdp/fdp.c
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@ static struct nci_driver_ops fdp_prop_ops[] = {
},
};

struct nci_ops nci_ops = {
static struct nci_ops nci_ops = {
.open = fdp_nci_open,
.close = fdp_nci_close,
.send = fdp_nci_send,
Expand Down
2 changes: 1 addition & 1 deletion drivers/nfc/microread/i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ static int microread_i2c_remove(struct i2c_client *client)
return 0;
}

static struct i2c_device_id microread_i2c_id[] = {
static const struct i2c_device_id microread_i2c_id[] = {
{ MICROREAD_I2C_DRIVER_NAME, 0},
{ }
};
Expand Down
2 changes: 1 addition & 1 deletion drivers/nfc/nfcmrvl/i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ static const struct of_device_id of_nfcmrvl_i2c_match[] = {
};
MODULE_DEVICE_TABLE(of, of_nfcmrvl_i2c_match);

static struct i2c_device_id nfcmrvl_i2c_id_table[] = {
static const struct i2c_device_id nfcmrvl_i2c_id_table[] = {
{ "nfcmrvl_i2c", 0 },
{}
};
Expand Down
2 changes: 1 addition & 1 deletion drivers/nfc/nxp-nci/i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ static int nxp_nci_i2c_remove(struct i2c_client *client)
return 0;
}

static struct i2c_device_id nxp_nci_i2c_id_table[] = {
static const struct i2c_device_id nxp_nci_i2c_id_table[] = {
{"nxp-nci_i2c", 0},
{}
};
Expand Down
2 changes: 1 addition & 1 deletion drivers/nfc/pn533/i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ static const struct of_device_id of_pn533_i2c_match[] = {
};
MODULE_DEVICE_TABLE(of, of_pn533_i2c_match);

static struct i2c_device_id pn533_i2c_id_table[] = {
static const struct i2c_device_id pn533_i2c_id_table[] = {
{ PN533_I2C_DRIVER_NAME, 0 },
{}
};
Expand Down
2 changes: 1 addition & 1 deletion drivers/nfc/pn544/i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
#define PN544_HCI_I2C_LLC_MAX_SIZE (PN544_HCI_I2C_LLC_LEN_CRC + 1 + \
PN544_HCI_I2C_LLC_MAX_PAYLOAD)

static struct i2c_device_id pn544_hci_i2c_id_table[] = {
static const struct i2c_device_id pn544_hci_i2c_id_table[] = {
{"pn544", 0},
{}
};
Expand Down
2 changes: 1 addition & 1 deletion drivers/nfc/s3fwrn5/firmware.c
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ static int s3fwrn5_fw_get_base_addr(
struct s3fwrn5_fw_cmd_get_bootinfo_rsp *bootinfo, u32 *base_addr)
{
int i;
struct {
static const struct {
u8 version[4];
u32 base_addr;
} match[] = {
Expand Down
2 changes: 1 addition & 1 deletion drivers/nfc/s3fwrn5/i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ static int s3fwrn5_i2c_remove(struct i2c_client *client)
return 0;
}

static struct i2c_device_id s3fwrn5_i2c_id_table[] = {
static const struct i2c_device_id s3fwrn5_i2c_id_table[] = {
{S3FWRN5_I2C_DRIVER_NAME, 0},
{}
};
Expand Down
2 changes: 1 addition & 1 deletion drivers/nfc/st-nci/i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ static int st_nci_i2c_remove(struct i2c_client *client)
return 0;
}

static struct i2c_device_id st_nci_i2c_id_table[] = {
static const struct i2c_device_id st_nci_i2c_id_table[] = {
{ST_NCI_DRIVER_NAME, 0},
{}
};
Expand Down
2 changes: 1 addition & 1 deletion drivers/nfc/st21nfca/i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ static int st21nfca_hci_i2c_remove(struct i2c_client *client)
return 0;
}

static struct i2c_device_id st21nfca_hci_i2c_id_table[] = {
static const struct i2c_device_id st21nfca_hci_i2c_id_table[] = {
{ST21NFCA_HCI_DRIVER_NAME, 0},
{}
};
Expand Down
2 changes: 2 additions & 0 deletions include/uapi/linux/nfc.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
* @NFC_CMD_ACTIVATE_TARGET: Request NFC controller to reactivate target.
* @NFC_CMD_VENDOR: Vendor specific command, to be implemented directly
* from the driver in order to support hardware specific operations.
* @NFC_CMD_DEACTIVATE_TARGET: Request NFC controller to deactivate target.
*/
enum nfc_commands {
NFC_CMD_UNSPEC,
Expand Down Expand Up @@ -121,6 +122,7 @@ enum nfc_commands {
NFC_CMD_SE_IO,
NFC_CMD_ACTIVATE_TARGET,
NFC_CMD_VENDOR,
NFC_CMD_DEACTIVATE_TARGET,
/* private: internal use only */
__NFC_CMD_AFTER_LAST
};
Expand Down
10 changes: 4 additions & 6 deletions net/nfc/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1015,9 +1015,9 @@ static void nfc_check_pres_work(struct work_struct *work)
device_unlock(&dev->dev);
}

static void nfc_check_pres_timeout(unsigned long data)
static void nfc_check_pres_timeout(struct timer_list *t)
{
struct nfc_dev *dev = (struct nfc_dev *)data;
struct nfc_dev *dev = from_timer(dev, t, check_pres_timer);

schedule_work(&dev->check_pres_work);
}
Expand Down Expand Up @@ -1094,9 +1094,7 @@ struct nfc_dev *nfc_allocate_device(struct nfc_ops *ops,
dev->targets_generation = 1;

if (ops->check_presence) {
setup_timer(&dev->check_pres_timer, nfc_check_pres_timeout,
(unsigned long)dev);

timer_setup(&dev->check_pres_timer, nfc_check_pres_timeout, 0);
INIT_WORK(&dev->check_pres_work, nfc_check_pres_work);
}

Expand All @@ -1105,7 +1103,7 @@ struct nfc_dev *nfc_allocate_device(struct nfc_ops *ops,
err_free_dev:
kfree(dev);

return ERR_PTR(rc);
return NULL;
}
EXPORT_SYMBOL(nfc_allocate_device);

Expand Down
1 change: 1 addition & 0 deletions net/nfc/digital_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,7 @@ static void digital_deactivate_target(struct nfc_dev *nfc_dev,
return;
}

digital_abort_cmd(ddev);
ddev->curr_protocol = 0;
}

Expand Down
7 changes: 3 additions & 4 deletions net/nfc/hci/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -428,9 +428,9 @@ void nfc_hci_event_received(struct nfc_hci_dev *hdev, u8 pipe, u8 event,
nfc_hci_driver_failure(hdev, r);
}

static void nfc_hci_cmd_timeout(unsigned long data)
static void nfc_hci_cmd_timeout(struct timer_list *t)
{
struct nfc_hci_dev *hdev = (struct nfc_hci_dev *)data;
struct nfc_hci_dev *hdev = from_timer(hdev, t, cmd_timer);

schedule_work(&hdev->msg_tx_work);
}
Expand Down Expand Up @@ -1004,8 +1004,7 @@ int nfc_hci_register_device(struct nfc_hci_dev *hdev)

INIT_WORK(&hdev->msg_tx_work, nfc_hci_msg_tx_work);

setup_timer(&hdev->cmd_timer, nfc_hci_cmd_timeout,
(unsigned long)hdev);
timer_setup(&hdev->cmd_timer, nfc_hci_cmd_timeout, 0);

skb_queue_head_init(&hdev->rx_hcp_frags);

Expand Down
23 changes: 9 additions & 14 deletions net/nfc/hci/llc_shdlc.c
Original file line number Diff line number Diff line change
Expand Up @@ -580,27 +580,27 @@ static void llc_shdlc_handle_send_queue(struct llc_shdlc *shdlc)
}
}

static void llc_shdlc_connect_timeout(unsigned long data)
static void llc_shdlc_connect_timeout(struct timer_list *t)
{
struct llc_shdlc *shdlc = (struct llc_shdlc *)data;
struct llc_shdlc *shdlc = from_timer(shdlc, t, connect_timer);

pr_debug("\n");

schedule_work(&shdlc->sm_work);
}

static void llc_shdlc_t1_timeout(unsigned long data)
static void llc_shdlc_t1_timeout(struct timer_list *t)
{
struct llc_shdlc *shdlc = (struct llc_shdlc *)data;
struct llc_shdlc *shdlc = from_timer(shdlc, t, t1_timer);

pr_debug("SoftIRQ: need to send ack\n");

schedule_work(&shdlc->sm_work);
}

static void llc_shdlc_t2_timeout(unsigned long data)
static void llc_shdlc_t2_timeout(struct timer_list *t)
{
struct llc_shdlc *shdlc = (struct llc_shdlc *)data;
struct llc_shdlc *shdlc = from_timer(shdlc, t, t2_timer);

pr_debug("SoftIRQ: need to retransmit\n");

Expand Down Expand Up @@ -763,14 +763,9 @@ static void *llc_shdlc_init(struct nfc_hci_dev *hdev, xmit_to_drv_t xmit_to_drv,
mutex_init(&shdlc->state_mutex);
shdlc->state = SHDLC_DISCONNECTED;

setup_timer(&shdlc->connect_timer, llc_shdlc_connect_timeout,
(unsigned long)shdlc);

setup_timer(&shdlc->t1_timer, llc_shdlc_t1_timeout,
(unsigned long)shdlc);

setup_timer(&shdlc->t2_timer, llc_shdlc_t2_timeout,
(unsigned long)shdlc);
timer_setup(&shdlc->connect_timer, llc_shdlc_connect_timeout, 0);
timer_setup(&shdlc->t1_timer, llc_shdlc_t1_timeout, 0);
timer_setup(&shdlc->t2_timer, llc_shdlc_t2_timeout, 0);

shdlc->w = SHDLC_MAX_WINDOW;
shdlc->srej_support = SHDLC_SREJ_SUPPORT;
Expand Down
14 changes: 6 additions & 8 deletions net/nfc/llcp_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,9 @@ static void nfc_llcp_timeout_work(struct work_struct *work)
nfc_dep_link_down(local->dev);
}

static void nfc_llcp_symm_timer(unsigned long data)
static void nfc_llcp_symm_timer(struct timer_list *t)
{
struct nfc_llcp_local *local = (struct nfc_llcp_local *) data;
struct nfc_llcp_local *local = from_timer(local, t, link_timer);

pr_err("SYMM timeout\n");

Expand Down Expand Up @@ -285,9 +285,9 @@ static void nfc_llcp_sdreq_timeout_work(struct work_struct *work)
nfc_genl_llc_send_sdres(local->dev, &nl_sdres_list);
}

static void nfc_llcp_sdreq_timer(unsigned long data)
static void nfc_llcp_sdreq_timer(struct timer_list *t)
{
struct nfc_llcp_local *local = (struct nfc_llcp_local *) data;
struct nfc_llcp_local *local = from_timer(local, t, sdreq_timer);

schedule_work(&local->sdreq_timeout_work);
}
Expand Down Expand Up @@ -1573,8 +1573,7 @@ int nfc_llcp_register_device(struct nfc_dev *ndev)
INIT_LIST_HEAD(&local->list);
kref_init(&local->ref);
mutex_init(&local->sdp_lock);
setup_timer(&local->link_timer, nfc_llcp_symm_timer,
(unsigned long)local);
timer_setup(&local->link_timer, nfc_llcp_symm_timer, 0);

skb_queue_head_init(&local->tx_queue);
INIT_WORK(&local->tx_work, nfc_llcp_tx_work);
Expand All @@ -1600,8 +1599,7 @@ int nfc_llcp_register_device(struct nfc_dev *ndev)

mutex_init(&local->sdreq_lock);
INIT_HLIST_HEAD(&local->pending_sdreqs);
setup_timer(&local->sdreq_timer, nfc_llcp_sdreq_timer,
(unsigned long)local);
timer_setup(&local->sdreq_timer, nfc_llcp_sdreq_timer, 0);
INIT_WORK(&local->sdreq_timeout_work, nfc_llcp_sdreq_timeout_work);

list_add(&local->list, &llcp_devices);
Expand Down
29 changes: 29 additions & 0 deletions net/nfc/netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -928,6 +928,30 @@ static int nfc_genl_activate_target(struct sk_buff *skb, struct genl_info *info)
return rc;
}

static int nfc_genl_deactivate_target(struct sk_buff *skb,
struct genl_info *info)
{
struct nfc_dev *dev;
u32 device_idx, target_idx;
int rc;

if (!info->attrs[NFC_ATTR_DEVICE_INDEX])
return -EINVAL;

device_idx = nla_get_u32(info->attrs[NFC_ATTR_DEVICE_INDEX]);

dev = nfc_get_device(device_idx);
if (!dev)
return -ENODEV;

target_idx = nla_get_u32(info->attrs[NFC_ATTR_TARGET_INDEX]);

rc = nfc_deactivate_target(dev, target_idx, NFC_TARGET_MODE_SLEEP);

nfc_put_device(dev);
return rc;
}

static int nfc_genl_dep_link_up(struct sk_buff *skb, struct genl_info *info)
{
struct nfc_dev *dev;
Expand Down Expand Up @@ -1751,6 +1775,11 @@ static const struct genl_ops nfc_genl_ops[] = {
.doit = nfc_genl_vendor_cmd,
.policy = nfc_genl_policy,
},
{
.cmd = NFC_CMD_DEACTIVATE_TARGET,
.doit = nfc_genl_deactivate_target,
.policy = nfc_genl_policy,
},
};

static struct genl_family nfc_genl_family __ro_after_init = {
Expand Down

0 comments on commit 6afce19

Please sign in to comment.