From patchwork Wed Jul 24 08:25:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 11056319 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 BC9B313B1 for ; Wed, 24 Jul 2019 08:25:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ADD94271CB for ; Wed, 24 Jul 2019 08:25:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A19DD286D0; Wed, 24 Jul 2019 08:25:55 +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=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4421E285BA for ; Wed, 24 Jul 2019 08:25:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726260AbfGXIZy (ORCPT ); Wed, 24 Jul 2019 04:25:54 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:44568 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726298AbfGXIZQ (ORCPT ); Wed, 24 Jul 2019 04:25:16 -0400 Received: by mail-wr1-f65.google.com with SMTP id p17so45902344wrf.11 for ; Wed, 24 Jul 2019 01:25:15 -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=A9RjNrSpXlzPhVNZCXaDwouPHTi7TIFzDls2JACrq3+/shRWFCWrnrspTHTM4I91jH ezoziNRBN2DQ5bIkHzan2QY0fid7sIZpj+W90xAKtLRzy5mL1NxRp24QUfHTwrqT1rfx SeS/Go55UuBU+CS4L/Z9MgOIcU0MpICJL3kpXsMK1FqUwUkjm3pjrjKWnN9Wcb/W1ITz G9DtjzD0Z+mZOITUKKR0MLN6FYml6GeYFEJSF41qOE9P9NAI8NWDod7eDWBSAbqQDWCm XQPYIUVcqWdPPTBMLGe1uOA9+MXjiuCeZ8xuvV22AGuAK2GA0lLZDJAdjh9VDaF/qDO+ a/uQ== 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=RzOf2pr14SkwgKnMnTg7rAmRGhthdKP5FK79SQY6XPU7zayVMSOl3/udSx2eJ9lXP9 N/TsArH7OdwwoZYMcW15SeiLyS3Js32Lg5BdBtkgn6++ZISNwP92jG4MVYINaOTz/LJd czpEVBbMHRqTKuxH+Y3xayywO9IceG4+lD+Q5fz8hwY3bAZJi+G/dY5AzD8YP3MQ9IKP S6nKMLrnl09HdwcAWheGclp2ZyGdCAxa3/mYk7EpQ4OkCqmGThfYDf+8dqir9sT289jN 5QIl2j8GTcU3micndh+BvAsgD/5rAOgJTBCO23Ia6NoLwrJE6e0luTEyvgk10gj0V/7S jvGw== X-Gm-Message-State: APjAAAUqZp2Qg0E36M5yrANFQwPhhoE8LDZQi4xfpurreSs6dpZqzOMF 0NVd/lmn/rQNmtY9W6Rd7nk= X-Google-Smtp-Source: APXvYqylEG+5UwTbcaSwczxEISEgX+vxsc2ZxbxeF0HClQcWNGuQkAApx11b3CnWSJnzqEygUClIyQ== X-Received: by 2002:adf:9d8b:: with SMTP id p11mr53138350wre.226.1563956714814; Wed, 24 Jul 2019 01:25:14 -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 z7sm42393880wrh.67.2019.07.24.01.25.13 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 24 Jul 2019 01:25:14 -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 v3 2/7] backlight: gpio: simplify the platform data handling Date: Wed, 24 Jul 2019 10:25:03 +0200 Message-Id: <20190724082508.27617-3-brgl@bgdev.pl> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190724082508.27617-1-brgl@bgdev.pl> References: <20190724082508.27617-1-brgl@bgdev.pl> MIME-Version: 1.0 Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Reviewed-by: Daniel Thompson Reviewed-by: Andy Shevchenko --- 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));