linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Oliver Neukum <oneukum@suse.com>
To: Wentong Wu <wentong.wu@intel.com>,
	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,
	hdegoede@redhat.com, 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, bartosz.golaszewski@linaro.org,
	srinivas.pandruvada@intel.com
Cc: zhifeng.wang@intel.com
Subject: Re: [PATCH v14 1/4] usb: Add support for Intel LJCA device
Date: Mon, 4 Sep 2023 12:33:38 +0200	[thread overview]
Message-ID: <a8c8af1b-9399-6ca9-ea3d-b71e6ee68cad@suse.com> (raw)
In-Reply-To: <1693806261-12958-2-git-send-email-wentong.wu@intel.com>



On 04.09.23 07:44, Wentong Wu wrote:

> +static int ljca_send(struct ljca_adapter *adap, u8 type, u8 cmd,
> +		     const void *obuf, unsigned int obuf_len, void *ibuf,
> +		     unsigned int ibuf_len, bool ack, unsigned long timeout)
> +{
> +	unsigned int msg_len = sizeof(struct ljca_msg) + obuf_len;
> +	struct ljca_msg *header = adap->tx_buf;
> +	unsigned long flags;
> +	unsigned int actual;
> +	int ret = 0;
> +
> +	if (msg_len > adap->tx_buf_len)
> +		return -EINVAL;
> +
> +	mutex_lock(&adap->mutex);
> +
> +	spin_lock_irqsave(&adap->lock, flags);
> +
> +	header->type = type;
> +	header->cmd = cmd;
> +	header->len = obuf_len;
> +	if (obuf)
> +		memcpy(header->data, obuf, obuf_len);
> +
> +	header->flags = LJCA_CMPL_FLAG | (ack ? LJCA_ACK_FLAG : 0);
> +
> +	adap->ex_buf = ibuf;
> +	adap->ex_buf_len = ibuf_len;
> +	adap->actual_length = 0;
> +
> +	spin_unlock_irqrestore(&adap->lock, flags);
> +
> +	reinit_completion(&adap->cmd_completion);
> +
> +	usb_autopm_get_interface(adap->intf);
> +
> +	ret = usb_bulk_msg(adap->usb_dev, adap->tx_pipe, header,
> +			   msg_len, &actual, LJCA_WRITE_TIMEOUT_MS);
> +	if (!ret && ack) {
> +		ret = wait_for_completion_timeout(&adap->cmd_completion,
> +						  timeout);

Let's suppose we are here, when a device is unplugged.
timeout is arbitrary as it is passed down to us.

> +		if (ret < 0) {
> +			goto out;
> +		} if (!ret) {
> +			ret = -ETIMEDOUT;
> +			goto out;
> +		}
> +	}
> +	ret = adap->actual_length;
> +
> +out:
> +	spin_lock_irqsave(&adap->lock, flags);
> +	adap->ex_buf = NULL;
> +	adap->ex_buf_len = 0;
> +
> +	memset(header, 0, sizeof(*header));
> +	spin_unlock_irqrestore(&adap->lock, flags);
> +
> +	usb_autopm_put_interface(adap->intf);
> +
> +	mutex_unlock(&adap->mutex);
> +
> +	return ret;
> +}
> +

[..]

> +static void ljca_disconnect(struct usb_interface *interface)
> +{
> +	struct ljca_adapter *adap = usb_get_intfdata(interface);
> +	struct ljca_client *client, *next;
> +
> +	usb_kill_urb(adap->rx_urb);
> +
> +	list_for_each_entry_safe(client, next, &adap->client_list, link) {
> +		auxiliary_device_delete(&client->auxdev);
> +		auxiliary_device_uninit(&client->auxdev);
> +
> +		list_del_init(&client->link);
> +		kfree(client);
> +	}
> +
> +	usb_free_urb(adap->rx_urb);
> +
> +	usb_put_intf(adap->intf);
> +
> +	mutex_destroy(&adap->mutex);
> +}

And we execute this. rx_urb is killed and does nothing.
I see nothing that terminates the waiting if you hit the wrong window.
It seems like this needs to complete the waiting.

	Regards
		Oliver

  parent reply	other threads:[~2023-09-04 10:33 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-04  5:44 [PATCH v14 0/4] Add Intel LJCA device driver Wentong Wu
2023-09-04  5:44 ` [PATCH v14 1/4] usb: Add support for Intel LJCA device Wentong Wu
2023-09-04  7:45   ` Hans de Goede
2023-09-04  7:52     ` Wu, Wentong
2023-09-04 10:33   ` Oliver Neukum [this message]
2023-09-04 13:52     ` Wu, Wentong
2023-09-04 14:06       ` Oliver Neukum
2023-09-05  2:20         ` Wu, Wentong
2023-09-05  8:46           ` Oliver Neukum
2023-09-05  8:53             ` Wu, Wentong
2023-09-05 10:04               ` gregkh
2023-09-06  3:29                 ` Wu, Wentong
2023-09-04  5:44 ` [PATCH v14 2/4] i2c: Add support for Intel LJCA USB I2C driver Wentong Wu
2023-09-04  5:44 ` [PATCH v14 3/4] spi: Add support for Intel LJCA USB SPI driver Wentong Wu
2023-09-04  5:44 ` [PATCH v14 4/4] gpio: update Intel LJCA USB GPIO driver Wentong Wu
2023-09-04  7:38 ` [PATCH v14 0/4] Add Intel LJCA device driver Bartosz Golaszewski
2023-09-04  8:25   ` Wu, Wentong
2023-09-04  7:44 ` Hans de Goede
2023-09-04  7:56   ` 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=a8c8af1b-9399-6ca9-ea3d-b71e6ee68cad@suse.com \
    --to=oneukum@suse.com \
    --cc=andi.shyti@linux.intel.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=arnd@arndb.de \
    --cc=bartosz.golaszewski@linaro.org \
    --cc=brgl@bgdev.pl \
    --cc=broonie@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=hdegoede@redhat.com \
    --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=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).