Re: [LEDE-DEV] [LEDE-DEV v3] Add support of using device symlinks.

2016-12-18 Thread Nikolay Ledovskikh
> pong ...
>
> "weekend, that thing where people rest"

OK. I'll wait for that wonderful moment

-- 
Best regards, Nikolay Ledovskikh.

___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


Re: [LEDE-DEV] [PATCH] kernel: add KERNEL_DEVMEM and KERNEL_DEVKMEM

2016-12-18 Thread John Crispin


On 17/12/2016 15:04, Hauke Mehrtens wrote:
> These options are needed to create /dev/mem or /dev/kmem .
> /dev/mem is needed by the io tool to access raw hardware memory, which
> is helpful when debugging and developing drivers.
> 
> Signed-off-by: Hauke Mehrtens 

Acked-by: John Crispin 

> ---
>  config/Config-kernel.in | 14 ++
>  1 file changed, 14 insertions(+)
> 
> diff --git a/config/Config-kernel.in b/config/Config-kernel.in
> index 3c69c86..3f30013 100644
> --- a/config/Config-kernel.in
> +++ b/config/Config-kernel.in
> @@ -745,3 +745,17 @@ menu "Filesystem ACL and attr support options"
>   default y if USE_FS_ACL_ATTR
>  
>  endmenu
> +
> +config KERNEL_DEVMEM
> + bool "/dev/mem virtual device support"
> + help
> +   Say Y here if you want to support the /dev/mem device.
> +   The /dev/mem device is used to access areas of physical
> +   memory.
> +
> +config KERNEL_DEVKMEM
> + bool "/dev/kmem virtual device support"
> + help
> +   Say Y here if you want to support the /dev/kmem device. The
> +   /dev/kmem device is rarely used, but can be used for certain
> +   kind of kernel debugging operations.
> 

___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


Re: [LEDE-DEV] [LEDE-DEV v3] Add support of using device symlinks.

2016-12-18 Thread John Crispin


On 19/12/2016 08:20, Nikolay Ledovskikh wrote:
>> It's useful when using multiple usb devices that should be bound to
>> certain usb ports. Symlinks are created by hotplug handlers.
> 
> Ping.
> 

pong ...

"weekend, that thing where people rest"

___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


Re: [LEDE-DEV] [LEDE-DEV v3] Add support of using device symlinks.

2016-12-18 Thread Nikolay Ledovskikh
> It's useful when using multiple usb devices that should be bound to
> certain usb ports. Symlinks are created by hotplug handlers.

Ping.

___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


Re: [LEDE-DEV] [PATCH] libubox: replace strtok with strsep

2016-12-18 Thread John Crispin


On 18/12/2016 17:29, Arjen de Korte wrote:
> Citeren John Crispin :
> 
>> On 16/12/2016 11:10, Felix Fietkau wrote:
>>> On 2016-12-16 10:58, John Crispin wrote:


 On 14/12/2016 06:43, Rosen Penev wrote:
> strsep is re-entrant whereas strtok not necessarily so.
>
> Signed-off by: Rosen Penev 
> ---
>  ulog.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/ulog.c b/ulog.c
> index 296605d..985d366 100644
> --- a/ulog.c
> +++ b/ulog.c
> @@ -39,8 +39,8 @@ static const char *ulog_default_ident(void)
>  if ((self = fopen("/proc/self/status", "r")) != NULL) {
>  while (fgets(line, sizeof(line), self)) {
>  if (!strncmp(line, "Name:", 5)) {
> -strtok(line, "\t\n");
> -p = strtok(NULL, "\t\n");
> +strsep(, "\t\n");
> +p = strsep(, "\t\n");

 Hi,

 i agree that using strsep() is a nice api however i fail to see why the
 original code would fail. according to the man page it is re-entrant,
 specially if called as done here. can you elaborate a bit why you think
 it is not re-entrant ?
>>> If the caller of ulog() is using strtok between ulog calls, internal use
>>> of strtok can break it. I think this change is worth merging.
>>>
>>> - Felix
>>>
>>
>> ah of course, i did not thing of the caller using it, i'll merge it in
>> that case
> 
> Bad idea. Please consider using strtok_r instead (this is a reetrant
> version of strtok) like in jshn.c. Functionally, strsep and strtok will
> behave differently if there are multiple delimiters between tokens. I
> doubt it is worth it to check if this difference in behavior is OK, if
> one can use strtok_r. So if thread safety is the only concern, replace
> strtok by strtok_r (not strsep). Also, keep in mind that the first
> argument passed to strsep is mofified, so if that happens to be a
> pointer to dynamically allocated memory and you use that pointer to free
> said memory, you'll have a memory leak.
> 
> 

even better, Rosen could you please change the patch to use strtok_r
(not strsep)

John


___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


Re: [LEDE-DEV] [PATCH v2] brcm63xx: fix internal net phy interrupt config

2016-12-18 Thread Daniel
Yes, better if I included that info. I was lazy to look for the
specific commit which caused the breakage. If Jonas makes the
upstream, it can be made there. Anyway I can resend again the patch if
needed.

Regards

2016-12-18 19:28 GMT+01:00 Florian Fainelli :
>
>
> On 12/18/2016 05:11 AM, Daniel Gonzalez Cabanelas wrote:
>> The internal phy is using wrong registers for the config interrupt function,
>> causing incorrect behavior when detecting the link activity. Fix it.
>>
>> We cannot use the bcm_phy_config_intr function from the bcm-phy-lib.c
>> because it uses different registers from brcm63xx. The old function was
>> right, so go back to it.
>>
>> It's worth mentioning that this function matches with the one used
>> by the Broadcom BCM5241 fast ethernet phy driver (brcm_fet_config_intr
>> at broadcom.c). This one uses exactly the same registers as BCM63xx.
>
> Would have been a good idea to mention that you are essentially
> reverting upstream commit a1cba5613edf ("net: phy: Add Broadcom phy
> library for common interfaces") for bcm63xx.c and this is what caused
> the breakage in the first place.
>
> Thanks
>
>>
>> ---
>> change in v2:
>>  use the original defines for focusing only on the bug
>>  modify the commit log accordingly with the new approach
>> ---
>> diff --git 
>> a/target/linux/brcm63xx/patches-4.4/409-bcm63xx_net_phy-fix-config_intr.patch
>>  
>> b/target/linux/brcm63xx/patches-4.4/409-bcm63xx_net_phy-fix-config_intr.patch
>> new file mode 100644
>> index 000..9e5a5d1
>> --- /dev/null
>> +++ 
>> b/target/linux/brcm63xx/patches-4.4/409-bcm63xx_net_phy-fix-config_intr.patch
>> @@ -0,0 +1,59 @@
>> +--- a/drivers/net/phy/bcm63xx.c
>>  b/drivers/net/phy/bcm63xx.c
>> +@@ -40,38 +40,54 @@
>> + MII_BCM63XX_IR_SPEED |
>> + MII_BCM63XX_IR_LINK) |
>> + MII_BCM63XX_IR_EN;
>> + return phy_write(phydev, MII_BCM63XX_IR, reg);
>> + }
>> +
>> ++static int bcm63xx_config_intr(struct phy_device *phydev)
>> ++{
>> ++int reg, err;
>> ++
>> ++reg = phy_read(phydev, MII_BCM63XX_IR);
>> ++if (reg < 0)
>> ++return reg;
>> ++
>> ++if (phydev->interrupts == PHY_INTERRUPT_ENABLED)
>> ++reg &= ~MII_BCM63XX_IR_GMASK;
>> ++else
>> ++reg |= MII_BCM63XX_IR_GMASK;
>> ++
>> ++return phy_write(phydev, MII_BCM63XX_IR, reg);
>> ++}
>> ++
>> + static struct phy_driver bcm63xx_driver[] = {
>> + {
>> + .phy_id = 0x00406000,
>> + .phy_id_mask= 0xfc00,
>> + .name   = "Broadcom BCM63XX (1)",
>> + /* ASYM_PAUSE bit is marked RO in datasheet, so don't cheat */
>> + .features   = (PHY_BASIC_FEATURES | SUPPORTED_Pause),
>> + .flags  = PHY_HAS_INTERRUPT | PHY_IS_INTERNAL,
>> + .config_init= bcm63xx_config_init,
>> + .config_aneg= genphy_config_aneg,
>> + .read_status= genphy_read_status,
>> + .ack_interrupt  = bcm_phy_ack_intr,
>> +-.config_intr= bcm_phy_config_intr,
>> ++.config_intr= bcm63xx_config_intr,
>> + .driver = { .owner = THIS_MODULE },
>> + }, {
>> + /* same phy as above, with just a different OUI */
>> + .phy_id = 0x002bdc00,
>> + .phy_id_mask= 0xfc00,
>> + .name   = "Broadcom BCM63XX (2)",
>> + .features   = (PHY_BASIC_FEATURES | SUPPORTED_Pause),
>> + .flags  = PHY_HAS_INTERRUPT | PHY_IS_INTERNAL,
>> + .config_init= bcm63xx_config_init,
>> + .config_aneg= genphy_config_aneg,
>> + .read_status= genphy_read_status,
>> + .ack_interrupt  = bcm_phy_ack_intr,
>> +-.config_intr= bcm_phy_config_intr,
>> ++.config_intr= bcm63xx_config_intr,
>> + .driver = { .owner = THIS_MODULE },
>> + } };
>> +
>> + module_phy_driver(bcm63xx_driver);
>> +
>> + static struct mdio_device_id __maybe_unused bcm63xx_tbl[] = {
>>
>>
>> ___
>> Lede-dev mailing list
>> Lede-dev@lists.infradead.org
>> http://lists.infradead.org/mailman/listinfo/lede-dev
>>
>
> --
> Florian



-- 
Daniel

___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


Re: [LEDE-DEV] [PATCH v2] package-ipkg: Do not fail build without base-files

2016-12-18 Thread Florian Fainelli


On 12/09/2016 04:04 PM, Florian Fainelli wrote:
> If the base-files package is not selected, we will fail executing the
> very first postinst script:
> 
> make[3]: Leaving directory `/local/users/fainelli/openwrt/trunk'
> cp -fpR
> /local/users/fainelli/openwrt/trunk/build_dir/target-arm_xscale_musl-1.1.15_eabi/root-orion
> /local/users/fainelli/openwrt/trunk/build_dir/target-arm_xscale_musl-1.1.15_eabi/root.orig-orion
> ./usr/lib/opkg/info/busybox.postinst: line 3:
> /local/users/fainelli/openwrt/trunk/build_dir/target-arm_xscale_musl-1.1.15_eabi/root-orion/lib/functions.sh:
> No such file or directory
> ./usr/lib/opkg/info/busybox.postinst: line 4: default_postinst: command
> not found
> postinst script ./usr/lib/opkg/info/busybox.postinst has failed with
> exit code 127
> make[2]: *** [package/install] Error 1
> 
> Check for the existence of lib/functions.sh, and if it does not exist,
> just bail out gracefully.
> 
> Signed-off-by: Florian Fainelli 

This was marked as accepted in patchwork, but I don't see it in either
John's staging tree or Felix's, do you need me to resubmit?

Thanks!
-- 
Florian

___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


Re: [LEDE-DEV] [PATCH v2] brcm63xx: fix internal net phy interrupt config

2016-12-18 Thread Florian Fainelli


On 12/18/2016 05:11 AM, Daniel Gonzalez Cabanelas wrote:
> The internal phy is using wrong registers for the config interrupt function,
> causing incorrect behavior when detecting the link activity. Fix it.
> 
> We cannot use the bcm_phy_config_intr function from the bcm-phy-lib.c 
> because it uses different registers from brcm63xx. The old function was
> right, so go back to it. 
> 
> It's worth mentioning that this function matches with the one used
> by the Broadcom BCM5241 fast ethernet phy driver (brcm_fet_config_intr 
> at broadcom.c). This one uses exactly the same registers as BCM63xx.

Would have been a good idea to mention that you are essentially
reverting upstream commit a1cba5613edf ("net: phy: Add Broadcom phy
library for common interfaces") for bcm63xx.c and this is what caused
the breakage in the first place.

Thanks

> 
> ---
> change in v2:
>  use the original defines for focusing only on the bug
>  modify the commit log accordingly with the new approach
> ---
> diff --git 
> a/target/linux/brcm63xx/patches-4.4/409-bcm63xx_net_phy-fix-config_intr.patch 
> b/target/linux/brcm63xx/patches-4.4/409-bcm63xx_net_phy-fix-config_intr.patch
> new file mode 100644
> index 000..9e5a5d1
> --- /dev/null
> +++ 
> b/target/linux/brcm63xx/patches-4.4/409-bcm63xx_net_phy-fix-config_intr.patch
> @@ -0,0 +1,59 @@
> +--- a/drivers/net/phy/bcm63xx.c
>  b/drivers/net/phy/bcm63xx.c
> +@@ -40,38 +40,54 @@
> + MII_BCM63XX_IR_SPEED |
> + MII_BCM63XX_IR_LINK) |
> + MII_BCM63XX_IR_EN;
> + return phy_write(phydev, MII_BCM63XX_IR, reg);
> + }
> + 
> ++static int bcm63xx_config_intr(struct phy_device *phydev)
> ++{
> ++int reg, err;
> ++
> ++reg = phy_read(phydev, MII_BCM63XX_IR);
> ++if (reg < 0)
> ++return reg;
> ++
> ++if (phydev->interrupts == PHY_INTERRUPT_ENABLED)
> ++reg &= ~MII_BCM63XX_IR_GMASK;
> ++else
> ++reg |= MII_BCM63XX_IR_GMASK;
> ++
> ++return phy_write(phydev, MII_BCM63XX_IR, reg);
> ++}
> ++
> + static struct phy_driver bcm63xx_driver[] = {
> + {
> + .phy_id = 0x00406000,
> + .phy_id_mask= 0xfc00,
> + .name   = "Broadcom BCM63XX (1)",
> + /* ASYM_PAUSE bit is marked RO in datasheet, so don't cheat */
> + .features   = (PHY_BASIC_FEATURES | SUPPORTED_Pause),
> + .flags  = PHY_HAS_INTERRUPT | PHY_IS_INTERNAL,
> + .config_init= bcm63xx_config_init,
> + .config_aneg= genphy_config_aneg,
> + .read_status= genphy_read_status,
> + .ack_interrupt  = bcm_phy_ack_intr,
> +-.config_intr= bcm_phy_config_intr,
> ++.config_intr= bcm63xx_config_intr,
> + .driver = { .owner = THIS_MODULE },
> + }, {
> + /* same phy as above, with just a different OUI */
> + .phy_id = 0x002bdc00,
> + .phy_id_mask= 0xfc00,
> + .name   = "Broadcom BCM63XX (2)",
> + .features   = (PHY_BASIC_FEATURES | SUPPORTED_Pause),
> + .flags  = PHY_HAS_INTERRUPT | PHY_IS_INTERNAL,
> + .config_init= bcm63xx_config_init,
> + .config_aneg= genphy_config_aneg,
> + .read_status= genphy_read_status,
> + .ack_interrupt  = bcm_phy_ack_intr,
> +-.config_intr= bcm_phy_config_intr,
> ++.config_intr= bcm63xx_config_intr,
> + .driver = { .owner = THIS_MODULE },
> + } };
> + 
> + module_phy_driver(bcm63xx_driver);
> + 
> + static struct mdio_device_id __maybe_unused bcm63xx_tbl[] = {
> 
> 
> ___
> Lede-dev mailing list
> Lede-dev@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/lede-dev
> 

-- 
Florian

___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


Re: [LEDE-DEV] [PATCH] ar71xx: Added support for the TP-Link WA855RE V1

2016-12-18 Thread Matthias Schiffer
On 12/18/2016 03:35 PM, Federico Cappon wrote:
> The device it's similar to the WR841N/ND v9 but without the internal switch.
> For install Lede, after soldering the serial, follow the istruction for the 
> WR841N/ND v9
> 
> Signed-off-by: Federico Cappon 
> ---
>  target/linux/ar71xx/base-files/etc/board.d/01_leds |   3 +
>  .../linux/ar71xx/base-files/etc/board.d/02_network |   1 +
>  target/linux/ar71xx/base-files/etc/diag.sh |   3 +
>  target/linux/ar71xx/base-files/lib/ar71xx.sh   |   6 ++
>  .../ar71xx/base-files/lib/upgrade/platform.sh  |   1 +
>  target/linux/ar71xx/config-4.4 |   1 +
>  .../ar71xx/files/arch/mips/ath79/Kconfig.openwrt   |   9 ++
>  target/linux/ar71xx/files/arch/mips/ath79/Makefile |   1 +
>  .../files/arch/mips/ath79/mach-tl-wa855re-v1.c | 117 
> +
>  .../linux/ar71xx/files/arch/mips/ath79/machtypes.h |   1 +
>  target/linux/ar71xx/image/tp-link.mk   |  10 ++
>  target/linux/ar71xx/mikrotik/config-default|   1 +
>  12 files changed, 154 insertions(+)
>  create mode 100644 
> target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wa855re-v1.c

Hi,
thanks for your patch. See inline comments.


> 
> diff --git a/target/linux/ar71xx/base-files/etc/board.d/01_leds 
> b/target/linux/ar71xx/base-files/etc/board.d/01_leds
> index a840e2f..f0c53c0 100755
> --- a/target/linux/ar71xx/base-files/etc/board.d/01_leds
> +++ b/target/linux/ar71xx/base-files/etc/board.d/01_leds
> @@ -624,6 +624,9 @@ tl-wr842n-v3)
>   ;;
>   esac
>   ;;
> +tl-wa855re-v1)
> + ucidef_set_led_default "power" "POWER" "tp-link:green:power" "1"
> + ;;

Don't add the LED here, you've already defined in in /etc/diag.sh.


>  tl-wr1043nd|\
>  tl-wr1043nd-v2)
>   ucidef_set_led_usbdev "usb" "USB" "tp-link:green:usb" "1-1"
> diff --git a/target/linux/ar71xx/base-files/etc/board.d/02_network 
> b/target/linux/ar71xx/base-files/etc/board.d/02_network
> index 8907605..733bc41 100755
> --- a/target/linux/ar71xx/base-files/etc/board.d/02_network
> +++ b/target/linux/ar71xx/base-files/etc/board.d/02_network
> @@ -105,6 +105,7 @@ ar71xx_setup_interfaces()
>   tl-wa801nd-v2|\
>   tl-wa830re-v2|\
>   tl-wa850re|\
> + tl-wa855re-v1|\
>   tl-wa901nd|\
>   tl-wa901nd-v2|\
>   tl-wa901nd-v3|\
> diff --git a/target/linux/ar71xx/base-files/etc/diag.sh 
> b/target/linux/ar71xx/base-files/etc/diag.sh
> index d9d8a29..7c72219 100644
> --- a/target/linux/ar71xx/base-files/etc/diag.sh
> +++ b/target/linux/ar71xx/base-files/etc/diag.sh
> @@ -444,6 +444,9 @@ get_status_led() {
>   wlr8100)
>   status_led="sitecom:amber:status"
>   ;;
> + tl-wa855re-v1)
> + status_led="tp-link:green:power"
> + ;;
>   esac
>  }
>  
> diff --git a/target/linux/ar71xx/base-files/lib/ar71xx.sh 
> b/target/linux/ar71xx/base-files/lib/ar71xx.sh
> index 2cfd017..cb6ce9d 100755
> --- a/target/linux/ar71xx/base-files/lib/ar71xx.sh
> +++ b/target/linux/ar71xx/base-files/lib/ar71xx.sh
> @@ -244,6 +244,9 @@ tplink_board_detect() {
>   "085000"*)
>   model="TP-Link TL-WA850RE"
>   ;;
> + "085501"*)
> + model="TP-Link TL-WA855RE"
> + ;;
>   "086000"*)
>   model="TP-Link TL-WA860RE"
>   ;;
> @@ -951,6 +954,9 @@ ar71xx_board_detect() {
>   *TL-WA850RE)
>   name="tl-wa850re"
>   ;;
> + *"TL-WA855RE v1")
> + name="tl-wa855re-v1"
> + ;;
>   *TL-WA860RE)
>   name="tl-wa860re"
>   ;;
> diff --git a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh 
> b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
> index 42cc1dd..74204a5 100755
> --- a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
> +++ b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
> @@ -397,6 +397,7 @@ platform_check_image() {
>   tl-wr941nd-v5|\
>   tl-wr941nd-v6|\
>   tl-wr940n-v4|\
> + tl-wa855re-v1|\
>   tl-wr941nd)
>   local magic_ver="0100"
>  
> diff --git a/target/linux/ar71xx/config-4.4 b/target/linux/ar71xx/config-4.4
> index 58d39ad..35709fd 100644
> --- a/target/linux/ar71xx/config-4.4
> +++ b/target/linux/ar71xx/config-4.4
> @@ -185,6 +185,7 @@ CONFIG_ATH79_MACH_TL_WR810N=y
>  CONFIG_ATH79_MACH_TL_WR841N_V1=y
>  CONFIG_ATH79_MACH_TL_WR841N_V8=y
>  CONFIG_ATH79_MACH_TL_WR841N_V9=y
> +CONFIG_ATH79_MACH_TL_WA855RE_V1=y
>  CONFIG_ATH79_MACH_TL_WR941ND=y
>  CONFIG_ATH79_MACH_TL_WR941ND_V6=y
>  CONFIG_ATH79_MACH_TL_WR940N_V4=y
> diff --git a/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt 
> b/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
> index 824f47f..1f3a746 100644
> --- a/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
> +++ b/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
> @@ -1472,6 +1472,15 @@ config ATH79_MACH_TL_WR841N_V9
> 

Re: [LEDE-DEV] [PATCH] libubox: replace strtok with strsep

2016-12-18 Thread Arjen de Korte

Citeren John Crispin :


On 16/12/2016 11:10, Felix Fietkau wrote:

On 2016-12-16 10:58, John Crispin wrote:



On 14/12/2016 06:43, Rosen Penev wrote:

strsep is re-entrant whereas strtok not necessarily so.

Signed-off by: Rosen Penev 
---
 ulog.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/ulog.c b/ulog.c
index 296605d..985d366 100644
--- a/ulog.c
+++ b/ulog.c
@@ -39,8 +39,8 @@ static const char *ulog_default_ident(void)
if ((self = fopen("/proc/self/status", "r")) != NULL) {
while (fgets(line, sizeof(line), self)) {
if (!strncmp(line, "Name:", 5)) {
-   strtok(line, "\t\n");
-   p = strtok(NULL, "\t\n");
+   strsep(, "\t\n");
+   p = strsep(, "\t\n");


Hi,

i agree that using strsep() is a nice api however i fail to see why the
original code would fail. according to the man page it is re-entrant,
specially if called as done here. can you elaborate a bit why you think
it is not re-entrant ?

If the caller of ulog() is using strtok between ulog calls, internal use
of strtok can break it. I think this change is worth merging.

- Felix



ah of course, i did not thing of the caller using it, i'll merge it in
that case


Bad idea. Please consider using strtok_r instead (this is a reetrant  
version of strtok) like in jshn.c. Functionally, strsep and strtok  
will behave differently if there are multiple delimiters between  
tokens. I doubt it is worth it to check if this difference in behavior  
is OK, if one can use strtok_r. So if thread safety is the only  
concern, replace strtok by strtok_r (not strsep). Also, keep in mind  
that the first argument passed to strsep is mofified, so if that  
happens to be a pointer to dynamically allocated memory and you use  
that pointer to free said memory, you'll have a memory leak.




___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


Re: [LEDE-DEV] [PATCH] ubox: Replace strtok with strsep

2016-12-18 Thread Arjen de Korte

Citeren Felix Fietkau :


On 2016-12-18 02:22, Rosen Penev wrote:

Thread safe replacement.

Signed-off by: Rosen Penev 

For ubox this change isn't really necessary. There's no thread safety
issues, or issues with use of strtok by callers.


I have my doubts about using strsep() on dynamically allocated  
buffers. In the scan_loaded_modules function of kmodloader.c, you'll  
lose the pointer to buf so you can't free the memory that was  
allocated by getline. Great, the function is now thread safe, but  
we've got a memory leak instead.


I would suggest to use strtok_r in cases where thread safety is an  
issue, rather than replacing it with strsep.



___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


[LEDE-DEV] [PATCH] Added support for the TP-Link WA855RE V1

2016-12-18 Thread Federico Cappon
The device it's similar to the WR841N/ND v9 but without the internal switch.
For install Lede, after soldering the serial, follow the istruction for the 
WR841N/ND v9

Signed-off-by: Federico Cappon 
---
 target/linux/ar71xx/base-files/etc/board.d/01_leds |   3 +
 .../linux/ar71xx/base-files/etc/board.d/02_network |   1 +
 target/linux/ar71xx/base-files/etc/diag.sh |   3 +
 target/linux/ar71xx/base-files/lib/ar71xx.sh   |   6 ++
 .../ar71xx/base-files/lib/upgrade/platform.sh  |   1 +
 target/linux/ar71xx/config-4.4 |   1 +
 .../ar71xx/files/arch/mips/ath79/Kconfig.openwrt   |   9 ++
 target/linux/ar71xx/files/arch/mips/ath79/Makefile |   1 +
 .../files/arch/mips/ath79/mach-tl-wa855re-v1.c | 117 +
 .../linux/ar71xx/files/arch/mips/ath79/machtypes.h |   1 +
 target/linux/ar71xx/image/tp-link.mk   |  10 ++
 target/linux/ar71xx/mikrotik/config-default|   1 +
 12 files changed, 154 insertions(+)
 create mode 100644 
target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wa855re-v1.c

diff --git a/target/linux/ar71xx/base-files/etc/board.d/01_leds 
b/target/linux/ar71xx/base-files/etc/board.d/01_leds
index a840e2f..f0c53c0 100755
--- a/target/linux/ar71xx/base-files/etc/board.d/01_leds
+++ b/target/linux/ar71xx/base-files/etc/board.d/01_leds
@@ -624,6 +624,9 @@ tl-wr842n-v3)
;;
esac
;;
+tl-wa855re-v1)
+   ucidef_set_led_default "power" "POWER" "tp-link:green:power" "1"
+   ;;
 tl-wr1043nd|\
 tl-wr1043nd-v2)
ucidef_set_led_usbdev "usb" "USB" "tp-link:green:usb" "1-1"
diff --git a/target/linux/ar71xx/base-files/etc/board.d/02_network 
b/target/linux/ar71xx/base-files/etc/board.d/02_network
index 8907605..733bc41 100755
--- a/target/linux/ar71xx/base-files/etc/board.d/02_network
+++ b/target/linux/ar71xx/base-files/etc/board.d/02_network
@@ -105,6 +105,7 @@ ar71xx_setup_interfaces()
tl-wa801nd-v2|\
tl-wa830re-v2|\
tl-wa850re|\
+   tl-wa855re-v1|\
tl-wa901nd|\
tl-wa901nd-v2|\
tl-wa901nd-v3|\
diff --git a/target/linux/ar71xx/base-files/etc/diag.sh 
b/target/linux/ar71xx/base-files/etc/diag.sh
index d9d8a29..7c72219 100644
--- a/target/linux/ar71xx/base-files/etc/diag.sh
+++ b/target/linux/ar71xx/base-files/etc/diag.sh
@@ -444,6 +444,9 @@ get_status_led() {
wlr8100)
status_led="sitecom:amber:status"
;;
+   tl-wa855re-v1)
+   status_led="tp-link:green:power"
+   ;;
esac
 }
 
diff --git a/target/linux/ar71xx/base-files/lib/ar71xx.sh 
b/target/linux/ar71xx/base-files/lib/ar71xx.sh
index 2cfd017..cb6ce9d 100755
--- a/target/linux/ar71xx/base-files/lib/ar71xx.sh
+++ b/target/linux/ar71xx/base-files/lib/ar71xx.sh
@@ -244,6 +244,9 @@ tplink_board_detect() {
"085000"*)
model="TP-Link TL-WA850RE"
;;
+   "085501"*)
+   model="TP-Link TL-WA855RE"
+   ;;
"086000"*)
model="TP-Link TL-WA860RE"
;;
@@ -951,6 +954,9 @@ ar71xx_board_detect() {
*TL-WA850RE)
name="tl-wa850re"
;;
+   *"TL-WA855RE v1")
+   name="tl-wa855re-v1"
+   ;;
*TL-WA860RE)
name="tl-wa860re"
;;
diff --git a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh 
b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
index 42cc1dd..74204a5 100755
--- a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
+++ b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
@@ -397,6 +397,7 @@ platform_check_image() {
tl-wr941nd-v5|\
tl-wr941nd-v6|\
tl-wr940n-v4|\
+   tl-wa855re-v1|\
tl-wr941nd)
local magic_ver="0100"
 
diff --git a/target/linux/ar71xx/config-4.4 b/target/linux/ar71xx/config-4.4
index 58d39ad..35709fd 100644
--- a/target/linux/ar71xx/config-4.4
+++ b/target/linux/ar71xx/config-4.4
@@ -185,6 +185,7 @@ CONFIG_ATH79_MACH_TL_WR810N=y
 CONFIG_ATH79_MACH_TL_WR841N_V1=y
 CONFIG_ATH79_MACH_TL_WR841N_V8=y
 CONFIG_ATH79_MACH_TL_WR841N_V9=y
+CONFIG_ATH79_MACH_TL_WA855RE_V1=y
 CONFIG_ATH79_MACH_TL_WR941ND=y
 CONFIG_ATH79_MACH_TL_WR941ND_V6=y
 CONFIG_ATH79_MACH_TL_WR940N_V4=y
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt 
b/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
index 824f47f..1f3a746 100644
--- a/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
+++ b/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
@@ -1472,6 +1472,15 @@ config ATH79_MACH_TL_WR841N_V9
select ATH79_DEV_M25P80
select ATH79_DEV_USB
select ATH79_DEV_WMAC
+   
+config ATH79_MACH_TL_WA855RE_V1
+   bool "TP-LINK TL-WA855RE V1 support"
+   select SOC_QCA953X
+   select ATH79_DEV_ETH
+   select ATH79_DEV_GPIO_BUTTONS
+   select ATH79_DEV_LEDS_GPIO
+   select 

Re: [LEDE-DEV] [PATCH] brcm63xx: fix internal phy registers

2016-12-18 Thread Daniel
Ok, patch v2 sent, only with the interrupt bug fix, and without
renaming all registers.

> Also this change should go upstream. If you don't want to handle it, I
> can do as well.

Yes, please make the upstream work.

Regards

2016-12-18 12:54 GMT+01:00 Jonas Gorski :
> Hi,
>
> On 18 December 2016 at 02:19, Daniel Gonzalez Cabanelas
>  wrote:
>> The internal phy is using wrong registers for the config interrupt function,
>> causing incorrect behavior when detecting the link activity. Fix it.
>>
>> We cannot use the bcm_phy_config_intr function from the bcm-phy-lib.c
>> because it uses different registers from brcm63xx. We need to use
>> our own function, which matches with the one used by the
>> "Broadcom PHY driver" (brcm_fet_config_intr at broadcom.c).
>>
>> brcm63xx internal phy uses the same registers as the ones defined in
>> brcmphy.h for fast ethernet, use them instead.
>>
>> Signed-off-by: Daniel Gonzalez Cabanelas 
>
> Good find.
>
>> diff --git 
>> a/target/linux/brcm63xx/patches-4.4/409-bcm63xx_net_phy-fix-registers.patch 
>> b/target/linux/brcm63xx/patches-4.4/409-bcm63xx_net_phy-fix-registers.patch
>> new file mode 100644
>> index 000..c53d464
>> --- /dev/null
>> +++ 
>> b/target/linux/brcm63xx/patches-4.4/409-bcm63xx_net_phy-fix-registers.patch
>> @@ -0,0 +1,102 @@
>> +--- a/drivers/net/phy/bcm63xx.c
>>  b/drivers/net/phy/bcm63xx.c
>> +@@ -6,44 +6,55 @@
>> +  *as published by the Free Software Foundation; either version
>> +  *2 of the License, or (at your option) any later version.
>> +  */
>> + #include "bcm-phy-lib.h"
>> + #include 
>> + #include 
>> +-
>> +-#define MII_BCM63XX_IR0x1a/* interrupt register */
>> +-#define MII_BCM63XX_IR_EN 0x4000  /* global interrupt enable */
>> +-#define MII_BCM63XX_IR_DUPLEX 0x0800  /* duplex changed */
>> +-#define MII_BCM63XX_IR_SPEED  0x0400  /* speed changed */
>> +-#define MII_BCM63XX_IR_LINK   0x0200  /* link changed */
>> +-#define MII_BCM63XX_IR_GMASK  0x0100  /* global interrupt mask */
>> ++#include 
>> +
>> + MODULE_DESCRIPTION("Broadcom 63xx internal PHY driver");
>> + MODULE_AUTHOR("Maxime Bizon ");
>> + MODULE_LICENSE("GPL");
>> +
>> + static int bcm63xx_config_init(struct phy_device *phydev)
>> + {
>> +   int reg, err;
>> +
>> +-  reg = phy_read(phydev, MII_BCM63XX_IR);
>> ++  reg = phy_read(phydev, MII_BRCM_FET_INTREG);
>> +   if (reg < 0)
>> +   return reg;
>> +
>> +   /* Mask interrupts globally.  */
>> +-  reg |= MII_BCM63XX_IR_GMASK;
>> +-  err = phy_write(phydev, MII_BCM63XX_IR, reg);
>> ++  reg |= MII_BRCM_FET_IR_MASK;
>> ++  err = phy_write(phydev, MII_BRCM_FET_INTREG, reg);
>> +   if (err < 0)
>> +   return err;
>> +
>> +   /* Unmask events we are interested in  */
>> +-  reg = ~(MII_BCM63XX_IR_DUPLEX |
>> +-  MII_BCM63XX_IR_SPEED |
>> +-  MII_BCM63XX_IR_LINK) |
>> +-  MII_BCM63XX_IR_EN;
>> +-  return phy_write(phydev, MII_BCM63XX_IR, reg);
>> ++  reg = ~(MII_BRCM_FET_IR_DUPLEX_EN |
>> ++  MII_BRCM_FET_IR_SPEED_EN |
>> ++  MII_BRCM_FET_IR_LINK_EN) |
>> ++  MII_BRCM_FET_IR_ENABLE;
>> ++  return phy_write(phydev, MII_BRCM_FET_INTREG, reg);
>> ++}
>
> This whole change has nothing to do with the issue and is just
> cosmetic, please drop it. It makes finding the actual changes hard to
> follow. The relevant part is:
>
>> ++
>> ++static int brcm_fet_config_intr(struct phy_device *phydev)
>
> Please call it bcm63xx_config_intr to match the other functions in this 
> driver.
>
>> ++{
>> ++  int reg, err;
>> ++
>> ++  reg = phy_read(phydev, MII_BRCM_FET_INTREG);
>> ++  if (reg < 0)
>> ++  return reg;
>> ++
>> ++  if (phydev->interrupts == PHY_INTERRUPT_ENABLED)
>> ++  reg &= ~MII_BRCM_FET_IR_MASK;
>> ++  else
>> ++  reg |= MII_BRCM_FET_IR_MASK;
>> ++
>> ++  err = phy_write(phydev, MII_BRCM_FET_INTREG, reg);
>> ++  return err;
>
> You can just do "return phy_write()" here, and then you can drop the
> err variable.
>
> *looks at the breaking commit*
>
> Ah, I see what you did there, that's basically the old function. So it
> can probably stay.
>
>
>
>
> Regards
> Jonas



-- 
Daniel

___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


[LEDE-DEV] [PATCH v2] brcm63xx: fix internal net phy interrupt config

2016-12-18 Thread Daniel Gonzalez Cabanelas
The internal phy is using wrong registers for the config interrupt function,
causing incorrect behavior when detecting the link activity. Fix it.

We cannot use the bcm_phy_config_intr function from the bcm-phy-lib.c 
because it uses different registers from brcm63xx. The old function was
right, so go back to it. 

It's worth mentioning that this function matches with the one used
by the Broadcom BCM5241 fast ethernet phy driver (brcm_fet_config_intr 
at broadcom.c). This one uses exactly the same registers as BCM63xx.

---
change in v2:
 use the original defines for focusing only on the bug
 modify the commit log accordingly with the new approach
---
diff --git 
a/target/linux/brcm63xx/patches-4.4/409-bcm63xx_net_phy-fix-config_intr.patch 
b/target/linux/brcm63xx/patches-4.4/409-bcm63xx_net_phy-fix-config_intr.patch
new file mode 100644
index 000..9e5a5d1
--- /dev/null
+++ 
b/target/linux/brcm63xx/patches-4.4/409-bcm63xx_net_phy-fix-config_intr.patch
@@ -0,0 +1,59 @@
+--- a/drivers/net/phy/bcm63xx.c
 b/drivers/net/phy/bcm63xx.c
+@@ -40,38 +40,54 @@
+   MII_BCM63XX_IR_SPEED |
+   MII_BCM63XX_IR_LINK) |
+   MII_BCM63XX_IR_EN;
+   return phy_write(phydev, MII_BCM63XX_IR, reg);
+ }
+ 
++static int bcm63xx_config_intr(struct phy_device *phydev)
++{
++  int reg, err;
++
++  reg = phy_read(phydev, MII_BCM63XX_IR);
++  if (reg < 0)
++  return reg;
++
++  if (phydev->interrupts == PHY_INTERRUPT_ENABLED)
++  reg &= ~MII_BCM63XX_IR_GMASK;
++  else
++  reg |= MII_BCM63XX_IR_GMASK;
++
++  return phy_write(phydev, MII_BCM63XX_IR, reg);
++}
++
+ static struct phy_driver bcm63xx_driver[] = {
+ {
+   .phy_id = 0x00406000,
+   .phy_id_mask= 0xfc00,
+   .name   = "Broadcom BCM63XX (1)",
+   /* ASYM_PAUSE bit is marked RO in datasheet, so don't cheat */
+   .features   = (PHY_BASIC_FEATURES | SUPPORTED_Pause),
+   .flags  = PHY_HAS_INTERRUPT | PHY_IS_INTERNAL,
+   .config_init= bcm63xx_config_init,
+   .config_aneg= genphy_config_aneg,
+   .read_status= genphy_read_status,
+   .ack_interrupt  = bcm_phy_ack_intr,
+-  .config_intr= bcm_phy_config_intr,
++  .config_intr= bcm63xx_config_intr,
+   .driver = { .owner = THIS_MODULE },
+ }, {
+   /* same phy as above, with just a different OUI */
+   .phy_id = 0x002bdc00,
+   .phy_id_mask= 0xfc00,
+   .name   = "Broadcom BCM63XX (2)",
+   .features   = (PHY_BASIC_FEATURES | SUPPORTED_Pause),
+   .flags  = PHY_HAS_INTERRUPT | PHY_IS_INTERNAL,
+   .config_init= bcm63xx_config_init,
+   .config_aneg= genphy_config_aneg,
+   .read_status= genphy_read_status,
+   .ack_interrupt  = bcm_phy_ack_intr,
+-  .config_intr= bcm_phy_config_intr,
++  .config_intr= bcm63xx_config_intr,
+   .driver = { .owner = THIS_MODULE },
+ } };
+ 
+ module_phy_driver(bcm63xx_driver);
+ 
+ static struct mdio_device_id __maybe_unused bcm63xx_tbl[] = {


___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


Re: [LEDE-DEV] [PATCH] brcm63xx: fix internal phy registers

2016-12-18 Thread Jonas Gorski
Hi,

On 18 December 2016 at 02:19, Daniel Gonzalez Cabanelas
 wrote:
> The internal phy is using wrong registers for the config interrupt function,
> causing incorrect behavior when detecting the link activity. Fix it.
>
> We cannot use the bcm_phy_config_intr function from the bcm-phy-lib.c
> because it uses different registers from brcm63xx. We need to use
> our own function, which matches with the one used by the
> "Broadcom PHY driver" (brcm_fet_config_intr at broadcom.c).
>
> brcm63xx internal phy uses the same registers as the ones defined in
> brcmphy.h for fast ethernet, use them instead.
>
> Signed-off-by: Daniel Gonzalez Cabanelas 

Good find.

> diff --git 
> a/target/linux/brcm63xx/patches-4.4/409-bcm63xx_net_phy-fix-registers.patch 
> b/target/linux/brcm63xx/patches-4.4/409-bcm63xx_net_phy-fix-registers.patch
> new file mode 100644
> index 000..c53d464
> --- /dev/null
> +++ 
> b/target/linux/brcm63xx/patches-4.4/409-bcm63xx_net_phy-fix-registers.patch
> @@ -0,0 +1,102 @@
> +--- a/drivers/net/phy/bcm63xx.c
>  b/drivers/net/phy/bcm63xx.c
> +@@ -6,44 +6,55 @@
> +  *as published by the Free Software Foundation; either version
> +  *2 of the License, or (at your option) any later version.
> +  */
> + #include "bcm-phy-lib.h"
> + #include 
> + #include 
> +-
> +-#define MII_BCM63XX_IR0x1a/* interrupt register */
> +-#define MII_BCM63XX_IR_EN 0x4000  /* global interrupt enable */
> +-#define MII_BCM63XX_IR_DUPLEX 0x0800  /* duplex changed */
> +-#define MII_BCM63XX_IR_SPEED  0x0400  /* speed changed */
> +-#define MII_BCM63XX_IR_LINK   0x0200  /* link changed */
> +-#define MII_BCM63XX_IR_GMASK  0x0100  /* global interrupt mask */
> ++#include 
> +
> + MODULE_DESCRIPTION("Broadcom 63xx internal PHY driver");
> + MODULE_AUTHOR("Maxime Bizon ");
> + MODULE_LICENSE("GPL");
> +
> + static int bcm63xx_config_init(struct phy_device *phydev)
> + {
> +   int reg, err;
> +
> +-  reg = phy_read(phydev, MII_BCM63XX_IR);
> ++  reg = phy_read(phydev, MII_BRCM_FET_INTREG);
> +   if (reg < 0)
> +   return reg;
> +
> +   /* Mask interrupts globally.  */
> +-  reg |= MII_BCM63XX_IR_GMASK;
> +-  err = phy_write(phydev, MII_BCM63XX_IR, reg);
> ++  reg |= MII_BRCM_FET_IR_MASK;
> ++  err = phy_write(phydev, MII_BRCM_FET_INTREG, reg);
> +   if (err < 0)
> +   return err;
> +
> +   /* Unmask events we are interested in  */
> +-  reg = ~(MII_BCM63XX_IR_DUPLEX |
> +-  MII_BCM63XX_IR_SPEED |
> +-  MII_BCM63XX_IR_LINK) |
> +-  MII_BCM63XX_IR_EN;
> +-  return phy_write(phydev, MII_BCM63XX_IR, reg);
> ++  reg = ~(MII_BRCM_FET_IR_DUPLEX_EN |
> ++  MII_BRCM_FET_IR_SPEED_EN |
> ++  MII_BRCM_FET_IR_LINK_EN) |
> ++  MII_BRCM_FET_IR_ENABLE;
> ++  return phy_write(phydev, MII_BRCM_FET_INTREG, reg);
> ++}

This whole change has nothing to do with the issue and is just
cosmetic, please drop it. It makes finding the actual changes hard to
follow. The relevant part is:

> ++
> ++static int brcm_fet_config_intr(struct phy_device *phydev)

Please call it bcm63xx_config_intr to match the other functions in this driver.

> ++{
> ++  int reg, err;
> ++
> ++  reg = phy_read(phydev, MII_BRCM_FET_INTREG);
> ++  if (reg < 0)
> ++  return reg;
> ++
> ++  if (phydev->interrupts == PHY_INTERRUPT_ENABLED)
> ++  reg &= ~MII_BRCM_FET_IR_MASK;
> ++  else
> ++  reg |= MII_BRCM_FET_IR_MASK;
> ++
> ++  err = phy_write(phydev, MII_BRCM_FET_INTREG, reg);
> ++  return err;

You can just do "return phy_write()" here, and then you can drop the
err variable.

*looks at the breaking commit*

Ah, I see what you did there, that's basically the old function. So it
can probably stay.


Also this change should go upstream. If you don't want to handle it, I
can do as well.


Regards
Jonas

___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


Re: [LEDE-DEV] [PATCH] ubox: Replace strtok with strsep

2016-12-18 Thread Felix Fietkau
On 2016-12-18 02:22, Rosen Penev wrote:
> Thread safe replacement.
> 
> Signed-off by: Rosen Penev 
For ubox this change isn't really necessary. There's no thread safety
issues, or issues with use of strtok by callers.

- Felix


___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


Re: [LEDE-DEV] [PATCH] brcm63xx: fix internal phy registers

2016-12-18 Thread dani
The defines were totally correct, what's wrong are the registers in
the interrupt function from bcm-phy-lib. I just replaced the defines
just to reflect the similiarities with  the "Broadcom PHY driver" from
where the interrupt function was taken. It eventually could facilitate
the work if a further integration is done.

2016-12-18 3:50 GMT+01:00 Florian Fainelli :
> Le 12/17/16 à 17:19, Daniel Gonzalez Cabanelas a écrit :
>> The internal phy is using wrong registers for the config interrupt function,
>> causing incorrect behavior when detecting the link activity. Fix it.
>>
>> We cannot use the bcm_phy_config_intr function from the bcm-phy-lib.c
>> because it uses different registers from brcm63xx. We need to use
>> our own function, which matches with the one used by the
>> "Broadcom PHY driver" (brcm_fet_config_intr at broadcom.c).
>>
>> brcm63xx internal phy uses the same registers as the ones defined in
>> brcmphy.h for fast ethernet, use them instead.
>
> Humm how did you find out? Not saying this is wrong, but since these
> defines were added to the driver, it sounds like they would have been
> correct.
> --
> Florian

___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev