lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <c78389521bb3d8526df9d9c686e4522005914a06.1371145891.git.andi@etezian.org>
Date:	Thu, 13 Jun 2013 20:20:53 +0200
From:	Andi Shyti <andi@...zian.org>
To:	arnd@...db.de, gregkh@...uxfoundation.org
Cc:	linux-kernel@...r.kernel.org, pc@...f.org, oatilla@...il.com,
	andi@...zian.org
Subject: [PATCH 19/19] bh1770glc: Proximity sensor LED current update

From: Onur Atilla <oatilla@...il.com>

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@...il.com>
Signed-off-by: Andi Shyti <andi@...zian.org>
---
 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@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ