From patchwork Thu Jun 22 16:12:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Chancellor X-Patchwork-Id: 13289380 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D2488EB64D8 for ; Thu, 22 Jun 2023 16:13:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:Message-Id:MIME-Version:Subject: Date:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=eJLaIBLbfATFOl7Umaa/767AxMlmInWm78uLXTfbboo=; b=yIwjbf44TbtDrF aG5/0o7bXRMNM0saZJ96x+17Uoursqu3ajK1uYK7qEOKOAU/kM29x0uxpQKkw56k1WgXxjYb+15hT 2Yr6gBqpcvRmHLdySxCcj8N3mPa8fxnMv9pBbJByNPg+bbDTolZiQ+zyvWxReYu3g/u4+g+qJqiKO naKWoOrN88KUQ1rEcuJZ59nI2w5LBXM6e0BWIggoBs+hss6Kztzz4tPnW+hruTlaBq/Nrp+yMv2TK W6GgsM2dELUsUanXmv/XZOKwYP6YUldeV27tC60YDDRGA9vCKVVMU/fYQicrNJymOsEaUCwhj/eks P4UA1tcHbSU9wwzv4nvA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qCMvb-001CXx-3B; Thu, 22 Jun 2023 16:12:59 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qCMvY-001CXS-2D; Thu, 22 Jun 2023 16:12:58 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 24F0D6188D; Thu, 22 Jun 2023 16:12:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D31B4C433C8; Thu, 22 Jun 2023 16:12:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1687450375; bh=usJVo5I+xdOS+40CAA4svVC3yYICHKGcsYVj9V2YNmo=; h=From:Date:Subject:To:Cc:From; b=Cvr3yZsAODWPS7ysBd/xRvdwx2qXOiyW4dC32Xfg4CsWYOo7O/5wu+6jWAiz/kCLq CO6eqFW2WNDs+kGyVD/KvoUay7OZmRwyOSUi1plh1FrUJ8CCdGBbGuZ+embHvrY27V 2VBcClhhnRUcnEE43DQYTSIwZQgCq3gNbDnO73nUZmE5p3MNU7pm3sda7il4Jjjths pmkIdg8Ly1isYAdMpURvK839Achyp1SnMC6rR2O8oYKqP+CkNgs8wQbdcf5wXi3Vyn azbvMnEt3UZvUTxzJAJ6DYeyRi+76WhHHFhu0bJQ3Yc3EK1CYxQFt5BX6RxFttu7gQ OMouSaf5UF/tA== From: Nathan Chancellor Date: Thu, 22 Jun 2023 16:12:41 +0000 Subject: [PATCH] leds: leds-mt6323: Adjust return/parameter types in wled get/set callbacks MIME-Version: 1.0 Message-Id: <20230622-mt6323-wled-wincompatible-function-pointer-types-strict-v1-1-6ad256f220e8@kernel.org> X-B4-Tracking: v=1; b=H4sIAPhylGQC/x2OywqDMBBFf0Wy7oAmRWh/pXSRx6QOmBgyY20R/ 72xy8PlHO6uGCshq3u3q4pvYlpyg+HSKT/Z/EKg0FjpXpt+1AMkGY02sM0YYKPsl1SskJsR4pq 9NB3KQlmwgnwLMrBU8gLGXGM/hpuO0alWd5YRXLXZT2c/WW7KOZSKkT7/S4/ncfwAi8UpiqIAA AA= To: lee@kernel.org Cc: sean.wang@mediatek.com, pavel@ucw.cz, matthias.bgg@gmail.com, angelogioacchino.delregno@collabora.com, ndesaulniers@google.com, trix@redhat.com, linux-leds@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, llvm@lists.linux.dev, patches@lists.linux.dev, Nathan Chancellor X-Mailer: b4 0.13-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=3491; i=nathan@kernel.org; h=from:subject:message-id; bh=usJVo5I+xdOS+40CAA4svVC3yYICHKGcsYVj9V2YNmo=; b=owGbwMvMwCEmm602sfCA1DTG02pJDClTitmmJE1V0UmQW5Etd+hbv7FWRJ6W0+n1a6NyROPMH /zLirrUUcrCIMbBICumyFL9WPW4oeGcs4w3Tk2CmcPKBDKEgYtTACYSqsvIsLL2uX7jTONiUfG2 mxZhm1UO8pi8dwrd2SQkeSzzSaL0XkaGnRrbl3F7T7Zm3nxQ2H5thRcDG5c0e0GdoJ3p2S/CU29 yAQA= X-Developer-Key: i=nathan@kernel.org; a=openpgp; fpr=2437CB76E544CB6AB3D9DFD399739260CB6CB716 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230622_091256_814092_DF079A41 X-CRM114-Status: GOOD ( 13.35 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Clang's kernel Control Flow Integrity (kCFI) is a compiler-based security mitigation that ensures the target of an indirect function call matches the expected type of the call and trapping if they do not match exactly. The warning -Wincompatible-function-pointer-types-strict aims to catch these issues at compile time, which reveals: drivers/leds/leds-mt6323.c:598:49: error: incompatible function pointer types assigning to 'int (*)(struct led_classdev *, enum led_brightness)' from 'int (struct led_classdev *, unsigned int)' [-Werror,-Wincompatible-function-pointer-types-strict] 598 | leds->led[reg]->cdev.brightness_set_blocking = | ^ 599 | mt6323_wled_set_brightness; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/leds/leds-mt6323.c:600:40: error: incompatible function pointer types assigning to 'enum led_brightness (*)(struct led_classdev *)' from 'unsigned int (struct led_classdev *)' [-Werror,-Wincompatible-function-pointer-types-strict] 600 | leds->led[reg]->cdev.brightness_get = | ^ 601 | mt6323_get_wled_brightness; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2 errors generated. While 'unsigned int' is ABI compatible with 'enum led_brightness' (hence no warning from -Wincompatible-function-pointer-types) and the callers of these callbacks use/pass the values as 'unsigned int', the mismatch between the prototype and the called function will trip kCFI at runtime. Change the types in the implementations to match the prototypes, clearing up the warning and avoiding kCFI failures. Fixes: 9bb0a9e0626c ("leds: leds-mt6323: Add support for WLEDs and MT6332") Signed-off-by: Nathan Chancellor Reviewed-by: Nick Desaulniers Reviewed-by: AngeloGioacchino Del Regno --- drivers/leds/leds-mt6323.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) --- base-commit: 7bd932d9adbcc5c5370d968bdb0b00385606bf3a change-id: 20230621-mt6323-wled-wincompatible-function-pointer-types-strict-334f06d92ffb Best regards, diff --git a/drivers/leds/leds-mt6323.c b/drivers/leds/leds-mt6323.c index e8fecfc2e90a..24f35bdb55fb 100644 --- a/drivers/leds/leds-mt6323.c +++ b/drivers/leds/leds-mt6323.c @@ -76,7 +76,7 @@ struct mt6323_led { int id; struct mt6323_leds *parent; struct led_classdev cdev; - unsigned int current_brightness; + enum led_brightness current_brightness; }; /** @@ -451,7 +451,7 @@ static int mtk_wled_hw_off(struct led_classdev *cdev) return 0; } -static unsigned int mt6323_get_wled_brightness(struct led_classdev *cdev) +static enum led_brightness mt6323_get_wled_brightness(struct led_classdev *cdev) { struct mt6323_led *led = container_of(cdev, struct mt6323_led, cdev); struct mt6323_leds *leds = led->parent; @@ -471,7 +471,7 @@ static unsigned int mt6323_get_wled_brightness(struct led_classdev *cdev) } static int mt6323_wled_set_brightness(struct led_classdev *cdev, - unsigned int brightness) + enum led_brightness brightness) { struct mt6323_led *led = container_of(cdev, struct mt6323_led, cdev); struct mt6323_leds *leds = led->parent;