From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jarkko Sakkinen Subject: Re: [PATCH v3 06/16] tpm-chip: utilize new cdev_device_add helper function Date: Mon, 6 Mar 2017 23:04:26 +0200 Message-ID: <20170306210426.qeftgujergryutie@intel.com> References: <1488783873-2614-1-git-send-email-logang@deltatee.com> <1488783873-2614-7-git-send-email-logang@deltatee.com> Reply-To: rtc-linux-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Return-path: Sender: rtc-linux-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Content-Disposition: inline In-Reply-To: <1488783873-2614-7-git-send-email-logang-OTvnGxWRz7hWk0Htik3J/w@public.gmane.org> List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , To: Logan Gunthorpe Cc: Greg Kroah-Hartman , Dan Williams , Alexander Viro , Johannes Thumshirn , Jan Kara , Arnd Bergmann , Sajjan Vikas C , Dmitry Torokhov , Linus Walleij , Alexandre Courbot , Peter Huewe , Marcel Selhorst , Jason Gunthorpe , Olof Johansson , Doug Ledford , Sean Hefty , Hal Rosenstock , Dmitry Vyukov , Haggai Eran , Parav Pandit , Leon Romanovsky , Hartmut Knaack , Lars-Peter Clausen List-Id: linux-input@vger.kernel.org On Mon, Mar 06, 2017 at 12:04:22AM -0700, Logan Gunthorpe wrote: > Replace the open coded registration of the cdev and dev with the > new device_add_cdev() helper. The helper replaces a common pattern by > taking the proper reference against the parent device and adding both > the cdev and the device. > > Signed-off-by: Logan Gunthorpe > Reviewed-by: Jason Gunthorpe > --- > drivers/char/tpm/tpm-chip.c | 19 +++---------------- > 1 file changed, 3 insertions(+), 16 deletions(-) > > diff --git a/drivers/char/tpm/tpm-chip.c b/drivers/char/tpm/tpm-chip.c > index c406343..935f0e9 100644 > --- a/drivers/char/tpm/tpm-chip.c > +++ b/drivers/char/tpm/tpm-chip.c > @@ -187,7 +187,6 @@ struct tpm_chip *tpm_chip_alloc(struct device *pdev, > > cdev_init(&chip->cdev, &tpm_fops); > chip->cdev.owner = THIS_MODULE; > - chip->cdev.kobj.parent = &chip->dev.kobj; > > return chip; > > @@ -230,27 +229,16 @@ static int tpm_add_char_device(struct tpm_chip *chip) > { > int rc; > > - rc = cdev_add(&chip->cdev, chip->dev.devt, 1); > + rc = cdev_device_add(&chip->cdev, &chip->dev); > if (rc) { > dev_err(&chip->dev, > - "unable to cdev_add() %s, major %d, minor %d, err=%d\n", > + "unable to cdev_device_add() %s, major %d, minor %d, err=%d\n", > dev_name(&chip->dev), MAJOR(chip->dev.devt), > MINOR(chip->dev.devt), rc); > > return rc; > } > > - rc = device_add(&chip->dev); > - if (rc) { > - dev_err(&chip->dev, > - "unable to device_register() %s, major %d, minor %d, err=%d\n", > - dev_name(&chip->dev), MAJOR(chip->dev.devt), > - MINOR(chip->dev.devt), rc); > - > - cdev_del(&chip->cdev); > - return rc; > - } > - > /* Make the chip available. */ > mutex_lock(&idr_lock); > idr_replace(&dev_nums_idr, chip, chip->dev_num); > @@ -261,8 +249,7 @@ static int tpm_add_char_device(struct tpm_chip *chip) > > static void tpm_del_char_device(struct tpm_chip *chip) > { > - cdev_del(&chip->cdev); > - device_del(&chip->dev); > + cdev_device_del(&chip->cdev, &chip->dev); > > /* Make the chip unavailable. */ > mutex_lock(&idr_lock); > -- > 2.1.4 > Reviewed-by: Jarkko Sakkinen I cannot test this at this point as security tree does not include the commit that is dependent on this. I'm also wondering if this commit is even going through my tree to upstream? /Jarkko -- You received this message because you are subscribed to "rtc-linux". Membership options at http://groups.google.com/group/rtc-linux . Please read http://groups.google.com/group/rtc-linux/web/checklist before submitting a driver. --- You received this message because you are subscribed to the Google Groups "rtc-linux" group. To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/d/optout.