USB fixes for 4.4-rc6

Here are some USB and PHY fixes for 4.4-rc6.  All of them resolve some
 reported problems.  Full details in the shortlog.
 
 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2
 
 iEYEABECAAYFAlZ1+CoACgkQMUfUDdst+yksSQCg1MuW8nVyz7eUHcZnd/r4dSPa
 fy8An0J0aKi8IhUMSIAIFcoM4/40ulCE
 =ycut
 -----END PGP SIGNATURE-----

Merge tag 'usb-4.4-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb

Pull USB fixes from Greg KH:
 "Here are some USB and PHY fixes for 4.4-rc6.  All of them resolve some
  reported problems.  Full details in the shortlog"

* tag 'usb-4.4-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb:
  USB: fix invalid memory access in hub_activate()
  USB: ipaq.c: fix a timeout loop
  phy: core: Get a refcount to phy in devm_of_phy_get_by_index()
  phy: cygnus: pcie: add missing of_node_put
  phy: miphy365x: add missing of_node_put
  phy: miphy28lp: add missing of_node_put
  phy: rockchip-usb: add missing of_node_put
  phy: berlin-sata: add missing of_node_put
  phy: mt65xx-usb3: add missing of_node_put
  phy: brcmstb-sata: add missing of_node_put
  phy: sun9i-usb: add USB dependency
This commit is contained in:
Linus Torvalds 2015-12-19 17:33:58 -08:00
commit 24b0d5e738
11 changed files with 122 additions and 47 deletions

View File

@ -233,6 +233,7 @@ config PHY_SUN9I_USB
tristate "Allwinner sun9i SoC USB PHY driver" tristate "Allwinner sun9i SoC USB PHY driver"
depends on ARCH_SUNXI && HAS_IOMEM && OF depends on ARCH_SUNXI && HAS_IOMEM && OF
depends on RESET_CONTROLLER depends on RESET_CONTROLLER
depends on USB_COMMON
select GENERIC_PHY select GENERIC_PHY
help help
Enable this to support the transceiver that is part of Allwinner Enable this to support the transceiver that is part of Allwinner

View File

@ -128,6 +128,7 @@ static int cygnus_pcie_phy_probe(struct platform_device *pdev)
struct phy_provider *provider; struct phy_provider *provider;
struct resource *res; struct resource *res;
unsigned cnt = 0; unsigned cnt = 0;
int ret;
if (of_get_child_count(node) == 0) { if (of_get_child_count(node) == 0) {
dev_err(dev, "PHY no child node\n"); dev_err(dev, "PHY no child node\n");
@ -154,24 +155,28 @@ static int cygnus_pcie_phy_probe(struct platform_device *pdev)
if (of_property_read_u32(child, "reg", &id)) { if (of_property_read_u32(child, "reg", &id)) {
dev_err(dev, "missing reg property for %s\n", dev_err(dev, "missing reg property for %s\n",
child->name); child->name);
return -EINVAL; ret = -EINVAL;
goto put_child;
} }
if (id >= MAX_NUM_PHYS) { if (id >= MAX_NUM_PHYS) {
dev_err(dev, "invalid PHY id: %u\n", id); dev_err(dev, "invalid PHY id: %u\n", id);
return -EINVAL; ret = -EINVAL;
goto put_child;
} }
if (core->phys[id].phy) { if (core->phys[id].phy) {
dev_err(dev, "duplicated PHY id: %u\n", id); dev_err(dev, "duplicated PHY id: %u\n", id);
return -EINVAL; ret = -EINVAL;
goto put_child;
} }
p = &core->phys[id]; p = &core->phys[id];
p->phy = devm_phy_create(dev, child, &cygnus_pcie_phy_ops); p->phy = devm_phy_create(dev, child, &cygnus_pcie_phy_ops);
if (IS_ERR(p->phy)) { if (IS_ERR(p->phy)) {
dev_err(dev, "failed to create PHY\n"); dev_err(dev, "failed to create PHY\n");
return PTR_ERR(p->phy); ret = PTR_ERR(p->phy);
goto put_child;
} }
p->core = core; p->core = core;
@ -191,6 +196,9 @@ static int cygnus_pcie_phy_probe(struct platform_device *pdev)
dev_dbg(dev, "registered %u PCIe PHY(s)\n", cnt); dev_dbg(dev, "registered %u PCIe PHY(s)\n", cnt);
return 0; return 0;
put_child:
of_node_put(child);
return ret;
} }
static const struct of_device_id cygnus_pcie_phy_match_table[] = { static const struct of_device_id cygnus_pcie_phy_match_table[] = {

View File

@ -195,7 +195,7 @@ static int phy_berlin_sata_probe(struct platform_device *pdev)
struct phy_provider *phy_provider; struct phy_provider *phy_provider;
struct phy_berlin_priv *priv; struct phy_berlin_priv *priv;
struct resource *res; struct resource *res;
int i = 0; int ret, i = 0;
u32 phy_id; u32 phy_id;
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
@ -237,22 +237,27 @@ static int phy_berlin_sata_probe(struct platform_device *pdev)
if (of_property_read_u32(child, "reg", &phy_id)) { if (of_property_read_u32(child, "reg", &phy_id)) {
dev_err(dev, "missing reg property in node %s\n", dev_err(dev, "missing reg property in node %s\n",
child->name); child->name);
return -EINVAL; ret = -EINVAL;
goto put_child;
} }
if (phy_id >= ARRAY_SIZE(phy_berlin_power_down_bits)) { if (phy_id >= ARRAY_SIZE(phy_berlin_power_down_bits)) {
dev_err(dev, "invalid reg in node %s\n", child->name); dev_err(dev, "invalid reg in node %s\n", child->name);
return -EINVAL; ret = -EINVAL;
goto put_child;
} }
phy_desc = devm_kzalloc(dev, sizeof(*phy_desc), GFP_KERNEL); phy_desc = devm_kzalloc(dev, sizeof(*phy_desc), GFP_KERNEL);
if (!phy_desc) if (!phy_desc) {
return -ENOMEM; ret = -ENOMEM;
goto put_child;
}
phy = devm_phy_create(dev, NULL, &phy_berlin_sata_ops); phy = devm_phy_create(dev, NULL, &phy_berlin_sata_ops);
if (IS_ERR(phy)) { if (IS_ERR(phy)) {
dev_err(dev, "failed to create PHY %d\n", phy_id); dev_err(dev, "failed to create PHY %d\n", phy_id);
return PTR_ERR(phy); ret = PTR_ERR(phy);
goto put_child;
} }
phy_desc->phy = phy; phy_desc->phy = phy;
@ -269,6 +274,9 @@ static int phy_berlin_sata_probe(struct platform_device *pdev)
phy_provider = phy_provider =
devm_of_phy_provider_register(dev, phy_berlin_sata_phy_xlate); devm_of_phy_provider_register(dev, phy_berlin_sata_phy_xlate);
return PTR_ERR_OR_ZERO(phy_provider); return PTR_ERR_OR_ZERO(phy_provider);
put_child:
of_node_put(child);
return ret;
} }
static const struct of_device_id phy_berlin_sata_of_match[] = { static const struct of_device_id phy_berlin_sata_of_match[] = {

View File

@ -140,7 +140,7 @@ static int brcm_sata_phy_probe(struct platform_device *pdev)
struct brcm_sata_phy *priv; struct brcm_sata_phy *priv;
struct resource *res; struct resource *res;
struct phy_provider *provider; struct phy_provider *provider;
int count = 0; int ret, count = 0;
if (of_get_child_count(dn) == 0) if (of_get_child_count(dn) == 0)
return -ENODEV; return -ENODEV;
@ -163,16 +163,19 @@ static int brcm_sata_phy_probe(struct platform_device *pdev)
if (of_property_read_u32(child, "reg", &id)) { if (of_property_read_u32(child, "reg", &id)) {
dev_err(dev, "missing reg property in node %s\n", dev_err(dev, "missing reg property in node %s\n",
child->name); child->name);
return -EINVAL; ret = -EINVAL;
goto put_child;
} }
if (id >= MAX_PORTS) { if (id >= MAX_PORTS) {
dev_err(dev, "invalid reg: %u\n", id); dev_err(dev, "invalid reg: %u\n", id);
return -EINVAL; ret = -EINVAL;
goto put_child;
} }
if (priv->phys[id].phy) { if (priv->phys[id].phy) {
dev_err(dev, "already registered port %u\n", id); dev_err(dev, "already registered port %u\n", id);
return -EINVAL; ret = -EINVAL;
goto put_child;
} }
port = &priv->phys[id]; port = &priv->phys[id];
@ -182,7 +185,8 @@ static int brcm_sata_phy_probe(struct platform_device *pdev)
port->ssc_en = of_property_read_bool(child, "brcm,enable-ssc"); port->ssc_en = of_property_read_bool(child, "brcm,enable-ssc");
if (IS_ERR(port->phy)) { if (IS_ERR(port->phy)) {
dev_err(dev, "failed to create PHY\n"); dev_err(dev, "failed to create PHY\n");
return PTR_ERR(port->phy); ret = PTR_ERR(port->phy);
goto put_child;
} }
phy_set_drvdata(port->phy, port); phy_set_drvdata(port->phy, port);
@ -198,6 +202,9 @@ static int brcm_sata_phy_probe(struct platform_device *pdev)
dev_info(dev, "registered %d port(s)\n", count); dev_info(dev, "registered %d port(s)\n", count);
return 0; return 0;
put_child:
of_node_put(child);
return ret;
} }
static struct platform_driver brcm_sata_phy_driver = { static struct platform_driver brcm_sata_phy_driver = {

View File

@ -636,8 +636,9 @@ EXPORT_SYMBOL_GPL(devm_of_phy_get);
* @np: node containing the phy * @np: node containing the phy
* @index: index of the phy * @index: index of the phy
* *
* Gets the phy using _of_phy_get(), and associates a device with it using * Gets the phy using _of_phy_get(), then gets a refcount to it,
* devres. On driver detach, release function is invoked on the devres data, * and associates a device with it using devres. On driver detach,
* release function is invoked on the devres data,
* then, devres data is freed. * then, devres data is freed.
* *
*/ */
@ -651,13 +652,21 @@ struct phy *devm_of_phy_get_by_index(struct device *dev, struct device_node *np,
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
phy = _of_phy_get(np, index); phy = _of_phy_get(np, index);
if (!IS_ERR(phy)) { if (IS_ERR(phy)) {
*ptr = phy;
devres_add(dev, ptr);
} else {
devres_free(ptr); devres_free(ptr);
return phy;
} }
if (!try_module_get(phy->ops->owner)) {
devres_free(ptr);
return ERR_PTR(-EPROBE_DEFER);
}
get_device(&phy->dev);
*ptr = phy;
devres_add(dev, ptr);
return phy; return phy;
} }
EXPORT_SYMBOL_GPL(devm_of_phy_get_by_index); EXPORT_SYMBOL_GPL(devm_of_phy_get_by_index);

View File

@ -1226,15 +1226,18 @@ static int miphy28lp_probe(struct platform_device *pdev)
miphy_phy = devm_kzalloc(&pdev->dev, sizeof(*miphy_phy), miphy_phy = devm_kzalloc(&pdev->dev, sizeof(*miphy_phy),
GFP_KERNEL); GFP_KERNEL);
if (!miphy_phy) if (!miphy_phy) {
return -ENOMEM; ret = -ENOMEM;
goto put_child;
}
miphy_dev->phys[port] = miphy_phy; miphy_dev->phys[port] = miphy_phy;
phy = devm_phy_create(&pdev->dev, child, &miphy28lp_ops); phy = devm_phy_create(&pdev->dev, child, &miphy28lp_ops);
if (IS_ERR(phy)) { if (IS_ERR(phy)) {
dev_err(&pdev->dev, "failed to create PHY\n"); dev_err(&pdev->dev, "failed to create PHY\n");
return PTR_ERR(phy); ret = PTR_ERR(phy);
goto put_child;
} }
miphy_dev->phys[port]->phy = phy; miphy_dev->phys[port]->phy = phy;
@ -1242,11 +1245,11 @@ static int miphy28lp_probe(struct platform_device *pdev)
ret = miphy28lp_of_probe(child, miphy_phy); ret = miphy28lp_of_probe(child, miphy_phy);
if (ret) if (ret)
return ret; goto put_child;
ret = miphy28lp_probe_resets(child, miphy_dev->phys[port]); ret = miphy28lp_probe_resets(child, miphy_dev->phys[port]);
if (ret) if (ret)
return ret; goto put_child;
phy_set_drvdata(phy, miphy_dev->phys[port]); phy_set_drvdata(phy, miphy_dev->phys[port]);
port++; port++;
@ -1255,6 +1258,9 @@ static int miphy28lp_probe(struct platform_device *pdev)
provider = devm_of_phy_provider_register(&pdev->dev, miphy28lp_xlate); provider = devm_of_phy_provider_register(&pdev->dev, miphy28lp_xlate);
return PTR_ERR_OR_ZERO(provider); return PTR_ERR_OR_ZERO(provider);
put_child:
of_node_put(child);
return ret;
} }
static const struct of_device_id miphy28lp_of_match[] = { static const struct of_device_id miphy28lp_of_match[] = {

View File

@ -566,22 +566,25 @@ static int miphy365x_probe(struct platform_device *pdev)
miphy_phy = devm_kzalloc(&pdev->dev, sizeof(*miphy_phy), miphy_phy = devm_kzalloc(&pdev->dev, sizeof(*miphy_phy),
GFP_KERNEL); GFP_KERNEL);
if (!miphy_phy) if (!miphy_phy) {
return -ENOMEM; ret = -ENOMEM;
goto put_child;
}
miphy_dev->phys[port] = miphy_phy; miphy_dev->phys[port] = miphy_phy;
phy = devm_phy_create(&pdev->dev, child, &miphy365x_ops); phy = devm_phy_create(&pdev->dev, child, &miphy365x_ops);
if (IS_ERR(phy)) { if (IS_ERR(phy)) {
dev_err(&pdev->dev, "failed to create PHY\n"); dev_err(&pdev->dev, "failed to create PHY\n");
return PTR_ERR(phy); ret = PTR_ERR(phy);
goto put_child;
} }
miphy_dev->phys[port]->phy = phy; miphy_dev->phys[port]->phy = phy;
ret = miphy365x_of_probe(child, miphy_phy); ret = miphy365x_of_probe(child, miphy_phy);
if (ret) if (ret)
return ret; goto put_child;
phy_set_drvdata(phy, miphy_dev->phys[port]); phy_set_drvdata(phy, miphy_dev->phys[port]);
@ -591,12 +594,15 @@ static int miphy365x_probe(struct platform_device *pdev)
&miphy_phy->ctrlreg); &miphy_phy->ctrlreg);
if (ret) { if (ret) {
dev_err(&pdev->dev, "No sysconfig offset found\n"); dev_err(&pdev->dev, "No sysconfig offset found\n");
return ret; goto put_child;
} }
} }
provider = devm_of_phy_provider_register(&pdev->dev, miphy365x_xlate); provider = devm_of_phy_provider_register(&pdev->dev, miphy365x_xlate);
return PTR_ERR_OR_ZERO(provider); return PTR_ERR_OR_ZERO(provider);
put_child:
of_node_put(child);
return ret;
} }
static const struct of_device_id miphy365x_of_match[] = { static const struct of_device_id miphy365x_of_match[] = {

View File

@ -415,7 +415,7 @@ static int mt65xx_u3phy_probe(struct platform_device *pdev)
struct resource *sif_res; struct resource *sif_res;
struct mt65xx_u3phy *u3phy; struct mt65xx_u3phy *u3phy;
struct resource res; struct resource res;
int port; int port, retval;
u3phy = devm_kzalloc(dev, sizeof(*u3phy), GFP_KERNEL); u3phy = devm_kzalloc(dev, sizeof(*u3phy), GFP_KERNEL);
if (!u3phy) if (!u3phy)
@ -447,31 +447,34 @@ static int mt65xx_u3phy_probe(struct platform_device *pdev)
for_each_child_of_node(np, child_np) { for_each_child_of_node(np, child_np) {
struct mt65xx_phy_instance *instance; struct mt65xx_phy_instance *instance;
struct phy *phy; struct phy *phy;
int retval;
instance = devm_kzalloc(dev, sizeof(*instance), GFP_KERNEL); instance = devm_kzalloc(dev, sizeof(*instance), GFP_KERNEL);
if (!instance) if (!instance) {
return -ENOMEM; retval = -ENOMEM;
goto put_child;
}
u3phy->phys[port] = instance; u3phy->phys[port] = instance;
phy = devm_phy_create(dev, child_np, &mt65xx_u3phy_ops); phy = devm_phy_create(dev, child_np, &mt65xx_u3phy_ops);
if (IS_ERR(phy)) { if (IS_ERR(phy)) {
dev_err(dev, "failed to create phy\n"); dev_err(dev, "failed to create phy\n");
return PTR_ERR(phy); retval = PTR_ERR(phy);
goto put_child;
} }
retval = of_address_to_resource(child_np, 0, &res); retval = of_address_to_resource(child_np, 0, &res);
if (retval) { if (retval) {
dev_err(dev, "failed to get address resource(id-%d)\n", dev_err(dev, "failed to get address resource(id-%d)\n",
port); port);
return retval; goto put_child;
} }
instance->port_base = devm_ioremap_resource(&phy->dev, &res); instance->port_base = devm_ioremap_resource(&phy->dev, &res);
if (IS_ERR(instance->port_base)) { if (IS_ERR(instance->port_base)) {
dev_err(dev, "failed to remap phy regs\n"); dev_err(dev, "failed to remap phy regs\n");
return PTR_ERR(instance->port_base); retval = PTR_ERR(instance->port_base);
goto put_child;
} }
instance->phy = phy; instance->phy = phy;
@ -483,6 +486,9 @@ static int mt65xx_u3phy_probe(struct platform_device *pdev)
provider = devm_of_phy_provider_register(dev, mt65xx_phy_xlate); provider = devm_of_phy_provider_register(dev, mt65xx_phy_xlate);
return PTR_ERR_OR_ZERO(provider); return PTR_ERR_OR_ZERO(provider);
put_child:
of_node_put(child_np);
return retval;
} }
static const struct of_device_id mt65xx_u3phy_id_table[] = { static const struct of_device_id mt65xx_u3phy_id_table[] = {

View File

@ -108,13 +108,16 @@ static int rockchip_usb_phy_probe(struct platform_device *pdev)
for_each_available_child_of_node(dev->of_node, child) { for_each_available_child_of_node(dev->of_node, child) {
rk_phy = devm_kzalloc(dev, sizeof(*rk_phy), GFP_KERNEL); rk_phy = devm_kzalloc(dev, sizeof(*rk_phy), GFP_KERNEL);
if (!rk_phy) if (!rk_phy) {
return -ENOMEM; err = -ENOMEM;
goto put_child;
}
if (of_property_read_u32(child, "reg", &reg_offset)) { if (of_property_read_u32(child, "reg", &reg_offset)) {
dev_err(dev, "missing reg property in node %s\n", dev_err(dev, "missing reg property in node %s\n",
child->name); child->name);
return -EINVAL; err = -EINVAL;
goto put_child;
} }
rk_phy->reg_offset = reg_offset; rk_phy->reg_offset = reg_offset;
@ -127,18 +130,22 @@ static int rockchip_usb_phy_probe(struct platform_device *pdev)
rk_phy->phy = devm_phy_create(dev, child, &ops); rk_phy->phy = devm_phy_create(dev, child, &ops);
if (IS_ERR(rk_phy->phy)) { if (IS_ERR(rk_phy->phy)) {
dev_err(dev, "failed to create PHY\n"); dev_err(dev, "failed to create PHY\n");
return PTR_ERR(rk_phy->phy); err = PTR_ERR(rk_phy->phy);
goto put_child;
} }
phy_set_drvdata(rk_phy->phy, rk_phy); phy_set_drvdata(rk_phy->phy, rk_phy);
/* only power up usb phy when it use, so disable it when init*/ /* only power up usb phy when it use, so disable it when init*/
err = rockchip_usb_phy_power(rk_phy, 1); err = rockchip_usb_phy_power(rk_phy, 1);
if (err) if (err)
return err; goto put_child;
} }
phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate); phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
return PTR_ERR_OR_ZERO(phy_provider); return PTR_ERR_OR_ZERO(phy_provider);
put_child:
of_node_put(child);
return err;
} }
static const struct of_device_id rockchip_usb_phy_dt_ids[] = { static const struct of_device_id rockchip_usb_phy_dt_ids[] = {

View File

@ -1035,10 +1035,20 @@ static void hub_activate(struct usb_hub *hub, enum hub_activation_type type)
unsigned delay; unsigned delay;
/* Continue a partial initialization */ /* Continue a partial initialization */
if (type == HUB_INIT2) if (type == HUB_INIT2 || type == HUB_INIT3) {
goto init2; device_lock(hub->intfdev);
if (type == HUB_INIT3)
/* Was the hub disconnected while we were waiting? */
if (hub->disconnected) {
device_unlock(hub->intfdev);
kref_put(&hub->kref, hub_release);
return;
}
if (type == HUB_INIT2)
goto init2;
goto init3; goto init3;
}
kref_get(&hub->kref);
/* The superspeed hub except for root hub has to use Hub Depth /* The superspeed hub except for root hub has to use Hub Depth
* value as an offset into the route string to locate the bits * value as an offset into the route string to locate the bits
@ -1236,6 +1246,7 @@ static void hub_activate(struct usb_hub *hub, enum hub_activation_type type)
queue_delayed_work(system_power_efficient_wq, queue_delayed_work(system_power_efficient_wq,
&hub->init_work, &hub->init_work,
msecs_to_jiffies(delay)); msecs_to_jiffies(delay));
device_unlock(hub->intfdev);
return; /* Continues at init3: below */ return; /* Continues at init3: below */
} else { } else {
msleep(delay); msleep(delay);
@ -1257,6 +1268,11 @@ static void hub_activate(struct usb_hub *hub, enum hub_activation_type type)
/* Allow autosuspend if it was suppressed */ /* Allow autosuspend if it was suppressed */
if (type <= HUB_INIT3) if (type <= HUB_INIT3)
usb_autopm_put_interface_async(to_usb_interface(hub->intfdev)); usb_autopm_put_interface_async(to_usb_interface(hub->intfdev));
if (type == HUB_INIT2 || type == HUB_INIT3)
device_unlock(hub->intfdev);
kref_put(&hub->kref, hub_release);
} }
/* Implement the continuations for the delays above */ /* Implement the continuations for the delays above */

View File

@ -531,7 +531,8 @@ static int ipaq_open(struct tty_struct *tty,
* through. Since this has a reasonably high failure rate, we retry * through. Since this has a reasonably high failure rate, we retry
* several times. * several times.
*/ */
while (retries--) { while (retries) {
retries--;
result = usb_control_msg(serial->dev, result = usb_control_msg(serial->dev,
usb_sndctrlpipe(serial->dev, 0), 0x22, 0x21, usb_sndctrlpipe(serial->dev, 0), 0x22, 0x21,
0x1, 0, NULL, 0, 100); 0x1, 0, NULL, 0, 100);