Re: [PATCH v3 9/9] driver core: Introduce device_iter_t for device iterating APIs
From: Jonathan Cameron
Date: Mon Dec 16 2024 - 10:34:34 EST
On Thu, 12 Dec 2024 21:38:45 +0800
Zijun Hu <zijun_hu@xxxxxxxxxx> wrote:
> From: Zijun Hu <quic_zijuhu@xxxxxxxxxxx>
>
> There are several for_each APIs which has parameter with type below:
> int (*fn)(struct device *dev, void *data)
> They iterate over various device lists and call @fn() for each device
> with caller provided data @*data, and they usually need to modify @*data.
>
> Give the type an dedicated typedef with advantages shown below:
> typedef int (*device_iter_t)(struct device *dev, void *data)
>
> - Shorter API declarations and definitions
> - Prevent further for_each APIs from using bad parameter type
>
> So introduce device_iter_t and apply it to various existing APIs below:
> bus_for_each_dev()
> (class|driver)_for_each_device()
> device_for_each_child(_reverse|_reverse_from)().
>
> Signed-off-by: Zijun Hu <quic_zijuhu@xxxxxxxxxxx>
I'd normally argue this wasn't worth the effort, but given you tidied
up one inconsistent case in this series, fair enough as far as I'm concerned.
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@xxxxxxxxxx>