From: Dan Carpenter <dan.carpenter@oracle.com>
To: Tim Waugh <tim@cyberelk.net>, Christoph Hellwig <hch@lst.de>
Cc: Jens Axboe <axboe@kernel.dk>,
linux-block@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: [PATCH] pcd: fix error codes in pcd_init_unit()
Date: Fri, 1 Oct 2021 15:26:23 +0300 [thread overview]
Message-ID: <20211001122623.GA2283@kili> (raw)
Return -ENODEV on these error paths instead of returning success.
Fixes: ea3d5fcb746a ("pcd: cleanup initialization")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
drivers/block/paride/pcd.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/drivers/block/paride/pcd.c b/drivers/block/paride/pcd.c
index 4cc0d141db78..0214f123d018 100644
--- a/drivers/block/paride/pcd.c
+++ b/drivers/block/paride/pcd.c
@@ -613,8 +613,7 @@ static int pcd_identify(struct pcd_unit *cd)
}
/*
- * returns 0, with id set if drive is detected
- * -1, if drive detection failed
+ * returns 0, with id set if drive is detected, otherwise an error code.
*/
static int pcd_probe(struct pcd_unit *cd, int ms)
{
@@ -627,7 +626,7 @@ static int pcd_probe(struct pcd_unit *cd, int ms)
if (!pcd_reset(cd) && !pcd_identify(cd))
return 0;
}
- return -1;
+ return -ENODEV;
}
static int pcd_probe_capabilities(struct pcd_unit *cd)
@@ -933,9 +932,12 @@ static int pcd_init_unit(struct pcd_unit *cd, bool autoprobe, int port,
disk->events = DISK_EVENT_MEDIA_CHANGE;
if (!pi_init(cd->pi, autoprobe, port, mode, unit, protocol, delay,
- pcd_buffer, PI_PCD, verbose, cd->name))
+ pcd_buffer, PI_PCD, verbose, cd->name)) {
+ ret = -ENODEV;
goto out_free_disk;
- if (pcd_probe(cd, ms))
+ }
+ ret = pcd_probe(cd, ms);
+ if (ret)
goto out_pi_release;
cd->present = 1;
--
2.20.1
next reply other threads:[~2021-10-01 12:26 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-01 12:26 Dan Carpenter [this message]
2021-10-01 19:34 ` [PATCH] pcd: fix error codes in pcd_init_unit() Jens Axboe
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=20211001122623.GA2283@kili \
--to=dan.carpenter@oracle.com \
--cc=axboe@kernel.dk \
--cc=hch@lst.de \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=tim@cyberelk.net \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.