From patchwork Mon Mar 19 07:37:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10291775 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 978F260386 for ; Mon, 19 Mar 2018 07:38:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 822B928B93 for ; Mon, 19 Mar 2018 07:38:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 76D0428BD4; Mon, 19 Mar 2018 07:38:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EFA4828B93 for ; Mon, 19 Mar 2018 07:38:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755332AbeCSHiO (ORCPT ); Mon, 19 Mar 2018 03:38:14 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:58390 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750962AbeCSHiN (ORCPT ); Mon, 19 Mar 2018 03:38:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=UnZnnWTDVrMXCezHyGVwbBjCZ4Thr4lHHQlXCw7ylFQ=; b=RZj9qUbO6pxur7pbp8uJyz9NQ BQ+Yy5878bWZUorsNi4mSswl2x9Fw6befQM/ASHGi4y9AubIX/9avP5eoEvx3h1Q4x1D70pNR2sWe jkfRaKlJCYArHXGV9cDJvFVqkdWHn8oSxzvUlgO+m5FYfTfPi9DCWQejd2KH9mQW/7XPXqtyfwZrF 9S/IYhBChvugifjLZ6NZx6Y9/BwQkbvvXHmzqDAegcW15xsHW6Hcld+Xruag2zqSrWBlR1WapumGk am/AhOFZ34QjeW7xM76HLpzGm00A/o0osajqJyGISE98OowIHV2i1kOROgTvZaVJiC82Dhzsri1PK bZFm7pM7A==; Received: from 178.114.187.156.wireless.dyn.drei.com ([178.114.187.156] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1expMv-00005l-G9; Mon, 19 Mar 2018 07:38:10 +0000 From: Christoph Hellwig To: "Martin K. Petersen" Cc: aacraid@adaptec.com, linuxdrivers@attotech.com, linux-m68k@lists.linux-m68k.org, linux-scsi@vger.kernel.org Subject: [PATCH 2/6] mvme147: stop using scsi_module.c Date: Mon, 19 Mar 2018 08:37:49 +0100 Message-Id: <20180319073753.9361-3-hch@lst.de> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20180319073753.9361-1-hch@lst.de> References: <20180319073753.9361-1-hch@lst.de> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Convert the driver to modern style probing. Given that there only is a single instance for a given board that can be done using a global struct Scsi_Host instance easily. Also fix the removal path by passing the correct cookie to free_irq, and enable it unconditionally. Signed-off-by: Christoph Hellwig --- drivers/scsi/mvme147.c | 107 ++++++++++++++++++++++++++----------------------- 1 file changed, 57 insertions(+), 50 deletions(-) diff --git a/drivers/scsi/mvme147.c b/drivers/scsi/mvme147.c index e6b2b681fda3..7d1ab414b78f 100644 --- a/drivers/scsi/mvme147.c +++ b/drivers/scsi/mvme147.c @@ -3,6 +3,9 @@ #include #include #include +#include +#include +#include #include #include @@ -14,9 +17,6 @@ #include "wd33c93.h" #include "mvme147.h" -#include - - static irqreturn_t mvme147_intr(int irq, void *data) { struct Scsi_Host *instance = data; @@ -65,40 +65,57 @@ static void dma_stop(struct Scsi_Host *instance, struct scsi_cmnd *SCpnt, m147_pcc->dma_cntrl = 0; } -int mvme147_detect(struct scsi_host_template *tpnt) +static struct scsi_host_template mvme147_host_template = { + .module = THIS_MODULE, + .proc_name = "MVME147", + .name = "MVME147 built-in SCSI", + .queuecommand = wd33c93_queuecommand, + .eh_abort_handler = wd33c93_abort, + .eh_host_reset_handler = wd33c93_host_reset, + .show_info = wd33c93_show_info, + .write_info = wd33c93_write_info, + .can_queue = CAN_QUEUE, + .this_id = 7, + .sg_tablesize = SG_ALL, + .cmd_per_lun = CMD_PER_LUN, + .use_clustering = ENABLE_CLUSTERING +}; + +static struct Scsi_Host *mvme147_shost; + +static int __init mvme147_init(void) { - static unsigned char called = 0; - struct Scsi_Host *instance; wd33c93_regs regs; struct WD33C93_hostdata *hdata; + int error = -ENOMEM; - if (!MACH_IS_MVME147 || called) + if (!MACH_IS_MVME147) return 0; - called++; - tpnt->proc_name = "MVME147"; - tpnt->show_info = wd33c93_show_info, - tpnt->write_info = wd33c93_write_info, - - instance = scsi_register(tpnt, sizeof(struct WD33C93_hostdata)); - if (!instance) + mvme147_shost = scsi_host_alloc(&mvme147_host_template, + sizeof(struct WD33C93_hostdata)); + if (!mvme147_shost) goto err_out; + mvme147_shost->base = 0xfffe4000; + mvme147_shost->irq = MVME147_IRQ_SCSI_PORT; - instance->base = 0xfffe4000; - instance->irq = MVME147_IRQ_SCSI_PORT; regs.SASR = (volatile unsigned char *)0xfffe4000; regs.SCMD = (volatile unsigned char *)0xfffe4001; - hdata = shost_priv(instance); + + hdata = shost_priv(mvme147_shost); hdata->no_sync = 0xff; hdata->fast = 0; hdata->dma_mode = CTRL_DMA; - wd33c93_init(instance, regs, dma_setup, dma_stop, WD33C93_FS_8_10); - if (request_irq(MVME147_IRQ_SCSI_PORT, mvme147_intr, 0, - "MVME147 SCSI PORT", instance)) + wd33c93_init(mvme147_shost, regs, dma_setup, dma_stop, WD33C93_FS_8_10); + + error = request_irq(MVME147_IRQ_SCSI_PORT, mvme147_intr, 0, + "MVME147 SCSI PORT", mvme147_shost); + if (error) goto err_unregister; - if (request_irq(MVME147_IRQ_SCSI_DMA, mvme147_intr, 0, - "MVME147 SCSI DMA", instance)) + error = request_irq(MVME147_IRQ_SCSI_DMA, mvme147_intr, 0, + "MVME147 SCSI DMA", mvme147_shost); + if (error) goto err_free_irq; #if 0 /* Disabled; causes problems booting */ m147_pcc->scsi_interrupt = 0x10; /* Assert SCSI bus reset */ @@ -112,40 +129,30 @@ int mvme147_detect(struct scsi_host_template *tpnt) m147_pcc->dma_cntrl = 0x00; /* ensure DMA is stopped */ m147_pcc->dma_intr = 0x89; /* Ack and enable ints */ - return 1; + error = scsi_add_host(mvme147_shost, NULL); + if (error) + goto err_free_irq; + scsi_scan_host(mvme147_shost); + return 0; err_free_irq: - free_irq(MVME147_IRQ_SCSI_PORT, mvme147_intr); + free_irq(MVME147_IRQ_SCSI_PORT, mvme147_shost); err_unregister: - scsi_unregister(instance); + scsi_host_put(mvme147_shost); err_out: - return 0; + return error; } -static struct scsi_host_template driver_template = { - .proc_name = "MVME147", - .name = "MVME147 built-in SCSI", - .detect = mvme147_detect, - .release = mvme147_release, - .queuecommand = wd33c93_queuecommand, - .eh_abort_handler = wd33c93_abort, - .eh_host_reset_handler = wd33c93_host_reset, - .can_queue = CAN_QUEUE, - .this_id = 7, - .sg_tablesize = SG_ALL, - .cmd_per_lun = CMD_PER_LUN, - .use_clustering = ENABLE_CLUSTERING -}; - - -#include "scsi_module.c" - -int mvme147_release(struct Scsi_Host *instance) +static void __exit mvme147_exit(void) { -#ifdef MODULE + scsi_remove_host(mvme147_shost); + /* XXX Make sure DMA is stopped! */ - free_irq(MVME147_IRQ_SCSI_PORT, mvme147_intr); - free_irq(MVME147_IRQ_SCSI_DMA, mvme147_intr); -#endif - return 1; + free_irq(MVME147_IRQ_SCSI_PORT, mvme147_shost); + free_irq(MVME147_IRQ_SCSI_DMA, mvme147_shost); + + scsi_host_put(mvme147_shost); } + +module_init(mvme147_init); +module_exit(mvme147_exit);