[PATCH 4/4] NFC: nxp-nci: Allow module removal during download

From: clement . perrochaud
Date: Thu Jan 22 2015 - 10:58:12 EST


From: ClÃment Perrochaud <clement.perrochaud@xxxxxxx>

Signed-off-by: ClÃment Perrochaud <clement.perrochaud@xxxxxxx>
Signed-off-by: ClÃment Perrochaud <clement.perrochaud@xxxxxxxxxxxx>
---
drivers/nfc/nxp-nci/core.c | 7 +++----
drivers/nfc/nxp-nci/firmware.c | 9 ++++++---
2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/nfc/nxp-nci/core.c b/drivers/nfc/nxp-nci/core.c
index d3643ef..c15606d 100644
--- a/drivers/nfc/nxp-nci/core.c
+++ b/drivers/nfc/nxp-nci/core.c
@@ -165,12 +165,11 @@ void nxp_nci_remove(struct nci_dev *ndev)
{
struct nxp_nci_info *info = nci_get_drvdata(ndev);

- mutex_lock(&info->info_lock);
-
- cancel_work_sync(&info->fw_info.work);
-
if (info->mode == NXP_NCI_MODE_FW)
nxp_nci_fw_work_complete(info, -ESHUTDOWN);
+ cancel_work_sync(&info->fw_info.work);
+
+ mutex_lock(&info->info_lock);

if (info->phy_ops->disable)
info->phy_ops->disable(info->phy_id);
diff --git a/drivers/nfc/nxp-nci/firmware.c b/drivers/nfc/nxp-nci/firmware.c
index 1814e9f..de136e1 100644
--- a/drivers/nfc/nxp-nci/firmware.c
+++ b/drivers/nfc/nxp-nci/firmware.c
@@ -166,7 +166,8 @@ static int nxp_nci_fw_send(struct nxp_nci_info *info)

if (*fw_info->data == NXP_NCI_FW_CMD_RESET) {
fw_info->cmd_result = 0;
- schedule_work(&fw_info->work);
+ if (fw_info->fw)
+ schedule_work(&fw_info->work);
} else {
completion_rc = wait_for_completion_interruptible_timeout(
&fw_info->cmd_completion, NXP_NCI_FW_ANSWER_TIMEOUT);
@@ -244,7 +245,8 @@ int nxp_nci_fw_download(struct nci_dev *ndev, const char *firmware_name)
fw_info->frame_size = 0;
fw_info->cmd_result = 0;

- schedule_work(&fw_info->work);
+ if (fw_info->fw)
+ schedule_work(&fw_info->work);

fw_download_exit:
mutex_unlock(&info->info_lock);
@@ -316,6 +318,7 @@ void nxp_nci_fw_recv_frame(struct nci_dev *ndev, struct sk_buff *skb)
fw_info->cmd_result = -EIO;
}

- schedule_work(&fw_info->work);
+ if (fw_info->fw)
+ schedule_work(&fw_info->work);
}
EXPORT_SYMBOL(nxp_nci_fw_recv_frame);
--
ClÃment Perrochaud

Eff'Innov Technologies
Caen, Aix-En-Provence, Grenoble

Eff'Innov Technologies
Campus EffiScience
2, Esplanade Anton Philips
14460 Colombelles, FRANCE

http://www.effinnov.com

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/