Skip to content

Commit

Permalink
mfd: ab8500-debugfs: Prevent initialised field from being over-written
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Lee Jones committed Oct 4, 2016
1 parent c646e2b commit c45eab2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 29 deletions.
50 changes: 21 additions & 29 deletions drivers/mfd/ab8500-debugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,14 @@ static struct hwreg_cfg hwreg_cfg = {

#define AB8500_NAME_STRING "ab8500"
#define AB8500_ADC_NAME_STRING "gpadc"
#define AB8500_NUM_BANKS 24
#define AB8500_NUM_BANKS AB8500_DEBUG_FIELD_LAST

#define AB8500_REV_REG 0x80

static struct ab8500_prcmu_ranges *debug_ranges;

static struct ab8500_prcmu_ranges ab8500_debug_ranges[AB8500_NUM_BANKS] = {
[0x0] = {
[AB8500_M_FSM_RANK] = {
.num_ranges = 0,
.range = NULL,
},
Expand Down Expand Up @@ -315,7 +315,7 @@ static struct ab8500_prcmu_ranges ab8500_debug_ranges[AB8500_NUM_BANKS] = {
},
},
},
[0x9] = {
[AB8500_RESERVED] = {
.num_ranges = 0,
.range = NULL,
},
Expand Down Expand Up @@ -386,24 +386,6 @@ static struct ab8500_prcmu_ranges ab8500_debug_ranges[AB8500_NUM_BANKS] = {
},
},
},
[AB8500_DEVELOPMENT] = {
.num_ranges = 1,
.range = (struct ab8500_reg_range[]) {
{
.first = 0x00,
.last = 0x00,
},
},
},
[AB8500_DEBUG] = {
.num_ranges = 1,
.range = (struct ab8500_reg_range[]) {
{
.first = 0x05,
.last = 0x07,
},
},
},
[AB8500_AUDIO] = {
.num_ranges = 1,
.range = (struct ab8500_reg_range[]) {
Expand Down Expand Up @@ -463,19 +445,29 @@ static struct ab8500_prcmu_ranges ab8500_debug_ranges[AB8500_NUM_BANKS] = {
},
},
},
[0x11] = {
.num_ranges = 0,
.range = NULL,
[AB8500_DEVELOPMENT] = {
.num_ranges = 1,
.range = (struct ab8500_reg_range[]) {
{
.first = 0x00,
.last = 0x00,
},
},
},
[0x12] = {
.num_ranges = 0,
.range = NULL,
[AB8500_DEBUG] = {
.num_ranges = 1,
.range = (struct ab8500_reg_range[]) {
{
.first = 0x05,
.last = 0x07,
},
},
},
[0x13] = {
[AB8500_PROD_TEST] = {
.num_ranges = 0,
.range = NULL,
},
[0x14] = {
[AB8500_STE_TEST] = {
.num_ranges = 0,
.range = NULL,
},
Expand Down
2 changes: 2 additions & 0 deletions include/linux/mfd/abx500/ab8500.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ enum ab8500_version {
#define AB8500_STE_TEST 0x14
#define AB8500_OTP_EMUL 0x15

#define AB8500_DEBUG_FIELD_LAST 0x16

/*
* Interrupts
* Values used to index into array ab8500_irq_regoffset[] defined in
Expand Down

0 comments on commit c45eab2

Please sign in to comment.