> -----Original Message-----
> From: Intel-wired-lan <[email protected]> On Behalf
> Of Ivan Vecera
> Sent: Friday, January 30, 2026 5:54 PM
> To: [email protected]
> Cc: Lobakin, Aleksander <[email protected]>; Andrew Lunn
> <[email protected]>; Kubalewski, Arkadiusz
> <[email protected]>; David S. Miller
> <[email protected]>; Eric Dumazet <[email protected]>; Jakub
> Kicinski <[email protected]>; Jiri Pirko <[email protected]>; Jonathan
> Lemon <[email protected]>; Leon Romanovsky <[email protected]>;
> Mark Bloch <[email protected]>; Paolo Abeni <[email protected]>;
> Prathosh Satish <[email protected]>; Kitszel, Przemyslaw
> <[email protected]>; Richard Cochran
> <[email protected]>; Saeed Mahameed <[email protected]>; Tariq
> Toukan <[email protected]>; Nguyen, Anthony L
> <[email protected]>; Vadim Fedorenko
> <[email protected]>; [email protected]; linux-
> [email protected]; [email protected]
> Subject: [Intel-wired-lan] [PATCH net-next v3 4/9] dpll: Support
> dynamic pin index allocation
> 
> Allow drivers to register DPLL pins without manually specifying a pin
> index.
> 
> Currently, drivers must provide a unique pin index when calling
> dpll_pin_get(). This works well for hardware-mapped pins but creates
> friction for drivers handling virtual pins or those without a strict
> hardware indexing scheme.
> 
> Introduce DPLL_PIN_IDX_UNSPEC (U32_MAX). When a driver passes this
> value as the pin index:
> 1. The core allocates a unique index using an IDA 2. The allocated
> index is mapped to a range starting above `INT_MAX`
> 
> This separation ensures that dynamically allocated indices never
> collide with standard driver-provided hardware indices, which are
> assumed to be within the `0` to `INT_MAX` range. The index is
> automatically freed when the pin is released in dpll_pin_put().
> 
> Signed-off-by: Ivan Vecera <[email protected]>
> ---
> v2:
> * fixed integer overflow in dpll_pin_idx_free()
> ---
>  drivers/dpll/dpll_core.c | 48 ++++++++++++++++++++++++++++++++++++++-
> -
>  include/linux/dpll.h     |  2 ++
>  2 files changed, 48 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/dpll/dpll_core.c b/drivers/dpll/dpll_core.c index
> 4bcffe3507cd7..b91f4dc6bb972 100644
> --- a/drivers/dpll/dpll_core.c
> +++ b/drivers/dpll/dpll_core.c
> @@ -10,6 +10,7 @@
> 
>  #include <linux/device.h>
>  #include <linux/err.h>
> +#include <linux/idr.h>
>  #include <linux/property.h>
>  #include <linux/slab.h>
>  #include <linux/string.h>
> @@ -24,6 +25,7 @@ DEFINE_XARRAY_FLAGS(dpll_device_xa, XA_FLAGS_ALLOC);
> DEFINE_XARRAY_FLAGS(dpll_pin_xa, XA_FLAGS_ALLOC);
> 
>  static RAW_NOTIFIER_HEAD(dpll_notifier_chain);
> +static DEFINE_IDA(dpll_pin_idx_ida);
> 
>  static u32 dpll_device_xa_id;
>  static u32 dpll_pin_xa_id;
> @@ -464,6 +466,36 @@ void dpll_device_unregister(struct dpll_device
> *dpll,  }  EXPORT_SYMBOL_GPL(dpll_device_unregister);
> 


...

> --
> 2.52.0


Reviewed-by: Aleksandr Loktionov <[email protected]>

Reply via email to