On Wed, Mar 6, 2024 at 12:09 AM Linus Walleij <linus.walleij@xxxxxxxxxx> wrote: > > Several commits introduce managed resources (devm_*) into the > nmk_gpio_populate_chip() function. > > This isn't always working because when called from the Nomadik pin > control driver we just want to populate some states for the device as > the same states are used by the pin control driver. > > Some managed resources such as devm_kzalloc() etc will work, as the > passed in platform device will be used for lifecycle management, > but in some cases where we used the looked-up platform device > for the GPIO block, this will cause problems for the combined > pin control and GPIO driver, because it adds managed resources > to the GPIO device before it is probed, which is something that > the device core will not accept, and all of the GPIO blocks will > refuse to probe: > > platform 8012e000.gpio: Resources present before probing > platform 8012e080.gpio: Resources present before probing > (...) > > Fix this by not tying any managed resources to the looked-up > gpio_pdev/gpio_dev device, let's just live with the fact that > these need imperative resource management for now. > > Drop in some notes and use a local *dev variable to clarify the > code. LGTM, some minor remarks below. ... > Cc: Théo Lebrun <theo.lebrun@xxxxxxxxxxx> Note, you can put Cc:s after --- line and it won't go to the commit message while Cc to the respective people. ... > if (device_property_read_u32(gpio_dev, "ngpios", &ngpio)) { > ngpio = NMK_GPIO_PER_CHIP; > - dev_dbg(&pdev->dev, "populate: using default ngpio (%d)\n", ngpio); > + dev_dbg(dev, "populate: using default ngpio (%d)\n", ngpio); While at it %d --> %u. > } ... > + dev_err(dev, "failed getting reset control: %ld\n", > PTR_ERR(reset)); Also possible %pe. -- With Best Regards, Andy Shevchenko