From patchwork Tue Nov 1 23:06:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ahelenia_Ziemia=C5=84ska?= X-Patchwork-Id: 13963 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp3263216wru; Tue, 1 Nov 2022 16:09:20 -0700 (PDT) X-Google-Smtp-Source: AMsMyM51TWFJiWAJl5R+fxUYaO2X4+OQfxh2U+T8dRZ4e2BvbbWDZeI53nmwLDdy6ETlVaZGqt6I X-Received: by 2002:a63:1d59:0:b0:46f:9448:1559 with SMTP id d25-20020a631d59000000b0046f94481559mr15710918pgm.284.1667344160329; Tue, 01 Nov 2022 16:09:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667344160; cv=none; d=google.com; s=arc-20160816; b=CIiBCaAQmpq/GXurtv8+xQo6oto7SPK2kQBnij5FFuz7zekAKNt2lL9WyC5oK8vlAY sCIYetyOYPl56Ul5olzCT0/EbUXfrw9Ph1lo+eZpgVPsr1NM8xxObskAlwjRAsIHCSMs s8X0X+OuVJGydD7dzDibmSdgRkolFMW+YhPS52JzEqmycEAJlhiNRuLI1Kpi779XOe2M /5NpPdbl6pnLVFnHIIPkDbizcOpmxE/FxX9HOP9yIFM+rBsBYuF+NflR5PiaAlIr3hgb TzrM5hkKE47UKhzt7/lhCNMmtUchq4SzoIOBGZ7Kb47eVPXCjwbro3Uqo3sN2dcVK1zb ttiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:from:date :dkim-signature; bh=RVezxjw01M4ffpsXvam9OYBKl3eHB7/hD9NCRCUdUwA=; b=h0gP4FOKd++TSflwI7bDlDXYJeZMS58nw4X4GdOmsHWpfTW/uYWFywuz/LP9hWcjkL UUH3MqCMUUT807X6cVN0v/mAjGZEAXzTQZJeuBHRlYuHCY55uoiYugWmjjMNkpfU8xjE CE4WMKDU8kv3RDVpY2fStBgk2gik60+MnIbhHrM59rX4spaXYw4edGfMo10/1OK5S/f9 2HEl1T5Ed7/Hto4OjSRvGrEq630qY0kuZV1AQChqKxplT8R1D++wI+74cxx23wRUBRyH 9pEtTdyA5KfysM0WBkxNMhHIgdf0DGjPMtpCOmL54V3BS7mZc2obHFqoCX5lj0KuPeZy WoMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nabijaczleweli.xyz header.s=202205 header.b=hNnV2gpV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nabijaczleweli.xyz Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 11-20020a63194b000000b0043966935b33si13417572pgz.166.2022.11.01.16.09.07; Tue, 01 Nov 2022 16:09:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@nabijaczleweli.xyz header.s=202205 header.b=hNnV2gpV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nabijaczleweli.xyz Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231482AbiKAXIe (ORCPT + 99 others); Tue, 1 Nov 2022 19:08:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231448AbiKAXH5 (ORCPT ); Tue, 1 Nov 2022 19:07:57 -0400 Received: from tarta.nabijaczleweli.xyz (unknown [139.28.40.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id CF45CDFA0; Tue, 1 Nov 2022 16:06:05 -0700 (PDT) Received: from tarta.nabijaczleweli.xyz (unknown [192.168.1.250]) by tarta.nabijaczleweli.xyz (Postfix) with ESMTPSA id 232CB511E; Wed, 2 Nov 2022 00:06:05 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nabijaczleweli.xyz; s=202205; t=1667343965; bh=oRx/tqbhEodcmennLfawsLB/b4V24e6OIzyts+HKR3U=; h=Date:From:Cc:Subject:References:In-Reply-To:From; b=hNnV2gpV5tHEDRRHoILgNh5IH420ewDM7/rhtqacniaYzRXfKf+20hKobmRsOCTAT VeCCPMIbW197OCnxWlu3ODYlg0g3PqiP0V0Hb8f2YQg7PGxhBXfCdhHOzupd05TeZp 7fCMzBlsSN/L8gsDoNukSUje6tbudSpau8JxTtAdyHey8c8YVjn2fYeoVQuJcxcFGB KX99Up1ue7GGurneWtMCshmrOwF2W5Igb6tTXt3x2qoiMniE35t1TYbwM4GKxb+SUU L4N1s177lXYZuMs74UWXmBqPWrFEZ4fUzDGzU7jdqG34tAtRjhuEQUjfWEuPecBEDA b4IxtCR79F6t8SZ80gDxpG6yDyxQl4N2KxL58yyFvJuG5zE/EvcjuU/+yHpmT7BIvZ mTpiNfRsBTjx2m53taEt64Sy02FZHWc2yrlK79eWSg5ZGfwfp2+lmqOp15KocXFcm8 Cob/qjXoRHHN/QHr9C/xPLM/PYe/Y2r7fSMXjUplJ6MScx31YZ7TEnavDvbiL87RUW S59mG/dXrFs5k2MpQtrBzZN1yqoBSz2YeerVhvulilEyOjb5knUThhRJtqsEv02dYm /L1wTlNJjdMGZ0BpGnaToAKF2aRen4sJeJLOVG9iO38tU70Or3DbQ3581SGshCsB4r t1DTSywO61Y1WTjqadmS023A= Date: Wed, 2 Nov 2022 00:06:04 +0100 From: Ahelenia =?utf-8?q?Ziemia=C5=84ska?= Cc: Jonathan Corbet , Federico Vaga , Alex Shi , Yanteng Si , Hu Haowen , "James E.J. Bottomley" , "Martin K. Petersen" , Greg Kroah-Hartman , Jiri Slaby , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc-tw-discuss@lists.sourceforge.net, linux-scsi@vger.kernel.org Subject: [PATCH v2 14/15] scsi: ncr53c8xx: replace CCB_MAGIC with bool busy Message-ID: <27cefe163e602f7d5b35ba2e966dccf9109798f9.1667330271.git.nabijaczleweli@nabijaczleweli.xyz> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20220429 X-Spam-Status: No, score=2.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FROM_SUSPICIOUS_NTLD, MISSING_HEADERS,PDS_OTHER_BAD_TLD,PDS_RDNS_DYNAMIC_FP,RDNS_DYNAMIC, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: ** X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748337070290609480?= X-GMAIL-MSGID: =?utf-8?q?1748337070290609480?= The only non-boolean check might as well be, since it just early-exits instead of noting the bug: lower it to a boolean and make it less confusing. As for magic numbers, we have largely moved away from this approach, and we have better debugging instrumentation nowadays: kill it. Link: https://lore.kernel.org/linux-doc/YyMlovoskUcHLEb7@kroah.com/ Signed-off-by: Ahelenia Ziemiańska --- Documentation/process/magic-number.rst | 1 - .../it_IT/process/magic-number.rst | 1 - .../zh_CN/process/magic-number.rst | 1 - .../zh_TW/process/magic-number.rst | 1 - drivers/scsi/ncr53c8xx.c | 25 ++++++------------- 5 files changed, 8 insertions(+), 21 deletions(-) diff --git a/Documentation/process/magic-number.rst b/Documentation/process/magic-number.rst index 6e432917a5a8..5a8c2755ac9c 100644 --- a/Documentation/process/magic-number.rst +++ b/Documentation/process/magic-number.rst @@ -68,5 +68,4 @@ Changelog:: ===================== ================ ======================== ========================================== Magic Name Number Structure File ===================== ================ ======================== ========================================== -CCB_MAGIC 0xf2691ad2 ccb ``drivers/scsi/ncr53c8xx.c`` ===================== ================ ======================== ========================================== diff --git a/Documentation/translations/it_IT/process/magic-number.rst b/Documentation/translations/it_IT/process/magic-number.rst index 7d4c117ac626..2fbc1876534a 100644 --- a/Documentation/translations/it_IT/process/magic-number.rst +++ b/Documentation/translations/it_IT/process/magic-number.rst @@ -74,5 +74,4 @@ Registro dei cambiamenti:: ===================== ================ ======================== ========================================== Nome magico Numero Struttura File ===================== ================ ======================== ========================================== -CCB_MAGIC 0xf2691ad2 ccb ``drivers/scsi/ncr53c8xx.c`` ===================== ================ ======================== ========================================== diff --git a/Documentation/translations/zh_CN/process/magic-number.rst b/Documentation/translations/zh_CN/process/magic-number.rst index c17e3f20440a..f8ec4767bc4e 100644 --- a/Documentation/translations/zh_CN/process/magic-number.rst +++ b/Documentation/translations/zh_CN/process/magic-number.rst @@ -57,5 +57,4 @@ Linux 魔术数 ===================== ================ ======================== ========================================== 魔术数名 数字 结构 文件 ===================== ================ ======================== ========================================== -CCB_MAGIC 0xf2691ad2 ccb ``drivers/scsi/ncr53c8xx.c`` ===================== ================ ======================== ========================================== diff --git a/Documentation/translations/zh_TW/process/magic-number.rst b/Documentation/translations/zh_TW/process/magic-number.rst index e2eeb74e7192..0ccc60bee3d6 100644 --- a/Documentation/translations/zh_TW/process/magic-number.rst +++ b/Documentation/translations/zh_TW/process/magic-number.rst @@ -60,5 +60,4 @@ Linux 魔術數 ===================== ================ ======================== ========================================== 魔術數名 數字 結構 文件 ===================== ================ ======================== ========================================== -CCB_MAGIC 0xf2691ad2 ccb ``drivers/scsi/ncr53c8xx.c`` ===================== ================ ======================== ========================================== diff --git a/drivers/scsi/ncr53c8xx.c b/drivers/scsi/ncr53c8xx.c index 4458449c960b..928417fca495 100644 --- a/drivers/scsi/ncr53c8xx.c +++ b/drivers/scsi/ncr53c8xx.c @@ -1095,15 +1095,6 @@ typedef u32 tagmap_t; #define NS_WIDE (2) #define NS_PPR (4) -/*========================================================== -** -** Misc. -** -**========================================================== -*/ - -#define CCB_MAGIC (0xf2691ad2) - /*========================================================== ** ** Declaration of structs. @@ -1567,7 +1558,7 @@ struct ccb { struct ccb * link_ccb; /* Host adapter CCB chain */ struct list_head link_ccbq; /* Link to unit CCB queue */ u32 startp; /* Initial data pointer */ - u_long magic; /* Free / busy CCB flag */ + bool busy; }; #define CCB_PHYS(cp,lbl) (cp->p_ccb + offsetof(struct ccb, lbl)) @@ -4356,7 +4347,7 @@ static int ncr_queue_command (struct ncb *np, struct scsi_cmnd *cmd) */ /* activate this job. */ - cp->magic = CCB_MAGIC; + cp->busy = true; /* ** insert next CCBs into start queue. @@ -4667,7 +4658,7 @@ void ncr_complete (struct ncb *np, struct ccb *cp) ** Sanity check */ - if (!cp || cp->magic != CCB_MAGIC || !cp->cmd) + if (!cp || !cp->busy || !cp->cmd) return; /* @@ -6998,7 +6989,7 @@ static struct ccb *ncr_get_ccb(struct ncb *np, struct scsi_cmnd *cmd) qp = ncr_list_pop(&lp->free_ccbq); if (qp) { cp = list_entry(qp, struct ccb, link_ccbq); - if (cp->magic) { + if (cp->busy) { PRINT_ADDR(cmd, "ccb free list corrupted " "(@%p)\n", cp); cp = NULL; @@ -7030,17 +7021,17 @@ static struct ccb *ncr_get_ccb(struct ncb *np, struct scsi_cmnd *cmd) ** Wait until available. */ #if 0 - while (cp->magic) { + while (cp->busy) { if (flags & SCSI_NOSLEEP) break; if (tsleep ((caddr_t)cp, PRIBIO|PCATCH, "ncr", 0)) break; } #endif - if (cp->magic) + if (cp->busy) return NULL; - cp->magic = 1; + cp->busy = true; /* ** Move to next available tag if tag used. @@ -7119,7 +7110,7 @@ static void ncr_free_ccb (struct ncb *np, struct ccb *cp) } } cp -> host_status = HS_IDLE; - cp -> magic = 0; + cp -> busy = false; if (cp->queued) { --np->queuedccbs; cp->queued = 0;