[linux-dvb] RE : Compile error, bug in compat.h with kernel ?

Mauro Carvalho Chehab mchehab at infradead.org
Fri Jan 2 21:47:11 CET 2009

Hi Thierry,

On Wed, 31 Dec 2008 09:45:22 +0100
"Thierry Lelegard" <thierry.lelegard at tv-numeric.com> wrote:

> De : BOUWSMA Barry [mailto:freebeer.bouwsma at gmail.com] 
> > 
> > On Tue, 30 Dec 2008, Thierry Lelegard wrote:
> > 
> > > OK, looking into the source RPM for the latest Fedora 10 update
> > > kernel (kernel-, it appears that
> > > the definition of pci_ioremap_bar in pci.h was introduced by
> > > linux-
> > > 
> > > I assume that this is a Fedora-specific patch (or more 
> > generally Red Hat),
> > > back-porting 2.6.28 stuff.
> > 
> > There may be hope for a dirty hack...

> Quite dirty indeed, but isn't it the exact purpose of the compat.h file,
> being the dirty glue to compile latest kernel code inside older kernels ?
> I think this would help all Fedora users to have this little path committed
> into the linuxtv.org repository.

Too dirty for my eyes ;) 

Generally, the better way for working around of compilation issues that are
specific to some patched kernel is to add a rule at

Instead of testing based on some kernel version, all you need to do is to write
a small regex match rule, against one of kernel .h file. If the rule matches,
you'll enable (or disable) a specific compatibility code at compat.h.

For example, some kernel versions need to use a different interface for
network. This started on kernels equal or newer than 2.6.18. So, for example,
all the standard 2.6.16 kernels use the old way, while the newer kernels use
the newer way. However, as network drivers are generally backport very often,
there are several 2.6.16 variants that use the new way as well. Just checking
for version doesn't work.

To fix this, we've added this check at make_config_compat.pl:

sub check_spin_lock()
        my $file = "$kdir/include/linux/netdevice.h";
        my $old_syntax = 1;

        open INNET, "<$file" or die "File not found: $file";
        while (<INNET>) {
                if (m/netif_tx_lock_bh/) {
                        $old_syntax = 0;

        if ($old_syntax) {
                $out.= "\n#define OLD_XMIT_LOCK 1\n";
        close INNET;

So, if we find netif_tx_lock_bh at netdevice.h, this means that the newer
network locking API should be used.

The compat handling, in this case, is done by this:

#ifdef OLD_XMIT_LOCK    /* Kernels equal or lower than 2.6.17 */

If you do something like this for Fedora, it is likely that it will work much
better, without risking to break compat with other kernels.


More information about the linux-dvb mailing list