Skip to content

Commit c45eab2

Browse files
author
Lee Jones
committed
mfd: ab8500-debugfs: Prevent initialised field from being over-written
Due to the lack of parity in the way array fields have been named/ numbered, a mistake was made where more debug fields were declared than actually existed. In doing so, 2 fields were added, which although unclear, were already declared in the array. The result was that the latter declarations trashed the former ones. This patch places the array back in the correct order and removes the offending NULL entries. While we're at it, let's ensure this doesn't happen again by naming each field properly and add a new *_LAST define to describe how many fields there should be. Signed-off-by: Lee Jones <lee.jones@linaro.org>
1 parent c646e2b commit c45eab2

2 files changed

Lines changed: 23 additions & 29 deletions

File tree

‎drivers/mfd/ab8500-debugfs.c‎

Lines changed: 21 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -153,14 +153,14 @@ static struct hwreg_cfg hwreg_cfg = {
153153

154154
#define AB8500_NAME_STRING "ab8500"
155155
#define AB8500_ADC_NAME_STRING "gpadc"
156-
#define AB8500_NUM_BANKS 24
156+
#define AB8500_NUM_BANKS AB8500_DEBUG_FIELD_LAST
157157

158158
#define AB8500_REV_REG 0x80
159159

160160
static struct ab8500_prcmu_ranges *debug_ranges;
161161

162162
static struct ab8500_prcmu_ranges ab8500_debug_ranges[AB8500_NUM_BANKS] = {
163-
[0x0] = {
163+
[AB8500_M_FSM_RANK] = {
164164
.num_ranges = 0,
165165
.range = NULL,
166166
},
@@ -315,7 +315,7 @@ static struct ab8500_prcmu_ranges ab8500_debug_ranges[AB8500_NUM_BANKS] = {
315315
},
316316
},
317317
},
318-
[0x9] = {
318+
[AB8500_RESERVED] = {
319319
.num_ranges = 0,
320320
.range = NULL,
321321
},
@@ -386,24 +386,6 @@ static struct ab8500_prcmu_ranges ab8500_debug_ranges[AB8500_NUM_BANKS] = {
386386
},
387387
},
388388
},
389-
[AB8500_DEVELOPMENT] = {
390-
.num_ranges = 1,
391-
.range = (struct ab8500_reg_range[]) {
392-
{
393-
.first = 0x00,
394-
.last = 0x00,
395-
},
396-
},
397-
},
398-
[AB8500_DEBUG] = {
399-
.num_ranges = 1,
400-
.range = (struct ab8500_reg_range[]) {
401-
{
402-
.first = 0x05,
403-
.last = 0x07,
404-
},
405-
},
406-
},
407389
[AB8500_AUDIO] = {
408390
.num_ranges = 1,
409391
.range = (struct ab8500_reg_range[]) {
@@ -463,19 +445,29 @@ static struct ab8500_prcmu_ranges ab8500_debug_ranges[AB8500_NUM_BANKS] = {
463445
},
464446
},
465447
},
466-
[0x11] = {
467-
.num_ranges = 0,
468-
.range = NULL,
448+
[AB8500_DEVELOPMENT] = {
449+
.num_ranges = 1,
450+
.range = (struct ab8500_reg_range[]) {
451+
{
452+
.first = 0x00,
453+
.last = 0x00,
454+
},
455+
},
469456
},
470-
[0x12] = {
471-
.num_ranges = 0,
472-
.range = NULL,
457+
[AB8500_DEBUG] = {
458+
.num_ranges = 1,
459+
.range = (struct ab8500_reg_range[]) {
460+
{
461+
.first = 0x05,
462+
.last = 0x07,
463+
},
464+
},
473465
},
474-
[0x13] = {
466+
[AB8500_PROD_TEST] = {
475467
.num_ranges = 0,
476468
.range = NULL,
477469
},
478-
[0x14] = {
470+
[AB8500_STE_TEST] = {
479471
.num_ranges = 0,
480472
.range = NULL,
481473
},

‎include/linux/mfd/abx500/ab8500.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ enum ab8500_version {
6363
#define AB8500_STE_TEST 0x14
6464
#define AB8500_OTP_EMUL 0x15
6565

66+
#define AB8500_DEBUG_FIELD_LAST 0x16
67+
6668
/*
6769
* Interrupts
6870
* Values used to index into array ab8500_irq_regoffset[] defined in

0 commit comments

Comments
 (0)