Commit f8811c76 authored by Sandeep Patil's avatar Sandeep Patil Committed by Greg Kroah-Hartman

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: default avatarSandeep Patil <sspatil@google.com>
Reviewed-by: default avatarRui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@google.com>
parent 3b90040d
......@@ -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
......
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment