compat: fix compat_firmware class for all kernels
authorLuis R. Rodriguez <>
Sat, 25 Feb 2012 04:15:18 +0000 (20:15 -0800)
committerLuis R. Rodriguez <>
Sat, 25 Feb 2012 04:15:18 +0000 (20:15 -0800)
Instead of ifdef checks on the to_dev() just simply rename it
to avoid clashes. This fixes compiling against all supported
kernels on compat.

mcgrof@tux ~/compat (git::master)$ ckmake
Trying kernel                  3.3.0-030300rc2-generic  [OK]
Trying kernel                     3.2.2-030202-generic  [OK]
Trying kernel                    3.1.10-030110-generic  [OK]
Trying kernel                    3.0.18-030018-generic  [OK]
Trying kernel                  2.6.39-02063904-generic  [OK]
Trying kernel                         2.6.38-8-generic  [OK]
Trying kernel                        2.6.38-13-generic  [OK]
Trying kernel                        2.6.38-12-generic  [OK]
Trying kernel                        2.6.38-11-generic  [OK]
Trying kernel                        2.6.38-10-generic  [OK]
Trying kernel                  2.6.38-02063808-generic  [OK]
Trying kernel                  2.6.37-02063706-generic  [OK]
Trying kernel                  2.6.36-02063604-generic  [OK]
Trying kernel                  2.6.35-02063512-generic  [OK]
Trying kernel                  2.6.34-02063410-generic  [OK]
Trying kernel                  2.6.33-02063305-generic  [OK]
Trying kernel                  2.6.32-02063255-generic  [OK]
Trying kernel                        2.6.31-22-generic  [OK]
Trying kernel                  2.6.31-02063113-generic  [OK]
Trying kernel                  2.6.30-02063010-generic  [OK]
Trying kernel                  2.6.29-02062906-generic  [OK]
Trying kernel                  2.6.28-02062810-generic  [OK]
Trying kernel                    2.6.27-020627-generic  [OK]
Trying kernel                    2.6.26-020626-generic  [OK]
Trying kernel                    2.6.25-020625-generic  [OK]
Trying kernel                    2.6.24-020624-generic  [OK]

Signed-off-by: Luis R. Rodriguez <>

index b085677..eb97dfc 100644 (file)
 #include <linux/firmware.h>
 #include <linux/slab.h>
-#ifdef to_dev
-#undef to_dev
-#define to_dev(obj) container_of(obj, struct device, kobj)
+#define compat_firmware_to_dev(obj) container_of(obj, struct device, kobj)
 MODULE_AUTHOR("Manuel Estrada Sainz");
 MODULE_DESCRIPTION("Multi purpose firmware loading support");
@@ -327,7 +324,7 @@ static ssize_t firmware_data_read(struct kobject *kobj,
                                  char *buffer, loff_t offset, size_t count)
-       struct device *dev = to_dev(kobj);
+       struct device *dev = compat_firmware_to_dev(kobj);
        struct firmware_priv *fw_priv = to_firmware_priv(dev);
        struct firmware *fw;
        ssize_t ret_count;
@@ -426,7 +423,7 @@ static ssize_t firmware_data_write(struct kobject *kobj,
                                   char *buffer, loff_t offset, size_t count)
-       struct device *dev = to_dev(kobj);
+       struct device *dev = compat_firmware_to_dev(kobj);
        struct firmware_priv *fw_priv = to_firmware_priv(dev);
        struct firmware *fw;
        ssize_t retval;