History

usb: ulpi: Add resource-managed variant of otg_ulpi_create()

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.

Dmitry Osipenko committed 6 years ago

Commit dea75ee1 parent 9df3adc2 files · +50 −9Browse files

Unified · Split

2 files
  1. drivers/usb/phy/phy-ulpi.c +39 −9
  2. include/linux/usb/ulpi.h +11 −0
drivers/usb/phy/phy-ulpi.c+39−9
@@ -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
243static 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
243struct usb_phy *258struct usb_phy *
244otg_ulpi_create(struct usb_phy_io_ops *ops,259otg_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}
272EXPORT_SYMBOL_GPL(otg_ulpi_create);279EXPORT_SYMBOL_GPL(otg_ulpi_create);
273 280
281struct usb_phy *
282devm_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}
303EXPORT_SYMBOL_GPL(devm_otg_ulpi_create);
include/linux/usb/ulpi.h+11−0
@@ -55,12 +55,23 @@ · 54 unmodified lines
55#if IS_ENABLED(CONFIG_USB_ULPI)55#if IS_ENABLED(CONFIG_USB_ULPI)
56struct usb_phy *otg_ulpi_create(struct usb_phy_io_ops *ops,56struct usb_phy *otg_ulpi_create(struct usb_phy_io_ops *ops,
57 unsigned int flags);57 unsigned int flags);
58
59struct usb_phy *devm_otg_ulpi_create(struct device *dev,
60 struct usb_phy_io_ops *ops,
61 unsigned int flags);
58#else62#else
59static inline struct usb_phy *otg_ulpi_create(struct usb_phy_io_ops *ops,63static 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
69static 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#endif75#endif
65 76
66#ifdef CONFIG_USB_ULPI_VIEWPORT77#ifdef CONFIG_USB_ULPI_VIEWPORT