From: Sandeep Patil Date: Tue, 15 Mar 2016 19:28:38 +0000 (-0700) Subject: greybus: power_supply: reverse version check for new psy API X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=f8811c7630912617d1bc0e0b18e3221fec26f9cf;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git 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 Reviewed-by: Rui Miguel Silva Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/greybus/kernel_ver.h b/drivers/staging/greybus/kernel_ver.h index 18bf8dff0f86..f5e62ed3d9f5 100644 --- a/drivers/staging/greybus/kernel_ver.h +++ b/drivers/staging/greybus/kernel_ver.h @@ -17,9 +17,9 @@ #include #include -#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 diff --git a/drivers/staging/greybus/power_supply.c b/drivers/staging/greybus/power_supply.c index 0467537bf4f6..ec8fb1b84024 100644 --- a/drivers/staging/greybus/power_supply.c +++ b/drivers/staging/greybus/power_supply.c @@ -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