Commit 4952501ac3a1ee6138d10e7f331928f0cf7e6fa4
Committed by
guoyin.chen
1 parent
d675652038
Exists in
smarc-imx_v2015.04_4.1.15_1.0.0_ga
and in
1 other branch
net: mdio: Add mdio_free() and mdio_unregister() API
Currently there is no API to uninitialize mdio. Add two APIs for this. Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Acked-by: Joe Hershberger <joe.hershberger@ni.com> (cherry picked from commit cb6baca77bca0ef999203a7ed73bd123e7da062e)
Showing 2 changed files with 21 additions and 0 deletions Side-by-side Diff
common/miiphyutil.c
... | ... | @@ -151,6 +151,11 @@ |
151 | 151 | return bus; |
152 | 152 | } |
153 | 153 | |
154 | +void mdio_free(struct mii_dev *bus) | |
155 | +{ | |
156 | + free(bus); | |
157 | +} | |
158 | + | |
154 | 159 | int mdio_register(struct mii_dev *bus) |
155 | 160 | { |
156 | 161 | if (!bus || !bus->name || !bus->read || !bus->write) |
... | ... | @@ -168,6 +173,20 @@ |
168 | 173 | |
169 | 174 | if (!current_mii) |
170 | 175 | current_mii = bus; |
176 | + | |
177 | + return 0; | |
178 | +} | |
179 | + | |
180 | +int mdio_unregister(struct mii_dev *bus) | |
181 | +{ | |
182 | + if (!bus) | |
183 | + return 0; | |
184 | + | |
185 | + /* delete it from the list */ | |
186 | + list_del(&bus->link); | |
187 | + | |
188 | + if (current_mii == bus) | |
189 | + current_mii = NULL; | |
171 | 190 | |
172 | 191 | return 0; |
173 | 192 | } |
include/miiphy.h
... | ... | @@ -59,7 +59,9 @@ |
59 | 59 | void miiphy_listdev(void); |
60 | 60 | |
61 | 61 | struct mii_dev *mdio_alloc(void); |
62 | +void mdio_free(struct mii_dev *bus); | |
62 | 63 | int mdio_register(struct mii_dev *bus); |
64 | +int mdio_unregister(struct mii_dev *bus); | |
63 | 65 | void mdio_list_devices(void); |
64 | 66 | |
65 | 67 | #ifdef CONFIG_BITBANGMII |