linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] vme: 8-bit status/id takes 256 values, not 255
@ 2015-10-10 22:00 Dmitry Kalinkin
  2015-10-18 13:30 ` Martyn Welch
  0 siblings, 1 reply; 4+ messages in thread
From: Dmitry Kalinkin @ 2015-10-10 22:00 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Martyn Welch, Manohar Vanga
  Cc: devel, linux-kernel, Dmitry Kalinkin

Fixes an off by one array size.

Signed-off-by: Dmitry Kalinkin <dmitry.kalinkin@gmail.com>
---
 drivers/vme/vme_bridge.h | 4 +++-
 include/linux/vme.h      | 3 +++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/vme/vme_bridge.h b/drivers/vme/vme_bridge.h
index 397578a..b59cbee 100644
--- a/drivers/vme/vme_bridge.h
+++ b/drivers/vme/vme_bridge.h
@@ -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) */
diff --git a/include/linux/vme.h b/include/linux/vme.h
index c013135..71e4a6d 100644
--- a/include/linux/vme.h
+++ b/include/linux/vme.h
@@ -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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] vme: 8-bit status/id takes 256 values, not 255
  2015-10-10 22:00 [PATCH] vme: 8-bit status/id takes 256 values, not 255 Dmitry Kalinkin
@ 2015-10-18 13:30 ` Martyn Welch
  2015-10-18 17:07   ` Dmitry Kalinkin
  0 siblings, 1 reply; 4+ messages in thread
From: Martyn Welch @ 2015-10-18 13:30 UTC (permalink / raw)
  To: Dmitry Kalinkin; +Cc: Greg Kroah-Hartman, Manohar Vanga, devel, linux-kernel

On 10 October 2015 at 23:00, Dmitry Kalinkin <dmitry.kalinkin@gmail.com> wrote:
> 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

> Signed-off-by: Dmitry Kalinkin <dmitry.kalinkin@gmail.com>
> ---
>  drivers/vme/vme_bridge.h | 4 +++-
>  include/linux/vme.h      | 3 +++
>  2 files changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/vme/vme_bridge.h b/drivers/vme/vme_bridge.h
> index 397578a..b59cbee 100644
> --- a/drivers/vme/vme_bridge.h
> +++ b/drivers/vme/vme_bridge.h
> @@ -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) */
> diff --git a/include/linux/vme.h b/include/linux/vme.h
> index c013135..71e4a6d 100644
> --- a/include/linux/vme.h
> +++ b/include/linux/vme.h
> @@ -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
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] vme: 8-bit status/id takes 256 values, not 255
  2015-10-18 13:30 ` Martyn Welch
@ 2015-10-18 17:07   ` Dmitry Kalinkin
  2015-10-18 18:22     ` Martyn Welch
  0 siblings, 1 reply; 4+ messages in thread
From: Dmitry Kalinkin @ 2015-10-18 17:07 UTC (permalink / raw)
  To: Martyn Welch; +Cc: Greg Kroah-Hartman, Manohar Vanga, devel, LKML

On Sun, Oct 18, 2015 at 9:30 AM, Martyn Welch <martyn@welchs.me.uk> wrote:
> On 10 October 2015 at 23:00, Dmitry Kalinkin <dmitry.kalinkin@gmail.com> wrote:
>> 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

>
> Martyn
>
>> Signed-off-by: Dmitry Kalinkin <dmitry.kalinkin@gmail.com>
>> ---
>>  drivers/vme/vme_bridge.h | 4 +++-
>>  include/linux/vme.h      | 3 +++
>>  2 files changed, 6 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/vme/vme_bridge.h b/drivers/vme/vme_bridge.h
>> index 397578a..b59cbee 100644
>> --- a/drivers/vme/vme_bridge.h
>> +++ b/drivers/vme/vme_bridge.h
>> @@ -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) */
>> diff --git a/include/linux/vme.h b/include/linux/vme.h
>> index c013135..71e4a6d 100644
>> --- a/include/linux/vme.h
>> +++ b/include/linux/vme.h
>> @@ -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
>>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] vme: 8-bit status/id takes 256 values, not 255
  2015-10-18 17:07   ` Dmitry Kalinkin
@ 2015-10-18 18:22     ` Martyn Welch
  0 siblings, 0 replies; 4+ messages in thread
From: Martyn Welch @ 2015-10-18 18:22 UTC (permalink / raw)
  To: Dmitry Kalinkin; +Cc: Greg Kroah-Hartman, Manohar Vanga, devel, LKML



On 18/10/15 18:07, Dmitry Kalinkin wrote:
> On Sun, Oct 18, 2015 at 9:30 AM, Martyn Welch <martyn@welchs.me.uk> wrote:
>> On 10 October 2015 at 23:00, Dmitry Kalinkin <dmitry.kalinkin@gmail.com> wrote:
>>> 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.

Err, yep. (Curses self for being so stupid.)

Signed-off-by: Martyn Welch <martyn@welchs.me.uk>

> Dmitri
>
>> Martyn
>>
>>> Signed-off-by: Dmitry Kalinkin <dmitry.kalinkin@gmail.com>
>>> ---
>>>   drivers/vme/vme_bridge.h | 4 +++-
>>>   include/linux/vme.h      | 3 +++
>>>   2 files changed, 6 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/vme/vme_bridge.h b/drivers/vme/vme_bridge.h
>>> index 397578a..b59cbee 100644
>>> --- a/drivers/vme/vme_bridge.h
>>> +++ b/drivers/vme/vme_bridge.h
>>> @@ -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) */
>>> diff --git a/include/linux/vme.h b/include/linux/vme.h
>>> index c013135..71e4a6d 100644
>>> --- a/include/linux/vme.h
>>> +++ b/include/linux/vme.h
>>> @@ -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
>>>


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-10-18 18:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-10 22:00 [PATCH] vme: 8-bit status/id takes 256 values, not 255 Dmitry Kalinkin
2015-10-18 13:30 ` Martyn Welch
2015-10-18 17:07   ` Dmitry Kalinkin
2015-10-18 18:22     ` Martyn Welch

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).