Blame view

drivers/leds/leds-net48xx.c 2.14 KB
1a87d9425   Chris Boot   [PATCH] LED Class...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
  /*
   * LEDs driver for Soekris net48xx
   *
   * Copyright (C) 2006 Chris Boot <bootc@bootc.net>
   *
   * Based on leds-ams-delta.c
   *
   * This program is free software; you can redistribute it and/or modify
   * it under the terms of the GNU General Public License version 2 as
   * published by the Free Software Foundation.
   */
  
  #include <linux/kernel.h>
  #include <linux/init.h>
  #include <linux/platform_device.h>
  #include <linux/leds.h>
  #include <linux/err.h>
  #include <asm/io.h>
cfedc920a   Chris Boot   [PATCH] Make net4...
19
  #include <linux/nsc_gpio.h>
1a87d9425   Chris Boot   [PATCH] LED Class...
20
  #include <linux/scx200_gpio.h>
54f4dedb5   Paul Gortmaker   drivers/leds: Add...
21
  #include <linux/module.h>
1a87d9425   Chris Boot   [PATCH] LED Class...
22

bca3bffec   Chris Boot   [PATCH] net48xx L...
23
  #define DRVNAME "net48xx-led"
1a87d9425   Chris Boot   [PATCH] LED Class...
24
25
26
27
28
29
30
  #define NET48XX_ERROR_LED_GPIO	20
  
  static struct platform_device *pdev;
  
  static void net48xx_error_led_set(struct led_classdev *led_cdev,
  		enum led_brightness value)
  {
cfedc920a   Chris Boot   [PATCH] Make net4...
31
  	scx200_gpio_ops.gpio_set(NET48XX_ERROR_LED_GPIO, value ? 1 : 0);
1a87d9425   Chris Boot   [PATCH] LED Class...
32
33
34
  }
  
  static struct led_classdev net48xx_error_led = {
6c152beef   Richard Purdie   leds: Standardise...
35
  	.name		= "net48xx::error",
1a87d9425   Chris Boot   [PATCH] LED Class...
36
  	.brightness_set	= net48xx_error_led_set,
859cb7f2a   Richard Purdie   leds: Add suspend...
37
  	.flags		= LED_CORE_SUSPENDRESUME,
1a87d9425   Chris Boot   [PATCH] LED Class...
38
  };
1a87d9425   Chris Boot   [PATCH] LED Class...
39
40
41
42
43
44
45
46
47
48
49
50
  static int net48xx_led_probe(struct platform_device *pdev)
  {
  	return led_classdev_register(&pdev->dev, &net48xx_error_led);
  }
  
  static int net48xx_led_remove(struct platform_device *pdev)
  {
  	led_classdev_unregister(&net48xx_error_led);
  	return 0;
  }
  
  static struct platform_driver net48xx_led_driver = {
1a87d9425   Chris Boot   [PATCH] LED Class...
51
52
  	.probe		= net48xx_led_probe,
  	.remove		= net48xx_led_remove,
1a87d9425   Chris Boot   [PATCH] LED Class...
53
  	.driver		= {
bca3bffec   Chris Boot   [PATCH] net48xx L...
54
55
  		.name		= DRVNAME,
  		.owner		= THIS_MODULE,
1a87d9425   Chris Boot   [PATCH] LED Class...
56
57
58
59
60
61
  	},
  };
  
  static int __init net48xx_led_init(void)
  {
  	int ret;
cfedc920a   Chris Boot   [PATCH] Make net4...
62
63
  	/* small hack, but scx200_gpio doesn't set .dev if the probe fails */
  	if (!scx200_gpio_ops.dev) {
1a87d9425   Chris Boot   [PATCH] LED Class...
64
65
66
67
68
69
70
  		ret = -ENODEV;
  		goto out;
  	}
  
  	ret = platform_driver_register(&net48xx_led_driver);
  	if (ret < 0)
  		goto out;
bca3bffec   Chris Boot   [PATCH] net48xx L...
71
  	pdev = platform_device_register_simple(DRVNAME, -1, NULL, 0);
1a87d9425   Chris Boot   [PATCH] LED Class...
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
  	if (IS_ERR(pdev)) {
  		ret = PTR_ERR(pdev);
  		platform_driver_unregister(&net48xx_led_driver);
  		goto out;
  	}
  
  out:
  	return ret;
  }
  
  static void __exit net48xx_led_exit(void)
  {
  	platform_device_unregister(pdev);
  	platform_driver_unregister(&net48xx_led_driver);
  }
  
  module_init(net48xx_led_init);
  module_exit(net48xx_led_exit);
  
  MODULE_AUTHOR("Chris Boot <bootc@bootc.net>");
  MODULE_DESCRIPTION("Soekris net48xx LED driver");
  MODULE_LICENSE("GPL");