From: Matthew Wilcox Date: Mon, 18 Feb 2019 21:49:49 +0000 (-0500) Subject: reset: Convert reset-ti-sci to XArray X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=f3ca01cdfb67ef17f1feaa77eaea544746e6ecbb;p=users%2Fwilly%2Fxarray.git reset: Convert reset-ti-sci to XArray Signed-off-by: Matthew Wilcox --- diff --git a/drivers/reset/reset-ti-sci.c b/drivers/reset/reset-ti-sci.c index bf68729ab729..2a48caaa0754 100644 --- a/drivers/reset/reset-ti-sci.c +++ b/drivers/reset/reset-ti-sci.c @@ -39,13 +39,13 @@ struct ti_sci_reset_control { * @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) \ @@ -77,7 +77,7 @@ static int ti_sci_reset_set(struct reset_controller_dev *rcdev, u32 reset_state; int ret; - control = idr_find(&data->idr, id); + control = xa_load(&data->controls, id); if (!control) return -EINVAL; @@ -158,7 +158,7 @@ static int ti_sci_reset_status(struct reset_controller_dev *rcdev, u32 reset_state; int ret; - control = idr_find(&data->idr, id); + control = xa_load(&data->controls, id); if (!control) return -EINVAL; @@ -187,13 +187,14 @@ static const struct reset_control_ops ti_sci_reset_ops = { * 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; @@ -206,7 +207,10 @@ static int ti_sci_reset_of_xlate(struct reset_controller_dev *rcdev, 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[] = { @@ -236,7 +240,7 @@ static int ti_sci_reset_probe(struct platform_device *pdev) 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); @@ -249,8 +253,6 @@ static int ti_sci_reset_remove(struct platform_device *pdev) reset_controller_unregister(&data->rcdev); - idr_destroy(&data->idr); - return 0; }