From nobody Tue Dec 30 09:16:29 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EE69CC072A2 for ; Fri, 17 Nov 2023 10:28:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229714AbjKQK2a (ORCPT ); Fri, 17 Nov 2023 05:28:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235027AbjKQK20 (ORCPT ); Fri, 17 Nov 2023 05:28:26 -0500 Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA65FD49 for ; Fri, 17 Nov 2023 02:28:20 -0800 (PST) Received: by mail.gandi.net (Postfix) with ESMTPSA id CAE89240002; Fri, 17 Nov 2023 10:28:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1700216899; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=hssYZxQ7oYF62vZivWNVQkuQ1Tob1SL3kJykunvJ4/0=; b=OojY2ahINfBpf0qydeGz+bModeIomJL0J4gdEXqwOR1DsOnBHPiIYI0KVvFUejAunfsP80 zJXmFqNOKAZG2Bei5aTGSIChuBwW3qQKRj/REPrcRrdB3mZHqM8OPTJeNBSoA6QS6AnPBr zOctfr0ClJRANXoKsGTHeez5FNXau/+7W0nXD83Eyv6tC6bOw9vk3sLLin1eVFM2LKBfkP MvWCTSf1Oxe4vNoOSDlf8Oxb7qj+SUNIN2SO/FdzkdzpnzZA0vlyYRDfkK6a+2P8YVuKLv T6bdW4t1azyXiEaNtwpwLnTa4Eg6fvO1sUWtL4phXmhZ/VFu0vRfuyizAyRjqw== From: Kory Maincent Date: Fri, 17 Nov 2023 11:27:53 +0100 Subject: [PATCH] firmware_loader: Expand Firmware upload error codes with firmware invalid error MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20231117-feature_firmware_error_code-v1-1-92c973a50847@bootlin.com> X-B4-Tracking: v=1; b=H4sIAChAV2UC/x3MQQqDMBBG4avIrBswdmHwKkVkNP+0s9CUidWCe HeDu/dt3kEZpsjUVQcZNs2algL/qGj68PKG01hMTd08vfetE/D6MwyiNu9cAmbJhilFuDHElqU OHARUDl+D6P++v/rzvAA6CmJwbQAAAA== To: Luis Chamberlain , Russ Weight , Greg Kroah-Hartman , "Rafael J. Wysocki" Cc: Thomas Petazzoni , linux-kernel@vger.kernel.org, Conor Dooley , Andrew Lunn , Kory Maincent X-Mailer: b4 0.12.4 X-GND-Sasl: kory.maincent@bootlin.com Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org No error code are available to signal an invalid firmware content. Drivers that can check the firmware content validity can not return this specific failure to the user-space Expand the firmware error code with an additional code: - "firmware invalid" code which can be used when the provided firmware is invalid Acked-by: Luis Chamberlain Acked-by: Greg Kroah-Hartman Signed-off-by: Kory Maincent --- This patch was initially submitted as part of a net patch series. Conor expressed interest in using it in a different subsystem. Consequently, I extracted it from the series and submitted it separately to the main tree, driver-core. https://lore.kernel.org/netdev/20231116-feature_poe-v1-7-be48044bf249@bootl= in.com/ --- drivers/base/firmware_loader/sysfs_upload.c | 1 + include/linux/firmware.h | 2 ++ 2 files changed, 3 insertions(+) diff --git a/drivers/base/firmware_loader/sysfs_upload.c b/drivers/base/fir= mware_loader/sysfs_upload.c index a0af8f5f13d8..829270067d16 100644 --- a/drivers/base/firmware_loader/sysfs_upload.c +++ b/drivers/base/firmware_loader/sysfs_upload.c @@ -27,6 +27,7 @@ static const char * const fw_upload_err_str[] =3D { [FW_UPLOAD_ERR_INVALID_SIZE] =3D "invalid-file-size", [FW_UPLOAD_ERR_RW_ERROR] =3D "read-write-error", [FW_UPLOAD_ERR_WEAROUT] =3D "flash-wearout", + [FW_UPLOAD_ERR_FW_INVALID] =3D "firmware-invalid", }; =20 static const char *fw_upload_progress(struct device *dev, diff --git a/include/linux/firmware.h b/include/linux/firmware.h index de7fea3bca51..0311858b46ce 100644 --- a/include/linux/firmware.h +++ b/include/linux/firmware.h @@ -27,6 +27,7 @@ struct firmware { * @FW_UPLOAD_ERR_INVALID_SIZE: invalid firmware image size * @FW_UPLOAD_ERR_RW_ERROR: read or write to HW failed, see kernel log * @FW_UPLOAD_ERR_WEAROUT: FLASH device is approaching wear-out, wait & re= try + * @FW_UPLOAD_ERR_FW_INVALID: invalid firmware file * @FW_UPLOAD_ERR_MAX: Maximum error code marker */ enum fw_upload_err { @@ -38,6 +39,7 @@ enum fw_upload_err { FW_UPLOAD_ERR_INVALID_SIZE, FW_UPLOAD_ERR_RW_ERROR, FW_UPLOAD_ERR_WEAROUT, + FW_UPLOAD_ERR_FW_INVALID, FW_UPLOAD_ERR_MAX }; =20 --- base-commit: b85ea95d086471afb4ad062012a4d73cd328fa86 change-id: 20231117-feature_firmware_error_code-b8d7af08a8fe Best regards, --=20 K=C3=B6ry Maincent, Bootlin Embedded Linux and kernel engineering https://bootlin.com