From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Sender: rtc-linux@googlegroups.com Received: from quartz.orcorp.ca (quartz.orcorp.ca. [184.70.90.242]) by gmr-mx.google.com with ESMTPS id b188si1480860ite.3.2017.02.27.08.44.40 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 Feb 2017 08:44:40 -0800 (PST) Date: Mon, 27 Feb 2017 09:42:09 -0700 From: Jason Gunthorpe 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 , Jarkko Sakkinen , Olof Johansson , Doug Ledford , Sean Hefty , Hal Rosenstock , Dmitry Vyukov , Haggai Eran , Parav Pandit , Leon Romanovsky , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , Hans Verkuil , Mauro Carvalho Chehab , Artem Bityutskiy , Richard Weinberger , David Woodhouse , Brian Norris , Boris Brezillon , Marek Vasut , Cyrille Pitchen , Matt Porter , Alexandre Bounine , Andrew Morton , Joe Perches , Lorenzo Stoakes , Vladimir Zapolskiy , Alessandro Zummo , Alexandre Belloni , Boaz Harrosh , "James E.J. Bottomley" , "Martin K. Petersen" , Stephen Bates , Bjorn Helgaas , linux-pci@vger.kernel.org, linux-scsi@vger.kernel.org, rtc-linux@googlegroups.com, linux-mtd@lists.infradead.org, linux-media@vger.kernel.org, linux-iio@vger.kernel.org, linux-rdma@vger.kernel.org, linux-gpio@vger.kernel.org, linux-input@vger.kernel.org, linux-nvdimm@ml01.01.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [rtc-linux] Re: [PATCH v2 06/16] tpm-chip: utilize new cdev_device_add helper function Message-ID: <20170227164209.GD5891@obsidianresearch.com> References: <1488091097-12328-1-git-send-email-logang@deltatee.com> <1488091097-12328-7-git-send-email-logang@deltatee.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 In-Reply-To: <1488091097-12328-7-git-send-email-logang@deltatee.com> Reply-To: rtc-linux@googlegroups.com List-ID: List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , On Sat, Feb 25, 2017 at 11:38:07PM -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 > 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 a77262d..933f96e 100644 > +++ b/drivers/char/tpm/tpm-chip.c > @@ -187,7 +187,6 @@ struct tpm_chip *tpm_chip_alloc(struct device *dev, > > 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; > - } This will collide with the patch I sent: https://patchwork.kernel.org/patch/9589001/ Jarkko: The resolution will be to continue to call tpm_del_char_device from the cdev_device_add error path and drop all calls to cdev_del Reviewed-by: Jason Gunthorpe Jason -- 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@googlegroups.com. For more options, visit https://groups.google.com/d/optout.