Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp1037310rdb; Wed, 6 Dec 2023 07:05:59 -0800 (PST) X-Google-Smtp-Source: AGHT+IGbiQHX25rzJA5cohWqBOp9XH8XpMTmOk2qeQCpwqt7MELAxjKzbqa7lQCop3xPrUgXrp0N X-Received: by 2002:a05:6a20:a199:b0:18f:97c:928a with SMTP id r25-20020a056a20a19900b0018f097c928amr555401pzk.111.1701875158815; Wed, 06 Dec 2023 07:05:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701875158; cv=none; d=google.com; s=arc-20160816; b=HmSlYauxtAiXoTOf3Id5K+HNvE9LF71JQEKwfeDonVgJIpO9njeUU+l29OL1zrwEh8 5Wpo41RhrG7+TrcLTyisicwZ6pGXjPV6qX10eIYgdgQJRMh2WF0HvkgrcoFVKxSjHdjS od/oyboQ/Zdqd9Bt1IlupmCjlmh4/Lk+CDf+5OCHCrcl386bErRGAEbE1S0/8fn1NBzK pDS55jqBvT+5vivaKiKIvG1oZhvjS3nLumwTPtkGq6zCRzjhdmPODe6w/iSo8JDa5C93 zQPMnkzu4ayu9ddublzUit6/H+CW+GgvrMGFko4ms0y37ntFMCFLcUgkgMIV74FO8D+8 7bzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date:dkim-signature; bh=hwMf7u3p+RDwOM148aayiXMLKhs7CLyC1S19yofYD4k=; fh=NBYcvYHc8FPYw2gR2HQKVseiKwF5OXhxV7eDq77cDiE=; b=W12KQOeam84EY8RAFNX6G+kAI/b4XY5R3BbD/u4rNTkhLxoOtFGv0q7Mi/BRywIQtS mDJboIQ8fuVUXn/an5tLZkxdZ9E2crRfGICx52JwOYTui7aqNhzVvxxVVwtDDAlIR8kl xGZ4MzDLb/lP1zKS1g4Ad511o560ad1aymsdeQNOpWZMip8oPf0rHnf7TMn/3vdTGany UyHD1EO4P95IP3KAOOwTx5yfHYcWIWqCZ1PwIlMMuWhnOtOYaUg3Miwt7Uk32e9NtErS FyGezGpoaf6XLKZPsMTg9NMDozxRacZl71cYsTkWYpFKX0O8//qRdJ7xKmsOCWsuYrJi MAOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gbxEfaVs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id j187-20020a638bc4000000b005b8f24e6526si39533pge.234.2023.12.06.07.05.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 07:05:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gbxEfaVs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id C9358807DEF9; Wed, 6 Dec 2023 07:05:53 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442295AbjLFPFR (ORCPT + 99 others); Wed, 6 Dec 2023 10:05:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1442302AbjLFPFP (ORCPT ); Wed, 6 Dec 2023 10:05:15 -0500 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2617CB5 for ; Wed, 6 Dec 2023 07:05:21 -0800 (PST) Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-332fd78fa9dso792693f8f.3 for ; Wed, 06 Dec 2023 07:05:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1701875119; x=1702479919; darn=vger.kernel.org; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=hwMf7u3p+RDwOM148aayiXMLKhs7CLyC1S19yofYD4k=; b=gbxEfaVsmGL+nnmZc76/sZqBIMNdLzVRh0CPgYb27gtd3EQ1SCKi/eYbl4MKhWrd3v qiXO36nUN+QC2fXHViUcjpj3g50gtmrbwS4EfsbTQsASluESePe3PFILigu2lVsGU2rn NhjqK0QuqJ9TaH2QrxzWV6Yi6/tK5jzd8ReEOV5l16yxra76eeu/XcZJsj3i8HzovqIB dYoVxnN8oF3TAN9jID+TMZ5W73VZuukpZjLt8iTGiEiNY7uyn3PqLworGVmhvwRPXIJX Un7cBe2a4ItvFmDXkZ4kcyWGUySEzmTgrEefnc4+DWpJeCjRcHBWuMLMBRwsdh/1s3iN YOEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701875119; x=1702479919; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=hwMf7u3p+RDwOM148aayiXMLKhs7CLyC1S19yofYD4k=; b=P16b5Dg0/gBDTz2tiq5snCwKSdZJ98rG5ZgMatvI4T0PXKqROIajN4q7j2G6m4cDaD x4jcMx7qqnkLI/GUAqw6mqR3nf45l0q4Idfah2XUCvf3EM2b1t6u+OqMK5sAZxJDzTYg U8NZPM8d4TtVn3Kr5AALEovi32InItYykQQOHH8OqOfk9nXCyQDRIOcTVUiLpSgcXMu0 lsCLAELoc0tcEDdMEQJjMjeNB7W484L7Mz2oXma7S2Lyiudw9o5mec4zL/85pbaniCw5 ISdec6BDD7yTqbjAegvYXxm5l6MsN2EIXbqSnXJKvfCIhVTl1D8C35Z0gWQ01R41/wFX 72oA== X-Gm-Message-State: AOJu0YzZrCOrOlHfT2LiLabYDjS6bQUtxgAgGZl5J/YgrPy/CQ36tDL6 mo7YXNKox5l3usn5i/au6WLjVbVDHycJ7eyZpYs= X-Received: by 2002:a5d:564a:0:b0:333:387b:687a with SMTP id j10-20020a5d564a000000b00333387b687amr280196wrw.199.1701875119471; Wed, 06 Dec 2023 07:05:19 -0800 (PST) Received: from localhost ([102.36.222.112]) by smtp.gmail.com with ESMTPSA id o14-20020a056000010e00b00333359b522dsm12772792wrx.77.2023.12.06.07.05.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 07:05:19 -0800 (PST) Date: Wed, 6 Dec 2023 18:05:15 +0300 From: Dan Carpenter To: Dan Carpenter Cc: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH] drm/bridge: nxp-ptn3460: simplify some error checking Message-ID: <04242630-42d8-4920-8c67-24ac9db6b3c9@moroto.mountain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Mailer: git-send-email haha only kidding X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Wed, 06 Dec 2023 07:05:54 -0800 (PST) The i2c_master_send/recv() functions return negative error codes or they return "len" on success. So the error handling here can be written as just normal checks for "if (ret < 0) return ret;". No need to complicate things. Btw, in this code the "len" parameter can never be zero, but even if it were, then I feel like this would still be the best way to write it. Fixes: 914437992876 ("drm/bridge: nxp-ptn3460: fix i2c_master_send() error checking") Signed-off-by: Dan Carpenter --- This is not really a bug fix but I added a Fixes tag because I don't want people to pull my other commit without also applying this. drivers/gpu/drm/bridge/nxp-ptn3460.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/bridge/nxp-ptn3460.c b/drivers/gpu/drm/bridge/nxp-ptn3460.c index 9b7eb8c669c1..7c0076e49953 100644 --- a/drivers/gpu/drm/bridge/nxp-ptn3460.c +++ b/drivers/gpu/drm/bridge/nxp-ptn3460.c @@ -54,15 +54,15 @@ static int ptn3460_read_bytes(struct ptn3460_bridge *ptn_bridge, char addr, int ret; ret = i2c_master_send(ptn_bridge->client, &addr, 1); - if (ret <= 0) { + if (ret < 0) { DRM_ERROR("Failed to send i2c command, ret=%d\n", ret); - return ret ?: -EIO; + return ret; } ret = i2c_master_recv(ptn_bridge->client, buf, len); - if (ret != len) { + if (ret < 0) { DRM_ERROR("Failed to recv i2c data, ret=%d\n", ret); - return ret < 0 ? ret : -EIO; + return ret; } return 0; @@ -78,9 +78,9 @@ static int ptn3460_write_byte(struct ptn3460_bridge *ptn_bridge, char addr, buf[1] = val; ret = i2c_master_send(ptn_bridge->client, buf, ARRAY_SIZE(buf)); - if (ret != ARRAY_SIZE(buf)) { + if (ret < 0) { DRM_ERROR("Failed to send i2c command, ret=%d\n", ret); - return ret < 0 ? ret : -EIO; + return ret; } return 0; -- 2.42.0