diff mbox

[02/14] device-dax: utilize new device_add_cdev helper function

Message ID 1487653253-11497-3-git-send-email-logang@deltatee.com (mailing list archive)
State New, archived
Headers show

Commit Message

Logan Gunthorpe Feb. 21, 2017, 5 a.m. UTC
Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
---
 drivers/dax/dax.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Comments

Alexandre Belloni Feb. 21, 2017, 11:37 a.m. UTC | #1
Hi,

A small comment, you must always have a commit message. Even if it is
small.

On 20/02/2017 at 22:00:41 -0700, Logan Gunthorpe wrote:
> Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
> ---
>  drivers/dax/dax.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/dax/dax.c b/drivers/dax/dax.c
> index ed758b7..0d24822 100644
> --- a/drivers/dax/dax.c
> +++ b/drivers/dax/dax.c
> @@ -701,12 +701,12 @@ struct dax_dev *devm_create_dax_dev(struct dax_region *dax_region,
>  
>  	/* device_initialize() so cdev can reference kobj parent */
>  	device_initialize(dev);
> +	dev->devt = dev_t;
>  
>  	cdev = &dax_dev->cdev;
>  	cdev_init(cdev, &dax_fops);
>  	cdev->owner = parent->driver->owner;
> -	cdev->kobj.parent = &dev->kobj;
> -	rc = cdev_add(&dax_dev->cdev, dev_t, 1);
> +	rc = device_add_cdev(dev, cdev);
>  	if (rc)
>  		goto err_cdev;
>  
> @@ -716,7 +716,6 @@ struct dax_dev *devm_create_dax_dev(struct dax_region *dax_region,
>  	dax_dev->region = dax_region;
>  	kref_get(&dax_region->kref);
>  
> -	dev->devt = dev_t;
>  	dev->class = dax_class;
>  	dev->parent = parent;
>  	dev->groups = dax_attribute_groups;
> -- 
> 2.1.4
>
Dan Williams Feb. 21, 2017, 7:26 p.m. UTC | #2
On Tue, Feb 21, 2017 at 3:37 AM, Alexandre Belloni
<alexandre.belloni@free-electrons.com> wrote:
> Hi,
>
> A small comment, you must always have a commit message. Even if it is
> small.

Yes, something like: "Replace the open coded initialization of the
cdev with the new device_add_cdev() helper. The helper takes the
proper reference against the parent device while the cdev object is
alive."

With that you can also add:

Acked-by: Dan Williams <dan.j.williams@intel.com>

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
diff mbox

Patch

diff --git a/drivers/dax/dax.c b/drivers/dax/dax.c
index ed758b7..0d24822 100644
--- a/drivers/dax/dax.c
+++ b/drivers/dax/dax.c
@@ -701,12 +701,12 @@  struct dax_dev *devm_create_dax_dev(struct dax_region *dax_region,
 
 	/* device_initialize() so cdev can reference kobj parent */
 	device_initialize(dev);
+	dev->devt = dev_t;
 
 	cdev = &dax_dev->cdev;
 	cdev_init(cdev, &dax_fops);
 	cdev->owner = parent->driver->owner;
-	cdev->kobj.parent = &dev->kobj;
-	rc = cdev_add(&dax_dev->cdev, dev_t, 1);
+	rc = device_add_cdev(dev, cdev);
 	if (rc)
 		goto err_cdev;
 
@@ -716,7 +716,6 @@  struct dax_dev *devm_create_dax_dev(struct dax_region *dax_region,
 	dax_dev->region = dax_region;
 	kref_get(&dax_region->kref);
 
-	dev->devt = dev_t;
 	dev->class = dax_class;
 	dev->parent = parent;
 	dev->groups = dax_attribute_groups;