Subject: Re: [PATCH v2 1/6] Add ancillary bus support

From: Leon Romanovsky <[email-masked]>
Date: Tue, 6 Oct 2020 20:23:17 +0300

On Mon, Oct 05, 2020 at 11:24:41AM -0700, Dave Ertman wrote:
> Add support for the Ancillary Bus, ancillary_device and ancillary_driver.
> It enables drivers to create an ancillary_device and bind an
> ancillary_driver to it.
>
> The bus supports probe/remove shutdown and suspend/resume callbacks.
> Each ancillary_device has a unique string based id; driver binds to
> an ancillary_device based on this id through the bus.
>
> Co-developed-by: Kiran Patil <[email-masked]>
> Signed-off-by: Kiran Patil <[email-masked]>
> Co-developed-by: Ranjani Sridharan <[email-masked]>
> Signed-off-by: Ranjani Sridharan <[email-masked]>
> Co-developed-by: Fred Oh <[email-masked]>
> Signed-off-by: Fred Oh <[email-masked]>
> Reviewed-by: Pierre-Louis Bossart <[email-masked]>
> Reviewed-by: Shiraz Saleem <[email-masked]>
> Reviewed-by: Parav Pandit <[email-masked]>
> Reviewed-by: Dan Williams <[email-masked]>
> Signed-off-by: Dave Ertman <[email-masked]>
> ---

<...>

> +/**
> + * __ancillary_driver_register - register a driver for ancillary bus devices
> + * @ancildrv: ancillary_driver structure
> + * @owner: owning module/driver
> + */
> +int __ancillary_driver_register(struct ancillary_driver *ancildrv, struct module *owner)
> +{
> +	if (WARN_ON(!ancildrv->probe) || WARN_ON(!ancildrv->remove) ||
> +	    WARN_ON(!ancildrv->shutdown) || WARN_ON(!ancildrv->id_table))
> +		return -EINVAL;

In our driver ->shutdown is empty, it will be best if ancillary bus will
do "if (->remove) ..->remove()" pattern.

> +
> +	ancildrv->driver.owner = owner;
> +	ancildrv->driver.bus = &ancillary_bus_type;
> +	ancildrv->driver.probe = ancillary_probe_driver;
> +	ancildrv->driver.remove = ancillary_remove_driver;
> +	ancildrv->driver.shutdown = ancillary_shutdown_driver;
> +

I think that this part is wrong, probe/remove/shutdown functions should
come from ancillary_bus_type. You are overwriting private device_driver
callbacks that makes impossible to make container_of of ancillary_driver
to chain operations.

> +	return driver_register(&ancildrv->driver);
> +}
> +EXPORT_SYMBOL_GPL(__ancillary_driver_register);

Thanks