Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1091241pxu; Mon, 23 Nov 2020 11:23:57 -0800 (PST) X-Google-Smtp-Source: ABdhPJxCpbN3Qj2OblN+4mbj8JGcY/rp5aAiSRygHsuELLNK1jojF5lhrAfyp6N6safi+YS3yQjl X-Received: by 2002:a50:c30d:: with SMTP id a13mr699890edb.89.1606159437521; Mon, 23 Nov 2020 11:23:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606159437; cv=none; d=google.com; s=arc-20160816; b=POoOCqTTnqatcvjpr8P3hEJiuXtsZXlkwKLvVp/gg0kJrkJHVuKqw5yWzGOv6Tjnut IBrebUtXc87abm5YGnrZszpsh2Cr8R1+8wHUHNfuyCU5V9E9ayLeDWqEAaLnbypC0tJs xdzKmVlVkJklWwP7nryzUiwasWgGYLSSmQQZLr7+eDwIP2sOk4M81/OUkOehHQoi4iAC Nf3Fm5eiup37042WdcnInt/xws9YkFZsJHOXXWJitKLNMM6k5tZfNk1MfcpBFsFeWFBU wj7ppRM7CdP9+jK3vXYfn5Q3NQe3tlrsTZypfTt7PCdeQfJYRjkpcaBumw49jawKD23x rSlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:ironport-sdr :ironport-sdr; bh=lltKZnFdvMJK1L1fEGiOoXcqc2uP9dTLQ8S6d/Q528Y=; b=C9njqs6mPe3yQQHCFa1ZOleTq5JMIp7K8BqQb76TO7lkv03+d3GnC9GrWE901TIfzw vJUI/VNO0A667MGRtZDiHg9ClJD837qmkzXl1ZUJ823WNgzSdS5XQixBqOxBWzsaUEfc UOEUGkKlVhyqDW4x8GxA47+PgIUdVHbuXZb3/dAasvvk42mqzFNlvO6BW/WhSj7HaeOY 5tdQJWNBri9R+Wn4OZ6NWl24GFFtdqurDuazZ1HxkblyLGN7S2EymmqRNUDMavc3Uy32 NjiGcRBz4bjvXhuPDD82dn5yltUVTh6g0UBSdGTpYsguc0g2oEaOXhLJ+7j8SBeTSGyO YVwA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t3si6921704edt.474.2020.11.23.11.23.33; Mon, 23 Nov 2020 11:23:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731975AbgKWTUd (ORCPT + 99 others); Mon, 23 Nov 2020 14:20:33 -0500 Received: from mga06.intel.com ([134.134.136.31]:51658 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729570AbgKWTUc (ORCPT ); Mon, 23 Nov 2020 14:20:32 -0500 IronPort-SDR: wpqtrXlSh/tld29/7HMwRkLwgTaaGwvqAu61zmAkYmDwx8tQvTNbtd9I/aEGgstF9AUW9AhKog /hBTCEEvSmgA== X-IronPort-AV: E=McAfee;i="6000,8403,9814"; a="233437087" X-IronPort-AV: E=Sophos;i="5.78,364,1599548400"; d="scan'208";a="233437087" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Nov 2020 11:20:31 -0800 IronPort-SDR: 4osoD/jQLFTXy5LI1vf4UreBRHY4eXiI8Ga6csa8pmpOpB05cVZ7OvHBvUabTlEWF91QWnEYbg NKIXacmNcYFA== X-IronPort-AV: E=Sophos;i="5.78,364,1599548400"; d="scan'208";a="327302195" Received: from laloy-mobl1.amr.corp.intel.com (HELO intel.com) ([10.252.133.93]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Nov 2020 11:20:30 -0800 Date: Mon, 23 Nov 2020 11:20:29 -0800 From: Ben Widawsky To: Bjorn Helgaas Cc: Dan Williams , linux-cxl@vger.kernel.org, Linux Kernel Mailing List , Linux PCI , Linux ACPI , Ira Weiny , Vishal Verma , "Kelley, Sean V" , Bjorn Helgaas , "Rafael J . Wysocki" Subject: Re: [RFC PATCH 4/9] cxl/mem: Map memory device registers Message-ID: <20201123192029.pmmy6ygts5fclz7b@intel.com> References: <20201117002321.GA1344659@bjorn-Precision-5520> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201117002321.GA1344659@bjorn-Precision-5520> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 20-11-16 18:23:21, Bjorn Helgaas wrote: > On Mon, Nov 16, 2020 at 03:19:41PM -0800, Dan Williams wrote: > > On Fri, Nov 13, 2020 at 5:12 PM Ben Widawsky wrote: > > > On 20-11-13 12:17:32, Bjorn Helgaas wrote: > > > > On Tue, Nov 10, 2020 at 09:43:51PM -0800, Ben Widawsky wrote: > > > > > > static int cxl_mem_probe(struct pci_dev *pdev, const struct pci_device_id *id) > > > > > { > > > > > + struct cxl_mem *cxlm = ERR_PTR(-ENXIO); > > > > > struct device *dev = &pdev->dev; > > > > > - struct cxl_mem *cxlm; > > > > > > > > The order was better before ("dev", then "clxm"). Oh, I suppose this > > > > is a "reverse Christmas tree" thing. > > > > > > > > > > I don't actually care either way as long as it's consistent. I tend to do > > > reverse Christmas tree for no particular reason. > > > > Yeah, reverse Christmas tree for no particular reason. > > FWIW, the usual drivers/pci style is to order the decls in the order > the variables are used in the code. But this isn't drivers/pci, so > it's up to you. I only noticed because changing the order made the > diff bigger than it needed to be. > > > > > I think this would be easier to read if cxl_mem_create() returned NULL > > > > on failure (it prints error messages and we throw away > > > > -ENXIO/-ENOMEM distinction here anyway) so you could do: > > > > > > > > struct cxl_mem *cxlm = NULL; > > > > > > > > for (...) { > > > > if (...) { > > > > cxlm = cxl_mem_create(pdev, reg_lo, reg_hi); > > > > break; > > > > } > > > > } > > > > > > > > if (!cxlm) > > > > return -ENXIO; /* -ENODEV might be more natural? */ > > > > > > > > > > I agree on both counts. Both of these came from Dan, so I will let him explain. > > > > I'm not attached to differentiating -ENOMEM from -ENXIO and am ok to > > drop the ERR_PTR() return. I do tend to use -ENXIO for failure to > > perform an initialization action vs failure to even find the device, > > but if -ENODEV seems more idiomatic to Bjorn, I won't argue. > > -ENXIO is fine with me. I just don't see it as often so I don't > really know what it is. > > Bjorn Dan, Bjorn, I did a fairly randomized look at various probe functions and ENODEV seems to be more common. My sort of historical use has been - ENODEV: General, couldn't establish device presence - ENXIO: Device was there but something is totally misconfigured - E*: A matching errno for exactly what went wrong My question though is, would it be useful to propagate the error up through probe?