From patchwork Tue Oct 22 08:36:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 11203983 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 27C6C913 for ; Tue, 22 Oct 2019 08:36:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 033552089E for ; Tue, 22 Oct 2019 08:36:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20150623.gappssmtp.com header.i=@bgdev-pl.20150623.gappssmtp.com header.b="Bq+WXbKo" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731242AbfJVIgj (ORCPT ); Tue, 22 Oct 2019 04:36:39 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:40156 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726978AbfJVIgj (ORCPT ); Tue, 22 Oct 2019 04:36:39 -0400 Received: by mail-wr1-f65.google.com with SMTP id o28so16995068wro.7 for ; Tue, 22 Oct 2019 01:36:38 -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=XXUGs3TD/mQ9EDaZ43OuKw31dOCYSa+NG57KsS4H5LI=; b=Bq+WXbKond/Rk9fhT8Y+bUAcQeyz3dkHjScEjk448jWb1Cp5GqJJPCE/dB22YytQit h6rjUQWMBpc6TooG9agn4sMX+chbXQnG5/8GgY+UxdpejJgraAYrt48FfVjryUqgw14o eKxMTfkTMWm6W1yJ42/yHNIZN8oq7M3iZ8mEiAbWi4ivzIihNzO6TCeTyTQVmTlgQkKe w6GlUVEL7VzvEO8ptqVO/U2g/gEt53Lk5q/TY+E9Eno8mRgVIsykdcC0QMwT9om0FLNt R47+/7FvF2qIahLXXIjlHw8sxq2q5/N9Ji3jmmIME4Sz3qd6qMUDOxZG0TtzF9ObGur4 yPZg== 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=XXUGs3TD/mQ9EDaZ43OuKw31dOCYSa+NG57KsS4H5LI=; b=feIxSK1j29kpeBQmqOdSDwcO5pXkQzG9SL1o/Z969QmUBVS4SYtdoOOsS8LCwakF7I 2vfGoIa05aai4y/qIWP/J7SQa7+w/hQxBTLawEaB2YZXeOenq4pn5McuIhBV530MNIfZ Be21Fv0vjwWxFhLclZDLyIuF4jOA7Oka+jrwBuvRJm21k3V+6GMm2t0S9kCjJU88CkM+ VHnD3xVSQkkkLJBRl0Y118BfJ7nHxYmBYWz95GmWV/QqglRKI7dk3IG/+xr9RQq3RtlH m99o25vKrGk3iNNcChkyOcOr0AFT4QYQHQj7PA6JF0wrX7eOiJUVAEAzK3w4LQnHrdOk hj5w== X-Gm-Message-State: APjAAAW6ZFLjhs3ShlNr3DY9waH2+rBg+HxoSTxUJHwDtBm+EMZp3DBx Pbhz3D8Q55wV7DApL5xBy3rzNQ== X-Google-Smtp-Source: APXvYqxz6AIr8fWnzKdVVzEewafWfmryfrIOZCjdoeaPq7mVTlB+8VWT79OlNyvmz2Bd6kRuyVN66w== X-Received: by 2002:a5d:498a:: with SMTP id r10mr2396794wrq.129.1571733397641; Tue, 22 Oct 2019 01:36:37 -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 g17sm17115253wrq.58.2019.10.22.01.36.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2019 01:36:37 -0700 (PDT) From: Bartosz Golaszewski To: Yoshinori Sato , Rich Felker , Lee Jones , Daniel Thompson , Jingoo Han , Bartlomiej Zolnierkiewicz , Linus Walleij , Andy Shevchenko , Jacopo Mondi 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 v7 1/9] backlight: gpio: remove unneeded include Date: Tue, 22 Oct 2019 10:36:22 +0200 Message-Id: <20191022083630.28175-2-brgl@bgdev.pl> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191022083630.28175-1-brgl@bgdev.pl> References: <20191022083630.28175-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 From: Bartosz Golaszewski We no longer use any symbols from of_gpio.h. Remove this include. Signed-off-by: Bartosz Golaszewski Reviewed-by: Linus Walleij Reviewed-by: Daniel Thompson Reviewed-by: Andy Shevchenko --- drivers/video/backlight/gpio_backlight.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/video/backlight/gpio_backlight.c b/drivers/video/backlight/gpio_backlight.c index 18e053e4716c..7e1990199fae 100644 --- a/drivers/video/backlight/gpio_backlight.c +++ b/drivers/video/backlight/gpio_backlight.c @@ -12,7 +12,6 @@ #include #include #include -#include #include #include #include From patchwork Tue Oct 22 08:36: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: 11204017 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 621BC1895 for ; Tue, 22 Oct 2019 08:37:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 410D9218AE for ; Tue, 22 Oct 2019 08:37:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20150623.gappssmtp.com header.i=@bgdev-pl.20150623.gappssmtp.com header.b="dunLQ6ge" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731372AbfJVIhS (ORCPT ); Tue, 22 Oct 2019 04:37:18 -0400 Received: from mail-wm1-f68.google.com ([209.85.128.68]:56047 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387479AbfJVIgl (ORCPT ); Tue, 22 Oct 2019 04:36:41 -0400 Received: by mail-wm1-f68.google.com with SMTP id g24so6974362wmh.5 for ; Tue, 22 Oct 2019 01:36:39 -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=2xc7P6YHG166j+xVZ+q+qvlahi4iLSSnRxTtpR6znoo=; b=dunLQ6gemIPjAP14+LRlmcclJuj0+sE8QniGZlmFE08l1BlWFoQ3/YWyhzvhngeu+J dtmBlbSAa2m99suSdqj0+hnyNzLlrwshDFR2kGmSShauix4nPJOF3InPnR1y8mrqX4r0 WL0tptIRlo0DXkwgFnfzkS4P/sEbB9x+RS6chKfgD95OyHdRXNg4xNZ/5p2SvKSXXhVW dkoYqMMZqsxitmArA1FzomKEKu1XhgBnOIJv3ypzSa4fBNMGMuYJa2shWuSFjBsH2kf/ DBq3Pjy9PiZ/YTenBUFmd1ty84SsEbnThYuB02SajOxgoRHhSeja1ud5df0UmMs1+aEu Kvvg== 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=2xc7P6YHG166j+xVZ+q+qvlahi4iLSSnRxTtpR6znoo=; b=DOHbBFxZDfc15REuVLLMPodIGsNsPrgRY8hrCnWHR1M1+1hEB8FAZwNlPG7no2WTUC kzGO1FUVkX2XL4QEz7qnnrCkjMtR3svSnXLOysB52E4ZgCyGV2J4LWZ5aYppNtWY566H rNVcIPmE4tisyescro/9e2gaZL4A4xk16AyniRv0aMw/KRzjkTxTe3ZLwLUP/wYD0IB1 vvn7NNCI2QcAtChEfD/MGQy+2/jTz6U8RfTLDS5JWqJ8dlT7Z4FuK117LQCM+fc91B82 vm2cMuchnU5ojZftoRP5xE3i/9KsTwsvKReq6Bcrnws5yV0fSrACAePlarSiC2PhaPpW hlzA== X-Gm-Message-State: APjAAAUAIDoBYc3oUKGXL4zqrepu3iSdCrNOUTAK8auLkCK0ZBxgDiLh WKyhNLEx6x0Pp9wHdbyZHyhjdg== X-Google-Smtp-Source: APXvYqyy9MvnYosLqyhGfKwbAizvJ2k43MowPI9FAKwbz4NYrwbFvayyhqWxgKL+r8/O7OFc8r1k2Q== X-Received: by 2002:a7b:ce94:: with SMTP id q20mr933111wmj.130.1571733398843; Tue, 22 Oct 2019 01:36:38 -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 g17sm17115253wrq.58.2019.10.22.01.36.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2019 01:36:38 -0700 (PDT) From: Bartosz Golaszewski To: Yoshinori Sato , Rich Felker , Lee Jones , Daniel Thompson , Jingoo Han , Bartlomiej Zolnierkiewicz , Linus Walleij , Andy Shevchenko , Jacopo Mondi Cc: linux-sh@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org, Bartosz Golaszewski , Andy Shevchenko Subject: [PATCH v7 2/9] backlight: gpio: remove stray newline Date: Tue, 22 Oct 2019 10:36:23 +0200 Message-Id: <20191022083630.28175-3-brgl@bgdev.pl> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191022083630.28175-1-brgl@bgdev.pl> References: <20191022083630.28175-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 From: Bartosz Golaszewski Remove a double newline from the driver. Signed-off-by: Bartosz Golaszewski Reviewed-by: Andy Shevchenko Reviewed-by: Daniel Thompson --- drivers/video/backlight/gpio_backlight.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/video/backlight/gpio_backlight.c b/drivers/video/backlight/gpio_backlight.c index 7e1990199fae..3955b513f2f8 100644 --- a/drivers/video/backlight/gpio_backlight.c +++ b/drivers/video/backlight/gpio_backlight.c @@ -91,7 +91,6 @@ static int gpio_backlight_initial_power_state(struct gpio_backlight *gbl) return FB_BLANK_UNBLANK; } - static int gpio_backlight_probe(struct platform_device *pdev) { struct gpio_backlight_platform_data *pdata = From patchwork Tue Oct 22 08:36:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 11204011 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D62211390 for ; Tue, 22 Oct 2019 08:37:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AB5AE218AE for ; Tue, 22 Oct 2019 08:37:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20150623.gappssmtp.com header.i=@bgdev-pl.20150623.gappssmtp.com header.b="UkLVmhIa" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731373AbfJVIhS (ORCPT ); Tue, 22 Oct 2019 04:37:18 -0400 Received: from mail-wm1-f68.google.com ([209.85.128.68]:34573 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731240AbfJVIgl (ORCPT ); Tue, 22 Oct 2019 04:36:41 -0400 Received: by mail-wm1-f68.google.com with SMTP id v3so3461863wmh.1 for ; Tue, 22 Oct 2019 01:36:40 -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=OjHvv8ZdSVaFl2j34zmQMRFMhFwh+26xUwIofDUAWMQ=; b=UkLVmhIaiNsxcswxRm7saAjEeStKBBF+NXde2AaAQaH3O4OXrI2JqpEeNiYtx1tT4k O3tmDJV08ouTAT18mpcXHM49waszOD09C3kcJoqJ1K3QN1xmklwP/eU7Hi3Da1KpH6+p xHzUd7cW8tvQpL0LdK8EzIbsEydpnZXp6EgfJ09/AxanR8iqfgD2W5clxItpQ1XlxvE1 Y3NivMmlc1FI2uZ+h4mjPDpGg07DcZC5wE4UFYAR5q7HGQNTlYTFiD5P+jRs/sNoqlfW 5Afs8sR94u+Uqox3JbfZuJfuKgrV7Pd2SzSCLdqv7UzJb6rRU5U+dBwxaIfjR8LqHfw9 VMTA== 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=OjHvv8ZdSVaFl2j34zmQMRFMhFwh+26xUwIofDUAWMQ=; b=TiiBdXgPOT3iiSaK483wto0yAOC+GD1Qu0sGoD2qDvYkUfLs/sLseD4xX3hddkov9R lvL4gOIxiKOFWoHvWP8tVWz3qy8bGzhHtnrbk60LhM+BSbqYHIDJuKnhzI2W4RBE846b l3JPy65Cx9n4q1X42gr+LObPBW9a/s08OqsGgh1xamH3dBE/F8xi6xPuCMp7j6VpEeLf R6ONTVpa8XEm9RTvy2L9fRml9vCBTP+jx045cJdC/l6bDcdVkcfLvK1wcD1bWlgsGAIY FM0y60sfg0uL8yvJKW7MdIlyn7Ws0GYKg9ggKoTt2IfswcLdN+I9etG3LqjYMFAsUln1 be9w== X-Gm-Message-State: APjAAAXAUxWbYHy5zx62GaeoGegYRf7dKDmbINShrRJrJ2OjBXYDzDW8 eGf0NGSZa0GpJtkB8PxVAeQSOQ== X-Google-Smtp-Source: APXvYqwKHDyg0m8WqC6lLMl8/nhXbBRKfJRxg4+8ou9ARo5YAW/NNdc3UuYo+8foYS7XDWsI6AWPPA== X-Received: by 2002:a7b:cb03:: with SMTP id u3mr1840598wmj.126.1571733399937; Tue, 22 Oct 2019 01:36:39 -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 g17sm17115253wrq.58.2019.10.22.01.36.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2019 01:36:39 -0700 (PDT) From: Bartosz Golaszewski To: Yoshinori Sato , Rich Felker , Lee Jones , Daniel Thompson , Jingoo Han , Bartlomiej Zolnierkiewicz , Linus Walleij , Andy Shevchenko , Jacopo Mondi 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 v7 3/9] backlight: gpio: explicitly set the direction of the GPIO Date: Tue, 22 Oct 2019 10:36:24 +0200 Message-Id: <20191022083630.28175-4-brgl@bgdev.pl> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191022083630.28175-1-brgl@bgdev.pl> References: <20191022083630.28175-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 From: Bartosz Golaszewski The GPIO backlight driver currently requests the line 'as is', without acively setting its direction. This can lead to problems: if the line is in input mode by default, we won't be able to drive it later when updating the status and also reading its initial value doesn't make sense for backlight setting. Request the line 'as is' initially, so that we can read its value without affecting it but then change the direction to output explicitly when setting the initial brightness. Also: check the current direction and only read the value if it's output. Signed-off-by: Bartosz Golaszewski Reviewed-by: Daniel Thompson --- drivers/video/backlight/gpio_backlight.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/drivers/video/backlight/gpio_backlight.c b/drivers/video/backlight/gpio_backlight.c index 3955b513f2f8..52f17c9ca1c3 100644 --- a/drivers/video/backlight/gpio_backlight.c +++ b/drivers/video/backlight/gpio_backlight.c @@ -25,9 +25,8 @@ struct gpio_backlight { int def_value; }; -static int gpio_backlight_update_status(struct backlight_device *bl) +static int gpio_backlight_get_next_brightness(struct backlight_device *bl) { - struct gpio_backlight *gbl = bl_get_data(bl); int brightness = bl->props.brightness; if (bl->props.power != FB_BLANK_UNBLANK || @@ -35,6 +34,14 @@ static int gpio_backlight_update_status(struct backlight_device *bl) bl->props.state & (BL_CORE_SUSPENDED | BL_CORE_FBBLANK)) brightness = 0; + return brightness; +} + +static int gpio_backlight_update_status(struct backlight_device *bl) +{ + struct gpio_backlight *gbl = bl_get_data(bl); + int brightness = gpio_backlight_get_next_brightness(bl); + gpiod_set_value_cansleep(gbl->gpiod, brightness); return 0; @@ -85,7 +92,8 @@ static int gpio_backlight_initial_power_state(struct gpio_backlight *gbl) return gbl->def_value ? FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN; /* if the enable GPIO is disabled, do not enable the backlight */ - if (gpiod_get_value_cansleep(gbl->gpiod) == 0) + if (gpiod_get_direction(gbl->gpiod) == 0 && + gpiod_get_value_cansleep(gbl->gpiod) == 0) return FB_BLANK_POWERDOWN; return FB_BLANK_UNBLANK; @@ -98,7 +106,7 @@ static int gpio_backlight_probe(struct platform_device *pdev) struct backlight_properties props; struct backlight_device *bl; struct gpio_backlight *gbl; - int ret; + int ret, init_brightness; gbl = devm_kzalloc(&pdev->dev, sizeof(*gbl), GFP_KERNEL); if (gbl == NULL) @@ -151,7 +159,12 @@ static int gpio_backlight_probe(struct platform_device *pdev) bl->props.power = gpio_backlight_initial_power_state(gbl); bl->props.brightness = 1; - backlight_update_status(bl); + init_brightness = gpio_backlight_get_next_brightness(bl); + ret = gpiod_direction_output(gbl->gpiod, init_brightness); + if (ret) { + dev_err(&pdev->dev, "failed to set initial brightness\n"); + return ret; + } platform_set_drvdata(pdev, bl); return 0; From patchwork Tue Oct 22 08:36:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 11204001 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7C3741390 for ; Tue, 22 Oct 2019 08:37:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5A8D6218AE for ; Tue, 22 Oct 2019 08:37:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20150623.gappssmtp.com header.i=@bgdev-pl.20150623.gappssmtp.com header.b="Tyg8K1E7" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731321AbfJVIhG (ORCPT ); Tue, 22 Oct 2019 04:37:06 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:40171 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388416AbfJVIgo (ORCPT ); Tue, 22 Oct 2019 04:36:44 -0400 Received: by mail-wr1-f68.google.com with SMTP id o28so16995304wro.7 for ; Tue, 22 Oct 2019 01:36:41 -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=l2IW6NowdeBUIPfd3VNaI3dgAIYTgpRJtcprF0UeLqs=; b=Tyg8K1E7cMRcer3+lkdqXntnVHJHzQPSYcVjamEEFJC1NLQo2ieybp5MQTeXGwl/Uq zhr5KPDI5yz9T/b+emE6PSD9KM/UxQNivFwNLeZOg9zsR2gWQOGvC3tffOlSpVBYh7+t cWHjmw/HsPmptGNShMH32AAfH4DkvXiRmOdkUDl8ACoFpAPMWcP2x/kv3TYfrAp4U8Kx KXSyo2AOrh1/P94ayGaqAHg/3pHgCo3vlEyxTYmTl6Wl7eyOknXg+aVyW5O24T42gp1/ L2bVu0PeNJm20e/mIbgIRf5RozmLSZGRyVMDo/yks8vys0xy714h7zCMq2WEo25H/ef+ E4hQ== 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=l2IW6NowdeBUIPfd3VNaI3dgAIYTgpRJtcprF0UeLqs=; b=W9PQxYJB5cZIrpAcVJ0EH1t2gjBMqlIVnEyUThSaVrglN46ELW3JFKc1ChbUHA4yFo BV23JXO47Qa6eVBuVOzLz0U0xesKWKsI8dn34yPyKQEU7ec7bu0Ezzibo3RMdtdvarVo zuPOyMjdYwjTZgcnU2mAqfIKAWm/22b5k1RrvOoXl+QrQ6aXxVo1OUL9u2kiPp02+vRZ VteUkQqMNaIQZx0z339+TB/5l+PaCI6qZh1Jb6cdBGCvkZj+w0LxCAe5vU2EHJw8+Y8+ d90uG5nlSrH6dfZ+n38kpDa67kQUIBM6TNvbxS4iyJRgcHUxm9v/nfRH0e1nZhJHkynY btwA== X-Gm-Message-State: APjAAAX5PSmubDtr7LdpiLb/zjt2/SvalsTdo+RzzFanJy+lQsx9+/US jHb7V7c943ski55QErate4KOGg== X-Google-Smtp-Source: APXvYqwWQlSbpw30v85cKgMt5omU5YH11fs8JlUz5yLbRA7yJFDrCsz1qIfQZi8zu1xwIlHvVCtOTg== X-Received: by 2002:adf:f306:: with SMTP id i6mr2237564wro.209.1571733400949; Tue, 22 Oct 2019 01:36:40 -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 g17sm17115253wrq.58.2019.10.22.01.36.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2019 01:36:40 -0700 (PDT) From: Bartosz Golaszewski To: Yoshinori Sato , Rich Felker , Lee Jones , Daniel Thompson , Jingoo Han , Bartlomiej Zolnierkiewicz , Linus Walleij , Andy Shevchenko , Jacopo Mondi 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 v7 4/9] sh: ecovec24: add additional properties to the backlight device Date: Tue, 22 Oct 2019 10:36:25 +0200 Message-Id: <20191022083630.28175-5-brgl@bgdev.pl> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191022083630.28175-1-brgl@bgdev.pl> References: <20191022083630.28175-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 From: Bartosz Golaszewski Add a GPIO lookup entry and a device property for GPIO backlight to the board file. Tie them to the platform device which is now registered using platform_device_register_full() because of the properties. These changes are inactive now but will be used once the gpio backlight driver is modified. Signed-off-by: Bartosz Golaszewski Reviewed-by: Andy Shevchenko Reviewed-by: Linus Walleij --- arch/sh/boards/mach-ecovec24/setup.c | 30 +++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/arch/sh/boards/mach-ecovec24/setup.c b/arch/sh/boards/mach-ecovec24/setup.c index acaa97459531..aaa8ea62636f 100644 --- a/arch/sh/boards/mach-ecovec24/setup.c +++ b/arch/sh/boards/mach-ecovec24/setup.c @@ -371,6 +371,19 @@ static struct platform_device lcdc_device = { }, }; +static struct gpiod_lookup_table gpio_backlight_lookup = { + .dev_id = "gpio-backlight.0", + .table = { + GPIO_LOOKUP("sh7724_pfc", GPIO_PTR1, NULL, GPIO_ACTIVE_HIGH), + { } + }, +}; + +static struct property_entry gpio_backlight_props[] = { + PROPERTY_ENTRY_BOOL("default-on"), + { } +}; + static struct gpio_backlight_platform_data gpio_backlight_data = { .fbdev = &lcdc_device.dev, .gpio = GPIO_PTR1, @@ -378,13 +391,15 @@ static struct gpio_backlight_platform_data gpio_backlight_data = { .name = "backlight", }; -static struct platform_device gpio_backlight_device = { +static const struct platform_device_info gpio_backlight_device_info = { .name = "gpio-backlight", - .dev = { - .platform_data = &gpio_backlight_data, - }, + .data = &gpio_backlight_data, + .size_data = sizeof(gpio_backlight_data), + .properties = gpio_backlight_props, }; +static struct platform_device *gpio_backlight_device; + /* CEU0 */ static struct ceu_platform_data ceu0_pdata = { .num_subdevs = 2, @@ -1006,7 +1021,6 @@ static struct platform_device *ecovec_devices[] __initdata = { &usb1_common_device, &usbhs_device, &lcdc_device, - &gpio_backlight_device, &keysc_device, &cn12_power, #if defined(CONFIG_MMC_SDHI) || defined(CONFIG_MMC_SDHI_MODULE) @@ -1462,6 +1476,12 @@ static int __init arch_setup(void) #endif #endif + gpiod_add_lookup_table(&gpio_backlight_lookup); + gpio_backlight_device = platform_device_register_full( + &gpio_backlight_device_info); + if (IS_ERR(gpio_backlight_device)) + return PTR_ERR(gpio_backlight_device); + return platform_add_devices(ecovec_devices, ARRAY_SIZE(ecovec_devices)); } From patchwork Tue Oct 22 08:36:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 11204005 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 160921951 for ; Tue, 22 Oct 2019 08:37:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E8BBE218AE for ; Tue, 22 Oct 2019 08:37:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20150623.gappssmtp.com header.i=@bgdev-pl.20150623.gappssmtp.com header.b="R0kpfQV0" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731344AbfJVIhH (ORCPT ); Tue, 22 Oct 2019 04:37:07 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:38579 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388407AbfJVIgo (ORCPT ); Tue, 22 Oct 2019 04:36:44 -0400 Received: by mail-wr1-f65.google.com with SMTP id v9so5744358wrq.5 for ; Tue, 22 Oct 2019 01:36:42 -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=kvQLRHJvRjudaJXCpLtV7CQx5y9VARSzzzMBbffwoBQ=; b=R0kpfQV0jZYq2r/gSdB59v/D7Ky/qC7QBaqd8jFL5iqpVaB7HbudHuRs3k/Du5yZrv RtLp9RXnK3Ac6JBmGc61233Jzc3czDf1nZkMp74sB5QkgfhDFSpXYx4SG6FF6KNOAcvK /xnwnzv9ysxeUNTqHWANmB+wu32P67SBprPLFSGNL0FSwskPlqDpo/ZF5YXHYp77tP89 ruPFvimpaR67SUNYOCzZLwoadfWEfB1p5iS/pd3brQsJSi7qoQpOZFfXaEzQTRwn+V6Z JPHXS9Y72JOkuFLWYupTjAv/kuwlsgyMZ9/CdzY8lCwE8KVEsY8bW6MoCWUxYQsh6ztg 9TeA== 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=kvQLRHJvRjudaJXCpLtV7CQx5y9VARSzzzMBbffwoBQ=; b=pPOEPWpaCeRV2H39EUfkQ8B0tlcMFq0b04PIjoi9VJFzZZ7QhDXABXEkS8M4u7ERPF AVw/a0si20nsEiXz8dIklKjJrFvXhfOPOfXKY8Ss+WyfwTajZrzLqQe+2ouhiV5Ug7Z6 D2j+6kOhKZxqRMjutPIlCeXBBBU7DYZNrOXx5rkDI0caRp4oaaiWViWBqk9mhSBnbtZt rGphs2ZIbTCBk+AdnFqxwlbKrQjrJ1qc7OUpfttsoxY2oqZjPgvotlrBRI8dZejXQUsC xMAS7r5ohDYQgApetAFFtyhGaM5oH1u0zJypvyHnVNnzecVZVgNZY3/FV2b1/+0HxEz6 3FHg== X-Gm-Message-State: APjAAAVNg3UAgX7wGdC0boJ9YO8+Q2Mlm4zzD576Gps2rC/vw//zuSYS jHRJZw+oM/bS5vEtvHxgPoECdA== X-Google-Smtp-Source: APXvYqyaselYLV/0dnxVgvDBqTCkwoVW8/nREL08BhLjGuMEQBFszR2zj3NmBAPYQD7CNxTVF2VrFw== X-Received: by 2002:adf:fb0b:: with SMTP id c11mr2450846wrr.50.1571733401978; Tue, 22 Oct 2019 01:36:41 -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 g17sm17115253wrq.58.2019.10.22.01.36.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2019 01:36:41 -0700 (PDT) From: Bartosz Golaszewski To: Yoshinori Sato , Rich Felker , Lee Jones , Daniel Thompson , Jingoo Han , Bartlomiej Zolnierkiewicz , Linus Walleij , Andy Shevchenko , Jacopo Mondi 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 v7 5/9] backlight: gpio: simplify the platform data handling Date: Tue, 22 Oct 2019 10:36:26 +0200 Message-Id: <20191022083630.28175-6-brgl@bgdev.pl> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191022083630.28175-1-brgl@bgdev.pl> References: <20191022083630.28175-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 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: Linus Walleij Reviewed-by: Daniel Thompson Reviewed-by: Andy Shevchenko --- drivers/video/backlight/gpio_backlight.c | 62 +++++------------------- 1 file changed, 11 insertions(+), 51 deletions(-) diff --git a/drivers/video/backlight/gpio_backlight.c b/drivers/video/backlight/gpio_backlight.c index 52f17c9ca1c3..ddc7d3b288b7 100644 --- a/drivers/video/backlight/gpio_backlight.c +++ b/drivers/video/backlight/gpio_backlight.c @@ -6,7 +6,6 @@ #include #include #include -#include /* Only for legacy support */ #include #include #include @@ -61,28 +60,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; - int ret; - - gbl->def_value = device_property_read_bool(dev, "default-on"); - - gbl->gpiod = devm_gpiod_get(dev, NULL, GPIOD_ASIS); - 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_initial_power_state(struct gpio_backlight *gbl) { struct device_node *node = gbl->dev->of_node; @@ -114,35 +91,18 @@ 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->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; + + gbl->def_value = device_property_read_bool(&pdev->dev, "default-on"); + + gbl->gpiod = devm_gpiod_get(&pdev->dev, NULL, GPIOD_ASIS); + 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"); + return ret; } memset(&props, 0, sizeof(props)); From patchwork Tue Oct 22 08:36:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 11203997 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8E9B71895 for ; Tue, 22 Oct 2019 08:36:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6D0D221872 for ; Tue, 22 Oct 2019 08:36:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20150623.gappssmtp.com header.i=@bgdev-pl.20150623.gappssmtp.com header.b="KOwac6lX" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731270AbfJVIgp (ORCPT ); Tue, 22 Oct 2019 04:36:45 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:52719 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388297AbfJVIgo (ORCPT ); Tue, 22 Oct 2019 04:36:44 -0400 Received: by mail-wm1-f65.google.com with SMTP id r19so16178895wmh.2 for ; Tue, 22 Oct 2019 01:36:43 -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=YdPiqrMx4DGxjMQly7Bs8yH/i3WsBA2bl/JSPtLQAlU=; b=KOwac6lXMvPzKQbGfVwOeuk/E80ZqaFmm5zXdBDTyds3/Js1pcVarjfBKCxKxF4H4u apUS5rMwuujrjZOQ6a7IQDxC0iyQLPSGSGwrYdpQjpsq7nau7MJt9PMGqZK1CZKlzxoe wXTFpQYR0kUsTC3gLtwmTju8gYiqmU3FUT5hm+NQIg5jPw8aJqxilt2wa7hEuyhgiTfs KG+V8Zdlm+SKT/bF1hR7zWuVljXx8qWrPmanQNX4oy78eIqIv5k9BZpOwQd+5v9+Azif Lc7blMT/nujxMIz8oqLpcJ//JXiXSXA18vogHoVObQ0yZZY1QWE3XLU1BfuskLL3xezj YR8Q== 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=YdPiqrMx4DGxjMQly7Bs8yH/i3WsBA2bl/JSPtLQAlU=; b=oZaG+4O93KIcanOTl4gMso5aVNa933KFGQ+DR4P5qZeYfq3U0TFFIWtSe0RlLuk/DL bx/kGWXHsiovcKzt/et2DbcVGzoz/1Ff6OoF31jhbdbVTy+H777M4geEBLmoaLRPulam yoaY+PMZnNV5HsBlTqu7Pu3P+wfR3EcbbcxQhRdV0wntmX0JiWWs5PrtLltlVStTwIjt EeX8mPhDxaMZVDBztzrvOEB6ekDV8r8BSIxBiaalEDh5r5zr4Ufxa7Rmxh94qBcQLbBb cxwtTb1znDrt/EKsrUD0AtR5KT3aHWPIHEmwK5hN6hY7GyklTsWj1uytAl5Fsnq06jtD FFjQ== X-Gm-Message-State: APjAAAUK3Zl9xKUnHrTS+uFnTlWtDUApRvrhqtj4ke6So4UACSHE0VCd e9Po3w4UW5FlHgZRWeVET1nD2g== X-Google-Smtp-Source: APXvYqzrOTy8tDKT2zZ6P5R14GHkgBj65AvHBPBErhOvZSksyq4orZqQnZgOBg6C1rMPoItuIr/Dgg== X-Received: by 2002:a1c:2986:: with SMTP id p128mr280566wmp.173.1571733403089; Tue, 22 Oct 2019 01:36:43 -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 g17sm17115253wrq.58.2019.10.22.01.36.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2019 01:36:42 -0700 (PDT) From: Bartosz Golaszewski To: Yoshinori Sato , Rich Felker , Lee Jones , Daniel Thompson , Jingoo Han , Bartlomiej Zolnierkiewicz , Linus Walleij , Andy Shevchenko , Jacopo Mondi 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 v7 6/9] sh: ecovec24: don't set unused fields in platform data Date: Tue, 22 Oct 2019 10:36:27 +0200 Message-Id: <20191022083630.28175-7-brgl@bgdev.pl> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191022083630.28175-1-brgl@bgdev.pl> References: <20191022083630.28175-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 From: Bartosz Golaszewski Platform data fields other than fbdev are no longer used by the backlight driver. Remove them. Signed-off-by: Bartosz Golaszewski Reviewed-by: Andy Shevchenko Reviewed-by: Linus Walleij --- arch/sh/boards/mach-ecovec24/setup.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/arch/sh/boards/mach-ecovec24/setup.c b/arch/sh/boards/mach-ecovec24/setup.c index aaa8ea62636f..dd427bac5cde 100644 --- a/arch/sh/boards/mach-ecovec24/setup.c +++ b/arch/sh/boards/mach-ecovec24/setup.c @@ -386,9 +386,6 @@ static struct property_entry gpio_backlight_props[] = { static struct gpio_backlight_platform_data gpio_backlight_data = { .fbdev = &lcdc_device.dev, - .gpio = GPIO_PTR1, - .def_value = 1, - .name = "backlight", }; static const struct platform_device_info gpio_backlight_device_info = { From patchwork Tue Oct 22 08:36:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 11203989 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 721541951 for ; Tue, 22 Oct 2019 08:36:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5145321872 for ; Tue, 22 Oct 2019 08:36:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20150623.gappssmtp.com header.i=@bgdev-pl.20150623.gappssmtp.com header.b="Fl1qTLhB" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731296AbfJVIgs (ORCPT ); Tue, 22 Oct 2019 04:36:48 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:36999 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731281AbfJVIgr (ORCPT ); Tue, 22 Oct 2019 04:36:47 -0400 Received: by mail-wr1-f65.google.com with SMTP id e11so8290543wrv.4 for ; Tue, 22 Oct 2019 01:36:44 -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=fJb9zTJUFk5gt04WV606l1pH2Oso/m6U1KjJZ/jsQAQ=; b=Fl1qTLhBQubCYTQvRFZGlqbpTFflj9tu3q08e1MlJzphl6MWRcspjYmiPTZQO2Nj6m L8FuqvAa/MmSqZfgRT8BK0odPTKh92doGHJtbxLFNYQ3Jq2IqO3h+/SX7sLrKDVjoZtO NcsW0dTxbzZRRQW+zVYC1/6FTVbUgWunR1cAtZ3QCODI0ZCAAS2VbKr/ZExzWJTjRnsS KZLvPQUIrnpg2BtCQrB5jK7IDHSB+/Xb4so9Es0sPAL3l52ve8BH3H/ygjsm0WkUjgPo z2OAjaxIvLaCP34M2mpYEXRyVWyNDFawxbs0agydIqrrRAhnwOhSTieVDVfZL8yBb/J3 YAug== 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=fJb9zTJUFk5gt04WV606l1pH2Oso/m6U1KjJZ/jsQAQ=; b=H8GU+qKrDeV40y10urCzxdCBTfAq06DpLuuo86xn68PRbqv4TuBCD78pTCjOeytSge UE+qiEltuzqvYHRal4tWVKPjQpeETAOndwuapuwOZ1VGItyt3dQd08nDPbLOr5V8CA8C YUV+O/Q74bw4s96ejPYdLTIUoLYjXC7oVc7eHisPP1fgFRKlV8e9BiGHn0//zx9LSPtd r99Te+9F7zT5Tv3zSoy3V03h+Mcxc2bVWShirDCJJUD7OcgK5fQsU2lyXtdradupaNse RCvwdoKPEydFYjwVdV9edOLaxWTYq89pyj99sMGNNG+mskv3CJVBRUdWhkSk5wKwCuhr 2XYw== X-Gm-Message-State: APjAAAXEwf2klkULl5hCcduKYgz5BpQc8OBq6CumtYQWGQdHOYgg2aDh CfWsWbLjJfHxxd79S0bnsxXdzQ== X-Google-Smtp-Source: APXvYqw+u7/kRo/kyLMNI3vyXRrtnO/cCP4ewAM9p5Okg1CflyD/yuwcP6eDPcrZB/Mod7dBy1vY5g== X-Received: by 2002:a5d:44c8:: with SMTP id z8mr2324652wrr.66.1571733404239; Tue, 22 Oct 2019 01:36:44 -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 g17sm17115253wrq.58.2019.10.22.01.36.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2019 01:36:43 -0700 (PDT) From: Bartosz Golaszewski To: Yoshinori Sato , Rich Felker , Lee Jones , Daniel Thompson , Jingoo Han , Bartlomiej Zolnierkiewicz , Linus Walleij , Andy Shevchenko , Jacopo Mondi 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 v7 7/9] backlight: gpio: remove unused fields from platform data Date: Tue, 22 Oct 2019 10:36:28 +0200 Message-Id: <20191022083630.28175-8-brgl@bgdev.pl> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191022083630.28175-1-brgl@bgdev.pl> References: <20191022083630.28175-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 From: Bartosz Golaszewski Remove the platform data fields that nobody uses. Signed-off-by: Bartosz Golaszewski Reviewed-by: Andy Shevchenko Reviewed-by: Linus Walleij Reviewed-by: Daniel Thompson --- include/linux/platform_data/gpio_backlight.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/include/linux/platform_data/gpio_backlight.h b/include/linux/platform_data/gpio_backlight.h index 34179d600360..1a8b5b1946fe 100644 --- a/include/linux/platform_data/gpio_backlight.h +++ b/include/linux/platform_data/gpio_backlight.h @@ -9,9 +9,6 @@ struct device; struct gpio_backlight_platform_data { struct device *fbdev; - int gpio; - int def_value; - const char *name; }; #endif From patchwork Tue Oct 22 08:36:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 11203995 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 62D4A1390 for ; Tue, 22 Oct 2019 08:36:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3746521872 for ; Tue, 22 Oct 2019 08:36:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20150623.gappssmtp.com header.i=@bgdev-pl.20150623.gappssmtp.com header.b="hD0eu+rm" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731299AbfJVIgu (ORCPT ); Tue, 22 Oct 2019 04:36:50 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:54365 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731293AbfJVIgs (ORCPT ); Tue, 22 Oct 2019 04:36:48 -0400 Received: by mail-wm1-f65.google.com with SMTP id p7so16172923wmp.4 for ; Tue, 22 Oct 2019 01:36:46 -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=BBwZAII4c+j90JuEwELJfoaTgwb4BYo/J/e6zDQv4+M=; b=hD0eu+rm2rnCFP73+AbIhyRwxjhgqFh+hxza/N1Idk4VUi0QtJM+GfN7gVPGjp4Z4j YUkIjUCh6x9nODKYqHv9hvjSprCJ99Tc1ygodmf5Oy3gnM2wClvINYUqlylplYGSvlZd eMXOa5fLbLu7NDm6e4U2VJQbpFkgloMODo+Fmpun0J973i9Vd55dDrlWsbC8zAV7prPc aHukaKYQxUSENUEHMncEtx7x/4n3KGxNxRnwfTzL//vvn5oKk99CynyMKx5Mu2+oXmgF GQYRa839XdpCQpq+MGMfkGfbdHXXJvz9W7M6sf+AGI+dYNjDZsbgsvRFuahEdRX4M6hQ tjqg== 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=BBwZAII4c+j90JuEwELJfoaTgwb4BYo/J/e6zDQv4+M=; b=s6jrU1HKDV+YP7L+7Jot0if9iDSqvMW++Ui3zaCyIMPcbmuXpMqfq13kH3VfUs6Qrv XnGCYSgWtWJ1DNKh4hixZzrAWOZQELmP4dxfBKwywZ9wbmMQiaKr41m3wDuQWGWo7RhF S45+hEOMJhOMCdZpKF7NYstXUD0zXGr0B2x4W70ATkEYfrVD1jPP00b9Vi2DcnxCVDAa qt25AhPVgxMqMDhWNS5nsJDwKbfMrX353KqgK11ojp8SPLrf/a7u5I6Cdfoe8liULrsm AFLr5AGUwyBj4VwiLn6YqwlNZ7xGoB22/KLv6vqfnyRg8CwBCZfRbzgE7dclLBsS5/G/ uYTg== X-Gm-Message-State: APjAAAUsUJfPTkLGbRRp+rR8kojKrl/tf/k6zSXt+9Xp2ZobAzPgSAPg TSuCk0xr4GJf7ZqnGTqWB7edVw== X-Google-Smtp-Source: APXvYqxzDA6PjDB8+VXbMfmE9gebpUr/TSL5Jz2YOoPBEyJhJx7o6yy2RVS6GyJDputcJKjnWi9muA== X-Received: by 2002:a05:600c:21c8:: with SMTP id x8mr1724605wmj.123.1571733405470; Tue, 22 Oct 2019 01:36:45 -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 g17sm17115253wrq.58.2019.10.22.01.36.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2019 01:36:44 -0700 (PDT) From: Bartosz Golaszewski To: Yoshinori Sato , Rich Felker , Lee Jones , Daniel Thompson , Jingoo Han , Bartlomiej Zolnierkiewicz , Linus Walleij , Andy Shevchenko , Jacopo Mondi 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 v7 8/9] backlight: gpio: use a helper variable for &pdev->dev Date: Tue, 22 Oct 2019 10:36:29 +0200 Message-Id: <20191022083630.28175-9-brgl@bgdev.pl> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191022083630.28175-1-brgl@bgdev.pl> References: <20191022083630.28175-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 From: Bartosz Golaszewski Instead of dereferencing pdev each time, use a helper variable for the associated device pointer. Signed-off-by: Bartosz Golaszewski Reviewed-by: Linus Walleij Reviewed-by: Daniel Thompson Reviewed-by: Andy Shevchenko --- drivers/video/backlight/gpio_backlight.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/drivers/video/backlight/gpio_backlight.c b/drivers/video/backlight/gpio_backlight.c index ddc7d3b288b7..d6969fae25cd 100644 --- a/drivers/video/backlight/gpio_backlight.c +++ b/drivers/video/backlight/gpio_backlight.c @@ -78,29 +78,29 @@ static int gpio_backlight_initial_power_state(struct gpio_backlight *gbl) static int gpio_backlight_probe(struct platform_device *pdev) { - struct gpio_backlight_platform_data *pdata = - dev_get_platdata(&pdev->dev); + struct device *dev = &pdev->dev; + struct gpio_backlight_platform_data *pdata = dev_get_platdata(dev); struct backlight_properties props; struct backlight_device *bl; struct gpio_backlight *gbl; int ret, init_brightness; - gbl = devm_kzalloc(&pdev->dev, sizeof(*gbl), GFP_KERNEL); + gbl = devm_kzalloc(dev, sizeof(*gbl), GFP_KERNEL); if (gbl == NULL) return -ENOMEM; - gbl->dev = &pdev->dev; + gbl->dev = dev; if (pdata) gbl->fbdev = pdata->fbdev; - gbl->def_value = device_property_read_bool(&pdev->dev, "default-on"); + gbl->def_value = device_property_read_bool(dev, "default-on"); - gbl->gpiod = devm_gpiod_get(&pdev->dev, NULL, GPIOD_ASIS); + gbl->gpiod = devm_gpiod_get(dev, NULL, GPIOD_ASIS); if (IS_ERR(gbl->gpiod)) { ret = PTR_ERR(gbl->gpiod); if (ret != -EPROBE_DEFER) - dev_err(&pdev->dev, + dev_err(dev, "Error: The gpios parameter is missing or invalid.\n"); return ret; } @@ -108,11 +108,10 @@ static int gpio_backlight_probe(struct platform_device *pdev) memset(&props, 0, sizeof(props)); props.type = BACKLIGHT_RAW; props.max_brightness = 1; - bl = devm_backlight_device_register(&pdev->dev, dev_name(&pdev->dev), - &pdev->dev, gbl, &gpio_backlight_ops, - &props); + bl = devm_backlight_device_register(dev, dev_name(dev), dev, gbl, + &gpio_backlight_ops, &props); if (IS_ERR(bl)) { - dev_err(&pdev->dev, "failed to register backlight\n"); + dev_err(dev, "failed to register backlight\n"); return PTR_ERR(bl); } @@ -122,7 +121,7 @@ static int gpio_backlight_probe(struct platform_device *pdev) init_brightness = gpio_backlight_get_next_brightness(bl); ret = gpiod_direction_output(gbl->gpiod, init_brightness); if (ret) { - dev_err(&pdev->dev, "failed to set initial brightness\n"); + dev_err(dev, "failed to set initial brightness\n"); return ret; } From patchwork Tue Oct 22 08:36:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 11203999 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D2A871390 for ; Tue, 22 Oct 2019 08:37:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B0CDF218AE for ; Tue, 22 Oct 2019 08:37:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20150623.gappssmtp.com header.i=@bgdev-pl.20150623.gappssmtp.com header.b="cRsmk4mL" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731291AbfJVIgy (ORCPT ); Tue, 22 Oct 2019 04:36:54 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:42139 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731292AbfJVIgs (ORCPT ); Tue, 22 Oct 2019 04:36:48 -0400 Received: by mail-wr1-f65.google.com with SMTP id r1so7197454wrs.9 for ; Tue, 22 Oct 2019 01:36:47 -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=FtPUzVzlAqT3akLPjsGT7UZcGZsyWgLA88Ro+E/PyfY=; b=cRsmk4mLpvgTbx4wEvgiHZaS1tLjsi0aF4JnsopyLgGpmMEMXnYMLhL0fm42GgI70y XxnfMH3CqbAyZg/O28PEX1LVz/cHnOYtZeRaqgFupY16Ayblq54JIE+7se+NvkqVt4oJ rkrxZ4BEApr0w4Dl3bAbBNkrY4RDZDZQpIycsjrwkQAO2F/MxhV9jR84PqF1GCpkRfeh zUkdh3b9QBQK0qOuXbpHsQZnpHrQZTJZWgdHKh8+ww/7BucydSG0km7QHTDo5rZXH4IS oNR3yf1g5/XZwlKXuint/5h8UkFzAzNVIWxFNvA19Z4MTNamZGDKDsLdpg3A/rwF8i0m iAYA== 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=FtPUzVzlAqT3akLPjsGT7UZcGZsyWgLA88Ro+E/PyfY=; b=O1WDsUvOMMIhR/QJ0vwZwMsz4A0JYHZ0h0+dNHpqBCiEGYeyqVQ0tsPSiXQigUQ3kl SQzT+KiWgQhr4uIVpWLAMoooIrUoJ1zCWEKlbwEMc0c85G2tahqWfjuEf9kC3JmLMLYe dbqWK88bp8hl4OBwAG3YRUs2hWIs9QrXsxNw4QA4Qu/5MVBhlLdmxB2ElB8G6Q9rbEzw EwylC8SdyWsboVdlSo3A6H07bsp+dPQXrylyXurRXSn5Cx+ckHidaZYYyymKfbkW+mcq bTjG5gwG4humbqQAEmNPs6PPu+Gvs92XnYLBjyrMMuqOej2hAaobWMKcH5Ldup30R3gi nVAQ== X-Gm-Message-State: APjAAAUig4VxxcyQvMCVWORyczWZCpKgq+rn3uQaLVqrRYdWH+MCiAOH AoRLpsq4u+OgQEv9SCJlse8gKw== X-Google-Smtp-Source: APXvYqyYvlPaTxYAVAqEdEsldeXrdmZ2pBJNeH+VuyZo6XrzBLOioU2qWHTeegUuyOqUciCp3tgmCA== X-Received: by 2002:a5d:694a:: with SMTP id r10mr2335737wrw.117.1571733406592; Tue, 22 Oct 2019 01:36:46 -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 g17sm17115253wrq.58.2019.10.22.01.36.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2019 01:36:46 -0700 (PDT) From: Bartosz Golaszewski To: Yoshinori Sato , Rich Felker , Lee Jones , Daniel Thompson , Jingoo Han , Bartlomiej Zolnierkiewicz , Linus Walleij , Andy Shevchenko , Jacopo Mondi 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 v7 9/9] backlight: gpio: pull gpio_backlight_initial_power_state() into probe Date: Tue, 22 Oct 2019 10:36:30 +0200 Message-Id: <20191022083630.28175-10-brgl@bgdev.pl> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191022083630.28175-1-brgl@bgdev.pl> References: <20191022083630.28175-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 From: Bartosz Golaszewski The probe function in the gpio-backlight driver is quite short. If we pull gpio_backlight_initial_power_state() into probe we can drop two more fields from struct gpio_backlight and shrink the driver code. Signed-off-by: Bartosz Golaszewski Acked-by: Daniel Thompson --- drivers/video/backlight/gpio_backlight.c | 38 +++++++++--------------- 1 file changed, 14 insertions(+), 24 deletions(-) diff --git a/drivers/video/backlight/gpio_backlight.c b/drivers/video/backlight/gpio_backlight.c index d6969fae25cd..75409ddfba3e 100644 --- a/drivers/video/backlight/gpio_backlight.c +++ b/drivers/video/backlight/gpio_backlight.c @@ -17,11 +17,8 @@ #include struct gpio_backlight { - struct device *dev; struct device *fbdev; - struct gpio_desc *gpiod; - int def_value; }; static int gpio_backlight_get_next_brightness(struct backlight_device *bl) @@ -60,41 +57,24 @@ static const struct backlight_ops gpio_backlight_ops = { .check_fb = gpio_backlight_check_fb, }; -static int gpio_backlight_initial_power_state(struct gpio_backlight *gbl) -{ - struct device_node *node = gbl->dev->of_node; - - /* Not booted with device tree or no phandle link to the node */ - if (!node || !node->phandle) - return gbl->def_value ? FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN; - - /* if the enable GPIO is disabled, do not enable the backlight */ - if (gpiod_get_direction(gbl->gpiod) == 0 && - gpiod_get_value_cansleep(gbl->gpiod) == 0) - return FB_BLANK_POWERDOWN; - - return FB_BLANK_UNBLANK; -} - static int gpio_backlight_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct gpio_backlight_platform_data *pdata = dev_get_platdata(dev); + struct device_node *of_node = dev->of_node; struct backlight_properties props; struct backlight_device *bl; struct gpio_backlight *gbl; - int ret, init_brightness; + int ret, init_brightness, def_value; gbl = devm_kzalloc(dev, sizeof(*gbl), GFP_KERNEL); if (gbl == NULL) return -ENOMEM; - gbl->dev = dev; - if (pdata) gbl->fbdev = pdata->fbdev; - gbl->def_value = device_property_read_bool(dev, "default-on"); + def_value = device_property_read_bool(dev, "default-on"); gbl->gpiod = devm_gpiod_get(dev, NULL, GPIOD_ASIS); if (IS_ERR(gbl->gpiod)) { @@ -115,7 +95,17 @@ static int gpio_backlight_probe(struct platform_device *pdev) return PTR_ERR(bl); } - bl->props.power = gpio_backlight_initial_power_state(gbl); + /* Set the initial power state */ + if (!of_node || !of_node->phandle) + /* Not booted with device tree or no phandle link to the node */ + bl->props.power = def_value ? FB_BLANK_UNBLANK + : FB_BLANK_POWERDOWN; + else if (gpiod_get_direction(gbl->gpiod) == 0 && + gpiod_get_value_cansleep(gbl->gpiod) == 0) + bl->props.power = FB_BLANK_POWERDOWN; + else + bl->props.power = FB_BLANK_UNBLANK; + bl->props.brightness = 1; init_brightness = gpio_backlight_get_next_brightness(bl);