From: Andi Shyti <andi.shyti@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, wsa@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,
linux-drivers-review@eclists.intel.com, zhifeng.wang@intel.com
Subject: Re: [PATCH v9 2/4] i2c: Add support for Intel LJCA USB I2C driver
Date: Sun, 20 Aug 2023 19:01:18 +0200 [thread overview]
Message-ID: <20230820170118.vdhtror3cfizbkfh@intel.intel> (raw)
In-Reply-To: <1692225111-19216-3-git-send-email-wentong.wu@intel.com>
Hi Weontong,
patch looks good, just few minor comments.
[...]
> +static u8 ljca_i2c_format_slave_addr(u8 slave_addr, u8 type)
> +{
> + return (slave_addr << 1) | type;
> +}
this is used only once, you could eventually ger rid of it and
use explicitely in the start function.
[...]
> +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;
> +
> + memset(w_packet, 0, sizeof(*w_packet));
do you really need to set this to '0' as you are initializing the
header
> + w_packet->id = ljca_i2c->i2c_info->id;
> + w_packet->len = cpu_to_le16(sizeof(*w_packet->data));
> + w_packet->data[0] = ljca_i2c_format_slave_addr(slave_addr, 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)
> + return ret;
> + else if (ret < sizeof(*r_packet))
> + return -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);
> + return -EIO;
> + }
> +
> + return 0;
> +}
> +
> +static int ljca_i2c_stop(struct ljca_i2c_dev *ljca_i2c, u8 slave_addr)
the return value here is not used anywhere, what about making
this function void and printing a warning in case of failure?
[...]
> +static int ljca_i2c_probe(struct auxiliary_device *auxdev,
> + const struct auxiliary_device_id *aux_dev_id)
> +{
[...]
> + ret = ljca_i2c_init(ljca_i2c, ljca_i2c->i2c_info->id);
> + if (ret) {
> + dev_err(&auxdev->dev, "i2c init failed id: %d\n",
> + ljca_i2c->i2c_info->id);
> + return -EIO;
please use dev_err_probe();
Andi
next prev parent reply other threads:[~2023-08-20 17:06 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-16 22:31 [PATCH v9 0/4] Add Intel LJCA device driver Wentong Wu
2023-08-16 22:31 ` [PATCH v9 1/4] usb: Add support for Intel LJCA device Wentong Wu
2023-08-16 22:31 ` [PATCH v9 2/4] i2c: Add support for Intel LJCA USB I2C driver Wentong Wu
2023-08-20 17:01 ` Andi Shyti [this message]
2023-08-21 8:02 ` Wu, Wentong
2023-08-16 22:31 ` [PATCH v9 3/4] spi: Add support for Intel LJCA USB SPI driver Wentong Wu
2023-08-16 22:31 ` [PATCH v9 4/4] gpio: update Intel LJCA USB GPIO driver Wentong Wu
2023-08-17 7:03 ` Linus Walleij
2023-08-17 7:07 ` Wu, Wentong
2023-08-23 19:01 ` sakari.ailus
2023-08-24 0:54 ` Wu, Wentong
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=20230820170118.vdhtror3cfizbkfh@intel.intel \
--to=andi.shyti@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-drivers-review@eclists.intel.com \
--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=wsa@kernel.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).