Skip to contentSkip to conversation

Input: tegra-kbc - fix computation of polling time

PATCH In review [email protected] 3 participants 4 messages Jul 29, 2011 – Aug 2, 2011

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Input: tegra-kbc - fix computation of polling time

From: Rakesh Iyer <[email protected]>

Fix a constant definition and computation of polling time.

---
 drivers/input/keyboard/tegra-kbc.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/input/keyboard/tegra-kbc.c +2 -2
index da3828f..263f6fc 100644
@@ -37,7 +37,7 @@
 #define KBC_ROW_SCAN_DLY	5
 
 /* KBC uses a 32KHz clock so a cycle = 1/32Khz */
-#define KBC_CYCLE_USEC	32
+#define KBC_CYCLE_MS	32
 
 /* KBC Registers */
 
@@ -647,7 +647,7 @@ static int __devinit tegra_kbc_probe(struct platform_device *pdev)
 	debounce_cnt = min(pdata->debounce_cnt, KBC_MAX_DEBOUNCE_CNT);
 	scan_time_rows = (KBC_ROW_SCAN_TIME + debounce_cnt) * num_rows;
 	kbc->repoll_dly = KBC_ROW_SCAN_DLY + scan_time_rows + pdata->repeat_cnt;
-	kbc->repoll_dly = ((kbc->repoll_dly * KBC_CYCLE_USEC) + 999) / 1000;
+	kbc->repoll_dly = (kbc->repoll_dly + KBC_CYCLE_MS - 1) / KBC_CYCLE_MS;
 
 	input_dev->name = pdev->name;
 	input_dev->id.bustype = BUS_HOST;
Signature · 1 line
1.7.1
#1 lore raw
Quoted 23 lines · * [email protected] wrote:

From: Rakesh Iyer <[email protected]>

Fix a constant definition and computation of polling time.

---
 drivers/input/keyboard/tegra-kbc.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/input/keyboard/tegra-kbc.c +1 -1
index da3828f..263f6fc 100644
@@ -37,7 +37,7 @@
 #define KBC_ROW_SCAN_DLY	5
 
 /* KBC uses a 32KHz clock so a cycle = 1/32Khz */
-#define KBC_CYCLE_USEC	32
+#define KBC_CYCLE_MS	32
 
 /* KBC Registers */
 

drivers/input/keyboard/tegra-kbc.c static int __devinit tegra_kbc_probe(struct platform_device *pdev) · line 650

Quoted 5 lines
drivers/input/keyboard/tegra-kbc.c +1 -1
@@ -647,7 +647,7 @@ static int __devinit tegra_kbc_probe(struct platform_device *pdev)
 	debounce_cnt = min(pdata->debounce_cnt, KBC_MAX_DEBOUNCE_CNT);
 	scan_time_rows = (KBC_ROW_SCAN_TIME + debounce_cnt) * num_rows;
 	kbc->repoll_dly = KBC_ROW_SCAN_DLY + scan_time_rows + pdata->repeat_cnt;
-	kbc->repoll_dly = ((kbc->repoll_dly * KBC_CYCLE_USEC) + 999) / 1000;
+	kbc->repoll_dly = (kbc->repoll_dly + KBC_CYCLE_MS - 1) / KBC_CYCLE_MS;

You might want to consider using DIV_ROUND_UP for this.

Thierry

maintainer
#2 lore raw
Quoted 23 lines · Thierry Reding
Quoted 22 lines · * [email protected] wrote:

From: Rakesh Iyer <[email protected]>

Fix a constant definition and computation of polling time.

---
 drivers/input/keyboard/tegra-kbc.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/input/keyboard/tegra-kbc.c +1 -1
index da3828f..263f6fc 100644
@@ -37,7 +37,7 @@
 #define KBC_ROW_SCAN_DLY	5
 
 /* KBC uses a 32KHz clock so a cycle = 1/32Khz */
-#define KBC_CYCLE_USEC	32
+#define KBC_CYCLE_MS	32
 
 /* KBC Registers */
 
Quoted 8 lines

drivers/input/keyboard/tegra-kbc.c static int __devinit tegra_kbc_probe(struct platform_device *pdev) · line 650

Quoted 6 lines
drivers/input/keyboard/tegra-kbc.c +1 -1
@@ -647,7 +647,7 @@ static int __devinit tegra_kbc_probe(struct platform_device *pdev)
 	debounce_cnt = min(pdata->debounce_cnt, KBC_MAX_DEBOUNCE_CNT);
 	scan_time_rows = (KBC_ROW_SCAN_TIME + debounce_cnt) * num_rows;
 	kbc->repoll_dly = KBC_ROW_SCAN_DLY + scan_time_rows + pdata->repeat_cnt;
-	kbc->repoll_dly = ((kbc->repoll_dly * KBC_CYCLE_USEC) + 999) / 1000;
+	kbc->repoll_dly = (kbc->repoll_dly + KBC_CYCLE_MS - 1) / KBC_CYCLE_MS;

You might want to consider using DIV_ROUND_UP for this.

Indeed. Adjusted locally and applied.

Thanks.

Signature · 1 line
Dmitry
#3 lore raw

Thanks Dmitry and Thierry.

Regards
Rakesh

Quoted 48 lines

-----Original Message-----
From: Dmitry Torokhov [mailto:[email protected]]
Sent: Saturday, July 30, 2011 12:02 PM
To: Thierry Reding
Cc: Rakesh Iyer; [email protected]; [email protected]; Allen Martin; linux- [email protected]; [email protected]
Subject: Re: [PATCH v1] Input: tegra-kbc - fix computation of polling time

Quoted 17 lines · Thierry Reding
Quoted 16 lines · * [email protected] wrote:

From: Rakesh Iyer <[email protected]>

Fix a constant definition and computation of polling time.

---
 drivers/input/keyboard/tegra-kbc.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/input/keyboard/tegra-kbc.c +0 -0
index da3828f..263f6fc 100644
@@ -37,7 +37,7 @@
 #define KBC_ROW_SCAN_DLY	5
 
Quoted 7 lines

drivers/input/keyboard/tegra-kbc.c static int __devinit tegra_kbc_probe(struct platform_device

Quoted 7 lines
drivers/input/keyboard/tegra-kbc.c +1 -1
 /* KBC uses a 32KHz clock so a cycle = 1/32Khz */
-#define KBC_CYCLE_USEC	32
+#define KBC_CYCLE_MS	32
 
 /* KBC Registers */
 
@@ -647,7 +647,7 @@ static int __devinit tegra_kbc_probe(struct platform_device

*pdev)

Quoted 7 lines

drivers/input/keyboard/tegra-kbc.c static int __devinit tegra_kbc_probe(struct platform_device *pdev) · line 650

Quoted 5 lines
drivers/input/keyboard/tegra-kbc.c +1 -1
 	debounce_cnt = min(pdata->debounce_cnt, KBC_MAX_DEBOUNCE_CNT);
 	scan_time_rows = (KBC_ROW_SCAN_TIME + debounce_cnt) * num_rows;
 	kbc->repoll_dly = KBC_ROW_SCAN_DLY + scan_time_rows + pdata->repeat_cnt;
-	kbc->repoll_dly = ((kbc->repoll_dly * KBC_CYCLE_USEC) + 999) / 1000;
+	kbc->repoll_dly = (kbc->repoll_dly + KBC_CYCLE_MS - 1) / KBC_CYCLE_MS;

You might want to consider using DIV_ROUND_UP for this.

Indeed. Adjusted locally and applied.

Thanks.

--
Dmitry