power: reset: at91-poweroff: do not procede if at91_shdwc is allocated
authorClaudiu Beznea <claudiu.beznea@microchip.com>
Thu, 30 Aug 2018 11:50:11 +0000 (14:50 +0300)
committerSebastian Reichel <sre@kernel.org>
Sun, 16 Sep 2018 10:32:17 +0000 (12:32 +0200)
There should be only one instance of struct shdwc in the system. This is
referenced through at91_shdwc. Return in probe if at91_shdwc is already
allocated.

Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
drivers/power/reset/at91-sama5d2_shdwc.c

index ad6e279..2b686c5 100644 (file)
@@ -255,6 +255,9 @@ static int __init at91_shdwc_probe(struct platform_device *pdev)
        if (!pdev->dev.of_node)
                return -ENODEV;
 
+       if (at91_shdwc)
+               return -EBUSY;
+
        at91_shdwc = devm_kzalloc(&pdev->dev, sizeof(*at91_shdwc), GFP_KERNEL);
        if (!at91_shdwc)
                return -ENOMEM;