From: Andi Shyti <andi.shyti@kernel.org>
To: Ye Xiang <xiang.ye@intel.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Arnd Bergmann <arnd@arndb.de>,
Matthias Kaehlcke <mka@chromium.org>, Lee Jones <lee@kernel.org>,
Wolfram Sang <wsa@kernel.org>, Tyrone Ting <kfting@nuvoton.com>,
Mark Brown <broonie@kernel.org>,
Linus Walleij <linus.walleij@linaro.org>,
Bartosz Golaszewski <brgl@bgdev.pl>,
linux-usb@vger.kernel.org, linux-i2c@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org,
linux-gpio@vger.kernel.org, srinivas.pandruvada@intel.com,
heikki.krogerus@linux.intel.com,
andriy.shevchenko@linux.intel.com, sakari.ailus@linux.intel.com,
zhifeng.wang@intel.com, wentong.wu@intel.com,
lixu.zhang@intel.com
Subject: Re: [PATCH v5 1/5] usb: Add support for Intel LJCA device
Date: Mon, 13 Mar 2023 17:21:46 +0100 [thread overview]
Message-ID: <20230313162146.eag5z6micbpczbt2@intel.intel> (raw)
In-Reply-To: <20230312190435.3568212-2-xiang.ye@intel.com>
Hi Ye,
On top of what Greg has already said, few things from my side
through the lines.
[...]
> +static int ljca_mng_link(struct ljca_dev *dev, struct ljca_stub *stub)
> +{
> + int ret;
> +
> + ret = ljca_mng_reset_handshake(stub);
> + if (ret)
> + return ret;
> +
> + /* try to enum all the stubs */
> + ljca_mng_enum_gpio(stub);
> + ljca_mng_enum_i2c(stub);
> + ljca_mng_enum_spi(stub);
We are ignoring here the return value. So either make the
whole function call chain to be void or please check the return
values here.
[...]
> +static ssize_t ljca_enable_dfu_store(struct device *dev, struct device_attribute *attr,
> + const char *buf, size_t count)
> +{
> + struct usb_interface *intf = to_usb_interface(dev);
> + struct ljca_dev *ljca_dev = usb_get_intfdata(intf);
> + struct ljca_stub *mng_stub = ljca_stub_find(ljca_dev, LJCA_MNG_STUB);
> + bool enable;
> + int ret;
> +
> + ret = kstrtobool(buf, &enable);
> + if (ret)
> + return ret;
> +
> + if (enable) {
> + ret = ljca_mng_set_dfu_mode(mng_stub);
> + if (ret)
> + return ret;
> + }
What is the DFU mode?
Is it an operational mode?
Do we enter and exit from it?
Does the device leave this mode on its own?
What if I write twice in a raw enable?
Can I check if I am in DFU mode or not?
Would you mind adding some comments here?
> +
> + return count;
> +}
> +static DEVICE_ATTR_WO(ljca_enable_dfu);
> +
> +static ssize_t ljca_trace_level_store(struct device *dev, struct device_attribute *attr,
> + const char *buf, size_t count)
> +{
> + struct usb_interface *intf = to_usb_interface(dev);
> + struct ljca_dev *ljca_dev = usb_get_intfdata(intf);
> + struct ljca_stub *diag_stub = ljca_stub_find(ljca_dev, LJCA_DIAG_STUB);
> + u8 level;
> + int ret;
> +
> + if (kstrtou8(buf, 0, &level))
> + return -EINVAL;
> +
> + ret = ljca_diag_set_trace_level(diag_stub, level);
> + if (ret)
> + return ret;
do we need any range check for the levels? What happens if I do:
echo "I am too cool" > /sys/.../ljca_trace_level
As there were questions here, would you mind adding some comments
so that the next reader won't make the same questions?
> +
> + return count;
> +}
> +static DEVICE_ATTR_WO(ljca_trace_level);
[...]
> +static int ljca_probe(struct usb_interface *intf, const struct usb_device_id *id)
> +{
> + struct ljca_dev *dev;
> + struct usb_endpoint_descriptor *bulk_in, *bulk_out;
> + int ret;
> +
> + /* allocate memory for our device state and initialize it */
> + dev = kzalloc(sizeof(*dev), GFP_KERNEL);
devm_kzalloc()
Thanks,
Andi
> + if (!dev)
> + return -ENOMEM;
next prev parent reply other threads:[~2023-03-13 16:21 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-12 19:04 [PATCH v5 0/5] Add Intel LJCA device driver Ye Xiang
2023-03-12 19:04 ` [PATCH v5 1/5] usb: Add support for Intel LJCA device Ye Xiang
2023-03-13 6:56 ` Greg Kroah-Hartman
2023-03-14 6:54 ` Ye, Xiang
2023-03-13 16:21 ` Andi Shyti [this message]
2023-03-14 7:33 ` Ye, Xiang
2023-03-13 17:03 ` Lee Jones
2023-03-14 8:03 ` Ye, Xiang
2023-03-14 8:36 ` Heikki Krogerus
2023-03-14 15:38 ` Ye, Xiang
2023-03-14 15:52 ` Andy Shevchenko
2023-03-15 9:09 ` Heikki Krogerus
2023-06-30 7:40 ` Wu, Wentong
2023-06-30 17:37 ` Andy Shevchenko
2023-03-12 19:04 ` [PATCH v5 2/5] gpio: Add support for Intel LJCA USB GPIO driver Ye Xiang
2023-03-15 12:20 ` Bartosz Golaszewski
2023-03-12 19:04 ` [PATCH v5 3/5] i2c: Add support for Intel LJCA USB I2C driver Ye Xiang
2023-03-12 19:04 ` [PATCH v5 4/5] spi: Add support for Intel LJCA USB SPI driver Ye Xiang
2023-03-12 19:04 ` [PATCH v5 5/5] Documentation: Add ABI doc for attributes of LJCA device Ye Xiang
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=20230313162146.eag5z6micbpczbt2@intel.intel \
--to=andi.shyti@kernel.org \
--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-kernel@vger.kernel.org \
--cc=linux-spi@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=lixu.zhang@intel.com \
--cc=mka@chromium.org \
--cc=sakari.ailus@linux.intel.com \
--cc=srinivas.pandruvada@intel.com \
--cc=wentong.wu@intel.com \
--cc=wsa@kernel.org \
--cc=xiang.ye@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.