On 2021/6/29 18:07, Wolfram Sang wrote:
> Hi,
>
> so some minor comments left:
>
>> + if (!msgs[i].len)
>> + break;
> I hope this can extended in the future to allow zero-length messages. If
> this is impossible we need to set an adapter quirk instead.
Yes, we can support it by removing this check and call it zero-length
request.
It don't think it will break anything.
>
>> + err = virtqueue_add_sgs(vq, sgs, outcnt, incnt, &reqs[i],
GFP_KERNEL);
>> + if (err < 0) {
>> + pr_err("failed to add msg[%d] to virtqueue.\n", i);
> Is it really helpful for the user to know that msg5 failed? We don't
> even say which transfer.
OK. I will remove this print.
>> +static u32 virtio_i2c_func(struct i2c_adapter *adap)
>> +{
>> + return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL;
> You are not emulating I2C_FUNC_SMBUS_QUICK, so you need to mask it out.
I will remove the check of? zero-length message.
>
>> + snprintf(vi->adap.name, sizeof(vi->adap.name), "Virtio I2C
Adapter");
> Is there something to add so you can distinguish multiple instances?
> Most people want that.
I find the I2C core will set a device name "i2c-%d" for this purpose,
right?
I think this name can be used to distinguish the adapter types while
"i2c-%d" can be used to
distinguish instances. Does it make sense ?
>> + vi->adap.class = I2C_CLASS_DEPRECATED;
>> + vi->adap.algo = &virtio_algorithm;
>> + vi->adap.dev.parent = &vdev->dev;
>> + vi->adap.timeout = HZ / 10;
> Why so short? HZ is the kinda default value.
Ah... I didn't know the I2C core had already set a default value.
I will remove this line to use the default one.
>
>> + i2c_set_adapdata(&vi->adap, vi);
>> +
>> + /* Setup ACPI node for controlled devices which will be probed
through ACPI */
>> + ACPI_COMPANION_SET(&vi->adap.dev, ACPI_COMPANION(pdev));
>> +
>> + ret = i2c_add_adapter(&vi->adap);
>> + if (ret) {
>> + virtio_i2c_del_vqs(vdev);
>> + dev_err(&vdev->dev, "failed to add virtio-i2c
adapter.\n");
> Won't the driver core print that for us?
Yes. It seems unnecessary. Will remove it.
>
>> + }
>> +
>> + return ret;
>> +}
>> +
>> +/* The bit 0 of the @virtio_i2c_out_hdr. at flags, used to group the
requests */
>> +#define VIRTIO_I2C_FLAGS_FAIL_NEXT 0x00000001
> BIT(0)?
That's better. Thank you.
>
> Happy hacking,
>
> Wolfram
>