greybus: power_supply: reverse version check for new psy API

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>
This commit is contained in:
Sandeep Patil 2016-03-15 12:28:38 -07:00 committed by Greg Kroah-Hartman
parent 3b90040de8
commit f8811c7630
2 changed files with 6 additions and 6 deletions

View 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

View 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