Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3547182pxb; Mon, 16 Nov 2020 18:42:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJwxsnvHJLzZ9ZEDmMFGY4B4XxCOmyCSogcR4yFOBid4OJsGSfuPpfEBCgVzxiQPopdOpc5/ X-Received: by 2002:a05:6402:3d9:: with SMTP id t25mr18835081edw.338.1605580926470; Mon, 16 Nov 2020 18:42:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605580926; cv=none; d=google.com; s=arc-20160816; b=YIiIhl1pFzbI46/QjF7+DLjMh7YKXCLorEs9xUjLDYEnldCIIgVf774mHoUxzNvgaN 9GzgbzYgHJxWlpLsl5BTFP+svLBKP24qD4y8QKOj99DqSoje70RbkTmBom/WZk6hKWRr Ku2kfTa+XxneIFfZ3QG+klJuavHOUr9nhUnE9IiwMp1kP+q+SD1265SouxzgelZWgsUm fLJ4SI0fYTdozzspeJqHufBZ5Oat8g1wE63Miy5RKvItcG4Qg+rroxHOo+s2lI5JdnKZ hT036VKW+PeNIzeanOGicVROKBdIFc+VnQLfRXNbMey9GJPiYTB3Fp6KCqEx9J2qj+fM 5tjw== 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 :message-id:subject:cc:to:from:date:dkim-signature; bh=9UuMcM6QBwE6hcJqjD0F0AxQ5HB4ptXaJ3M3OdJUA8k=; b=wZ2s2X98+7GFLm2z/CSzCZBh8JLg/swvtqYbADlDc+W489uYFAuJofpvBuQVGFUqKU qgjtBoCKQvDn97Kajj0Dm308lnBSVelBunPktwWGG/5LMavLjdeEfbvn9/1OzDthe6Tr 7pIZERvphq+h3H++DTqM8QXOM+QRgnV9TYhjFgSsJI0KVrLae0STXiiZ6NmZYK17H3jW z13S56uOIeUAc6uxvqF149ix37wDpygNcrnt591/5q04+Qag6XerJfU+plcgfBFazmY6 xtvhyjRT33yPi1HUGUqei7icyLJMzOxCMve6ZS+vpVy8YhP984ygf+21JkhY44TvpKUK MyPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=wEQLPLwt; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d17si460266edv.208.2020.11.16.18.41.43; Mon, 16 Nov 2020 18:42:06 -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; dkim=pass header.i=@kernel.org header.s=default header.b=wEQLPLwt; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730804AbgKQAXY (ORCPT + 99 others); Mon, 16 Nov 2020 19:23:24 -0500 Received: from mail.kernel.org ([198.145.29.99]:42404 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726156AbgKQAXY (ORCPT ); Mon, 16 Nov 2020 19:23:24 -0500 Received: from localhost (189.sub-72-105-114.myvzw.com [72.105.114.189]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1B74E24677; Tue, 17 Nov 2020 00:23:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1605572603; bh=sYrq5ZVWtycoGePIH5LmN/YjigTf7wK8WJYW4RYZ7ro=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=wEQLPLwtcR4SH37LZBBWPU5BFsexHAZG85AusZlOF15wABBTyV7iUbUnVxjgKSqvU M+05Wqv2RN204nrMqpjGeZKZi9T2XL2eg0RF+0ZBuYAilqIIvemHkxVCHR7yBMPQZC sfq6RQgyT6UEFENMVw+B9FAiLf9mLw1El+8xF0Bs= Date: Mon, 16 Nov 2020 18:23:21 -0600 From: Bjorn Helgaas To: Dan Williams Cc: Ben Widawsky , 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: <20201117002321.GA1344659@bjorn-Precision-5520> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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