Blame view

drivers/leds/leds-net48xx.c 1.83 KB
d2912cb15   Thomas Gleixner   treewide: Replace...
1
  // SPDX-License-Identifier: GPL-2.0-only
1a87d9425   Chris Boot   [PATCH] LED Class...
2
3
4
5
6
7
  /*
   * LEDs driver for Soekris net48xx
   *
   * Copyright (C) 2006 Chris Boot <bootc@bootc.net>
   *
   * Based on leds-ams-delta.c
1a87d9425   Chris Boot   [PATCH] LED Class...
8
9
10
11
12
13
14
   */
  
  #include <linux/kernel.h>
  #include <linux/init.h>
  #include <linux/platform_device.h>
  #include <linux/leds.h>
  #include <linux/err.h>
6023ff738   Sachin Kamat   leds: leds-net48x...
15
  #include <linux/io.h>
cfedc920a   Chris Boot   [PATCH] Make net4...
16
  #include <linux/nsc_gpio.h>
1a87d9425   Chris Boot   [PATCH] LED Class...
17
  #include <linux/scx200_gpio.h>
54f4dedb5   Paul Gortmaker   drivers/leds: Add...
18
  #include <linux/module.h>
1a87d9425   Chris Boot   [PATCH] LED Class...
19

bca3bffec   Chris Boot   [PATCH] net48xx L...
20
  #define DRVNAME "net48xx-led"
1a87d9425   Chris Boot   [PATCH] LED Class...
21
22
23
24
25
26
27
  #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...
28
  	scx200_gpio_ops.gpio_set(NET48XX_ERROR_LED_GPIO, value ? 1 : 0);
1a87d9425   Chris Boot   [PATCH] LED Class...
29
30
31
  }
  
  static struct led_classdev net48xx_error_led = {
6c152beef   Richard Purdie   leds: Standardise...
32
  	.name		= "net48xx::error",
1a87d9425   Chris Boot   [PATCH] LED Class...
33
  	.brightness_set	= net48xx_error_led_set,
859cb7f2a   Richard Purdie   leds: Add suspend...
34
  	.flags		= LED_CORE_SUSPENDRESUME,
1a87d9425   Chris Boot   [PATCH] LED Class...
35
  };
1a87d9425   Chris Boot   [PATCH] LED Class...
36
37
  static int net48xx_led_probe(struct platform_device *pdev)
  {
511676230   Muhammad Falak R Wani   leds: leds-net48x...
38
  	return devm_led_classdev_register(&pdev->dev, &net48xx_error_led);
1a87d9425   Chris Boot   [PATCH] LED Class...
39
40
41
  }
  
  static struct platform_driver net48xx_led_driver = {
1a87d9425   Chris Boot   [PATCH] LED Class...
42
  	.probe		= net48xx_led_probe,
1a87d9425   Chris Boot   [PATCH] LED Class...
43
  	.driver		= {
bca3bffec   Chris Boot   [PATCH] net48xx L...
44
  		.name		= DRVNAME,
1a87d9425   Chris Boot   [PATCH] LED Class...
45
46
47
48
49
50
  	},
  };
  
  static int __init net48xx_led_init(void)
  {
  	int ret;
cfedc920a   Chris Boot   [PATCH] Make net4...
51
52
  	/* small hack, but scx200_gpio doesn't set .dev if the probe fails */
  	if (!scx200_gpio_ops.dev) {
1a87d9425   Chris Boot   [PATCH] LED Class...
53
54
55
56
57
58
59
  		ret = -ENODEV;
  		goto out;
  	}
  
  	ret = platform_driver_register(&net48xx_led_driver);
  	if (ret < 0)
  		goto out;
bca3bffec   Chris Boot   [PATCH] net48xx L...
60
  	pdev = platform_device_register_simple(DRVNAME, -1, NULL, 0);
1a87d9425   Chris Boot   [PATCH] LED Class...
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
  	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");