From e2b63f79b8f3d88e281a25f71b831cc9e85e0377 Mon Sep 17 00:00:00 2001 From: Matthew Wilcox Date: Mon, 18 Feb 2019 09:49:21 -0500 Subject: [PATCH] ac97: Convert ac97_adapter_idr to XArray Signed-off-by: Matthew Wilcox --- include/sound/ac97/controller.h | 2 -- sound/ac97/bus.c | 16 ++++++---------- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/include/sound/ac97/controller.h b/include/sound/ac97/controller.h index 06b5afb7fa6b..64d8bdf68790 100644 --- a/include/sound/ac97/controller.h +++ b/include/sound/ac97/controller.h @@ -17,7 +17,6 @@ struct ac97_controller_ops; /** * struct ac97_controller - The AC97 controller of the AC-Link * @ops: the AC97 operations. - * @controllers: linked list of all existing controllers. * @adap: the shell device ac97-%d, ie. ac97 adapter * @nr: the number of the shell device * @slots_available: the mask of accessible/scanable codecs. @@ -30,7 +29,6 @@ struct ac97_controller_ops; */ struct ac97_controller { const struct ac97_controller_ops *ops; - struct list_head controllers; struct device adap; int nr; unsigned short slots_available; diff --git a/sound/ac97/bus.c b/sound/ac97/bus.c index 7985dd8198b6..fae3668f4401 100644 --- a/sound/ac97/bus.c +++ b/sound/ac97/bus.c @@ -7,7 +7,6 @@ #include #include #include -#include #include #include #include @@ -15,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -22,11 +22,10 @@ #include "ac97_core.h" /* - * Protects ac97_controllers and each ac97_controller structure. + * Protects each ac97_controller structure. */ static DEFINE_MUTEX(ac97_controllers_mutex); -static DEFINE_IDR(ac97_adapter_idr); -static LIST_HEAD(ac97_controllers); +static DEFINE_XARRAY_ALLOC(ac97_adapters); static struct bus_type ac97_bus_type; @@ -287,7 +286,6 @@ static void ac97_del_adapter(struct ac97_controller *ac97_ctrl) { mutex_lock(&ac97_controllers_mutex); ac97_ctrl_codecs_unregister(ac97_ctrl); - list_del(&ac97_ctrl->controllers); mutex_unlock(&ac97_controllers_mutex); device_unregister(&ac97_ctrl->adap); @@ -298,7 +296,7 @@ static void ac97_adapter_release(struct device *dev) struct ac97_controller *ac97_ctrl; ac97_ctrl = to_ac97_controller(dev); - idr_remove(&ac97_adapter_idr, ac97_ctrl->nr); + xa_erase(&ac97_adapters, ac97_ctrl->nr); dev_dbg(&ac97_ctrl->adap, "adapter unregistered by %s\n", dev_name(ac97_ctrl->parent)); } @@ -313,8 +311,8 @@ static int ac97_add_adapter(struct ac97_controller *ac97_ctrl) int ret; mutex_lock(&ac97_controllers_mutex); - ret = idr_alloc(&ac97_adapter_idr, ac97_ctrl, 0, 0, GFP_KERNEL); - ac97_ctrl->nr = ret; + ret = xa_alloc(&ac97_adapters, &ac97_ctrl->nr, ac97_ctrl, + xa_limit_32b, GFP_KERNEL); if (ret >= 0) { dev_set_name(&ac97_ctrl->adap, "ac97-%d", ret); ac97_ctrl->adap.type = &ac97_adapter_type; @@ -323,8 +321,6 @@ static int ac97_add_adapter(struct ac97_controller *ac97_ctrl) if (ret) put_device(&ac97_ctrl->adap); } - if (!ret) - list_add(&ac97_ctrl->controllers, &ac97_controllers); mutex_unlock(&ac97_controllers_mutex); if (!ret) -- 2.50.1