mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-11-01 17:08:10 +00:00
greybus: battery: use feature tag rather than kernel version
Conditionally define a new symbol DRIVER_OWNS_PSY_STRUCT, which is set in "kernel_ver.h" based on on the kernel version. Use it to distinguish code used for kernels that differ in whether a power supply structure is owned by the driver, or by the power supply core. Signed-off-by: Alex Elder <elder@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
This commit is contained in:
parent
9ade6d3122
commit
5c58640d8d
2 changed files with 9 additions and 5 deletions
|
@ -7,7 +7,6 @@
|
|||
* Released under the GPLv2 only.
|
||||
*/
|
||||
|
||||
#include <linux/version.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/slab.h>
|
||||
|
@ -20,7 +19,7 @@ struct gb_battery {
|
|||
* and new apis in the same driver for now, until this is merged
|
||||
* upstream, when all of these version checks can be removed.
|
||||
*/
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 1, 0)
|
||||
#ifdef DRIVER_OWNS_PSY_STRUCT
|
||||
struct power_supply bat;
|
||||
#define to_gb_battery(x) container_of(x, struct gb_battery, bat)
|
||||
#else
|
||||
|
@ -295,7 +294,7 @@ static enum power_supply_property battery_props[] = {
|
|||
POWER_SUPPLY_PROP_VOLTAGE_NOW,
|
||||
};
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 1, 0)
|
||||
#ifdef DRIVER_OWNS_PSY_STRUCT
|
||||
static int init_and_register(struct gb_connection *connection,
|
||||
struct gb_battery *gb)
|
||||
{
|
||||
|
@ -362,7 +361,7 @@ static void gb_battery_connection_exit(struct gb_connection *connection)
|
|||
{
|
||||
struct gb_battery *gb = connection->private;
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 1, 0)
|
||||
#ifdef DRIVER_OWNS_PSY_STRUCT
|
||||
power_supply_unregister(&gb->bat);
|
||||
#else
|
||||
power_supply_unregister(gb->bat);
|
||||
|
|
|
@ -15,6 +15,12 @@
|
|||
#define __GREYBUS_KERNEL_VER_H
|
||||
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/version.h>
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 1, 0)
|
||||
/* Commit: 297d716 power_supply: Change ownership from driver to core */
|
||||
#define DRIVER_OWNS_PSY_STRUCT
|
||||
#endif
|
||||
|
||||
#ifndef __ATTR_WO
|
||||
#define __ATTR_WO(_name) { \
|
||||
|
@ -57,7 +63,6 @@
|
|||
* 3.17, which they explicitly changed in the 3.17 kernel. Consistency is
|
||||
* overrated.
|
||||
*/
|
||||
#include <linux/version.h>
|
||||
#include <linux/gpio.h>
|
||||
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)
|
||||
|
|
Loading…
Reference in a new issue