From: Wolfram Sang <wsa@kernel.org>
To: Wentong Wu <wentong.wu@intel.com>
Cc: gregkh@linuxfoundation.org, arnd@arndb.de, mka@chromium.org,
oneukum@suse.com, lee@kernel.org, kfting@nuvoton.com,
broonie@kernel.org, linus.walleij@linaro.org, maz@kernel.org,
brgl@bgdev.pl, linux-usb@vger.kernel.org,
linux-i2c@vger.kernel.org, linux-spi@vger.kernel.org,
linux-gpio@vger.kernel.org, andriy.shevchenko@linux.intel.com,
heikki.krogerus@linux.intel.com, andi.shyti@linux.intel.com,
sakari.ailus@linux.intel.com, srinivas.pandruvada@intel.com,
zhifeng.wang@intel.com
Subject: Re: [PATCH v10 2/4] i2c: Add support for Intel LJCA USB I2C driver
Date: Mon, 28 Aug 2023 21:24:30 +0200 [thread overview]
Message-ID: <ZOz0bgJUZuAcUBWf@ninjato> (raw)
In-Reply-To: <1693091643-20867-3-git-send-email-wentong.wu@intel.com>
[-- Attachment #1: Type: text/plain, Size: 3141 bytes --]
Hi,
thank you for your patches!
...
> +static int ljca_i2c_start(struct ljca_i2c_dev *ljca_i2c, u8 slave_addr,
> + enum ljca_xfer_type type)
> +{
> + struct ljca_i2c_rw_packet *w_packet =
> + (struct ljca_i2c_rw_packet *)ljca_i2c->obuf;
> + struct ljca_i2c_rw_packet *r_packet =
> + (struct ljca_i2c_rw_packet *)ljca_i2c->ibuf;
> + s16 rp_len;
> + int ret;
> +
> + w_packet->id = ljca_i2c->i2c_info->id;
> + w_packet->len = cpu_to_le16(sizeof(*w_packet->data));
> + w_packet->data[0] = (slave_addr << 1) | type;
> +
> + ret = ljca_transfer(ljca_i2c->ljca, LJCA_I2C_START, w_packet,
> + struct_size(w_packet, data, 1), r_packet,
> + LJCA_I2C_BUF_SIZE);
> + if (ret < 0 || ret < sizeof(*r_packet))
> + return ret < 0 ? ret : -EIO;
> +
> + rp_len = le16_to_cpu(r_packet->len);
> + if (rp_len < 0 || r_packet->id != w_packet->id) {
> + dev_err(&ljca_i2c->adap.dev,
> + "i2c start failed len: %d id: %d %d\n",
> + rp_len, r_packet->id, w_packet->id);
All dev_err look more like dev_dbg to me. They are not helpful for the
regular user, I'd think.
> + return -EIO;
> + }
> +
> + return 0;
> +}
> +
...
> +static int ljca_i2c_pure_read(struct ljca_i2c_dev *ljca_i2c, u8 *data, u8 len)
> +{
> + struct ljca_i2c_rw_packet *w_packet =
> + (struct ljca_i2c_rw_packet *)ljca_i2c->obuf;
> + struct ljca_i2c_rw_packet *r_packet =
> + (struct ljca_i2c_rw_packet *)ljca_i2c->ibuf;
> + s16 rp_len;
> + int ret;
> +
> + if (len > LJCA_I2C_MAX_XFER_SIZE)
> + return -EINVAL;
You can remove this check. You already have a quirk structure, so the
core will do it for you.
...
> +static int ljca_i2c_pure_write(struct ljca_i2c_dev *ljca_i2c, u8 *data, u8 len)
> +{
> + struct ljca_i2c_rw_packet *w_packet =
> + (struct ljca_i2c_rw_packet *)ljca_i2c->obuf;
> + struct ljca_i2c_rw_packet *r_packet =
> + (struct ljca_i2c_rw_packet *)ljca_i2c->ibuf;
> + s16 rplen;
> + int ret;
> +
> + if (len > LJCA_I2C_MAX_XFER_SIZE)
> + return -EINVAL;
You can remove this check. You already have a quirk structure, so the
core will do it for you.
...
> +static u32 ljca_i2c_func(struct i2c_adapter *adap)
> +{
> + return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL;
> +}
Have you successfully tried SMBUS_QUICK (e.g. with scanning a bus with
'i2cdetect')?
...
> +static int ljca_i2c_probe(struct auxiliary_device *auxdev,
> + const struct auxiliary_device_id *aux_dev_id)
> +{
> + struct ljca_client *ljca = auxiliary_dev_to_ljca_client(auxdev);
> + struct ljca_i2c_dev *ljca_i2c;
> + int ret;
> +
> + ljca_i2c = devm_kzalloc(&auxdev->dev, sizeof(*ljca_i2c), GFP_KERNEL);
> + if (!ljca_i2c)
> + return -ENOMEM;
> +
> + ljca_i2c->ljca = ljca;
> + ljca_i2c->i2c_info = dev_get_platdata(&auxdev->dev);
> +
> + ljca_i2c->adap.owner = THIS_MODULE;
> + ljca_i2c->adap.class = I2C_CLASS_HWMON;
Just to make sure: you want class based instantiation here because you
have no other way of describing clients? I guess it makes sense for USB,
just wanted to ask.
Other than that, it looks good!
All the best,
Wolfram
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2023-08-28 19:25 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-26 23:13 [PATCH v10 0/4] Add Intel LJCA device driver Wentong Wu
2023-08-26 23:14 ` [PATCH v10 1/4] usb: Add support for Intel LJCA device Wentong Wu
2023-08-26 23:14 ` [PATCH v10 2/4] i2c: Add support for Intel LJCA USB I2C driver Wentong Wu
2023-08-28 19:24 ` Wolfram Sang [this message]
2023-08-29 3:29 ` Wu, Wentong
2023-08-29 7:43 ` Wolfram Sang
2023-08-29 7:46 ` Wu, Wentong
2023-08-26 23:14 ` [PATCH v10 3/4] spi: Add support for Intel LJCA USB SPI driver Wentong Wu
2023-08-26 23:14 ` [PATCH v10 4/4] gpio: update Intel LJCA USB GPIO driver Wentong Wu
2023-08-28 7:27 ` Bartosz Golaszewski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZOz0bgJUZuAcUBWf@ninjato \
--to=wsa@kernel.org \
--cc=andi.shyti@linux.intel.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=arnd@arndb.de \
--cc=brgl@bgdev.pl \
--cc=broonie@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=heikki.krogerus@linux.intel.com \
--cc=kfting@nuvoton.com \
--cc=lee@kernel.org \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-spi@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=maz@kernel.org \
--cc=mka@chromium.org \
--cc=oneukum@suse.com \
--cc=sakari.ailus@linux.intel.com \
--cc=srinivas.pandruvada@intel.com \
--cc=wentong.wu@intel.com \
--cc=zhifeng.wang@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.