Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 325649
b: refs/heads/master
c: 7f0bc6a
h: refs/heads/master
i:
  325647: e677d88
v: v3
  • Loading branch information
Jiri Slaby authored and Greg Kroah-Hartman committed Aug 10, 2012
1 parent 7c064c6 commit 7d60642
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 14 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 2312e4f3b2f17cac2cf257c759ad48eb80fdf230
refs/heads/master: 7f0bc6a68ed93f3b4ad77b94df5ef32446c583e3
34 changes: 25 additions & 9 deletions trunk/drivers/tty/tty_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -3061,21 +3061,37 @@ void tty_unregister_device(struct tty_driver *driver, unsigned index)
}
EXPORT_SYMBOL(tty_unregister_device);

struct tty_driver *__alloc_tty_driver(int lines, struct module *owner)
/**
* __tty_alloc_driver -- allocate tty driver
* @lines: count of lines this driver can handle at most
* @owner: module which is repsonsible for this driver
* @flags: some of TTY_DRIVER_* flags, will be set in driver->flags
*
* This should not be called directly, some of the provided macros should be
* used instead. Use IS_ERR and friends on @retval.
*/
struct tty_driver *__tty_alloc_driver(unsigned int lines, struct module *owner,
unsigned long flags)
{
struct tty_driver *driver;

if (!lines)
return ERR_PTR(-EINVAL);

driver = kzalloc(sizeof(struct tty_driver), GFP_KERNEL);
if (driver) {
kref_init(&driver->kref);
driver->magic = TTY_DRIVER_MAGIC;
driver->num = lines;
driver->owner = owner;
/* later we'll move allocation of tables here */
}
if (!driver)
return ERR_PTR(-ENOMEM);

kref_init(&driver->kref);
driver->magic = TTY_DRIVER_MAGIC;
driver->num = lines;
driver->owner = owner;
driver->flags = flags;
/* later we'll move allocation of tables here */

return driver;
}
EXPORT_SYMBOL(__alloc_tty_driver);
EXPORT_SYMBOL(__tty_alloc_driver);

static void destruct_tty_driver(struct kref *kref)
{
Expand Down
23 changes: 19 additions & 4 deletions trunk/include/linux/tty_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -296,11 +296,11 @@ struct tty_driver {
int name_base; /* offset of printed name */
int major; /* major device number */
int minor_start; /* start of minor device number */
int num; /* number of devices allocated */
unsigned int num; /* number of devices allocated */
short type; /* type of tty driver */
short subtype; /* subtype of tty driver */
struct ktermios init_termios; /* Initial termios */
int flags; /* tty driver flags */
unsigned long flags; /* tty driver flags */
struct proc_dir_entry *proc_entry; /* /proc fs entry */
struct tty_driver *other; /* only used for the PTY driver */

Expand All @@ -322,15 +322,30 @@ struct tty_driver {

extern struct list_head tty_drivers;

extern struct tty_driver *__alloc_tty_driver(int lines, struct module *owner);
extern struct tty_driver *__tty_alloc_driver(unsigned int lines,
struct module *owner, unsigned long flags);
extern void put_tty_driver(struct tty_driver *driver);
extern void tty_set_operations(struct tty_driver *driver,
const struct tty_operations *op);
extern struct tty_driver *tty_find_polling_driver(char *name, int *line);

extern void tty_driver_kref_put(struct tty_driver *driver);

#define alloc_tty_driver(lines) __alloc_tty_driver(lines, THIS_MODULE)
/* Use TTY_DRIVER_* flags below */
#define tty_alloc_driver(lines, flags) \
__tty_alloc_driver(lines, THIS_MODULE, flags)

/*
* DEPRECATED Do not use this in new code, use tty_alloc_driver instead.
* (And change the return value checks.)
*/
static inline struct tty_driver *alloc_tty_driver(unsigned int lines)
{
struct tty_driver *ret = tty_alloc_driver(lines, 0);
if (IS_ERR(ret))
return NULL;
return ret;
}

static inline struct tty_driver *tty_driver_kref_get(struct tty_driver *d)
{
Expand Down

0 comments on commit 7d60642

Please sign in to comment.