From patchwork Thu Oct 25 21:10:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 989355 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-ide-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=kernel.dk Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel-dk.20150623.gappssmtp.com header.i=@kernel-dk.20150623.gappssmtp.com header.b="gs9tarY5"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42h0Cz4WV1z9sDX for ; Fri, 26 Oct 2018 08:11:11 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726113AbeJZFp2 (ORCPT ); Fri, 26 Oct 2018 01:45:28 -0400 Received: from mail-io1-f65.google.com ([209.85.166.65]:42860 "EHLO mail-io1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727150AbeJZFp0 (ORCPT ); Fri, 26 Oct 2018 01:45:26 -0400 Received: by mail-io1-f65.google.com with SMTP id n18-v6so6402079ioa.9 for ; Thu, 25 Oct 2018 14:11:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Rq1wiiOYe2u5z6boQIXUmhXbtDk0+8xQd7UIJF1OIGk=; b=gs9tarY5wzrNW1c20tPO6q2hcqW8b5YaR01G1DiASKo2FoWQyq3Uy8G+MZvtyQp5qK aMruQIwUB6Q18+4ZYVyGQGxpt+LES/kABa4WQ+CEflBi9JLZoIEGqMEahEstz1KVL12p PZcz8nnbNNWnb2NKciZBYRFrJce9X+53Q2/8gOalyVXrgdMeSR4fkLjvXlJT1G4tnHUS dOtndgRvxfrYS4iim7bU4vw8fmV15VM+alE1O7/6r07ewzzmC1Mom9FHVBbivlemqVPS pulLADmbkoG8iPgxUcErnqSOnZEJpq7Y+NMT7ljCcCGo6qkyLDOmsLdxYp/GC2mehI0W QhEQ== 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; bh=Rq1wiiOYe2u5z6boQIXUmhXbtDk0+8xQd7UIJF1OIGk=; b=cqIgjT07CJWTEKKUUGin0T29UNAo9mtrDk582iO7n4UuDTq+iztTAQAW5iLlaDutjl 8LJ2mwNknaw/KGLfJvvTixHnB5rlF60sxwi0hVlGJOcH7fyECTwjsllHOx2uzTRjCrad lxPZ2qMtrgzCkP/l43A8qfJR4pL7XZeQoiyPrTU7ER53zqCWo5qRrXn43AhQ+JS2uWTO ctER+2OTV69HPWKgYtGKj0sOtc5hyCCf8a0X0odOY2824DEN41OtM0y27LwJsMNYxJwZ Exloi90jCcK4DHfkorF68TiYUYRSqQzxb+jWhQ1QvSywFkgO86wywH9ow0mn1jt/+995 XOBg== X-Gm-Message-State: AGRZ1gKD+RbDgVoZO4Mfn2zB5WuxNywVZeCToRaPxb83YTUR4wwR40kH Fxxg1RWo+WTNvLMTJe1UJ6TmFg== X-Google-Smtp-Source: AJdET5cNPPOn3ZI9hArihIeLar8+UvZGWAEvOjdUYp+bG5wV9Em4ErVJ+SZGqOKvbKiEO5VpGx5dNw== X-Received: by 2002:a6b:1701:: with SMTP id 1-v6mr573533iox.48.1540501867768; Thu, 25 Oct 2018 14:11:07 -0700 (PDT) Received: from localhost.localdomain ([216.160.245.98]) by smtp.gmail.com with ESMTPSA id e65-v6sm3446375ioa.76.2018.10.25.14.11.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 Oct 2018 14:11:06 -0700 (PDT) From: Jens Axboe To: linux-block@vger.kernel.org, linux-scsi@vger.kernel.org, linux-ide@vger.kernel.org Cc: Jens Axboe , Johannes Thumshirn , Benjamin Block Subject: [PATCH 12/28] bsg: provide bsg_remove_queue() helper Date: Thu, 25 Oct 2018 15:10:23 -0600 Message-Id: <20181025211039.11559-13-axboe@kernel.dk> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181025211039.11559-1-axboe@kernel.dk> References: <20181025211039.11559-1-axboe@kernel.dk> Sender: linux-ide-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ide@vger.kernel.org All drivers do unregister + cleanup, provide a helper for that. Cc: Johannes Thumshirn Cc: Benjamin Block Cc: linux-scsi@vger.kernel.org Signed-off-by: Jens Axboe Reviewed-by: Christoph Hellwig Reviewed-by: Hannes Reinecke Reviewed-by: Johannes Thumshirn --- block/bsg-lib.c | 7 +++++++ drivers/scsi/scsi_transport_fc.c | 6 ++---- drivers/scsi/scsi_transport_iscsi.c | 7 +++---- drivers/scsi/scsi_transport_sas.c | 6 ++---- include/linux/bsg-lib.h | 1 + 5 files changed, 15 insertions(+), 12 deletions(-) diff --git a/block/bsg-lib.c b/block/bsg-lib.c index 1da011ec04e6..267f965af77a 100644 --- a/block/bsg-lib.c +++ b/block/bsg-lib.c @@ -296,6 +296,13 @@ static void bsg_exit_rq(struct request_queue *q, struct request *req) kfree(job->reply); } +void bsg_remove_queue(struct request_queue *q) +{ + bsg_unregister_queue(q); + blk_cleanup_queue(q); +} +EXPORT_SYMBOL_GPL(bsg_remove_queue); + /** * bsg_setup_queue - Create and add the bsg hooks so we can receive requests * @dev: device to attach bsg device to diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c index 98aaffb4c715..4d64956bb5d3 100644 --- a/drivers/scsi/scsi_transport_fc.c +++ b/drivers/scsi/scsi_transport_fc.c @@ -3851,10 +3851,8 @@ fc_bsg_rportadd(struct Scsi_Host *shost, struct fc_rport *rport) static void fc_bsg_remove(struct request_queue *q) { - if (q) { - bsg_unregister_queue(q); - blk_cleanup_queue(q); - } + if (q) + bsg_remove_queue(q); } diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c index 26b11a775be9..3ead0dba5d8d 100644 --- a/drivers/scsi/scsi_transport_iscsi.c +++ b/drivers/scsi/scsi_transport_iscsi.c @@ -1576,10 +1576,9 @@ static int iscsi_remove_host(struct transport_container *tc, struct Scsi_Host *shost = dev_to_shost(dev); struct iscsi_cls_host *ihost = shost->shost_data; - if (ihost->bsg_q) { - bsg_unregister_queue(ihost->bsg_q); - blk_cleanup_queue(ihost->bsg_q); - } + if (ihost->bsg_q) + bsg_remove_queue(ihost->bsg_q); + return 0; } diff --git a/drivers/scsi/scsi_transport_sas.c b/drivers/scsi/scsi_transport_sas.c index cf6d47891d77..c46d642dc133 100644 --- a/drivers/scsi/scsi_transport_sas.c +++ b/drivers/scsi/scsi_transport_sas.c @@ -246,10 +246,8 @@ static int sas_host_remove(struct transport_container *tc, struct device *dev, struct Scsi_Host *shost = dev_to_shost(dev); struct request_queue *q = to_sas_host_attrs(shost)->q; - if (q) { - bsg_unregister_queue(q); - blk_cleanup_queue(q); - } + if (q) + bsg_remove_queue(q); return 0; } diff --git a/include/linux/bsg-lib.h b/include/linux/bsg-lib.h index b13ae143e7ef..9c9b134b1fa5 100644 --- a/include/linux/bsg-lib.h +++ b/include/linux/bsg-lib.h @@ -73,6 +73,7 @@ void bsg_job_done(struct bsg_job *job, int result, unsigned int reply_payload_rcv_len); struct request_queue *bsg_setup_queue(struct device *dev, const char *name, bsg_job_fn *job_fn, rq_timed_out_fn *timeout, int dd_job_size); +void bsg_remove_queue(struct request_queue *q); void bsg_job_put(struct bsg_job *job); int __must_check bsg_job_get(struct bsg_job *job);