greybus: power_supply: reverse version check for new psy API
authorSandeep Patil <sspatil@google.com>
Tue, 15 Mar 2016 19:28:38 +0000 (12:28 -0700)
committerGreg Kroah-Hartman <gregkh@google.com>
Thu, 17 Mar 2016 04:49:31 +0000 (21:49 -0700)
Reversing the kernel version check for new power supply APIs will
easily allow us to use older kernels with backported power supply APIs
by defining "CORE_OWNS_PSY_STRUCT" in power supply core header

Testing Done:
- Build tested with arche kernel with backported power supply APIs
- Build tested also with current arche kernel to make sure we build with
  3.10 kernels

Signed-off-by: Sandeep Patil <sspatil@google.com>
Reviewed-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
drivers/staging/greybus/kernel_ver.h
drivers/staging/greybus/power_supply.c

index 18bf8df..f5e62ed 100644 (file)
@@ -17,9 +17,9 @@
 #include <linux/kernel.h>
 #include <linux/version.h>
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 1, 0)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 0)
 /* Commit: 297d716 power_supply: Change ownership from driver to core */
-#define DRIVER_OWNS_PSY_STRUCT
+#define CORE_OWNS_PSY_STRUCT
 #endif
 
 #ifndef __ATTR_WO
index 0467537..ec8fb1b 100644 (file)
@@ -26,7 +26,7 @@ struct gb_power_supply_prop {
 struct gb_power_supply {
        u8                              id;
        bool                            registered;
-#ifdef DRIVER_OWNS_PSY_STRUCT
+#ifndef CORE_OWNS_PSY_STRUCT
        struct power_supply             psy;
 #define to_gb_power_supply(x) container_of(x, struct gb_power_supply, psy)
 #else
@@ -126,7 +126,7 @@ static void next_interval(struct gb_power_supply *gbpsy)
                gbpsy->update_interval = update_interval_max;
 }
 
-#ifdef DRIVER_OWNS_PSY_STRUCT
+#ifndef CORE_OWNS_PSY_STRUCT
 static void __gb_power_supply_changed(struct gb_power_supply *gbpsy)
 {
        power_supply_changed(&gbpsy->psy);
@@ -513,7 +513,7 @@ static int property_is_writeable(struct power_supply *b,
 }
 
 
-#ifdef DRIVER_OWNS_PSY_STRUCT
+#ifndef CORE_OWNS_PSY_STRUCT
 static int gb_power_supply_register(struct gb_power_supply *gbpsy)
 {
        struct gb_connection *connection = get_conn_from_psy(gbpsy);
@@ -569,7 +569,7 @@ static void _gb_power_supply_release(struct gb_power_supply *gbpsy)
        gbpsy->update_interval = 0;
 
        cancel_delayed_work_sync(&gbpsy->work);
-#ifdef DRIVER_OWNS_PSY_STRUCT
+#ifndef CORE_OWNS_PSY_STRUCT
        if (gbpsy->registered)
                power_supply_unregister(&gbpsy->psy);
 #else