MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / _get_unit_shift

Function _get_unit_shift

components/dfs/dfs_v2/filesystems/devfs/devfs.c:117–138  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

115}
116
117static rt_ubase_t _get_unit_shift(rt_device_t device)
118{
119 rt_ubase_t shift = 0;
120
121 /**
122 * transfer unit size from POSIX RW(in bytes) to rt_device_R/W
123 * (block size for blk device, otherwise in bytes).
124 */
125 if (device->type == RT_Device_Class_Block)
126 {
127 struct rt_device_blk_geometry geometry = {0};
128
129 /* default to 512 */
130 shift = 9;
131 if (!rt_device_control(device, RT_DEVICE_CTRL_BLK_GETGEOME, &geometry))
132 {
133 shift = __rt_ffs(geometry.block_size) - 1;
134 }
135 }
136
137 return shift;
138}
139
140static ssize_t dfs_devfs_read(struct dfs_file *file, void *buf, size_t count, off_t *pos)
141{

Callers 2

dfs_devfs_readFunction · 0.85
dfs_devfs_writeFunction · 0.85

Calls 2

rt_device_controlFunction · 0.85
__rt_ffsFunction · 0.50

Tested by

no test coverage detected