lkml.org 
[lkml]   [2020]   [Aug]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v2 03/24] virtio: allow __virtioXX, __leXX in config space
From
Date

On 2020/8/5 下午7:45, Michael S. Tsirkin wrote:
>>> #define virtio_cread(vdev, structname, member, ptr) \
>>> do { \
>>> might_sleep(); \
>>> /* Must match the member's type, and be integer */ \
>>> - if (!typecheck(typeof((((structname*)0)->member)), *(ptr))) \
>>> + if (!__virtio_typecheck(structname, member, *(ptr))) \
>>> (*ptr) = 1; \
>> A silly question,  compare to using set()/get() directly, what's the value
>> of the accessors macro here?
>>
>> Thanks
> get/set don't convert to the native endian, I guess that's why
> drivers use cread/cwrite. It is also nice that there's type
> safety, checking the correct integer width is used.


Yes, but this is simply because a macro is used here, how about just
doing things similar like virtio_cread_bytes():

static inline void virtio_cread(struct virtio_device *vdev,
                      unsigned int offset,
                      void *buf, size_t len)


And do the endian conversion inside?

Thanks


>

\
 
 \ /
  Last update: 2020-08-06 05:38    [W:0.073 / U:1.164 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site