Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp4014121ybd; Tue, 25 Jun 2019 12:27:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqzVLFl62UZbSn/tjC187MAb8RGvtjhY/hRFfEBEW4UUAMJAPoYe+cpskHe5j6zJ+kFalqz+ X-Received: by 2002:a17:90a:26ef:: with SMTP id m102mr546493pje.50.1561490841786; Tue, 25 Jun 2019 12:27:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561490841; cv=none; d=google.com; s=arc-20160816; b=iDNhq0BCYFMkXIcKwcNMc8WiD2LYbOeQGjO0PbO97IoQDL28Pug7D/GGfDxXT1P3uy 4yvLikMBuQIiNliSDr5SkNoiOOp35jRxrC2ES09cs9+ZX5ndI+jh0oiOEnkMT+Y2usJq 3THxIeNsAhbHebT6OnyfB2BrwpoMua4JX049+03Bi4sif1MoWvBN6Mw1f3Z2xLTAH230 qkj7fsqg2pFEvNyRnIHszMMkKyMwXnz+abpdHpImhLX4mtJAEtIXOE6Oe+SCJKmycLiC jkX4rGYYmabd91ILp5Lp4lejYCl+C4Zhl5h7PxjFMcnhCxP89eSqrBvaNBc1M/nyHGH3 Jr6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=2ZSWbqFAdYMHZSBHSRb1jfufvzOhyuDcLok5vmyDpAk=; b=S0xnXqlnu4XgLKkTS+erdCPXnCo90v6igmFMHZ2ojyZOsDVvrlLlxo8pGimG4mgCu1 SMd8LayMCOry9deC90mi1YYRDC0fkq3RnibLVpOVCsc3k5YRX+hePzWpXsrEYI1hXqaT SjewpN8nZYtYs5Fp+wQ6dRMBi6UNXnIRuUSuWHVrj27vMjsYR+zUKpHcqQZ3vb1rqXB1 yIXg8y1d76+Plvqo0e1Q7tMHUxR5NbZlKKp1UIOTmGbO1G6cVtq5q1Yx1F9wZl8CyhM6 LSx6wMEEJ0gR9Tw0IF+nYbe8vgaQ4uyee+vs0M5wJlqzAeKYFumfTU2bO9UImJfcmSHv L/jg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=SJOSCbrB; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f12si13136657pgs.37.2019.06.25.12.27.06; Tue, 25 Jun 2019 12:27:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=SJOSCbrB; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729607AbfFYQe5 (ORCPT + 99 others); Tue, 25 Jun 2019 12:34:57 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:42649 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728283AbfFYQez (ORCPT ); Tue, 25 Jun 2019 12:34:55 -0400 Received: by mail-wr1-f67.google.com with SMTP id x17so18601022wrl.9 for ; Tue, 25 Jun 2019 09:34:53 -0700 (PDT) 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-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=Tv16+PDfbWmpduCIg+ueO8MrQAhGCcju4pvXJPaAfVH21+U5CCVDLXYGm0t5+4IwRm mvKc+GqpV4YdtZASlk3YibHTmWvZjNEkbDfvmRWPO1S2KVnWSfbXWu1XkIhyVjrGL1oD P+peE1V4cNmAAIxUPprGgsU0SUBO7QUQGQtHnW14SfmjkXAnQGXbEfgQGpnUadFR+aLb Zyv4J3EriwQjmkkqn4RnMbMwzDOam7sFAaq28CliF3uj3j8UkYBj4TXktkuMSUPlSjBN Dmpa5MCpeFbZkUQR08i2BOJxSWh1/prbMd/FvbeEQM7VIqPnTx8Z5O+NGSBnKZfTSdIM 5WmA== X-Gm-Message-State: APjAAAV3CBEsOo5PAqvcHHDQSmxYU5feNt5rBI33Y4+9yJO9rWQfmIFr bngE4hbqDmN2ckK2TOLcW3Xb8qO0Gso= 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 Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org, Bartosz Golaszewski 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 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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)); -- 2.21.0