* @rcdev: reset controller entity
* @dev: reset controller device pointer
* @sci: TI SCI handle used for communication with system controller
- * @idr: idr structure for mapping ids to reset control structures
+ * @controls: maps ids to reset control structures
*/
struct ti_sci_reset_data {
struct reset_controller_dev rcdev;
struct device *dev;
const struct ti_sci_handle *sci;
- struct idr idr;
+ struct xarray controls;
};
#define to_ti_sci_reset_data(p) \
u32 reset_state;
int ret;
- control = idr_find(&data->idr, id);
+ control = xa_load(&data->controls, id);
if (!control)
return -EINVAL;
u32 reset_state;
int ret;
- control = idr_find(&data->idr, id);
+ control = xa_load(&data->controls, id);
if (!control)
return -EINVAL;
* is allocated and used to map to the reset control structure. This idr
* is used by the driver to do reset lookups.
*
- * Return: 0 for successful request, else a corresponding error value
+ * Return: ID for successful request, else a corresponding error value
*/
static int ti_sci_reset_of_xlate(struct reset_controller_dev *rcdev,
const struct of_phandle_args *reset_spec)
{
struct ti_sci_reset_data *data = to_ti_sci_reset_data(rcdev);
struct ti_sci_reset_control *control;
+ int id, err;
if (WARN_ON(reset_spec->args_count != rcdev->of_reset_n_cells))
return -EINVAL;
control->reset_mask = reset_spec->args[1];
mutex_init(&control->lock);
- return idr_alloc(&data->idr, control, 0, 0, GFP_KERNEL);
+ err = xa_alloc(&data->controls, &id, control, xa_limit_31b, GFP_KERNEL);
+ if (err < 0)
+ return err;
+ return id;
}
static const struct of_device_id ti_sci_reset_of_match[] = {
data->rcdev.of_reset_n_cells = 2;
data->rcdev.of_xlate = ti_sci_reset_of_xlate;
data->dev = &pdev->dev;
- idr_init(&data->idr);
+ xa_init_flags(&data->controls, XA_FLAGS_ALLOC);
platform_set_drvdata(pdev, data);
reset_controller_unregister(&data->rcdev);
- idr_destroy(&data->idr);
-
return 0;
}