]> www.infradead.org Git - users/willy/xarray.git/commitdiff
reset: Convert reset-ti-sci to XArray
authorMatthew Wilcox <willy@infradead.org>
Mon, 18 Feb 2019 21:49:49 +0000 (16:49 -0500)
committerMatthew Wilcox (Oracle) <willy@infradead.org>
Fri, 9 Aug 2019 01:38:18 +0000 (21:38 -0400)
Signed-off-by: Matthew Wilcox <willy@infradead.org>
drivers/reset/reset-ti-sci.c

index bf68729ab72925ea1df58cfb67130db4d151a0e4..2a48caaa07545b0e191a1cb2ebaa231f9fd827e9 100644 (file)
@@ -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;
 }