public inbox for linux-usb@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: David Mosberger <davidm@egauge.net>,
	linux-usb@vger.kernel.org, kernel@pengutronix.de
Subject: Re: [PATCH] usb: max-3421: Use driver data instead of maintaining a list of bound devices
Date: Mon, 18 Oct 2021 16:55:38 +0200	[thread overview]
Message-ID: <YW2K6iWveIPAQSiM@kroah.com> (raw)
In-Reply-To: <20211018120055.2902897-1-u.kleine-koenig@pengutronix.de>

On Mon, Oct 18, 2021 at 02:00:55PM +0200, Uwe Kleine-König wrote:
> Instead of maintaining a single-linked list of devices that must be
> searched linearly in .remove() just use spi_set_drvdata() to remember the
> link between the spi device and the driver struct. Then the global list
> and the next member can be dropped.
> 
> This simplifies the driver, reduces the memory footprint and the time to
> search the list. Also it makes obvious that there is always a corresponding
> driver struct for a given device in .remove(), so the error path for
> !max3421_hcd can be dropped, too.
> 
> As a side effect this fixes a data inconsistency when .probe() races with
> itself for a second max3421 device in manipulating max3421_hcd_list. A
> similar race is fixed in .remove(), too.
> 
> Fixes: 2d53139f3162 ("Add support for using a MAX3421E chip as a host driver.")
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> ---
>  drivers/usb/host/max3421-hcd.c | 26 +++++---------------------
>  1 file changed, 5 insertions(+), 21 deletions(-)
> 
> diff --git a/drivers/usb/host/max3421-hcd.c b/drivers/usb/host/max3421-hcd.c
> index 59cc1bc7f12f..3e39f62904af 100644
> --- a/drivers/usb/host/max3421-hcd.c
> +++ b/drivers/usb/host/max3421-hcd.c
> @@ -125,8 +125,6 @@ struct max3421_hcd {
>  
>  	struct task_struct *spi_thread;
>  
> -	struct max3421_hcd *next;
> -
>  	enum max3421_rh_state rh_state;
>  	/* lower 16 bits contain port status, upper 16 bits the change mask: */
>  	u32 port_status;
> @@ -174,8 +172,6 @@ struct max3421_ep {
>  	u8 retransmit;			/* packet needs retransmission */
>  };
>  
> -static struct max3421_hcd *max3421_hcd_list;
> -
>  #define MAX3421_FIFO_SIZE	64
>  
>  #define MAX3421_SPI_DIR_RD	0	/* read register from MAX3421 */
> @@ -1881,10 +1877,8 @@ max3421_probe(struct spi_device *spi)
>  		goto error;
>  	}
>  	set_bit(HCD_FLAG_POLL_RH, &hcd->flags);
> -	max3421_hcd = hcd_to_max3421(hcd);

I don't think you should have deleted this line :(

Did you test this?

thanks,

greg k-h

  parent reply	other threads:[~2021-10-18 14:55 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-18 12:00 [PATCH] usb: max-3421: Use driver data instead of maintaining a list of bound devices Uwe Kleine-König
2021-10-18 14:03 ` kernel test robot
2021-10-18 14:55 ` Greg Kroah-Hartman [this message]
2021-10-18 20:28   ` Uwe Kleine-König
2021-10-18 20:40     ` [PATCH v2] " Uwe Kleine-König
2021-10-19 14:51       ` David Mosberger-Tang

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=YW2K6iWveIPAQSiM@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=davidm@egauge.net \
    --cc=kernel@pengutronix.de \
    --cc=linux-usb@vger.kernel.org \
    --cc=u.kleine-koenig@pengutronix.de \
    /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