| .. | .. |
|---|
| 240 | 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 | 258 | struct usb_phy * |
|---|
| 244 | 259 | otg_ulpi_create(struct usb_phy_io_ops *ops, |
|---|
| 245 | 260 | unsigned int flags) |
|---|
| .. | .. |
|---|
| 257 | 272 | return NULL; |
|---|
| 258 | 273 | } |
|---|
| 259 | 274 | |
|---|
| 260 | | - phy->label = "ULPI"; |
|---|
| 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; |
|---|
| 275 | + otg_ulpi_init(phy, otg, ops, flags); |
|---|
| 269 | 276 | |
|---|
| 270 | 277 | return phy; |
|---|
| 271 | 278 | } |
|---|
| 272 | 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); |
|---|