From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) (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 2CDED2BE7DB for ; Tue, 7 Apr 2026 14:32:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775572339; cv=none; b=RO5fhX7D9aDjfpqyAEzLzMyE5IsZGuehVCTSDFcHE4KlTRh6gowvdSHGZIS1IHazyfUmgcAVHJeD6Jzh10WT2+8EY8vd8RYCzTNTBeFCPlM85qVfPHjXXdZB6CudbTC0hW24M37FrlYoE5me4EXy8je1wG2lqApaRuETwiLmVTA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775572339; c=relaxed/simple; bh=2VKrCPDi3pKTXYq0V1T3BBsCsCo51omN0tE2jlm/9Ys=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=srCVCp973sp/Un4mt/KnHfhIqt7DNviCFsuqUzjCFMaNEkDG4dn/ggUj9hM5SpM2fpCZV5WsGCVSANyNgcLQ0vje03kLyIiNvyQknj0s/Lb/RMhFCM9tn2w/vsJcFNYVvUhQyNIo5Taf6kCEE/CSaER7TTfCKKkVzvEh3vxs4/4= 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=Pug3AKBC; arc=none smtp.client-ip=209.85.214.176 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="Pug3AKBC" Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-2ad21f437eeso25843365ad.0 for ; Tue, 07 Apr 2026 07:32:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775572337; x=1776177137; 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=WCaF3kLdCiAgYQ5/bk3SyXEWPD5dHMX+3j2VLCRYM2s=; b=Pug3AKBCkqlV1AlQ9RUts5p8n+zd+hry+FiWb8r9gGgqqDfLJU7ziJcTkGS2OlOh9a jD1NnOqT3UPmnLhbsYnFaxTA5rdc8ZFJ46mGU+G8veFHyOYMVBFvNT0qValyZyQ4Ouda kX1XcBzibkNKSjN/NhznoWLNCukF0WPEi1lfLu1MNZ2j/XIdJSCxm0H91KwITGo5ZjH3 mq/3aRyfStrMx/jr9M3BbWBUGmzFVVh8q9WWZX3EhxGysCr03Z7yAIQLPnWPQbGXkNue 86qVXX9GYauYYORkot0bmOLWDdFJDJ6lCs6ICK7Bcp0kK2K+EeFtPPg+H/7u46Yy0ehn GQag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775572337; x=1776177137; 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=WCaF3kLdCiAgYQ5/bk3SyXEWPD5dHMX+3j2VLCRYM2s=; b=rhK3Uo4EYfjFt0TeB2Y7goJ73XHHFh3PUxDKznRCxwDlmADpCyPX+MtfRoa1DV5get RX+JDO4/Pdv0ElEYUZX3xV3UCDSOLjLD/CJKjnxUISGePOnIgIVDcWOAZBSnuK51bu0P sTmpoiggs7NSSMWnh0+aEUnRjt0g5ZZ9i/pPrWhvy7w4ODb1s9fS8fcfFBQADRqHwhMY AiyhgocvU6iBci8fLo+BTmIC+zgmqpjO0TYCJ0ES81gU/Hi6orbwXPXnqmTR0uie+ryD FwKFGsXdTJClZ61WXxSTO+507LhfRQOQA8Kh4WPxCgTVwx1QFmOalKQrtqSc4nTf7hho ZFDg== X-Forwarded-Encrypted: i=1; AJvYcCUFytmJ8JV8BrpexfeELsDqI8Gv05T17zooCUwhp39jiOLcMtUuNhyvnFt3irGiP5O1m9oy/eXStxbNByU=@vger.kernel.org X-Gm-Message-State: AOJu0YxwaXtkgvKDGJp5I48AFWqGKHjHdIbPuh8ZNir9SmvtAuQRkjRI 2BSezr3BlhZLenLY4bOoS3DsaiktxCb7PlosZ0L6x4Xr8PPqa3CQzDIW X-Gm-Gg: AeBDies3P+VJE5qqoYRzQS+TmC5GwdkueS3oP4o4j9eijUW0dSUUbboDjQgmaMhUmTd fdNUW5o+jEqINKCbRgOPjVz+ZrhFGVb1IrpqR/z0kmdI6zo1/teFEqH+HZXT4xlDadkAzBN3KKT 7WtEzVdLlyFFpd4hdl9IwAacghcSjumtHMTFWMOzzPSCvlgufr0nxWEs2J+44gYWRbdLJxyP4Vb ym8zA9yykei+3UD/nSod8SB73p92Lq9VVjhH07fc8oV7Oc+hwaTUCm19yTDLVGH/uKM7TC9H6rj ZgifvavNkXKXg8NUm/2I5QfL20ipja7M1o1/IJqViRMbJ0PC8kXIdH9k0MhK7U2iY8LUxS9/6uV vMnkOTUZyvaCmrX5qcAl6Ml2zMQQcdyBjMRO6998qebX2X8clIsnx7XtgXOcOidaN7PKpMHDs44 SB3Y0DdI5DpFm0EmcQsfTFD8fTYhi/bxschP/5kZp8LF/xhGzolQeuNCZVX2OE X-Received: by 2002:a17:903:1b0c:b0:2b0:6068:4c5f with SMTP id d9443c01a7336-2b277d966bdmr184775385ad.8.1775572337304; Tue, 07 Apr 2026 07:32:17 -0700 (PDT) Received: from Mac.localdomain.com ([49.205.216.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2b2749cbc58sm181201525ad.78.2026.04.07.07.32.13 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 07 Apr 2026 07:32:16 -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 v1 5/6] pseries/papr-hvpipe: Refactor and simplify hvpipe_rtas_recv_msg() Date: Tue, 7 Apr 2026 20:01:39 +0530 Message-ID: <51b10f1e82e5c9965902b34b082a4d2aa981ff8f.1775569027.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 funcion ensures bail out routines are handled early, to simplify the function logic. 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 7242a14eb5ec..f41f5c0a8418 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