aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomas Hlavacek <tmshlvck@gmail.com>2012-09-06 17:17:47 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-09-06 17:40:18 -0400
commitb1b799164afb22711e6bee718f2a5ee669bb9517 (patch)
tree2bb7e2c7513b879531a8f0b898bc5557f4a784ed
parent6915c0e487c822e2436683e14302c0b8a6155cc7 (diff)
tty_register_device_attr updated for tty-next
Added tty_device_create_release() and bound to dev->release in tty_register_device_attr(). Added tty_port_register_device_attr() and used in uart_add_one_port() instead of tty_register_device_attr(). Signed-off-by: Tomas Hlavacek <tmshlvck@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/tty/serial/serial_core.c8
-rw-r--r--drivers/tty/tty_io.c7
-rw-r--r--drivers/tty/tty_port.c24
-rw-r--r--include/linux/tty.h4
4 files changed, 39 insertions, 4 deletions
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index f629bdf2a8cf..046279ce3e8d 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -2313,9 +2313,9 @@ static ssize_t uart_get_attr_uartclk(struct device *dev,
2313 struct device_attribute *attr, char *buf) 2313 struct device_attribute *attr, char *buf)
2314{ 2314{
2315 int ret; 2315 int ret;
2316
2317 struct tty_port *port = dev_get_drvdata(dev); 2316 struct tty_port *port = dev_get_drvdata(dev);
2318 struct uart_state *state = container_of(port, struct uart_state, port); 2317 struct uart_state *state = container_of(port, struct uart_state, port);
2318
2319 mutex_lock(&state->port.mutex); 2319 mutex_lock(&state->port.mutex);
2320 ret = snprintf(buf, PAGE_SIZE, "%d\n", state->uart_port->uartclk); 2320 ret = snprintf(buf, PAGE_SIZE, "%d\n", state->uart_port->uartclk);
2321 mutex_unlock(&state->port.mutex); 2321 mutex_unlock(&state->port.mutex);
@@ -2330,7 +2330,7 @@ static struct attribute *tty_dev_attrs[] = {
2330 NULL, 2330 NULL,
2331 }; 2331 };
2332 2332
2333static struct attribute_group tty_dev_attr_group = { 2333static const struct attribute_group tty_dev_attr_group = {
2334 .attrs = tty_dev_attrs, 2334 .attrs = tty_dev_attrs,
2335 }; 2335 };
2336 2336
@@ -2392,8 +2392,8 @@ int uart_add_one_port(struct uart_driver *drv, struct uart_port *uport)
2392 * Register the port whether it's detected or not. This allows 2392 * Register the port whether it's detected or not. This allows
2393 * setserial to be used to alter this ports parameters. 2393 * setserial to be used to alter this ports parameters.
2394 */ 2394 */
2395 tty_dev = tty_register_device_attr(drv->tty_driver, uport->line, 2395 tty_dev = tty_port_register_device_attr(port, drv->tty_driver,
2396 uport->dev, port, tty_dev_attr_groups); 2396 uport->line, uport->dev, port, tty_dev_attr_groups);
2397 if (likely(!IS_ERR(tty_dev))) { 2397 if (likely(!IS_ERR(tty_dev))) {
2398 device_set_wakeup_capable(tty_dev, 1); 2398 device_set_wakeup_capable(tty_dev, 1);
2399 } else { 2399 } else {
diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index dcb30d55d39c..8a5a8b064616 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -3045,6 +3045,12 @@ struct device *tty_register_device(struct tty_driver *driver, unsigned index,
3045} 3045}
3046EXPORT_SYMBOL(tty_register_device); 3046EXPORT_SYMBOL(tty_register_device);
3047 3047
3048static void tty_device_create_release(struct device *dev)
3049{
3050 pr_debug("device: '%s': %s\n", dev_name(dev), __func__);
3051 kfree(dev);
3052}
3053
3048/** 3054/**
3049 * tty_register_device_attr - register a tty device 3055 * tty_register_device_attr - register a tty device
3050 * @driver: the tty driver that describes the tty device 3056 * @driver: the tty driver that describes the tty device
@@ -3103,6 +3109,7 @@ struct device *tty_register_device_attr(struct tty_driver *driver,
3103 dev->devt = devt; 3109 dev->devt = devt;
3104 dev->class = tty_class; 3110 dev->class = tty_class;
3105 dev->parent = device; 3111 dev->parent = device;
3112 dev->release = tty_device_create_release;
3106 dev_set_name(dev, "%s", name); 3113 dev_set_name(dev, "%s", name);
3107 dev->groups = attr_grp; 3114 dev->groups = attr_grp;
3108 dev_set_drvdata(dev, drvdata); 3115 dev_set_drvdata(dev, drvdata);
diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c
index 96302f4c7079..d7bdd8d0c23f 100644
--- a/drivers/tty/tty_port.c
+++ b/drivers/tty/tty_port.c
@@ -73,6 +73,30 @@ struct device *tty_port_register_device(struct tty_port *port,
73} 73}
74EXPORT_SYMBOL_GPL(tty_port_register_device); 74EXPORT_SYMBOL_GPL(tty_port_register_device);
75 75
76/**
77 * tty_port_register_device_attr - register tty device
78 * @port: tty_port of the device
79 * @driver: tty_driver for this device
80 * @index: index of the tty
81 * @device: parent if exists, otherwise NULL
82 * @drvdata: Driver data to be set to device.
83 * @attr_grp: Attribute group to be set on device.
84 *
85 * It is the same as tty_register_device_attr except the provided @port is
86 * linked to a concrete tty specified by @index. Use this or tty_port_install
87 * (or both). Call tty_port_link_device as a last resort.
88 */
89struct device *tty_port_register_device_attr(struct tty_port *port,
90 struct tty_driver *driver, unsigned index,
91 struct device *device, void *drvdata,
92 const struct attribute_group **attr_grp)
93{
94 tty_port_link_device(port, driver, index);
95 return tty_register_device_attr(driver, index, device, drvdata,
96 attr_grp);
97}
98EXPORT_SYMBOL_GPL(tty_port_register_device_attr);
99
76int tty_port_alloc_xmit_buf(struct tty_port *port) 100int tty_port_alloc_xmit_buf(struct tty_port *port)
77{ 101{
78 /* We may sleep in get_zeroed_page() */ 102 /* We may sleep in get_zeroed_page() */
diff --git a/include/linux/tty.h b/include/linux/tty.h
index 599d60347bf0..1509b86825d8 100644
--- a/include/linux/tty.h
+++ b/include/linux/tty.h
@@ -507,6 +507,10 @@ extern void tty_port_link_device(struct tty_port *port,
507extern struct device *tty_port_register_device(struct tty_port *port, 507extern struct device *tty_port_register_device(struct tty_port *port,
508 struct tty_driver *driver, unsigned index, 508 struct tty_driver *driver, unsigned index,
509 struct device *device); 509 struct device *device);
510extern struct device *tty_port_register_device_attr(struct tty_port *port,
511 struct tty_driver *driver, unsigned index,
512 struct device *device, void *drvdata,
513 const struct attribute_group **attr_grp);
510extern int tty_port_alloc_xmit_buf(struct tty_port *port); 514extern int tty_port_alloc_xmit_buf(struct tty_port *port);
511extern void tty_port_free_xmit_buf(struct tty_port *port); 515extern void tty_port_free_xmit_buf(struct tty_port *port);
512extern void tty_port_put(struct tty_port *port); 516extern void tty_port_put(struct tty_port *port);