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

Function blk_dev_write

components/fal/src/fal_rtt.c:105–136  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

103}
104
105static rt_ssize_t blk_dev_write(rt_device_t dev, rt_off_t pos, const void* buffer, rt_size_t size)
106{
107 int ret = 0;
108 struct fal_blk_device *part;
109 rt_off_t phy_pos;
110 rt_size_t phy_size;
111
112 part = (struct fal_blk_device*) dev;
113 RT_ASSERT(part != RT_NULL);
114
115 /* change the block device's logic address to physical address */
116 phy_pos = pos * part->geometry.bytes_per_sector;
117 phy_size = size * part->geometry.bytes_per_sector;
118
119 ret = fal_partition_erase(part->fal_part, phy_pos, phy_size);
120
121 if (ret == (int) phy_size)
122 {
123 ret = fal_partition_write(part->fal_part, phy_pos, buffer, phy_size);
124 }
125
126 if (ret != (int) phy_size)
127 {
128 ret = 0;
129 }
130 else
131 {
132 ret = size;
133 }
134
135 return ret;
136}
137
138#ifdef RT_USING_DEVICE_OPS
139const static struct rt_device_ops blk_dev_ops =

Callers

nothing calls this directly

Calls 2

fal_partition_eraseFunction · 0.85
fal_partition_writeFunction · 0.85

Tested by

no test coverage detected