From patchwork Tue Jun 25 16:34:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 11017203 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4E1911398 for ; Wed, 26 Jun 2019 08:13:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3DCBD28694 for ; Wed, 26 Jun 2019 08:13:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 31E69286C6; Wed, 26 Jun 2019 08:13:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D559F28694 for ; Wed, 26 Jun 2019 08:13:30 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B3BAF6E2E3; Wed, 26 Jun 2019 08:12:36 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) by gabe.freedesktop.org (Postfix) with ESMTPS id 44A6D6E171 for ; Tue, 25 Jun 2019 16:34:54 +0000 (UTC) Received: by mail-wr1-x442.google.com with SMTP id v14so18635067wrr.4 for ; Tue, 25 Jun 2019 09:34:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2ZSWbqFAdYMHZSBHSRb1jfufvzOhyuDcLok5vmyDpAk=; b=YxkTqkMz7nS5pMEDvB/bjBPI1Szmtt3LmQuztgWzrAFw3gqWNIPNBc7Tz6F+PyyD8z nH/kkhj3dyZ4/4PI4+kBvrJmjnlNTWXcoTNNDmz+bQ6HKAwFe3fHQg33GMTpD3M1Svdx 5ICr/Kg0utK0w6ytAIgoelLwRF24wfs9fVdr4cqyok1JRtLZSkTYUig1H7h93Dkh1NYg yX+metkyOcYhdbB189+DAb67xRRuzSn07dRa6879UtB2uKruND1HC5CacQ0apaQxPjGr OVuHAEywX/he4I0Pu/bUCnsrbtPcbDi37WgulaKj7dKoDMj/7oZ/I75DiiLu1kZ9L/m8 VRGQ== X-Gm-Message-State: APjAAAWVb8lHJgy0g3ab568fB8EG+xN4pJsyLfiR6sCLxAGCNw1eRV3q UCjsieYUozufCdqfWhbp3PiSCw== X-Google-Smtp-Source: APXvYqxBEmrDBznAn14GIGVfoHIVRb3pDwaOfikmLmN/GvkdUV1EAMzyMBq7WLZPIpw1AC69xAAo+Q== X-Received: by 2002:a05:6000:114b:: with SMTP id d11mr47787109wrx.167.1561480492966; Tue, 25 Jun 2019 09:34:52 -0700 (PDT) Received: from debian-brgl.home ([2a01:cb1d:af:5b00:6d6c:8493:1ab5:dad7]) by smtp.gmail.com with ESMTPSA id g8sm2683795wme.20.2019.06.25.09.34.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 25 Jun 2019 09:34:52 -0700 (PDT) From: Bartosz Golaszewski To: Sekhar Nori , Kevin Hilman , Lee Jones , Daniel Thompson , Jingoo Han , Bartlomiej Zolnierkiewicz , David Lechner , Linus Walleij Subject: [PATCH 01/12] backlight: gpio: allow to probe non-pdata devices from board files Date: Tue, 25 Jun 2019 18:34:23 +0200 Message-Id: <20190625163434.13620-2-brgl@bgdev.pl> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190625163434.13620-1-brgl@bgdev.pl> References: <20190625163434.13620-1-brgl@bgdev.pl> MIME-Version: 1.0 X-Mailman-Approved-At: Wed, 26 Jun 2019 08:12:13 +0000 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2ZSWbqFAdYMHZSBHSRb1jfufvzOhyuDcLok5vmyDpAk=; b=SJOSCbrBbZkjOqrPgnuNAn3R5vfXS6muglF3i2rYm4u0+9MfY8ZtiyCWhaoSYkXO8w eOFkyeVW0jcrhK2bzRVm7OVFfxNNRuPXIaA1Pc5QIbfMItUzavJ+NDMN8n9e0L9FS8p6 tq7TTeGdzaX0136DmFa1LftA7xw+cPs//R7BxHfmQaa/vNwriSWQhE6HYmKQuFbGDxDq Bg5erLaGp0cgJlgeiEOIPYKLnoR9icCMSctMhsB1HZzmQqp3udL5+Sn4pNOcL9yKERsx Z5y5KpcxAJ9+MaE4zx8TVcaHvHGAnMEpPRGOC89hkmJe4zcmW8hColHnvm5z1nJEKHx+ Lt5A== X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Bartosz Golaszewski , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-fbdev@vger.kernel.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Bartosz Golaszewski Currently we can only probe devices that either use device tree or pass platform data to probe(). Rename gpio_backlight_probe_dt() to gpio_backlight_probe_prop() and use generic device properties instead of OF specific helpers. Reverse the logic checking the presence of platform data in probe(). This way we can probe devices() registered from machine code that neither have a DT node nor use platform data. Signed-off-by: Bartosz Golaszewski Reviewed-by: Bartlomiej Zolnierkiewicz --- drivers/video/backlight/gpio_backlight.c | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/drivers/video/backlight/gpio_backlight.c b/drivers/video/backlight/gpio_backlight.c index b9300f3e1ee6..654c19d3a81d 100644 --- a/drivers/video/backlight/gpio_backlight.c +++ b/drivers/video/backlight/gpio_backlight.c @@ -54,15 +54,14 @@ static const struct backlight_ops gpio_backlight_ops = { .check_fb = gpio_backlight_check_fb, }; -static int gpio_backlight_probe_dt(struct platform_device *pdev, - struct gpio_backlight *gbl) +static int gpio_backlight_probe_prop(struct platform_device *pdev, + struct gpio_backlight *gbl) { struct device *dev = &pdev->dev; - struct device_node *np = dev->of_node; enum gpiod_flags flags; int ret; - gbl->def_value = of_property_read_bool(np, "default-on"); + gbl->def_value = device_property_read_bool(dev, "default-on"); flags = gbl->def_value ? GPIOD_OUT_HIGH : GPIOD_OUT_LOW; gbl->gpiod = devm_gpiod_get(dev, NULL, flags); @@ -86,26 +85,15 @@ static int gpio_backlight_probe(struct platform_device *pdev) struct backlight_properties props; struct backlight_device *bl; struct gpio_backlight *gbl; - struct device_node *np = pdev->dev.of_node; int ret; - if (!pdata && !np) { - dev_err(&pdev->dev, - "failed to find platform data or device tree node.\n"); - return -ENODEV; - } - gbl = devm_kzalloc(&pdev->dev, sizeof(*gbl), GFP_KERNEL); if (gbl == NULL) return -ENOMEM; gbl->dev = &pdev->dev; - if (np) { - ret = gpio_backlight_probe_dt(pdev, gbl); - if (ret) - return ret; - } else { + if (pdata) { /* * Legacy platform data GPIO retrieveal. Do not expand * the use of this code path, currently only used by one @@ -126,6 +114,10 @@ static int gpio_backlight_probe(struct platform_device *pdev) gbl->gpiod = gpio_to_desc(pdata->gpio); if (!gbl->gpiod) return -EINVAL; + } else { + ret = gpio_backlight_probe_prop(pdev, gbl); + if (ret) + return ret; } memset(&props, 0, sizeof(props));