Re: [PATCH v5 1/5] usb: Add support for Intel LJCA device

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Andi,

Thanks for the review.
On Mon, Mar 13, 2023 at 05:21:46PM +0100, Andi Shyti wrote:
> 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.
Ok, got it.
> 
> [...]
> 
> > +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?
DFU mode is used for updating LJCA device Firmware.
We have a Documentation/ABI/testing/sysfs-bus-usb-devices-ljca in patch
5 of this patch series. It has information about the entry. Maybe it
should be go after this patch (patch 2/5).
> 
> > +
> > +	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?
We have a patch (patch 5 of this series) adding some Documentation/ABI/
entries to specify the correct value for each entry.

> 
> > +
> > +	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()
Got it. Thanks.

--
Thanks
Ye Xiang



[Index of Archives]     [Linux GPIO]     [Linux SPI]     [Linux Hardward Monitoring]     [LM Sensors]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux