hc
2024-10-22 8ac6c7a54ed1b98d142dce24b11c6de6a1e239a5
kernel/drivers/usb/core/phy.c
....@@ -23,10 +23,11 @@
2323 struct list_head *list)
2424 {
2525 struct usb_phy_roothub *roothub_entry;
26
- struct phy *phy = devm_of_phy_get_by_index(dev, dev->of_node, index);
26
+ struct phy *phy;
2727
28
- if (IS_ERR_OR_NULL(phy)) {
29
- if (!phy || PTR_ERR(phy) == -ENODEV)
28
+ phy = devm_of_phy_get_by_index(dev, dev->of_node, index);
29
+ if (IS_ERR(phy)) {
30
+ if (PTR_ERR(phy) == -ENODEV)
3031 return 0;
3132 else
3233 return PTR_ERR(phy);
....@@ -122,6 +123,55 @@
122123 }
123124 EXPORT_SYMBOL_GPL(usb_phy_roothub_exit);
124125
126
+int usb_phy_roothub_set_mode(struct usb_phy_roothub *phy_roothub,
127
+ enum phy_mode mode)
128
+{
129
+ struct usb_phy_roothub *roothub_entry;
130
+ struct list_head *head;
131
+ int err;
132
+
133
+ if (!phy_roothub)
134
+ return 0;
135
+
136
+ head = &phy_roothub->list;
137
+
138
+ list_for_each_entry(roothub_entry, head, list) {
139
+ err = phy_set_mode(roothub_entry->phy, mode);
140
+ if (err)
141
+ goto err_out;
142
+ }
143
+
144
+ return 0;
145
+
146
+err_out:
147
+ list_for_each_entry_continue_reverse(roothub_entry, head, list)
148
+ phy_power_off(roothub_entry->phy);
149
+
150
+ return err;
151
+}
152
+EXPORT_SYMBOL_GPL(usb_phy_roothub_set_mode);
153
+
154
+int usb_phy_roothub_calibrate(struct usb_phy_roothub *phy_roothub)
155
+{
156
+ struct usb_phy_roothub *roothub_entry;
157
+ struct list_head *head;
158
+ int err;
159
+
160
+ if (!phy_roothub)
161
+ return 0;
162
+
163
+ head = &phy_roothub->list;
164
+
165
+ list_for_each_entry(roothub_entry, head, list) {
166
+ err = phy_calibrate(roothub_entry->phy);
167
+ if (err)
168
+ return err;
169
+ }
170
+
171
+ return 0;
172
+}
173
+EXPORT_SYMBOL_GPL(usb_phy_roothub_calibrate);
174
+
125175 int usb_phy_roothub_power_on(struct usb_phy_roothub *phy_roothub)
126176 {
127177 struct usb_phy_roothub *roothub_entry;