Hi,

On 12/22/2016 07:47 PM, Hans de Goede wrote:
> +static int intel_cht_usb_phy_probe(struct platform_device *pdev)
> +{
> +     struct intel_cht_usb_phy *phy;
> +     struct device *dev = &pdev->dev;
> +     struct resource *res;
> +     resource_size_t size;
> +     int i, ret;
> +
> +     phy = devm_kzalloc(dev, sizeof(*phy), GFP_KERNEL);
> +     if (!phy)
> +             return -ENOMEM;
> +
> +     phy->dev = dev;
> +     phy->mode = PHY_MODE_USB_OTG;
> +     INIT_WORK(&phy->work, intel_cht_usb_phy_work);
> +     platform_set_drvdata(pdev, phy);
> +
> +     phy->id_extcon = extcon_get_extcon_dev(USB_HOST_EXTCON_DEV_NAME);
> +     if (phy->id_extcon == NULL) {
> +             dev_dbg(dev, "id_extcon is not ready, probe deferred\n");
> +             return -EPROBE_DEFER;
> +     }
> +
> +     phy->vbus_extcon = extcon_get_extcon_dev(AXP288_EXTCON_DEV_NAME);
> +     if (phy->vbus_extcon == NULL) {
> +             dev_dbg(dev, "vbus_extcon is not ready, probe deferred\n");
> +             return -EPROBE_DEFER;
> +     }
> +
> +     res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> +     size = (res->end + 1) - res->start;

"res" is used without check.

> +     phy->base = devm_ioremap_nocache(dev, res->start, size);

This resource is part of xHCI MMIO. xHCI driver has already declared
to use the whole memory space. I am afraid you are not able to do this
due to resource conflict.

Best regards,
Lu Baolu

> +     if (IS_ERR(phy->base)) {
> +             ret = PTR_ERR(phy->base);
> +             dev_err(dev, "can't iomap registers: %d\n", ret);
> +             return ret;
> +     }
> +
> +     phy->phy = devm_phy_create(dev, NULL, &intel_cht_usb_phy_ops);
> +     if (IS_ERR(phy->phy)) {
> +             ret = PTR_ERR(phy->phy);
> +             dev_err(dev, "can't create PHY: %d\n", ret);
> +             return ret;
> +     }
> +     phy_set_drvdata(phy->phy, phy);
> +
> +     /* Register for id notification */
> +     phy->id_nb.notifier_call = intel_cht_usb_phy_id_cable_evt;
> +     ret = devm_extcon_register_notifier(dev, phy->id_extcon,
> +                                         EXTCON_USB_HOST, &phy->id_nb);
> +     if (ret) {
> +             dev_err(dev, "can't register id extcon notifier: %d\n", ret);
> +             return ret;
> +     }
> +
> +     /* Register for vbus notification */
> +     phy->vbus_nb[0].notifier_call = intel_cht_usb_phy_vbus_cable0_evt;
> +     phy->vbus_nb[1].notifier_call = intel_cht_usb_phy_vbus_cable1_evt;
> +     phy->vbus_nb[2].notifier_call = intel_cht_usb_phy_vbus_cable2_evt;
> +     for (i = 0; i < ARRAY_SIZE(vbus_cable_ids); i++) {
> +             ret = devm_extcon_register_notifier(dev, phy->vbus_extcon,
> +                                     vbus_cable_ids[i], &phy->vbus_nb[i]);
> +             if (ret) {
> +                     dev_err(dev, "can't register extcon notifier for %u: 
> %d\n",
> +                             vbus_cable_ids[i], ret);
> +                     return ret;
> +             }
> +     }
> +
> +     /* Get and process initial cable states */
> +     schedule_work(&phy->work);
> +
> +     device_create_file(dev, &dev_attr_mode);
> +
> +     return phy_create_lookup(phy->phy, "dwc3.0", "usb3-phy");
> +}

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to