vme: 8-bit status/id takes 256 values, not 255
PATCH 1/1 vme: 8-bit status/id takes 256 values, not 255
Fixes an off by one array size.
--- drivers/vme/vme_bridge.h | 4 +++- include/linux/vme.h | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-)
drivers/vme/vme_bridge.h +3 -1
@@ -1,6 +1,8 @@#ifndef _VME_BRIDGE_H_#define _VME_BRIDGE_H_ +#include <linux/vme.h> +#define VME_CRCSR_BUF_SIZE (508*1024)/* * Resource structures
@@ -91,7 +93,7 @@ struct vme_callback {struct vme_irq {int count; -struct vme_callback callback[255 ]; +struct vme_callback callback[VME_NUM_STATUSID ]; };/* Allow 16 characters for name (including null character) */
include/linux/vme.h +3 -0
@@ -81,6 +81,9 @@ struct vme_resource {extern struct bus_type vme_bus_type; +/* Number of VME interrupt vectors */ +#define VME_NUM_STATUSID 256 +/* VME_MAX_BRIDGES comes from the type of vme_bus_numbers */ #define VME_MAX_BRIDGES (sizeof(unsigned int)*8)#define VME_MAX_SLOTS 32
Signature · 1 line
1.8.3.1
Quoted 2 lines · Dmitry Kalinkin
Fixes an off by one array size.
The Status/ID is an 8-bit value (OK, the standard states it can be a 8, 16 or 32-bit value, however both of the chipsets we support at this point in time support an 8-bit value), why do we need a 256th entry in the array?
Martyn
Quoted 45 lines
Signed-off-by Dmitry Kalinkin <[email protected]>--- drivers/vme/vme_bridge.h | 4 +++- include/linux/vme.h | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-)drivers/vme/vme_bridge.h +3
-1@@ -1,6 +1,8 @@#ifndef _VME_BRIDGE_H_#define _VME_BRIDGE_H_ +#include <linux/vme.h> +#define VME_CRCSR_BUF_SIZE (508*1024)/* * Resource structures @@ -91,7 +93,7 @@ struct vme_callback {struct vme_irq {int count; -struct vme_callback callback[255 ]; +struct vme_callback callback[VME_NUM_STATUSID ]; };/* Allow 16 characters for name (including null character) */ include/linux/vme.h +3
-1@@ -81,6 +81,9 @@ struct vme_resource {extern struct bus_type vme_bus_type; +/* Number of VME interrupt vectors */ +#define VME_NUM_STATUSID 256 +/* VME_MAX_BRIDGES comes from the type of vme_bus_numbers */ #define VME_MAX_BRIDGES (sizeof(unsigned int)*8)#define VME_MAX_SLOTS 32 --1.8.3.1
Quoted 8 lines · Martyn Welch
Quoted 2 lines · Dmitry Kalinkin
Fixes an off by one array size.
The Status/ID is an 8-bit value (OK, the standard states it can be a 8, 16 or 32-bit value, however both of the chipsets we support at this point in time support an 8-bit value), why do we need a 256th entry in the array?
Hi Martyn,
8 bit signal spans 256 values from 8'b0000_0000 to 8'b1111_1111. In order to serve that we need a C array of size 256. callback[255]; in the original code means that array has 255 elements with indices from 0 to 254, there would be no way to register callback for a valid Status/ID value of 255 (aka 8'b1111_1111). For that we need a 256th element.
Dmitri
Quoted 48 lines
Martyn
Quoted 45 lines
Signed-off-by Dmitry Kalinkin <[email protected]>--- drivers/vme/vme_bridge.h | 4 +++- include/linux/vme.h | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-)drivers/vme/vme_bridge.h +3
-1@@ -1,6 +1,8 @@#ifndef _VME_BRIDGE_H_#define _VME_BRIDGE_H_ +#include <linux/vme.h> +#define VME_CRCSR_BUF_SIZE (508*1024)/* * Resource structures @@ -91,7 +93,7 @@ struct vme_callback {struct vme_irq {int count; -struct vme_callback callback[255 ]; +struct vme_callback callback[VME_NUM_STATUSID ]; };/* Allow 16 characters for name (including null character) */ include/linux/vme.h +3
-1@@ -81,6 +81,9 @@ struct vme_resource {extern struct bus_type vme_bus_type; +/* Number of VME interrupt vectors */ +#define VME_NUM_STATUSID 256 +/* VME_MAX_BRIDGES comes from the type of vme_bus_numbers */ #define VME_MAX_BRIDGES (sizeof(unsigned int)*8)#define VME_MAX_SLOTS 32 --1.8.3.1
Quoted 8 lines · Dmitry Kalinkin
Quoted 7 lines · Martyn Welch
Quoted 2 lines · Dmitry Kalinkin
Fixes an off by one array size.
The Status/ID is an 8-bit value (OK, the standard states it can be a 8, 16 or 32-bit value, however both of the chipsets we support at this point in time support an 8-bit value), why do we need a 256th entry in the array?
Quoted 8 lines
Hi Martyn,
8 bit signal spans 256 values from 8'b0000_0000 to 8'b1111_1111. In order to serve that we need a C array of size 256. callback[255]; in the original code means that array has 255 elements with indices from 0 to 254, there would be no way to register callback for a valid Status/ID value of 255 (aka 8'b1111_1111). For that we need a 256th element.
Err, yep. (Curses self for being so stupid.)
Quoted 49 lines
Dmitri
Quoted 47 lines
Martyn
Quoted 45 lines
Signed-off-by Dmitry Kalinkin <[email protected]>--- drivers/vme/vme_bridge.h | 4 +++- include/linux/vme.h | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-)drivers/vme/vme_bridge.h +3
-1@@ -1,6 +1,8 @@#ifndef _VME_BRIDGE_H_#define _VME_BRIDGE_H_ +#include <linux/vme.h> +#define VME_CRCSR_BUF_SIZE (508*1024)/* * Resource structures @@ -91,7 +93,7 @@ struct vme_callback {struct vme_irq {int count; -struct vme_callback callback[255 ]; +struct vme_callback callback[VME_NUM_STATUSID ]; };/* Allow 16 characters for name (including null character) */ include/linux/vme.h +3
-1@@ -81,6 +81,9 @@ struct vme_resource {extern struct bus_type vme_bus_type; +/* Number of VME interrupt vectors */ +#define VME_NUM_STATUSID 256 +/* VME_MAX_BRIDGES comes from the type of vme_bus_numbers */ #define VME_MAX_BRIDGES (sizeof(unsigned int)*8)#define VME_MAX_SLOTS 32 --1.8.3.1