ikwzm / udmabuf

User space mappable dma buffer device driver for Linux.
BSD 2-Clause "Simplified" License
539 stars 165 forks source link

typo in sync_for_cpu sample in documentation? #82

Closed 5p00kk closed 2 years ago

5p00kk commented 2 years ago

Hi,

In Readme.md in section https://github.com/ikwzm/udmabuf#sync_for_cpu it states that:

If '1' is written to device file, if sync_direction is 2(=DMA_FROM_DEVICE) or 0(=DMA_BIDIRECTIONAL), the write to the device file invalidates a cache specified by sync_offset and sync_size.

but in both sync_for_cpu code samples

unsigned long sync_for_cpu = 1;

I expect this is just a typo in the code sample right?

ikwzm commented 2 years ago

No, it's not a typo. Whenever you run sync_for_cpu, you must write a non-zero value. Therefore, 1 is set in sync_for_cpu to make the least significant bit 1.

5p00kk commented 2 years ago

Sorry I actually copied wrong line, I meant:

unsigned int sync_direction = 1;

I'd expect direction to be either 2 or 0 based on the description.

ikwzm commented 2 years ago

As you pointed out, it is confusing as a sample code, so I corrected it.

Thank you for issue.