drm/nouveau/bios: fix DCB v1.5 parsing
Subsystems (3)
PATCH 1/1 drm/nouveau/bios: fix DCB v1.5 parsing
memcmp->nv_strncmp conversion should have inverted the return value.
---
See http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=blob;f=drivers/gpu/drm/nouveau/nouveau_bios.c;h=a0a3fe3c016be86665db1369c44bef832f829a1a;hb=a0d271cbfed1dd50278c6b06bead3d00ba0a88f9#l5652 (3.6) and http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=blob;f=drivers/gpu/drm/nouveau/core/include/core/object.h;h=818feabbf4a0969f090f897852fe4476a422b1b6;hb=77b67063bb6bce6d475e910d3b886a606d0d91f7#l179 (nv_strncmp definition)
--- drivers/gpu/drm/nouveau/core/subdev/bios/dcb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/nouveau/core/subdev/bios/dcb.c +1 -1
@@ -64,7 +64,7 @@ dcb_table(struct nouveau_bios *bios, u8 *ver, u8 *hdr, u8 *cnt, u8 *len) } }else if (*ver >=0x15 ) { -if (!nv_strncmp (bios, dcb -7 ,7 ,"DEV_REC" )) { +if (nv_strncmp (bios, dcb -7 ,7 ,"DEV_REC" )) {u16 i2c =nv_ro16 (bios, dcb +2 ); *hdr =4 ; *cnt = (i2c - dcb) /10 ;
Signature · 1 line
1.7.12
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 6 lines · Marcin Slusarz
memcmp->nv_strncmpconversion should have inverted the return value.Signed-off-by Marcin Slusarz <[email protected]>---
See http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=blob;f=drivers/gpu/drm/nouveau/nouveau_bios.c;h=a0a3fe3c016be86665db1369c44bef832f829a1a;hb=a0d271cbfed1dd50278c6b06bead3d00ba0a88f9#l5652 (3.6) and http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=blob;f=drivers/gpu/drm/nouveau/core/include/core/object.h;h=818feabbf4a0969f090f897852fe4476a422b1b6;hb=77b67063bb6bce6d475e910d3b886a606d0d91f7#l179 (nv_strncmpdefinition)
Christ fix that nv_strncmp to act like the C one, or give it a very different name!
Dave.
A message that is not in the archive (sent off-list or not yet received): CAPM=9tx7nxB1ncQUZrBCh2xyKNxEz77=QMyandzoKmY3yopXEA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Quoted 11 lines · Dave Airlie
Quoted 6 lines · Marcin Slusarz
memcmp->nv_strncmpconversion should have inverted the return value.Signed-off-by Marcin Slusarz <[email protected]>---
See http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=blob;f=drivers/gpu/drm/nouveau/nouveau_bios.c;h=a0a3fe3c016be86665db1369c44bef832f829a1a;hb=a0d271cbfed1dd50278c6b06bead3d00ba0a88f9#l5652 (3.6) and http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=blob;f=drivers/gpu/drm/nouveau/core/include/core/object.h;h=818feabbf4a0969f090f897852fe4476a422b1b6;hb=77b67063bb6bce6d475e910d3b886a606d0d91f7#l179 (nv_strncmpdefinition)Christ fix that
nv_strncmpto act like the C one, or give it a very different name!
Please don't kill the messenger.
---
From: Marcin Slusarz <[email protected]>
Subject: [PATCH v2] drm/nouveau/bios: fix DCB v1.5 parsing
memcmp->nv_strncmp conversion, in addition to name change, should have inverted the return value.
But nv_strncmp does not act like strncmp - it does not check for string terminator, returns true/false instead of -1/0/1 and has different parameters order.
Let's rename it to nv_memcmp and let it act like memcmp.
--- drivers/gpu/drm/nouveau/core/include/core/object.h | 14 +++++++++----- drivers/gpu/drm/nouveau/core/subdev/bios/dcb.c | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-)
drivers/gpu/drm/nouveau/core/include/core/object.h +9 -5
@@ -175,14 +175,18 @@ nv_mo32(void *obj, u32 addr, u32 mask, u32 data) return temp; } -static inline bool -nv_strncmp (void *obj,u32 addr,u32 len,const char *str) +static inline int +nv_memcmp (void *obj,u32 addr,const char *str,u32 len) { +unsigned char c1, c2; +while (len--) { -if (nv_ro08 (obj, addr++) != *(str++)) -return false; + c1 =nv_ro08 (obj, addr++); + c2 = *(str++); +if (c1 != c2) +return c1 - c2; } -return true; +return 0 ; }#endif
drivers/gpu/drm/nouveau/core/subdev/bios/dcb.c +1 -1
@@ -64,7 +64,7 @@ dcb_table(struct nouveau_bios *bios, u8 *ver, u8 *hdr, u8 *cnt, u8 *len) } }else if (*ver >=0x15 ) { -if (!nv_strncmp (bios, dcb -7 ,7 ,"DEV_REC" )) { +if (!nv_memcmp (bios, dcb -7 ,"DEV_REC" ,7 )) {u16 i2c =nv_ro16 (bios, dcb +2 ); *hdr =4 ; *cnt = (i2c - dcb) /10 ;
Signature · 1 line
1.7.12