From patchwork Fri Jan 3 09:18:52 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 854938 Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (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 A5D871119A; Fri, 3 Jan 2025 09:19:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735895956; cv=none; b=dtcVVencIqQKyho2g1hje3k7gxADshj6JPx5P3rZgfcsbs6SLlTCAOk5V+JVkYBCcquDlMEz0YEJpPzPVGbshaAMlX1SsHaoaHitruNO5kSik8YYG4SkM73Wap1Axk0RvaW2kfmrCdGmx5hiw+sqpMHS11eVCReKOLBrsrUnckE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735895956; c=relaxed/simple; bh=nvONnhRInxBTf32N5voMJ4stDfChre64pZCqb66Vp48=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sHXG7ZKmSbju2PtWzf9AEz2Jn5QrNPo8AEL3gNE1NStWYFXyaY8xrRnsH4gMUNBWPB8lxNSVfJ7Lraz2vqz/D/3cYc5zatSosAqMPCcXmeoNTbfQ9uRNw/c/+4Q7FbsjBkokxNqx9l9ZQX48mS2euvVjIKBDEyAbK+qdqRo3UlY= 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=kyVjT3Ew; arc=none smtp.client-ip=209.85.128.45 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="kyVjT3Ew" Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-436341f575fso125035295e9.1; Fri, 03 Jan 2025 01:19:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1735895953; x=1736500753; 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=DZC00Z9dkYVufzWTHzlU8berQ/ewDLFuIhT4jig9bpg=; b=kyVjT3Ew7zYRlSe7/p0M2eZqi5XACCVSPy6Tte74V0EQsRI7m5wBMh/RcHx+bQOmuC 8Ch1LDlB8xf7Nnl3QYyQd9+Hi9af9mT8Zs/LQXEUpe36dHOZp4TCFRVaJSCjlZslWzbp wH4Ij562YenK3kmS0/b6DY47kN4yNK8ypIK6L2NhqZNYzrrd4h208QwEzBsLXEDXIlu5 KIsmb1A75l16+bGVQYbAzkTh8FiSodj33OmP63HVb2KL5yLQgq7F6e82dvOBYwzzyCct ro4tzu9i832GYZzWcpN/n9wKu0jShddZbCmnQbnn5/qCRxeoheYeNBt/6TTPBcbMSDHG bRpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735895953; x=1736500753; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DZC00Z9dkYVufzWTHzlU8berQ/ewDLFuIhT4jig9bpg=; b=oC6sFyyl+o795cbxgzG22+++gg56VIN+YhipFB3Nrou9a9h4odoqsNL+XfSfQGuat1 gAxGGIX9agHXunbjgC2kXUWcVW5mKj/O7+3idEloi4Q1CC7A8Qp+7CnJUwjQtjbWC5xX eZg/Kk4JXGxJ9LwiXhCsQ3ASXuCvZ2+ruNp71cGGsFd1LQGX28qXeO6PkSLJwTjATYjn 4XM5q9r++NhqYMAqQNhzSjeT8mHEVzKJD9SMTknYs9gS3CTpLzFaOHCHVKAzgBImPd8o BYE/YjSvUog4mhCsebpZ7OvBAy8+v5lZSEZ/VAJBGFGm1xppuT7uIvoO1CoheP+E/3Sg PLLQ== X-Forwarded-Encrypted: i=1; AJvYcCUgAIM77jevFAvB1UABzl9ccyDAL06caZ3RVWNybo5kc8TjAAmZ4hTI6I3dpesBTNXkaM6NhWzoX0+gMUID@vger.kernel.org, AJvYcCVZDmovlosL821k1s+1Il+gPWpAvkwhL2GhXj4kpa4lMPEMU/EeFxPOXysirfApyswIYCpLEnceJhM=@vger.kernel.org X-Gm-Message-State: AOJu0Yx9/TwNnad+vI9WQy4tAY5N8sbNmSNo8Lx7CsTVQYYIiiThTmgH kbKHkhLoolQqPob3OzCPvR3a34pLWu6IDwc83lgas9j/WjM92/qO X-Gm-Gg: ASbGnct0h0nMWIX7FekiHGDFGunmjhQt8hQRaf1fupj5XZpPsEKv4gDmMD/hGH3MHWk PBPzlkPKl9ZuJOcPLrcuoY0lw5+++sthjMLgPGT7fEAwQeig7W3nORrX8MgWClvU9rCKhMBiG9h giKhbhTazkUVpGVYI6/w0CWc3gdBRuuoUHtmPWye+2NxCC+RH8DSwIgrrN/16x+409ZESKV1FJm ONiYZBBH8eNPdSp3FV9nfbj3gPqiFctSmPEE1ReiSvFqK/Z3Dfj/mZqO3j7ut3sxfsl5v+VUpGJ Bv9aoIQw8g== X-Google-Smtp-Source: AGHT+IHZc96f/buPB7yleSN0vTjAPMJ11rdQmR11PZzRhsf9/US/P9dDmXzK1MCbShQ4mOwiVwdTLQ== X-Received: by 2002:a05:600c:1c9d:b0:434:f5c0:329f with SMTP id 5b1f17b1804b1-4366854c17bmr415178075e9.14.1735895952690; Fri, 03 Jan 2025 01:19:12 -0800 (PST) Received: from prasmi.Home ([2a06:5906:61b:2d00:84e9:7adb:b646:c9c0]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4366a093cbfsm452493275e9.22.2025.01.03.01.19.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Jan 2025 01:19:12 -0800 (PST) From: Prabhakar X-Google-Original-From: Prabhakar To: Chris Brandt , Andi Shyti , Geert Uytterhoeven , Wolfram Sang , Andy Shevchenko , Philipp Zabel Cc: linux-renesas-soc@vger.kernel.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, Prabhakar , Biju Das , Fabrizio Castro , Lad Prabhakar Subject: [PATCH v4 1/9] i2c: riic: Introduce a separate variable for IRQ Date: Fri, 3 Jan 2025 09:18:52 +0000 Message-ID: <20250103091900.428729-2-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250103091900.428729-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20250103091900.428729-1-prabhakar.mahadev-lad.rj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-i2c@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Lad Prabhakar Refactor the IRQ handling in riic_i2c_probe by introducing a local variable `irq` to store IRQ numbers instead of assigning them to `ret`. This change improves code readability and clarity. Remove explicit error handling after `platform_get_irq()` since `devm_request_irq()` already handles such errors. Suggested-by: Andy Shevchenko Signed-off-by: Lad Prabhakar --- v3->v4 - New patch --- drivers/i2c/busses/i2c-riic.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/i2c/busses/i2c-riic.c b/drivers/i2c/busses/i2c-riic.c index 9264adc97ca9..c9b2ceaf4000 100644 --- a/drivers/i2c/busses/i2c-riic.c +++ b/drivers/i2c/busses/i2c-riic.c @@ -464,11 +464,9 @@ static int riic_i2c_probe(struct platform_device *pdev) return ret; for (i = 0; i < ARRAY_SIZE(riic_irqs); i++) { - ret = platform_get_irq(pdev, riic_irqs[i].res_num); - if (ret < 0) - return ret; + int irq = platform_get_irq(pdev, riic_irqs[i].res_num); - ret = devm_request_irq(dev, ret, riic_irqs[i].isr, + ret = devm_request_irq(dev, irq, riic_irqs[i].isr, 0, riic_irqs[i].name, riic); if (ret) { dev_err(dev, "failed to request irq %s\n", riic_irqs[i].name); From patchwork Fri Jan 3 09:18:54 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 854937 Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) (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 5817F1D432F; Fri, 3 Jan 2025 09:19:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735895959; cv=none; b=aNJvuL1h9jPH1HwgcTURATHl/r8Fh2WIFGn2JqetbD8LciT3UB9ECicfCUMgfJdoc1bmOBYGFiMXuW8cNtFQJ0/zIzguE//rxGDR5aZVlD1qWqsLW1WsxumS7LMK669wRQJSUf9vJnEv/61SHzbdejyp3pXTW1g26TBwtEeQb9Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735895959; c=relaxed/simple; bh=Cb/Xx1BBP42JVzj+xyi/HC4NS8Uto5wanu77JCmVC58=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=foTeN0mM8nu9Lc27VtNYq20W4ajhfXDSEjrJINckuqJEEVBcxKSv2yrsH6ssstDuZlZWslY4jGZ9ZaSXozyanoTOBwV0LTjDLlvjI1McHk2VUkGq5PaCHvQ1tiloz7jx6+xZ26NRLp10skYcBryCQZ510YptPXh2ukvwLrNjSVQ= 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=DcqbDMH3; arc=none smtp.client-ip=209.85.221.44 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="DcqbDMH3" Received: by mail-wr1-f44.google.com with SMTP id ffacd0b85a97d-3862a921123so8176272f8f.3; Fri, 03 Jan 2025 01:19:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1735895955; x=1736500755; 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=H6Idbb7bGpoVzKoKkuBpR2WvH0u9CWLrp2ifBVLPjBU=; b=DcqbDMH3OtGW5onLSx3/mMVaYnW8/8pYEEVD5/Bpbsu0XQLKMGr6Wd4fNmShKNOf57 jeO1dgVfg3TWb6n8MB5fja7H7MoHUvpKRI+/+PRVfqjscNhWW6n9OtesAmcDdqozK9a2 IzHGPZYoI3gdAuRH8y8OczngFhI/OCvj1aBNis/itGw3NVCRDMIJrQ9I+yjm/YmA0tm8 juJr2evq9mT6AB8k5i8CkdQdrBW2kHpOz2fyEnpRrRY6BnU1O7I8vS4ynXYPztEsRMp6 a00VtVxXeewlpZ9mgrQqxsplIHhgQshutFjbYIL6YY0etzvYCeTH57S2Vj02kArQxaUE F42g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735895955; x=1736500755; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=H6Idbb7bGpoVzKoKkuBpR2WvH0u9CWLrp2ifBVLPjBU=; b=ccA7I4vfu09QLQTbKStYYbrR5vHrMXN5BpqSQJeLX90T7IqY1oimca4mtlwKMLdxo2 hFiNuZiWWzEY8K2eyM7JEW5kuSyDhRZYdyNUvvJDRQ0wpPM6ixdK0sm5jSZwLcJ1xiwU mYSyUEmxMhu9BF9oulHRgyShed/1EamzpkJIcnbem+eWnkG7Xx02qWsU8OHCwiRUrpFT nVupQ6o3XjiDFvdl/HiljYPk1b/EN7wOftFTxb8N6X3iUJ5TSKUANHDhx8tTryAvh2Mt ydZZwsiv6PIW97E3ytkgrxmQG0YjkbGW24EC+Rn6DvUjaTTpcoqHYbyRmYd/hXn9JQCl iUIw== X-Forwarded-Encrypted: i=1; AJvYcCVfSYQAJdq6ZkQ4fBn6wf6CtkDS63ScYZia9fSN/c68UoMQlrD+0WLSFUcDEfFvhECF7LycJtL79FwVnkLz@vger.kernel.org, AJvYcCVjohTuN/OwZ0NAqZKmsa3HbovzJ10lzfVmW94p7Bh7UOSCPuNmuBwxvAZzUle1uBK9ZZmGHb/JbxA=@vger.kernel.org X-Gm-Message-State: AOJu0YwsddhYVvSvOTMIOFYQc0pPTpRAwPL2VDIe+TQwIqO0ArpxGZlN B+dv5Bl2fGZE4Rwxrz25eBQWjL23hoDWbeKztIeLSsesZh49Gjvf X-Gm-Gg: ASbGnctW5kdrVza4vvGJfouS0j2mCwD/5vMHkLyG1eJzOcAudVvR/SYnqnOYB5ODOAZ zser6LdQ/lbVNhhAhoZmgh2qxKlkq7b5WvCe2A1cOTnH5SJ45VzwtPenliXaSOSwPjgw8RoODwF cwsEJCG+jdBqd8AgprKOBUp5zssHb/X7HK4UpEqlVSYdM9y6VNl0jZWaR3RWrIICpotI+AS6nGZ dfiQmSuhSziR2246hCSrIkqfrwzfcpLDFh/bGfmBZEm996/L2M54VfjN3jgyEqT3ZOrhS5LiW6B H+LogTwkNA== X-Google-Smtp-Source: AGHT+IF5g6Cwah1nUH4293law20BWq2kOqEosji28czoj5s+tXSGVRYefZBOtc+tsL0eYZ30GPMwFg== X-Received: by 2002:a5d:64a3:0:b0:385:fae2:f443 with SMTP id ffacd0b85a97d-38a221fa238mr43347757f8f.34.1735895955042; Fri, 03 Jan 2025 01:19:15 -0800 (PST) Received: from prasmi.Home ([2a06:5906:61b:2d00:84e9:7adb:b646:c9c0]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4366a093cbfsm452493275e9.22.2025.01.03.01.19.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Jan 2025 01:19:14 -0800 (PST) From: Prabhakar X-Google-Original-From: Prabhakar To: Chris Brandt , Andi Shyti , Geert Uytterhoeven , Wolfram Sang , Andy Shevchenko , Philipp Zabel Cc: linux-renesas-soc@vger.kernel.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, Prabhakar , Biju Das , Fabrizio Castro , Lad Prabhakar , Claudiu Beznea Subject: [PATCH v4 3/9] i2c: riic: Use local `dev` pointer in `dev_err_probe()` Date: Fri, 3 Jan 2025 09:18:54 +0000 Message-ID: <20250103091900.428729-4-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250103091900.428729-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20250103091900.428729-1-prabhakar.mahadev-lad.rj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-i2c@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Lad Prabhakar Update the `riic_init_hw()` function to use the local `dev` pointer in calls to `dev_err_probe()`. Previously, `riic_init_hw()` used `riic->adapter.dev` in error reporting. Since this function is invoked during the probe phase, the I2C adapter is not yet initialized, leading to `(null) ...` being printed in error messages. This patch fixes the issue by consistently using the local `dev` pointer, which points to `riic->adapter.dev.parent`. Signed-off-by: Lad Prabhakar Reviewed-by: Geert Uytterhoeven Reviewed-by: Wolfram Sang Tested-by: Wolfram Sang Tested-by: Claudiu Beznea Reviewed-by: Claudiu Beznea --- v3->v4 - No change v2->v3 - Moved replacing dev_err -> dev_err_probe into patch#1 - Dropped fixes tags - Updated commit message - Collected RB and tested tags v1->v2 - Collected RB tag from Geert --- drivers/i2c/busses/i2c-riic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/i2c/busses/i2c-riic.c b/drivers/i2c/busses/i2c-riic.c index 9041936fde04..459f7158ed11 100644 --- a/drivers/i2c/busses/i2c-riic.c +++ b/drivers/i2c/busses/i2c-riic.c @@ -320,7 +320,7 @@ static int riic_init_hw(struct riic_dev *riic) : I2C_MAX_FAST_MODE_FREQ; if (t->bus_freq_hz > max_freq) - return dev_err_probe(&riic->adapter.dev, -EINVAL, + return dev_err_probe(dev, -EINVAL, "unsupported bus speed %uHz (%u max)\n", t->bus_freq_hz, max_freq); From patchwork Fri Jan 3 09:18:56 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 854936 Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) (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 121221D5143; Fri, 3 Jan 2025 09:19:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735895962; cv=none; b=d4gEx6cWUb9PVNhVATb623R+fhdIerqjnrmJe4zedFNzpYKC664ZUt8PP6WmC16uQnyVkQuMcZVxr3Pp3OfdEVk7I2w/cJBcIZAaeG4GS2yLvWuL0fkAth0v0P0JgfY5kBWmsInuiyd9yYaylgL+D6q98cMA0PgRyDhOv0udItY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735895962; c=relaxed/simple; bh=H3BGHV+hqByntCmC4Mk6Y1zGCgtp0X+ATVa5BuzUyqQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=h+Kwvxx0drVjjlDUpRJNOq+jdsYiksKHNBpQiSPmbkpTaxQYEsqAvZY0cDrxm0qFDpb+EQ136N71r0G/2eb6k0tyoFfe2QvG5stJ7KvC5L90zbyXP/pKo+dEWSTaqhqkTYYy9eNgHLfcoihwh5RBhFbCYtCPLdiPVJVyBLfi2kU= 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=Dzk6wYrJ; arc=none smtp.client-ip=209.85.128.43 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="Dzk6wYrJ" Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-4361dc6322fso79424745e9.3; Fri, 03 Jan 2025 01:19:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1735895957; x=1736500757; 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=bXymxgBA3nfQnH+aUrjAZrq/QguZ/NMkC+2P4OG0kmI=; b=Dzk6wYrJ4u795KwlEqg1ybL+8Jva4Aruk66Iqy89vKhto7xbeNoQWtaaNPTL4fWaZr lYfMX6KrfaN6vd59lFPirhjBzSADD1HMY4mB//hj2Wb3yZckh5Z7oNjgqFYhhiX6cxJx MwykogjUHVIcYTeqN++bg1O0nUAagPNdXHlCuI0OdMG9pQ7VyPwqyh/UdUMd8NYjQ3qC YxS34iEZc9tMgAkqn3igNgED7rpAJF4DRTKsQTC4MEoLy1yNr/yM2tEi/Cchx9q3hFpa i2PT7KwPAsaUFxU0+nf01XKuikTH/6823EWxbt0agkqVIZ5BpAELEpFQqfcIiFAVnX/3 nQ5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735895957; x=1736500757; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bXymxgBA3nfQnH+aUrjAZrq/QguZ/NMkC+2P4OG0kmI=; b=eFZ2rLXmKR7g63sdHY9R8j0C6SW8pCapmsvxUa7tQCg/eLhW4t70nzrKN6Szu+Jebo TmtHQ1ZG2Vye0JL1FeQMJJzbI9RnIk1too/YdzW9xSe91flYAbkcHPyfM47clF+TVoin KtrYBqTBByIXqqFMR+EIc7kx6tDutgcNm6jF35hpIru2mcWKVHD7lAQcGpOaY69IOrs2 ld+0btTgykDISJ/vKKDGuzRslS9hKw4UfXHJFvnm2hcEZ/7SCw7OU0lZcQ7yXaknr94m xRb4RpobVOT/hcfY7B4gEjHj3kSotu2JEJh5Qtx7rDayha9iZB7xQhDx2RAXUXgiSt5K ugIQ== X-Forwarded-Encrypted: i=1; AJvYcCUIVANXsAAGuIi1Un1xquxwB6bhBTIkKUBufXGctffWjv42ZOjsd4DZ7uOi+3+PuNoB6ctpXHJ0HjMpa2NZ@vger.kernel.org, AJvYcCUuxtN20Ahxpr15IV3t/FLQtmIt4MmUYHlpqO/NU9dMWkoBqKeHxDUDyCB9+tf1G+EOllwe7HcBbJw=@vger.kernel.org X-Gm-Message-State: AOJu0YwkxyH5fSoLUa7270xtYWe1utsIOl8XeU2GXD40sMyjHu1Jcjs1 6K8kZpy6zy6udevzyEahSnKZJA7aGHtUk45GnF7T+VyP6v2BayQ6 X-Gm-Gg: ASbGncuWYgyg6tmQJBL9O7abvui7cPI4jQ6HE6UoUMHEhYhpti8KGzH4LhSR2JoS4l8 tRRcuYA94NvKKEZzisvXdEeZnY2di65AcT5/N6oP+xJfeYvSgGj8Kcm1IKib8/F8ctAk0VTv8Bj EDOpTrGRbiQghsGDc+/xyOjRpvMGzWF6KFQu1ZGCldU0nFRQz9/73g8GGkWXyRFjmJ4Xeg7XTTi SInfgOMp4g2vSh+cFqQUN3WkoCrTqxVPlYB6hSuHhBJmg4JQcCxAvN846KA3xIA4LWfAvrF10y/ Nyvk0fdtOQ== X-Google-Smtp-Source: AGHT+IEg/rGbg9t+Pi0lEg5J93rtZ7Cl0ndnmH572G9tK1NtGFLJjVbCEFVwVd5Cb7rw73vdSyXnxQ== X-Received: by 2002:a05:600c:3b24:b0:436:2923:d23a with SMTP id 5b1f17b1804b1-43668b7a683mr328059965e9.33.1735895956907; Fri, 03 Jan 2025 01:19:16 -0800 (PST) Received: from prasmi.Home ([2a06:5906:61b:2d00:84e9:7adb:b646:c9c0]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4366a093cbfsm452493275e9.22.2025.01.03.01.19.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Jan 2025 01:19:16 -0800 (PST) From: Prabhakar X-Google-Original-From: Prabhakar To: Chris Brandt , Andi Shyti , Geert Uytterhoeven , Wolfram Sang , Andy Shevchenko , Philipp Zabel Cc: linux-renesas-soc@vger.kernel.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, Prabhakar , Biju Das , Fabrizio Castro , Lad Prabhakar , Claudiu Beznea Subject: [PATCH v4 5/9] i2c: riic: Use GENMASK() macro for bitmask definitions Date: Fri, 3 Jan 2025 09:18:56 +0000 Message-ID: <20250103091900.428729-6-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250103091900.428729-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20250103091900.428729-1-prabhakar.mahadev-lad.rj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-i2c@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Lad Prabhakar Replace raw bitmask values with the `GENMASK()` macro in the `i2c-riic` driver to improve readability and maintain consistency. Signed-off-by: Lad Prabhakar Reviewed-by: Geert Uytterhoeven Reviewed-by: Wolfram Sang Tested-by: Wolfram Sang Tested-by: Claudiu Beznea Reviewed-by: Claudiu Beznea --- v3->v4 - Included bits.h - Since the changes were small, I've kept the RB/TB tags. v2->v3 - Collected RB and tested tags v1->v2 - Collected RB tag from Geert --- drivers/i2c/busses/i2c-riic.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/busses/i2c-riic.c b/drivers/i2c/busses/i2c-riic.c index 5551964c3971..ab9ec7f12032 100644 --- a/drivers/i2c/busses/i2c-riic.c +++ b/drivers/i2c/busses/i2c-riic.c @@ -34,6 +34,7 @@ * Also check the comments in the interrupt routines for some gory details. */ +#include #include #include #include @@ -56,7 +57,7 @@ #define ICCR2_RS BIT(2) #define ICCR2_ST BIT(1) -#define ICMR1_CKS_MASK 0x70 +#define ICMR1_CKS_MASK GENMASK(6, 4) #define ICMR1_BCWP BIT(3) #define ICMR1_CKS(_x) ((((_x) << 4) & ICMR1_CKS_MASK) | ICMR1_BCWP) @@ -74,7 +75,7 @@ #define ICSR2_NACKF BIT(4) -#define ICBR_RESERVED 0xe0 /* Should be 1 on writes */ +#define ICBR_RESERVED GENMASK(7, 5) /* Should be 1 on writes */ #define RIIC_INIT_MSG -1 From patchwork Fri Jan 3 09:18:58 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 854935 Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (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 E80271D5154; Fri, 3 Jan 2025 09:19:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735895964; cv=none; b=ZuYZmk9ta6WX0+nepi3qZl+U4hsL70DDEYLvYJSR3PQJ2LZUXg8U/ktSSpb5aADO7XPQfFDVCh39y86pjcNCeBSlyva4zMNs1eAxOW3o9vFeEA6OEb7S3b1BNFp1nYfHHaa3GLfqGekxxeJc6EgdDIajO2pfTqBx3AbMdSPsoMY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735895964; c=relaxed/simple; bh=aK5JtUupKOmP6fpq0zjMaKUa69XCr4gZnjAvboTppgM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=a7Ziq8CowANewtDs9AxzcBpk6d1tb6V+sOmf9Oo2FCzPVzwewtDBhRfQJ6W5Hpqq+gjAA1q88uY7zgX+mB1E20x2G+2pG85yluqox1TC7BUBCc/qnREGrC++Wgi4Ujl99G06L+ycZERjiqifJ5X+WhFDSwbkg1KRKnua6UEU0ro= 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=Z0XTomPB; arc=none smtp.client-ip=209.85.128.47 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="Z0XTomPB" Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-436ce2ab251so902655e9.1; Fri, 03 Jan 2025 01:19:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1735895959; x=1736500759; 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=Dqc4S3D6pdOcxominqczIDsj878t38ZnFEbh7Pys8XE=; b=Z0XTomPB2v/62zLPCHYT9q6IlCCwKc26YuwVlk/EeW4dvQ6p+heD2e1q08LxpgiLj7 UVPClLszj5YsS8IEfN49O//6WNOzAS/yB5tIHwzscyPfr4vx3wWA2jtYx5LwCPEuMsX6 Ac2lGytkOXkEPGkEfCFZfzA12CpKiRBlhJAYkAmt47leql40mY/jy0I8TBg7wEXUMo5h kw14U0M6qga2NrH8tImtuvRo2rFjeiBxwtaAGcf+vD//c0wuUNFIQTrxmnVCrosWcnS7 9pt2nBWH6bk4L4AKoNnbvE7SukZTNtexxskzme+k1f8krxCi9agdXubPBCPxisKpCb+k ozMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735895959; x=1736500759; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Dqc4S3D6pdOcxominqczIDsj878t38ZnFEbh7Pys8XE=; b=Qn3EZh1xWICNm1VpRDuSc39cwFoMCh0mw7MXh5SYUY8iyc7R9z7iuIML7t5JNCyWec 3W51taOlKHj7F7crEwh3zmgTPyh68/TYvtECADDcLWd9UlpiiYvhVSs909L5zE2gYQHL i6nqpW/PoOkuA/6YQ464p7UiMRHZV2qYcBMGwVuarZ6VSYPLchYElGvm3HrvxBPPY1Vd M3IAQwt1WR+aGarwRYFoS9n+ImgELZ8CTUNbTjIGB2LTS9qhabww5ezEgKl+dY3J9HIW YcmNZLwcpYb05vw8stFIz/z0hg8vJvprUWM3KzeLTxG7bdbHC5Cx5/42uDqNVJ9GMOCX dShg== X-Forwarded-Encrypted: i=1; AJvYcCUJEXCHifzjDBHGI5SHGqMNAIIyhCfG39TNgEMMLFcqsFAMDWwNH06UpbuPCLR+6BawNYLSDQPxRepU0Kbx@vger.kernel.org, AJvYcCXhnd+fY1D8JSaYX/3WhVv/5Re4dzcHlxiMbF77n3nZOjS36qxhroQZwLmh6vtchetttz3g4qW5l2w=@vger.kernel.org X-Gm-Message-State: AOJu0YyaCUVz+C5+slxd2tFw4Rc3YdSHJc/Ih+WPIPirPfWcsKQVgPEY AC0fnu+kkPE0m5JjtMIfQR/EAZanWF98SLedr2LTQpRp/q4kvFHd X-Gm-Gg: ASbGncuh11jkJaHMhXiwngFYbqpDdiQAEhRZvWtkER+fBaCNW6hNETnNXMHeS3mt1jz rCWH0OzFdUclSgw1IYdnP/DbX+7jv8ZHLtzh645A0zgsCefCKgVDQBRzURM9iI7SRfxXJBV/Vx/ iEGrLxaJfZroxNfFerT+AbpArtfHEHLD8KWLC3yUFCGsdoC9n2Bebzg0vmrqzZGsKtdbwWxJE/x QaSDvIGpIfqmk3DN74RsygAE7xPFLnGRFy168aoTf9kvVQtzyx+w1juByByUyol9gabSrwO4KSH NMXWSl1b/g== X-Google-Smtp-Source: AGHT+IEFbAUFUDwmhAVIZRwPIXJ1h6DyvUqlZe4tom9/tX7Omh6fs1VNNnZ+JJsEecjqp3p1gvwmrw== X-Received: by 2002:a05:600c:1c1a:b0:434:f0df:a14 with SMTP id 5b1f17b1804b1-43668548500mr377792285e9.2.1735895958863; Fri, 03 Jan 2025 01:19:18 -0800 (PST) Received: from prasmi.Home ([2a06:5906:61b:2d00:84e9:7adb:b646:c9c0]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4366a093cbfsm452493275e9.22.2025.01.03.01.19.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Jan 2025 01:19:18 -0800 (PST) From: Prabhakar X-Google-Original-From: Prabhakar To: Chris Brandt , Andi Shyti , Geert Uytterhoeven , Wolfram Sang , Andy Shevchenko , Philipp Zabel Cc: linux-renesas-soc@vger.kernel.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, Prabhakar , Biju Das , Fabrizio Castro , Lad Prabhakar , Claudiu Beznea Subject: [PATCH v4 7/9] i2c: riic: Mark riic_irqs array as const Date: Fri, 3 Jan 2025 09:18:58 +0000 Message-ID: <20250103091900.428729-8-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250103091900.428729-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20250103091900.428729-1-prabhakar.mahadev-lad.rj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-i2c@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Lad Prabhakar The riic_irqs array describes the supported IRQs by the RIIC driver and does not change at runtime. Signed-off-by: Lad Prabhakar Reviewed-by: Geert Uytterhoeven Tested-by: Wolfram Sang Tested-by: Claudiu Beznea Reviewed-by: Claudiu Beznea --- v2->v3 - No change v2->v3 - Collected RB and tested tags v1->v2 - Collected RB tag from Geert --- drivers/i2c/busses/i2c-riic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/i2c/busses/i2c-riic.c b/drivers/i2c/busses/i2c-riic.c index 0953fedac786..eff1efd381dd 100644 --- a/drivers/i2c/busses/i2c-riic.c +++ b/drivers/i2c/busses/i2c-riic.c @@ -416,7 +416,7 @@ static int riic_init_hw(struct riic_dev *riic) return 0; } -static struct riic_irq_desc riic_irqs[] = { +static const struct riic_irq_desc riic_irqs[] = { { .res_num = 0, .isr = riic_tend_isr, .name = "riic-tend" }, { .res_num = 1, .isr = riic_rdrf_isr, .name = "riic-rdrf" }, { .res_num = 2, .isr = riic_tdre_isr, .name = "riic-tdre" }, From patchwork Fri Jan 3 09:19:00 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 854934 Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) (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 572761D5CFF; Fri, 3 Jan 2025 09:19:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735895966; cv=none; b=rVgKx/rSQJ5lwLueDQHQF7VqvOrL6uhoS4hSjNPj7cxA74WV46XukNgSeiHUh6y9qN1sL77k821gpYelmc48R5HvMFV+SBKvt/n8HDn4aqRpbsMJ8qdgAGmyqqgCChS7Hc6YycyHQ1H8Odg1QY5Fzl/uCDcsfqRpb4XkUjBK6MI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735895966; c=relaxed/simple; bh=+4OMMUZfh4BkjVViKYkCPGwka9jdUb6j6tqSnv6+3wg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Vc8XsEfsC6u07INhknB6V2T1OqxGFyBZDGIlmkty8y0USoK4bm4MJ8RxHFvoY7pZ4XX0jLwthwtIFXLu8R2jA/wOzVojqclAbpeq2ejDBmXLzKNa0Z9co0PpFPAHBZHVWzNsdwGIofUL7IIRJvTjFf3YDULoxhMG8jLXf173LNk= 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=OdruoAl8; arc=none smtp.client-ip=209.85.221.52 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="OdruoAl8" Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-385df53e559so9492117f8f.3; Fri, 03 Jan 2025 01:19:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1735895962; x=1736500762; 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=0yurOIfpt2Q3gkoaHQayh4cFDnUaXcdQ7j4zWTYnga8=; b=OdruoAl829fkBBvNb95wYYsal5O8eg5iksqZ9IzY9nedj/E+63qmcN4X7l1piI1D2r /H2T4VJzJtSVpSAmTFsM6O/i5ZLy08AZKdV1zlvHSOdnXwjm2dzt5kSBdhw+n9KH+4eB ycLyKMI1SQ4iN/p3xDWt5Ws6a/PtS3kqHIuEBzpGC+6jIu5AXbCKguPjlxIVatHuC7rY FR/X5hZSqJF6cYUiFbrHK8BnzsUutK3AmFYREku7XcSZDIFpk0IH5SsJ8YfTLAp/Ecak VMsmjp3zC3TnNu/bYWEC3LO2mRWQtYb6j5vZHZRoJCZKv0ZzyXrxNZMx7p251+XJRi18 AsEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735895962; x=1736500762; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0yurOIfpt2Q3gkoaHQayh4cFDnUaXcdQ7j4zWTYnga8=; b=J7SEHCZVbFqCV86LNUZ2ru0vMr1YTZPQY5J8mbtwJ3zOxFIvhCaaWjyM6pvFzEctp/ cHp0Cm8uQNwaYhDFqwErlUslpidOA8hxO4qoBhlIg0ZRcPhnQxyx13haOurXnJsv4tul 075L3uUFng+zdX8a35HCMwos7hlDHB02KwcOYzZeK1slCd6hN5jFrv4T2znNsX8JEk67 gqTiRWJv47OulOZUx5GmUTUoRMjU1n+MCYs640UIi5rFqPyjsKzAd68aIF+Q7TE9JkUV n7Acb8vMqGY5XMch31U2LPOWKRTgZOF9/h8mGYwoMACQ2GNXQOqrvlolLx6/FNjjIKFa yHng== X-Forwarded-Encrypted: i=1; AJvYcCVbfUXbLYPsG+Mlq+BouuDqY4K2sPYrlcNTC5MxA2e9nR5xwTv/+VdUT4wSBa6bBEirJw+ERezCYyJRaviB@vger.kernel.org, AJvYcCWiSry4L9+MPzl2YIYYRn2SjF8AFvQsY+r0aVgOrWSE1jwtOls/89jeg/faAJtV+5Rks6zjRa5DOXk=@vger.kernel.org X-Gm-Message-State: AOJu0YxIT/3J/cHcJ0PxjFU6qvbUIt95AuQZRWvVGwq6uzpKf3LaPwEQ eMkxG89cRUL5ILmlq754o9CYgK4Q+LMWIpi84v9ih/O5w/JUnJ2q X-Gm-Gg: ASbGncvB8kP1upxXMcU1taWnXxvWJnVUmRf74zNEux49zNfcL+qI9eYg8ws+D7CL1wg YOxI6Sru9AZFitmfYmU0yPOlzoh2gYGqeppLaZPW0xbJB0ctFv+Uc9cg2KhZOXiNnUhi/mV0jnX 4wxGRq+XrGLCojkyDu4Zt2dR1ZRihHgNmvAMsWQFMVky5bFy7CjE8FghlSbA+B5O0HkDHkS5i5Q SvQSCm1QmY/qInkbs3zxkxxxHFlprW1tswRqzD35f9AbMDOkCzETuX9oW6iIMyaBgSTU5MsS9Q8 GpMz0sCL7Q== X-Google-Smtp-Source: AGHT+IGj8NOm0X5nYwtYCd25/+ipYX/YuBIj/NeTZQqmtUaVhfyGmm7CLVb4/eebxY58FNsJZNud0Q== X-Received: by 2002:a05:6000:144b:b0:385:efc7:932d with SMTP id ffacd0b85a97d-38a223ffb44mr40446408f8f.46.1735895962154; Fri, 03 Jan 2025 01:19:22 -0800 (PST) Received: from prasmi.Home ([2a06:5906:61b:2d00:84e9:7adb:b646:c9c0]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4366a093cbfsm452493275e9.22.2025.01.03.01.19.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Jan 2025 01:19:21 -0800 (PST) From: Prabhakar X-Google-Original-From: Prabhakar To: Chris Brandt , Andi Shyti , Geert Uytterhoeven , Wolfram Sang , Andy Shevchenko , Philipp Zabel Cc: linux-renesas-soc@vger.kernel.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, Prabhakar , Biju Das , Fabrizio Castro , Lad Prabhakar , Claudiu Beznea Subject: [PATCH v4 9/9] i2c: riic: Add `riic_bus_barrier()` to check bus availability Date: Fri, 3 Jan 2025 09:19:00 +0000 Message-ID: <20250103091900.428729-10-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250103091900.428729-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20250103091900.428729-1-prabhakar.mahadev-lad.rj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-i2c@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Lad Prabhakar Introduce a new `riic_bus_barrier()` function to verify bus availability before initiating an I2C transfer. This function enhances the bus arbitration check by ensuring that the SDA and SCL lines are not held low, in addition to checking the BBSY flag using `readb_poll_timeout()`. Previously, only the BBSY flag was checked to determine bus availability. However, it is possible for the SDA line to remain low even when BBSY = 0. This new implementation performs an additional check on the SDA and SCL lines to avoid potential bus contention issues. Signed-off-by: Lad Prabhakar Reviewed-by: Geert Uytterhoeven Reviewed-by: Wolfram Sang Tested-by: Wolfram Sang Tested-by: Claudiu Beznea Reviewed-by: Claudiu Beznea --- v3->v4 - Propogated error code when readb_poll_timeout() failed - I've kept the RB/TB tags as the changes were minimal. v2->v3 - Collected RB and tested tags v1->v2 - Used single register read to check SDA/SCL lines --- drivers/i2c/busses/i2c-riic.c | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/drivers/i2c/busses/i2c-riic.c b/drivers/i2c/busses/i2c-riic.c index 042933a2a985..bb8383d53b52 100644 --- a/drivers/i2c/busses/i2c-riic.c +++ b/drivers/i2c/busses/i2c-riic.c @@ -41,6 +41,7 @@ #include #include #include +#include #include #include #include @@ -52,6 +53,8 @@ #define ICCR1_ICE BIT(7) #define ICCR1_IICRST BIT(6) #define ICCR1_SOWP BIT(4) +#define ICCR1_SCLI BIT(1) +#define ICCR1_SDAI BIT(0) #define ICCR2_BBSY BIT(7) #define ICCR2_SP BIT(3) @@ -137,6 +140,27 @@ static inline void riic_clear_set_bit(struct riic_dev *riic, u8 clear, u8 set, u riic_writeb(riic, (riic_readb(riic, reg) & ~clear) | set, reg); } +static int riic_bus_barrier(struct riic_dev *riic) +{ + int ret; + u8 val; + + /* + * The SDA line can still be low even when BBSY = 0. Therefore, after checking + * the BBSY flag, also verify that the SDA and SCL lines are not being held low. + */ + ret = readb_poll_timeout(riic->base + riic->info->regs[RIIC_ICCR2], val, + !(val & ICCR2_BBSY), 10, riic->adapter.timeout); + if (ret) + return ret; + + if ((riic_readb(riic, RIIC_ICCR1) & (ICCR1_SDAI | ICCR1_SCLI)) != + (ICCR1_SDAI | ICCR1_SCLI)) + return -EBUSY; + + return 0; +} + static int riic_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num) { struct riic_dev *riic = i2c_get_adapdata(adap); @@ -149,13 +173,11 @@ static int riic_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num) if (ret) return ret; - if (riic_readb(riic, RIIC_ICCR2) & ICCR2_BBSY) { - riic->err = -EBUSY; + riic->err = riic_bus_barrier(riic); + if (riic->err) goto out; - } reinit_completion(&riic->msg_done); - riic->err = 0; riic_writeb(riic, 0, RIIC_ICSR2);