Messages in this thread | | | Date | Tue, 29 Jun 2021 12:07:30 +0200 | From | Wolfram Sang <> | Subject | Re: [PATCH v10] i2c: virtio: add a virtio i2c frontend driver |
| |
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.
> + 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.
> +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.
> + 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.
> + 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.
> + 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?
> + } > + > + return ret; > +} > +
> +/* The bit 0 of the @virtio_i2c_out_hdr.@flags, used to group the requests */ > +#define VIRTIO_I2C_FLAGS_FAIL_NEXT 0x00000001
BIT(0)?
Happy hacking,
Wolfram
[unhandled content-type:application/pgp-signature] | |