Commit b1b799164afb22711e6bee718f2a5ee669bb9517

Authored by Tomas Hlavacek
Committed by Greg Kroah-Hartman
1 parent 6915c0e487

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>

Showing 4 changed files with 39 additions and 4 deletions Side-by-side Diff

drivers/tty/serial/serial_core.c
... ... @@ -2313,9 +2313,9 @@
2313 2313 struct device_attribute *attr, char *buf)
2314 2314 {
2315 2315 int ret;
2316   -
2317 2316 struct tty_port *port = dev_get_drvdata(dev);
2318 2317 struct uart_state *state = container_of(port, struct uart_state, port);
  2318 +
2319 2319 mutex_lock(&state->port.mutex);
2320 2320 ret = snprintf(buf, PAGE_SIZE, "%d\n", state->uart_port->uartclk);
2321 2321 mutex_unlock(&state->port.mutex);
... ... @@ -2330,7 +2330,7 @@
2330 2330 NULL,
2331 2331 };
2332 2332  
2333   -static struct attribute_group tty_dev_attr_group = {
  2333 +static const struct attribute_group tty_dev_attr_group = {
2334 2334 .attrs = tty_dev_attrs,
2335 2335 };
2336 2336  
... ... @@ -2392,8 +2392,8 @@
2392 2392 * Register the port whether it's detected or not. This allows
2393 2393 * setserial to be used to alter this ports parameters.
2394 2394 */
2395   - tty_dev = tty_register_device_attr(drv->tty_driver, uport->line,
2396   - uport->dev, port, tty_dev_attr_groups);
  2395 + tty_dev = tty_port_register_device_attr(port, drv->tty_driver,
  2396 + uport->line, uport->dev, port, tty_dev_attr_groups);
2397 2397 if (likely(!IS_ERR(tty_dev))) {
2398 2398 device_set_wakeup_capable(tty_dev, 1);
2399 2399 } else {
drivers/tty/tty_io.c
... ... @@ -3045,6 +3045,12 @@
3045 3045 }
3046 3046 EXPORT_SYMBOL(tty_register_device);
3047 3047  
  3048 +static 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 3055 * tty_register_device_attr - register a tty device
3050 3056 * @driver: the tty driver that describes the tty device
... ... @@ -3103,6 +3109,7 @@
3103 3109 dev->devt = devt;
3104 3110 dev->class = tty_class;
3105 3111 dev->parent = device;
  3112 + dev->release = tty_device_create_release;
3106 3113 dev_set_name(dev, "%s", name);
3107 3114 dev->groups = attr_grp;
3108 3115 dev_set_drvdata(dev, drvdata);
drivers/tty/tty_port.c
... ... @@ -73,6 +73,30 @@
73 73 }
74 74 EXPORT_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 + */
  89 +struct 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 +}
  98 +EXPORT_SYMBOL_GPL(tty_port_register_device_attr);
  99 +
76 100 int tty_port_alloc_xmit_buf(struct tty_port *port)
77 101 {
78 102 /* We may sleep in get_zeroed_page() */
... ... @@ -507,6 +507,10 @@
507 507 extern struct device *tty_port_register_device(struct tty_port *port,
508 508 struct tty_driver *driver, unsigned index,
509 509 struct device *device);
  510 +extern 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);
510 514 extern int tty_port_alloc_xmit_buf(struct tty_port *port);
511 515 extern void tty_port_free_xmit_buf(struct tty_port *port);
512 516 extern void tty_port_put(struct tty_port *port);