> -----Original Message----- > From: Wolfram Sang <wsa@xxxxxxxxxxxxx> > Sent: Saturday, June 01, 2019 3:44 PM > To: Vadim Pasternak <vadimp@xxxxxxxxxxxx> > Cc: linux-i2c@xxxxxxxxxxxxxxx; Michael Shych <michaelsh@xxxxxxxxxxxx> > Subject: Re: [PATCH v1 i2c-next] i2c: mlxcpld: prevent devices from being > unbounded from driver via sysfs > > > > 'i2c_mlxcpld' is a platform drivers and it registered via > > platform_driver_probe() and can be bound to devices only once, upon > > registration. > > ?? No, it isn't. If it was, the driver core would have prevented these attributes > (post 2009 kernels at least). Hi Wolfram, Thank you very much for your input. Yes, I see my statement was wrong. I performed more debug with option CONFIG_DEBUG_TEST_DRIVER_REMOVE. And I think I found the issue. In code from 'mlx-platform' driver, I pointed out in commit text, 'mlx-platform' registers 'i2c_mlxcpld' device and then registers few underlying 'i2c-mux-reg' devices: priv->pdev_i2c = platform_device_register_simple("i2c_mlxcpld", nr, NULL, 0); ... for (i = 0; i < ARRAY_SIZE(mlxplat_mux_data); i++) { priv->pdev_mux[i] = platform_device_register_resndata( &mlxplat_dev->dev, "i2c-mux-reg", i, NULL, 0, &mlxplat_mux_data[i], sizeof(mlxplat_mux_data[i])); But it seems for priv->pdev_mux[i] entries, platform_device_register_resndata() should be called with parent device priv->pdev_i2c->dev instead of mlxplat_dev->dev, since "i2c-mux-reg parent is device, created by "i2c_mlxcpld". This change solves the issue I found with DEBUG_TEST_DRIVER_REMOVE. And it also seems to be a possible source for some other issues. I am going to send a path with this fix to platform. --- a/drivers/platform/x86/mlx-platform.c +++ b/drivers/platform/x86/mlx-platform.c @@ -2032,7 +2032,7 @@ static int __init mlxplat_init(void) for (i = 0; i < ARRAY_SIZE(mlxplat_mux_data); i++) { priv->pdev_mux[i] = platform_device_register_resndata( - &mlxplat_dev->dev, + &priv->pdev_i2c->dev, "i2c-mux-reg", i, NULL, 0, &mlxplat_mux_data[i], sizeof(mlxplat_mux_data[i])); Thank you, Vadim.