Module Name:    src
Committed By:   martin
Date:           Wed Feb 26 19:41:46 UTC 2014

Modified Files:
        src/sys/arch/arm/marvell: mvsoctmr.c

Log Message:
Initialize mvsoctmr_freq earlier (in mvsoctmr_attach) to avoid division
by zero in calculation of the watchdog parameters.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/arm/marvell/mvsoctmr.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/marvell/mvsoctmr.c
diff -u src/sys/arch/arm/marvell/mvsoctmr.c:1.11 src/sys/arch/arm/marvell/mvsoctmr.c:1.12
--- src/sys/arch/arm/marvell/mvsoctmr.c:1.11	Mon Feb 17 05:25:32 2014
+++ src/sys/arch/arm/marvell/mvsoctmr.c	Wed Feb 26 19:41:46 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: mvsoctmr.c,v 1.11 2014/02/17 05:25:32 kiyohara Exp $	*/
+/*	$NetBSD: mvsoctmr.c,v 1.12 2014/02/26 19:41:46 martin Exp $	*/
 /*
  * Copyright (c) 2007, 2008, 2010 KIYOHARA Takashi
  * All rights reserved.
@@ -25,7 +25,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mvsoctmr.c,v 1.11 2014/02/17 05:25:32 kiyohara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mvsoctmr.c,v 1.12 2014/02/26 19:41:46 martin Exp $");
 
 #include "opt_ddb.h"
 #include "opt_mvsoc.h"
@@ -185,6 +185,14 @@ mvsoctmr_attach(device_t parent, device_
 	db_trap_callback = mvsoctmr_wdog_ddb_trap;
 #endif
 
+	if (sc->sc_flags & TMR_FLAGS_25MHZ)
+		/* We set global timer and counter to 25 MHz mode */
+		mvsoctmr_freq = 25000000;
+	else if (sc->sc_flags & TMR_FLAGS_SYSCLK)
+		mvsoctmr_freq = mvSysclk;
+	else
+		mvsoctmr_freq = mvTclk;
+
 	sc->sc_wdog.smw_name = device_xname(self);
 	sc->sc_wdog.smw_cookie = sc;
 	sc->sc_wdog.smw_setmode = mvsoctmr_wdog_setmode;
@@ -248,14 +256,6 @@ cpu_initclocks(void)
 	if (sc == NULL)
 		panic("cpu_initclocks: mvsoctmr not found");
 
-	if (sc->sc_flags & TMR_FLAGS_25MHZ)
-		/* We set global timer and counter to 25 MHz mode */
-		mvsoctmr_freq = 25000000;
-	else if (sc->sc_flags & TMR_FLAGS_SYSCLK)
-		mvsoctmr_freq = mvSysclk;
-	else
-		mvsoctmr_freq = mvTclk;
-
 	mvsoctmr_timecounter.tc_priv = sc;
 	mvsoctmr_timecounter.tc_frequency = mvsoctmr_freq;
 

Reply via email to