Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-or-later
0002 /*
0003  *  Registration of Cobalt LED platform device.
0004  *
0005  *  Copyright (C) 2007  Yoichi Yuasa <yuasa@linux-mips.org>
0006  */
0007 #include <linux/errno.h>
0008 #include <linux/init.h>
0009 #include <linux/ioport.h>
0010 #include <linux/platform_device.h>
0011 
0012 #include <cobalt.h>
0013 
0014 static struct resource cobalt_led_resource __initdata = {
0015     .start  = 0x1c000000,
0016     .end    = 0x1c000000,
0017     .flags  = IORESOURCE_MEM,
0018 };
0019 
0020 static __init int cobalt_led_add(void)
0021 {
0022     struct platform_device *pdev;
0023     int retval;
0024 
0025     if (cobalt_board_id == COBALT_BRD_ID_QUBE1 ||
0026         cobalt_board_id == COBALT_BRD_ID_QUBE2)
0027         pdev = platform_device_alloc("cobalt-qube-leds", -1);
0028     else
0029         pdev = platform_device_alloc("cobalt-raq-leds", -1);
0030 
0031     if (!pdev)
0032         return -ENOMEM;
0033 
0034     retval = platform_device_add_resources(pdev, &cobalt_led_resource, 1);
0035     if (retval)
0036         goto err_free_device;
0037 
0038     retval = platform_device_add(pdev);
0039     if (retval)
0040         goto err_free_device;
0041 
0042     return 0;
0043 
0044 err_free_device:
0045     platform_device_put(pdev);
0046 
0047     return retval;
0048 }
0049 device_initcall(cobalt_led_add);