- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I've got a DMA component in my system named "/dev/dma". I copied code from the Memtest template so it should work. However, calling alt_dma_txchan_open("/dev/dma") fails. I traced down into the library code and found that alt_find_dev was performing a memcmp on the name. If I manually change the number of bytes to compare, then memcmp will pass otherwise it fails. Any ideas if I'm doing something wrong?
alt_dev* alt_find_dev(const char* name, alt_llist* llist)
{
alt_dev* next = (alt_dev*) llist->next;
alt_32 len;
// change this line to pass
len = strlen(name) + 1; // fails
len = strlen(name); // passes
while (next != (alt_dev*) llist)
{
if (!memcmp (next->name, name, len))
{
/* match found */
return next;
}
next = (alt_dev*) next->llist.next;
}
return NULL;
}
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Are you sure that your component device name is really "/dev/dma" and not something like "/dev/dma_0" or something else?
To be sure you can include system.h in your source file and use the constant defined there instead of hard coding "/dev/dma". The constant should have a name like DMA_NAME or something close.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I was actually using the defined name from system.h, but I modified my post to make it clear what I was doing.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The only reason I can see for the failure is that the two strings (the one that you provide as device name and tho one declared in the system) are equal on the first 8 characters but differ on the ninth: yours has a 0 indicating an end of string, and the one in the system has something else, indicating that the string is longer.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
A recompile of the hardware and software solved the problem, with no indication of what the problem might have been.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
--- Quote Start --- A recompile of the hardware and software solved the problem, with no indication of what the problem might have been. --- Quote End --- i had the same pb, i simply add a counter to limit the cycle, when the counter reaches max times, return null. and pb solved. dont need to recompile the system. if you look carefully,i'ts the llist.next who block the program. .next remains always the same address, that's why it turns into a infinity cycle.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page