leds: qpnp-flash: Introduce a function pointer for qpnp_flash_led_prepare

Introduce a function pointer to avoid the compilation error
due the same function name used in the legacy and v2 flash
drivers. These two drivers need to be enabled in a single
defconfig that supports multiple hardware platforms to achieve
the binary compatibility.

Change-Id: I1ded3d4d9013c6f7f56e0a8952f4b45d20b07326
Signed-off-by: Kiran Gunda <kgunda@codeaurora.org>
This commit is contained in:
Kiran Gunda
2018-01-17 17:50:20 +05:30
parent 8cf0b1c94f
commit bf1e6c0af0
5 changed files with 34 additions and 9 deletions

View File

@@ -72,8 +72,8 @@ obj-$(CONFIG_LEDS_IS31FL32XX) += leds-is31fl32xx.o
obj-$(CONFIG_LEDS_PM8058) += leds-pm8058.o
obj-$(CONFIG_LEDS_MLXCPLD) += leds-mlxcpld.o
obj-$(CONFIG_LEDS_QPNP) += leds-qpnp.o
obj-$(CONFIG_LEDS_QPNP_FLASH) += leds-qpnp-flash.o
obj-$(CONFIG_LEDS_QPNP_FLASH_V2) += leds-qpnp-flash-v2.o
obj-$(CONFIG_LEDS_QPNP_FLASH) += leds-qpnp-flash.o leds-qpnp-flash-common.o
obj-$(CONFIG_LEDS_QPNP_FLASH_V2) += leds-qpnp-flash-v2.o leds-qpnp-flash-common.o
obj-$(CONFIG_LEDS_QPNP_WLED) += leds-qpnp-wled.o
obj-$(CONFIG_LEDS_QPNP_HAPTICS) += leds-qpnp-haptics.o
obj-$(CONFIG_LEDS_QPNP_VIBRATOR_LDO) += leds-qpnp-vibrator-ldo.o

View File

@@ -0,0 +1,16 @@
/* Copyright (c) 2018, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
* only version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include <linux/leds-qpnp-flash.h>
int (*qpnp_flash_led_prepare)(struct led_trigger *trig, int options,
int *max_current);

View File

@@ -1,4 +1,4 @@
/* Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
/* Copyright (c) 2016-2018, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@@ -1210,7 +1210,7 @@ static int qpnp_flash_led_switch_set(struct flash_switch_data *snode, bool on)
return 0;
}
int qpnp_flash_led_prepare(struct led_trigger *trig, int options,
static int qpnp_flash_led_prepare_v2(struct led_trigger *trig, int options,
int *max_current)
{
struct led_classdev *led_cdev;
@@ -2194,6 +2194,7 @@ static int qpnp_flash_led_probe(struct platform_device *pdev)
if (!led->pdata)
return -ENOMEM;
qpnp_flash_led_prepare = qpnp_flash_led_prepare_v2;
rc = qpnp_flash_led_parse_common_dt(led, node);
if (rc < 0) {
pr_err("Failed to parse common flash LED device tree\n");

View File

@@ -1,4 +1,4 @@
/* Copyright (c) 2014-2017, The Linux Foundation. All rights reserved.
/* Copyright (c) 2014-2018, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@@ -1207,7 +1207,7 @@ error_regulator_enable:
return rc;
}
int qpnp_flash_led_prepare(struct led_trigger *trig, int options,
static int qpnp_flash_led_prepare_v1(struct led_trigger *trig, int options,
int *max_current)
{
struct led_classdev *led_cdev = trigger_to_lcdev(trig);
@@ -2468,6 +2468,7 @@ static int qpnp_flash_led_probe(struct platform_device *pdev)
led->pdev = pdev;
led->current_addr = FLASH_LED0_CURRENT(led->base);
led->current2_addr = FLASH_LED1_CURRENT(led->base);
qpnp_flash_led_prepare = qpnp_flash_led_prepare_v1;
led->pdata = devm_kzalloc(&pdev->dev, sizeof(*led->pdata), GFP_KERNEL);
if (!led->pdata)

View File

@@ -1,4 +1,4 @@
/* Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
/* Copyright (c) 2016-2018, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@@ -21,7 +21,14 @@
#define FLASH_LED_PREPARE_OPTIONS_MASK GENMASK(3, 0)
int qpnp_flash_led_prepare(struct led_trigger *trig, int options,
#if (defined CONFIG_LEDS_QPNP_FLASH || defined CONFIG_LEDS_QPNP_FLASH_V2)
extern int (*qpnp_flash_led_prepare)(struct led_trigger *trig, int options,
int *max_current);
#else
static inline int qpnp_flash_led_prepare(struct led_trigger *trig, int options,
int *max_current)
{
return -ENODEV;
}
#endif
#endif