lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <d4a6b988-c938-4f2a-8815-9b4f1e7f338f@rowland.harvard.edu>
Date: Fri, 15 Dec 2023 10:50:19 -0500
From: Alan Stern <stern@...land.harvard.edu>
To: Yajun Deng <yajun.deng@...ux.dev>
Cc: gregkh@...uxfoundation.org, marcel@...tmann.org, johan.hedberg@...il.com,
  luiz.dentz@...il.com, wg@...ndegger.com, mkl@...gutronix.de,
  aspriel@...il.com, franky.lin@...adcom.com, hante.meuleman@...adcom.com,
  kvalo@...nel.org, briannorris@...omium.org, mka@...omium.org,
  johan@...nel.org, oneukum@...e.com, valentina.manea.m@...il.com,
  shuah@...nel.org, linux-usb@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] USB: core: Use device_driver directly in struct
 usb_driver and usb_device_driver

On Fri, Dec 15, 2023 at 02:31:01PM +0800, Yajun Deng wrote:
> There is usbdrv_wrap in struct usb_driver and usb_device_driver,
> it contains device_driver and for_devices. for_devices is used to
> distinguish between device drivers and interface drivers.
> 
> We can compare that if 'drv->probe' is equal to usb_probe_device instead
> of using for_devices in is_usb_device_driver().
> 
> Remove struct usbdrv_wrap, use device_driver directly in struct usb_driver
> and usb_device_driver. This makes the code more concise.
> 
> Signed-off-by: Yajun Deng <yajun.deng@...ux.dev>
> ---

Acked-by: Alan Stern <stern@...land.harvard.edu>

However you should simplify the new test:

> --- a/drivers/usb/core/usb.h
> +++ b/drivers/usb/core/usb.h
> @@ -176,11 +176,12 @@ static inline int is_root_hub(struct usb_device *udev)
>  }
>  
>  /* Do the same for device drivers and interface drivers. */
> -
> +extern int usb_probe_device(struct device *dev);
>  static inline int is_usb_device_driver(struct device_driver *drv)
>  {
> -	return container_of(drv, struct usbdrv_wrap, driver)->
> -			for_devices;
> +	if (drv->probe == usb_probe_device)
> +		return 1;
> +	return 0;
>  }

This should just be:

	return drv->probe == usb_probe_device;

Alan Stern

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ