Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp719253pxb; Tue, 2 Feb 2021 16:36:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJzAlpwGkurKhKnpr2vGaueVkrgs5DLbOj0AkJbZ/5ScuRC/Cf8mg5hMLCQrRwswvTEKmmkb X-Received: by 2002:a17:906:c010:: with SMTP id e16mr555649ejz.91.1612312601798; Tue, 02 Feb 2021 16:36:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612312601; cv=none; d=google.com; s=arc-20160816; b=uN+I+L2139NuE1aiYndvWCOnZ/T02+x2b8pgrdg0QqIf6I2qJEn8KxV+Enl8hzPgTZ 26U8Fr7QmFG4oci6Qg6X8HIsSZK48xJ4R1ZeHilLdhGdTlLK2dFisNVe7LN0dbUuJIny rF4wWbhnW8F7KCn8hLB6FKiS8G+vEnbMpIuF/4V6kssfWfjCMk7lvW8Ln7tAI0Jms82h dg++DfjvyF7qgGUFXznxmp/QZBrcsureHUaijS47tUykqS+JWma/5qh3oSAVootmmto9 1usrlNMeJ4tAxcvEY0GvxZL1n3Rz9DbVFohIjwn75XjOZBLaJ96NccQsRzZLXICASMPf hf1Q== 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:dkim-signature; bh=bJEP+2U5IHzdV2qfnQ7rYOCO3psxW3Bn2kjhHos5sUE=; b=VW72pSyjKcdvBZK4dPAcZXUlN1gM4m6rAMGks2vpKv70GEwHr8ZFQ6NoXQtWMAW0L+ J0RNrq/Q5nrA+Ul8iaHlOBt1sUf3oFPQxfpy+bszlGk5J/D+HeJkinx9J/lemPsbj1rt iIwTDI39ERuq9PVcsFB3sCYWp49NBUH740tm+viUSDW4U20x+RLHt784uXnPvg5X9qmo jnnCz37DviXsE+oRNGp96cPGE2VwX1xxpDryBI0VA2c9dhvlfhk6UUFZ7VGqlHTc2dkf 0yc1YFDwF16eMIfZ/fCP2/3werkaxRmxy3UP1IWi9sbsIgJTBbcPBc9VtEI074QBvbi9 FNdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=wJAxx4sa; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i9si292899ejy.32.2021.02.02.16.36.17; Tue, 02 Feb 2021 16:36:41 -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=@infradead.org header.s=casper.20170209 header.b=wJAxx4sa; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238332AbhBBSQP (ORCPT + 99 others); Tue, 2 Feb 2021 13:16:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238397AbhBBSOi (ORCPT ); Tue, 2 Feb 2021 13:14:38 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8131EC06174A; Tue, 2 Feb 2021 10:13:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=bJEP+2U5IHzdV2qfnQ7rYOCO3psxW3Bn2kjhHos5sUE=; b=wJAxx4saCmpOESyrOd9ngpJa8p WclqsGHnEBCWPZPSjwMviTo2DraBgO/ruRSqVc1jZKjk8P1ETlGUT0ZhoSJ33sXPtY4wPD7EvVtuh vCvgqYuU6TWVajw+XMVs3AHKvE5tj9r31Wn/vHI220bvXTQUv2tsHtmfxQzVKF/YsaUzbG3Vf9Ab3 k/bav4UP053XTUZXT8EEZItKfYHXn9QYa4ayeq5KkBDZ9C0tBvTgz8TTDs1JdXN30lUSljn6FZsQA n63z8TKMycIgOhwJqOfnP/Y2l/w5Xc5shymhQEajRookQg5x/6X5bhabeGGdnWvfGkOTYGGBW5qIJ kuPLgAzg==; Received: from hch by casper.infradead.org with local (Exim 4.94 #2 (Red Hat Linux)) id 1l70BW-00FZoh-LW; Tue, 02 Feb 2021 18:13:54 +0000 Date: Tue, 2 Feb 2021 18:13:54 +0000 From: Christoph Hellwig To: Ben Widawsky Cc: linux-cxl@vger.kernel.org, Dan Williams , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-nvdimm@lists.01.org, linux-pci@vger.kernel.org, Bjorn Helgaas , Chris Browy , Christoph Hellwig , Ira Weiny , Jon Masters , Jonathan Cameron , Rafael Wysocki , Randy Dunlap , Vishal Verma , daniel.lll@alibaba-inc.com, "John Groves (jgroves)" , "Kelley, Sean V" Subject: Re: [PATCH 05/14] cxl/mem: Register CXL memX devices Message-ID: <20210202181354.GE3708021@infradead.org> References: <20210130002438.1872527-1-ben.widawsky@intel.com> <20210130002438.1872527-6-ben.widawsky@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210130002438.1872527-6-ben.widawsky@intel.com> X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > diff --git a/drivers/base/core.c b/drivers/base/core.c > index 25e08e5f40bd..33432a4cbe23 100644 > --- a/drivers/base/core.c > +++ b/drivers/base/core.c > @@ -3179,6 +3179,20 @@ struct device *get_device(struct device *dev) > } > EXPORT_SYMBOL_GPL(get_device); > > +/** > + * get_live_device() - increment reference count for device iff !dead > + * @dev: device. > + * > + * Forward the call to get_device() if the device is still alive. If > + * this is called with the device_lock() held then the device is > + * guaranteed to not die until the device_lock() is dropped. > + */ > +struct device *get_live_device(struct device *dev) > +{ > + return dev && !dev->p->dead ? get_device(dev) : NULL; > +} > +EXPORT_SYMBOL_GPL(get_live_device); Err, if you want to add new core functionality that needs to be in a separate well documented prep patch, and also CCed to the relevant maintainers. > mutex_unlock(&cxlm->mbox.mutex); > } > > +static int cxl_memdev_open(struct inode *inode, struct file *file) > +{ > + struct cxl_memdev *cxlmd = > + container_of(inode->i_cdev, typeof(*cxlmd), cdev); > + > + file->private_data = cxlmd; There is no good reason to ever mirror stuff from the inode into file->private_data, as you can just trivially get at the original location using file_inode(file).