Thread (21 messages) flat view 21 messages, 6 authors, 2015-03-23

Re: [PATCH 1/1] Add virtio-input driver.

From: David Herrmann <hidden>
Date: 2015-03-19 17:16:47
Also in: lkml

Hey

On Thu, Mar 19, 2015 at 5:27 PM, Dmitry Torokhov
[off-list ref] wrote:
On Thu, Mar 19, 2015 at 01:29:49PM +0100, David Herrmann wrote:
[...]
quoted
quoted
+static int virtinput_probe(struct virtio_device *vdev)
+{
+       struct virtio_input *vi;
+       size_t size;
+       int abs, err;
+
+       vi = kzalloc(sizeof(*vi), GFP_KERNEL);
+       if (!vi) {
+               err = -ENOMEM;
+               goto out1;
+       }
+       vdev->priv = vi;
+       vi->vdev = vdev;
+
+       err = virtinput_init_vqs(vi);
+       if (err)
+               goto out2;
+
+       vi->idev = input_allocate_device();
+       if (!vi->idev) {
+               err = -ENOMEM;
+               goto out3;
+       }
+       input_set_drvdata(vi->idev, vi);
+
+       size = virtinput_cfg_select(vi, VIRTIO_INPUT_CFG_ID_NAME, 0);
+       virtio_cread_bytes(vi->vdev, offsetof(struct virtio_input_config, u),
+                          vi->name, min(size, sizeof(vi->name)));
+       size = virtinput_cfg_select(vi, VIRTIO_INPUT_CFG_ID_SERIAL, 0);
+       virtio_cread_bytes(vi->vdev, offsetof(struct virtio_input_config, u),
+                          vi->serial, min(size, sizeof(vi->serial)));
+       snprintf(vi->phys, sizeof(vi->phys),
+                "virtio%d/input0", vdev->index);
+
+       virtinput_cfg_bits(vi, VIRTIO_INPUT_CFG_PROP_BITS, 0,
+                          vi->idev->propbit, INPUT_PROP_CNT);
+       size = virtinput_cfg_select(vi, VIRTIO_INPUT_CFG_EV_BITS, EV_REP);
+       if (size)
+               set_bit(EV_REP, vi->idev->evbit);
+
+       vi->idev->name = vi->name;
+       vi->idev->phys = vi->phys;
Can you set vi->idev->uniq to the virtio-bus path?
No, uniq can't be phys as phys is unique within the system while uniq is
like serial number or UUID and should never repeat.
...sorry, my bad! We should still forward it from the host, imo. It's
really handy for applications to re-detect devices.

Thanks
David
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help