diff --git a/drivers/base/core.c b/drivers/base/core.c
index 25e08e5f40bd..33432a4cbe23 100644
@@ -3179,6 +3179,20 @@ struct device *get_device(struct device *dev)
+ * 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;
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
+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).