[PATCH] usb: host: Remove the deprecated ATH79 USB host config options
The options USB_EHCI_ATH79 and USB_OHCI_ATH79 only enable the generic EHCI and OHCI platform drivers, and have been marked as deprecated since 2012. These can be safely removed if we make sure that USB_EHCI_ROOT_HUB_TT still get enabled for the EHCI driver. This is now done be selecting this option when the EHCI platform driver is enabled on the ATH79 platform. Signed-off-by: Alban Bedel <al...@free.fr> --- arch/mips/Kconfig| 1 + drivers/usb/host/Kconfig | 25 - 2 files changed, 1 insertion(+), 25 deletions(-) diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index 8128c3b..61e9a24 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -200,6 +200,7 @@ config ATH79 select SYS_SUPPORTS_MIPS16 select SYS_SUPPORTS_ZBOOT_UART_PROM select USE_OF + select USB_EHCI_ROOT_HUB_TT if USB_EHCI_HCD_PLATFORM help Support for the Atheros AR71XX/AR724X/AR913X SoCs. diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig index 4fcfb30..55b45dc 100644 --- a/drivers/usb/host/Kconfig +++ b/drivers/usb/host/Kconfig @@ -293,19 +293,6 @@ config USB_CNS3XXX_EHCI It is needed for high-speed (480Mbit/sec) USB 2.0 device support. -config USB_EHCI_ATH79 - bool "EHCI support for AR7XXX/AR9XXX SoCs (DEPRECATED)" - depends on (SOC_AR71XX || SOC_AR724X || SOC_AR913X || SOC_AR933X) - select USB_EHCI_ROOT_HUB_TT - select USB_EHCI_HCD_PLATFORM - default y - ---help--- - This option is deprecated now and the driver was removed, use - USB_EHCI_HCD_PLATFORM instead. - - Enables support for the built-in EHCI controller present - on the Atheros AR7XXX/AR9XXX SoCs. - config USB_EHCI_HCD_PLATFORM tristate "Generic EHCI driver for a platform device" default n @@ -489,18 +476,6 @@ config USB_OHCI_HCD_DAVINCI controller. This driver cannot currently be a loadable module because it lacks a proper PHY abstraction. -config USB_OHCI_ATH79 - bool "USB OHCI support for the Atheros AR71XX/AR7240 SoCs (DEPRECATED)" - depends on (SOC_AR71XX || SOC_AR724X) - select USB_OHCI_HCD_PLATFORM - default y - help - This option is deprecated now and the driver was removed, use - USB_OHCI_HCD_PLATFORM instead. - - Enables support for the built-in OHCI controller present on the - Atheros AR71XX/AR7240 SoCs. - config USB_OHCI_HCD_PPC_OF_BE bool "OHCI support for OF platform bus (big endian)" depends on PPC -- 2.7.4 -- 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
Re: [PATCH] usbnet: ax88179_178a: Add support for writing the EEPROM
On Thu, 25 Aug 2016 11:16:36 +0200 Oliver Neukum <oneu...@suse.com> wrote: > On Wed, 2016-08-24 at 16:40 +0200, Alban Bedel wrote: > > On Wed, 24 Aug 2016 16:30:39 +0200 > > Oliver Neukum <oneu...@suse.com> wrote: > > > > > On Wed, 2016-08-24 at 15:52 +0200, Alban Bedel wrote: > > > > > + if (block != data) > > > > + kfree(block); > > > > > > And if block == dta, what frees the memory? > > > > In this case this function didn't allocate any memory, so there is > > nothing to free. > > Hi, > > I see. kfree() has a check for NULL, so you could drop the > test, but it doesn't matter much either way. I think you misunderstand something here. data is the buffer passed by the caller and block is a local variable. There is two cases: 1) The data to write is block aligned, then we use the caller buffer as is and set block = data. 2) The requested data is not block aligned, then we kalloc block. In both case the writing loop then use the block pointer. Afterwards we only need to kfree block in case 2, that is when block != data. Alban pgpr98qNZVlpv.pgp Description: OpenPGP digital signature
Re: [PATCH] usbnet: ax88179_178a: Add support for writing the EEPROM
On Wed, 24 Aug 2016 16:30:39 +0200 Oliver Neukum <oneu...@suse.com> wrote: > On Wed, 2016-08-24 at 15:52 +0200, Alban Bedel wrote: > > Implement the .set_eeprom callback to allow setting the MAC address > > as well as a few other parameters. Note that the EEPROM must have a > > correct PID/VID checksum set otherwise the SROM is used and reads > > return the SROM content. > > > > Signed-off-by: Alban Bedel <alban.be...@avionic-design.de> > > --- > > drivers/net/usb/ax88179_178a.c | 57 > > ++ > > 1 file changed, 57 insertions(+) > > > > diff --git a/drivers/net/usb/ax88179_178a.c > > b/drivers/net/usb/ax88179_178a.c > > index e6338c16081a..e6a986303dad 100644 > > --- a/drivers/net/usb/ax88179_178a.c > > +++ b/drivers/net/usb/ax88179_178a.c > > @@ -28,6 +28,7 @@ > > > > #define AX88179_PHY_ID 0x03 > > #define AX_EEPROM_LEN 0x100 > > +#define AX_EEPROM_BLOCK0x40u > > #define AX88179_EEPROM_MAGIC 0x17900b95 > > #define AX_MCAST_FLTSIZE 8 > > #define AX_MAX_MCAST 64 > > @@ -43,6 +44,7 @@ > > #define AX_ACCESS_PHY 0x02 > > #define AX_ACCESS_EEPROM 0x04 > > #define AX_ACCESS_EFUS 0x05 > > +#define AX_RELOAD_EEPROM 0x06 > > #define AX_PAUSE_WATERLVL_HIGH 0x54 > > #define AX_PAUSE_WATERLVL_LOW 0x55 > > > > @@ -620,6 +622,60 @@ ax88179_get_eeprom(struct net_device *net, struct > > ethtool_eeprom *eeprom, > > return 0; > > } > > > > +static int > > +ax88179_set_eeprom(struct net_device *net, struct ethtool_eeprom > > *eeprom, > > + u8 *data) > > +{ > > + struct usbnet *dev = netdev_priv(net); > > + unsigned int offset = eeprom->offset; > > + unsigned int len = eeprom->len; > > + int i, err = 0; > > + u8 *block; > > + > > + /* The EEPROM data must be aligned on blocks of 64 bytes */ > > + if ((offset % AX_EEPROM_BLOCK) || (len % AX_EEPROM_BLOCK)) { > > + offset = eeprom->offset / AX_EEPROM_BLOCK * > > AX_EEPROM_BLOCK; > > + len = eeprom->len + eeprom->offset - offset; > > + len = DIV_ROUND_UP(len, AX_EEPROM_BLOCK) * > > AX_EEPROM_BLOCK; > > + > > + block = kmalloc(len, GFP_KERNEL); > > + if (!block) > > + return -ENOMEM; > > + > > + /* Copy the current data, we could skip some but KISS > > */ > > + for (i = 0; i < len; i += AX_EEPROM_BLOCK) { > > + err = __ax88179_read_cmd(dev, > > AX_ACCESS_EEPROM, > > +(offset + i) >> 1, > > +AX_EEPROM_BLOCK >> 1, > > +AX_EEPROM_BLOCK, > > +[i], 0); > > + if (err < 0) { > > + kfree(block); > > + return err; > > + } > > + } > > + memcpy(block + eeprom->offset - offset, data, > > eeprom->len); > > + } else { > > + block = data; > > + } > > + > > + for (i = 0; err >= 0 && i < len; i += AX_EEPROM_BLOCK) { > > + err = ax88179_write_cmd(dev, AX_ACCESS_EEPROM, > > + (offset + i) >> 1, > > + AX_EEPROM_BLOCK >> 1, > > + AX_EEPROM_BLOCK, [i]); > > + } > > + > > + if (block != data) > > + kfree(block); > > And if block == dta, what frees the memory? In this case this function didn't allocate any memory, so there is nothing to free. Alban pgpI1v3WKESy_.pgp Description: OpenPGP digital signature
[PATCH] usbnet: ax88179_178a: Add support for writing the EEPROM
Implement the .set_eeprom callback to allow setting the MAC address as well as a few other parameters. Note that the EEPROM must have a correct PID/VID checksum set otherwise the SROM is used and reads return the SROM content. Signed-off-by: Alban Bedel <alban.be...@avionic-design.de> --- drivers/net/usb/ax88179_178a.c | 57 ++ 1 file changed, 57 insertions(+) diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c index e6338c16081a..e6a986303dad 100644 --- a/drivers/net/usb/ax88179_178a.c +++ b/drivers/net/usb/ax88179_178a.c @@ -28,6 +28,7 @@ #define AX88179_PHY_ID 0x03 #define AX_EEPROM_LEN 0x100 +#define AX_EEPROM_BLOCK0x40u #define AX88179_EEPROM_MAGIC 0x17900b95 #define AX_MCAST_FLTSIZE 8 #define AX_MAX_MCAST 64 @@ -43,6 +44,7 @@ #define AX_ACCESS_PHY 0x02 #define AX_ACCESS_EEPROM 0x04 #define AX_ACCESS_EFUS 0x05 +#define AX_RELOAD_EEPROM 0x06 #define AX_PAUSE_WATERLVL_HIGH 0x54 #define AX_PAUSE_WATERLVL_LOW 0x55 @@ -620,6 +622,60 @@ ax88179_get_eeprom(struct net_device *net, struct ethtool_eeprom *eeprom, return 0; } +static int +ax88179_set_eeprom(struct net_device *net, struct ethtool_eeprom *eeprom, + u8 *data) +{ + struct usbnet *dev = netdev_priv(net); + unsigned int offset = eeprom->offset; + unsigned int len = eeprom->len; + int i, err = 0; + u8 *block; + + /* The EEPROM data must be aligned on blocks of 64 bytes */ + if ((offset % AX_EEPROM_BLOCK) || (len % AX_EEPROM_BLOCK)) { + offset = eeprom->offset / AX_EEPROM_BLOCK * AX_EEPROM_BLOCK; + len = eeprom->len + eeprom->offset - offset; + len = DIV_ROUND_UP(len, AX_EEPROM_BLOCK) * AX_EEPROM_BLOCK; + + block = kmalloc(len, GFP_KERNEL); + if (!block) + return -ENOMEM; + + /* Copy the current data, we could skip some but KISS */ + for (i = 0; i < len; i += AX_EEPROM_BLOCK) { + err = __ax88179_read_cmd(dev, AX_ACCESS_EEPROM, +(offset + i) >> 1, +AX_EEPROM_BLOCK >> 1, +AX_EEPROM_BLOCK, +[i], 0); + if (err < 0) { + kfree(block); + return err; + } + } + memcpy(block + eeprom->offset - offset, data, eeprom->len); + } else { + block = data; + } + + for (i = 0; err >= 0 && i < len; i += AX_EEPROM_BLOCK) { + err = ax88179_write_cmd(dev, AX_ACCESS_EEPROM, + (offset + i) >> 1, + AX_EEPROM_BLOCK >> 1, + AX_EEPROM_BLOCK, [i]); + } + + if (block != data) + kfree(block); + + /* Reload the EEPROM */ + if (err >= 0) + err = ax88179_write_cmd(dev, AX_RELOAD_EEPROM, 0, 0, 0, NULL); + + return err < 0 ? err : 0; +} + static int ax88179_get_settings(struct net_device *net, struct ethtool_cmd *cmd) { struct usbnet *dev = netdev_priv(net); @@ -826,6 +882,7 @@ static const struct ethtool_ops ax88179_ethtool_ops = { .set_wol= ax88179_set_wol, .get_eeprom_len = ax88179_get_eeprom_len, .get_eeprom = ax88179_get_eeprom, + .set_eeprom = ax88179_set_eeprom, .get_settings = ax88179_get_settings, .set_settings = ax88179_set_settings, .get_eee= ax88179_get_eee, -- 2.9.3 -- 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
[PATCH v2] usb: ehci-platform: Fix using multiple controllers from OF
When using OF defined controllers the platform data struct is shared between all devices, so it can't be used for device specific settings. However it is currently used for the OF properties needs-reset-on-resume and has-transaction-translator. To fix this issue move setting hcd-has_tt to the probe and move pdata-reset_on_resume to the private data. Signed-off-by: Alban Bedel al...@free.fr --- Changelog: v2: * Use true instead of 1 to set boolean type --- drivers/usb/host/ehci-platform.c | 13 + 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/usb/host/ehci-platform.c b/drivers/usb/host/ehci-platform.c index 2593def..5c3c085 100644 --- a/drivers/usb/host/ehci-platform.c +++ b/drivers/usb/host/ehci-platform.c @@ -45,6 +45,7 @@ struct ehci_platform_priv { struct reset_control *rst; struct phy **phys; int num_phys; + bool reset_on_resume; }; static const char hcd_name[] = ehci-platform; @@ -56,7 +57,6 @@ static int ehci_platform_reset(struct usb_hcd *hcd) struct ehci_hcd *ehci = hcd_to_ehci(hcd); int retval; - hcd-has_tt = pdata-has_tt; ehci-has_synopsys_hc_bug = pdata-has_synopsys_hc_bug; if (pdata-pre_setup) { @@ -193,11 +193,11 @@ static int ehci_platform_probe(struct platform_device *dev) if (of_property_read_bool(dev-dev.of_node, needs-reset-on-resume)) - pdata-reset_on_resume = 1; + priv-reset_on_resume = true; if (of_property_read_bool(dev-dev.of_node, has-transaction-translator)) - pdata-has_tt = 1; + hcd-has_tt = 1; priv-num_phys = of_count_phandle_with_args(dev-dev.of_node, phys, #phy-cells); @@ -247,6 +247,10 @@ static int ehci_platform_probe(struct platform_device *dev) ehci-big_endian_desc = 1; if (pdata-big_endian_mmio) ehci-big_endian_mmio = 1; + if (pdata-has_tt) + hcd-has_tt = 1; + if (pdata-reset_on_resume) + priv-reset_on_resume = true; #ifndef CONFIG_USB_EHCI_BIG_ENDIAN_MMIO if (ehci-big_endian_mmio) { @@ -359,6 +363,7 @@ static int ehci_platform_resume(struct device *dev) struct usb_ehci_pdata *pdata = dev_get_platdata(dev); struct platform_device *pdev = container_of(dev, struct platform_device, dev); + struct ehci_platform_priv *priv = hcd_to_ehci_priv(hcd); if (pdata-power_on) { int err = pdata-power_on(pdev); @@ -366,7 +371,7 @@ static int ehci_platform_resume(struct device *dev) return err; } - ehci_resume(hcd, pdata-reset_on_resume); + ehci_resume(hcd, priv-reset_on_resume); return 0; } #endif /* CONFIG_PM_SLEEP */ -- 2.0.0 -- 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
[PATCH] usb: ehci-platform: Fix using multiple controllers from OF
When using OF defined controllers the platform data struct is shared between all devices, so it can't be used for device specific settings. However it is currently used for the OF properties needs-reset-on-resume and has-transaction-translator. To fix this issue move setting hcd-has_tt to the probe and move pdata-reset_on_resume to the private data. Signed-off-by: Alban Bedel al...@free.fr --- drivers/usb/host/ehci-platform.c | 13 + 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/usb/host/ehci-platform.c b/drivers/usb/host/ehci-platform.c index 2593def..40d029e 100644 --- a/drivers/usb/host/ehci-platform.c +++ b/drivers/usb/host/ehci-platform.c @@ -45,6 +45,7 @@ struct ehci_platform_priv { struct reset_control *rst; struct phy **phys; int num_phys; + bool reset_on_resume; }; static const char hcd_name[] = ehci-platform; @@ -56,7 +57,6 @@ static int ehci_platform_reset(struct usb_hcd *hcd) struct ehci_hcd *ehci = hcd_to_ehci(hcd); int retval; - hcd-has_tt = pdata-has_tt; ehci-has_synopsys_hc_bug = pdata-has_synopsys_hc_bug; if (pdata-pre_setup) { @@ -193,11 +193,11 @@ static int ehci_platform_probe(struct platform_device *dev) if (of_property_read_bool(dev-dev.of_node, needs-reset-on-resume)) - pdata-reset_on_resume = 1; + priv-reset_on_resume = 1; if (of_property_read_bool(dev-dev.of_node, has-transaction-translator)) - pdata-has_tt = 1; + hcd-has_tt = 1; priv-num_phys = of_count_phandle_with_args(dev-dev.of_node, phys, #phy-cells); @@ -247,6 +247,10 @@ static int ehci_platform_probe(struct platform_device *dev) ehci-big_endian_desc = 1; if (pdata-big_endian_mmio) ehci-big_endian_mmio = 1; + if (pdata-has_tt) + hcd-has_tt = 1; + if (pdata-reset_on_resume) + priv-reset_on_resume = true; #ifndef CONFIG_USB_EHCI_BIG_ENDIAN_MMIO if (ehci-big_endian_mmio) { @@ -359,6 +363,7 @@ static int ehci_platform_resume(struct device *dev) struct usb_ehci_pdata *pdata = dev_get_platdata(dev); struct platform_device *pdev = container_of(dev, struct platform_device, dev); + struct ehci_platform_priv *priv = hcd_to_ehci_priv(hcd); if (pdata-power_on) { int err = pdata-power_on(pdev); @@ -366,7 +371,7 @@ static int ehci_platform_resume(struct device *dev) return err; } - ehci_resume(hcd, pdata-reset_on_resume); + ehci_resume(hcd, priv-reset_on_resume); return 0; } #endif /* CONFIG_PM_SLEEP */ -- 2.0.0 -- 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