From: 俞朝阳 <2426767509@qq.com>
To: "Greg KH" <gregkh@linuxfoundation.org>
Cc: "sergei.shtylyov" <sergei.shtylyov@gmail.com>,
daniel <daniel@zonque.org>,
"haojian.zhuang" <haojian.zhuang@gmail.com>,
"robert.jarzmik" <robert.jarzmik@free.fr>,
linux-arm-kernel <linux-arm-kernel@lists.infradead.org>,
linux-usb <linux-usb@vger.kernel.org>,
linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v3] USB: pxa27x_udc: check return value of clk_enable
Date: Thu, 12 Mar 2026 16:12:32 +0800 [thread overview]
Message-ID: <tencent_28D4DB4E0AD6774FAB12761B8AD05A5D3F06@qq.com> (raw)
In-Reply-To: <2026031145-stencil-italics-89b3@gregkh>
Hi Greg,
On Wed, Mar 11, 2026 at 01:56:14PM +0000, Greg Kroah-Hartman wrote:
> > dplus_pullup(udc, is_active);
> >
> > - if (should_enable_udc(udc))
> > - udc_enable(udc);
> > + if (should_enable_udc(udc)) {
> > + ret = udc_enable(udc);
> > + if (ret)
> > + return ret;
> > + }
>
> DOn't you need to change the pullup?
Yes, you are absolutely right. If udc_enable() fails, the hardware pullup state should be reverted to !is_active. I missed this in v3.
> > udc->vbus_sensed = is_active;
> > - if (should_enable_udc(udc))
> > - udc_enable(udc);
> > + if (should_enable_udc(udc)) {
> > + ret = udc_enable(udc);
> > + if (ret)
> > + return ret;
> > + }
>
> Shouldn't you change vbus_sensed?
Indeed, I should also roll back udc->vbus_sensed = !is_active if the enable fails.
> > +fail_enable:
> > + if (!IS_ERR_OR_NULL(udc->transceiver))
> > + otg_set_peripheral(udc->transceiver->otg, NULL);
> > fail:
> > udc->driver = NULL;
> > return retval;
>
> No other unwinding is needed?
I double-checked `pxa27x_udc_start`. The only setup steps before `udc_enable()` are assigning `udc->driver` and calling `otg_set_peripheral()`. The error path undoes both, so there shouldn't be any other unwinding needed here.
However, your question prompted me to check the other functions, and I realized that I also missed rolling back `dplus_pullup` in `pxa_udc_resume()` on failure. I will fix all of these missing rollbacks.
Thank you for the rigorous review! I will send out the v4 patch shortly.
Best regards,
Zhaoyang Yu
prev parent reply other threads:[~2026-03-12 8:12 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-11 13:56 Zhaoyang Yu
2026-03-11 14:58 ` Greg KH
2026-03-12 8:12 ` 俞朝阳 [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=tencent_28D4DB4E0AD6774FAB12761B8AD05A5D3F06@qq.com \
--to=2426767509@qq.com \
--cc=daniel@zonque.org \
--cc=gregkh@linuxfoundation.org \
--cc=haojian.zhuang@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=robert.jarzmik@free.fr \
--cc=sergei.shtylyov@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®