diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2017-07-04 05:57:30 +0300 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2017-07-04 05:57:30 +0300 |
commit | cbcd4f08aa637b74f575268770da86a00fabde6d (patch) | |
tree | 449b5da5a05a8539b75640bcc4661147d840e053 /drivers/tty | |
parent | 362f6729cbb1d6bbab59e069f19441b0622ff7ec (diff) | |
parent | 9b326dfce12afb429915c63f5a3df4afa4bea957 (diff) | |
download | linux-cbcd4f08aa637b74f575268770da86a00fabde6d.tar.xz |
Merge tag 'staging-4.13-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging
Pull staging/IIO updates from Greg KH:
"Here's the large set of staging and iio driver patches for 4.13-rc1.
After over 500 patches, we removed about 200 more lines of code than
we added, not great, but we added some new IIO drivers for unsupported
hardware, so it's an overall win.
Also here are lots of small fixes, and some tty core api additions
(with the tty maintainer's ack) for the speakup drivers, those are
finally getting some much needed cleanups and are looking much better
now than before. Full details in the shortlog.
All of these have been in linux-next for a while with no reported
issues"
* tag 'staging-4.13-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging: (529 commits)
staging: lustre: replace kmalloc with kmalloc_array
Staging: ion: fix code style warning from NULL comparisons
staging: fsl-mc: make dprc.h header private
staging: fsl-mc: move mc-cmd.h contents in the public header
staging: fsl-mc: move mc-sys.h contents in the public header
staging: fsl-mc: fix a few implicit includes
staging: fsl-mc: remove dpmng API files
staging: fsl-mc: move rest of mc-bus.h to private header
staging: fsl-mc: move couple of definitions to public header
staging: fsl-mc: move irq domain creation prototype to public header
staging: fsl-mc: turn several exported functions static
staging: fsl-mc: delete prototype of unimplemented function
staging: fsl-mc: delete duplicated function prototypes
staging: fsl-mc: decouple the mc-bus public headers from dprc.h
staging: fsl-mc: drop useless #includes
staging: fsl-mc: be consistent when checking strcmp() return
staging: fsl-mc: move comparison before strcmp() call
staging: speakup: make function ser_to_dev static
staging: ks7010: fix spelling mistake: "errror" -> "error"
staging: rtl8192e: fix spelling mistake: "respose" -> "response"
...
Diffstat (limited to 'drivers/tty')
-rw-r--r-- | drivers/tty/tty_io.c | 60 | ||||
-rw-r--r-- | drivers/tty/tty_ldisc.c | 2 |
2 files changed, 59 insertions, 3 deletions
diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c index 0c150b5a9dd6..974b13d24401 100644 --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c @@ -325,6 +325,56 @@ static struct tty_driver *get_tty_driver(dev_t device, int *index) return NULL; } +/** + * tty_dev_name_to_number - return dev_t for device name + * @name: user space name of device under /dev + * @number: pointer to dev_t that this function will populate + * + * This function converts device names like ttyS0 or ttyUSB1 into dev_t + * like (4, 64) or (188, 1). If no corresponding driver is registered then + * the function returns -ENODEV. + * + * Locking: this acquires tty_mutex to protect the tty_drivers list from + * being modified while we are traversing it, and makes sure to + * release it before exiting. + */ +int tty_dev_name_to_number(const char *name, dev_t *number) +{ + struct tty_driver *p; + int ret; + int index, prefix_length = 0; + const char *str; + + for (str = name; *str && !isdigit(*str); str++) + ; + + if (!*str) + return -EINVAL; + + ret = kstrtoint(str, 10, &index); + if (ret) + return ret; + + prefix_length = str - name; + mutex_lock(&tty_mutex); + + list_for_each_entry(p, &tty_drivers, tty_drivers) + if (prefix_length == strlen(p->name) && strncmp(name, + p->name, prefix_length) == 0) { + if (index < p->num) { + *number = MKDEV(p->major, p->minor_start + index); + goto out; + } + } + + /* if here then driver wasn't found */ + ret = -ENODEV; +out: + mutex_unlock(&tty_mutex); + return ret; +} +EXPORT_SYMBOL_GPL(tty_dev_name_to_number); + #ifdef CONFIG_CONSOLE_POLL /** @@ -1083,7 +1133,10 @@ static struct tty_struct *tty_driver_lookup_tty(struct tty_driver *driver, struct tty_struct *tty; if (driver->ops->lookup) - tty = driver->ops->lookup(driver, file, idx); + if (!file) + tty = ERR_PTR(-EIO); + else + tty = driver->ops->lookup(driver, file, idx); else tty = driver->ttys[idx]; @@ -1715,7 +1768,7 @@ static struct tty_driver *tty_lookup_driver(dev_t device, struct file *filp, struct tty_driver *console_driver = console_device(index); if (console_driver) { driver = tty_driver_kref_get(console_driver); - if (driver) { + if (driver && filp) { /* Don't let /dev/console block */ filp->f_flags |= O_NONBLOCK; break; @@ -1748,7 +1801,7 @@ static struct tty_driver *tty_lookup_driver(dev_t device, struct file *filp, * - concurrent tty driver removal w/ lookup * - concurrent tty removal from driver table */ -static struct tty_struct *tty_open_by_driver(dev_t device, struct inode *inode, +struct tty_struct *tty_open_by_driver(dev_t device, struct inode *inode, struct file *filp) { struct tty_struct *tty; @@ -1793,6 +1846,7 @@ out: tty_driver_kref_put(driver); return tty; } +EXPORT_SYMBOL_GPL(tty_open_by_driver); /** * tty_open - open a tty device diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c index e4603b09863a..f6ffe28b8a0d 100644 --- a/drivers/tty/tty_ldisc.c +++ b/drivers/tty/tty_ldisc.c @@ -605,6 +605,7 @@ err: tty_unlock(tty); return retval; } +EXPORT_SYMBOL_GPL(tty_set_ldisc); /** * tty_ldisc_kill - teardown ldisc @@ -797,6 +798,7 @@ void tty_ldisc_release(struct tty_struct *tty) tty_ldisc_debug(tty, "released\n"); } +EXPORT_SYMBOL_GPL(tty_ldisc_release); /** * tty_ldisc_init - ldisc setup for new tty |