meta-digi/meta-digi-dey/recipes-core/busybox/busybox-1.24.1/0001-del-baudrates.patch

110 lines
2.5 KiB
Diff

From: Javier Viguera <javier.viguera@digi.com>
Date: Wed, 20 Apr 2011 11:08:27 +0200
Subject: [PATCH] del-baudrates
http://thread.gmane.org/gmane.linux.busybox/22612
Signed-off-by: Javier Viguera <javier.viguera@digi.com>
---
libbb/speed_table.c | 67 ++++++++++++++++++++++++++++++++++++++++++-----------
1 file changed, 54 insertions(+), 13 deletions(-)
diff --git a/libbb/speed_table.c b/libbb/speed_table.c
index 174d531..0e57de4 100644
--- a/libbb/speed_table.c
+++ b/libbb/speed_table.c
@@ -34,30 +34,68 @@ static const struct speed_map speeds[] = {
{B2400, 2400},
{B4800, 4800},
{B9600, 9600},
-#ifdef B19200
- {B19200, 19200},
+/* To fit in 16 bits with larget values, scale by 256 or by 10000 and mark */
+#define MARKER_MASK 0xc000U
+#define MARKER_256 0x8000U
+#define MARKER_10k 0x4000U
+#define SCALE_256(x) ((x)/256 | MARKER_256)
+#define SCALE_10k(x) ((x)/10000 | MARKER_10k)
+#define DO_256(x) {B##x, SCALE_256(x)}
+#define DO_10k(x) {B##x, SCALE_10k(x)}
+#ifdef B19200
+ DO_256(19200),
#elif defined(EXTA)
- {EXTA, 19200},
+ {EXTA, SCALE_256(19200)},
#endif
-#ifdef B38400
- {B38400, 38400/256 + 0x8000U},
+#ifdef B38400
+ DO_256(38400),
#elif defined(EXTB)
- {EXTB, 38400/256 + 0x8000U},
+ {EXTB, SCALE_256(38400)},
#endif
#ifdef B57600
- {B57600, 57600/256 + 0x8000U},
+ DO_256(57600),
#endif
#ifdef B115200
- {B115200, 115200/256 + 0x8000U},
+ DO_256(115200),
#endif
#ifdef B230400
- {B230400, 230400/256 + 0x8000U},
+ DO_256(230400),
#endif
#ifdef B460800
- {B460800, 460800/256 + 0x8000U},
+ DO_256(460800),
+#endif
+#ifdef B500000
+ DO_10k(500000),
+#endif
+#ifdef B576000
+ DO_256(576000),
#endif
#ifdef B921600
- {B921600, 921600/256 + 0x8000U},
+ DO_256(921600),
+#endif
+#ifdef B1000000
+ DO_10k(1000000),
+#endif
+#ifdef B1152000
+ DO_256(1152000),
+#endif
+#ifdef B1500000
+ DO_10k(1500000),
+#endif
+#ifdef B2000000
+ DO_10k(2000000),
+#endif
+#ifdef B2500000
+ DO_10k(2500000),
+#endif
+#ifdef B3000000
+ DO_10k(3000000),
+#endif
+#ifdef B3500000
+ DO_10k(3500000),
+#endif
+#ifdef B4000000
+ DO_10k(4000000),
#endif
};
@@ -69,8 +107,11 @@ unsigned FAST_FUNC tty_baud_to_value(speed_t speed)
do {
if (speed == speeds[i].speed) {
- if (speeds[i].value & 0x8000U) {
- return ((unsigned long) (speeds[i].value) & 0x7fffU) * 256;
+ if (speeds[i].value & MARKER_256) {
+ return ((unsigned long) (speeds[i].value) & ~MARKER_MASK) * 256;
+ }
+ if (speeds[i].value & MARKER_10k) {
+ return ((unsigned long) (speeds[i].value) & ~MARKER_MASK) * 10000;
}
return speeds[i].value;
}