Commit 9bfe54e3 authored by Matthew Wilcox (Oracle)'s avatar Matthew Wilcox (Oracle) Committed by Greg Kroah-Hartman

xilinx_sdfec: Convert to IDA

This driver does not use the lookup abilities of the IDR, so convert it
to the more space-efficient IDA.
Signed-off-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
Link: https://lore.kernel.org/r/20190807025050.28367-1-willy@infradead.orgSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent e00feed0
...@@ -26,8 +26,7 @@ ...@@ -26,8 +26,7 @@
#define DEV_NAME_LEN 12 #define DEV_NAME_LEN 12
static struct idr dev_idr; static DEFINE_IDA(dev_nrs);
static struct mutex dev_idr_lock;
/* Xilinx SDFEC Register Map */ /* Xilinx SDFEC Register Map */
/* CODE_WRI_PROTECT Register */ /* CODE_WRI_PROTECT Register */
...@@ -1374,13 +1373,6 @@ static void xsdfec_disable_all_clks(struct xsdfec_clks *clks) ...@@ -1374,13 +1373,6 @@ static void xsdfec_disable_all_clks(struct xsdfec_clks *clks)
clk_disable_unprepare(clks->axi_clk); clk_disable_unprepare(clks->axi_clk);
} }
static void xsdfec_idr_remove(struct xsdfec_dev *xsdfec)
{
mutex_lock(&dev_idr_lock);
idr_remove(&dev_idr, xsdfec->dev_id);
mutex_unlock(&dev_idr_lock);
}
static int xsdfec_probe(struct platform_device *pdev) static int xsdfec_probe(struct platform_device *pdev)
{ {
struct xsdfec_dev *xsdfec; struct xsdfec_dev *xsdfec;
...@@ -1435,9 +1427,7 @@ static int xsdfec_probe(struct platform_device *pdev) ...@@ -1435,9 +1427,7 @@ static int xsdfec_probe(struct platform_device *pdev)
} }
} }
mutex_lock(&dev_idr_lock); err = ida_alloc(&dev_nrs, GFP_KERNEL);
err = idr_alloc(&dev_idr, xsdfec->dev_name, 0, 0, GFP_KERNEL);
mutex_unlock(&dev_idr_lock);
if (err < 0) if (err < 0)
goto err_xsdfec_dev; goto err_xsdfec_dev;
xsdfec->dev_id = err; xsdfec->dev_id = err;
...@@ -1450,12 +1440,12 @@ static int xsdfec_probe(struct platform_device *pdev) ...@@ -1450,12 +1440,12 @@ static int xsdfec_probe(struct platform_device *pdev)
err = misc_register(&xsdfec->miscdev); err = misc_register(&xsdfec->miscdev);
if (err) { if (err) {
dev_err(dev, "error:%d. Unable to register device", err); dev_err(dev, "error:%d. Unable to register device", err);
goto err_xsdfec_idr; goto err_xsdfec_ida;
} }
return 0; return 0;
err_xsdfec_idr: err_xsdfec_ida:
xsdfec_idr_remove(xsdfec); ida_free(&dev_nrs, xsdfec->dev_id);
err_xsdfec_dev: err_xsdfec_dev:
xsdfec_disable_all_clks(&xsdfec->clks); xsdfec_disable_all_clks(&xsdfec->clks);
return err; return err;
...@@ -1467,7 +1457,7 @@ static int xsdfec_remove(struct platform_device *pdev) ...@@ -1467,7 +1457,7 @@ static int xsdfec_remove(struct platform_device *pdev)
xsdfec = platform_get_drvdata(pdev); xsdfec = platform_get_drvdata(pdev);
misc_deregister(&xsdfec->miscdev); misc_deregister(&xsdfec->miscdev);
xsdfec_idr_remove(xsdfec); ida_free(&dev_nrs, xsdfec->dev_id);
xsdfec_disable_all_clks(&xsdfec->clks); xsdfec_disable_all_clks(&xsdfec->clks);
return 0; return 0;
} }
...@@ -1493,8 +1483,6 @@ static int __init xsdfec_init(void) ...@@ -1493,8 +1483,6 @@ static int __init xsdfec_init(void)
{ {
int err; int err;
mutex_init(&dev_idr_lock);
idr_init(&dev_idr);
err = platform_driver_register(&xsdfec_driver); err = platform_driver_register(&xsdfec_driver);
if (err < 0) { if (err < 0) {
pr_err("%s Unabled to register SDFEC driver", __func__); pr_err("%s Unabled to register SDFEC driver", __func__);
...@@ -1506,7 +1494,6 @@ static int __init xsdfec_init(void) ...@@ -1506,7 +1494,6 @@ static int __init xsdfec_init(void)
static void __exit xsdfec_exit(void) static void __exit xsdfec_exit(void)
{ {
platform_driver_unregister(&xsdfec_driver); platform_driver_unregister(&xsdfec_driver);
idr_destroy(&dev_idr);
} }
module_init(xsdfec_init); module_init(xsdfec_init);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment