提交 d94f9c55 编写于 作者: E Eric Lapuyade 提交者: John W. Linville

NFC: nfc_targets_found() should accept zero target found

The semantics for a zero target found event is that the polling operation
could not complete.
Signed-off-by: NEric Lapuyade <eric.lapuyade@intel.com>
Signed-off-by: NSamuel Ortiz <sameo@linux.intel.com>
上级 8668fdd6
...@@ -560,6 +560,8 @@ EXPORT_SYMBOL(nfc_alloc_recv_skb); ...@@ -560,6 +560,8 @@ EXPORT_SYMBOL(nfc_alloc_recv_skb);
* The device driver must call this function when one or many nfc targets * The device driver must call this function when one or many nfc targets
* are found. After calling this function, the device driver must stop * are found. After calling this function, the device driver must stop
* polling for targets. * polling for targets.
* NOTE: This function can be called with targets=NULL and n_targets=0 to
* notify a driver error, meaning that the polling operation cannot complete.
* IMPORTANT: this function must not be called from an atomic context. * IMPORTANT: this function must not be called from an atomic context.
* In addition, it must also not be called from a context that would prevent * In addition, it must also not be called from a context that would prevent
* the NFC Core to call other nfc ops entry point concurrently. * the NFC Core to call other nfc ops entry point concurrently.
...@@ -586,7 +588,11 @@ int nfc_targets_found(struct nfc_dev *dev, ...@@ -586,7 +588,11 @@ int nfc_targets_found(struct nfc_dev *dev,
dev->targets_generation++; dev->targets_generation++;
kfree(dev->targets); kfree(dev->targets);
dev->targets = kmemdup(targets, n_targets * sizeof(struct nfc_target), dev->targets = NULL;
if (targets) {
dev->targets = kmemdup(targets,
n_targets * sizeof(struct nfc_target),
GFP_ATOMIC); GFP_ATOMIC);
if (!dev->targets) { if (!dev->targets) {
...@@ -594,6 +600,7 @@ int nfc_targets_found(struct nfc_dev *dev, ...@@ -594,6 +600,7 @@ int nfc_targets_found(struct nfc_dev *dev,
device_unlock(&dev->dev); device_unlock(&dev->dev);
return -ENOMEM; return -ENOMEM;
} }
}
dev->n_targets = n_targets; dev->n_targets = n_targets;
device_unlock(&dev->dev); device_unlock(&dev->dev);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册