mirror of
https://dev.iopsys.eu/feed/iopsys.git
synced 2025-12-10 07:44:50 +01:00
Fix gryphon LED module crash.
Update gryphon LED module to work with Linux 4.1 and not to crash when 'gpiod_get_index()' fails. Change-Id: I27fcbe3ad9dbc755eabdd3f2120544b171b07885
This commit is contained in:
parent
7978a656a7
commit
6e35356954
1 changed files with 16 additions and 2 deletions
|
|
@ -129,6 +129,8 @@ static int canyon_led_probe(struct platform_device *pdev)
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dev_warn(&pdev->dev, "Could not read led-count property\n");
|
dev_warn(&pdev->dev, "Could not read led-count property\n");
|
||||||
leds->led_count = SK9822_DEFAULT_NUM_LEDS;
|
leds->led_count = SK9822_DEFAULT_NUM_LEDS;
|
||||||
|
} else {
|
||||||
|
printk(KERN_INFO "Got led count: %u\n", leds->led_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
leds->led_colors = devm_kzalloc(&pdev->dev,
|
leds->led_colors = devm_kzalloc(&pdev->dev,
|
||||||
|
|
@ -140,7 +142,7 @@ static int canyon_led_probe(struct platform_device *pdev)
|
||||||
|
|
||||||
platform_set_drvdata(pdev, leds);
|
platform_set_drvdata(pdev, leds);
|
||||||
|
|
||||||
#if LINUX_VERSION_CODE <= KERNEL_VERSION(3, 16, 0)
|
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 3, 0)
|
||||||
leds->clock_gpio = gpiod_get_index(&pdev->dev, "led", 0);
|
leds->clock_gpio = gpiod_get_index(&pdev->dev, "led", 0);
|
||||||
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 3, 0)
|
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 3, 0)
|
||||||
leds->clock_gpio = gpiod_get_index(&pdev->dev, "led", 0, GPIOD_OUT_HIGH);
|
leds->clock_gpio = gpiod_get_index(&pdev->dev, "led", 0, GPIOD_OUT_HIGH);
|
||||||
|
|
@ -148,6 +150,12 @@ static int canyon_led_probe(struct platform_device *pdev)
|
||||||
dev_warn(&pdev->dev, "Kernel version Not supported\n");
|
dev_warn(&pdev->dev, "Kernel version Not supported\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
#endif
|
#endif
|
||||||
|
if (IS_ERR(leds->clock_gpio)) {
|
||||||
|
dev_err(&pdev->dev, "Failed to acquire clock GPIO %ld\n",
|
||||||
|
PTR_ERR(leds->clock_gpio));
|
||||||
|
leds->clock_gpio = NULL;
|
||||||
|
return PTR_ERR(leds->clock_gpio);
|
||||||
|
}
|
||||||
|
|
||||||
gpiod_direction_output(leds->clock_gpio, 1);
|
gpiod_direction_output(leds->clock_gpio, 1);
|
||||||
if (IS_ERR(leds->clock_gpio)) {
|
if (IS_ERR(leds->clock_gpio)) {
|
||||||
|
|
@ -160,7 +168,7 @@ static int canyon_led_probe(struct platform_device *pdev)
|
||||||
gpiod_set_value(leds->clock_gpio, 0);
|
gpiod_set_value(leds->clock_gpio, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if LINUX_VERSION_CODE <= KERNEL_VERSION(3, 16, 0)
|
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 3, 0)
|
||||||
leds->data_gpio = gpiod_get_index(&pdev->dev, "led", 1);
|
leds->data_gpio = gpiod_get_index(&pdev->dev, "led", 1);
|
||||||
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 3, 0)
|
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 3, 0)
|
||||||
leds->data_gpio = gpiod_get_index(&pdev->dev, "led", 1, GPIOD_OUT_HIGH);
|
leds->data_gpio = gpiod_get_index(&pdev->dev, "led", 1, GPIOD_OUT_HIGH);
|
||||||
|
|
@ -168,6 +176,12 @@ static int canyon_led_probe(struct platform_device *pdev)
|
||||||
dev_warn(&pdev->dev, "Kernel version Not supported\n");
|
dev_warn(&pdev->dev, "Kernel version Not supported\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
#endif
|
#endif
|
||||||
|
if (IS_ERR(leds->data_gpio)) {
|
||||||
|
dev_err(&pdev->dev, "Failed to acquire data GPIO %ld\n",
|
||||||
|
PTR_ERR(leds->data_gpio));
|
||||||
|
leds->data_gpio = NULL;
|
||||||
|
return PTR_ERR(leds->data_gpio);
|
||||||
|
}
|
||||||
|
|
||||||
gpiod_direction_output(leds->data_gpio, 1);
|
gpiod_direction_output(leds->data_gpio, 1);
|
||||||
if (IS_ERR(leds->data_gpio)) {
|
if (IS_ERR(leds->data_gpio)) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue