Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3630445pxb; Mon, 24 Jan 2022 13:57:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJwP4HQYjTzvYjCt4Ezj4TwCqIjE5rb7NcESo2faZu3myLFOhIkejBTs03OBZ7tDgkQ469kr X-Received: by 2002:aa7:904d:0:b0:4bc:a970:be1 with SMTP id n13-20020aa7904d000000b004bca9700be1mr15497152pfo.65.1643061462149; Mon, 24 Jan 2022 13:57:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643061462; cv=none; d=google.com; s=arc-20160816; b=q8S/aQWW9ntSfhkd1GWMPDUxzNrKQ4nKEKLdujwOEHUlTifxc6kGkVVIUp9A9i9u27 2mFKO1pY7BilySe+AZFFfCr7UwPSMFO7yYwH589Z4eCnvDV5xj91kENSy3kjP0+jAS7b ay/Q7JFkFicvGUjiBSK+ASAj9dPZVFrLy+Vtpdg9V4UHHOh/qOfmJJN1IWNXP2Z71IAs lFH6ojbHNQndaAq93/WMClmnHbRnUhkAV6mHh+9ZXcxogWAVvNNaJRubdBJ2+CGH3xWO jRawQWLLK4MujDqI02qhd6CtAdttNSTJX8BaznFHa8npK4Lq7GcVgSDGLjrdn5pJRTZk VIpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=UOUdJgiUIUKW39BziucGFJ8DewWsDtCuUfAJIX5Rw0U=; b=Z2YB9f0/OgYEVOlcFzVjehpU5yy3gR0/7l3UNe7wpIDC3cAYzlogwZTqgCJmlxUtCu 3JrNBwpbW/cKuEKXFFcEcWfUuEEmONeH1b8rNJCkUmJxiXcQZjuBRpc2JxIwMTKYFaFp kESi6AnSERbDqwx6XTIUTtX/++HspIl8SA4PXT9hHxaPFKuYTvimbL1q9TcPMvRcadXP B6lSuK6KFxVPkZG3HvBSa0IbzuJ+0cQPg9tEPxkhIc9u5jYhJA6Hl+qx8nJg7SbyMzE+ r+JjDKtiDJEa026bv9cW3ggJ5cl61sS9o+xAwbB+IA8lfjfnDo/Zg/xFYErZo5n1wFEc 8hjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="dLEfl6T/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i17si16611830plr.151.2022.01.24.13.57.28; Mon, 24 Jan 2022 13:57:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="dLEfl6T/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1573168AbiAXVoj (ORCPT + 99 others); Mon, 24 Jan 2022 16:44:39 -0500 Received: from dfw.source.kernel.org ([139.178.84.217]:60548 "EHLO dfw.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1447263AbiAXVKU (ORCPT ); Mon, 24 Jan 2022 16:10:20 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E691261471; Mon, 24 Jan 2022 21:10:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C965CC340E5; Mon, 24 Jan 2022 21:10:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643058618; bh=O3rKWbRYROdrjBDmKSVUoul83ssFRlJvdg9Jkqbc8ek=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dLEfl6T/auMPx3D5OKUPTSKuk6SEjjwXRV963OnudoxQ+f1UGhtb0sipZKcaoPSp3 k5Gkb3Li1p0iOSO5o/oftAdjk2URuj1psXbjHLwBYk3HJYHT9MTZZ8stDPRfFoyh7c mHycLR5Ro2rPCmlbMGIrYir0J5ZUC43Sl6RMQIuE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Marijn Suijten , AngeloGioacchino Del Regno , Daniel Thompson , Lee Jones , Sasha Levin Subject: [PATCH 5.16 0348/1039] backlight: qcom-wled: Use cpu_to_le16 macro to perform conversion Date: Mon, 24 Jan 2022 19:35:37 +0100 Message-Id: <20220124184136.991896518@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Marijn Suijten [ Upstream commit 0a139358548968b2ff308257b4fbeec7badcc3e1 ] The kernel already provides appropriate primitives to perform endianness conversion which should be used in favour of manual bit-wrangling. Signed-off-by: Marijn Suijten Reviewed-by: AngeloGioacchino Del Regno Reviewed-by: Daniel Thompson Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20211115203459.1634079-4-marijn.suijten@somainline.org Signed-off-by: Sasha Levin --- drivers/video/backlight/qcom-wled.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/drivers/video/backlight/qcom-wled.c b/drivers/video/backlight/qcom-wled.c index c057368e5056e..5306b06044b4f 100644 --- a/drivers/video/backlight/qcom-wled.c +++ b/drivers/video/backlight/qcom-wled.c @@ -231,14 +231,14 @@ struct wled { static int wled3_set_brightness(struct wled *wled, u16 brightness) { int rc, i; - u8 v[2]; + __le16 v; - v[0] = brightness & 0xff; - v[1] = (brightness >> 8) & 0xf; + v = cpu_to_le16(brightness & WLED3_SINK_REG_BRIGHT_MAX); for (i = 0; i < wled->cfg.num_strings; ++i) { rc = regmap_bulk_write(wled->regmap, wled->ctrl_addr + - WLED3_SINK_REG_BRIGHT(i), v, 2); + WLED3_SINK_REG_BRIGHT(i), + &v, sizeof(v)); if (rc < 0) return rc; } @@ -250,18 +250,18 @@ static int wled4_set_brightness(struct wled *wled, u16 brightness) { int rc, i; u16 low_limit = wled->max_brightness * 4 / 1000; - u8 v[2]; + __le16 v; /* WLED4's lower limit of operation is 0.4% */ if (brightness > 0 && brightness < low_limit) brightness = low_limit; - v[0] = brightness & 0xff; - v[1] = (brightness >> 8) & 0xf; + v = cpu_to_le16(brightness & WLED3_SINK_REG_BRIGHT_MAX); for (i = 0; i < wled->cfg.num_strings; ++i) { rc = regmap_bulk_write(wled->regmap, wled->sink_addr + - WLED4_SINK_REG_BRIGHT(i), v, 2); + WLED4_SINK_REG_BRIGHT(i), + &v, sizeof(v)); if (rc < 0) return rc; } @@ -273,21 +273,20 @@ static int wled5_set_brightness(struct wled *wled, u16 brightness) { int rc, offset; u16 low_limit = wled->max_brightness * 1 / 1000; - u8 v[2]; + __le16 v; /* WLED5's lower limit is 0.1% */ if (brightness < low_limit) brightness = low_limit; - v[0] = brightness & 0xff; - v[1] = (brightness >> 8) & 0x7f; + v = cpu_to_le16(brightness & WLED5_SINK_REG_BRIGHT_MAX_15B); offset = (wled->cfg.mod_sel == MOD_A) ? WLED5_SINK_REG_MOD_A_BRIGHTNESS_LSB : WLED5_SINK_REG_MOD_B_BRIGHTNESS_LSB; rc = regmap_bulk_write(wled->regmap, wled->sink_addr + offset, - v, 2); + &v, sizeof(v)); return rc; } -- 2.34.1