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

Function pci_read

components/drivers/pci/procfs.c:64–143  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

62}
63
64static ssize_t pci_read(struct dfs_file *file, void *buf, size_t count, off_t *ppos)
65{
66 off_t pos = *ppos;
67 size_t res = count;
68 rt_ubase_t pm_flags;
69 struct proc_dentry *dentry = file->vnode->data;
70 struct rt_pci_device *pdev = dentry->data;
71
72 pci_pm_runtime_get(pdev, &pm_flags);
73
74 if ((pos & 1) && count)
75 {
76 rt_uint8_t val;
77
78 rt_pci_read_config_u8(pdev, pos, &val);
79 copy_to_user(buf, &val, sizeof(val));
80
81 ++buf;
82 ++pos;
83 --count;
84 }
85
86 if ((pos & 3) && count > 2)
87 {
88 rt_uint16_t val;
89
90 rt_pci_read_config_u16(pdev, pos, &val);
91
92 val = rt_cpu_to_le16(val);
93 copy_to_user(buf, &val, sizeof(val));
94
95 buf += 2;
96 pos += 2;
97 count -= 2;
98 }
99
100 while (count >= 4)
101 {
102 rt_uint32_t val;
103
104 rt_pci_read_config_u32(pdev, pos, &val);
105
106 val = rt_cpu_to_le32(val);
107 copy_to_user(buf, &val, sizeof(val));
108
109 buf += 4;
110 pos += 4;
111 count -= 4;
112 }
113
114 if (count >= 2)
115 {
116 rt_uint16_t val;
117
118 rt_pci_read_config_u16(pdev, pos, &val);
119
120 val = rt_cpu_to_le16(val);
121 copy_to_user(buf, &val, sizeof(val));

Callers

nothing calls this directly

Calls 6

pci_pm_runtime_getFunction · 0.85
rt_pci_read_config_u8Function · 0.85
copy_to_userFunction · 0.85
rt_pci_read_config_u16Function · 0.85
rt_pci_read_config_u32Function · 0.85
pci_pm_runtime_putFunction · 0.85

Tested by

no test coverage detected