From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 8ACB080349 for ; Mon, 6 Mar 2017 21:31:47 -0800 (PST) Date: Tue, 7 Mar 2017 06:31:38 +0100 From: Greg Kroah-Hartman Subject: Re: [PATCH v3 06/16] tpm-chip: utilize new cdev_device_add helper function Message-ID: <20170307053138.GA7665@kroah.com> References: <1488783873-2614-1-git-send-email-logang@deltatee.com> <1488783873-2614-7-git-send-email-logang@deltatee.com> <20170306210426.qeftgujergryutie@intel.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20170306210426.qeftgujergryutie@intel.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" To: Jarkko Sakkinen Cc: Alessandro Zummo , Jan Kara , linux-iio@vger.kernel.org, linux-pci@vger.kernel.org, Linus Walleij , Alexandre Bounine , Alexandre Belloni , Peter Meerwald-Stadler , linux-scsi@vger.kernel.org, Sean Hefty , Parav Pandit , Peter Huewe , Alexandre Courbot , Lars-Peter Clausen , "James E.J. Bottomley" , rtc-linux@googlegroups.com, Leon Romanovsky , linux-nvdimm@lists.01.org, linux-rdma@vger.kernel.org, Richard Weinberger , Jason Gunthorpe , Marek Vasut , Doug Ledford , Hans Verkuil , Matt Porter , Hal Rosenstock , linux-media@vger.kernel.org, Boaz Harrosh , Arnd Bergmann , Boris Brezillon , Sajjan Vikas C , linux-input@vger.kernel.org, Marcel Selhorst , Vladimir Zapolskiy , Joe Perches , Cyrille Pitchen , Alexander Viro , Bjorn Helgaas , Mauro Carvalho Chehab , Dmitry Vyukov , linux-fsdevel@vger.kernel.org, Haggai Eran , Lorenzo Stoakes , "Martin K. Petersen" , Artem Bityutskiy , David Woodhouse , linux-gpio@vger.kernel.org, Dmitry Torokhov , linux-kernel@vger.kernel.org, Stephen Bates , Hartmut Knaack , Olof Johansson , linux-mtd@lists.infradead.org, Andrew Morton , Brian Norris List-ID: On Mon, Mar 06, 2017 at 11:04:26PM +0200, Jarkko Sakkinen wrote: > 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? I can take it all at once through my tree. thanks, greg k-h _______________________________________________ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm