From patchwork Wed Apr 22 06:51:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 11503069 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 12E0414B4 for ; Wed, 22 Apr 2020 06:51:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F06E720706 for ; Wed, 22 Apr 2020 06:51:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="yjKxu2Ct" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726527AbgDVGvb (ORCPT ); Wed, 22 Apr 2020 02:51:31 -0400 Received: from lelv0143.ext.ti.com ([198.47.23.248]:46362 "EHLO lelv0143.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726423AbgDVGvb (ORCPT ); Wed, 22 Apr 2020 02:51:31 -0400 Received: from fllv0034.itg.ti.com ([10.64.40.246]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 03M6pPWY002122; Wed, 22 Apr 2020 01:51:25 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1587538285; bh=upP5WA4qSGdUri1Qc9y0c7ggU/AdA1J+HO5qhLQGGMg=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=yjKxu2Ct2Lsucn+iO0Cx6dHX4nc5q+q7QH3+CF46UZ0+of0KD4bMz00HKU9HWnx4l vBW8g3bDAr1HTrTnfLD6qZmyw5ntC5z/XhLPiGTchc2zO5W8gmbCRLUi0IsCSICJAG YCVLCY0Nb2mDq4VcnYKISzjoltBVv5Geu2q5sxmU= Received: from DLEE104.ent.ti.com (dlee104.ent.ti.com [157.170.170.34]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 03M6pPjY039981 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 22 Apr 2020 01:51:25 -0500 Received: from DLEE104.ent.ti.com (157.170.170.34) by DLEE104.ent.ti.com (157.170.170.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3; Wed, 22 Apr 2020 01:51:24 -0500 Received: from fllv0040.itg.ti.com (10.64.41.20) by DLEE104.ent.ti.com (157.170.170.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3 via Frontend Transport; Wed, 22 Apr 2020 01:51:24 -0500 Received: from deskari.lan (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id 03M6pKUX100224; Wed, 22 Apr 2020 01:51:23 -0500 From: Tomi Valkeinen To: Lee Jones , Daniel Thompson , Jingoo Han , Bartlomiej Zolnierkiewicz , , CC: Tomi Valkeinen Subject: [PATCHv3 1/4] backlight: led_bl: fix cosmetic issues Date: Wed, 22 Apr 2020 09:51:11 +0300 Message-ID: <20200422065114.22164-2-tomi.valkeinen@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200422065114.22164-1-tomi.valkeinen@ti.com> References: <20200422065114.22164-1-tomi.valkeinen@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Fix issues reported by checkpatch. No functional changes. Signed-off-by: Tomi Valkeinen Reviewed-by: Daniel Thompson --- drivers/video/backlight/led_bl.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/video/backlight/led_bl.c b/drivers/video/backlight/led_bl.c index 3f66549997c8..d4e1ce684366 100644 --- a/drivers/video/backlight/led_bl.c +++ b/drivers/video/backlight/led_bl.c @@ -126,7 +126,7 @@ static int led_bl_get_leds(struct device *dev, } static int led_bl_parse_levels(struct device *dev, - struct led_bl_data *priv) + struct led_bl_data *priv) { struct device_node *node = dev->of_node; int num_levels; @@ -148,8 +148,8 @@ static int led_bl_parse_levels(struct device *dev, return -ENOMEM; ret = of_property_read_u32_array(node, "brightness-levels", - levels, - num_levels); + levels, + num_levels); if (ret < 0) return ret; @@ -159,14 +159,15 @@ static int led_bl_parse_levels(struct device *dev, */ db = priv->default_brightness; for (i = 0 ; i < num_levels; i++) { - if ((i && db > levels[i-1]) && db <= levels[i]) + if ((i && db > levels[i - 1]) && db <= levels[i]) break; } priv->default_brightness = i; priv->max_brightness = num_levels - 1; priv->levels = levels; - } else if (num_levels >= 0) + } else if (num_levels >= 0) { dev_warn(dev, "Not enough levels defined\n"); + } ret = of_property_read_u32(node, "default-brightness-level", &value); if (!ret && value <= priv->max_brightness) @@ -208,7 +209,8 @@ static int led_bl_probe(struct platform_device *pdev) props.power = (priv->default_brightness > 0) ? FB_BLANK_POWERDOWN : FB_BLANK_UNBLANK; priv->bl_dev = backlight_device_register(dev_name(&pdev->dev), - &pdev->dev, priv, &led_bl_ops, &props); + &pdev->dev, priv, &led_bl_ops, + &props); if (IS_ERR(priv->bl_dev)) { dev_err(&pdev->dev, "Failed to register backlight\n"); return PTR_ERR(priv->bl_dev); From patchwork Wed Apr 22 06:51:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 11503071 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 B01381667 for ; Wed, 22 Apr 2020 06:51:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8F58D20775 for ; Wed, 22 Apr 2020 06:51:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="IxBNf8QB" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726423AbgDVGvc (ORCPT ); Wed, 22 Apr 2020 02:51:32 -0400 Received: from lelv0142.ext.ti.com ([198.47.23.249]:42410 "EHLO lelv0142.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726525AbgDVGvc (ORCPT ); Wed, 22 Apr 2020 02:51:32 -0400 Received: from lelv0265.itg.ti.com ([10.180.67.224]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 03M6pRcQ125681; Wed, 22 Apr 2020 01:51:27 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1587538287; bh=Zs6KQC1iefAXl+flTN8k21B4sb8ZHsnZ/WFHZcR7wUc=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=IxBNf8QBapDf+Z8CMPujF5ZZOU7y+K4A6uWXaPWq6FNAoT055+eeJiP/rHVjXTpiU jXGQisZB1g+i8c94NSmvJgYFLu9y3sIavKvxJI/uFJjj+/a/l8kMehx77VT8uJdJHV J00DWgudYGu4aWfa4spd/d5Eqst+Fvavk9KTbgEY= Received: from DLEE100.ent.ti.com (dlee100.ent.ti.com [157.170.170.30]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 03M6pQSY025177 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 22 Apr 2020 01:51:26 -0500 Received: from DLEE110.ent.ti.com (157.170.170.21) by DLEE100.ent.ti.com (157.170.170.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3; Wed, 22 Apr 2020 01:51:26 -0500 Received: from fllv0040.itg.ti.com (10.64.41.20) by DLEE110.ent.ti.com (157.170.170.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3 via Frontend Transport; Wed, 22 Apr 2020 01:51:26 -0500 Received: from deskari.lan (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id 03M6pKUY100224; Wed, 22 Apr 2020 01:51:24 -0500 From: Tomi Valkeinen To: Lee Jones , Daniel Thompson , Jingoo Han , Bartlomiej Zolnierkiewicz , , CC: Tomi Valkeinen Subject: [PATCHv3 2/4] backlight: led_bl: drop useless NULL initialization Date: Wed, 22 Apr 2020 09:51:12 +0300 Message-ID: <20200422065114.22164-3-tomi.valkeinen@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200422065114.22164-1-tomi.valkeinen@ti.com> References: <20200422065114.22164-1-tomi.valkeinen@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org There's no need to set 'levels' to NULL. Signed-off-by: Tomi Valkeinen Reviewed-by: Daniel Thompson --- drivers/video/backlight/led_bl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/video/backlight/led_bl.c b/drivers/video/backlight/led_bl.c index d4e1ce684366..c46ecdfe8b0a 100644 --- a/drivers/video/backlight/led_bl.c +++ b/drivers/video/backlight/led_bl.c @@ -140,7 +140,7 @@ static int led_bl_parse_levels(struct device *dev, if (num_levels > 1) { int i; unsigned int db; - u32 *levels = NULL; + u32 *levels; levels = devm_kzalloc(dev, sizeof(u32) * num_levels, GFP_KERNEL); From patchwork Wed Apr 22 06:51:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 11503081 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 CE6ED1667 for ; Wed, 22 Apr 2020 06:51:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B7777206D9 for ; Wed, 22 Apr 2020 06:51:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="CSfSi1e2" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726520AbgDVGvg (ORCPT ); Wed, 22 Apr 2020 02:51:36 -0400 Received: from fllv0016.ext.ti.com ([198.47.19.142]:50394 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726456AbgDVGvg (ORCPT ); Wed, 22 Apr 2020 02:51:36 -0400 Received: from fllv0035.itg.ti.com ([10.64.41.0]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 03M6pTup049515; Wed, 22 Apr 2020 01:51:29 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1587538289; bh=LskT7Fluz1afemuppgQ3E8smEknLw7ty0G3qU//E2DU=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=CSfSi1e2omadz6STW3mIOTHuOExZA8JRd3dTbM2FLxp/79zIY5MGvasnIRMrio6c9 IMaJkb+nQAYGqgqjRaHkmXzYol/uPu8TfgtTu8IhavtSib0u5F48syiRUwpZU+o5Xx s8n8qgm4/scOLFiEOiOqOUTB0fvmcaFQc3fjccEA= Received: from DFLE102.ent.ti.com (dfle102.ent.ti.com [10.64.6.23]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTP id 03M6pT5V001135; Wed, 22 Apr 2020 01:51:29 -0500 Received: from DFLE114.ent.ti.com (10.64.6.35) by DFLE102.ent.ti.com (10.64.6.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3; Wed, 22 Apr 2020 01:51:28 -0500 Received: from fllv0040.itg.ti.com (10.64.41.20) by DFLE114.ent.ti.com (10.64.6.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3 via Frontend Transport; Wed, 22 Apr 2020 01:51:28 -0500 Received: from deskari.lan (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id 03M6pKUZ100224; Wed, 22 Apr 2020 01:51:26 -0500 From: Tomi Valkeinen To: Lee Jones , Daniel Thompson , Jingoo Han , Bartlomiej Zolnierkiewicz , , CC: Tomi Valkeinen Subject: [PATCHv3 3/4] backlight: led_bl: add led_access locking Date: Wed, 22 Apr 2020 09:51:13 +0300 Message-ID: <20200422065114.22164-4-tomi.valkeinen@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200422065114.22164-1-tomi.valkeinen@ti.com> References: <20200422065114.22164-1-tomi.valkeinen@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org led_bl does not lock 'led_access' when calling led_sysfs_disable and led_sysfs_enable, causing the below WARN. Add the locking. WARNING: CPU: 0 PID: 223 at drivers/leds/led-core.c:353 led_sysfs_disable+0x4c/0x5c Signed-off-by: Tomi Valkeinen Reviewed-by: Daniel Thompson --- drivers/video/backlight/led_bl.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/video/backlight/led_bl.c b/drivers/video/backlight/led_bl.c index c46ecdfe8b0a..63693c4f0883 100644 --- a/drivers/video/backlight/led_bl.c +++ b/drivers/video/backlight/led_bl.c @@ -216,8 +216,11 @@ static int led_bl_probe(struct platform_device *pdev) return PTR_ERR(priv->bl_dev); } - for (i = 0; i < priv->nb_leds; i++) + for (i = 0; i < priv->nb_leds; i++) { + mutex_lock(&priv->leds[i]->led_access); led_sysfs_disable(priv->leds[i]); + mutex_unlock(&priv->leds[i]->led_access); + } backlight_update_status(priv->bl_dev); @@ -233,8 +236,11 @@ static int led_bl_remove(struct platform_device *pdev) backlight_device_unregister(bl); led_bl_power_off(priv); - for (i = 0; i < priv->nb_leds; i++) + for (i = 0; i < priv->nb_leds; i++) { + mutex_lock(&priv->leds[i]->led_access); led_sysfs_enable(priv->leds[i]); + mutex_unlock(&priv->leds[i]->led_access); + } return 0; } From patchwork Wed Apr 22 06:51:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 11503079 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 A59BA912 for ; Wed, 22 Apr 2020 06:51:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8D73220706 for ; Wed, 22 Apr 2020 06:51:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="ZPEj913Q" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726525AbgDVGvg (ORCPT ); Wed, 22 Apr 2020 02:51:36 -0400 Received: from fllv0015.ext.ti.com ([198.47.19.141]:42140 "EHLO fllv0015.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726520AbgDVGvg (ORCPT ); Wed, 22 Apr 2020 02:51:36 -0400 Received: from lelv0266.itg.ti.com ([10.180.67.225]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 03M6pUn3130148; Wed, 22 Apr 2020 01:51:30 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1587538290; bh=34pGNEIVX9mec7aDUBogd/7S0j9oPZJtVWJoDUjyq8A=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=ZPEj913Q6Ix4Ym9VAqlA0JUjWsjP9eO+UGbwskzLebtgjxVyb6o26O9Ka9+V3hfYz sTw6FPVvB9mViKXjFFnLZxY6SBoWhnwNDAGiF8PwJNpNHvUtGSVQT8utE0+NDa1bw0 n+/fiF2lrdSW8WGF87PigzxcaVVRXZbUOi82j6zI= Received: from DLEE106.ent.ti.com (dlee106.ent.ti.com [157.170.170.36]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 03M6pUAd099586 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 22 Apr 2020 01:51:30 -0500 Received: from DLEE113.ent.ti.com (157.170.170.24) by DLEE106.ent.ti.com (157.170.170.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3; Wed, 22 Apr 2020 01:51:30 -0500 Received: from fllv0040.itg.ti.com (10.64.41.20) by DLEE113.ent.ti.com (157.170.170.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3 via Frontend Transport; Wed, 22 Apr 2020 01:51:30 -0500 Received: from deskari.lan (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id 03M6pKUa100224; Wed, 22 Apr 2020 01:51:28 -0500 From: Tomi Valkeinen To: Lee Jones , Daniel Thompson , Jingoo Han , Bartlomiej Zolnierkiewicz , , CC: Tomi Valkeinen Subject: [PATCHv3 4/4] backlight: led_bl: fix led -> backlight brightness mapping Date: Wed, 22 Apr 2020 09:51:14 +0300 Message-ID: <20200422065114.22164-5-tomi.valkeinen@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200422065114.22164-1-tomi.valkeinen@ti.com> References: <20200422065114.22164-1-tomi.valkeinen@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org The code that maps the LED default brightness to backlight levels has two issues: 1) if the default brightness is the first backlight level (usually 0), the code fails to find it, and 2) when the code fails to find a backlight level, it ends up using max_brightness + 1 as the default brightness. Fix these two issues. Signed-off-by: Tomi Valkeinen Reviewed-by: Daniel Thompson --- drivers/video/backlight/led_bl.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/drivers/video/backlight/led_bl.c b/drivers/video/backlight/led_bl.c index 63693c4f0883..699424b111ec 100644 --- a/drivers/video/backlight/led_bl.c +++ b/drivers/video/backlight/led_bl.c @@ -139,7 +139,6 @@ static int led_bl_parse_levels(struct device *dev, num_levels = of_property_count_u32_elems(node, "brightness-levels"); if (num_levels > 1) { int i; - unsigned int db; u32 *levels; levels = devm_kzalloc(dev, sizeof(u32) * num_levels, @@ -153,15 +152,11 @@ static int led_bl_parse_levels(struct device *dev, if (ret < 0) return ret; - /* - * Try to map actual LED brightness to backlight brightness - * level - */ - db = priv->default_brightness; - for (i = 0 ; i < num_levels; i++) { - if ((i && db > levels[i - 1]) && db <= levels[i]) + /* Map LED brightness to backlight brightness level */ + for (i = 0; i < num_levels - 1; i++) + if (levels[i] >= priv->default_brightness) break; - } + priv->default_brightness = i; priv->max_brightness = num_levels - 1; priv->levels = levels;