linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Luis Chamberlain <mcgrof@kernel.org>
To: axboe@kernel.dk, bhelgaas@google.com, liushixin2@huawei.com,
	thunder.leizhen@huawei.com, lee.jones@linaro.org,
	geoff@infradead.org, mpe@ellerman.id.au,
	benh@kernel.crashing.org, paulus@samba.org, jim@jtan.com,
	haris.iqbal@ionos.com, jinpu.wang@ionos.com,
	josh.h.morris@us.ibm.com, pjk1939@linux.ibm.com,
	tim@cyberelk.net, richard@nod.at, miquel.raynal@bootlin.com,
	vigneshr@ti.com
Cc: linux-mtd@lists.infradead.org, linuxppc-dev@lists.ozlabs.org,
	linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
	Luis Chamberlain <mcgrof@kernel.org>
Subject: [PATCH 08/10] block/sx8: add error handling support for add_disk()
Date: Wed,  1 Sep 2021 14:00:26 -0700	[thread overview]
Message-ID: <20210901210028.1750956-9-mcgrof@kernel.org> (raw)
In-Reply-To: <20210901210028.1750956-1-mcgrof@kernel.org>

We never checked for errors on add_disk() as this function
returned void. Now that this is fixed, use the shiny new
error handling.

A completion is used to notify the initial probe what is
happening and so we must defer error handling on completion.
Do this by remembering the error and using the shared cleanup
function.

The tags are shared and so are hanlded later for the
driver already.

Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
 drivers/block/sx8.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/block/sx8.c b/drivers/block/sx8.c
index 420cd952ddc4..1c79248c4826 100644
--- a/drivers/block/sx8.c
+++ b/drivers/block/sx8.c
@@ -297,6 +297,7 @@ struct carm_host {
 
 	struct work_struct		fsm_task;
 
+	int probe_err;
 	struct completion		probe_comp;
 };
 
@@ -1181,8 +1182,11 @@ static void carm_fsm_task (struct work_struct *work)
 				struct gendisk *disk = port->disk;
 
 				set_capacity(disk, port->capacity);
-				add_disk(disk);
-				activated++;
+				host->probe_err = add_disk(disk);
+				if (!host->probe_err)
+					activated++;
+				else
+					break;
 			}
 
 		printk(KERN_INFO DRV_NAME "(%s): %d ports activated\n",
@@ -1192,11 +1196,9 @@ static void carm_fsm_task (struct work_struct *work)
 		reschedule = 1;
 		break;
 	}
-
 	case HST_PROBE_FINISHED:
 		complete(&host->probe_comp);
 		break;
-
 	case HST_ERROR:
 		/* FIXME: TODO */
 		break;
@@ -1507,7 +1509,10 @@ static int carm_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
 		goto err_out_free_irq;
 
 	DPRINTK("waiting for probe_comp\n");
+	host->probe_err = -ENODEV;
 	wait_for_completion(&host->probe_comp);
+	if (host->probe_err)
+		goto err_out_free_irq;
 
 	printk(KERN_INFO "%s: pci %s, ports %d, io %llx, irq %u, major %d\n",
 	       host->name, pci_name(pdev), (int) CARM_MAX_PORTS,
-- 
2.30.2


  parent reply	other threads:[~2021-09-01 21:01 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-01 21:00 [PATCH 00/10] block: fourth batch of add_disk() error handling conversions Luis Chamberlain
2021-09-01 21:00 ` [PATCH 01/10] mtip32xx: add error handling support for add_disk() Luis Chamberlain
2021-09-01 21:00 ` [PATCH 02/10] pktcdvd: " Luis Chamberlain
2021-09-01 21:00 ` [PATCH 03/10] ps3disk: " Luis Chamberlain
2021-09-01 21:00 ` [PATCH 04/10] ps3vram: " Luis Chamberlain
2021-09-01 21:00 ` [PATCH 05/10] rnbd: " Luis Chamberlain
2021-09-02  5:32   ` Jinpu Wang
2021-09-01 21:00 ` [PATCH 06/10] block/rsxx: " Luis Chamberlain
2021-09-01 21:00 ` [PATCH 07/10] block/sunvdc: " Luis Chamberlain
2021-09-01 21:00 ` Luis Chamberlain [this message]
2021-09-01 21:00 ` [PATCH 09/10] pf: " Luis Chamberlain
2021-09-01 21:00 ` [PATCH 10/10] mtd/ubi/block: " Luis Chamberlain

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=20210901210028.1750956-9-mcgrof@kernel.org \
    --to=mcgrof@kernel.org \
    --cc=axboe@kernel.dk \
    --cc=benh@kernel.crashing.org \
    --cc=bhelgaas@google.com \
    --cc=geoff@infradead.org \
    --cc=haris.iqbal@ionos.com \
    --cc=jim@jtan.com \
    --cc=jinpu.wang@ionos.com \
    --cc=josh.h.morris@us.ibm.com \
    --cc=lee.jones@linaro.org \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=liushixin2@huawei.com \
    --cc=miquel.raynal@bootlin.com \
    --cc=mpe@ellerman.id.au \
    --cc=paulus@samba.org \
    --cc=pjk1939@linux.ibm.com \
    --cc=richard@nod.at \
    --cc=thunder.leizhen@huawei.com \
    --cc=tim@cyberelk.net \
    --cc=vigneshr@ti.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;
as well as URLs for NNTP newsgroup(s).