Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp7295448ybi; Mon, 22 Jul 2019 10:29:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqyZLjiuL2zmf5jbMgGJseWJBNQK3IHG/t80XziXG8MqjOkT5JsIBvk7bKDuxHcA0CcZxNYh X-Received: by 2002:a17:90a:26ea:: with SMTP id m97mr78313493pje.59.1563816559705; Mon, 22 Jul 2019 10:29:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563816559; cv=none; d=google.com; s=arc-20160816; b=risQRpKWMqiHkAACGFVxt4JbVv5FSHPfGvW/ky83Fo9Uqx7H5QZvTw9ebGlLIsIG40 +8JtrPy5fXOd2ObHJPf6NPVqCpNUtU8yMwX8af9ynLj6ABMJSBYivB5D5PkRdllh9ZzY xWNU75azxyoWuDYdlO5Zdy2Q29Sl3JhOXOflvykmxacVMqRb8VUIWCiUIsf4NxUq1F4g CiFBJ2vkKSkZF1Ox8fd+MwiwUjrZtM3M1a8hjZM2SAlyW7CpfX3FCDCjDL3yirUXqhSV OOY0JJzeSE3JZHMCI+ukgHEXkFJ/n6Wirq2D8IXktmhVoW3KPZZX3KGcPHOs6Mk13z4z 9S1g== 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=8VOxOTv40kWNEJHTWrrT/jLtfVvkKD73o3YTvSQ9LmQ=; b=CfTath5aKXV6yoo9papO4SSGqAOEIHa+s9xvy2WSeQDzmZKOZ9URc6TKP/NcmQr7J1 FrgWqEnsfYX/lLkyF41AJ77WtC51UTO1fo7lqFtBWzjyrTTN9uQU3L+r30aycljnzmj8 s7b9wgZT23fZSMzEva4JnnEZ4Up5nXClNJuo8Kn5flEe79TOqNIoMoJeCX8n1Jg8wJlN jWJKeqcfziKzN48iDiDA6lMmLLfXVhvhYo/o8iyMo5U/keWwY7e3ieS5P5rNNBmWckaD 41stuHUIlKj3OufgjqBelbxcdEfY7t2mKItsVrLKrdyHVuRO6DX0aQRaEM/pAJe3Y5wz VroA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b="y/bfQV37"; 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 100si12048442pla.158.2019.07.22.10.29.03; Mon, 22 Jul 2019 10:29:19 -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="y/bfQV37"; 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 S1727627AbfGVPDp (ORCPT + 99 others); Mon, 22 Jul 2019 11:03:45 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:43417 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727090AbfGVPDT (ORCPT ); Mon, 22 Jul 2019 11:03:19 -0400 Received: by mail-wr1-f65.google.com with SMTP id p13so39751481wru.10 for ; Mon, 22 Jul 2019 08:03:18 -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=8VOxOTv40kWNEJHTWrrT/jLtfVvkKD73o3YTvSQ9LmQ=; b=y/bfQV37drOfVrF4n+Iqq4NGk+7tKntp1pEhzWKHHRbiBdgwKFn5ULWP6hZT5WjrpQ KSmH6Gwv36Cmuit2W2oi+R7e/Sse8GlHM5GCVVh3iyZ7zTuVrLZluj9cEhZ+z8ALiExU K+guiU7eeyH2GcErUOnZTfQKo1mU9soy5jkATQRCpeEZQynuPngCDIDsfB1ThYKeKBxP vXNRA4vOqomu3/g1DTfGIWUnZjmP/hmiZ5tsttLzqE/Cg5nEeIPdrV7Qw1GbqjByCHlO j32I4tBQQfldKTGkt72MjMY1rAknjvyyCqPjEy1B4FtXrrHt1tZJ/Hv00wvl4+eEmtO4 0CYg== 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=8VOxOTv40kWNEJHTWrrT/jLtfVvkKD73o3YTvSQ9LmQ=; b=d9g/Zvz3StmJ0ONf25Lw7phIzoQ3jPcv11zVL2r1f5pWUCtb/j+sd4E9dC6QILtvdn FPjFb90pnt0qpDCis0qItF4PZPtoPvu3o3+VRM3tuLfFh6Jy1jRaF+LQ5AT5YbssyPZ7 Fj6YQkUWT5Az5EEmLhHgVW/X7rTMGSI6lCiFab6Q5OLIP1uZPAj42fSyxO0DDh5cgDeQ 7TVBxC5qT9CcroJFHXWQWIDrN57Y4vvtuyGoiIACaKp6DPK92wKOftlbTorUeRR/9nec s8SJww+xFieBXgNgLTbSUFW442MyIdKm6HMv7kkSItAWgqJtYJeAWeLk/5OwS0kO37Qr RKtA== X-Gm-Message-State: APjAAAUThLNEoJC6MYOUgVOW5mvVpG1uUKRhW/z3aHiGoMlCltUnpm9d zT81yxX/rB4YsbGrdnuto5k= X-Received: by 2002:adf:ed04:: with SMTP id a4mr70026812wro.86.1563807797982; Mon, 22 Jul 2019 08:03:17 -0700 (PDT) Received: from localhost.localdomain (amontpellier-652-1-281-69.w109-210.abo.wanadoo.fr. [109.210.96.69]) by smtp.gmail.com with ESMTPSA id v23sm36310460wmj.32.2019.07.22.08.03.16 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 22 Jul 2019 08:03:17 -0700 (PDT) From: Bartosz Golaszewski To: Yoshinori Sato , Rich Felker , Lee Jones , Daniel Thompson , Jingoo Han , Bartlomiej Zolnierkiewicz , Linus Walleij , Andy Shevchenko Cc: linux-sh@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v2 2/7] backlight: gpio: simplify the platform data handling Date: Mon, 22 Jul 2019 17:02:57 +0200 Message-Id: <20190722150302.29526-3-brgl@bgdev.pl> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190722150302.29526-1-brgl@bgdev.pl> References: <20190722150302.29526-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 Now that the last user of platform data (sh ecovec24) defines a proper GPIO lookup and sets the 'default-on' device property, we can drop the platform_data-specific GPIO handling and unify a big chunk of code. The only field used from the platform data is now the fbdev pointer. Signed-off-by: Bartosz Golaszewski --- drivers/video/backlight/gpio_backlight.c | 64 +++++------------------- 1 file changed, 13 insertions(+), 51 deletions(-) diff --git a/drivers/video/backlight/gpio_backlight.c b/drivers/video/backlight/gpio_backlight.c index e84f3087e29f..01262186fa1e 100644 --- a/drivers/video/backlight/gpio_backlight.c +++ b/drivers/video/backlight/gpio_backlight.c @@ -55,30 +55,6 @@ 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) -{ - struct device *dev = &pdev->dev; - enum gpiod_flags flags; - int ret; - - 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); - if (IS_ERR(gbl->gpiod)) { - ret = PTR_ERR(gbl->gpiod); - - if (ret != -EPROBE_DEFER) { - dev_err(dev, - "Error: The gpios parameter is missing or invalid.\n"); - } - return ret; - } - - return 0; -} - static int gpio_backlight_probe(struct platform_device *pdev) { struct gpio_backlight_platform_data *pdata = @@ -86,6 +62,7 @@ static int gpio_backlight_probe(struct platform_device *pdev) struct backlight_properties props; struct backlight_device *bl; struct gpio_backlight *gbl; + enum gpiod_flags flags; int ret; gbl = devm_kzalloc(&pdev->dev, sizeof(*gbl), GFP_KERNEL); @@ -94,35 +71,20 @@ static int gpio_backlight_probe(struct platform_device *pdev) gbl->dev = &pdev->dev; - if (pdev->dev.fwnode) { - 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 - * SH board. - */ - unsigned long flags = GPIOF_DIR_OUT; - + if (pdata) gbl->fbdev = pdata->fbdev; - gbl->def_value = pdata->def_value; - flags |= gbl->def_value ? GPIOF_INIT_HIGH : GPIOF_INIT_LOW; - - ret = devm_gpio_request_one(gbl->dev, pdata->gpio, flags, - pdata ? pdata->name : "backlight"); - if (ret < 0) { - dev_err(&pdev->dev, "unable to request GPIO\n"); - return ret; + + gbl->def_value = device_property_read_bool(&pdev->dev, "default-on"); + flags = gbl->def_value ? GPIOD_OUT_HIGH : GPIOD_OUT_LOW; + + gbl->gpiod = devm_gpiod_get(&pdev->dev, NULL, flags); + if (IS_ERR(gbl->gpiod)) { + ret = PTR_ERR(gbl->gpiod); + if (ret != -EPROBE_DEFER) { + dev_err(&pdev->dev, + "Error: The gpios parameter is missing or invalid.\n"); } - gbl->gpiod = gpio_to_desc(pdata->gpio); - if (!gbl->gpiod) - return -EINVAL; - } else { - dev_err(&pdev->dev, - "failed to find platform data or device tree node.\n"); - return -ENODEV; + return ret; } memset(&props, 0, sizeof(props)); -- 2.21.0