aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char
diff options
context:
space:
mode:
authorSjur Brændeland <sjur.brandeland@stericsson.com>2013-02-12 00:54:59 -0500
committerRusty Russell <rusty@rustcorp.com.au>2013-02-12 00:56:39 -0500
commitdc18f0800f5f16460030a9623d4fcc165d607edf (patch)
tree27318d5a4cb4bddb3792d0f4dc65d224939d95f7 /drivers/char
parent35cdc9eb65837687bdfc9ea1d2515eb03ea5048a (diff)
virtio_console: Use virtio device index to generate port name
Use virtio device index for creating unique device port names. Current index allocation in virtio is based on a monotonically increasing variable "index". A better handling of this is to use device index which is allocated by ida. Signed-off-by: Sjur Brændeland <sjur.brandeland@stericsson.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'drivers/char')
-rw-r--r--drivers/char/virtio_console.c16
1 files changed, 3 insertions, 13 deletions
diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index 95cae778bd73..2cfd5a0575ab 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -61,9 +61,6 @@ struct ports_driver_data {
61 /* List of all the devices we're handling */ 61 /* List of all the devices we're handling */
62 struct list_head portdevs; 62 struct list_head portdevs;
63 63
64 /* Number of devices this driver is handling */
65 unsigned int index;
66
67 /* 64 /*
68 * This is used to keep track of the number of hvc consoles 65 * This is used to keep track of the number of hvc consoles
69 * spawned by this driver. This number is given as the first 66 * spawned by this driver. This number is given as the first
@@ -169,9 +166,6 @@ struct ports_device {
169 /* Array of per-port IO virtqueues */ 166 /* Array of per-port IO virtqueues */
170 struct virtqueue **in_vqs, **out_vqs; 167 struct virtqueue **in_vqs, **out_vqs;
171 168
172 /* Used for numbering devices for sysfs and debugfs */
173 unsigned int drv_index;
174
175 /* Major number for this device. Ports will be created as minors. */ 169 /* Major number for this device. Ports will be created as minors. */
176 int chr_major; 170 int chr_major;
177}; 171};
@@ -1415,7 +1409,7 @@ static int add_port(struct ports_device *portdev, u32 id)
1415 } 1409 }
1416 port->dev = device_create(pdrvdata.class, &port->portdev->vdev->dev, 1410 port->dev = device_create(pdrvdata.class, &port->portdev->vdev->dev,
1417 devt, port, "vport%up%u", 1411 devt, port, "vport%up%u",
1418 port->portdev->drv_index, id); 1412 port->portdev->vdev->index, id);
1419 if (IS_ERR(port->dev)) { 1413 if (IS_ERR(port->dev)) {
1420 err = PTR_ERR(port->dev); 1414 err = PTR_ERR(port->dev);
1421 dev_err(&port->portdev->vdev->dev, 1415 dev_err(&port->portdev->vdev->dev,
@@ -1470,7 +1464,7 @@ static int add_port(struct ports_device *portdev, u32 id)
1470 * inspect a port's state at any time 1464 * inspect a port's state at any time
1471 */ 1465 */
1472 sprintf(debugfs_name, "vport%up%u", 1466 sprintf(debugfs_name, "vport%up%u",
1473 port->portdev->drv_index, id); 1467 port->portdev->vdev->index, id);
1474 port->debugfs_file = debugfs_create_file(debugfs_name, 0444, 1468 port->debugfs_file = debugfs_create_file(debugfs_name, 0444,
1475 pdrvdata.debugfs_dir, 1469 pdrvdata.debugfs_dir,
1476 port, 1470 port,
@@ -1961,16 +1955,12 @@ static int virtcons_probe(struct virtio_device *vdev)
1961 portdev->vdev = vdev; 1955 portdev->vdev = vdev;
1962 vdev->priv = portdev; 1956 vdev->priv = portdev;
1963 1957
1964 spin_lock_irq(&pdrvdata_lock);
1965 portdev->drv_index = pdrvdata.index++;
1966 spin_unlock_irq(&pdrvdata_lock);
1967
1968 portdev->chr_major = register_chrdev(0, "virtio-portsdev", 1958 portdev->chr_major = register_chrdev(0, "virtio-portsdev",
1969 &portdev_fops); 1959 &portdev_fops);
1970 if (portdev->chr_major < 0) { 1960 if (portdev->chr_major < 0) {
1971 dev_err(&vdev->dev, 1961 dev_err(&vdev->dev,
1972 "Error %d registering chrdev for device %u\n", 1962 "Error %d registering chrdev for device %u\n",
1973 portdev->chr_major, portdev->drv_index); 1963 portdev->chr_major, vdev->index);
1974 err = portdev->chr_major; 1964 err = portdev->chr_major;
1975 goto free; 1965 goto free;
1976 } 1966 }