Page MenuHomeFreeBSD

D14027.id.diff
No OneTemporary

D14027.id.diff

Index: sys/arm/samsung/exynos/chrome_kb.c
===================================================================
--- sys/arm/samsung/exynos/chrome_kb.c
+++ sys/arm/samsung/exynos/chrome_kb.c
@@ -514,17 +514,8 @@
if (!KBD_HAS_DEVICE(kbd)) {
return (0);
}
- if (((int *)arg)[1] < 0) {
- return (EINVAL);
- }
- if (((int *)arg)[0] < 0) {
- return (EINVAL);
- }
- if (((int *)arg)[0] < 200) /* fastest possible value */
- kbd->kb_delay1 = 200;
- else
- kbd->kb_delay1 = ((int *)arg)[0];
- kbd->kb_delay2 = ((int *)arg)[1];
+ kbd->kb_delay1 = keyboard_repeat_get(arg, 0);
+ kbd->kb_delay2 = keyboard_repeat_get(arg, 1);
return (0);
case KDSETRAD: /* set keyboard repeat rate (old
Index: sys/arm/versatile/pl050.c
===================================================================
--- sys/arm/versatile/pl050.c
+++ sys/arm/versatile/pl050.c
@@ -418,17 +418,8 @@
if (!KBD_HAS_DEVICE(kbd)) {
return (0);
}
- if (((int *)arg)[1] < 0) {
- return (EINVAL);
- }
- if (((int *)arg)[0] < 0) {
- return (EINVAL);
- }
- if (((int *)arg)[0] < 200) /* fastest possible value */
- kbd->kb_delay1 = 200;
- else
- kbd->kb_delay1 = ((int *)arg)[0];
- kbd->kb_delay2 = ((int *)arg)[1];
+ kbd->kb_delay1 = keyboard_repeat_get(arg, 0);
+ kbd->kb_delay2 = keyboard_repeat_get(arg, 1);
return (0);
#if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) || \
Index: sys/dev/adb/adb_kbd.c
===================================================================
--- sys/dev/adb/adb_kbd.c
+++ sys/dev/adb/adb_kbd.c
@@ -780,16 +780,8 @@
case KDSETREPEAT:
if (!KBD_HAS_DEVICE(kbd))
return 0;
- if (((int *)data)[1] < 0)
- return EINVAL;
- if (((int *)data)[0] < 0)
- return EINVAL;
- else if (((int *)data)[0] == 0) /* fastest possible value */
- kbd->kb_delay1 = 200;
- else
- kbd->kb_delay1 = ((int *)data)[0];
- kbd->kb_delay2 = ((int *)data)[1];
-
+ kbd->kb_delay1 = keyboard_repeat_get(data, 0);
+ kbd->kb_delay2 = keyboard_repeat_get(data, 1);
break;
case KDSETRAD:
Index: sys/dev/gpio/gpiokeys.c
===================================================================
--- sys/dev/gpio/gpiokeys.c
+++ sys/dev/gpio/gpiokeys.c
@@ -822,17 +822,8 @@
if (!KBD_HAS_DEVICE(kbd)) {
return (0);
}
- if (((int *)arg)[1] < 0) {
- return (EINVAL);
- }
- if (((int *)arg)[0] < 0) {
- return (EINVAL);
- }
- if (((int *)arg)[0] < 200) /* fastest possible value */
- kbd->kb_delay1 = 200;
- else
- kbd->kb_delay1 = ((int *)arg)[0];
- kbd->kb_delay2 = ((int *)arg)[1];
+ kbd->kb_delay1 = keyboard_repeat_get(arg, 0);
+ kbd->kb_delay2 = keyboard_repeat_get(arg, 1);
return (0);
#if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) || \
Index: sys/dev/usb/input/ukbd.c
===================================================================
--- sys/dev/usb/input/ukbd.c
+++ sys/dev/usb/input/ukbd.c
@@ -1950,14 +1950,8 @@
if (!KBD_HAS_DEVICE(kbd)) {
return (0);
}
- /*
- * Convert negative, zero and tiny args to the same limits
- * as atkbd. We could support delays of 1 msec, but
- * anything much shorter than the shortest atkbd value
- * of 250.34 is almost unusable as well as incompatible.
- */
- kbd->kb_delay1 = imax(((int *)arg)[0], 250);
- kbd->kb_delay2 = imax(((int *)arg)[1], 34);
+ kbd->kb_delay1 = keyboard_repeat_get(arg, 0);
+ kbd->kb_delay2 = keyboard_repeat_get(arg, 1);
#ifdef EVDEV_SUPPORT
if (sc->sc_evdev != NULL)
evdev_push_repeats(sc->sc_evdev, kbd);
Index: sys/sys/kbio.h
===================================================================
--- sys/sys/kbio.h
+++ sys/sys/kbio.h
@@ -87,6 +87,47 @@
int kb_repeat[2];
};
typedef struct keyboard_repeat keyboard_repeat_t;
+
+/*
+ * Helper function to get range checked keyboard repeat values in
+ * milliseconds:
+ */
+static __inline int
+keyboard_repeat_get(const void *arg, const int index)
+{
+ const struct keyboard_repeat *ptr =
+ (const struct keyboard_repeat *)arg;
+ int retval;
+
+ switch (index) {
+ case 0:
+ /*
+ * Convert negative, zero and tiny args to the same
+ * limits as atkbd. We could support delays of 1 msec,
+ * but anything much shorter than the shortest atkbd
+ * value of 250.34 is almost unusable as well as
+ * incompatible.
+ */
+ retval = ptr->kb_repeat[0];
+ if (retval < 250)
+ retval = 250;
+ else if (retval > 65535)
+ retval = 65535;
+ break;
+ case 1:
+ retval = ptr->kb_repeat[1];
+ if (retval < 34)
+ retval = 34;
+ else if (retval > 65535)
+ retval = 65535;
+ break;
+ default:
+ retval = 0;
+ break;
+ }
+ return (retval);
+}
+
#define KDSETREPEAT _IOW('K', 102, keyboard_repeat_t)
#define KDGETREPEAT _IOR('K', 103, keyboard_repeat_t)

File Metadata

Mime Type
text/plain
Expires
Fri, Nov 15, 9:51 AM (11 h, 44 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
14640825
Default Alt Text
D14027.id.diff (4 KB)

Event Timeline