From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6F78DC433DB for ; Tue, 2 Feb 2021 18:16:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4805864F68 for ; Tue, 2 Feb 2021 18:16:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238308AbhBBSQK (ORCPT ); Tue, 2 Feb 2021 13:16:10 -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-pci@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).