From: Luis R. Rodriguez Date: Tue, 31 Jan 2012 22:44:41 +0000 (-0800) Subject: compat: backport __netdev_printk() X-Git-Tag: compat-2012-07-02~28 X-Git-Url: https://openfabrics.org/gitweb/?a=commitdiff_plain;h=95a119f3f13c3513baac430ff40175ad8faeea2c;p=~emulex%2Fcompat.git compat: backport __netdev_printk() This was added in v3.2, and will be used by the new shiny alx Ethernet driver which is not yet upstream. This now has some fixes for 2.6.35. Tested with ckmake. Signed-off-by: Luis R. Rodriguez --- diff --git a/compat/Makefile b/compat/Makefile index fa9c6cb..3c72ef9 100644 --- a/compat/Makefile +++ b/compat/Makefile @@ -34,6 +34,7 @@ compat-$(CONFIG_COMPAT_KERNEL_2_6_39) += \ compat-2.6.39.o \ kstrtox.o compat-$(CONFIG_COMPAT_KERNEL_3_0) += compat-3.0.o +compat-$(CONFIG_COMPAT_KERNEL_3_2) += compat-3.2.o compat-$(CONFIG_COMPAT_CORDIC) += cordic.o compat-$(CONFIG_COMPAT_CRC8) += crc8.o diff --git a/compat/compat-3.2.c b/compat/compat-3.2.c new file mode 100644 index 0000000..80f5597 --- /dev/null +++ b/compat/compat-3.2.c @@ -0,0 +1,34 @@ +/* + * Copyright 2012 Luis R. Rodriguez + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * Compatibility file for Linux wireless for kernels 3.2. + */ + +#include +#include + +int __netdev_printk(const char *level, const struct net_device *dev, + struct va_format *vaf) +{ + int r; + + if (dev && dev->dev.parent) +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,35)) + r = dev_printk(level, dev->dev.parent, "%s: %pV", + netdev_name(dev), vaf); +#else + /* XXX: this could likely be done better but I'm lazy */ + r = printk("%s%s: %pV", level, netdev_name(dev), vaf); +#endif + else if (dev) + r = printk("%s%s: %pV", level, netdev_name(dev), vaf); + else + r = printk("%s(NULL net_device): %pV", level, vaf); + + return r; +} +EXPORT_SYMBOL(__netdev_printk); diff --git a/include/linux/compat-3.2.h b/include/linux/compat-3.2.h index a17c4ad..cb14f0b 100644 --- a/include/linux/compat-3.2.h +++ b/include/linux/compat-3.2.h @@ -73,6 +73,9 @@ static inline void *dma_zalloc_coherent(struct device *dev, size_t size, return ret; } +extern int __netdev_printk(const char *level, const struct net_device *dev, + struct va_format *vaf); + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,2,0)) */ #endif /* LINUX_3_2_COMPAT_H */