Re: [RFC] remove static dependencies on dvb-pll

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

 



On Fri, 1 Jun 2007, Michael Krufky wrote:
> I haven't tested this yet, but it should work just fine...
>
> I will test it when I get home.
>
>
> This patch removes all static dependencies on the dvb-pll module, without _any_
> harmful side effects.
>
> Any comments?

I think the handling inside dvb-pll might be better a little differently.

Keep the pll_desc inside dvb_pll_priv as a pointer, instead of making it the
pll id number.  Look up the pointer from the id once in dvb_pll_attach(), so
it doesn't have to be done for each time a pll function is called.

Instead of making the pll ID an int and using #defines, I'd make the id an
enum.  You don't have to manually assign the id numbers that way and it's
clear what supposed to go there.

Instead of using a big switch statement to turn the pll id into a description
pointer, I'd use an array:

dvb-pll.h:
enum dvb_pll_id = {
	DVB_PLL_THOMSON_DTT7579,
	...
	DVB_PLL_LAST
};

dvb-pll.c:
static struct dvb_pll_desc* pll_list[] = {
	[DVB_PLL_THOMSON_DTT7579] = &dvb_pll_thomson_dtt7579,
	...  // order doesn't actually have to match the enum
};

struct dvb_frontend *dvb_pll_attach(..., enum dvb_pll_id id)
{
        if (id >= DVB_PLL_LAST) { some error? BUG()? };
	priv->pll_desc = pll_list[id];
}

_______________________________________________
linux-dvb mailing list
linux-dvb@xxxxxxxxxxx
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb

[Index of Archives]     [Linux Media]     [Video 4 Linux]     [Asterisk]     [Samba]     [Xorg]     [Xfree86]     [Linux USB]

  Powered by Linux