aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/generic/pending-4.19/0931-w1-gpio-fix-problem-with-platfom-data-in-w1-gpio.patch
blob: be9ceebc3a5d25a039b8b5089cf772af14137352 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
From d9c8bc8c1408f3e8529db6e4e04017b4c579c342 Mon Sep 17 00:00:00 2001
From: Pawel Dembicki <paweldembicki@gmail.com>
Date: Sun, 18 Feb 2018 17:08:04 +0100
Subject: [PATCH] w1: gpio: fix problem with platfom data in w1-gpio

In devices, where fdt is used, is impossible to apply platform data
without proper fdt node.

This patch allow to use platform data in devices with fdt.

Signed-off-by: Pawel Dembicki <paweldembicki@gmail.com>
---
 drivers/w1/masters/w1-gpio.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

--- a/drivers/w1/masters/w1-gpio.c
+++ b/drivers/w1/masters/w1-gpio.c
@@ -79,7 +79,7 @@ static int w1_gpio_probe(struct platform
 	enum gpiod_flags gflags = GPIOD_OUT_LOW_OPEN_DRAIN;
 	int err;
 
-	if (of_have_populated_dt()) {
+	if (of_have_populated_dt() && !dev_get_platdata(&pdev->dev)) {
 		pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
 		if (!pdata)
 			return -ENOMEM;
nse for the specific language governing permissions and limitations under the License. */ #include "ch.h" #include "hal.h" #include "rt_test_root.h" #include "oslib_test_root.h" /* * Blue LED blinker thread, times are in milliseconds. */ static THD_WORKING_AREA(waThread1, 128); static THD_FUNCTION(Thread1, arg) { (void)arg; chRegSetThreadName("blinker1"); while (true) { palClearPad(GPIOC, GPIOC_LED4); chThdSleepMilliseconds(500); palSetPad(GPIOC, GPIOC_LED4); chThdSleepMilliseconds(500); } } /* * Green LED blinker thread, times are in milliseconds. */ static THD_WORKING_AREA(waThread2, 128); static THD_FUNCTION(Thread2, arg) { (void)arg; chRegSetThreadName("blinker2"); while (true) { palClearPad(GPIOC, GPIOC_LED3); chThdSleepMilliseconds(250); palSetPad(GPIOC, GPIOC_LED3); chThdSleepMilliseconds(250); } } /* * Application entry point. */ int main(void) { /* * System initializations. * - HAL initialization, this also initializes the configured device drivers * and performs the board-specific initializations. * - Kernel initialization, the main() function becomes a thread and the * RTOS is active. */ halInit(); chSysInit(); /* * Activates the serial driver 1 using the driver default configuration. * PA9 and PA10 are routed to USART1. */ sdStart(&SD1, NULL); palSetPadMode(GPIOA, 9, PAL_MODE_ALTERNATE(1)); /* USART1 TX. */ palSetPadMode(GPIOA, 10, PAL_MODE_ALTERNATE(1)); /* USART1 RX. */ /* * Creates the blinker threads. */ chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL); chThdCreateStatic(waThread2, sizeof(waThread2), NORMALPRIO, Thread2, NULL); /* * Normal main() thread activity, in this demo it does nothing except * sleeping in a loop and check the button state, when the button is * pressed the test procedure is launched with output on the serial * driver 1. */ while (true) { if (palReadPad(GPIOA, GPIOA_BUTTON)) { test_execute((BaseSequentialStream *)&SD1, &rt_test_suite); test_execute((BaseSequentialStream *)&SD1, &oslib_test_suite); } chThdSleepMilliseconds(500); } }