Hi: > -----Original Message----- > From: Sergei Shtylyov [mailto:sergei.shtylyov@xxxxxxxxxxxxxxxxxx] > Sent: 2019年1月5日 16:30 > To: Linus Walleij <linus.walleij@xxxxxxxxxx>; Jens Axboe <axboe@xxxxxxxxx>; > Bartlomiej Zolnierkiewicz <b.zolnierkie@xxxxxxxxxxx> > Cc: linux-ide@xxxxxxxxxxxxxxx; Egor Starkov <egor.starkov@xxxxxx>; Richard > Zhu <hongxing.zhu@xxxxxxx> > Subject: Re: [PATCH] ata: ahci-imx: Covert to use GPIO descriptor > > Hello! > > On 05.01.2019 3:14, Linus Walleij wrote: > > > This converts the i.MX AHCI driver to use a GPIO descriptor instead of > > parsing the device tree by itself. > > > > This driver is quite obviously device tree only, and the GPIO line is > > treated as optional, so let's keep it as optional. > > > > None of the device trees in the kernek use this GPIO > > Kernel. :-) > > > facility today, so it is hard to test. > > > > Cc: Egor Starkov <egor.starkov@xxxxxx> > > Cc: Richard Zhu <hongxing.zhu@xxxxxxx> > > Signed-off-by: Linus Walleij <linus.walleij@xxxxxxxxxx> > > --- > > drivers/ata/ahci_imx.c | 24 ++++++++---------------- > > 1 file changed, 8 insertions(+), 16 deletions(-) > > > > diff --git a/drivers/ata/ahci_imx.c b/drivers/ata/ahci_imx.c index > > b00799d208f5..1c9d35c2f89c 100644 > > --- a/drivers/ata/ahci_imx.c > > +++ b/drivers/ata/ahci_imx.c > [...] > > @@ -1044,19 +1043,12 @@ static int imx8_sata_probe(struct device *dev, > struct imx_ahci_priv *imxpriv) > > } > > > > /* Fetch GPIO, then enable the external OSC */ > > - imxpriv->clkreq_gpio = of_get_named_gpio(np, "clkreq-gpio", 0); > > - if (gpio_is_valid(imxpriv->clkreq_gpio)) { > > - ret = devm_gpio_request_one(dev, imxpriv->clkreq_gpio, > > - GPIOF_OUT_INIT_LOW, > > - "SATA CLKREQ"); > > - if (ret == -EBUSY) { > > - dev_info(dev, "clkreq had been initialized.\n"); > > - } else if (ret) { > > - dev_err(dev, "%d unable to get clkreq.\n", ret); > > - return ret; > > - } > > - } else if (imxpriv->clkreq_gpio == -EPROBE_DEFER) { > > - return imxpriv->clkreq_gpio; > > + imxpriv->clkreq_gpiod = devm_gpiod_get_optional(dev, "clkreq", > GPIOD_OUT_LOW); > > + if (IS_ERR(imxpriv->clkreq_gpiod)) > > + return PTR_ERR(imxpriv->clkreq_gpiod); > > + if (imxpriv->clkreq_gpiod) { > > + gpiod_set_consumer_name(imxpriv->clkreq_gpiod, "SATA > CLKREQ"); > > + dev_info(dev, "clkreq had been initialized.\n"); > > Hm, this message was printed on -EBUSY error, now you print it on > success... > [Richard Zhu] Correct. The clkreq gpio maybe initialized(requested/configured) by other module, when the external OSC is shared by ATA and the other module. Thus, it's not a real error when devm_gpio_request_one return -EBUSY in this scenario. That message is used to tell us the clkreq# had been initialized by another module already. Best Regards Richard Zhu > MBR, Sergei