From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from ale.deltatee.com ([207.54.116.67]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1chsVp-0000lO-Ot for linux-mtd@lists.infradead.org; Sun, 26 Feb 2017 06:40:55 +0000 From: Logan Gunthorpe To: 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 , Jason Gunthorpe , 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 Cc: 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@lists.01.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Logan Gunthorpe Date: Sat, 25 Feb 2017 23:38:17 -0700 Message-Id: <1488091097-12328-17-git-send-email-logang@deltatee.com> In-Reply-To: <1488091097-12328-1-git-send-email-logang@deltatee.com> References: <1488091097-12328-1-git-send-email-logang@deltatee.com> Subject: [PATCH v2 16/16] switchtec: utilize new device_add_cdev helper function List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Very straightforward conversion to device_add_cdev. Drop cdev_add and device_add and use cdev_device_add. Signed-off-by: Logan Gunthorpe --- drivers/pci/switch/switchtec.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/drivers/pci/switch/switchtec.c b/drivers/pci/switch/switchtec.c index 94384e7..bd8135b 100644 --- a/drivers/pci/switch/switchtec.c +++ b/drivers/pci/switch/switchtec.c @@ -1182,10 +1182,10 @@ static void stdev_unregister(struct switchtec_dev *stdev) pci_clear_master(stdev->pdev); pci_set_drvdata(stdev->pdev, NULL); - cdev_del(&stdev->cdev); + cdev_device_del(&stdev->cdev, &stdev->dev); ida_simple_remove(&switchtec_minor_ida, MINOR(stdev->dev.devt)); - device_unregister(&stdev->dev); + put_device(&stdev->dev); } static struct switchtec_dev *stdev_create(struct pci_dev *pdev) @@ -1231,24 +1231,17 @@ static struct switchtec_dev *stdev_create(struct pci_dev *pdev) cdev = &stdev->cdev; cdev_init(cdev, &switchtec_fops); cdev->owner = THIS_MODULE; - cdev->kobj.parent = &dev->kobj; - rc = cdev_add(&stdev->cdev, dev->devt, 1); + rc = cdev_device_add(&stdev->cdev, dev); if (rc) goto err_cdev; - rc = device_add(dev); - if (rc) - goto err_devadd; - return stdev; -err_devadd: +err_cdev: mutex_lock(&stdev->mrpc_mutex); stdev->alive = false; mutex_unlock(&stdev->mrpc_mutex); - cdev_del(&stdev->cdev); -err_cdev: ida_simple_remove(&switchtec_minor_ida, minor); err_put: put_device(&stdev->dev); -- 2.1.4