Re: [PATCH 4/4] MIPS: Loongson64: Load platform device during boot This patch just add pdev during boot to load the platform driver

2017-11-14 Thread Ralf Baechle
On Sun, Nov 12, 2017 at 02:36:17PM +0800, jiaxun.y...@flygoat.com wrote:

> From: Jiaxun Yang 
> 
> Signed-off-by: Jiaxun Yang 
> ---
>  arch/mips/loongson64/lemote-2f/Makefile   |  2 +-
>  arch/mips/loongson64/lemote-2f/platform.c | 45 
> +++
>  2 files changed, 46 insertions(+), 1 deletion(-)
>  create mode 100644 arch/mips/loongson64/lemote-2f/platform.c
> 
> diff --git a/arch/mips/loongson64/lemote-2f/Makefile 
> b/arch/mips/loongson64/lemote-2f/Makefile
> index 08b8abcbfef5..31c90737b98c 100644
> --- a/arch/mips/loongson64/lemote-2f/Makefile
> +++ b/arch/mips/loongson64/lemote-2f/Makefile
> @@ -2,7 +2,7 @@
>  # Makefile for lemote loongson2f family machines
>  #
>  
> -obj-y += clock.o machtype.o irq.o reset.o ec_kb3310b.o
> +obj-y += clock.o machtype.o irq.o reset.o ec_kb3310b.o platform.o
>  
>  #
>  # Suspend Support
> diff --git a/arch/mips/loongson64/lemote-2f/platform.c 
> b/arch/mips/loongson64/lemote-2f/platform.c
> new file mode 100644
> index ..c36efcccb9a9
> --- /dev/null
> +++ b/arch/mips/loongson64/lemote-2f/platform.c
> @@ -0,0 +1,45 @@
> +/*
> + * Copyright (C) 2017 Jiaxun Yang.
> + * Author: Jiaxun Yang, jiaxun.y...@flygoat.com
> +
> + * Copyright (C) 2009 Lemote Inc.
> + * Author: Wu Zhangjin, wuzhang...@gmail.com
> + *
> + * This program is free software; you can redistribute  it and/or modify it
> + * under  the terms of  the GNU General  Public License as published by the
> + * Free Software Foundation;  either version 2 of the  License, or (at your
> + * option) any later version.
> + */
> +
> +#include 
> +#include 
> +
> +#include 
> +
> +static struct platform_device yeeloong_pdev = {
> + .name = "yeeloong_laptop",
> + .id = -1,
> +};
> +
> +
> +static int __init lemote2f_platform_init(void)
> +{
> + struct platform_device *pdev = NULL;
> +
> + switch (mips_machtype) {
> + case MACH_LEMOTE_YL2F89:
> + pdev = &yeeloong_pdev;
> + break;
> +
> + default:
> + break;
> +
> + }
> +
> + if (pdev != NULL)
> + return platform_device_register(pdev);
> +
> + return -ENODEV;
> +}
> +
> +arch_initcall(lemote2f_platform_init);

Looks like you can simplify this by using something like:

> +static int __init lemote2f_platform_init(void)
> +{
> + struct platform_device *pdev = NULL;
> +
> + switch (mips_machtype) {
> + case MACH_LEMOTE_YL2F89:
> + pdev = &yeeloong_pdev;
> + break;
> +
> + default:
> + break;
> +
> + }
> +
> + if (pdev != NULL)
> + return platform_device_register(pdev);
> +
> + return -ENODEV;
> +}

Looks like this can be simplified to:

static int __init lemote2f_platform_init(void)
{
if (mips_machtype != MACH_LEMOTE_YL2F89)
return -ENODEV;

return platform_device_register_simple("yeeloong_laptop", -1, NULL, 0);
}


  Ralf


[PATCH 4/4] MIPS: Loongson64: Load platform device during boot This patch just add pdev during boot to load the platform driver

2017-11-11 Thread jiaxun . yang
From: Jiaxun Yang 

Signed-off-by: Jiaxun Yang 
---
 arch/mips/loongson64/lemote-2f/Makefile   |  2 +-
 arch/mips/loongson64/lemote-2f/platform.c | 45 +++
 2 files changed, 46 insertions(+), 1 deletion(-)
 create mode 100644 arch/mips/loongson64/lemote-2f/platform.c

diff --git a/arch/mips/loongson64/lemote-2f/Makefile 
b/arch/mips/loongson64/lemote-2f/Makefile
index 08b8abcbfef5..31c90737b98c 100644
--- a/arch/mips/loongson64/lemote-2f/Makefile
+++ b/arch/mips/loongson64/lemote-2f/Makefile
@@ -2,7 +2,7 @@
 # Makefile for lemote loongson2f family machines
 #
 
-obj-y += clock.o machtype.o irq.o reset.o ec_kb3310b.o
+obj-y += clock.o machtype.o irq.o reset.o ec_kb3310b.o platform.o
 
 #
 # Suspend Support
diff --git a/arch/mips/loongson64/lemote-2f/platform.c 
b/arch/mips/loongson64/lemote-2f/platform.c
new file mode 100644
index ..c36efcccb9a9
--- /dev/null
+++ b/arch/mips/loongson64/lemote-2f/platform.c
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2017 Jiaxun Yang.
+ * Author: Jiaxun Yang, jiaxun.y...@flygoat.com
+
+ * Copyright (C) 2009 Lemote Inc.
+ * Author: Wu Zhangjin, wuzhang...@gmail.com
+ *
+ * This program is free software; you can redistribute  it and/or modify it
+ * under  the terms of  the GNU General  Public License as published by the
+ * Free Software Foundation;  either version 2 of the  License, or (at your
+ * option) any later version.
+ */
+
+#include 
+#include 
+
+#include 
+
+static struct platform_device yeeloong_pdev = {
+   .name = "yeeloong_laptop",
+   .id = -1,
+};
+
+
+static int __init lemote2f_platform_init(void)
+{
+   struct platform_device *pdev = NULL;
+
+   switch (mips_machtype) {
+   case MACH_LEMOTE_YL2F89:
+   pdev = &yeeloong_pdev;
+   break;
+
+   default:
+   break;
+
+   }
+
+   if (pdev != NULL)
+   return platform_device_register(pdev);
+
+   return -ENODEV;
+}
+
+arch_initcall(lemote2f_platform_init);
-- 
2.14.1