Now drivers (like NVIDIA Tegra USB PHY for example) will be able to benefit from the resource-managed variant, making driver's code a bit cleaner.
Unified · Split
| @@ -240,6 +240,21 @@ static int ulpi_set_vbus(struct usb_otg *otg, bool on) · 239 unmodified lines | |||
| 240 | return usb_phy_io_write(phy, flags, ULPI_OTG_CTRL); | 240 | return usb_phy_io_write(phy, flags, ULPI_OTG_CTRL); |
| 241 | } | 241 | } |
| 242 | 242 | ||
| 243 | static void otg_ulpi_init(struct usb_phy *phy, struct usb_otg *otg, | ||
| 244 | struct usb_phy_io_ops *ops, | ||
| 245 | unsigned int flags) | ||
| 246 | { | ||
| 247 | phy->label = "ULPI"; | ||
| 248 | phy->flags = flags; | ||
| 249 | phy->io_ops = ops; | ||
| 250 | phy->otg = otg; | ||
| 251 | phy->init = ulpi_init; | ||
| 252 | |||
| 253 | otg->usb_phy = phy; | ||
| 254 | otg->set_host = ulpi_set_host; | ||
| 255 | otg->set_vbus = ulpi_set_vbus; | ||
| 256 | } | ||
| 257 | |||
| 243 | struct usb_phy * | 258 | struct usb_phy * |
| 244 | otg_ulpi_create(struct usb_phy_io_ops *ops, | 259 | otg_ulpi_create(struct usb_phy_io_ops *ops, |
| 245 | unsigned int flags) | 260 | unsigned int flags) |
| @@ -257,17 +272,32 @@ otg_ulpi_create(struct usb_phy_io_ops *ops, · 11 unmodified lines | |||
| 257 | return NULL; | 272 | return NULL; |
| 258 | } | 273 | } |
| 259 | 274 | ||
| 260 | phy->label = "ULPI"; | 275 | otg_ulpi_init(phy, otg, ops, flags); |
| 261 | phy->flags = flags; | ||
| 262 | phy->io_ops = ops; | ||
| 263 | phy->otg = otg; | ||
| 264 | phy->init = ulpi_init; | ||
| 265 | |||
| 266 | otg->usb_phy = phy; | ||
| 267 | otg->set_host = ulpi_set_host; | ||
| 268 | otg->set_vbus = ulpi_set_vbus; | ||
| 269 | 276 | ||
| 270 | return phy; | 277 | return phy; |
| 271 | } | 278 | } |
| 272 | EXPORT_SYMBOL_GPL(otg_ulpi_create); | 279 | EXPORT_SYMBOL_GPL(otg_ulpi_create); |
| 273 | 280 | ||
| 281 | struct usb_phy * | ||
| 282 | devm_otg_ulpi_create(struct device *dev, | ||
| 283 | struct usb_phy_io_ops *ops, | ||
| 284 | unsigned int flags) | ||
| 285 | { | ||
| 286 | struct usb_phy *phy; | ||
| 287 | struct usb_otg *otg; | ||
| 288 | |||
| 289 | phy = devm_kzalloc(dev, sizeof(*phy), GFP_KERNEL); | ||
| 290 | if (!phy) | ||
| 291 | return NULL; | ||
| 292 | |||
| 293 | otg = devm_kzalloc(dev, sizeof(*otg), GFP_KERNEL); | ||
| 294 | if (!otg) { | ||
| 295 | devm_kfree(dev, phy); | ||
| 296 | return NULL; | ||
| 297 | } | ||
| 298 | |||
| 299 | otg_ulpi_init(phy, otg, ops, flags); | ||
| 300 | |||
| 301 | return phy; | ||
| 302 | } | ||
| 303 | EXPORT_SYMBOL_GPL(devm_otg_ulpi_create); | ||
| @@ -55,12 +55,23 @@ · 54 unmodified lines | |||
| 55 | #if IS_ENABLED(CONFIG_USB_ULPI) | 55 | #if IS_ENABLED(CONFIG_USB_ULPI) |
| 56 | struct usb_phy *otg_ulpi_create(struct usb_phy_io_ops *ops, | 56 | struct usb_phy *otg_ulpi_create(struct usb_phy_io_ops *ops, |
| 57 | unsigned int flags); | 57 | unsigned int flags); |
| 58 | |||
| 59 | struct usb_phy *devm_otg_ulpi_create(struct device *dev, | ||
| 60 | struct usb_phy_io_ops *ops, | ||
| 61 | unsigned int flags); | ||
| 58 | #else | 62 | #else |
| 59 | static inline struct usb_phy *otg_ulpi_create(struct usb_phy_io_ops *ops, | 63 | static inline struct usb_phy *otg_ulpi_create(struct usb_phy_io_ops *ops, |
| 60 | unsigned int flags) | 64 | unsigned int flags) |
| 61 | { | 65 | { |
| 62 | return NULL; | 66 | return NULL; |
| 63 | } | 67 | } |
| 68 | |||
| 69 | static inline struct usb_phy *devm_otg_ulpi_create(struct device *dev, | ||
| 70 | struct usb_phy_io_ops *ops, | ||
| 71 | unsigned int flags) | ||
| 72 | { | ||
| 73 | return NULL; | ||
| 74 | } | ||
| 64 | #endif | 75 | #endif |
| 65 | 76 | ||
| 66 | #ifdef CONFIG_USB_ULPI_VIEWPORT | 77 | #ifdef CONFIG_USB_ULPI_VIEWPORT |