public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Earl Chew <echew@ixiacom.com>
To: <linux-kernel@vger.kernel.org>
Cc: "Hans J. Koch" <hjk@linutronix.de>
Subject: RFC: UIO  null parent for __uio_register_device and uio_device_name()
Date: Tue, 18 Jan 2011 19:56:52 -0800	[thread overview]
Message-ID: <4D366104.1000400@ixiacom.com> (raw)

Hans,

I had a two UIO changes queued up from earlier which I
forgot to ask you about.

Would you consider these changes for inclusion in the mainline ?


o Allow a null parent during uio_register_device. We've had
  situations where there was no convenient parent. We could
  concoct a parent, but it seemed to make sense to allow
  for a null.

  The commentary for device_create() say:

 * device_create - creates a device and registers it with sysfs
 * @class: pointer to the struct class that this device should be registered to
 * @parent: pointer to the parent struct device of this new device, if any

 The "if any" suggests that a null parent is possibility that is catered for.

 Our implementation with a null parent seems to work fine.

o Introduce uio_device_name() to allow callers to query for the
  name of the created uio device. Without this, there doesn't seem
  to be a straightforward way for a client to figure out the name of the
  device.




--- /tmp/uio.c.orig     2011-01-18 17:38:17.157452875 -0800
+++ /tmp/uio.c  2011-01-18 19:46:48.367453578 -0800
@@ -808,6 +808,18 @@
 }

 /**
+ * uio_device_name - obtain the name of the registered device
+ * @info:      UIO device capabilities
+ *
+ * returns name of device.
+ */
+const char *uio_device_name(struct uio_info *info)
+{
+       return dev_name(info->uio_dev->dev);
+}
+EXPORT_SYMBOL_GPL(uio_device_name);
+
+/**
  * uio_register_device - register a new userspace IO device
  * @owner:     module that creates the new device
  * @parent:    parent device
@@ -822,7 +834,7 @@
        struct uio_device *idev;
        int ret = 0;

-       if (!parent || !info || !info->name || !info->version)
+       if (!info || !info->name || !info->version)
                return -EINVAL;

        info->uio_dev = NULL;

--- /tmp/uio.c.orig     2011-01-18 17:38:17.157452875 -0800
+++ /tmp/uio.c  2011-01-18 17:38:56.307452064 -0800
@@ -822,7 +822,7 @@
        struct uio_device *idev;
        int ret = 0;

-       if (!parent || !info || !info->name || !info->version)
+       if (!info || !info->name || !info->version)
                return -EINVAL;

        info->uio_dev = NULL;


--- /tmp/uio_driver.h.orig      2011-01-18 19:42:13.777452360 -0800
+++ /tmp/uio_driver.h   2011-01-18 19:45:03.507453695 -0800
@@ -105,6 +105,7 @@
 }
 extern void uio_unregister_device(struct uio_info *info);
 extern void uio_event_notify(struct uio_info *info);
+extern const char *uio_device_name(struct uio_device *info);

 /* defines for uio_info->irq */
 #define UIO_IRQ_CUSTOM -1

             reply	other threads:[~2011-01-19  4:02 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-19  3:56 Earl Chew [this message]
2011-01-19 14:56 ` RFC: UIO null parent for __uio_register_device and uio_device_name() Hans J. Koch
2011-01-19 15:42   ` Earl Chew
2011-01-19 16:30     ` Greg KH
2011-01-19 17:07       ` Earl Chew
2011-01-19 17:11         ` Earl Chew
2011-01-19 17:24           ` Greg KH
2011-01-19 17:22         ` Greg KH
2011-01-19 20:52         ` Hans J. Koch
2011-01-19 22:06           ` Earl Chew
2011-01-19 22:41             ` Greg KH

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=4D366104.1000400@ixiacom.com \
    --to=echew@ixiacom.com \
    --cc=hjk@linutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    /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