Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp758042rdb; Thu, 15 Feb 2024 14:51:36 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVbmS4+k8S8XWCLyEEYjvjmOG73ckfRjnTXK4JLG/oNehiVbAI5O9ytBknYsNrV/tORMj/np4bVNiw0RA1d0ziOAMD729YOgZ401rL+1w== X-Google-Smtp-Source: AGHT+IFF23WZnEqm++oT5mhDj5o/7cUybOZz4ZSZzNZ7vIIRsWSM/K8tJUfZvbUWlt5cZgyCDdjk X-Received: by 2002:a17:906:6c6:b0:a3d:4da2:746b with SMTP id v6-20020a17090606c600b00a3d4da2746bmr2358610ejb.68.1708037496845; Thu, 15 Feb 2024 14:51:36 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708037496; cv=pass; d=google.com; s=arc-20160816; b=v1FHJ39+GoPxjtdTiGgU4ysEC/7Qvt0ynE5pAWVL5RJn3biqLLZjGRYLbpgaPyokKT wc+pK/M1ujxb4B9ynS2kTO1rJyIwZAWjnSTreSo2HH3Z6Ye8tkzBiNnXCLEiPyAha1EG gP65ex/anQWKYGJ0zyMP1AT5qcRbhOeGZAyYGsnuFFfGvgbImG2wI6/I7R5wFjcaNIIh 7AyC94/I5tnJ7841PRMgGNSQjB8+3JQb6GMFmQW5LXftfULLrvumCiE2J5pDiBFmVDqs rb1fjnqY01SuQ5VG5NBsx8t3uk7PGZNsKJfN05KcYwyi17QYw98izIdxsZ/M0k4DcW+0 IclQ== 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=VTP7z+tQ2W8GOsBuCAI+ahfXY5pZN8Q0NRIJ8nxWHJo=; fh=Usz7XAB1EI7Q/DdLEXd449E1MLGpSzqdCCNe5XKh9R0=; b=efz6xL09vmo964mAPV5GKFAPwjpFYKdtylKUU4Aorx5Y5NDRbnP4Gw4XQ7oU9nnehl r74qer4m2JCc/7sTvm9x+HP8F7X0i3ohsuP86eieOdK8NZupPHhXl03Dp4RirW2i23CK uW0IbXLzHUJfh+BQXQmemnGSmL0fhW4HZ1+G3GSbTIcTWF3WFCkJEOU9jyo0eQiMd2XG gS57pU+sM332qKEDMWEhnzrD4w8Q+Q/KuvnBq7ZNzOnVurp7YZBEPGHe4fUs3EvaOSuc qVoJQn/Ani7QliZznPhZUHCjJXcX6xp33Aw9QPxLJZKBuMlbe29/w7H1hOHBqz7fz4yM 8ecg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=aUpU1rEt; 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-67756-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67756-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id mc12-20020a170906eb4c00b00a3dab66db87si591505ejb.721.2024.02.15.14.51.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 14:51:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-67756-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=aUpU1rEt; 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-67756-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67756-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 600AB1F27026 for ; Thu, 15 Feb 2024 22:13:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 402C213DBBE; Thu, 15 Feb 2024 22:08:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="aUpU1rEt" Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (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 82F0A14901C; Thu, 15 Feb 2024 22:08:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708034912; cv=none; b=C+XKjCcIFNFWaLnKVn4jZ4fukIPFoq1Hpo9nkTilDLtVVjgWBU5Oe5kmqunxEZNJI48cKtaRQ/UNRa7rcnSoHRsq9ZLTrWMFHXLjXK1xg4mpC0CFmwzx9Z5x8xks5F4ZhleseEQpxd9xJqEt4FMH53J6SP/v5blVH6jAEBGyQnY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708034912; c=relaxed/simple; bh=H95OXKDiOnZPDBQirsADlzhMc6VAfrwQDtpLN9WMyRg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=O5p6ZwqAGCuIPzIazchOACipHOThkCB7jgjR+dC/tB3ssn4FZtADjHjO5043FM8uIzEt33T9anm0x6eLTZStkM0oryOX6AEaLQlPpW+YNB4AfVD/K+05iEQHX5wLxDjNwb8F88YZvJLZLQmZS6bjOeIVbzXwa1td6VK+F1+1rv4= 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=aUpU1rEt; arc=none smtp.client-ip=148.163.158.5 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 (m0356516.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 41FLPhFN030019; Thu, 15 Feb 2024 22:08:18 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=VTP7z+tQ2W8GOsBuCAI+ahfXY5pZN8Q0NRIJ8nxWHJo=; b=aUpU1rEt26Ixm4wuXt4ARN+OBDwsdN/LfQSQmCjbUGrD7xkBj1r3W4JOTRYmcDLBk4mO ePXHlLuflhKQM2YVaTdAa6Oaj+G2F16rpmIAtMW3Tj4ttagB+tgfHMoO5coEKWU0DlN6 jGXFtz66GZ2G4cmPHLnKZZ7gUSt7rjj+3trXLQgJ0zOb2XFlwfWmvGyX9BBN6T22p4s7 rmFg34JIab+F97yEj+Zp+vctoGY5RezhF/IoqZAoDLXxEEFLN3WMSQBf5tmz8EpYX06e nHWRH71YsqStw/oSWVoEl/PDijUbQXHhZVOlnPXdN1oKuU/YPYzR5Evl7MNux1PJQSXt UQ== 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 3w9s0tjy8v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 15 Feb 2024 22:08:17 +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 41FJBGLv004329; Thu, 15 Feb 2024 22:08:17 GMT Received: from smtprelay05.dal12v.mail.ibm.com ([172.16.1.7]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3w6kv0qtng-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 15 Feb 2024 22:08:16 +0000 Received: from smtpav03.dal12v.mail.ibm.com (smtpav03.dal12v.mail.ibm.com [10.241.53.102]) by smtprelay05.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 41FM8ED815729300 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 15 Feb 2024 22:08:16 GMT Received: from smtpav03.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DE14158073; Thu, 15 Feb 2024 22:08:12 +0000 (GMT) Received: from smtpav03.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9371E58064; Thu, 15 Feb 2024 22:08:12 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.61.14.18]) by smtpav03.dal12v.mail.ibm.com (Postfix) with ESMTP; Thu, 15 Feb 2024 22:08:12 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Cc: linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, linux-clk@vger.kernel.org, devicetree@vger.kernel.org, andi.shyti@kernel.org, eajames@linux.ibm.com, alistair@popple.id.au, joel@jms.id.au, jk@ozlabs.org, sboyd@kernel.org, mturquette@baylibre.com, robh@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org Subject: [PATCH 31/33] i2c: fsi: Define a function to check status error bits Date: Thu, 15 Feb 2024 16:07:57 -0600 Message-Id: <20240215220759.976998-32-eajames@linux.ibm.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240215220759.976998-1-eajames@linux.ibm.com> References: <20240215220759.976998-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-GUID: HJ1k8QJcGw75HAqAiCnMmu28CeQrKR_Y X-Proofpoint-ORIG-GUID: HJ1k8QJcGw75HAqAiCnMmu28CeQrKR_Y X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-15_20,2024-02-14_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=928 clxscore=1015 suspectscore=0 phishscore=0 lowpriorityscore=0 spamscore=0 malwarescore=0 bulkscore=0 impostorscore=0 priorityscore=1501 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2402150171 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 096dc7e2369f..5f524fb6f0f8 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