Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp725827rdb; Thu, 30 Nov 2023 17:27:19 -0800 (PST) X-Google-Smtp-Source: AGHT+IHLwrnZbo+Pvbvf5YWKnS+wc3M1878boQn0i+fR8Xzpw2Y+ezdV2NNqZnA8VqEcmpZ+8IPu X-Received: by 2002:a05:6830:6889:b0:6d8:5a35:ee16 with SMTP id cv9-20020a056830688900b006d85a35ee16mr1456827otb.27.1701394039326; Thu, 30 Nov 2023 17:27:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701394039; cv=none; d=google.com; s=arc-20160816; b=eA6waPYv3QxVs/sxKZCkqKOqi79zloqHeHXxCnV12lJxDktOBVu9PJofHR6NvdSDfG w7CFbU0NT4cjnjl7hjay562DahkZ2yng5DZVYkwkKtjZVnjti5oAHxLX8eO5i1uCzCqb WGpNFhZYNRalUBh8ZV6C9nxPGxc7n7yDt6gyHX2+O7y+vPjb1SOHxJFCCBTsTzToafdK 3m2p0o6FhSlWgxmlYjEp2b3EamGVQIK+XSeuJ/GL1GcHqur6Tm4vhHB5AgtLdwp6BIU/ aNh6X88crGumPZ7fsndhypdDJj2oQSSwmfnN5hgsrd0CACE7Wn7ossNK1+VS12iNobqq 7DAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from:cc:to :content-language:subject:user-agent:mime-version:date:message-id; bh=r2D76fWrFi8bn6LHlfLdrc9UScTEmAfqTrezH6WSbSs=; fh=cDhAuT5bwyWJHg+4C/vpfq2WyK1XvrGnZEGW6152X+g=; b=giA17yrnF3kiItCDwTBCOjnInHf/Qxyj/O4zmfI7m258oqoeGVOZzPkOHS/uy+r+Ts PZzj8jwjkLzCzvK/VEmGx5FmwLgnv1fFVpA2oeKZALjVQQOq4wFWhuLCuJXOgfKJ9kCV 2bUmXKLiRAW2uk3Lw0RLCIDYtWmvFpgwZ555bVDqsf6zAXPycY9pB+cI7ENmlx8wN5aq PUzfW94MsLg/+wHk5OyKrpMn3W//cH+Ec6CEOHRQSxhzYMI2l3GgVoH/AgykyD/112yp 8bogAUj2Vz2RM4bapUwAVd6ZKoes1q7YjnNXOwuCUc6i9jMAPfnEArDpShx1qj0Qd43y RC1Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id c2-20020a631c42000000b005bd641c3614si2223996pgm.769.2023.11.30.17.27.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 17:27:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id A3BEC80F6D31; Thu, 30 Nov 2023 17:27:16 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229577AbjLAB1B (ORCPT + 99 others); Thu, 30 Nov 2023 20:27:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229448AbjLAB1A (ORCPT ); Thu, 30 Nov 2023 20:27:00 -0500 Received: from mail.nfschina.com (unknown [42.101.60.195]) by lindbergh.monkeyblade.net (Postfix) with SMTP id 8960A10E2; Thu, 30 Nov 2023 17:27:04 -0800 (PST) Received: from [172.30.11.106] (unknown [180.167.10.98]) by mail.nfschina.com (Maildata Gateway V2.8.8) with ESMTPSA id 04889605E83EA; Fri, 1 Dec 2023 09:26:44 +0800 (CST) Message-ID: <0247c807-333a-0e8c-d7ca-60e142ab6279@nfschina.com> Date: Fri, 1 Dec 2023 09:26:44 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 Subject: Re: [PATCH] scsi: aic7xxx: fix some problem of return value Content-Language: en-US To: Dan Carpenter Cc: hare@suse.com, jejb@linux.ibm.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org X-MD-Sfrom: suhui@nfschina.com X-MD-SrcIP: 180.167.10.98 From: Su Hui In-Reply-To: <1784b008-6eb2-4dc8-ae21-b0b2c18760bf@suswa.mountain> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Thu, 30 Nov 2023 17:27:16 -0800 (PST) On 2023/11/30 15:21, Dan Carpenter wrote: > On Thu, Nov 30, 2023 at 10:41:23AM +0800, Su Hui wrote: >> error = aic7770_config(ahc, aic7770_ident_table + edev->id.driver_data, >> eisaBase); >> if (error != 0) { >> ahc->bsh.ioport = 0; >> ahc_free(ahc); >> - return (error); >> + return -error; > aic7770_config() mostly returns positive error codes but I see it also > return -1 from ahc_reset(). So you'd want to do something like: > > return error < 0 ? error : -error; Oh, I missed this one. Thanks for pointing out this mistake! >> @@ -1117,7 +1117,7 @@ ahc_linux_register_host(struct ahc_softc *ahc, struct scsi_host_template *templa >> if (retval) { >> printk(KERN_WARNING "aic7xxx: scsi_add_host failed\n"); >> scsi_host_put(host); >> - return retval; >> + return -retval; > Originally ahc_linux_register_host() returned a mix of positive and > negative error codes. You have converted it to return only positive > error codes. That's good for consistency in a way, but it's a step > backwards from the big picture point of view. Agreed, it's better to let ahc_linux_register_host() only return negative error codes. >> } >> >> scsi_scan_host(host); >> diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c b/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c >> index a07e94fac673..e17eb8df12c4 100644 >> --- a/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c >> +++ b/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c >> @@ -241,8 +241,8 @@ ahc_linux_pci_dev_probe(struct pci_dev *pdev, const struct pci_device_id *ent) >> ahc_linux_pci_inherit_flags(ahc); >> >> pci_set_drvdata(pdev, ahc); >> - ahc_linux_register_host(ahc, &aic7xxx_driver_template); >> - return (0); >> + error = ahc_linux_register_host(ahc, &aic7xxx_driver_template); >> + return -error; > This should be done in a separate patch. > > patch 1: return negative error codes in ahc_linux_register_host() > patch 2: return negative error codes in aic7770_probe() > patch 3: add a check for errors in ahc_linux_pci_dev_probe() Got it, I will send v2 patch set soon. Really thanks for your suggestions! Su Hui