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: 13925399 X-Patchwork-Delegate: geert@linux-m68k.org 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-renesas-soc@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:53 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 13925400 X-Patchwork-Delegate: geert@linux-m68k.org Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (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 CC5531D2B2A; Fri, 3 Jan 2025 09:19:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735895957; cv=none; b=FCUiZBkEAX1CXashlub8H3oQbbpBmrPFriwDqizHA/bzkpUsxerrJy1DmuuhaZsVWbmR7hE0KN9JbxFA1W02mekNHR/UtxhDa/AN6g52w8yNQFFQxDHVVpndpi244nk0lnyUfLB8NA3WnSFKnhY7z529LdFB+UJS2O6dK5NEqSY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735895957; c=relaxed/simple; bh=bULAalD5QJBL9vIjSovbP45/QlOuIW1he2eC8KwtC4c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Nl+z/CEkDnhTCdXjZ4zjDHZhOwDFvTfefhsY7nbIIXdaKPkT4/q2t2MDraEba2PAf69ExZeeMOhbTBFI5OYTg7P7aaC/P6a6KvJ8ArVtYtoSVpP4sdaAFkYbK/HrcyWiaMahsRqVj9CljVUec0nQ/utCtbHmmNV7d4kLUBtAqDA= 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=cULrHFKb; arc=none smtp.client-ip=209.85.128.49 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="cULrHFKb" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-436637e8c8dso122759415e9.1; Fri, 03 Jan 2025 01:19:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1735895954; x=1736500754; 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=W2OPM7TGlALYjuAONwjHdanb07QeJdpPzvLSV0+BUrg=; b=cULrHFKboTYMLKLCRvj2TwJhANTisYPLp+B6JxuooXAmyNN2WTd8zk8n23xpA/i7u2 Vyrrlc7X5vdLYNZwEjKThhTqtfBdSxCHhjuYoDMr6AyxhYFPRSommvbCIiAIkfFKQQa6 /GkXjyFVlzsvw1Sg4Y9rAimCbc/6iQoz8PuS9iilyd3omyV8nNpjteSh4Ia+XlomENFF yLfS37VgAgZzOfWp9Xvy99LMUEgh8+4WaDU2qGdfwPSWzwV9j5ZDIzz+3At9Hzr//WsQ 3BDSV0Skps5CAvjAlunmjflrIsBailDb5/Zo+w+eCZcBmR/tL039ub/8wNeLqttUu9MM 5zoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735895954; x=1736500754; 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=W2OPM7TGlALYjuAONwjHdanb07QeJdpPzvLSV0+BUrg=; b=KkXe5IrERZOvXPOxEwluTWnxufTRXBybsmO8j9rm5nqVxESXDhD+CxzDpH/2N6Ombu OoSM8u0ZiNQmNGbVxzXXz2Co+7wPn0LZLwQw64GQdDxBMlrupZtLeYytgPc+/O+q/Hnm aVlaBiYfSy/viW1KdZio5XHc5MpveUQbtsNOAU4lSvh+y8P5Ay+g2SDTQKeDhuhbZQr2 kw9Om+v3K0yPqgB/78e+nftxzPP55KeRDZbzmd7Rbd438qBXfo/kKxJuifCdLQdGlFGU mejamTyMSZuICI+Oatm8N0bYudowxpH8My84hjBxk76rJjf5P23aM7BWV7EdOH+4hUFW ESgw== X-Forwarded-Encrypted: i=1; AJvYcCUt+I8REl33MOctIhA7HbRgAv9o/AeD6PpwzNmRJBNaredarc13TRZN0XYqFrfzFKyJtV8rLoK9gCorPAfq@vger.kernel.org, AJvYcCW4l2f+s9r0Hkts+QlQwf86LLqM4T6oGlvvbcL3juPot4p5av0dx9AivfZc0pBUsY81lMacgvRW82Y=@vger.kernel.org X-Gm-Message-State: AOJu0YwafCiv+2qLEoEL6RU7s8kgD7AGif4ZIjtGp2SvtsA8zWA/hCSU 3HVnTgWmDKaV7JUEnAFuWViGYq4jJmrGZNlIzYyZPMrF0MfkG9oX X-Gm-Gg: ASbGncs1VIhb9f+RSIN8ElLsNpcZJW1UgOHi/42ezA66VPFVczRSPDuSqveNCwpOs4c 73CYUnjTOVuwrWghyE43xGtsWkdct9KV3PVXuQGtv/lSzfss0KmpaNGJLafTtTmM+1rCSyabOb7 XuMLM2lKmOigUEmq+fSpKibACOo8iwpud+Is82xFfzYnIPMhg1j/i5WI76FuyUEvs+QGbIFG+5m 9BKJVWN/8cd3RQPiHMiEZKgwUHwdvQxpFt5oHxVFVzgWp69Ku5FKeQCpP3LaA4y6BLTcXOVLCTl QFXN8uRFQg== X-Google-Smtp-Source: AGHT+IGbXZOIhq3ZwWqYUA2M/NS4pwsMVul7dLJya/8cPi0GT77oEa4UlW158deCfcEPMlvC6RFLsQ== X-Received: by 2002:a5d:64eb:0:b0:386:3711:ff8c with SMTP id ffacd0b85a97d-38a221f1fddmr36113049f8f.23.1735895953806; Fri, 03 Jan 2025 01:19:13 -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.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Jan 2025 01:19:13 -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 2/9] i2c: riic: Use dev_err_probe in probe and riic_init_hw functions Date: Fri, 3 Jan 2025 09:18:53 +0000 Message-ID: <20250103091900.428729-3-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-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Lad Prabhakar Refactor error handling in the riic_i2c_probe() and riic_init_hw() functions by replacing multiple dev_err() calls with dev_err_probe(). Additionally, update the riic_init_hw() function to use a local `dev` pointer instead of `riic->adapter.dev` for dev_err_probe(), as the I2C adapter is not initialized at this stage. Drop the cast to (unsigned long) in the riic_init_hw() function when printing the bus frequency, and update the error message to display the frequency in Hz, improving clarity. 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 - Dropped `unsigned long` cast and updated the format specifier while printing bus frequency - Since the changes were small, I've kept the RB/TB tags. v2->v3 - Squashed dev_err_probe() change from patch #2 into patch #1 - Updated commit message - Collected RB and tested tags v1->v2 - Collected RB tag from Geert --- drivers/i2c/busses/i2c-riic.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/drivers/i2c/busses/i2c-riic.c b/drivers/i2c/busses/i2c-riic.c index c9b2ceaf4000..9041936fde04 100644 --- a/drivers/i2c/busses/i2c-riic.c +++ b/drivers/i2c/busses/i2c-riic.c @@ -356,11 +356,9 @@ static int riic_init_hw(struct riic_dev *riic) rate /= 2; } - if (brl > (0x1F + 3)) { - dev_err(&riic->adapter.dev, "invalid speed (%lu). Too slow.\n", - (unsigned long)t->bus_freq_hz); - return -EINVAL; - } + if (brl > (0x1F + 3)) + return dev_err_probe(dev, -EINVAL, "invalid speed (%uHz). Too slow.\n", + t->bus_freq_hz); brh = total_ticks - brl; @@ -445,10 +443,9 @@ static int riic_i2c_probe(struct platform_device *pdev) return PTR_ERR(riic->base); riic->clk = devm_clk_get(dev, NULL); - if (IS_ERR(riic->clk)) { - dev_err(dev, "missing controller clock"); - return PTR_ERR(riic->clk); - } + if (IS_ERR(riic->clk)) + return dev_err_probe(dev, PTR_ERR(riic->clk), + "missing controller clock"); riic->rstc = devm_reset_control_get_optional_exclusive(dev, NULL); if (IS_ERR(riic->rstc)) @@ -468,10 +465,9 @@ static int riic_i2c_probe(struct platform_device *pdev) 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); - return ret; - } + if (ret) + return dev_err_probe(dev, ret, "failed to request irq %s\n", + riic_irqs[i].name); } riic->info = of_device_get_match_data(dev); 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: 13925401 X-Patchwork-Delegate: geert@linux-m68k.org 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-renesas-soc@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:55 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 13925402 X-Patchwork-Delegate: geert@linux-m68k.org Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (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 B857A1D2F46; Fri, 3 Jan 2025 09:19:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735895960; cv=none; b=AkJdFQNok4x6fChv2dN6eHYpH1Tg98Q50nVHU7gPUgLp8D0L1SL3KSSyGk/EzFBWHYfAJgHysOhKkk54L/gSl4zkIrjJGYK+lKgfLhgMH5noAnUmtqDX8VKO+TE2TxtU2c0q5kj+NAeSTyzhKqOeaBq9QBfXrHt6dFmI+yNo//U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735895960; c=relaxed/simple; bh=zkRrUObJmVJ9XbJbPhkBEEXKgumRrCvPWXppMfRVLd0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=K3YHXV7FFTpkutdD7uD+WbFR5Gn4B608YzxLY4TgwY8eKIhACxk5LZfq992QOwEdHZ4/kffCfqiX9hIp3aWQj/czsbSYU2DNyiQTNpz7rkLlZVdzRPXjjL/udIU/9WfvwQt+0KvbYsXnjxIHTkbfXJm270zrVFFVBmPCPx6ywVA= 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=HrWFMcXl; arc=none smtp.client-ip=209.85.128.48 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="HrWFMcXl" Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-4361c705434so87524255e9.3; Fri, 03 Jan 2025 01:19:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1735895956; x=1736500756; 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=J2HVpu9VKlVzY8IdkZhOKiWna1uiPP+wmt/t5mxL2t4=; b=HrWFMcXlf4nKxpT2NsRIQCSysrX0DxLW/QF2qe28sRclw/2Lm+rrMABoQnu3D66oYD 2qb9nYxT6sGj3h6xHB+/a3kDQrVFlwQqckydLh8d29fd1V3aHovbDAxrHC59cFam5h+B Q/GYJI5OuwDgt1k3voqq5r50l1ExHCD6R9r0Gj4eL5BLljAnzygJhwXaQe6oZ9LI5I5d DhlvE/Feo1smPQM6d9tCT/ByLRDVIf69o8ZTVNOsq603AXVhGHX/WLsJVXOiAnsz764A XMbyjywVNQQoSXqloiklvrQvAkiWXnYxnD6TDfW03YYbnwSAssWw4ijoE/nN9ID8e+yT aKSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735895956; x=1736500756; 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=J2HVpu9VKlVzY8IdkZhOKiWna1uiPP+wmt/t5mxL2t4=; b=ZBwwLneCMj1rV9ap2/C17NQlHZGidZqh+QHKGAwcIWaYbPiSj+1/Rh9kBC9BCHzCtD WhAK82hMj6otu75gBB7jsNwEOXUDihlKz6QYzFu2fRbykX7NtkT5tNbIGncydLrVrdE0 Ocx+ujg6GWtrqu/OzTLdOauzsz8iGI/gaEqN7sfQupybIMlDgZVF8YHexEN4/seRHyT4 3oJXRtSS+CERf4P+FwkbrkFXb481L5SmYipj7QOdFn0W2XxGdLp3lA5hMkqlIom1DmZ4 BOIgUBt4y5L+xuXpJ+Ishko9StlSlUAT8MlC5JVH4dUIMvJv/d/dW/lj+LscLx3evqgS Z4dg== X-Forwarded-Encrypted: i=1; AJvYcCUI1/kkxwTDZ4yXQp3sk4CcoAHKiLajehfZgEyF/QyjZ5GUmjrSk/MH4BVPnt4/DBV8UZ1C0MxBP3I=@vger.kernel.org, AJvYcCULiNXQDrbIH5JsAyQgaW2XKStOyIwjwmNi3QdgDIkPnOr31A3BZjjTFB/sqkkGzI1wlvrfgvYXnLi5eGro@vger.kernel.org X-Gm-Message-State: AOJu0YwjLSzaFuNStGRpG/NXIO2nxB5P5CgXQvH0VGYZvb+O93AAfT7w qW9hXJPLHy7+afbzkWXBB1Lw7mEN3MR3twR16Fac/asSM0OKD/iy X-Gm-Gg: ASbGncunc0TBsKy3/D9VzLQ/8mabcB7Z2LqOOWHZSfliU8Gm13jjYK10bgZ+YPpWVUt lsNSlwui6j5sbE71/vo0dqWqq4tXH06JDdGhLAFhjI+CF3yXd1vtoJWxIO41rTLhRjAvdSVf2/v hFXVnuLD45OJAL3/GMWbM0FyggKsqUU5jrVgYI/dx7rauITqn8FJHXsjZRpKO/NXDTNFuFsRKZC l9N2apMMekdfwKx7N1SIs1m4zyx6aGR7hRJ2nqS7xQH/raGqlt4dBQZo3dnz4UTEpN92MVNum+7 UmQBULKKRA== X-Google-Smtp-Source: AGHT+IH4+6w4OKa2DqT69LRW9WmPeorZEubkFLvWp64oZz/hpENXwQwdi4VP6FcTFTVWOy30ULwPsA== X-Received: by 2002:a5d:47c9:0:b0:38a:615c:8223 with SMTP id ffacd0b85a97d-38a615c82bemr8284509f8f.10.1735895955911; 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.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Jan 2025 01:19:15 -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 4/9] i2c: riic: Use BIT macro consistently Date: Fri, 3 Jan 2025 09:18:55 +0000 Message-ID: <20250103091900.428729-5-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-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Lad Prabhakar Easier to read and ensures proper types. 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 | 37 ++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/drivers/i2c/busses/i2c-riic.c b/drivers/i2c/busses/i2c-riic.c index 459f7158ed11..5551964c3971 100644 --- a/drivers/i2c/busses/i2c-riic.c +++ b/drivers/i2c/busses/i2c-riic.c @@ -45,33 +45,34 @@ #include #include #include +#include -#define ICCR1_ICE 0x80 -#define ICCR1_IICRST 0x40 -#define ICCR1_SOWP 0x10 +#define ICCR1_ICE BIT(7) +#define ICCR1_IICRST BIT(6) +#define ICCR1_SOWP BIT(4) -#define ICCR2_BBSY 0x80 -#define ICCR2_SP 0x08 -#define ICCR2_RS 0x04 -#define ICCR2_ST 0x02 +#define ICCR2_BBSY BIT(7) +#define ICCR2_SP BIT(3) +#define ICCR2_RS BIT(2) +#define ICCR2_ST BIT(1) #define ICMR1_CKS_MASK 0x70 -#define ICMR1_BCWP 0x08 +#define ICMR1_BCWP BIT(3) #define ICMR1_CKS(_x) ((((_x) << 4) & ICMR1_CKS_MASK) | ICMR1_BCWP) -#define ICMR3_RDRFS 0x20 -#define ICMR3_ACKWP 0x10 -#define ICMR3_ACKBT 0x08 +#define ICMR3_RDRFS BIT(5) +#define ICMR3_ACKWP BIT(4) +#define ICMR3_ACKBT BIT(3) -#define ICFER_FMPE 0x80 +#define ICFER_FMPE BIT(7) -#define ICIER_TIE 0x80 -#define ICIER_TEIE 0x40 -#define ICIER_RIE 0x20 -#define ICIER_NAKIE 0x10 -#define ICIER_SPIE 0x08 +#define ICIER_TIE BIT(7) +#define ICIER_TEIE BIT(6) +#define ICIER_RIE BIT(5) +#define ICIER_NAKIE BIT(4) +#define ICIER_SPIE BIT(3) -#define ICSR2_NACKF 0x10 +#define ICSR2_NACKF BIT(4) #define ICBR_RESERVED 0xe0 /* Should be 1 on writes */ 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: 13925403 X-Patchwork-Delegate: geert@linux-m68k.org 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-renesas-soc@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:57 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 13925404 X-Patchwork-Delegate: geert@linux-m68k.org Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) (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 A8D411D514E; Fri, 3 Jan 2025 09:19:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735895962; cv=none; b=BuxZlrfPF3d0ov4cLMF1+7XXOzLVDLOB+dx1h3+nlwWhPLVZ2lQ5ubXuk1e4D5QXuvrD4gS+kSEN/AsljFe/gEqShoPXTCTrZMx9GJHzfkIPxXKktfJW/qe/wZ357WOqpTf/JSYErtdwBtDuOMdwC8JN1caKLI1Q/KxIFohu4Hc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735895962; c=relaxed/simple; bh=KtuJmz9E5NAD/kQy/wEtix/DQqXZ7mFJuytQUHhe+rc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dXJWNUT5qE9nmdsOevISVOmTqyZ63QsDLs69cf5lSosidu1qmvQJyzoVx69+pyxkHtmPoREMfP0UtZs6NAEskPnhwk9ampTmM7UvK2/FkIJpF1hAJW1zGwlM/mdhJzwLeVTTHrvlroX1GjODEYG8JGOwOW2xJiU61Ft4x3V4Egg= 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=TQ9pkxzg; arc=none smtp.client-ip=209.85.128.42 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="TQ9pkxzg" Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-43690d4605dso46254955e9.0; Fri, 03 Jan 2025 01:19:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1735895958; x=1736500758; 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=9MeO3qg7TGRxVchfa98hl5J7dZ69kA3UnrU6UXyWv8w=; b=TQ9pkxzgFinWSaTTjlC+T2wmOExx5z2ell46PS72KBUfGmi9EqUtIJPEqdW2wjEx8L 5eiDLVhWJ6ANS+GI5a5VCvZdKwidBlFOz120EM1OZ9C5clbu8PEfT4yz8BfyJ6bAHCxW NBRA78OvOeFoUI/rHtT6OGIh44MyTabqb14BaRn+6y+IF/wd+w7LZyQt8mZnMgZWs0Bp ZPoapS4ZVz3heE0hFMW+Ez7nIZ/XkioQ9tnYqhPrKSCnIGp19UFH5YpL3ior27PHeion /l1H6Iq08XupqNstfViXGgiQU5YylSseOfnpyTONISIcBOvR46FZpJCgsPINBSAyGZtH bvsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735895958; x=1736500758; 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=9MeO3qg7TGRxVchfa98hl5J7dZ69kA3UnrU6UXyWv8w=; b=a7b7gMFGPR4vG43Vn5i2o8p6XWz0VfVGRW6HwVQPFNvzHTTiitKykBRZagx0qwU1rb sqXg+8I6vwuPBxmmTaWW2ugdEHoMn26GHTrpPw+/zEjVyWGRBnKi1FVqrS608e54miL1 UomR4IlGMWVoMVppIegEWBu+ifbFy8JwDkdg32c0dR7P7OGGlTmoJRPdxvn9DOV+JUyD 4IPpOhY3LuyUxrrgsvEbDMxjFNPM2auGRJMQ4ikLAtI/gitUyUa6o+pDb2KAspP52S7R lJx8WzqmkIFdRSEU7odKvHFAEJTJ2+dzzw55Lrcb3oGyJOHGxwmnjjSwcfA/Hi3LR5aH jY1w== X-Forwarded-Encrypted: i=1; AJvYcCUCEreoCgNg2sQGWwk1gVb/Hp1SXeKVTeAmna7BO5J2q+ySyfxLO4brIt2kJN2ZcGnw5dRqgImc2o0=@vger.kernel.org, AJvYcCXPKIUihIw9hVVEFykINeN2Pszbf7H3arzq4XBWT4uo6EGH1mZoSajigJ4yWcVU5HkHmGy2GoKXPJOzj2h4@vger.kernel.org X-Gm-Message-State: AOJu0Yz9Z+KquBBW6r0vSVY55XNS4Uye7wBV2HyFxS0oC46IY17O3kM2 /V4kw8dV1HthZaJJPb/YJ0QHTvFBjq2pcphPnKR0MGAywCXVmNxZ9qCQmFRZ X-Gm-Gg: ASbGncuqYHhflwxOHBfUcu7ES52NRZrj20ZqHisRpVJaq3zj5EsFaKhwLajQZ4rOMUH iTW1LAc2up6KDBMlo/Xf591rKlOO8oXif/WZ8+576I6Ap0Objq2zEK/6BgAzkIfvZh0D1ScApY5 X+fpE7gA4ufWCwgmFyCzXNV4qbRVSUm1Pr14gAExmcG2WhIQeyaYTfOv89a+FDQtFS6qg1L8Ovb UG1lOYVpYbQjhEWVyE11U/lo2rP9SSkwfAo9YYDQy4+5BLpNTj4ynvUZdYOF0hieU6KNjozhvgZ vP4Bm358mQ== X-Google-Smtp-Source: AGHT+IEnpIFuwVMfRAKXeaDqLWuliYppRAQNQhkTLxsCXYqFw9Mj9eZrq086glu9kkRv4blrRtsC3g== X-Received: by 2002:a5d:5f8a:0:b0:385:e3d3:be1b with SMTP id ffacd0b85a97d-38a2220044emr43608934f8f.28.1735895957847; Fri, 03 Jan 2025 01:19:17 -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:17 -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 6/9] i2c: riic: Make use of devres helper to request deasserted reset line Date: Fri, 3 Jan 2025 09:18:57 +0000 Message-ID: <20250103091900.428729-7-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-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Lad Prabhakar Simplify the `riic_i2c_probe()` function by using the `devm_reset_control_get_optional_exclusive_deasserted()` API to request a deasserted reset line. This eliminates the need to manually deassert the reset control and the additional cleanup. Signed-off-by: Lad Prabhakar Reviewed-by: Geert Uytterhoeven Tested-by: Wolfram Sang Tested-by: Claudiu Beznea Reviewed-by: Claudiu Beznea Reviewed-by: Wolfram Sang --- v2->v3 - No change v2->v3 - Collected RB and tested tags v1->v2 - Updated error message --- drivers/i2c/busses/i2c-riic.c | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/drivers/i2c/busses/i2c-riic.c b/drivers/i2c/busses/i2c-riic.c index ab9ec7f12032..0953fedac786 100644 --- a/drivers/i2c/busses/i2c-riic.c +++ b/drivers/i2c/busses/i2c-riic.c @@ -424,11 +424,6 @@ static struct riic_irq_desc riic_irqs[] = { { .res_num = 5, .isr = riic_tend_isr, .name = "riic-nack" }, }; -static void riic_reset_control_assert(void *data) -{ - reset_control_assert(data); -} - static int riic_i2c_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -449,18 +444,10 @@ static int riic_i2c_probe(struct platform_device *pdev) return dev_err_probe(dev, PTR_ERR(riic->clk), "missing controller clock"); - riic->rstc = devm_reset_control_get_optional_exclusive(dev, NULL); + riic->rstc = devm_reset_control_get_optional_exclusive_deasserted(dev, NULL); if (IS_ERR(riic->rstc)) return dev_err_probe(dev, PTR_ERR(riic->rstc), - "Error: missing reset ctrl\n"); - - ret = reset_control_deassert(riic->rstc); - if (ret) - return ret; - - ret = devm_add_action_or_reset(dev, riic_reset_control_assert, riic->rstc); - if (ret) - return ret; + "failed to acquire deasserted reset\n"); for (i = 0; i < ARRAY_SIZE(riic_irqs); i++) { int irq = platform_get_irq(pdev, riic_irqs[i].res_num); 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: 13925405 X-Patchwork-Delegate: geert@linux-m68k.org 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-renesas-soc@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 Reviewed-by: Wolfram Sang --- 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:18:59 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 13925406 X-Patchwork-Delegate: geert@linux-m68k.org Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (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 05E531D5CD1; Fri, 3 Jan 2025 09:19:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735895965; cv=none; b=bOoXJ6SEKaEUTJetCcWzMzBsFigCBDR0SHPV0gCHgNrfCE+2WrPd4CSOpeYmId17bUcoi1l1gaVYisunvAkeKkpZjdVaXpvQa+361zaHmEWBoHSkZFIFpWI2TCzGeBUQeuUKKScVelpRx3OGiYPLtzDJ59ldjqSZUUzy3dPOQTw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735895965; c=relaxed/simple; bh=4C51F2g5rtYIOiiWjD+7aWGpYlSg9uyxPe4xB13BrMs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sLXH5xIH231W1PD1yvF4ny7aho0cbv2fEVogq9VVUO3zLgw+PFXjdY5TSiCXT4sHfebrxTm4Dz3myzF8SKujm0mhR+jqyUDAj8Wq5aal7dsoHAArqr0o133Vtw5LhV7TZ1o8XiN8mv1U4mtFL4EBnrU8DFKkMerpySDFj/1bHhk= 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=W46vFgw0; arc=none smtp.client-ip=209.85.128.49 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="W46vFgw0" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-4361b6f9faeso72990225e9.1; Fri, 03 Jan 2025 01:19:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1735895961; x=1736500761; 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=fHh51fkXKAHazwUrHjB1gbxZCr0pjDS/1vk1G1UeVto=; b=W46vFgw0Lc21VkbdU6S1PsKh9NAVPCmC1NrnhwQYeGDG4ZCpVIE+1zwHqFil7jbMRK ja5AdZxCaTl6VjN4cnz+YkTRX1k0jTeCwqaSfvq6J0jUOlUzqe824Z241yVPDV7A2Pl/ 35Xenf6EGRKoMVlK2q/HXTXygJj+oTFCWHHdrlC/cSv2ltigvbab9quAjrfSoQdK09Wr JBNGXGwDMcsCiCgA//fdMd2rIuWWMnuaLgUNlFBbkg9bb6Xxqo6eYu4HPST94HjOLqCU 80LdttkkNmGIYhSnNthKgJWBWwKvgNINrvPrAHLIgtxJASgbrrIcbLIEyqErCClnS+A9 IyTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735895961; x=1736500761; 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=fHh51fkXKAHazwUrHjB1gbxZCr0pjDS/1vk1G1UeVto=; b=mGBj1u2bX1WVLfrl45fLMLkyLfZiyGJnn5AZKI/OBcbaPUXIMaHJIF0P0uVrXRR7Ow q7cnlB6sVDGAt9noblRK7UPC7uQsgp7/6EtHgmoAIYr3Wh2dI8urNGE9JMALN3/zNMpw ZvWifgrH9svnvM38hLiur4Oq4a266FOpVReHCF5K9H4YwsSek43vFFc1e7nbiLwcD5mf kkrDCScO/9rW/fekloAINthwD8n3a2LHWw0+FDv2E1yJblvStfy2CFyOmdCYqHanW9pb //SjZVocQOja7sfRA8QKKnu07GXhGz8qkEmUQZeff0P4C17A1CfPb5y6AcGXAvh5I6e6 +4zA== X-Forwarded-Encrypted: i=1; AJvYcCV8eaXg0v0q/JMIxafaL61/iptHMY23fDSZQxU9ph5bXCUnmRDgs73zKCsf0a//zk4/hs+p+lfUqSo=@vger.kernel.org, AJvYcCXo87KF6qyxY9djOvSZ/Uag6nI9+cDwFqxQLU+QmmcjEMEp7O8PT7o99FuaSYwO5HEJPFgLs3OAAIxsUsjR@vger.kernel.org X-Gm-Message-State: AOJu0YzopuuSD7YijQHA3MkfKWtwWgap3YwTNhIxpO0n83C2uFASB9Si U0i6Z613KVQdAlo97cgKbq/GhSuppuTIv0msI6er9AUdrQelY2v+oMCK3zCE X-Gm-Gg: ASbGncsrOcPE3r4JkRWJOyqX8a351MqS/bmXdQtNkvOK+WNnUxQDvzkVFdIytkyckll s2Tld8I0hDP/TZ8A6UZFOPeX1gozncHHqtjYCbnjbhR2lTu814DdBdVLGamiaeOFqHxbGGbbGz4 70EluuTjvgYeZz1RzIrMYSG8etJ0opuTtkqJckOuYcOPHftrwn2IWKo9JsEIJmEr4NE6+qKij0i EC4c7rfojMnLr3v2+0eY80Jcsn9eOuqMpJVmqy+OTeduJmQV9MloLKLeb3nBtQ/tDJXmvFPM5jR RPyHV5lwPw== X-Google-Smtp-Source: AGHT+IG44qI/dgkLDoQgXMew27iZICM2uvMbm4ppzD+sdG6bHHhhSJOc01DaG6MiKXQ11FZQDwSE/Q== X-Received: by 2002:a05:600c:a696:b0:436:1af3:5b13 with SMTP id 5b1f17b1804b1-4365c79ac13mr434891065e9.15.1735895961140; Fri, 03 Jan 2025 01:19:21 -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.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Jan 2025 01:19:19 -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 8/9] i2c: riic: Use predefined macro and simplify clock tick calculation Date: Fri, 3 Jan 2025 09:18:59 +0000 Message-ID: <20250103091900.428729-9-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-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Lad Prabhakar Replace the hardcoded `1000000000` with the predefined `NSEC_PER_SEC` macro for clarity. Simplify the code by introducing a `ns_per_tick` variable to store `NSEC_PER_SEC / rate`, reducing redundancy and improving readability. Signed-off-by: Lad Prabhakar Reviewed-by: Geert Uytterhoeven Tested-by: Wolfram Sang --- v3->v4 - Switched to use NSEC_PER_SEC instead of NANO - Updated the commit message - Dropped the RB/TB tags v2->v3 - Collected RB and tested tags v1->v2 - Collected RB tag from Geert --- drivers/i2c/busses/i2c-riic.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/i2c/busses/i2c-riic.c b/drivers/i2c/busses/i2c-riic.c index eff1efd381dd..042933a2a985 100644 --- a/drivers/i2c/busses/i2c-riic.c +++ b/drivers/i2c/busses/i2c-riic.c @@ -47,6 +47,7 @@ #include #include #include +#include #define ICCR1_ICE BIT(7) #define ICCR1_IICRST BIT(6) @@ -314,6 +315,7 @@ static int riic_init_hw(struct riic_dev *riic) { int ret; unsigned long rate; + unsigned long ns_per_tick; int total_ticks, cks, brl, brh; struct i2c_timings *t = &riic->i2c_t; struct device *dev = riic->adapter.dev.parent; @@ -377,8 +379,9 @@ static int riic_init_hw(struct riic_dev *riic) * Remove clock ticks for rise and fall times. Convert ns to clock * ticks. */ - brl -= t->scl_fall_ns / (1000000000 / rate); - brh -= t->scl_rise_ns / (1000000000 / rate); + ns_per_tick = NSEC_PER_SEC / rate; + brl -= t->scl_fall_ns / ns_per_tick; + brh -= t->scl_rise_ns / ns_per_tick; /* Adjust for min register values for when SCLE=1 and NFE=1 */ if (brl < 1) @@ -388,8 +391,7 @@ static int riic_init_hw(struct riic_dev *riic) pr_debug("i2c-riic: freq=%lu, duty=%d, fall=%lu, rise=%lu, cks=%d, brl=%d, brh=%d\n", rate / total_ticks, ((brl + 3) * 100) / (brl + brh + 6), - t->scl_fall_ns / (1000000000 / rate), - t->scl_rise_ns / (1000000000 / rate), cks, brl, brh); + t->scl_fall_ns / ns_per_tick, t->scl_rise_ns / ns_per_tick, cks, brl, brh); ret = pm_runtime_resume_and_get(dev); if (ret) 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: 13925407 X-Patchwork-Delegate: geert@linux-m68k.org 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-renesas-soc@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);