.. | .. |
---|
23 | 23 | struct list_head *list) |
---|
24 | 24 | { |
---|
25 | 25 | 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; |
---|
27 | 27 | |
---|
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) |
---|
30 | 31 | return 0; |
---|
31 | 32 | else |
---|
32 | 33 | return PTR_ERR(phy); |
---|
.. | .. |
---|
122 | 123 | } |
---|
123 | 124 | EXPORT_SYMBOL_GPL(usb_phy_roothub_exit); |
---|
124 | 125 | |
---|
| 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 | + |
---|
125 | 175 | int usb_phy_roothub_power_on(struct usb_phy_roothub *phy_roothub) |
---|
126 | 176 | { |
---|
127 | 177 | struct usb_phy_roothub *roothub_entry; |
---|