From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.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 0E88831F997 for ; Fri, 1 May 2026 04:12:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.180 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777608771; cv=none; b=dJBG6yQVb8w6v/CP/SupOHN7+ia0a2V6J6bHqjtAgoGAJnclr6vhi1TN3Y8Jebhp6ik4QqhDFYR1h+gNks8/zZvlViTUXbjWgRFLVkdaDBj2iR8omt9MAKVIp8cQg/xc5w8djKyWt8rUfji4xTyAKdL8/N8AQwWT8jnpjAYPpkc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777608771; c=relaxed/simple; bh=JQiMt4k27JP9YGtVOe0AmtKjjUOh8nYiK7BUBFyyjxY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KZnm5MWrcR015Jkellp6v5FCqm3fFkJSFFAo9PotBWbYs8zRaKYevNxJ+ZmFtUHCHiK/42xYIJh6d5S1DRs/Vq6BjkTrV9ireJNNuJiLHcxvD/db8bvAyEPWkf+pIXQ00nDeJqjpiVOTEYgs5N9N6ceKqJOQ3EqOfYmAN7SE/S4= 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=a95hmJFQ; arc=none smtp.client-ip=209.85.210.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="a95hmJFQ" Received: by mail-pf1-f180.google.com with SMTP id d2e1a72fcca58-82f351ca23cso764257b3a.2 for ; Thu, 30 Apr 2026 21:12:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777608769; x=1778213569; 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=tmK0ukFVMjb3b7sfCs+v8o+MM2eoVKnNMBXjoF9UXgk=; b=a95hmJFQToibaN6fPBeim4Hn8tbMG5HolR4y3g6kifvL5uTNdanBup5v/GKhJNDyBp MHaY7G1KE53BjqL2idvPIwLhLHYJgozFPDgs2CCS3wR6ZkrcpGlZo646kmFXYeFksex3 UDemx+Wf3uOsI1w3xkgoXi0mo41TAecDyyRIrm8lEqeIs35S8+iHkyDS2Uk760El4b5c PPZkv3vGC526YGQhLlZVRiBJJvgmm9vcjw5/uIrauwljE1oNbwYO7SVLRYiFVs2ex35X YYq0aD5BZwQoLe86cgDlON9ztxkPi5dNiIY5fwVel3nsvPJx2tj8S9PL5xVquz1pIWkm M+gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777608769; x=1778213569; 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=tmK0ukFVMjb3b7sfCs+v8o+MM2eoVKnNMBXjoF9UXgk=; b=qfBIBZj6n72rOYvpLvVR2oI+t/QWf/bq4MZ3e1QcDlLagO2Zw6q3yEvf0pz8FKlMSm Pu260XnoNAn2KJGhhCENY6XehJwZEg2Uh+/64hncuLvgBWVrPgWLjPd3LSb1G0nkeBb3 ekCo27VmTQToz7DtUGJnty+q9fiO9t0/V0PjFw4SPcxO5Of6PR5Dh40znvVx+W5gH5qO 0pvgD9T88ri8aKbrSE4EUFLM3d11OqVXTe9dq4kjQQPYTO2vDkDEkPZwBYA7MBPrRa35 B77MbddNu9xPup7VGOpu3LoS8osh1pVKRY0FbW5QodllniNfNRFYTc26LKj/gZL+YRlZ A8xQ== X-Forwarded-Encrypted: i=1; AFNElJ8xi2QHS1jYM5mlfLr0g4kMMkLMK5CkrQUlVfGkyqk3d6FGNrVDlyhdBnXqw6T/2ZPEMW6E9FdgADcRehU=@vger.kernel.org X-Gm-Message-State: AOJu0YyhztfYtHZt8svGMUClu/m0LpJk1BHKJBxxs9PiF2UezuHok341 2WrGMkLj1p6+oHvSZWKXFZEX93mIbrJ4x7pgIfLo7aFY4wUW6LKvkmdA X-Gm-Gg: AeBDiethgBiCWBBjEJeiurSlWiMofhwERtELHZGUacy+JeUo87g+k4pnsVL03D9W4Nc 01OUjjiIuZnwfyRjuTq10lm7LfGym//tmxXEjDLq5WkGSz1hvYFP53siOxdwI9+CjqUF2pdOrPW JOA/mFJKbNXB4sr8JY4c42zEwPqcnz1MNjc8btaAf5riELOhaL++oIQ3U5YigpMRmkVud3Qlj3u kJr2ryJzFaZvoAKxupDZE8m14c1A5XMm8nJzxzQ9XTlv8JoRBqIeTbLwEFv0T2y2LPBQ4Avuma8 Nv20aA+fLts1MWyVIHc0u0SCdr+FAM2VfLMOgY421888EVJqrsjFk7TpkkT74Y8hgmbZ21oomLw zGBaGBbAeEqB6zvYJ2Gv9JfNKGfAW/7SNGz73g6Swj5LiBYRZbgElfD/NY65NZYDksHxDyA9Krk 2d564X9xBQtF8o/UtPzlD/pFT/2ICUXPa5MT7BaO0UUdZlBl0oC9v8xpob1yWuWlA= X-Received: by 2002:a05:6a00:1ca5:b0:82f:5154:d1d9 with SMTP id d2e1a72fcca58-834fdb07c68mr7050443b3a.6.1777608769448; Thu, 30 Apr 2026 21:12:49 -0700 (PDT) Received: from localhost.localdomain ([49.205.216.49]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-83515b485eesm1159428b3a.48.2026.04.30.21.12.45 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 30 Apr 2026 21:12:48 -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: [PATCH v3 8/9] pseries/papr-hvpipe: Refactor and simplify hvpipe_rtas_recv_msg() Date: Fri, 1 May 2026 09:41:47 +0530 Message-ID: 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 46159f1c1cf1..3688b2be0445 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