leds: qpnp-flash: Implement the flash_prepare API
Add the flash_prepare API to the leds-qpnp-flash driver to maintain consistent usage of the API by the camera flash driver across targets. CRs-Fixed: 1043718 Change-Id: I21cc4b4556b2a4a1a918bfeb1d55ae164d4b5568 Signed-off-by: Devesh Jhunjhunwala <deveshj@codeaurora.org>
This commit is contained in:
parent
dc12c73b37
commit
a0a1d3cd64
1 changed files with 43 additions and 1 deletions
|
@ -26,11 +26,12 @@
|
|||
#include <linux/regulator/consumer.h>
|
||||
#include <linux/workqueue.h>
|
||||
#include <linux/power_supply.h>
|
||||
#include <linux/leds-qpnp-flash.h>
|
||||
#include <linux/qpnp/qpnp-adc.h>
|
||||
#include <linux/qpnp/qpnp-revid.h>
|
||||
#include "leds.h"
|
||||
#include <linux/debugfs.h>
|
||||
#include <linux/uaccess.h>
|
||||
#include "leds.h"
|
||||
|
||||
#define FLASH_LED_PERIPHERAL_SUBTYPE(base) (base + 0x05)
|
||||
#define FLASH_SAFETY_TIMER(base) (base + 0x40)
|
||||
|
@ -1154,6 +1155,47 @@ error_regulator_enable:
|
|||
return rc;
|
||||
}
|
||||
|
||||
int qpnp_flash_led_prepare(struct led_trigger *trig, int options)
|
||||
{
|
||||
struct led_classdev *led_cdev = trigger_to_lcdev(trig);
|
||||
struct flash_node_data *flash_node;
|
||||
struct qpnp_flash_led *led;
|
||||
int rc, val = 0;
|
||||
|
||||
if (!led_cdev) {
|
||||
pr_err("Invalid led_trigger provided\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
flash_node = container_of(led_cdev, struct flash_node_data, cdev);
|
||||
led = dev_get_drvdata(&flash_node->pdev->dev);
|
||||
|
||||
if (!(options & (ENABLE_REGULATOR | QUERY_MAX_CURRENT))) {
|
||||
dev_err(&led->pdev->dev, "Invalid options %d\n", options);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (options & ENABLE_REGULATOR) {
|
||||
rc = flash_regulator_enable(led, flash_node, true);
|
||||
if (rc < 0) {
|
||||
dev_err(&led->pdev->dev,
|
||||
"enable regulator failed, rc=%d\n", rc);
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
|
||||
if (options & QUERY_MAX_CURRENT) {
|
||||
val = qpnp_flash_led_get_max_avail_current(flash_node, led);
|
||||
if (val < 0) {
|
||||
dev_err(&led->pdev->dev,
|
||||
"query max current failed, rc=%d\n", val);
|
||||
return val;
|
||||
}
|
||||
}
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
static void qpnp_flash_led_work(struct work_struct *work)
|
||||
{
|
||||
struct flash_node_data *flash_node = container_of(work,
|
||||
|
|
Loading…
Add table
Reference in a new issue