Signed-off-by: Luc Verhaegen <[email protected]>
---
 meminfo.c |   36 +++++++++++++++++++++++-------------
 1 files changed, 23 insertions(+), 13 deletions(-)

diff --git a/meminfo.c b/meminfo.c
index ca099c1..a53c081 100644
--- a/meminfo.c
+++ b/meminfo.c
@@ -341,6 +341,28 @@ sun4i_dram_para_print_fex(struct sun4i_dram_para 
*dram_para)
        printf("dram_emr3 = 0x%02x\n", dram_para->emr3);
 }
 
+static int
+sun4i_dram_para_print(bool uboot)
+{
+       struct sun4i_dram_para dram_para = {0};
+       int ret;
+
+       ret = sunxi_dram_clock_read(&dram_para.clock);
+       if (ret)
+               return ret;
+
+       ret = sun4i_dram_parameters_read(&dram_para);
+       if (ret)
+               return ret;
+
+       if (uboot)
+               sun4i_dram_para_print_uboot(&dram_para);
+       else
+               sun4i_dram_para_print_fex(&dram_para);
+
+       return 0;
+}
+
 static void
 print_usage(const char *name)
 {
@@ -363,7 +385,6 @@ print_usage(const char *name)
 int
 main(int argc, char *argv[])
 {
-       struct sun4i_dram_para dram_para = {0};
        bool uboot;
        int ret;
 
@@ -403,18 +424,7 @@ main(int argc, char *argv[])
        if (ret)
                return ret;
 
-       ret = sun4i_dram_parameters_read(&dram_para);
-       if (ret)
-               return ret;
-
-       ret = sunxi_dram_clock_read(&dram_para.clock);
-       if (ret)
-               return ret;
-
-       if (uboot)
-               sun4i_dram_para_print_uboot(&dram_para);
-       else
-               sun4i_dram_para_print_fex(&dram_para);
+       sun4i_dram_para_print(uboot);
 
        return 0;
 
-- 
1.7.7

-- 
You received this message because you are subscribed to the Google Groups 
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to