Re: [PATCH 02/10] driver core: Pull required checks into driver_probe_device()

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

 



This looks good as-is, but a suggestions for incremental improvements
below:

> @@ -1032,10 +1035,10 @@ int device_driver_attach(struct device_driver *drv, struct device *dev)
>  	__device_driver_lock(dev, dev->parent);
>  
>  	/*
> -	 * If device has been removed or someone has already successfully
> -	 * bound a driver before us just skip the driver probe call.
> +	 * If device someone has already successfully bound a driver before us
> +	 * just skip the driver probe call.
>  	 */
> -	if (!dev->p->dead && !dev->driver)
> +	if (!dev->driver)
>  		ret = driver_probe_device(drv, dev);
>  
>  	__device_driver_unlock(dev, dev->parent);

It is kinda silly to keep the ->driver check here given that one caller
completely ignores the return value, and the other turns a 0 return into
-ENODEV anyway.  So I think this check can go away, turning
device_driver_attach into a trivial wrapper for driver_probe_device
that adds locking, which might be useful to reflect in the naming.

> @@ -1047,19 +1050,11 @@ static void __driver_attach_async_helper(void *_dev, async_cookie_t cookie)
>  {
>  	struct device *dev = _dev;
>  	struct device_driver *drv;
> -	int ret = 0;
> +	int ret;
>  
>  	__device_driver_lock(dev, dev->parent);
> -
>  	drv = dev->p->async_driver;
> -
> -	/*
> -	 * If device has been removed or someone has already successfully
> -	 * bound a driver before us just skip the driver probe call.
> -	 */
> -	if (!dev->p->dead && !dev->driver)
> -		ret = driver_probe_device(drv, dev);
> -
> +	ret = driver_probe_device(drv, dev);
>  	__device_driver_unlock(dev, dev->parent);

And that helper could be used here as well.



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux