Re: [PATCH v1 3/3] mmc: mediatek: add support for SDIO eint irq

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Dec 27, 2021 at 6:46 PM Axe Yang <axe.yang@xxxxxxxxxxxx> wrote:

...

> +       if (mmc->card && !mmc->card->cccr.enable_async_int) {
> +               if (enb)

Spell it fully, i.e. enable.


> +                       pm_runtime_get_noresume(host->dev);
> +               else
> +                       pm_runtime_put_noidle(host->dev);
> +       }

...

> +       int ret = 0;

Redundant assignment, see below.

...

> +       desc = devm_gpiod_get_index(host->dev, "eint", 0, GPIOD_IN);

Why _index variant? By default devm_gpiod_get() uses 0 for index.

> +       if (IS_ERR(desc))
> +               return PTR_ERR(desc);

...

> +       irq = gpiod_to_irq(desc);

ret = ...
if (ret < 0)
  ...handle error...

> +       if (irq >= 0) {

(for the record, 0 is never returned by gpiod_to_irq() according to
all its versions).

> +               irq_set_status_flags(irq, IRQ_NOAUTOEN);

Use corresponding flag:
https://elixir.bootlin.com/linux/latest/source/include/linux/interrupt.h#L83

> +               ret = devm_request_threaded_irq(host->dev, irq, NULL, msdc_sdio_eint_irq,
> +                                               IRQF_TRIGGER_LOW | IRQF_ONESHOT,
> +                                               "sdio-eint", host);
> +       } else {
> +               ret = irq;
> +       }
> +
> +       host->eint_irq = irq;

Is it okay if you assign garbage here in case of error?

> +       return ret;

...

> +       host->pins_eint = pinctrl_lookup_state(host->pinctrl, "state_eint");
> +       if (IS_ERR(host->pins_eint)) {
> +               dev_dbg(&pdev->dev, "Cannot find pinctrl eint!\n");
> +       } else {
> +               host->pins_dat1 = pinctrl_lookup_state(host->pinctrl, "state_dat1");
> +               if (IS_ERR(host->pins_dat1)) {

> +                       ret = PTR_ERR(host->pins_dat1);
> +                       dev_err(&pdev->dev, "Cannot find pinctrl dat1!\n");

ret = dev_err_probe(...); ?

> +                       goto host_free;
> +               }
> +       }

...

> +       if (!IS_ERR(host->pins_eint)) {

I'm wondering if you can use a pattern "error check first"?

> +               disable_irq(host->irq);
> +               pinctrl_select_state(host->pinctrl, host->pins_eint);
> +               spin_lock_irqsave(&host->lock, flags);
> +               if (host->sdio_irq_cnt == 0) {
> +                       enable_irq(host->eint_irq);
> +                       enable_irq_wake(host->eint_irq);
> +                       host->sdio_irq_cnt++;
> +               }
> +               sdr_clr_bits(host->base + SDC_CFG, SDC_CFG_SDIOIDE);
> +               spin_unlock_irqrestore(&host->lock, flags);
> +       }

-- 
With Best Regards,
Andy Shevchenko



[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux