A proposal to check the device in generic way

From: Shevchenko, Andriy
Date: Mon Mar 11 2013 - 07:32:55 EST


Hello.

Currently in linux-next we have the following things:

$ git grep -n 'chan->device->dev->driver' drivers/dma/

drivers/dma/amba-pl08x.c:1594: if (chan->device->dev->driver !=
&pl08x_amba_driver.drv)
drivers/dma/dmaengine.c:190: return chan->device->dev->driver->owner;
drivers/dma/edma.c:609: if (chan->device->dev->driver ==
&edma_driver.driver) {
drivers/dma/omap-dma.c:654: if (chan->device->dev->driver ==
&omap_dma_driver.driver) {
drivers/dma/pl330.c:2374: if (chan->device->dev->driver !=
&pl330_driver.drv)
drivers/dma/sa11x0-dma.c:1080: if (chan->device->dev->driver ==
&sa11x0_dma_driver.driver)

I think it's a non-generic way to check which driver provides a channel
into filter function. First of all, I don't get why that comparison goes
as deep as driver structure. Isn't clearer to check chan->device->dev
against the struct dev passed in the custom parameter structure? Like:

struct filter_params {
struct dev *dev;
void *param;
};

bool filter_fn(struct dma_chan *chan, void *fparams)
{
struct filter_params *p = fparams;
if (chan->device->dev != p->dev)
return false;
...
}

In case my idea has a right to live, what about to move such check inside
DMA engine code?

Opinions, comments?

Earlier I tried to discuss this with Arnd here: http://www.spinics.net/lists/arm-kernel/msg220716.html

--
Andy Shevchenko <andriy.shevchenko@xxxxxxxxx>
Intel Finland Oy

---------------------------------------------------------------------
Intel Finland Oy
Registered Address: PL 281, 00181 Helsinki
Business Identity Code: 0357606 - 4
Domiciled in Helsinki

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
èº{.nÇ+‰·Ÿ®‰­†+%ŠËlzwm…ébëæìr¸›zX§»®w¥Š{ayºÊÚë,j­¢f£¢·hš‹àz¹®w¥¢¸ ¢·¦j:+v‰¨ŠwèjØm¶Ÿÿ¾«‘êçzZ+ƒùšŽŠÝj"ú!¶iO•æ¬z·švØ^¶m§ÿðà nÆàþY&—