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

From: David Herrmann
Date: Thu Mar 19 2015 - 13:16:51 EST


Hey

On Thu, Mar 19, 2015 at 5:27 PM, Dmitry Torokhov
<dmitry.torokhov@xxxxxxxxx> wrote:
> On Thu, Mar 19, 2015 at 01:29:49PM +0100, David Herrmann wrote:
[...]
>> > +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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/