diff mbox

[OpenWrt-Devel,v3,2/7] ath79: dev-eth: initialize clock for id 0 on AR934X

Message ID 1436273936-6908-3-git-send-email-guenther.kelleter@devolo.de
State Superseded
Headers show

Commit Message

Günther Kelleter July 7, 2015, 12:58 p.m. UTC
Signed-off-by: Günther Kelleter <guenther.kelleter@devolo.de>
---
 target/linux/ar71xx/files/arch/mips/ath79/dev-eth.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

John Crispin July 9, 2015, 6:31 a.m. UTC | #1
Hi,

looking closer at the code i noticed that you need to do this as
ath79_mdio1_data is not initialized to 0 properly. the reason being that
it is not static and that in turn is because the header file declares it
as extern yet there are no users.

i would suggest you drop this patch and instead make ath79_mdio1_data
static and remove the prototype from the header file. that should have
the same effect and will make sure ath79_mdio1_data is properly initialized.

please also fix ath79_mdio0_data while at it.

	John

On 07/07/2015 14:58, Günther Kelleter wrote:
> Signed-off-by: Günther Kelleter <guenther.kelleter@devolo.de>
> ---
>  target/linux/ar71xx/files/arch/mips/ath79/dev-eth.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/target/linux/ar71xx/files/arch/mips/ath79/dev-eth.c b/target/linux/ar71xx/files/arch/mips/ath79/dev-eth.c
> index ff94e2e..c7524be 100644
> --- a/target/linux/ar71xx/files/arch/mips/ath79/dev-eth.c
> +++ b/target/linux/ar71xx/files/arch/mips/ath79/dev-eth.c
> @@ -251,9 +251,11 @@ void __init ath79_register_mdio(unsigned int id, u32 phy_mask)
>  	case ATH79_SOC_AR9344:
>  		if (id == 1) {
>  			mdio_data->builtin_switch = 1;
> -			mdio_data->ref_clock = ar934x_get_mdio_ref_clock();
> -			mdio_data->mdio_clock = 6250000;
> +		} else {
> +			mdio_data->builtin_switch = 0;
>  		}
> +		mdio_data->ref_clock = ar934x_get_mdio_ref_clock();
> +		mdio_data->mdio_clock = 6250000;
>  		mdio_data->is_ar934x = 1;
>  		break;
>  
>
Günther Kelleter July 9, 2015, 11:39 a.m. UTC | #2
Hi

> -----Original Message-----

> From: John Crispin [mailto:blogic@openwrt.org]

> Sent: Thursday, July 09, 2015 8:32 AM

> To: Guenther Kelleter; openwrt-devel@lists.openwrt.org

> Subject: Re: [OpenWrt-Devel] [PATCH v3 2/7] ath79: dev-eth: initialize clock

> for id 0 on AR934X

> 

> Hi,

> 

> looking closer at the code i noticed that you need to do this as

> ath79_mdio1_data is not initialized to 0 properly. the reason being that it is

> not static and that in turn is because the header file declares it as extern

> yet there are no users.

> 

> i would suggest you drop this patch and instead make ath79_mdio1_data static

> and remove the prototype from the header file. that should have the same

> effect and will make sure ath79_mdio1_data is properly initialized.



Static or not doesn't change initialization here. ath79_mdio1_data will be in BSS and initialized to 0. And arch/mips/ath79/mach-mynet-n750.c uses ath79_mdio0_data so this cannot be changed to static.
I can remove mdio_data->builtin_switch = 0 though since that's implicit.

The important part of the patch is initializing the *_clock members (that's what I thought before).
But I checked it again without this patch, and now it looks as if it's working.

Günther

> 

> please also fix ath79_mdio0_data while at it.

> 

> 	John

> 

> On 07/07/2015 14:58, Günther Kelleter wrote:

> > Signed-off-by: Günther Kelleter <guenther.kelleter@devolo.de>

> > ---

> >  target/linux/ar71xx/files/arch/mips/ath79/dev-eth.c | 6 ++++--

> >  1 file changed, 4 insertions(+), 2 deletions(-)

> >

> > diff --git a/target/linux/ar71xx/files/arch/mips/ath79/dev-eth.c

> > b/target/linux/ar71xx/files/arch/mips/ath79/dev-eth.c

> > index ff94e2e..c7524be 100644

> > --- a/target/linux/ar71xx/files/arch/mips/ath79/dev-eth.c

> > +++ b/target/linux/ar71xx/files/arch/mips/ath79/dev-eth.c

> > @@ -251,9 +251,11 @@ void __init ath79_register_mdio(unsigned int id, u32

> phy_mask)

> >  	case ATH79_SOC_AR9344:

> >  		if (id == 1) {

> >  			mdio_data->builtin_switch = 1;

> > -			mdio_data->ref_clock = ar934x_get_mdio_ref_clock();

> > -			mdio_data->mdio_clock = 6250000;

> > +		} else {

> > +			mdio_data->builtin_switch = 0;

> >  		}	

> > +		mdio_data->ref_clock = ar934x_get_mdio_ref_clock();

> > +		mdio_data->mdio_clock = 6250000;

> >  		mdio_data->is_ar934x = 1;

> >  		break;

> >

> >
diff mbox

Patch

diff --git a/target/linux/ar71xx/files/arch/mips/ath79/dev-eth.c b/target/linux/ar71xx/files/arch/mips/ath79/dev-eth.c
index ff94e2e..c7524be 100644
--- a/target/linux/ar71xx/files/arch/mips/ath79/dev-eth.c
+++ b/target/linux/ar71xx/files/arch/mips/ath79/dev-eth.c
@@ -251,9 +251,11 @@  void __init ath79_register_mdio(unsigned int id, u32 phy_mask)
 	case ATH79_SOC_AR9344:
 		if (id == 1) {
 			mdio_data->builtin_switch = 1;
-			mdio_data->ref_clock = ar934x_get_mdio_ref_clock();
-			mdio_data->mdio_clock = 6250000;
+		} else {
+			mdio_data->builtin_switch = 0;
 		}
+		mdio_data->ref_clock = ar934x_get_mdio_ref_clock();
+		mdio_data->mdio_clock = 6250000;
 		mdio_data->is_ar934x = 1;
 		break;