From: Tilman Schmidt <tilman@imap.cc>
To: Andrew Morton <akpm@osdl.org>
Cc: linux-kernel@vger.kernel.org, gregkh@suse.de, hjlipp@web.de
Subject: Re: [PATCH 2.6.17-rc2 1/2] return class device pointer from tty_register_device()
Date: Sat, 22 Apr 2006 18:36:53 +0200 [thread overview]
Message-ID: <444A5BA5.6040007@imap.cc> (raw)
In-Reply-To: <20060421181429.5ea9d777.akpm@osdl.org>
[-- Attachment #1: Type: text/plain, Size: 3434 bytes --]
On 22.04.2006 03:14, Andrew Morton wrote:
> Tilman Schmidt <tilman@imap.cc> wrote:
>
>> + * Returns a pointer to the class device (or NULL on error).
>> + *
>
> It would be better to make this return ERR_PTR(-Efoo) on error, rather than
> NULL.
Good point. Here's an accordingly updated version.
I'll follow up with a matching version of part 2.
From: Hansjoerg Lipp <hjlipp@web.de>
Let tty_register_device() return a pointer to the class device it creates.
This allows registrants to add their own sysfs files under the class
device node.
Signed-off-by: Hansjoerg Lipp <hjlipp@web.de>
Signed-off-by: Tilman Schmidt <tilman@imap.cc>
---
drivers/char/tty_io.c | 11 +++++++----
include/linux/tty.h | 4 +++-
2 files changed, 10 insertions(+), 5 deletions(-)
diff -urpN -X exclude linux-2.6.17-rc1-mm2.orig/drivers/char/tty_io.c linux-2.6.17-rc1-mm2/drivers/char/tty_io.c
--- linux-2.6.17-rc1-mm2.orig/drivers/char/tty_io.c 2006-04-09 18:30:56.000000000 +0200
+++ linux-2.6.17-rc1-mm2/drivers/char/tty_io.c 2006-04-22 04:57:59.000000000 +0200
@@ -2957,12 +2957,14 @@ static struct class *tty_class;
* This field is optional, if there is no known struct device for this
* tty device it can be set to NULL safely.
*
+ * Returns a pointer to the class device (or ERR_PTR(-Efoo) on error).
+ *
* This call is required to be made to register an individual tty device if
* the tty driver's flags have the TTY_DRIVER_NO_DEVFS bit set. If that
* bit is not set, this function should not be called.
*/
-void tty_register_device(struct tty_driver *driver, unsigned index,
- struct device *device)
+struct class_device *tty_register_device(struct tty_driver *driver,
+ unsigned index, struct device *device)
{
char name[64];
dev_t dev = MKDEV(driver->major, driver->minor_start) + index;
@@ -2970,7 +2972,7 @@ void tty_register_device(struct tty_driv
if (index >= driver->num) {
printk(KERN_ERR "Attempt to register invalid tty line number "
" (%d).\n", index);
- return;
+ return ERR_PTR(-EINVAL);
}
devfs_mk_cdev(dev, S_IFCHR | S_IRUSR | S_IWUSR,
@@ -2980,7 +2982,8 @@ void tty_register_device(struct tty_driv
pty_line_name(driver, index, name);
else
tty_line_name(driver, index, name);
- class_device_create(tty_class, NULL, dev, device, "%s", name);
+
+ return class_device_create(tty_class, NULL, dev, device, "%s", name);
}
/**
diff -urpN -X exclude linux-2.6.17-rc1-mm2.orig/include/linux/tty.h linux-2.6.17-rc1-mm2/include/linux/tty.h
--- linux-2.6.17-rc1-mm2.orig/include/linux/tty.h 2006-04-04 23:29:14.000000000 +0200
+++ linux-2.6.17-rc1-mm2/include/linux/tty.h 2006-04-22 05:12:34.000000000 +0200
@@ -291,7 +291,9 @@ extern int tty_register_ldisc(int disc,
extern int tty_unregister_ldisc(int disc);
extern int tty_register_driver(struct tty_driver *driver);
extern int tty_unregister_driver(struct tty_driver *driver);
-extern void tty_register_device(struct tty_driver *driver, unsigned index, struct device *dev);
+extern struct class_device *tty_register_device(struct tty_driver *driver,
+ unsigned index,
+ struct device *dev);
extern void tty_unregister_device(struct tty_driver *driver, unsigned index);
extern int tty_read_raw_data(struct tty_struct *tty, unsigned char *bufp,
int buflen);
--
Tilman Schmidt E-Mail: tilman@imap.cc
Bonn, Germany
Imagine a world without hypothetical situations.
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 253 bytes --]
next prev parent reply other threads:[~2006-04-22 17:26 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-04-22 0:59 [PATCH 2.6.17-rc2 1/2] return class device pointer from tty_register_device() Tilman Schmidt
2006-04-22 1:14 ` Andrew Morton
2006-04-22 4:16 ` Greg KH
2006-04-22 16:36 ` Tilman Schmidt [this message]
2006-04-22 18:07 ` [PATCH 2.6.17-rc2 2/2] i4l gigaset: move sysfs entry to tty class device Tilman Schmidt
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=444A5BA5.6040007@imap.cc \
--to=tilman@imap.cc \
--cc=akpm@osdl.org \
--cc=gregkh@suse.de \
--cc=hjlipp@web.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