Received: by 2002:a05:7412:b101:b0:e2:908c:2ebd with SMTP id az1csp3295727rdb; Thu, 16 Nov 2023 06:02:47 -0800 (PST) X-Google-Smtp-Source: AGHT+IFvm0CeMPkaLljBFpA5zlguEd4p5PqJlpph7cH/vF2ARo5+gT9nSwCfspXAbvx0tJ5cYnk/ X-Received: by 2002:a05:6871:a693:b0:1f5:6753:dd71 with SMTP id wh19-20020a056871a69300b001f56753dd71mr931893oab.18.1700143366449; Thu, 16 Nov 2023 06:02:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700143366; cv=none; d=google.com; s=arc-20160816; b=fVWSlWcO2XQn+oae0XGPK/wkYYQ9lGvrRMLB7e3z+TUBZg/ZqFl1niGre9io2HljCi 0FyFw6toh4XGTEidpu1ll3JkLaMBS8Ip6lbI4gwXpuz8csiDdk3BpVvV/pu+eAUkDGae 2JmKO5BSt6NNdQoj5FdaSIrybA/gRZ6u73bo0PI9QNtFnYjMSLzEUzJ4mRMilOTMce3E wKZJ6ZyWO2FiOWcofwno7V9Cus9vJQ5wpK/Q8KxCk+npweEqtPTC0lLj44KDLzdRDO0x QJpuQsKFGm0LYER/0M2v6gkPNDchtqmGOQlBdtvz96Ca88j7cM+06UwO0SOGA07pzaUa aAiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=OI8MkD291CkzowE8oOm7BtXKSZyE48TtKxrx2423dGY=; fh=Pq7utEzs3KbaBDGtrjfUXzjEIBPT1l1o0fhVtCU5Oyc=; b=Hhy52IOb27RPAfTFRuYFUtmhK5wm/fmKLq/ZN02t3ssfeg7AM2FWIai3B6MT/+fqMG ssuxtZHSGCGMvdQHfQSRvi+cTlHGICYnv8pXBtwSIg8G4tSvuUSudB5+DPVXaFRzX1tv r2yQzrTPPcj83SMujw+Nna8z/QL7z+/EUxYjQNyrnonaNLeTz3C7kfWYCOnUY6uC3kmf bjhuoJbwQUiKXY6aSkdJySOYG0UbGCAJDT36rrIr11QfBnLK9T6/ELUvjRTQ8TeOs+5i bptE2PGGTLo0JSx5O3+s9bvQsULzgmNdgk78XffA21uNXon8tKyLoIh+R+gKYOnq8V2q 6rMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=PqFyl7tH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id kx8-20020a056871400800b001e96995128esi4465112oab.264.2023.11.16.06.02.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Nov 2023 06:02:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=PqFyl7tH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id E88568213F38; Thu, 16 Nov 2023 06:02:31 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345300AbjKPOCW (ORCPT + 99 others); Thu, 16 Nov 2023 09:02:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345305AbjKPOCG (ORCPT ); Thu, 16 Nov 2023 09:02:06 -0500 Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::227]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F154719D; Thu, 16 Nov 2023 06:02:02 -0800 (PST) Received: by mail.gandi.net (Postfix) with ESMTPSA id C20DA2000C; Thu, 16 Nov 2023 14:02:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1700143321; 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: in-reply-to:in-reply-to:references:references; bh=OI8MkD291CkzowE8oOm7BtXKSZyE48TtKxrx2423dGY=; b=PqFyl7tHI5VwR2GOARvmf21vfQJHzN4P4RzOkxQxMv/UTvrX/e3gfY2i1BuwBYzgU2HXw2 lpEasKjgsNYMeifH1bMhFgS+ymFEBYOO0TDxk4SMS/LByS/HLdZVZD+4lfJ6Gm+Y62t7Qm 29AzrWMpxyePVxBNxcU2QdrL2i68FVQxyUABYG4R93h/VRz08kQvAqEGpEJhYQLWifTYUm sWOjvTISFLqnLdrC+O3TsAkpDzwf+jlsSjYn+WM6IJsaKwzDfFTkTu+Ngb1M1Os34QhxHY DIEejjoeiJAIVw+O67XZ/k5q4tztZ5ma6YaR+uNWnZocCJ74R8RRLycrre1aOw== From: Kory Maincent Date: Thu, 16 Nov 2023 15:01:39 +0100 Subject: [PATCH net-next 7/9] firmware_loader: Expand Firmware upload error codes MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20231116-feature_poe-v1-7-be48044bf249@bootlin.com> References: <20231116-feature_poe-v1-0-be48044bf249@bootlin.com> In-Reply-To: <20231116-feature_poe-v1-0-be48044bf249@bootlin.com> To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jonathan Corbet , Luis Chamberlain , Russ Weight , Greg Kroah-Hartman , "Rafael J. Wysocki" , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: Thomas Petazzoni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, devicetree@vger.kernel.org, Kory Maincent X-Mailer: b4 0.12.4 X-GND-Sasl: kory.maincent@bootlin.com X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 16 Nov 2023 06:02:32 -0800 (PST) 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 Signed-off-by: Kory Maincent --- 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/firmware_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[] = { [FW_UPLOAD_ERR_INVALID_SIZE] = "invalid-file-size", [FW_UPLOAD_ERR_RW_ERROR] = "read-write-error", [FW_UPLOAD_ERR_WEAROUT] = "flash-wearout", + [FW_UPLOAD_ERR_FW_INVALID] = "firmware-invalid", }; 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 & retry + * @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 }; -- 2.25.1