From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f180.google.com (mail-pg1-f180.google.com [209.85.215.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7312B3BC683 for ; Wed, 8 Apr 2026 12:02:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.180 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775649743; cv=none; b=tvNgXd72gcfpRw8W/Yeu/6WiQQePUVfRMT4sS1GZbe4fpU8lQAfP6MBOf810bOrNcwN/ZK97GJYqQu85uYNboJ8u6ryvVj3xholRziTVtmWcJLKW/ud69WT+w/7vN0GDTVArYUGjNKxPO5yzIUdmn0S/Cm4NEaRzkbe+n4j6OII= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775649743; c=relaxed/simple; bh=9xVmVnnQEmBhLZ6zKtAVXz9LYcbBNbD4AhA7vmG0KWA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mm+wjNe1r1cf/5lXujadlY6q8MQZpzw0uneDzuWIx06rB/KuuM1AN7Qk7L2Hxso702jiizvn9M3L3cdD17Dht3maLbELtjXojU0CBFb9PJkEAGJKEge1mhWVNdeyeV8FEIFSlKzJsFnWXZSr3DJumBqzWd9ZZFEMpDDeXZPv/UE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=lj5AfM79; arc=none smtp.client-ip=209.85.215.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lj5AfM79" Received: by mail-pg1-f180.google.com with SMTP id 41be03b00d2f7-c76b6abdb73so4444394a12.1 for ; Wed, 08 Apr 2026 05:02:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775649742; x=1776254542; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=SCwuqGPqq1xW71wkNIANtyK3Rl5bXk4EbTq6DUkJUCM=; b=lj5AfM79XIFL65DIyFT4+Bkd6ZQXn5Ss++exuq7LzYQcv6QzPWQaMXtebm/5BXCivq /4vYK3pGuIxSjBsl+c+t3LNkX310PfM4M/dmgpRr0wsE/7EcH2LUZ5aXGhVzgWcHAixq RFJRQMSgmESm5+T4PL8SJWl446toKuVB9P9K9ilQ+2UdDa82Nrvs5WXKC2MCR5SgsUg8 UDbaHfQo+tX1W6aklCU9Zj1arTlKJTamaPlp5n3akHlYGZU0Db45VNLr85UI8/e55BKn 7iH9wapGKMFS0gA/HOxwmFkJOUqS67b03/0zm5na0+i0oJERFkSMv8EdJ5vqo2V8D7ll lllg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775649742; x=1776254542; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=SCwuqGPqq1xW71wkNIANtyK3Rl5bXk4EbTq6DUkJUCM=; b=NUbmAy+aiKOAIOqSHnqGGMTKQ7FORyFZ9tJy1ViJtBdWlHprRdy/PvAAoiC18p8qZV RyUqGoFCN/w7X/mHMPc2+XEeooTLoK/8wfT8KFkkyro9y6WVfXWWojuUWS0zV4GBawy9 yEqUHMy+rvXVi8EAKaWN5hPv+3ubi9ResneFis1pqc0hCMObRHNuxU5s75HYy19tTZWP E7XLulpIfO72m6Xgu1jRdnWHU0vxhHmsnFbvQ9Asjsv8Z8SN/BIj95W8wYsWVbvr/Icn 0EXVT2CxpquLoK2j7q32csv0Iw3hzeyZBv73liGyPQfvKUj/FcKkcdNlfYECvjPo4/XN uIOA== X-Forwarded-Encrypted: i=1; AJvYcCVggrCHNu/G7sb02kJzs5QdnIHDrT4L77jYtrdewKWC/iMpz+IzJrAhQaPUANz2OJpAQrpX3azMBn1aZcM=@vger.kernel.org X-Gm-Message-State: AOJu0Yysrvtz7QCcssP+60Ymg2Rw2R47temZVbl9h5gDT73i7B2rdx7P ferzSvHCQpvK5V5gBp76aLvwvfDPxHBqhXoDSF57j1rKAxviQZP5vrg4 X-Gm-Gg: AeBDiesc/FeAMmKVEHvOVJ7QNYWQ42Z1wAasFpo08ne4OvP0B66/JKtQ0nnOQtVrGHY RE8ja7Eg4I/vLEBiSbIkXzjCXmn43Jy73FXPPYYaCx3cfxyfhYXHDa6vfwOAhqqGL54aCkXTI7n /SCamFJgaDzF/1XppokTk+loVsCpXE8WRHUaufPNSyikgBICaVxvHINhRfmLkbP/Ml+G8PG5BRl f+S+kdO3tFisRVshJ6ICWL0if55+45XwawHDLgxfXd9+trBYN/F61XczvflRSwKnqgSEjcK3WQU zThFTAmUTood6DS16xMPBpiBad1F9QI6q5yU4PcCV7HH20x95kp/xtVQWeQlRje0sjjsbRIAf6q I8/QWLYfMDZvsJRo8q/hPCzYDwYdETojAE0pYvGMj+HZND7hqOih8qouawLv9r5Gob0qBwqCBIs 5QVZZhog4Ph5YOvxeQHFSI2kSIYinLgXm8e2ackl9Yqrr0 X-Received: by 2002:a05:6a00:8e09:b0:827:3e19:574a with SMTP id d2e1a72fcca58-82d0db97457mr21444881b3a.42.1775649741673; Wed, 08 Apr 2026 05:02:21 -0700 (PDT) Received: from Mac.localdomain ([49.205.216.49]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-82cf9b3e169sm21209322b3a.18.2026.04.08.05.02.18 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 08 Apr 2026 05:02:20 -0700 (PDT) From: "Ritesh Harjani (IBM)" To: linuxppc-dev@lists.ozlabs.org, Haren Myneni Cc: Madhavan Srinivasan , Christophe Leroy , Venkat Rao Bagalkote , Nicholas Piggin , linux-kernel@vger.kernel.org, "Ritesh Harjani (IBM)" Subject: [RFC v2 07/10] pseries/papr-hvpipe: Refactor and simplify hvpipe_rtas_recv_msg() Date: Wed, 8 Apr 2026 17:31:37 +0530 Message-ID: <78feef3c4670f9de041e7e835b4451d42eb2d39a.1775648406.git.ritesh.list@gmail.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Simplify hvpipe_rtas_recv_msg() by removing three levels of nesting... if (!ret) if (buf) if (size < bytes_written) ... this refactoring of the function bails out to "out:" label first, in case of any error. This simplifies the init flow. Signed-off-by: Ritesh Harjani (IBM) --- arch/powerpc/platforms/pseries/papr-hvpipe.c | 52 ++++++++++---------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/arch/powerpc/platforms/pseries/papr-hvpipe.c b/arch/powerpc/platforms/pseries/papr-hvpipe.c index 41958ed8ee97..ac2c4b42b373 100644 --- a/arch/powerpc/platforms/pseries/papr-hvpipe.c +++ b/arch/powerpc/platforms/pseries/papr-hvpipe.c @@ -190,34 +190,34 @@ static int hvpipe_rtas_recv_msg(char __user *buf, int size) return -ENOMEM; } - ret = rtas_ibm_receive_hvpipe_msg(work_area, &srcID, - &bytes_written); - if (!ret) { - /* - * Recv HVPIPE RTAS is successful. - * When releasing FD or no one is waiting on the - * specific source, issue recv HVPIPE RTAS call - * so that pipe is not blocked - this func is called - * with NULL buf. - */ - if (buf) { - if (size < bytes_written) { - pr_err("Received the payload size = %d, but the buffer size = %d\n", - bytes_written, size); - bytes_written = size; - } - if (copy_to_user(buf, - rtas_work_area_raw_buf(work_area), - bytes_written)) - ret = -EFAULT; - else - ret = bytes_written; - } - } else { - pr_err("ibm,receive-hvpipe-msg failed with %d\n", - ret); + /* + * Recv HVPIPE RTAS is successful. + * When releasing FD or no one is waiting on the + * specific source, issue recv HVPIPE RTAS call + * so that pipe is not blocked - this func is called + * with NULL buf. + */ + ret = rtas_ibm_receive_hvpipe_msg(work_area, &srcID, &bytes_written); + if (ret) { + pr_err("ibm,receive-hvpipe-msg failed with %d\n", ret); + goto out; } + if (!buf) + goto out; + + if (size < bytes_written) { + pr_err("Received the payload size = %d, but the buffer size = %d\n", + bytes_written, size); + bytes_written = size; + } + + if (copy_to_user(buf, rtas_work_area_raw_buf(work_area), bytes_written)) + ret = -EFAULT; + else + ret = bytes_written; + +out: rtas_work_area_free(work_area); return ret; } -- 2.39.5