On Sun, Jan 13, 2019 at 10:22 PM Stefan Wahren <stefan.wahren@xxxxxxxx> wrote: > as proposed in a recent discussion [1], this is a hack to improve gpioinfo. > I think this could a start point for a discussion. I like the idea. > +bool pinmux_is_in_use(struct pinctrl_dev *pctldev, unsigned pin) > +{ > + struct pin_desc *desc = pin_desc_get(pctldev, pin); > + > + if (!desc) { > + dev_err(pctldev->dev, > + "pin %u is not registered so it cannot be requested\n", > + pin); > + return false; > + } > + > + if (desc->mux_usecount) > + return true; > + > + return !!desc->gpio_owner; > +} This needs to be augmented to respect the .strict attribute of the pin. Only if the pin controller is strict can you assume that it's use by something else than GPIO blocks the GPIO usecase. Further explanations to this are detailed in Documentation/driver-api/pinctl.rst section "GPIO mode pitfalls". Since BCM2835 which IIRC is your target does not set .strict to true, you might first have to look into and solve that. Yours, Linus Walleij