Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp690769pxv; Thu, 15 Jul 2021 13:34:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxlONWPBTNZNVDNpFxL4daBhuZJ5R1/1xcAOwwDKEAJUQagstl2GTZoDCZFlDPjOLXujUSw X-Received: by 2002:aa7:c808:: with SMTP id a8mr9658484edt.245.1626381270688; Thu, 15 Jul 2021 13:34:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626381270; cv=none; d=google.com; s=arc-20160816; b=wYqT2sZgqStCY4U+VkvM8YWUwBwtMZWn5iTPqsusrIYbjyS67/mfrqoKDmRTSWaJra 07F3RzOiLvsZGfggv1L/Yy/PrxaOPxRi+FuVBlbG4gk74skkmHg0+z+pYT+kPKOiXYqZ NcJaouBcS4Smy+jwHJvjC3GoruFil55SkRAW1kPTo4HLj1IqRwJtLOifnUkqX7CPxHnd OeyOo49pL6b0yUABYK7HARc9LfnZZqockGc1HBKfhkXF69EyO9yVNdTAlVr8JAXq2yOz uPmIeQIZ89yyMnCG647Xo/ft+OZfbtQ/0XZ3j3HkywK300yyxxs0PNG3xwpaUOyUZOj4 7sHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=AfqEur0D3iK3wyEW51FZ1fhyTp8fBt0DR6t9c5iQRFU=; b=j7aYZtkOeToli4kHJSaNys4RVybNgFC8kjPmuBxZvSp5X3z/qygF7LjmT2nwDLHREI jeja7LQVuABSJbP3tpvROzXtkxBn09qb3IjLQUj8bkJVJe2y/t31vULcMo3185l8cRP0 1wKw2nJ94aHz5KKijLHtrxP9WDhqMJ0cI2TmuQvHXIO6qsqZmRrps1PUjFx35AluNp5a zE0CIOYEyBBt48ybKauTodkgIoi7j708QF33sd1wRbm4DuPE/3ATexXYMy5Yr93xLDdi uQVUBsZY3o+7HnZ78eo9ND5j1AoOznijKSH+qJI9Rh2QeSGTMlg6tPooPljApBhZ5YKz HvXw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lh21si8574711ejb.632.2021.07.15.13.34.07; Thu, 15 Jul 2021 13:34:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237111AbhGOUdp (ORCPT + 99 others); Thu, 15 Jul 2021 16:33:45 -0400 Received: from mail-pg1-f174.google.com ([209.85.215.174]:46770 "EHLO mail-pg1-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235562AbhGOUdg (ORCPT ); Thu, 15 Jul 2021 16:33:36 -0400 Received: by mail-pg1-f174.google.com with SMTP id w15so7680535pgk.13; Thu, 15 Jul 2021 13:30:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=AfqEur0D3iK3wyEW51FZ1fhyTp8fBt0DR6t9c5iQRFU=; b=LJTI+yPMYraA7gtyGtl01g2cptfLkGFKeTSHj9npWGA7OH+LR58+7XjnVQqIRiIun4 OYqmm8nvCpdBnBpR1sbrOkb8t7MlQpSwSJ7zNQpus+qUbGW3gX4Y59yZ2jZecyNvlUJP xQANE89GvjQRiGfKTdygdej0tTAuVRkteQyErmkS1U6n9bLzJGxaqEnmpkCV51apk2dT dlSHRgcT6XK2iVaROnvReibsahWpibfV1nuh7jwktUwqny779HfB2PN+STD/KmjNttwt 5tJBzIBbfWRoS+SgXLr9i0f+T/m3o9iKjCoJvdSFp4HMC/6pGxZLBWxvcyY5d6n75MlU 3yuw== X-Gm-Message-State: AOAM530p1x84YNbJOVFGZqf6b6rw6BkpQjiz7TyCU7fcG38TvEvg3RtF kQvGOLJh/UqYppTKUNfM1XI= X-Received: by 2002:a62:7c16:0:b029:329:8d4c:d12d with SMTP id x22-20020a627c160000b02903298d4cd12dmr6510253pfc.47.1626381042892; Thu, 15 Jul 2021 13:30:42 -0700 (PDT) Received: from localhost ([191.96.120.37]) by smtp.gmail.com with ESMTPSA id a22sm7476719pfv.113.2021.07.15.13.30.41 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 15 Jul 2021 13:30:42 -0700 (PDT) From: Luis Chamberlain To: axboe@kernel.dk Cc: hare@suse.de, bvanassche@acm.org, ming.lei@redhat.com, hch@infradead.org, jack@suse.cz, osandov@fb.com, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Luis Chamberlain Subject: [RFC 5/5] block/sx8: add error handling support for add_disk() Date: Thu, 15 Jul 2021 13:30:25 -0700 Message-Id: <20210715203025.2018218-6-mcgrof@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210715203025.2018218-1-mcgrof@kernel.org> References: <20210715203025.2018218-1-mcgrof@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.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 --- drivers/block/sx8.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/block/sx8.c b/drivers/block/sx8.c index 6a6dc3fffa5c..34bbd033e2fd 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; }; @@ -1202,8 +1203,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", @@ -1213,11 +1217,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; @@ -1515,7 +1517,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_disks; printk(KERN_INFO "%s: pci %s, ports %d, io %llx, irq %u, major %d\n", host->name, pci_name(pdev), (int) CARM_MAX_PORTS, @@ -1526,6 +1531,8 @@ static int carm_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) pci_set_drvdata(pdev, host); return 0; +err_out_disks: + carm_free_all_disks(host); err_out_free_irq: free_irq(pdev->irq, host); err_out_blkdev_disks: -- 2.27.0