linux-mips
[Top] [All Lists]

Re: [PATCH V2] MIPS: move mips_{set,get}_machine_name() to a more generi

To: John Crispin <blogic@openwrt.org>
Subject: Re: [PATCH V2] MIPS: move mips_{set,get}_machine_name() to a more generic place
From: Jonas Gorski <jogo@openwrt.org>
Date: Sat, 13 Apr 2013 14:18:53 +0200
Cc: Ralf Baechle <ralf@linux-mips.org>, linux-mips@linux-mips.org
In-reply-to: <1365842829-10768-1-git-send-email-blogic@openwrt.org>
List-archive: <http://www.linux-mips.org/archives/linux-mips/>
List-help: <mailto:ecartis@linux-mips.org?Subject=help>
List-id: linux-mips <linux-mips.eddie.linux-mips.org>
List-owner: <mailto:ralf@linux-mips.org>
List-post: <mailto:linux-mips@linux-mips.org>
List-software: Ecartis version 1.0.0
List-subscribe: <mailto:ecartis@linux-mips.org?subject=subscribe%20linux-mips>
List-unsubscribe: <mailto:ecartis@linux-mips.org?subject=unsubscribe%20linux-mips>
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <1365842829-10768-1-git-send-email-blogic@openwrt.org>
Sender: linux-mips-bounce@linux-mips.org
On 13 April 2013 10:47, John Crispin <blogic@openwrt.org> wrote:
> Previously this functionality was only available to users of the mips_machine
> api. Moving the code to prom.c allows us to also add a OF wrapper.
>
> Signed-off-by: John Crispin <blogic@openwrt.org>
> ---

(snip)

> diff --git a/arch/mips/kernel/mips_machine.c b/arch/mips/kernel/mips_machine.c
> index 411a058..6dc5866 100644
> --- a/arch/mips/kernel/mips_machine.c
> +++ b/arch/mips/kernel/mips_machine.c
> @@ -13,7 +13,6 @@
>  #include <asm/mips_machine.h>
>
>  static struct mips_machine *mips_machine __initdata;
> -static char *mips_machine_name = "Unknown";
>
>  #define for_each_machine(mach) \
>         for ((mach) = (struct mips_machine *)&__mips_machines_start; \
> @@ -21,25 +20,6 @@ static char *mips_machine_name = "Unknown";
>              (unsigned long)(mach) < (unsigned long)&__mips_machines_end; \
>              (mach)++)
>
> -__init void mips_set_machine_name(const char *name)
> -{
> -       char *p;
> -
> -       if (name == NULL)
> -               return;
> -
> -       p = kstrdup(name, GFP_KERNEL);
> -       if (!p)
> -               pr_err("MIPS: no memory for machine_name\n");
> -
> -       mips_machine_name = p;
> -}
> -
> -char *mips_get_machine_name(void)
> -{
> -       return mips_machine_name;
> -}
> -
>  __init int mips_machtype_setup(char *id)
>  {
>         struct mips_machine *mach;
> @@ -79,7 +59,6 @@ __init void mips_machine_setup(void)
>                 return;
>
>         mips_set_machine_name(mips_machine->mach_name);
> -       pr_info("MIPS: machine is %s\n", mips_machine_name);

Why remove the printk and not just adapt it?

>
>         if (mips_machine->mach_setup)
>                 mips_machine->mach_setup();
> diff --git a/arch/mips/kernel/proc.c b/arch/mips/kernel/proc.c
> index 7a54f74..1dd137b 100644
> --- a/arch/mips/kernel/proc.c
> +++ b/arch/mips/kernel/proc.c
> @@ -12,7 +12,7 @@
>  #include <asm/cpu-features.h>
>  #include <asm/mipsregs.h>
>  #include <asm/processor.h>
> -#include <asm/mips_machine.h>
> +#include <asm/prom.h>
>
>  unsigned int vced_count, vcei_count;
>
> diff --git a/arch/mips/kernel/prom.c b/arch/mips/kernel/prom.c
> index 028f6f8..a5731c2 100644
> --- a/arch/mips/kernel/prom.c
> +++ b/arch/mips/kernel/prom.c
> @@ -23,6 +23,21 @@
>  #include <asm/page.h>
>  #include <asm/prom.h>
>
> +static char mips_machine_name[64] = "Unknown";
> +
> +__init void mips_set_machine_name(const char *name)
> +{
> +       if (name == NULL)
> +               return;
> +
> +       strncpy(mips_machine_name, name, sizeof(mips_machine_name));
> +}
> +
> +char *mips_get_machine_name(void)
> +{
> +       return mips_machine_name;
> +}
> +
>  int __init early_init_dt_scan_memory_arch(unsigned long node,
>                                           const char *uname, int depth,
>                                           void *data)
> @@ -50,6 +65,21 @@ void __init early_init_dt_setup_initrd_arch(unsigned long 
> start,
>  }
>  #endif
>
> +int __init early_init_dt_scan_model(unsigned long node,
> +       const char *uname, int depth,
> +       void *data)

Indentation level is wrong.

> +{
> +       if (!depth) {
> +               char *model = of_get_flat_dt_prop(node, "model", NULL);

Missing empty line.

> +               if (model) {
> +                       mips_set_machine_name(model);
> +                       pr_info("MIPS: machine is %s\n",
> +                                       mips_get_machine_name());

Indentation level is wrong.

> +               }
> +       }
> +       return 0;
> +}
> +
>  void __init early_init_devtree(void *params)
>  {
>         /* Setup flat device-tree pointer */
> @@ -65,6 +95,9 @@ void __init early_init_devtree(void *params)
>         /* Scan memory nodes */
>         of_scan_flat_dt(early_init_dt_scan_root, NULL);
>         of_scan_flat_dt(early_init_dt_scan_memory_arch, NULL);
> +
> +       /* try to load the mips machine name */
> +       of_scan_flat_dt(early_init_dt_scan_model, NULL);
>  }
>
>  void __init __dt_setup_arch(struct boot_param_header *bph)
> --
> 1.7.10.4
>
>

<Prev in Thread] Current Thread [Next in Thread>