1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
From ae7ecbfa459730344eeb559ce0352662c540289c Mon Sep 17 00:00:00 2001
From: Bas Laarhoven <sjml@xs4all.nl>
Date: Tue, 15 May 2012 10:00:47 +0200
Subject: [PATCH 56/79] Added check on EEPROM revision to prevent interpreting
unknown formats.
Signed-off-by: Koen Kooi <koen@dominion.thruhere.net>
---
arch/arm/mach-omap2/board-am335xevm.c | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/arch/arm/mach-omap2/board-am335xevm.c b/arch/arm/mach-omap2/board-am335xevm.c
index 0fa8a32..68ddfe2 100644
--- a/arch/arm/mach-omap2/board-am335xevm.c
+++ b/arch/arm/mach-omap2/board-am335xevm.c
@@ -2481,12 +2481,21 @@ static int bone_io_config_pin( const char* pin_name, pin_def eeprom_setting)
pr_info( "+%s+\n", status); \
} while (0)
-static void bone_io_config_from_cape_eeprom( void)
+static int bone_io_config_from_cape_eeprom( void)
{
int i;
int cnt = BIG_ENDIAN_16( cape_config.numpins);
u16* pmuxdata;
char status[ NR_ITEMS( cape_config.muxdata) + 1];
+ char revision[ NR_ITEMS( cape_config.format_revision) + 1];
+
+ strncpy( revision, cape_config.format_revision, NR_ITEMS( revision) - 1);
+ revision[ NR_ITEMS( revision) - 1] = '\0';
+ if (strcmp( revision, "A0") != 0) {
+ pr_warn( "BeagleBone cape: configuration revision '%s' is not supported\n",
+ revision);
+ return -1;
+ }
// Workaround for capes that have encoded this as ASCII
if (cnt > 256) {
@@ -2494,8 +2503,8 @@ static void bone_io_config_from_cape_eeprom( void)
cnt = (cape_config.numpins & 255) - '0';
cnt = 10 * cnt + ((cape_config.numpins >> 8) & 255) - '0';
}
- pr_info( "BeagleBone cape: configuring %2d out of %2d signals:\n",
- cnt, NR_ITEMS( cape_config.muxdata));
+ pr_info( "BeagleBone cape: revision %s format, configuring %2d out of %2d signals:\n",
+ revision, cnt, NR_ITEMS( cape_config.muxdata));
RULER( NR_ITEMS( cape_config.muxdata));
for (i = 0, pmuxdata = cape_config.muxdata ; i < NR_ITEMS( cape_config.muxdata) ; ++i, ++pmuxdata) {
const char* pin_name = cape_pins[ i];
@@ -2517,6 +2526,7 @@ static void bone_io_config_from_cape_eeprom( void)
status[ NR_ITEMS( cape_config.muxdata)] = '\0';
pr_info( "|%s|\n", status);
RULER( NR_ITEMS( cape_config.muxdata));
+ return 0;
}
static void beaglebone_cape_setup(struct memory_accessor *mem_acc, void *context)
--
1.7.10
|