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

Function pci_write

components/drivers/pci/procfs.c:145–218  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

143}
144
145static ssize_t pci_write(struct dfs_file *file, const void *buf, size_t count, off_t *ppos)
146{
147 off_t pos = *ppos;
148 size_t res = count;
149 rt_ubase_t pm_flags;
150 struct proc_dentry *dentry = file->vnode->data;
151 struct rt_pci_device *pdev = dentry->data;
152
153 pci_pm_runtime_get(pdev, &pm_flags);
154
155 if ((pos & 1) && count)
156 {
157 rt_uint8_t val;
158
159 copy_from_user(&val, buf, sizeof(val));
160 rt_pci_write_config_u8(pdev, pos, val);
161
162 ++buf;
163 ++pos;
164 --count;
165 }
166
167 if ((pos & 3) && count > 2)
168 {
169 rt_le16_t val;
170
171 copy_from_user(&val, buf, sizeof(val));
172 rt_pci_write_config_u16(pdev, pos, rt_le16_to_cpu(val));
173
174 buf += 2;
175 pos += 2;
176 count -= 2;
177 }
178
179 while (count >= 4)
180 {
181 rt_le32_t val;
182
183 copy_from_user(&val, buf, sizeof(val));
184 rt_pci_write_config_u32(pdev, pos, rt_le32_to_cpu(val));
185
186 buf += 4;
187 pos += 4;
188 count -= 4;
189 }
190
191 if (count >= 2)
192 {
193 rt_le16_t val;
194
195 copy_from_user(&val, buf, sizeof(val));
196 rt_pci_write_config_u16(pdev, pos, rt_le16_to_cpu(val));
197
198 buf += 2;
199 pos += 2;
200 count -= 2;
201 }
202

Callers

nothing calls this directly

Calls 6

pci_pm_runtime_getFunction · 0.85
copy_from_userFunction · 0.85
rt_pci_write_config_u8Function · 0.85
rt_pci_write_config_u16Function · 0.85
rt_pci_write_config_u32Function · 0.85
pci_pm_runtime_putFunction · 0.85

Tested by

no test coverage detected