Loading include/net/nfc/nfc.h +1 −1 Original line number Diff line number Diff line Loading @@ -95,7 +95,7 @@ struct nfc_genl_data { }; struct nfc_dev { unsigned int idx; int idx; u32 target_next_idx; struct nfc_target *targets; int n_targets; Loading net/nfc/core.c +16 −7 Original line number Diff line number Diff line Loading @@ -40,6 +40,9 @@ int nfc_devlist_generation; DEFINE_MUTEX(nfc_devlist_mutex); /* NFC device ID bitmap */ static DEFINE_IDA(nfc_index_ida); /** * nfc_dev_up - turn on the NFC device * Loading Loading @@ -760,7 +763,6 @@ struct nfc_dev *nfc_allocate_device(struct nfc_ops *ops, u32 supported_protocols, int tx_headroom, int tx_tailroom) { static atomic_t dev_no = ATOMIC_INIT(0); struct nfc_dev *dev; if (!ops->start_poll || !ops->stop_poll || !ops->activate_target || Loading @@ -774,11 +776,6 @@ struct nfc_dev *nfc_allocate_device(struct nfc_ops *ops, if (!dev) return NULL; dev->dev.class = &nfc_class; dev->idx = atomic_inc_return(&dev_no) - 1; dev_set_name(&dev->dev, "nfc%d", dev->idx); device_initialize(&dev->dev); dev->ops = ops; dev->supported_protocols = supported_protocols; dev->tx_headroom = tx_headroom; Loading Loading @@ -814,6 +811,14 @@ int nfc_register_device(struct nfc_dev *dev) pr_debug("dev_name=%s\n", dev_name(&dev->dev)); dev->idx = ida_simple_get(&nfc_index_ida, 0, 0, GFP_KERNEL); if (dev->idx < 0) return dev->idx; dev->dev.class = &nfc_class; dev_set_name(&dev->dev, "nfc%d", dev->idx); device_initialize(&dev->dev); mutex_lock(&nfc_devlist_mutex); nfc_devlist_generation++; rc = device_add(&dev->dev); Loading Loading @@ -842,10 +847,12 @@ EXPORT_SYMBOL(nfc_register_device); */ void nfc_unregister_device(struct nfc_dev *dev) { int rc; int rc, id; pr_debug("dev_name=%s\n", dev_name(&dev->dev)); id = dev->idx; mutex_lock(&nfc_devlist_mutex); nfc_devlist_generation++; Loading @@ -864,6 +871,8 @@ void nfc_unregister_device(struct nfc_dev *dev) pr_debug("The userspace won't be notified that the device %s was removed\n", dev_name(&dev->dev)); ida_simple_remove(&nfc_index_ida, id); } EXPORT_SYMBOL(nfc_unregister_device); Loading Loading
include/net/nfc/nfc.h +1 −1 Original line number Diff line number Diff line Loading @@ -95,7 +95,7 @@ struct nfc_genl_data { }; struct nfc_dev { unsigned int idx; int idx; u32 target_next_idx; struct nfc_target *targets; int n_targets; Loading
net/nfc/core.c +16 −7 Original line number Diff line number Diff line Loading @@ -40,6 +40,9 @@ int nfc_devlist_generation; DEFINE_MUTEX(nfc_devlist_mutex); /* NFC device ID bitmap */ static DEFINE_IDA(nfc_index_ida); /** * nfc_dev_up - turn on the NFC device * Loading Loading @@ -760,7 +763,6 @@ struct nfc_dev *nfc_allocate_device(struct nfc_ops *ops, u32 supported_protocols, int tx_headroom, int tx_tailroom) { static atomic_t dev_no = ATOMIC_INIT(0); struct nfc_dev *dev; if (!ops->start_poll || !ops->stop_poll || !ops->activate_target || Loading @@ -774,11 +776,6 @@ struct nfc_dev *nfc_allocate_device(struct nfc_ops *ops, if (!dev) return NULL; dev->dev.class = &nfc_class; dev->idx = atomic_inc_return(&dev_no) - 1; dev_set_name(&dev->dev, "nfc%d", dev->idx); device_initialize(&dev->dev); dev->ops = ops; dev->supported_protocols = supported_protocols; dev->tx_headroom = tx_headroom; Loading Loading @@ -814,6 +811,14 @@ int nfc_register_device(struct nfc_dev *dev) pr_debug("dev_name=%s\n", dev_name(&dev->dev)); dev->idx = ida_simple_get(&nfc_index_ida, 0, 0, GFP_KERNEL); if (dev->idx < 0) return dev->idx; dev->dev.class = &nfc_class; dev_set_name(&dev->dev, "nfc%d", dev->idx); device_initialize(&dev->dev); mutex_lock(&nfc_devlist_mutex); nfc_devlist_generation++; rc = device_add(&dev->dev); Loading Loading @@ -842,10 +847,12 @@ EXPORT_SYMBOL(nfc_register_device); */ void nfc_unregister_device(struct nfc_dev *dev) { int rc; int rc, id; pr_debug("dev_name=%s\n", dev_name(&dev->dev)); id = dev->idx; mutex_lock(&nfc_devlist_mutex); nfc_devlist_generation++; Loading @@ -864,6 +871,8 @@ void nfc_unregister_device(struct nfc_dev *dev) pr_debug("The userspace won't be notified that the device %s was removed\n", dev_name(&dev->dev)); ida_simple_remove(&nfc_index_ida, id); } EXPORT_SYMBOL(nfc_unregister_device); Loading