From: Logan Gunthorpe <logang@deltatee.com>
To: Keith Busch <keith.busch@intel.com>,
Myron Stowe <myron.stowe@gmail.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Bjorn Helgaas <bhelgaas@google.com>,
Geert Uytterhoeven <geert+renesas@glider.be>,
Jonathan Corbet <corbet@lwn.net>,
"David S. Miller" <davem@davemloft.net>,
Andrew Morton <akpm@linux-foundation.org>,
Emil Velikov <emil.l.velikov@gmail.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Guenter Roeck <linux@roeck-us.net>,
Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>,
Linus Walleij <linus.walleij@linaro.org>,
Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>,
Stefan Berger <stefanb@linux.vnet.ibm.com>,
Wei Zhang <wzhang@fb.com>
Cc: Kurt Schwemmer <kurt.schwemmer@microsemi.com>,
Stephen Bates <stephen.bates@microsemi.com>,
linux-pci@vger.kernel.org, linux-doc@vger.kernel.org,
linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org,
Logan Gunthorpe <logang@deltatee.com>
Subject: [PATCH] switchtec: cleanup cdev init
Date: Fri, 10 Feb 2017 10:57:20 -0700 [thread overview]
Message-ID: <1486749440-24309-1-git-send-email-logang@deltatee.com> (raw)
In-Reply-To: <20170210145124.GA24594@kroah.com>
Per a suggestion from Greg Kroah-Hartman [1], don't set the cdev's
kobject parent. This allows us to use device_register instead of init
and add.
[1] https://lkml.org/lkml/2017/2/10/370
---
drivers/pci/switch/switchtec.c | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/drivers/pci/switch/switchtec.c b/drivers/pci/switch/switchtec.c
index 82bfd18..014eaec 100644
--- a/drivers/pci/switch/switchtec.c
+++ b/drivers/pci/switch/switchtec.c
@@ -1222,24 +1222,23 @@ static struct switchtec_dev *stdev_create(struct pci_dev *pdev)
return ERR_PTR(minor);
dev = &stdev->dev;
- device_initialize(dev);
dev->devt = MKDEV(MAJOR(switchtec_devt), minor);
- dev->class = switchtec_class;
- dev->parent = &pdev->dev;
- dev->groups = switchtec_device_groups;
- dev->release = stdev_release;
- dev_set_name(dev, "switchtec%d", minor);
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);
if (rc)
goto err_cdev;
- rc = device_add(dev);
+ dev->class = switchtec_class;
+ dev->parent = &pdev->dev;
+ dev->groups = switchtec_device_groups;
+ dev->release = stdev_release;
+ dev_set_name(dev, "switchtec%d", minor);
+
+ rc = device_register(dev);
if (rc) {
cdev_del(&stdev->cdev);
put_device(dev);
--
2.1.4
next prev parent reply other threads:[~2017-02-10 17:57 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-02 18:05 [PATCH v2 0/4] New Microsemi PCI Switch Management Driver Logan Gunthorpe
2017-02-02 18:06 ` [PATCH v2 1/4] MicroSemi Switchtec management interface driver Logan Gunthorpe
2017-02-10 14:51 ` Greg Kroah-Hartman
2017-02-10 16:48 ` Logan Gunthorpe
2017-02-10 16:55 ` Greg Kroah-Hartman
2017-02-10 17:03 ` Logan Gunthorpe
2017-02-10 17:09 ` Greg Kroah-Hartman
2017-02-10 18:00 ` Logan Gunthorpe
2017-02-10 17:57 ` Logan Gunthorpe [this message]
2017-02-18 20:22 ` [PATCH] switchtec: cleanup cdev init Logan Gunthorpe
2017-02-19 21:43 ` Dan Williams
2017-02-20 4:22 ` Logan Gunthorpe
2017-02-21 18:37 ` Jason Gunthorpe
2017-02-10 14:54 ` [PATCH v2 1/4] MicroSemi Switchtec management interface driver Greg Kroah-Hartman
2017-02-24 0:35 ` Bjorn Helgaas
2017-02-24 18:32 ` Logan Gunthorpe
2017-02-02 18:06 ` [PATCH v2 2/4] switchtec: Add user interface documentation Logan Gunthorpe
2017-02-02 18:06 ` [PATCH v2 3/4] switchtec: Add sysfs attributes to the Switchtec driver Logan Gunthorpe
2017-02-10 14:54 ` Greg Kroah-Hartman
2017-02-23 22:43 ` Bjorn Helgaas
2017-02-23 22:56 ` Logan Gunthorpe
2017-02-24 22:45 ` Bjorn Helgaas
2017-02-02 18:06 ` [PATCH v2 4/4] switchtec: Add IOCTLs " Logan Gunthorpe
2017-02-09 23:16 ` [PATCH v2 0/4] New Microsemi PCI Switch Management Driver Wei Zhang
2017-02-09 23:46 ` Wei Zhang
2017-02-10 14:54 ` Greg Kroah-Hartman
2017-02-10 16:14 ` Jens Axboe
2017-02-17 20:36 ` Logan Gunthorpe
2017-02-23 20:36 ` Logan Gunthorpe
2017-02-23 20:51 ` Sinan Kaya
2017-02-23 20:54 ` Jens Axboe
2017-02-23 20:56 ` Logan Gunthorpe
2017-02-23 20:52 ` Jens Axboe
2017-02-23 20:55 ` Greg Kroah-Hartman
2017-02-23 22:14 ` Bjorn Helgaas
2017-02-23 22:19 ` Logan Gunthorpe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1486749440-24309-1-git-send-email-logang@deltatee.com \
--to=logang@deltatee.com \
--cc=akpm@linux-foundation.org \
--cc=bhelgaas@google.com \
--cc=corbet@lwn.net \
--cc=davem@davemloft.net \
--cc=emil.l.velikov@gmail.com \
--cc=geert+renesas@glider.be \
--cc=gregkh@linuxfoundation.org \
--cc=jarkko.sakkinen@linux.intel.com \
--cc=keith.busch@intel.com \
--cc=konishi.ryusuke@lab.ntt.co.jp \
--cc=kurt.schwemmer@microsemi.com \
--cc=linus.walleij@linaro.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=mchehab@kernel.org \
--cc=myron.stowe@gmail.com \
--cc=stefanb@linux.vnet.ibm.com \
--cc=stephen.bates@microsemi.com \
--cc=wzhang@fb.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).