Received: by 2002:a05:6358:700f:b0:131:369:b2a3 with SMTP id 15csp3042621rwo; Thu, 3 Aug 2023 20:59:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFftpF48Pto6Qcxalx+3BK7jJyQo1wha4Zz7QNo8ojy3hg1nkGm/pH7rWdASwNb05pTgRFH X-Received: by 2002:a17:903:249:b0:1bb:1e69:28be with SMTP id j9-20020a170903024900b001bb1e6928bemr661093plh.42.1691121561071; Thu, 03 Aug 2023 20:59:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691121561; cv=none; d=google.com; s=arc-20160816; b=Co/A/ovl1wFb1lEEQHF3c1CCwZ2rHgtDKIujKnlE2awV8511nLjJgcR+jBXlR9IaK9 R66fI3yMcVQlkRyeSQ7153AXRQzZM8bIbdjH554/AzbH2Lzi/aA7WgMjRhPuxaV75QJT G4fQNLqPH6xxtBnCL2bRMc4k3ixmpOFc3l5LknpuBerix/8ETaCK/diIgSpK5FciMBM3 IfRwyiL8doAFdF9+SarAWn27DPO/Q5fQBqNZXbhlUvsmBHKTECuLbE5uEj0ZK2OcRj4E FFsUUMJj3Am3DRDYVbaG6FQUPy8QTRMSBJ4uTnY3vPHF26WhKatxlLr83snOWVUMp3dS lcZA== 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 :references:to:content-language:subject:cc:user-agent:mime-version :date:message-id:dkim-signature; bh=oKInTCjxm8jN8c801mKBdY3k0OA08iAKK2dNmF3u6tw=; fh=lUKVdYiTv5UZoEavPARWrYLGgaq0Tzj7zaAZH6YskUw=; b=gLBDw7DXLjrygvaXa3LfgnqfddOqzRBVsgid9AEdZVxfiYH+cnI20L+Q6WxXYySOs1 5mvdSDjXzL6yG5h1jUg9GBU3InN+CuD24qJvsCMwSzuGUeebXV0Vj52Tjxc+1ywxGiGC dAZnybE6BPptFuLr3hPRWOnw0/j+18/aRvUV73SdwckjCf8TAVJvp0KUSJNPqRvwZefO ZoNkbIZ7FnGiTxWOLixFVoI8uznyt4jibQ3v2Z/uoxx1X/PJpyFSZyH+/FUyWpy/duAJ Prx52+pVpdPW0LrdyMrREzfbxos/KrTMD9dN3ZdDTnMfSQpvkClmbEiOWFYp05ninArP UaAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=oAEoqUqM; 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=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x2-20020a17090300c200b001bb1504b696si995204plc.4.2023.08.03.20.59.09; Thu, 03 Aug 2023 20:59:21 -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=@intel.com header.s=Intel header.b=oAEoqUqM; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231262AbjHDDNs (ORCPT + 99 others); Thu, 3 Aug 2023 23:13:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40276 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232456AbjHDDMc (ORCPT ); Thu, 3 Aug 2023 23:12:32 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD27A5278; Thu, 3 Aug 2023 20:10:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1691118622; x=1722654622; h=message-id:date:mime-version:cc:subject:to:references: from:in-reply-to:content-transfer-encoding; bh=ifI9ykdQ7oocrSyNeOcXUTl2KxrALUZ7bAa7qp62vJg=; b=oAEoqUqMZrOcbAjXeayI06iwNUqyImxkhwR2dne25NZfQUo1LUlpeCoh XeLxXmFYmH//va172zhuenAe8W4JRpokl5TWGFgQ7MeAoX9GAOlUlohOP 8sBuPMa09jufVMZk6LJh6oNQo3MSzd9fU73OADPoh7Y23pyi91boJx+I+ 3xXuWt6v3iGEr8JABHL+A7YZj4j9si7IlrsB43xY3BentDZdH0/8xgGKw PYJ3QVPi1/ME3vRW2D76IEZu7pIt8LM94lsr9Kp0I8cg9vkhBgFxnChuf C9HVi9qU6p8rgMfYEMX90arousP6r3RMaQ6/wFns/WIcFBBMJEUStLR6v A==; X-IronPort-AV: E=McAfee;i="6600,9927,10791"; a="401007533" X-IronPort-AV: E=Sophos;i="6.01,253,1684825200"; d="scan'208";a="401007533" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Aug 2023 20:10:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10791"; a="729882400" X-IronPort-AV: E=Sophos;i="6.01,253,1684825200"; d="scan'208";a="729882400" Received: from blu2-mobl.ccr.corp.intel.com (HELO [10.254.210.88]) ([10.254.210.88]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Aug 2023 20:10:16 -0700 Message-ID: <0866104f-b070-405c-da27-71a138a10e7c@linux.intel.com> Date: Fri, 4 Aug 2023 11:10:14 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Cc: baolu.lu@linux.intel.com, "Liu, Yi L" , Jacob Pan , "iommu@lists.linux.dev" , "kvm@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH v2 05/12] iommu: Change the return value of dev_iommu_get() Content-Language: en-US To: "Tian, Kevin" , Joerg Roedel , Will Deacon , Robin Murphy , Jason Gunthorpe , Jean-Philippe Brucker , Nicolin Chen References: <20230727054837.147050-1-baolu.lu@linux.intel.com> <20230727054837.147050-6-baolu.lu@linux.intel.com> From: Baolu Lu In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2023/8/3 15:59, Tian, Kevin wrote: >> From: Lu Baolu >> Sent: Thursday, July 27, 2023 1:49 PM >> >> Make dev_iommu_get() return 0 for success and error numbers for failure. >> This will make the code neat and readable. No functionality changes. >> >> Reviewed-by: Jacob Pan >> Signed-off-by: Lu Baolu >> --- >> drivers/iommu/iommu.c | 19 +++++++++++-------- >> 1 file changed, 11 insertions(+), 8 deletions(-) >> >> diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c >> index 00309f66153b..4ba3bb692993 100644 >> --- a/drivers/iommu/iommu.c >> +++ b/drivers/iommu/iommu.c >> @@ -290,20 +290,20 @@ void iommu_device_unregister(struct >> iommu_device *iommu) >> } >> EXPORT_SYMBOL_GPL(iommu_device_unregister); >> >> -static struct dev_iommu *dev_iommu_get(struct device *dev) >> +static int dev_iommu_get(struct device *dev) >> { >> struct dev_iommu *param = dev->iommu; >> >> if (param) >> - return param; >> + return 0; >> >> param = kzalloc(sizeof(*param), GFP_KERNEL); >> if (!param) >> - return NULL; >> + return -ENOMEM; >> >> mutex_init(¶m->lock); >> dev->iommu = param; >> - return param; >> + return 0; >> } >> > > Jason's series [1] has been queued. Time to refine according to > the discussion in [2]. > > [1] https://lore.kernel.org/linux-iommu/ZLFYXlSBZrlxFpHM@8bytes.org/ > [2] https://lore.kernel.org/linux-iommu/c815fa2b-00df-91e1-8353-8258773957e4@linux.intel.com/ I'm not sure I understand your point here. This only changes the return value of dev_iommu_get() to make the code more concise. Best regards, baolu