Re: [PATCH 2.6.20-rc5] SPI: alternative fix for spi_busnum_to_master

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

 



On Sunday 21 January 2007 6:25 pm, Atsushi Nemoto wrote:

> Here is a revised version.  The children list of spi_master_class
> contains only spi_master class so we can just compare bus_num member
> instead of class_id string.

Looks just a bit iffy ... though, thanks for helping to finally
sort this out!


> +	down(&spi_master_class.sem);
> +	list_for_each_entry(cdev, &spi_master_class.children, node) {
> +		cdev = class_device_get(cdev);
> +		if (!cdev)
> +			continue;

That "continue" case doesn't seem like it should be possible... but
at any rate, the "get" can be deferred until the relevent class
device is known, since that _valid_ handle can't disappear so long
as that semaphore is held.  And if you find the right device but
can't get a reference ... no point in continuing!

Something like a class_find_device() would be the best way to solve
this sort of problem, IMO.  But we don't have one of those.  :(


> +		master = container_of(cdev, struct spi_master, cdev);
> +		if (master->bus_num == bus_num)
> +			break;
> +		master = NULL;
> +		class_device_put(cdev);
> +	}
> +	up(&spi_master_class.sem);
> +	return master;
>  }
>  EXPORT_SYMBOL_GPL(spi_busnum_to_master);
>  
> 
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux