linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: sergei.shtylyov@cogentembedded.com (Sergei Shtylyov)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] phy: rockchip-inno-usb2: fix of_irq_get_byname() error checks
Date: Sun, 30 Jul 2017 20:46:23 +0300	[thread overview]
Message-ID: <20170730174630.481994041@cogentembedded.com> (raw)

of_irq_get_byname() may  return 0 as well as negative error number on
failure,  while the driver only checks for the negative values. The driver
would then call devm_request_threaded_irq() for IRQ0 and thus never get
the valid interrupts.

Check for IRQ <= 0 instead and return -ENXIO iff  it's 0 from
rockchip_usb2phy_{host|otg}_port_init(), and thus fail the driver's probe.

Fixes: 0e08d2a727e6 ("phy: rockchip-inno-usb2: add a new driver for Rockchip usb2phy")
Fixes: 98898f3bc83c ("phy: rockchip-inno-usb2: support otg-port for rk3399")
Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>

---
The patch is against the 'fixes' branch of Kishon's 'linux-phy.git' repo.

 drivers/phy/rockchip/phy-rockchip-inno-usb2.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Index: linux-phy/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
===================================================================
--- linux-phy.orig/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
+++ linux-phy/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
@@ -925,9 +925,9 @@ static int rockchip_usb2phy_host_port_in
 	INIT_DELAYED_WORK(&rport->sm_work, rockchip_usb2phy_sm_work);
 
 	rport->ls_irq = of_irq_get_byname(child_np, "linestate");
-	if (rport->ls_irq < 0) {
+	if (rport->ls_irq <= 0) {
 		dev_err(rphy->dev, "no linestate irq provided\n");
-		return rport->ls_irq;
+		return rport->ls_irq ?: -ENXIO;
 	}
 
 	ret = devm_request_threaded_irq(rphy->dev, rport->ls_irq, NULL,
@@ -988,9 +988,9 @@ static int rockchip_usb2phy_otg_port_ini
 		of_property_read_bool(child_np, "rockchip,utmi-avalid");
 
 	rport->bvalid_irq = of_irq_get_byname(child_np, "otg-bvalid");
-	if (rport->bvalid_irq < 0) {
+	if (rport->bvalid_irq <= 0) {
 		dev_err(rphy->dev, "no vbus valid irq provided\n");
-		ret = rport->bvalid_irq;
+		ret = rport->bvalid_irq ?: -ENXIO;
 		goto out;
 	}
 

                 reply	other threads:[~2017-07-30 17:46 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20170730174630.481994041@cogentembedded.com \
    --to=sergei.shtylyov@cogentembedded.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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;
as well as URLs for NNTP newsgroup(s).