On Fri, Oct 13, 2023 at 06:52:09PM +0800, Hongren Zheng wrote: > .data of platform_device_info will be copied into .platform_data of > struct device via platform_device_add_data. > > However, vhcis[i] contains a spinlock, is dynamically allocated and > used by other code, so it is not meant to be copied. The workaround > was to use void *vhci as an agent, but it was removed in the commit > suggested below. > > This patch adds back the workaround and changes the way of using > platform_data accordingly. ... One more thing... > static int __init vhci_hcd_init(void) > { > int i, ret; > + void *vhci; > > if (usb_disabled()) > return -ENODEV; > @@ -1522,10 +1522,11 @@ static int __init vhci_hcd_init(void) > goto err_driver_register; > > for (i = 0; i < vhci_num_controllers; i++) { > + vhci = &vhcis[i]; This should be void *vhci = &vhcis[i]; because otherwise we mix code and definitions which is not so good style. (Yet we allow to do that in exceptional cases: 1) iterators in for-loops, and 2) RAII allocations with __free() in use.) > struct platform_device_info pdevinfo = { > .name = driver_name, > .id = i, > - .data = &vhcis[i], > + .data = &vhci, > .size_data = sizeof(void *), > }; -- With Best Regards, Andy Shevchenko