Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1226352 > unrolled thread
| Started by | Lee Duncan <lduncan@suse.com> |
|---|---|
| First post | 2015-09-16 20:00 +0200 |
| Last post | 2015-09-16 20:00 +0200 |
| Articles | 5 — 1 participant |
Back to article view | Back to linux.kernel
[PATCH 00/17] Create and use ida and idr helper routines [RESEND] Lee Duncan <lduncan@suse.com> - 2015-09-16 20:00 +0200
[PATCH 17/17] Update the ARM soc base driver to use ida helper functions. Lee Duncan <lduncan@suse.com> - 2015-09-16 20:00 +0200
[PATCH 10/17] Update the DCA DMA driver to use idr helper functions. Lee Duncan <lduncan@suse.com> - 2015-09-16 20:00 +0200
[PATCH 12/17] Update the TI Flash Media driver to use idr helper functions. Lee Duncan <lduncan@suse.com> - 2015-09-16 20:00 +0200
[PATCH 13/17] Update the SCSI disk driver to use ida helper functions. Lee Duncan <lduncan@suse.com> - 2015-09-16 20:00 +0200
| From | Lee Duncan <lduncan@suse.com> |
|---|---|
| Date | 2015-09-16 20:00 +0200 |
| Subject | [PATCH 00/17] Create and use ida and idr helper routines [RESEND] |
| Message-ID | <q9p9T-3ca-3@gated-at.bofh.it> |
[Apologies if you see this twice. I had to resend it.] The idr index management library supplies two sets of routines for managing monotonically increasing index numbers. The "ida" set of routines manage allocating and freeing simple index numbers. The "idr" set of routines add the ability to save an arbitrary pointer with each index. Both sets of routines are used throughout the kernel, and it was noted that many of them use the same or similar calling sequences, making a helper function a useful addition. This set of patches adds some helper functions, defined as inline in <linux/idr.h>. In addition, any of the clients of these idr library functions that could benefit from using these helper functions where modified to use them. In addition to cleaning up the code in the clients of these functions, the SCSI hosts module, which used to use a simple atomic integer for index management is converted to using the idr set of routines to manage its index values as well as to simplify and speed up host number to instance lookups. I have functionally tested the SCSI host indexing change, and I have compile tested all of the other changes. The maintainers of each driver are cc-ed on the patch series, where available. Note: I did not mark this patch series as "v2" since the scope of the patch set has grown considerably since my first submissions. Summary: There is one patch that adds helper functions, 11 patches that use the new "idr" helper functions, and 5 that use the new "ida" helper functions. Lee Duncan (17): 1. Add ida and idr helper routines. 2. Update scsi hosts to use idr for host number mgmt 3. Update the st driver to use idr helper functions. 4. Update the ch driver to use idr helper functions. 5. Update the md driver to use idr helper functions. 6. Update the infiniband uverbs driver to use idr helper functions. 7. Update the memstick driver to use idr helper functions. 8. Update the mmc driver to use idr helper functions. 9. Update the virtgpu driver to use idr helper functions. 10. Update the DCA DMA driver to use idr helper functions. 11. Update the rtsx multifunction driver to use idr helper functions. 12. Update the TI Flash Media driver to use idr helper functions. 13. Update the SCSI disk driver to use ida helper functions. 14. Update the rsxx flash adapter driver to use ida helper functions. 15. Update the NVMe SSD driver to use ida helper functions. 16. Update the Micron PCIe SSD driver to use ida helper functions. 17. Update the ARM soc base driver to use ida helper functions. drivers/base/soc.c | 17 ++---- drivers/block/mtip32xx/mtip32xx.c | 22 ++------ drivers/block/nvme-core.c | 14 +---- drivers/block/rsxx/core.c | 16 +----- drivers/dca/dca-sysfs.c | 19 ++----- drivers/gpu/drm/virtio/virtgpu_vq.c | 15 ++---- drivers/infiniband/core/uverbs_cmd.c | 12 +---- drivers/md/dm.c | 22 ++------ drivers/memstick/core/memstick.c | 19 ++----- drivers/mfd/rtsx_pcr.c | 13 ++--- drivers/misc/tifm_core.c | 17 ++---- drivers/mmc/core/host.c | 14 ++--- drivers/scsi/ch.c | 14 ++--- drivers/scsi/hosts.c | 59 ++++++++++---------- drivers/scsi/sd.c | 20 ++----- drivers/scsi/st.c | 15 ++---- include/linux/idr.h | 102 +++++++++++++++++++++++++++++++++++ 17 files changed, 182 insertions(+), 228 deletions(-) -- 2.1.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | Lee Duncan <lduncan@suse.com> |
|---|---|
| Date | 2015-09-16 20:00 +0200 |
| Subject | [PATCH 17/17] Update the ARM soc base driver to use ida helper functions. |
| Message-ID | <q9p9X-3ca-95@gated-at.bofh.it> |
| In reply to | #1226352 |
Signed-off-by: Lee Duncan <lduncan@suse.com>
---
drivers/base/soc.c | 17 +++--------------
1 file changed, 3 insertions(+), 14 deletions(-)
diff --git a/drivers/base/soc.c b/drivers/base/soc.c
index 39fca01c8fa1..cf70c3246123 100644
--- a/drivers/base/soc.c
+++ b/drivers/base/soc.c
@@ -122,18 +122,7 @@ struct soc_device *soc_device_register(struct soc_device_attribute *soc_dev_attr
}
/* Fetch a unique (reclaimable) SOC ID. */
- do {
- if (!ida_pre_get(&soc_ida, GFP_KERNEL)) {
- ret = -ENOMEM;
- goto out2;
- }
-
- spin_lock(&soc_lock);
- ret = ida_get_new(&soc_ida, &soc_dev->soc_dev_num);
- spin_unlock(&soc_lock);
-
- } while (ret == -EAGAIN);
-
+ ret = ida_get_index(&soc_ida, &soc_lock, &soc_dev->soc_dev_num);
if (ret)
goto out2;
@@ -151,7 +140,7 @@ struct soc_device *soc_device_register(struct soc_device_attribute *soc_dev_attr
return soc_dev;
out3:
- ida_remove(&soc_ida, soc_dev->soc_dev_num);
+ ida_put_index(&soc_ida, &soc_lock, soc_dev->soc_dev_num);
out2:
kfree(soc_dev);
out1:
@@ -161,7 +150,7 @@ out1:
/* Ensure soc_dev->attr is freed prior to calling soc_device_unregister. */
void soc_device_unregister(struct soc_device *soc_dev)
{
- ida_remove(&soc_ida, soc_dev->soc_dev_num);
+ ida_put_index(&soc_ida, &soc_lock, soc_dev->soc_dev_num);
device_unregister(&soc_dev->dev);
}
--
2.1.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Lee Duncan <lduncan@suse.com> |
|---|---|
| Date | 2015-09-16 20:00 +0200 |
| Subject | [PATCH 10/17] Update the DCA DMA driver to use idr helper functions. |
| Message-ID | <q9p9X-3ca-99@gated-at.bofh.it> |
| In reply to | #1226352 |
Signed-off-by: Lee Duncan <lduncan@suse.com>
---
drivers/dca/dca-sysfs.c | 19 ++++---------------
1 file changed, 4 insertions(+), 15 deletions(-)
diff --git a/drivers/dca/dca-sysfs.c b/drivers/dca/dca-sysfs.c
index 126cf295b198..8930707df295 100644
--- a/drivers/dca/dca-sysfs.c
+++ b/drivers/dca/dca-sysfs.c
@@ -55,23 +55,14 @@ int dca_sysfs_add_provider(struct dca_provider *dca, struct device *dev)
struct device *cd;
int ret;
- idr_preload(GFP_KERNEL);
- spin_lock(&dca_idr_lock);
-
- ret = idr_alloc(&dca_idr, dca, 0, 0, GFP_NOWAIT);
- if (ret >= 0)
- dca->id = ret;
-
- spin_unlock(&dca_idr_lock);
- idr_preload_end();
+ ret = idr_get_index(&dca_idr, &dca_idr_lock, dca);
if (ret < 0)
return ret;
+ dca->id = ret;
cd = device_create(dca_class, dev, MKDEV(0, 0), NULL, "dca%d", dca->id);
if (IS_ERR(cd)) {
- spin_lock(&dca_idr_lock);
- idr_remove(&dca_idr, dca->id);
- spin_unlock(&dca_idr_lock);
+ idr_put_index(&dca_idr, &dca_idr_lock, dca->id);
return PTR_ERR(cd);
}
dca->cd = cd;
@@ -82,9 +73,7 @@ void dca_sysfs_remove_provider(struct dca_provider *dca)
{
device_unregister(dca->cd);
dca->cd = NULL;
- spin_lock(&dca_idr_lock);
- idr_remove(&dca_idr, dca->id);
- spin_unlock(&dca_idr_lock);
+ idr_put_index(&dca_idr, &dca_idr_lock, dca->id);
}
int __init dca_sysfs_init(void)
--
2.1.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Lee Duncan <lduncan@suse.com> |
|---|---|
| Date | 2015-09-16 20:00 +0200 |
| Subject | [PATCH 12/17] Update the TI Flash Media driver to use idr helper functions. |
| Message-ID | <q9p9X-3ca-115@gated-at.bofh.it> |
| In reply to | #1226352 |
Signed-off-by: Lee Duncan <lduncan@suse.com>
---
drivers/misc/tifm_core.c | 17 ++++-------------
1 file changed, 4 insertions(+), 13 deletions(-)
diff --git a/drivers/misc/tifm_core.c b/drivers/misc/tifm_core.c
index a511b2a713b3..46385f828a8f 100644
--- a/drivers/misc/tifm_core.c
+++ b/drivers/misc/tifm_core.c
@@ -198,22 +198,15 @@ int tifm_add_adapter(struct tifm_adapter *fm)
{
int rc;
- idr_preload(GFP_KERNEL);
- spin_lock(&tifm_adapter_lock);
- rc = idr_alloc(&tifm_adapter_idr, fm, 0, 0, GFP_NOWAIT);
- if (rc >= 0)
- fm->id = rc;
- spin_unlock(&tifm_adapter_lock);
- idr_preload_end();
+ rc = idr_get_index(&tifm_adapter_idr, &tifm_adapter_lock, fm);
if (rc < 0)
return rc;
+ fm->id = rc;
dev_set_name(&fm->dev, "tifm%u", fm->id);
rc = device_add(&fm->dev);
if (rc) {
- spin_lock(&tifm_adapter_lock);
- idr_remove(&tifm_adapter_idr, fm->id);
- spin_unlock(&tifm_adapter_lock);
+ idr_put_index(&tifm_adapter_idr, &tifm_adapter_lock, fm->id);
}
return rc;
@@ -230,9 +223,7 @@ void tifm_remove_adapter(struct tifm_adapter *fm)
device_unregister(&fm->sockets[cnt]->dev);
}
- spin_lock(&tifm_adapter_lock);
- idr_remove(&tifm_adapter_idr, fm->id);
- spin_unlock(&tifm_adapter_lock);
+ idr_put_index(&tifm_adapter_idr, &tifm_adapter_lock, fm->id);
device_del(&fm->dev);
}
EXPORT_SYMBOL(tifm_remove_adapter);
--
2.1.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Lee Duncan <lduncan@suse.com> |
|---|---|
| Date | 2015-09-16 20:00 +0200 |
| Subject | [PATCH 13/17] Update the SCSI disk driver to use ida helper functions. |
| Message-ID | <q9p9Y-3ca-129@gated-at.bofh.it> |
| In reply to | #1226352 |
Signed-off-by: Lee Duncan <lduncan@suse.com>
---
drivers/scsi/sd.c | 20 ++++----------------
1 file changed, 4 insertions(+), 16 deletions(-)
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 3b2fcb4fada0..60b2ad918208 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -2948,15 +2948,7 @@ static int sd_probe(struct device *dev)
if (!gd)
goto out_free;
- do {
- if (!ida_pre_get(&sd_index_ida, GFP_KERNEL))
- goto out_put;
-
- spin_lock(&sd_index_lock);
- error = ida_get_new(&sd_index_ida, &index);
- spin_unlock(&sd_index_lock);
- } while (error == -EAGAIN);
-
+ error = ida_get_index(&sd_index_ida, &sd_index_lock, &index);
if (error) {
sdev_printk(KERN_WARNING, sdp, "sd_probe: memory exhausted.\n");
goto out_put;
@@ -3001,9 +2993,7 @@ static int sd_probe(struct device *dev)
return 0;
out_free_index:
- spin_lock(&sd_index_lock);
- ida_remove(&sd_index_ida, index);
- spin_unlock(&sd_index_lock);
+ ida_put_index(&sd_index_ida, &sd_index_lock, index);
out_put:
put_disk(gd);
out_free:
@@ -3063,10 +3053,8 @@ static void scsi_disk_release(struct device *dev)
{
struct scsi_disk *sdkp = to_scsi_disk(dev);
struct gendisk *disk = sdkp->disk;
-
- spin_lock(&sd_index_lock);
- ida_remove(&sd_index_ida, sdkp->index);
- spin_unlock(&sd_index_lock);
+
+ ida_put_index(&sd_index_ida, &sd_index_lock, sdkp->index);
blk_integrity_unregister(disk);
disk->private_data = NULL;
--
2.1.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web