[PATCH 19/19] bh1770glc: Proximity sensor LED current update

From: Andi Shyti
Date: Thu Jun 13 2013 - 14:35:29 EST


From: Onur Atilla <oatilla@xxxxxxxxx>

Instead of using a constant value, the LED current
of the proximity sensor is now made individually
configurable for each product.

bh1770glc reads the platform-defined data and sets
the most suitable current value accordingly.

Signed-off-by: Onur Atilla <oatilla@xxxxxxxxx>
Signed-off-by: Andi Shyti <andi@xxxxxxxxxxx>
---
drivers/misc/bh1770glc.c | 11 ++++++++++-
include/linux/i2c/bh1770glc.h | 1 +
2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/misc/bh1770glc.c b/drivers/misc/bh1770glc.c
index ef1ab49..0af50bf 100644
--- a/drivers/misc/bh1770glc.c
+++ b/drivers/misc/bh1770glc.c
@@ -1256,6 +1256,7 @@ static int bh1770_probe(struct i2c_client *client,
{
struct bh1770_chip *chip;
int err;
+ u8 i;

chip = kzalloc(sizeof *chip, GFP_KERNEL);
if (!chip)
@@ -1274,7 +1275,15 @@ static int bh1770_probe(struct i2c_client *client,
goto fail1;
}

- chip->pdata = client->dev.platform_data;
+ /* Set the proximity sensor LED current according to the
+ * platform data. If the given value is out of range,
+ * use the closest supported current per default.
+ */
+ for (i = ARRAY_SIZE(prox_curr_ma)-1; i > 0; i--) {
+ if (chip->pdata->led1_def_curr_ma >= prox_curr_ma[i])
+ break;
+ }
+ chip->prox_led = i;
chip->lux_calib = BH1770_LUX_NEUTRAL_CALIB_VALUE;
chip->lux_rate_index = BH1770_LUX_DEFAULT_RATE;
chip->lux_threshold_lo = BH1770_LUX_DEF_THRES;
diff --git a/include/linux/i2c/bh1770glc.h b/include/linux/i2c/bh1770glc.h
index 6fb4488..9c081a8 100644
--- a/include/linux/i2c/bh1770glc.h
+++ b/include/linux/i2c/bh1770glc.h
@@ -47,6 +47,7 @@

struct bh1770_platform_data {
u8 led_def_curr;
+ u8 led1_def_curr_ma;
u32 glass_attenuation;
u32 als_scf_BH1770;
u32 als_scf_SFH7770;
--
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/