Mailing List archive

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

[linux-dvb] Re: refactoring



Ralph Metzler wrote:

Holger Waechtler writes:
> Gerd Knorr wrote:
> > >
> >>I have left it using the kernel i2c_adapter stuff, and i2c_transfer() > >>functions as before.
> >> > >>
> >
> >Which is a bad idea.
> >
> > why? please elaborate.
> > > Have you actually looked at my cx22702 version?
> >There is much generic, reusable code in there. And it is generic
> >*because* it makes heavy use of the kernl i2c infrastructure.
> >
> > no. that's just the reason why it's not portable, not testable in a > userspace mockup and hardly portable to other OSes like MacOS-X and BSD. > The new approach without dependencies to kernel APIs is much nicer.

You could completely rewrite lots of drivers (and not for the better)
with this argument. Of course Linux kernel APIs primarily make it
easier to write drivers just for Linux. So, I should not use any
Linux kernel APIs because they are not in userspace, MacOS-X and BSD?

You should try to encapsulate them at lease so that porting is made easy. You know that there have been several approaches in the past to port the linux-dvb code to BSD, MacOS-X and even the GPL'd Windows BDA drivers on sourceforge mention the linux driver as codebase:

http://cvs.sourceforge.net/viewcvs.py/bdadev/NovaTDriver/saa7146.cpp?rev=1.11&view=auto

btw: the BDA drivers are a very nice example how to encapsulate your code away from OS-specific APIs: please take a look on the l64781 or SAA7146 implementations, they are much better organized, simpler and easier to maintain that their linux parents:

I think it's a good thing to inherit some of the ideas and maybe we even reach one day a point where a common 'hardware library' codebase can used for all platforms and the OS-specific PCI/USB/BDA/linux-DVB API registration functions are collected in a single file as small and compact as possible.

> Not allocating dynamic memory but using static data > instead is always a good thing.

Why?
Now each and every driver has to take care of it instead of just the
demodulator driver.

no. Please have a look:

struct budget_with_stv0299 {
struct pci_device pcidev;
struct dma_related_stuff dma;
struct stv0299_state_and_config stv0299;
/* ans so on... */
};

this card struct gets allocated once in the pci attach() can and freed in the release() callback. No need for additional maintenance, kmalloc() and kfree() anywhere.

Holger





Home | Main Index | Thread Index