Re: [PATCH v2 1/4] spi: allow ancillary devices to share parent's chip selects
From: David Lechner
Date: Sat Feb 07 2026 - 13:09:53 EST
On 2/6/26 10:07 AM, Antoniu Miclaus wrote:
> When registering an ancillary SPI device, the current code flags a chip
> select conflict with the parent device. This happens because the
> ancillary device intentionally uses one of the parent's chip selects,
> but __spi_add_device() checks against all existing devices including
> the parent.
>
> Allow this by passing the parent device pointer to __spi_add_device()
> and skipping the conflict check when the existing device is the parent.
>
...
> static int spi_dev_check(struct device *dev, void *data)
> {
> struct spi_device *spi = to_spi_device(dev);
> - struct spi_device *new_spi = data;
> + struct spi_dev_check_info *info = data;
> + struct spi_device *new_spi = info->new_spi;
> int status, idx;
>
> + /*
> + * When registering an ancillary device, skip checking against the
> + * parent device since the ancillary is intentionally using one of
> + * the parent's chip selects.
> + */
> + if (info->parent && spi == info->parent)
spi should never be NULL (or we would get a segfault later), so
if `(spi == info->parent)` should be enough.
> + return 0;
> +
Reviewed-by: David Lechner <dlechner@xxxxxxxxxxxx>