Received: by 2002:ab2:6d45:0:b0:1fb:d597:ff75 with SMTP id d5csp571088lqr; Wed, 5 Jun 2024 14:30:22 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWZI6e7KJnCVXNSUvfOM/9cUxOMgvcRU61ckNIWpVgo4776QVig3F2Zg0JC2fAkE0wSG2KYmj99MPiJk0RFK+8hbyoZJBiCRtQ8IwwQJA== X-Google-Smtp-Source: AGHT+IG1v1/jIBg08JmrXT0t4n4AJ3xCCk4CAGx047kvM6fum8p6FWRze0zHAzxZDaz42q5vrlmi X-Received: by 2002:a17:903:2292:b0:1f4:9138:8178 with SMTP id d9443c01a7336-1f6a5a6bdbfmr47590775ad.49.1717623022262; Wed, 05 Jun 2024 14:30:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717623022; cv=pass; d=google.com; s=arc-20160816; b=nVOEx6nsUVhVn+sF+spnwMkZvXxHhHoNu0I7fPzjvD9ak9ssmHeZXbdz7o7/1NP/pi YAhdWtZ29iL1AHGv/YYxOP28aZGCCBloWZoSYbkVRWHlz5f0aqNuACVtr0XjY4x7XitW JdAPFAuWnnEHc3UQXe0/qjAXpDC408ZPMR8Hv+35iT23M3Yb7QBA2hjCs42xCqDbrJhj s6rtJDqYj/rk1UM48iu2H5nz0vjPTcU/IXcO8Apv/RxNzBkCxvxLXnGARJx3WXrfQfR0 l6PMhRFYttIu4KYHrSr4m4TMAMWX0y+503GaaU+YyqtTbFt5sFYKaHZl1p1evFUyMCjq Jlow== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=VVh0pOteeIri9qqbCA+sDhPXPbv1rTPqRDlFd5iwUgU=; fh=F5i+rNW4hjf57QJHDx14Nq4Eso4Z4OyY/LhC2i40VT4=; b=yRZPlXttnETDbpm/u16FKnah/jJZhUNPZmL0PCEROjXIYDiEcngEXR2TkxVxO7zKXn ESdXFN35cJD4W5RO3Zg2P/mIt7FLS/Xfjd1T8mDf/Ou2WroZRsWKDTHMLhlcyutLuWD7 2nqrPjovc4kKMHX/RIoM/HHoEDzG6RWkgEX8dX+AKoSnlWXCa5mB7v9Hf5AswotDTBIU pMrcmTlbAyP3fnBwf170kJ74+mqI2DpsWM3BgMTJga23mMZlnY3AoAmyk5ZAkDL2qsdt nWXDhYN7s81okfeVy4nI3A3FOGktwp7E1sc2VzBWOo6pwYv+Fc2Li1dy7UnWb4qI9iUh UTRA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=bZIAPUDX; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-203266-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-203266-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d9443c01a7336-1f6bd75fc5asi163835ad.12.2024.06.05.14.30.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 14:30:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-203266-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=bZIAPUDX; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-203266-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-203266-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 3EDCC287070 for ; Wed, 5 Jun 2024 21:27:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9B5F017E91E; Wed, 5 Jun 2024 21:23:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="bZIAPUDX" Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 C42C8161308; Wed, 5 Jun 2024 21:23:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622621; cv=none; b=amlBFFmX2l/4/wO1HOZGqNYTXIEnVq8eXiGotTXOPLlsKMigqfbbQl/O0zcSigCKnMwoGb471Ht93EwoC4+bwz2g00k955o7omTu1XQ97ZMf2KDuxnHVD0HzAqCNGIqaoTsa9nUbNbA0YOecG0pSJJKsb7yqQQ9CLBrE+DZ4+x8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622621; c=relaxed/simple; bh=Go/Sw2mfEMY8QsnrCy8Zm/3ksaghSmu3WnFOYYCPdrQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=X0F0ClN/ObYC5UV1tKxvfHuChL0XfOQd8DV7MsUsV3ipY7zINK4PTPnvOjWZj6Q4JsIJ7fJSZGGuZY/eDduPKL/mOPUyKV8T9pgQLJbp66caZsBrIU6w5u2Vy2wJV7Mgijlzi00fONwnkCtdQ+SfahFjlxQmJlW3B6f2Ec9cbvA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=bZIAPUDX; arc=none smtp.client-ip=148.163.156.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Received: from pps.filterd (m0353727.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 455KKjXd025682; Wed, 5 Jun 2024 21:23:27 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc : content-transfer-encoding : date : from : in-reply-to : message-id : mime-version : references : subject : to; s=pp1; bh=VVh0pOteeIri9qqbCA+sDhPXPbv1rTPqRDlFd5iwUgU=; b=bZIAPUDXFYmgTFtCfDv9tEDVvUj6CmYgYvE/7YWCivsVTzkCYsCopRFTTMaEsvCVoJoe +d6h5Izah7nlyXWIHXtPUwzKrHP5m99aE8RO5oJOmFMR5iaLxPGBLm1xph9MVxVYYNkW ywZ5Fn+uQWEhWtfHJ6/c9p2Db5XLgoQLtTAHWT3c5xyT4joiM6MZiYRgQUxe0CymqjnE NJ6yDlb34unaIJld6jTZrrQsR4qJbuCaTODjEoxHhRcJXQPdJZEawgRu1hIPZ4Wsig+0 3yLBFfYRObbednuK3gEEJMINFhFPKOld5AzoDgxxUXP1pnlVoKgWSaZf6K5v5/nd65ho MA== Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yjuwr0qc0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:26 +0000 Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 455LKNJ5008463; Wed, 5 Jun 2024 21:23:25 GMT Received: from smtprelay04.dal12v.mail.ibm.com ([172.16.1.6]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3ygec0xv6j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:25 +0000 Received: from smtpav06.dal12v.mail.ibm.com (smtpav06.dal12v.mail.ibm.com [10.241.53.105]) by smtprelay04.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 455LNMRD48103912 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 5 Jun 2024 21:23:24 GMT Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6A02558055; Wed, 5 Jun 2024 21:23:22 +0000 (GMT) Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2C8415806A; Wed, 5 Jun 2024 21:23:22 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.61.121.242]) by smtpav06.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 5 Jun 2024 21:23:22 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Cc: eajames@linux.ibm.com, linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, linux-spi@vger.kernel.org, broonie@kernel.org, andi.shyti@kernel.org, joel@jms.id.au, alistair@popple.id.au, jk@ozlabs.org, andrew@codeconstruct.com.au, linux-aspeed@lists.ozlabs.org, ninad@linux.ibm.com, lakshmiy@us.ibm.com Subject: [PATCH v4 30/40] i2c: fsi: Define a function to check status error bits Date: Wed, 5 Jun 2024 16:23:02 -0500 Message-Id: <20240605212312.349188-31-eajames@linux.ibm.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240605212312.349188-1-eajames@linux.ibm.com> References: <20240605212312.349188-1-eajames@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: uIQ3lo8aMA4Sveu7X7k3F3_3kcFfPMRd X-Proofpoint-GUID: uIQ3lo8aMA4Sveu7X7k3F3_3kcFfPMRd X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-05_02,2024-06-05_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 phishscore=0 adultscore=0 priorityscore=1501 lowpriorityscore=0 bulkscore=0 clxscore=1015 impostorscore=0 malwarescore=0 spamscore=0 mlxlogscore=914 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2405010000 definitions=main-2406050160 This will be used more than once with interrupt support, so split the error bit checks into a function. Signed-off-by: Eddie James --- drivers/i2c/busses/i2c-fsi.c | 38 ++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/drivers/i2c/busses/i2c-fsi.c b/drivers/i2c/busses/i2c-fsi.c index f3b97bf88d0f9..022f1287aa0e3 100644 --- a/drivers/i2c/busses/i2c-fsi.c +++ b/drivers/i2c/busses/i2c-fsi.c @@ -507,6 +507,26 @@ static int fsi_i2c_abort(struct fsi_i2c_port *port, u32 status) return -ETIMEDOUT; } +static int fsi_i2c_error_status_to_rc(u32 status) +{ + if (status & I2C_STAT_INV_CMD) + return -EINVAL; + + if (status & (I2C_STAT_PARITY | I2C_STAT_BE_OVERRUN | I2C_STAT_BE_ACCESS)) + return -EPROTO; + + if (status & I2C_STAT_NACK) + return -ENXIO; + + if (status & I2C_STAT_LOST_ARB) + return -EAGAIN; + + if (status & I2C_STAT_STOP_ERR) + return -EBADMSG; + + return -EIO; +} + static int fsi_i2c_handle_status(struct fsi_i2c_port *port, struct i2c_msg *msg, u32 status) { @@ -518,23 +538,7 @@ static int fsi_i2c_handle_status(struct fsi_i2c_port *port, if (rc) return rc; - if (status & I2C_STAT_INV_CMD) - return -EINVAL; - - if (status & (I2C_STAT_PARITY | I2C_STAT_BE_OVERRUN | - I2C_STAT_BE_ACCESS)) - return -EPROTO; - - if (status & I2C_STAT_NACK) - return -ENXIO; - - if (status & I2C_STAT_LOST_ARB) - return -EAGAIN; - - if (status & I2C_STAT_STOP_ERR) - return -EBADMSG; - - return -EIO; + return fsi_i2c_error_status_to_rc(status); } if (status & I2C_STAT_DAT_REQ) { -- 2.39.3