Re: [PATCH v2 1/1] mcb: create dedicated bus_type for mcb_bus and mcb_device

From: gregkh@xxxxxxxxxxxxxxxxxxx
Date: Sat Aug 19 2023 - 06:41:31 EST


On Fri, Aug 18, 2023 at 11:03:03AM +0000, Rodríguez Barbarin, José Javier wrote:
> When allocating a new mcb_bus the bus_type is added to the mcb_bus
> itself, causing an issue when calling mcb_bus_add_devices().
> This function is not only called for each mcb_device under the
> mcb_bus but for the bus itself.
>
> This causes a crash when freeing the ida resources as the bus numbering
> gets corrupted due to a wrong cast of structs mcb_bus and mcb_device.

Why not just fix this up and determine the "type" of the device before
you cast anything?

> Make the release of the mcb devices and their mcb bus explicit.

That's good, but now you have a new bus type which is a bit odd just for
the bus controller. It's not necessarily bad, but not generally what
other busses do. As an example, USB controllers are not their own bus
type, but rather, a different type of device on the same bus. Same goes
for greybus devices/controllers.

So perhaps try doing that instead of creating a whole new bus here?

thanks,

greg k-h