From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 85B001DDCE; Tue, 16 Jul 2024 16:11:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721146296; cv=none; b=JXvcbkiuSa7NDFbvw15tsZwgniHe8Sit1FwO3a2mm8PKpbQ1fAHFLD/M3o2lRwDFeXUAtEYlFHcyJBF2pzKynX1hRWj9QgJ9UW12hnafQaqGAP1mKo7u8i6hCqr79vPZi0U1cWi0zxcQoqQa2lvOvIZ0SlmY+KjF+5ZWNJzcBus= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721146296; c=relaxed/simple; bh=EwRVU2qeSRoTz1ZZCVa2Jv8n2WZYLxFwkARYSWFHG3s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iXjyv6Xuk221TIKHg8XJHk+mm4+mC3myaA3vETgPrprcX9meVtxpKNYyyKFWA2aldSZIqz0Dgp4HYHErgA/CmfO0NXsJfUc1pVZHHeDde9YpoIXiuJuu+62Kl48zlkwCul7fUKjvYdSFdc0j0ZyjlD1K9PTYwVBcqOc/9QINR0A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=2ZqOTQdi; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="2ZqOTQdi" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F3B24C116B1; Tue, 16 Jul 2024 16:11:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1721146296; bh=EwRVU2qeSRoTz1ZZCVa2Jv8n2WZYLxFwkARYSWFHG3s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2ZqOTQdixio6cG/XmO2QKaauhHRJI2aAz4puYQMFuEpBmZPOhD27T0Z0w/YR1NWTZ lwfVqZptf9VE6Iq8BnWfugCTENehcngUP7UzERhpJc+ZkY+Z43jGYrk5NRjVWpDlwf PjtyXfXzY22N9vJjiJhvAgv1Sy2ApcMeUMGxmg+k= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Joy Chakraborty , Dan Carpenter , Neil Armstrong , Srinivas Kandagatla Subject: [PATCH 5.15 119/144] nvmem: meson-efuse: Fix return value of nvmem callbacks Date: Tue, 16 Jul 2024 17:33:08 +0200 Message-ID: <20240716152757.099797279@linuxfoundation.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240716152752.524497140@linuxfoundation.org> References: <20240716152752.524497140@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Joy Chakraborty commit 7a0a6d0a7c805f9380381f4deedffdf87b93f408 upstream. Read/write callbacks registered with nvmem core expect 0 to be returned on success and a negative value to be returned on failure. meson_efuse_read() and meson_efuse_write() call into meson_sm_call_read() and meson_sm_call_write() respectively which return the number of bytes read or written on success as per their api description. Fix to return error if meson_sm_call_read()/meson_sm_call_write() returns an error else return 0. Fixes: a29a63bdaf6f ("nvmem: meson-efuse: simplify read callback") Cc: stable@vger.kernel.org Signed-off-by: Joy Chakraborty Reviewed-by: Dan Carpenter Reviewed-by: Neil Armstrong Signed-off-by: Srinivas Kandagatla Link: https://lore.kernel.org/r/20240628113704.13742-3-srinivas.kandagatla@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/nvmem/meson-efuse.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) --- a/drivers/nvmem/meson-efuse.c +++ b/drivers/nvmem/meson-efuse.c @@ -18,18 +18,24 @@ static int meson_efuse_read(void *contex void *val, size_t bytes) { struct meson_sm_firmware *fw = context; + int ret; - return meson_sm_call_read(fw, (u8 *)val, bytes, SM_EFUSE_READ, offset, - bytes, 0, 0, 0); + ret = meson_sm_call_read(fw, (u8 *)val, bytes, SM_EFUSE_READ, offset, + bytes, 0, 0, 0); + + return ret < 0 ? ret : 0; } static int meson_efuse_write(void *context, unsigned int offset, void *val, size_t bytes) { struct meson_sm_firmware *fw = context; + int ret; + + ret = meson_sm_call_write(fw, (u8 *)val, bytes, SM_EFUSE_WRITE, offset, + bytes, 0, 0, 0); - return meson_sm_call_write(fw, (u8 *)val, bytes, SM_EFUSE_WRITE, offset, - bytes, 0, 0, 0); + return ret < 0 ? ret : 0; } static const struct of_device_id meson_efuse_match[] = {