From patchwork Mon Jan 13 12:26:34 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 13937269 X-Patchwork-Delegate: geert@linux-m68k.org Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) (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 7FEE922A4D8; Mon, 13 Jan 2025 12:26:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736771219; cv=none; b=VwqC62gFhBswfoofGmUsS9GQKA16W/zmm0jXY2rpgIaR9bWxF6y5LxjbUORYJqK5or71n6BqxGZI1t/GDiA02hxArkXPcBYcDvOIQxHVuPKgTtEEYTINfV7UiuWDIdOJ858Q7S2h/zZNC/FbN1kMrFF49I9ZwEeyU7A/kc6+avQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736771219; c=relaxed/simple; bh=xPxmZJPzgiB1EkmfuTmM3PZFUFf/FL1WQSgyJtf/1sM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QbaSO9o11uWtnWeFEkLepRCOmIU1niDTjpGY0fUVIipMOVNebgl7hQEYicRp7LWj8NlqkWbLEcesbzI7D4/fmid3Fw+ZzuKnIYLFiQmxXmZosvq86ZBUL9CRwHG6/miDdrLNB8CR34wf3jhBH7yAyoZXBPU9raxXB/TGwmHJZVo= 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=N3MXtZX/; arc=none smtp.client-ip=209.85.128.54 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="N3MXtZX/" Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-4363ae65100so43700695e9.0; Mon, 13 Jan 2025 04:26:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736771216; x=1737376016; 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=/rNx74P1jADybHGnkrn/6e/0CTICNmCpKRaJWriNlBY=; b=N3MXtZX/ACm0aS0a/Xb4msFjyaIGYA+9S3hlKQIepQe1JLH1LCpX5L0Da55RvJaSOd lsE7EhlJDQokRVSjiev9FVxAD/yEWUhGh8iyH35FEioed0oz6aNpiN9uvzWECiC+zSNx NW9tLjeasQwybAFBpI1GzmXVNVV5o7vo/XSH25wCTGThOJApmKzGxrcBfbJ8tJL5jcAJ FQ+ejaZ91J96groyYDmgHWSz2XkKSc+ERbXhgowSskzIiF2ZAYXgiVA0xRC9YIazLIxZ ul043wa+CNmXMGuC6k74aYMlgrHzwuDAIxJFsA4fWj/oUIaar7O8B0chRu/KJA4xidWC mNxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736771216; x=1737376016; 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=/rNx74P1jADybHGnkrn/6e/0CTICNmCpKRaJWriNlBY=; b=QnGnungwzGkEVcMyOEib66ZDXHCF5jVl1QHpLwUVxA9zRVScZI334f8AUs6hqwZtVi bKOlIhHHB0l6mtt1pYjBLG32zgyaoYaNBHWcTzbBVIxxyOK99q1I4LACnTG+PVypeXX2 2RXd04Kqpo2x9ylw1qb/S8k2s1SGEAYZWqBf0vTvUN+nUxBAzuwernfrf4VyCVXMUxiY LWF9C7pNvHY8L7/LUWiIFn1MWOaxWLdYV8uSCgYvt35J/+mjg/5N5AGwsZtnAUEWmi8v /ZLbbR2U3GTLyvsk7ZqUSqTtlUea/KMB4E15AJ0cPP07Q9s3naD+MqScgqh4fD4aV+Mr 0A5w== X-Forwarded-Encrypted: i=1; AJvYcCVmXS4DnVwV/M3vf7NwZ3wlocD6eihQduMAistuIInkocjUXzW9J9pw9DoY3K74AQ0ii2CZpGHkooI=@vger.kernel.org, AJvYcCVxgVfH9vTRZeP77yZN+Nf44sX7gAGnwT03Ewdnh2m+rp8wHNi05eVLQBpcwYhINbOslUHqKtU0ntDhuq2V@vger.kernel.org X-Gm-Message-State: AOJu0YzNybTavB8UdW3Nn+pWiVjsMnrpYTRIvPk0iznfXgksw7fbnMCM hw6nu4/TaGG42z7CdexRbYZlHnigxty+kGZmb6Cx+RFUfmOk+2UQ X-Gm-Gg: ASbGncs9o8lDGKDMYRmU26kM7ck3kyYK7YQYN/yLj+cGyI72KTY2+BuZ4t67elBprxQ uGh4rqV2F2dK/vkdotmjX2CfSGad4gyD/TvV6WVuyiAb3WsugnVaEih/ZuorQBksNZf4vobZ6TC 81266tBa6hZFWOWSE63TwWyl59gE617RTKyIdpUzbz6yNKSkhB7CgXMyHau16WAhPLChw4ZCmQA xxEhaLBFVbz+afrB8LvOVtDx0IwvYJENOAQcIr4P8nuxuSPvulQ0GU5mJArpIB+BjWeXW1/i5xZ rLJ1awm2Tg== X-Google-Smtp-Source: AGHT+IEiYjukAIxRXXeGT+ERN00ZzABAxetvZIxM+7Ej1bgXJ1tTG2/IXdBox3XmCl9Yt+E/1UAVrg== X-Received: by 2002:a05:6000:2107:b0:38b:d7d2:131c with SMTP id ffacd0b85a97d-38bd7d215f8mr3819777f8f.32.1736771215660; Mon, 13 Jan 2025 04:26:55 -0800 (PST) Received: from prasmi.Home ([2a06:5906:61b:2d00:acc9:404c:3a6c:d1aa]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a8e4c23dcsm11812720f8f.101.2025.01.13.04.26.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jan 2025 04:26:55 -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 v6 01/10] i2c: riic: Introduce a separate variable for IRQ Date: Mon, 13 Jan 2025 12:26:34 +0000 Message-ID: <20250113122643.819379-2-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250113122643.819379-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20250113122643.819379-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. Suggested-by: Andy Shevchenko Signed-off-by: Lad Prabhakar Reviewed-by: Wolfram Sang Reviewed-by: Geert Uytterhoeven Reviewed-by: Andy Shevchenko --- v5->v6 - Included RB tags --- 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 9264adc97ca9..9809ac095710 100644 --- a/drivers/i2c/busses/i2c-riic.c +++ b/drivers/i2c/busses/i2c-riic.c @@ -464,11 +464,13 @@ 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; + + irq = platform_get_irq(pdev, riic_irqs[i].res_num); + if (irq < 0) + return irq; - 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 Mon Jan 13 12:26:35 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 13937271 X-Patchwork-Delegate: geert@linux-m68k.org Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) (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 2A42B22CF20; Mon, 13 Jan 2025 12:26:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736771222; cv=none; b=XDtLdUqzCIwehY5iLN+TYGQ4XT4DHX1xDViZq33C82wvwkOTi3IS5iDoYQhd+Og+wH2CQ5en1Gu30qh5ZZEkOMndNYSR4chxVaRaO0/0rGnFS7UBEatAXXYhW61mmRfpHQhp+zFOgNv7moLxtPNlajxOeKCHUsd2rfh9dUemkvw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736771222; c=relaxed/simple; bh=g5laTRAgY1gdvIii8C9AlPVnsizuMBnSyfZ01yGizLs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aD+aVzTF9HYfo4kPuGVKGuUL4P8nsaHhZwDXShdyhic+VwPcrGgmcItdaAAODF8ueeR+v7VpDG2EsX0V/nOBE+IEHuwam92TgTt6R5w9Z8wh2bRzeN5WOrv/KJiJPGzwHI/vM51VUr9FClhEvBMIPqLm8JaCd465CYFCYL2Hs6A= 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=ct/8toTL; arc=none smtp.client-ip=209.85.128.50 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="ct/8toTL" Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-436637e8c8dso44528555e9.1; Mon, 13 Jan 2025 04:26:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736771218; x=1737376018; 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=U2aP7wxtN8DueoMdmDqjwDxDgdAEwzbMAGyBqdL8kNk=; b=ct/8toTLHj7xWOZI9gPC/wX1UrCNCplOI53o9pWASIfBVTUQGCtKSFBEbMT04hujok 2ba+ArG0i6CE6yztinB3Rq5/7nX/FNn+AzHIDN9eITJ0JfnW9Tzx10vsgeLTNkxgq8bq It0Nz3PdhvlWgV9KLsKCyfd9pTDDy3TzzyJtTMYCOEMEAIR3kIENjrYs+wFfQQgycVbu WadHxq1rFv+VM6mepozM3eUzEUZPavsfiTXJIykvRxFZVooQC+T3qSs4aGSOkNC2GNJQ LzsnXUePYBWmSGQ7T03v+QbQqE0moeqAjb/Apzk0cTU6Mwh6gfau0KjtRqztMsLzdNxZ H2HQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736771218; x=1737376018; 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=U2aP7wxtN8DueoMdmDqjwDxDgdAEwzbMAGyBqdL8kNk=; b=LQ1W5LidztfUJMSOZUQ50g2aUfMvzf9SeE2td9OY/XPdGhrOVU091CIl1ILmWi3Pf6 XLD4KYT2xzRlICVccQJspoB3SrknBZoXD2ICsbi7ZyP2LaVF23FxEd+n5zF6c+oSte3C RxsqWC5/+Y0AO0eDPmABZRCkEK5YRPt+Ckg5+CsptmjAPnQ+BSbHhxCVDw4WIoBfVnJK k4DWIcASW2mBygvkuatshOTP/agyHWDPfOUca9lefFHkhYcswb/Cxyr1/ecQx+IeS+G+ A2tCWSl7UzVK2HIYbynCQ1wYeEzzFvgF5mzGTe+CrUAYhiNVBB90NkudFKhfIV9t3pH2 /xHg== X-Forwarded-Encrypted: i=1; AJvYcCUkHkCJnXG1//61Rx0djDLNMqdeNaxUAoOC1TlrmHzm4OoDDHDANjDH8880h78LQjwbBPZQpOgOPv0=@vger.kernel.org, AJvYcCWPyvYebKE8dABgNSdXF7+pG+NOJZC+VfkYBLfPugsvUOzcndDw5SnN1VD60tCXcNxGmskP7tNtlY4VBzJD@vger.kernel.org X-Gm-Message-State: AOJu0YwunTzy+5Y9Wue0rMcJaVL0RlUoChHnwQXA0J33Juargk1/KUUD geg8jMomt3NWrg0SPVO1WUUqQDEZ7tLk6ks+Gyj0ag2a+lS0BXTx X-Gm-Gg: ASbGncvHrRZD+BIGTjb6amz+xCY81HRoW82qS6SAmZkGNsd1b/0LhFY4MT18mwrtsO0 /A95yIyszG9I67VzsJ+3zZFN8MmfLaCke9dp8nZ5Yk6eQLgcK/ze+S98eDyazE3EqnuQxUHT6Mu E5qeHhb63AFWZr28V27YTVBxqM30W8g8D6arncPNvAlBgciUvpjbQD9h9RJUpMi/SzKH+o9Dcdd 2hMMjNMY6IXe2aXYjUEmNVR181XlS5DHzJ3D7c43eUsNZv/3SozOXHauYw71RLo+LCVXrky7o/H q2aogfg8QA== X-Google-Smtp-Source: AGHT+IGJhAZPHfGuzXSp4PexcbIZVhg0NX65E/CP6iiAhT3eDL5LDl4cE6PmjldbdowNvvGvphfpIw== X-Received: by 2002:a05:600c:46d0:b0:431:58cd:b259 with SMTP id 5b1f17b1804b1-436e26f4d53mr189728405e9.31.1736771216661; Mon, 13 Jan 2025 04:26:56 -0800 (PST) Received: from prasmi.Home ([2a06:5906:61b:2d00:acc9:404c:3a6c:d1aa]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a8e4c23dcsm11812720f8f.101.2025.01.13.04.26.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jan 2025 04:26:56 -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 v6 02/10] i2c: riic: Use dev_err_probe in probe and riic_init_hw functions Date: Mon, 13 Jan 2025 12:26:35 +0000 Message-ID: <20250113122643.819379-3-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250113122643.819379-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20250113122643.819379-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 --- v4->v6 - No changes 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 9809ac095710..4e2add343c9e 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)) @@ -472,10 +469,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 Mon Jan 13 12:26:36 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 13937270 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 6719122AE49; Mon, 13 Jan 2025 12:26:59 +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=1736771221; cv=none; b=Z50e7DJWwIP9BfRIjBnRO+4dXYfH1E+bmWhYf7FfgGFrGgoKtdwhzaoX9Hc7taMqujAjxvVWoZ26Q5kI/a4i8T5fRd7ipXiGReS8ins+/E+br4stFROUiC3OQ3yDSRzZnuuxagIG7EO1Ke+oFtYa7zcCMMmvJ0zO9zM35P53T+g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736771221; c=relaxed/simple; bh=4pAohm9PgiohpzQ+nzLusuwNomgnJTKczSn8upU0tFw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ROEhhiQNfrIDTT2bsb/5YR4GMjh0oj9OdyZa9uZWMjpaQtcKJKcVBMp5eDtgJqnVo/2vIjoBW0VFBXA6/JVtDXOFHy1YDmSf5s/rxd9GBX4vFdi7UNpQ/ZL9s/zQXnSSBY6AsI0qFvjTRIvNWzdy6CgV/NIwlkqT51bpaOznwFs= 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=FBI9DACe; 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="FBI9DACe" Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-385de59c1a0so2015103f8f.2; Mon, 13 Jan 2025 04:26:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736771218; x=1737376018; 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=6CQU+DVYlAO+oIq3UJzRqfbMr0HitdK160Letc85i8Q=; b=FBI9DACejVceFcC0ClTTVHujkvx+3bYJJzeDXW3KIKpiNYES4mwCbUlmL9GvcXIRsz 8mp4OQvDgtH3D1KsN4M47BxJijNAVUciCmlGHXLJ4ikl3GNqKwIc+J56D+in1K8yKDTa fLXfUzMu7iWal+NcQAs5gLrrT8+o5exaGEa2/UaGbQFTwhGAwWocWR8rsJ7bnXQuV/FY wf5U3EOUI8vajQrC5j3or1IftP989uRlg+CmyyTrlG1LThAG3g27AmwMmPKxAQG02Hh/ +ivrLg8O4BG0mfYdeX2AGkaPl1ukVa+mLb79voac3Y8Tk00SCZ7w+uzioE04BRTWvRjb 1fZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736771218; x=1737376018; 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=6CQU+DVYlAO+oIq3UJzRqfbMr0HitdK160Letc85i8Q=; b=GNejgqWwnGPe0MncDuqpLX2XPqpAxEXoN2kX40No0HHKjttv0YJyov/VY8WoxYDUEV vQj4TUwEq+09WMVLqYilFiHxjgwfIKIngY1lP49h6uI/YALjOr3bnmaeRJZXwwcv+YJE JmL6aCSenX6qfrVQROhNwgXuIxlUX4cP/jEXh9zUemXQIfIQeSd1VPO0ZYnitSwDw6L7 gJZJCSzHjyx/5bINfllj93hVu2LN82gNUiBbV+ZPEkAWwHDRYlscJ1T7KK0b6DoYcUyg 9wmtH7ULBDJ1nEtuPjTzYuoBCzO8fPaz3q8cFHqeHAu/S98cyymh221wTIGafE5z8Whl ISwg== X-Forwarded-Encrypted: i=1; AJvYcCU2+z+89Y0yzvHIKnWxGyRPgZ8WwVQnO6IHJZh2lN+VsEV7LS42yLvvT0hpXYnEbAbBuQ0DeCFMITM=@vger.kernel.org, AJvYcCWL5XgkdAaSQlfgssZTaDACqHIpKYAT1BMedgvwP2R6Fz0DsJ5B7+rGuSAIjW5XN3UQF6dDyMoFZfzEJh5i@vger.kernel.org X-Gm-Message-State: AOJu0Yz7U3Y2nKddsXtP2bNfNlL//wPSeNsRpQTMuloQzJy8a0bNJY7d 3+ceRxg/ajnZEmTmBnFgWFG+juRl0Wio01kP5tPAH3uUDsqMfvP0 X-Gm-Gg: ASbGncsIPigo8DuO4BMXIyIh9kHHGtBMCUGcADbGyCgQqUyaxKjuUH2YAVHueuy4iTW qU3WzGDOKyxgj3u1rMT5QW12PMp3A9QlWqQr2KnjSR8F4t6kM7h5n+1NzYijKPrzNPblyWmGzXM nyqBWvCG/HDvQo++tjQYFwndouWDMitDaJzQ1BkVhlghe/tk+EXnAWAr4WPRL9k7odhphcSLsaP xEZQQmOCUe2kZyL/i+zaURUq12AgBybQLFxkFpH+5b35Fl3aKsL1iCAcHdoK2/qBpWEyMzTVcJB k5DbogFdHQ== X-Google-Smtp-Source: AGHT+IGC9DFGOG62gGkAFLoAPAC0GixW8o1Xy5xI6YUgpzDHJiXwzZYTQrub0EvnDhbOYWrR9yNROQ== X-Received: by 2002:a05:6000:470d:b0:385:df2c:91b5 with SMTP id ffacd0b85a97d-38a87085becmr18908243f8f.0.1736771217635; Mon, 13 Jan 2025 04:26:57 -0800 (PST) Received: from prasmi.Home ([2a06:5906:61b:2d00:acc9:404c:3a6c:d1aa]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a8e4c23dcsm11812720f8f.101.2025.01.13.04.26.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jan 2025 04:26:57 -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 v6 03/10] i2c: riic: Use local `dev` pointer in `dev_err_probe()` Date: Mon, 13 Jan 2025 12:26:36 +0000 Message-ID: <20250113122643.819379-4-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250113122643.819379-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20250113122643.819379-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 --- v4->v6 - No change 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 4e2add343c9e..c555b6220e66 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 Mon Jan 13 12:26:37 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 13937272 X-Patchwork-Delegate: geert@linux-m68k.org Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (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 C740E22F16E; Mon, 13 Jan 2025 12:27:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736771222; cv=none; b=C56aVv6JrRK0vog7dDc4kaUbPBdyzCfgt3GZP1ThC6IQ674T6jkzA86ISASN/iwFMFCVNbwsSgkz7gBqXpKVHC0mXxq1scXAZKIaLp5rSXiTBDBAJ9No7ftiNg2eN1cZTGViEqQs6hYIpUCxlQe1D6CT2AwH5bVIJNyKy5umlj4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736771222; c=relaxed/simple; bh=kD/BB26IlDjp+BdXvMhyWMQzfTjuj11XTsCTUTRtnqU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CxoNAqfohZkkLt5VO+1/CbIwMt3v4IP3oJMolroR6QozaFpnZFYlJEtS3DIJ07Jmt25zTZWtQCDKzKtxFAqOfU3/LBkOTE0SEdwvjPv6nj//zYBCJBJNGd+CptN/x4Vp1j0cqOcWAL8r4+qDO98geZSM9rsxrt+Zw4OfbDVm45Y= 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=E8uFQGiR; arc=none smtp.client-ip=209.85.128.41 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="E8uFQGiR" Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-436202dd7f6so48634405e9.0; Mon, 13 Jan 2025 04:27:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736771219; x=1737376019; 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=oLFxeHsbZaMLi7y4U70NTqyWNjRRV0RJYoNkPRe1z3c=; b=E8uFQGiR23PjDvOc7p9ji3lzxHocelzezvga91HUT5eVlHDbCSyeXjOZwCoT8U70dA fC/fClvhlEiferVWWJUvqNCmjBMeGCJmyUmEDtHLdCvsMmfOMD4RCuGtIEpV3VlfYGPD qFksiTYg2GRAKmJuWlc00XY/nkOZV6TeAkPFJeUkYY/U56iHq+UDD0mdJrgIcmWAiAlx jGQkuVPOq8mCmqv7fEqHtrLDj7pkblavGdcZWF+eaF0JZ047YtIsq2VNigRiwZ/x/YLa 3ql42rQTiCRX3HEGTQV3Qa/wGRoclcKidNNs6Lj/ypur3RJbbrab8RIooRW3gCN+/TEj bhFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736771219; x=1737376019; 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=oLFxeHsbZaMLi7y4U70NTqyWNjRRV0RJYoNkPRe1z3c=; b=QbjTq5JAcEFC05SCs02i8J+KXIJ5nfaIM9BFFV6XUwuPNcC3gorXEbVxe6d9jxxXAf 1aoWK1Ttoxx4gTTrYhvhTSWBWt6PWbGuVMqX4CcsjDYy59o1Rsx9mMaT/3S+TM32CPgS sl8X1wofU5UNktvTbZ3Y3aqhHxkUpGV7pRcy3lnR3xioCgHiAbs+d+HAhwYDsaMK8Hpj wSKL+bbvmKf53+LkbqPA3R0R4PHKYTnDaXtt9pHr8PEnP5lk+VjavI/HfpzCnIPPaUJQ PJD2SOuvYUeBDTv9eDQQpLZO3vyjIx6eGHr9tLaNTwtSNEU7GNDi8/2q43CQeUFor5Q/ IkTg== X-Forwarded-Encrypted: i=1; AJvYcCVSw/StTvBhCX+6joKzQxg3p+XR/tBwQ3eoS9SMm/piNkfLhJZk671E/7DDDO+OVFU/k0fQZ778M/A=@vger.kernel.org, AJvYcCXVk9Vn6NxZ11nv9P+Qd4I9lZcEWLjgdrB9zna1Gzrv/Gn/14/GtV56Vv4iL2oOhGccezRVN+iAhwkc0Kal@vger.kernel.org X-Gm-Message-State: AOJu0YzMSPtJKXhqDenBxkZ5cBrvtNOTkRZwsZf9KfWTjNl7bRtcp1IA kZGYpWrRjEcwjpBx+7ks439FcGJG2yv1WMxazjz6kUxY9YATIOXa X-Gm-Gg: ASbGncuXmKLGp65VMG3PsZeJ3aJjRK0pk4uvLRo4ynwRE4aDMdgyZTnc7/Bmi1Wxzgi T98NHklUWmxeB9fQNbuF1W+I9xH6TAijplBVh+bBkLVSFEDHuRBlzTeOuGy/jlpxKi44luOm7vG 4r0GDp0G4h0Y+RLa2EphcWf7UfglbPctBHsKk8wO9km6nMCxSFJ56IydsjBAgO5Ctn+GFgN21WZ 2Kg32DQ4M5NgfYh2OhBGtG53tPyX42n4BcIYqiyE4blK2gJX3JKHB4f2FYhWLWHRXtCunfcclyP n8tNyikOWw== X-Google-Smtp-Source: AGHT+IEJdT1V5ztbSQit1l4JUUiyXQNX5YIla9xZdjNckE55C9SpnMwefkT1tGr3ozOfyOqyW8KNCQ== X-Received: by 2002:a05:600c:4f03:b0:434:f396:525e with SMTP id 5b1f17b1804b1-436e269c2e6mr184653945e9.9.1736771218578; Mon, 13 Jan 2025 04:26:58 -0800 (PST) Received: from prasmi.Home ([2a06:5906:61b:2d00:acc9:404c:3a6c:d1aa]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a8e4c23dcsm11812720f8f.101.2025.01.13.04.26.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jan 2025 04:26:58 -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 v6 04/10] i2c: riic: Use BIT macro consistently Date: Mon, 13 Jan 2025 12:26:37 +0000 Message-ID: <20250113122643.819379-5-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250113122643.819379-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20250113122643.819379-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 --- v4->v6 - Used linux/bits.h - Since the changes were small, I've kept the RB/TB tags. 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 c555b6220e66..370cb83bf5ac 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 @@ -46,32 +47,32 @@ #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 Mon Jan 13 12:26:38 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 13937273 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 5FCFA22F17A; Mon, 13 Jan 2025 12:27:01 +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=1736771223; cv=none; b=GUIgjn3JLc3LeUotR/tR7VN/lLdsVWK3SaNdFB4wprJ1pFGu2jKr9zthYZL9lAeGCVyXPXlhcKsCk+4/453tXZzQL9CScLy50niTQ9NzRlv0/kKB0YKll26GJRPzDSly8F4e5H/5ne+6dpifxLduEGaVnSdvrNAsi9V827i8ulM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736771223; c=relaxed/simple; bh=A+cAFzqBYaL4Zs8NQikZ1JgEEOjtnnh99UNkVD+R91A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CgsLcn0r1lLwwy5gByRxyxUU3lPRdeLO3xhx9vhoY52Ffih9eqv9Vrp5aOnkUlirx7eiMraG7DT24RdFlZFX7ithYgLpkJhSVVHsefAdmwVCqbXLcv4D5iBZJ57NPj6aQiljFs67OBhfLvS5FoD06e/8gf8hRUVi1c6V2xo8QkY= 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=iSEHgmHA; 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="iSEHgmHA" Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-43626213fffso31789965e9.1; Mon, 13 Jan 2025 04:27:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736771220; x=1737376020; 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=poNT0Bmmh5IK2SPayphwfLNuv7i1YY72QjCWcSLlhrg=; b=iSEHgmHAQBgK8RLnZbCDpR8tNf30GG74A60QkC46VslgptSIHy3VsqKe41pg+CsE+/ y47PAeeOlvMylw8RRFEJGMjSaeB7motPuLoFKVhs76ctdTfIZho947B1lsa8j9v4pIyV yTh0KwwwGoRYO9UkLjp989cXmPZ9oK/16P1tZM8krPPEdIQUi2lZmVtIaPNgo3WnhJqR cqL22nHLPt/EE8WNFTxm6YlgJse//duaUK15gK9ZitN+jwiF2W4gmlnyetsZsFe06IFX QYhDxV+qclKuvO9Y5YIUalMx8+p7dhXGsIA+TOJML+iCAAO674GsbmgbA7Omm910peaX 0Izw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736771220; x=1737376020; 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=poNT0Bmmh5IK2SPayphwfLNuv7i1YY72QjCWcSLlhrg=; b=REYmRZNtDdbICCwEByBlQR6OIH9ngAAiaPdA3DeelPY/Xtt3/eUVf4lewK32URlCGO 8Y1M4D4LYO4gvPsVdztrwT3Ojx0/CI2Yz9k1Wkh0LLPNqcJ+Ss/PYK1WiXpcxwuSpngH MdBqe5hkfEOXurreAFQkej+TRHrFmMf8AG1pAt157meGiq4ws6UtVw8QUr5ziJBmR8qQ HChuOBPwI1dXn/nozfRyvdAtd21wIOYKIsw5nemwLq2IWxvMc5PYKLoqV/jApTvSKBSc DYYDNNSWWCAf9L6+qYcEGzoEXfA5sYyRdo9a+Xfrl4G7av6eOsfCIdX+mh7+mZWP+gVK aT/Q== X-Forwarded-Encrypted: i=1; AJvYcCUN1+Lz6eSToRApzPS1GX7YusrTjHOJRZQBomuO7T1TZcQ/ZC4TCtbiFqHTvGv5ZMQhuNqKt1Nv6GM2S0I4@vger.kernel.org, AJvYcCWiWROaxHiTjTXyAlPzCHAtw+gZSGGPBg9JTWwB36xmORV0l+frrxbgQjt5kutOuPDWp8IHYYUSJis=@vger.kernel.org X-Gm-Message-State: AOJu0YyvS3pEhpaXb5fOrxu2x0qOwoynXI4Ecm2My1nqVHmnfpnEOnwh hgNnECTDRAM9yra9Gf7UG2bXSFBU9wm2j8wXDAotg792DeQC4xCby8XzUQMdD00= X-Gm-Gg: ASbGncsRfZCc6CnS7TNE1r5kpab0p/sUmRFjC3hGnmO/uCpV5aehT0BoCpRngH59sTq pg4hebieYpGxbkcMkqXlPkANrg/x25v57WfSsQCu8LBas1AJOm360jFcKZHxM7wsnOF3GUeIWJn ph8r8fH77UvrnFmcUPvJYvgBcotrXnjs9ccCWxdA1ftM0g4AWw8I3ndEq0UgDOW/LkdmtjObRBV +2E4dB0jEztTgDbUPw8pbnKAG7QQTAFrezTx1dgsbTf/h4Pxmcj2BE7DQeJXTdN4o1N3RkE6VdF +vWzJSFebg== X-Google-Smtp-Source: AGHT+IFJfwBXlyuVbXaH4dE6L99Fx92pkXUev8hcHAaUTFGJPZz/rT1ELw7nx0tfNKufIahFJWMmwA== X-Received: by 2002:a5d:64e8:0:b0:385:df17:2148 with SMTP id ffacd0b85a97d-38a8b0f2ffamr12309576f8f.20.1736771219524; Mon, 13 Jan 2025 04:26:59 -0800 (PST) Received: from prasmi.Home ([2a06:5906:61b:2d00:acc9:404c:3a6c:d1aa]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a8e4c23dcsm11812720f8f.101.2025.01.13.04.26.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jan 2025 04:26:59 -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 v6 05/10] i2c: riic: Use GENMASK() macro for bitmask definitions Date: Mon, 13 Jan 2025 12:26:38 +0000 Message-ID: <20250113122643.819379-6-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250113122643.819379-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20250113122643.819379-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 --- v4->v6 - Dropped bits.h, as patch 04/10 adds it. - Since the changes were small, I've kept the RB/TB tags. 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 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/busses/i2c-riic.c b/drivers/i2c/busses/i2c-riic.c index 370cb83bf5ac..cf0b45f9e3d5 100644 --- a/drivers/i2c/busses/i2c-riic.c +++ b/drivers/i2c/busses/i2c-riic.c @@ -56,7 +56,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 +74,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 Mon Jan 13 12:26:39 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 13937275 X-Patchwork-Delegate: geert@linux-m68k.org Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.50]) (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 012AA235BFB; Mon, 13 Jan 2025 12:27:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736771225; cv=none; b=Ri6VM7GaFqxP9md3qjqYz+o+WzntpN+0jPWMjZZqcXPTBug3SBrvXtsK/Uopax7e94nvT2oiRe4iQZtOTMhQhcyoJEHPUXibdFSwwvSwCjY1qBosJS50VvaS1AxPGqwOC9vaNvMSzfolOpPEtdJk7YChZc5T+PJkf3QZz+rmv5U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736771225; c=relaxed/simple; bh=R7pz0XBX0BgrtScwKhgYERxMm6Ina5M2/cQDoHU36z0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KUM/Gjw0dRRF8tgNlZFuZc40BleMLdZK/q4dRH3sUTDr6AnRuYYDaFCcsbz1ircH0uv0VxaArtI23Qo8rbfEtf8QBSrtGCs7gfyaBTCUcOzxo7gfealvJfbGwS9vgk41tDOm+vQg+nie6JHFon84bOa9bdg4O3Y2+FFROMgqEnE= 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=GCrWrwp9; arc=none smtp.client-ip=209.85.221.50 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="GCrWrwp9" Received: by mail-wr1-f50.google.com with SMTP id ffacd0b85a97d-3862b40a6e0so2279442f8f.0; Mon, 13 Jan 2025 04:27:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736771222; x=1737376022; 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=tgZ23kaBTh2F/RZ2prBStTL5i4OYKF6YytVP7mVC+3s=; b=GCrWrwp9YaV2LO7FpEiYymnUpom/6JWKQUNFq/7RwndkoMND+QkJCjMXhcOYc0Ul19 SY2Lr6r6q6rg49iSoVIR3BMS2Rn3/FyQRrY5e88AOjCETmbJ4nlB23zulv+0CkzTFnlG VZtl8DOxJiu93xxfeqi+ivXV6knGyV7f6yz2To9jMndBQzXcnYwu9rJkZScX4o9qNQlv i8X8KlfFfWj8pLUOhZG+mH0LuSNSL/jOgNMmKBU1cfWeIf3a5RCoKTlKor1f1dsbFrlh 6LvT8sUjb6+8kp+JtIHUrmSP8EEwXs2yo6EuQ9o81rBpjLOWF6+sd4cMxAKuKsAIED0U O1ow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736771222; x=1737376022; 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=tgZ23kaBTh2F/RZ2prBStTL5i4OYKF6YytVP7mVC+3s=; b=rde3XaVLV7iRr3uBgTqQCzcvcKNtmyh4QR08khSd78A4Nmethxxp+6ysWE1V36uyA0 MWcLaD3jBcrvdsPiogAdLSXu48dMK/QTJDfCUepAURiLtO77QPh1iQ8ni+Co4xan9ROz 4G1bfTH4hAUwmUUUqYDyE9KqtaxBJxEzPbh7jUoYsaMz3kZNUehbUTH3GCKgImVKwKJ4 rqNtDZ7A2ziDE9ytxy5nF/jahTFlSk2mmVGRr/yDHsdPn/DbMQK2bYwtm06wpyPWl1aC Ga5/KKeXZ0BpWbMc99lZduZVr8JHWSfr9bluzF1V8APE3B4R4/KjFDYLZBMb+K3xdFvs 7IbA== X-Forwarded-Encrypted: i=1; AJvYcCUdoZTCfIH4dpu9kyy1B6mbHcilcsozJDip4wjhVttdeX7OVNvajGjecx+isFXwj38LuXjeTYBiRtwhXKTt@vger.kernel.org, AJvYcCX2BbhjiUkTMa7iheSKtcQxroOw6w745DNY8Aj6j/Q9XMInEC2nXDrdP7+6Jkf2inH/XMXjrtow3L0=@vger.kernel.org X-Gm-Message-State: AOJu0YyiiUMF1nZnhp3xrrw0pVg2U71g1U3tVna4bUEGldxxt8jLxP8C q887GRwrC8cM2ZFyEM1No6L925UayNysIG+FkCBtzolXe4fOYckn X-Gm-Gg: ASbGncsn11+hGopg2EYmHT+HauWPYrEUTyrcBctdYsvDpVsbZkUEVwZC+KiFa+NheUi 39Gj+PfH3cGvWiPt5uzBekr0ms8nAZgw/IV/YZEJA+VV6YuwFlv76vTLoAKI0gvCVKsJ5mT7xUr ST9BRjevZYJ52y8UyEsFuTmEdXawZuzVCgqBwYVlrbCZIZSx0uaZdfuke3T8dG4jhrOEA6rEE9W cJ3pKTGLgkYCukmS4mQ2SYYj+zhLVE5xFi/VF1uttpbwjxrvYdjDrVoSQJDiM9pdveGXqn0ZnJc Eh5TjcNkfw== X-Google-Smtp-Source: AGHT+IFKUc067RWqKURCdqYEN45IevOqPBL4b1CXvL6+cWgOYnMj7SxoaS7PBYDlsmu+TgOR8p/6uA== X-Received: by 2002:a5d:6da8:0:b0:38a:5ce8:df51 with SMTP id ffacd0b85a97d-38a872f7ef2mr17709349f8f.2.1736771220579; Mon, 13 Jan 2025 04:27:00 -0800 (PST) Received: from prasmi.Home ([2a06:5906:61b:2d00:acc9:404c:3a6c:d1aa]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a8e4c23dcsm11812720f8f.101.2025.01.13.04.26.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jan 2025 04:27:00 -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 v6 06/10] i2c: riic: Make use of devres helper to request deasserted reset line Date: Mon, 13 Jan 2025 12:26:39 +0000 Message-ID: <20250113122643.819379-7-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250113122643.819379-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20250113122643.819379-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 --- v4->v6 - No change v3->v4 - 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 cf0b45f9e3d5..577be1fb941e 100644 --- a/drivers/i2c/busses/i2c-riic.c +++ b/drivers/i2c/busses/i2c-riic.c @@ -423,11 +423,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; @@ -448,18 +443,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; From patchwork Mon Jan 13 12:26:40 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 13937274 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 8A4D2235BED; Mon, 13 Jan 2025 12:27:03 +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=1736771225; cv=none; b=q3EPWn673Qho7J3R7hazd3H3JTszjjnAnUBGvOz0Lk5GG77dQpeFRQ6PBgnqpoUw50gohA3tJKEB9I7Rifs0k4Rh0oPsq0ENgaeMYqWMOEquQmwcIQmEET/C5wDFw+Mdcs2eMT5Nji8P/OotBdPdRfbSCNPk3hQ6cMRWXBp69yw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736771225; c=relaxed/simple; bh=J9hyRBKSuXe8hqhiAoUA3WRKFV5ZyRq8cJJ8EI+szls=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QfYjUIbmmuQhfV1irrk1v0Eb/5tVqR0hnMi4bMxlYAR08cmiPZxtZwiD6EywPfevTucT+lhX8zyZ9KWds0FsyskfClHieLJOUDZbznfMMgoGg+nUwdGo5//rXRXsm8jFHvu/UJMXiP74THOzRUTmckVDrkjmQ57s9W1z2pEMGDc= 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=k7156tSE; 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="k7156tSE" Received: by mail-wr1-f44.google.com with SMTP id ffacd0b85a97d-385ef8b64b3so3656713f8f.0; Mon, 13 Jan 2025 04:27:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736771222; x=1737376022; 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=JwlrU1/L4OoVV250darEN+AvnT2p06BYtepXz4Se2OE=; b=k7156tSEtY8eE1t/IVqJltlcubA8LnyEp/DGob24HZgZM0qrbmRBHSkvyoIAE5/HYy rDm3XsuW0UQBnmp2LaIWzvj+wplCFXlyHwHHnpIit5Q5mg6zZFBTX8I5lK496JNPSyJG wtNLyTn4x26haQjBeWUtD2TZkwT+E+ahyr2ql8UX/YJoneNiMGJs/y3FkxrnnBHSvovD y3l6Cx2tXhDZSNt6TrpaeEXB4kcJapIbs5yMLP5xcuQGnqzJUSJgdDXdNBeCnqRniov/ c1JvAl/8POsiq5RrKmOfB/pnh0CReAF0ktPLNq3xv6P+ig8uAteHNg0uhsBTf26KaFZ5 ikpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736771222; x=1737376022; 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=JwlrU1/L4OoVV250darEN+AvnT2p06BYtepXz4Se2OE=; b=fAv7uvhteunOX2F6E9k6pjApIgTYAzsBsuHWblO5py+K6ubQ5CyIbU7KXFlseLOTtj 0M412Pol3x3EFMz8JpKFniNJApdxNse5A26bg0/WlTUM9ZE8f6og6IhtGEMWcFsohDWU TcM1FB6LpUXG/CXafvh5/VM4DtJ5vtDVXkeFGPW6B7q5MScRqBKcRlNkuW0RWViAJspC yO+g09kTaPYeKnvRQPX/sjOQLvTnPpndT/lPXRvC660mM7XQdlM3P3BChGWwNjRKfZYT JPrn4By2FNV1/nsOt/c2YCoI3wBza+9WANLDAyPsrcthfObtdOE4dG6MD0rDyZ6s8pDM J9rw== X-Forwarded-Encrypted: i=1; AJvYcCWXLt2PtiDhXfz4uSWMjyf/f3eiXLML4E4yPxhgadMSeUfVYAggKriAu3cprjlgb8KuHPomDNWGi4w=@vger.kernel.org, AJvYcCWl9wnPu+xdj4Vi2LekXhlHknSc+qk8ci+hAM5Qg8SOqVAyKhvTfgIp05YkGKOqjBV+eeJ51eSA6lmRBJcN@vger.kernel.org X-Gm-Message-State: AOJu0YwojPtCGdg41Jtz585AOA7MMJLDkd21DKbtbHtNAxO8nVzQvff/ arN61y/KZBG3IIiVC2fw1ml1zw7vSsw8E6w1ASeAzjoGySvrcgdxz6uXCc4HwiA= X-Gm-Gg: ASbGncvau0QO+esxn2HU52McaJ/6WpMYbGdH/0U7bvtKNORmmh83i4M90KJbpSGfQjH T9weJx1SKcU7cLsYYG88y1LRXG0jXI+Am7398IJx20U+8RQGPHeETyDIAaqhatwKdQHqhs+YAap 72YJEGAFd1grCuiW3XWpqArGo8seKiw5jTG/Y1D2UNDptYT7Tml01H49D12j0s7gLs2M9VpTK9e sPrXYBRl2Xf/ehECLxESJ6WN2Im2+F67yR6M0lDuqjcNbHnhfMyZZ/eimasBFoj/0UPkwC14Izs tLhWM33RmA== X-Google-Smtp-Source: AGHT+IFFobk5AQ2m4K7uPD7TeaYAsYgBxs8uq8w+kSbuaKt94jIejAPw3myughySRCs1PqIrI6LI7Q== X-Received: by 2002:a05:6000:4711:b0:386:2d40:a192 with SMTP id ffacd0b85a97d-38a872f51ffmr18082388f8f.34.1736771221625; Mon, 13 Jan 2025 04:27:01 -0800 (PST) Received: from prasmi.Home ([2a06:5906:61b:2d00:acc9:404c:3a6c:d1aa]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a8e4c23dcsm11812720f8f.101.2025.01.13.04.27.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jan 2025 04:27:01 -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 v6 07/10] i2c: riic: Mark riic_irqs array as const Date: Mon, 13 Jan 2025 12:26:40 +0000 Message-ID: <20250113122643.819379-8-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250113122643.819379-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20250113122643.819379-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 --- v4->v6 - Included RB tag from Wolfram v3->v4 - 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 577be1fb941e..d1768b38b12d 100644 --- a/drivers/i2c/busses/i2c-riic.c +++ b/drivers/i2c/busses/i2c-riic.c @@ -415,7 +415,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 Mon Jan 13 12:26:41 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 13937276 X-Patchwork-Delegate: geert@linux-m68k.org Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (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 98A26239799; Mon, 13 Jan 2025 12:27:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736771226; cv=none; b=gOq+XZ1aBcCpCBBhNAVbRKbAFSezO+ejFVMdWzoYDSvRK59qfFysPPrEyq8Wfrq6+MJEawXjiyLdQ5KpqMiGvrtdu1YvMybYEbevicFF4lB3jKlTzTTzV1yHdLlkRR77WfBL9drPxRISO2DEZnQjlcAEQG0oXTfim+cBhmhMa94= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736771226; c=relaxed/simple; bh=kxkVdWLNWABkMrhQXDHs8153xINcmHXb/kPLxxUgWhc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QOsTAyQP7OIZ5wk/pPzi1dEdM8VvR4iM9ymSMFrj+oEy2g9H9zO/jrr7+y9vI9N1NVxlixdA9JZvtcokxOnPNFpusIlzYj4L9z2fS3xsdUuV8u1ZQ2fk10vRh3/Bm7AwBXjgERrjQc2Pqme5I2eN8Ll0LsA2+PVoc1glDtQmX5g= 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=diG434a+; arc=none smtp.client-ip=209.85.128.46 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="diG434a+" Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-436202dd730so29766455e9.2; Mon, 13 Jan 2025 04:27:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736771223; x=1737376023; 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=Ep0KfFAO2kailNpwGXc9iLyPxYa9AKLwF9zXOgKPL94=; b=diG434a+9zVeYf4ZIwXWFqBIi2NptFA8Tnoa/zHPqVmmX51rTqFXGcQ+OOmnKWr7/N bcBT8Oopj7abQ+vkoEYQ2g2IR8KLCDjbdf6fBvCvx+szTZs1Oz8QylbWuaGUwCtGQJ6f YL8xur3QSTkCXK0dxqyJLwN1lH0eiWIYsv1NNe7V+yI9meP8WeTqTQflNRcDEl1810dA aMhVlDOyciMHFnR2tbilw8R7/yOVo5SXQRgJcuDC5PFQeVEpBw0f2/1fY5ZYoTKQKheb zHgbw31fUA05ioPScrWWHxB5GvCQSgbyx6KNdBgfLfx33w0lKe8yFZmVBQ+0zMvg8lNL zcZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736771223; x=1737376023; 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=Ep0KfFAO2kailNpwGXc9iLyPxYa9AKLwF9zXOgKPL94=; b=MnlEBc+GUdBP4F+pL0l9I3GONyM8v2RthqMwuvdSpFltToPH99rEnNqW2pjNilcrIh 6dniBGAIcTTJsAg+Ia44DqMuw7nwsdMRO5RukM1jd657JrcUUhrVGHxp03SoyhKAZdgh Fjy4DU8phz7udyJrohKsQOLiccU53gyE0618zG4s9WWrqeDseBrUCFZ/58PQg2X61jEf XxbRxuYBC/ahECPvvm9R81eYgiGoi8zfO1i/EoYMkra2AQ4+Nb+MKMYkFT42ZyzhqU9g 4i9nDL/H2hQ12I48OyPAceksGScrywaEpXbnfzmzcogDSYmBEgkL4NGfVRCl7wcRgoSY lJJA== X-Forwarded-Encrypted: i=1; AJvYcCURzyYlztPZ83OdkYW9kdr7lnRFozKQmRJ2MUpSJ7p+Z9X6FCzUAqaFEKfTmNi4e2IluJIEvxQEKOeIDO3+@vger.kernel.org, AJvYcCUxGZ7TZtinU4RdZwPY9yaGPR+TtW8YzU/y+WqGirfyKC+aTtrx7X2r3aRVuh+8lqdND+q457ny+9c=@vger.kernel.org X-Gm-Message-State: AOJu0Yw/IDtG7O6iQrkfjLRI7kYVAVnPgjuzTepfHt+RXCw5ksQk8utO orJXetdAhptJl5Cc0JMq9+x6+faQeQAzHbs8rMHCSRpS3ENhlnlLxc1ece3lDrM= X-Gm-Gg: ASbGncvETNYpeJpeB+cmrzzUR+no4qfrCAX9Y1z8+W2ecwbypJSoDpUHkDkCv8xS1sE x/eQil4LvYvoSpQsNL/fursOVb/7XcUQx4TfP04SWzfg7WwvK6uqWKYeG60KcqvNyLugPsTbt1/ mMcsjaIxOdH+rIqoqbp7ufez74mPKj0Z8SfD/gn/UyAqZBg9+gy3cr2EeUumDOtDIX0npxbLZXU XdYcALZSqUdSnnp1GTk0FUeyST72H+ZGR5vTqPVw5zSblMV4Z8+WjNEn/k4kvTagkvzoI61Ef7X BGMGqF2jRQ== X-Google-Smtp-Source: AGHT+IFsgLgEBrMB7TTIJ/qjyTgtk19I+bBa9GftLkpjygWN6k7hLa5OVQFYWM3xH/JzRmnhoP+0xA== X-Received: by 2002:adf:9787:0:b0:386:3e48:f732 with SMTP id ffacd0b85a97d-38a87303f5dmr15132911f8f.16.1736771222734; Mon, 13 Jan 2025 04:27:02 -0800 (PST) Received: from prasmi.Home ([2a06:5906:61b:2d00:acc9:404c:3a6c:d1aa]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a8e4c23dcsm11812720f8f.101.2025.01.13.04.27.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jan 2025 04:27:02 -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 v6 08/10] i2c: riic: Use predefined macro and simplify clock tick calculation Date: Mon, 13 Jan 2025 12:26:41 +0000 Message-ID: <20250113122643.819379-9-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250113122643.819379-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20250113122643.819379-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 Reviewed-by: Wolfram Sang --- v4->v6 - Included `linux/time.h` - Included RB/TB tested from Geert and Wolfram 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 d1768b38b12d..aa3e4f430b11 100644 --- a/drivers/i2c/busses/i2c-riic.c +++ b/drivers/i2c/busses/i2c-riic.c @@ -46,6 +46,7 @@ #include #include #include +#include #define ICCR1_ICE BIT(7) #define ICCR1_IICRST BIT(6) @@ -313,6 +314,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; @@ -376,8 +378,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) @@ -387,8 +390,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 Mon Jan 13 12:26:42 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 13937277 X-Patchwork-Delegate: geert@linux-m68k.org Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.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 C766623A579; Mon, 13 Jan 2025 12:27:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736771227; cv=none; b=BBs2DOmZVfu6vrfjV0vCFgMknz0pJD07i9r/SwnvtKHBsYdkEquS5uHjN+0LQ8iFyExFj7YtEPCJe6XVI13s5qI9mRCRAihgNQemN9l0mSWv88tNBOwb821wJDIsOQ9jgZZGBAN+ZAv4zFE6M9VrsP1TgMpyopJpwfUE2vlDH6Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736771227; c=relaxed/simple; bh=3Uv1tiFV4GlgTWpZ9h/HxzvVDe0P5DA97d4NIr0LF8I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HS3blyUIosHF52gIlkQaIhP1j9LHoLmZ8RcAO0LQxHbsIMlCRvBdyoj2N7XCDzmwxh/m6SxN8x6IRQ7g/aEfclEYmxqGkyyfVbZ+GvFq26/oMdHioQ9s23npb6K4eL0jDzdJtu1pw/bLP4YR2Frwastuhrmxgda3mLyqBjwtQp4= 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=emkZJg63; arc=none smtp.client-ip=209.85.221.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="emkZJg63" Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-38a8b17d7a7so2138439f8f.2; Mon, 13 Jan 2025 04:27:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736771224; x=1737376024; 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=m4+VZACaH/dvwtO2cJgknMiIs63iY2gH5Qg6pU/Yu0g=; b=emkZJg63+R95F1TvsxjeM+W5AxRUOQJLkGqkYJSupL6+uifzscOI2Kk5s/6heF8JgY w+fEloAD95eM4/8qwI/KuHRUCO3KOTrK/QzEfPbXVQ6lmduqDauHrVJLPH4w+vixmZ6v cwyRvl13A3uFiDHZiAlyJR3ZJ3OgzSb4Jtx4UxOyZZFMEFW6FMN4kGzN5Rjxeb28/7Zy BILnfxs5pSH8IK7d7c+6dlRb3s0NEsVw0d6+j2xazbHRmBzIvSuHeYVFbPwMUhb1FZRi ljl6WJkVdJ/LuZNe8ElirS1Ns1gsmu1/jtpqAN2bxfGuMOCh/QeZZBmnFRe2dz+t96SA YFIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736771224; x=1737376024; 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=m4+VZACaH/dvwtO2cJgknMiIs63iY2gH5Qg6pU/Yu0g=; b=HrxhZc0zNIP5y3g3i7gs7EnJtxp8HcW+BqS2zWYuXMs1ZTZQO6ju3L6KNz3pDEUU6/ IHLrZ9XMtaucdRjd3Hjdl/No6BikoSmfVD0eXMr0GIE9iCe+LyZD+lY4Ob4TUJWSGzfa 78G9YhdHMD/P2BTyyHiphyLl5eL/UtV6bc2m8FVhjeCMaOOvC36vCH8g8mE2URPqSKxG TwXClKb8y3t1dX9NfLsWovyobc8imQQuxqzK5CDLRFyHkfFPyhl0MuB6Wdjh23FWcmPO W6/3XYX4REFkin45KlYnQmzqkhrDWTqcQD/RIO/rZ9kT4KtUb5BkG5f6wdEcp4gOETi2 biRg== X-Forwarded-Encrypted: i=1; AJvYcCXFUFoqItG+a9i6jN31/wxUHuvll9WNHx5TEiaThQQVT+qVwzbdmJRfXMBVKvAbmsvuRoumfpygCJw=@vger.kernel.org, AJvYcCXJiPvmaRd/gYma1wDjH4/DvKRL6suPAQAiDYUgefFgDqnAX5b+58DMjs6+eZl4JKvIB08BOV6KihOuNYCJ@vger.kernel.org X-Gm-Message-State: AOJu0YxzImU31V/EHyrlpYHmXdmLtoOXrEkf3zn04m25MBMIGnn4I7OX 1XNcTZTUH8VnceP4lE1lH/I+OQxOCXFcW/RgjFmLJ9roNjNy6tYD X-Gm-Gg: ASbGncu5uMWItgRED8RPxvvX/KKZbWW+xRRVIxIbbHD0I2NH3Ic4Ra9/HEIsPeChOsE R/QqMK1f769Ypalm80SDnr90eg0ui6TQXQC5ItVCjdtkPBeQ/paLhaCXoMrP4WA2M3ynprJiWzG cXwptAjtlaRGDekRpBuHYdXk00PKI8tVbkag8hgQnY8VRxdL16kr+JiMmsgirNX3KRgJh5ImFXq ymeNDnr7BL1Veoh6NanK3nu1JkAdaeQfxet7PHjpRPxnRFzkv5X5Ds+yrLI4g4vYO2qgpl0/cap nzmD0W5VcA== X-Google-Smtp-Source: AGHT+IFIKmE9m3bgbks+HbC08EMGmjcJ0dZpnRP4TPeBI6bN2lK0m8TJ2zk3DyzOBoCo9BLBol6U1g== X-Received: by 2002:a5d:5f85:0:b0:385:fdc2:1808 with SMTP id ffacd0b85a97d-38a87336ee3mr18961746f8f.40.1736771223887; Mon, 13 Jan 2025 04:27:03 -0800 (PST) Received: from prasmi.Home ([2a06:5906:61b:2d00:acc9:404c:3a6c:d1aa]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a8e4c23dcsm11812720f8f.101.2025.01.13.04.27.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jan 2025 04:27:03 -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 v6 09/10] i2c: riic: Add `riic_bus_barrier()` to check bus availability Date: Mon, 13 Jan 2025 12:26:42 +0000 Message-ID: <20250113122643.819379-10-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250113122643.819379-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20250113122643.819379-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 --- v4->v6 - No change v3->v4 - No change 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 aa3e4f430b11..d7dddd6c296a 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 @@ -51,6 +52,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) @@ -136,6 +139,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); @@ -148,13 +172,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); From patchwork Mon Jan 13 12:26:43 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 13937278 X-Patchwork-Delegate: geert@linux-m68k.org Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.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 C972222F16E; Mon, 13 Jan 2025 12:27:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736771228; cv=none; b=M12au43CXtYqUfLv3wTAlRnItfnYwvaGjckuf22y88HdXwt4lxFKuY0DvTsxPdnk8mTMO9McW/ZOXNHYN+Bf5y/R6te195mQYlSR0PL/JzHupgHpSRXEjfnwMYcykHCzP16cT478BuvL9JwiWvkrnkX/YowqyrYbbriroN//zm4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736771228; c=relaxed/simple; bh=/Lyj8zeajSffVRPgPE60R+/Zg9mopkTcD9qHBwfxMGM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gp7BesPHSLJbVzSj+U+a2cXE5H7rTarkdnMYzm44s5J+2NBPUarmzm+WvD49yQq6S0LnJXobC3zcn7KuzhArFV6GryROVEMX46cEytMeHGODMD1EIFuFO3NgFFFUVCA6rtI9reFEFQIMu+olMi++FK8R2RPcqeEyAZc9JA7Qm4w= 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=W4eUjoPV; arc=none smtp.client-ip=209.85.221.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="W4eUjoPV" Received: by mail-wr1-f49.google.com with SMTP id ffacd0b85a97d-38a88ba968aso3513668f8f.3; Mon, 13 Jan 2025 04:27:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736771225; x=1737376025; 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=Eu4ESOBvVBzaEzRYnyWj2Jpuu4zqLWmBIIf9AvIQNX0=; b=W4eUjoPVVW/ht/uvZr1oIoqrQa3WioYv4+lpXQSId448/WwtAphAjGEOo6k3z8DkjX DkaoHdWlIIOIJ2GNK8WWeO+6sJrLeWzZ6nQZTFEnebCDYPy8BsLy2Ixrs1x4SaaXx+l6 krRn7htY4t/i7QDckLEUW4/nfg9PiQl03X69Ck/kZ8XDT+3H+sYR9O+QUGqN6JJ6QWcI JDiE5iO0SDVVQprF3AjqpcrQvOJfM0VNI+/flTokkJx3MZ+k9SekxXnCnkK3PLtdz7iI DkchcudbwB3nCtDWVYFebLx2fX1/Ik2ZDrruwgpJBQ3S5AkVpe31wxyg+XhIvhrtyl5k Dywg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736771225; x=1737376025; 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=Eu4ESOBvVBzaEzRYnyWj2Jpuu4zqLWmBIIf9AvIQNX0=; b=Cuc9h4zG6Ux1ZWAHAk+XHEwQfqa4he2BQUxE08Amd5o/g7w439fcxFuW5lrmXi+9Ma d0JTWy1+irthq1x4goq4+aPckJUc8RjwR7ySa+QNzsQS/nH3SckSoaABpJJwdMtc2BXx BANjlKeUVuDUW2LRBXS+fImIgVVU8PExDvdueyIbY4UNlgisQBdZjCnxTiBm3ULEtWZB HiCZTcXKYYRwRpn1+VtgVTQUB0SksY1vRrBTxNsWuQ2QPpUtAMFnpzDzrJ7XNBbnKvXj NnGbuVCTRoLAbP055nBPVtBppIK3L9LbEg2QYQPFFK9lfGNx5Ypzk44jX1ndq1TZtXER 3pqQ== X-Forwarded-Encrypted: i=1; AJvYcCUrOXTGridfJk0Qge8IZ1mGcMyICyyGCgVUeN9oue6gc4WXSNzT8mwzTu9MmJvh+zGkvRCJMzBBjtGcvNCh@vger.kernel.org, AJvYcCVTzTyY8de1DbQoRQOZh3LoNO06CiGN0RRrOZe+DYHcVUey6FyRNZxg0/oVJmWMDSpNQDM6RKWh2g4=@vger.kernel.org X-Gm-Message-State: AOJu0YzfxSc7BolhmMb106U8+3d/iJkmOo9c4DblphWv972JctWALfRC Q0Q0efLhW3RkjOeywr1F3PPRU+S00j1rIypgcwKZ+PNqomSM9iKt X-Gm-Gg: ASbGnctgWQds71r0WhcmyK/duKJh77XwuTkESL4GxBT+279oaqG2uttqe6Q5VNAHpBP HEuEpiDfcsqnMzIH8zvTHBnhH2uNLn99Usa7Fu+hb/9BFDscnOVcSGygPJ9nT3gMzvKGb+Hg0xs 5LN8uiRASA2gUM3QJ4yzc9xJzcAyEDDZg8Al7Z/t/baUBgYMyyQXk1L4W3Amp7rP5azeCSUNveD W0+MU5VzvM6ZYI1lVgtMSMzn2wE44yqBrgkf1Sn9cYy+c0MthmB0sYD6Xmke0+y4mqC3LJ8ZpUG /FzKl8TA8w== X-Google-Smtp-Source: AGHT+IH++7Mt7kMI0ZNxMuFx6bJy0gxGzyTry5sGR7HsNR9hj6Q2VncFV4yRvdodzlJLS5SawD8f4g== X-Received: by 2002:a5d:5f51:0:b0:38a:8e2e:9fe3 with SMTP id ffacd0b85a97d-38a8e2ea20cmr13470048f8f.24.1736771225041; Mon, 13 Jan 2025 04:27:05 -0800 (PST) Received: from prasmi.Home ([2a06:5906:61b:2d00:acc9:404c:3a6c:d1aa]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a8e4c23dcsm11812720f8f.101.2025.01.13.04.27.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jan 2025 04:27:04 -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 v6 10/10] i2c: riic: Implement bus recovery Date: Mon, 13 Jan 2025 12:26:43 +0000 Message-ID: <20250113122643.819379-11-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250113122643.819379-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20250113122643.819379-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 Implement bus recovery by reinitializing the hardware to reset the bus state and generating 9 clock cycles (and a stop condition) to release the SDA line. Signed-off-by: Lad Prabhakar Tested-by: Claudiu Beznea Reviewed-by: Claudiu Beznea --- Hi Wolfram, I have inlcuded bus recovery patch as part of v6 as I am seeing issues while using generic I2C algorithm for bus recovery as mentioned in the below thread. [0] https://lore.kernel.org/all/CA+V-a8s4-g9vxyfYMgnKMK=Oej9kDBwWsWehWLYTkxw-06w-2g@mail.gmail.com/ Cheers, Prabhakar v2->v6 - Included RB and TB from Claudiu. v1->v2 - Used single register read to check SDA/SCL lines --- drivers/i2c/busses/i2c-riic.c | 100 ++++++++++++++++++++++++++++++---- 1 file changed, 90 insertions(+), 10 deletions(-) diff --git a/drivers/i2c/busses/i2c-riic.c b/drivers/i2c/busses/i2c-riic.c index d7dddd6c296a..888825423d94 100644 --- a/drivers/i2c/busses/i2c-riic.c +++ b/drivers/i2c/busses/i2c-riic.c @@ -51,6 +51,7 @@ #define ICCR1_ICE BIT(7) #define ICCR1_IICRST BIT(6) +#define ICCR1_CLO BIT(5) #define ICCR1_SOWP BIT(4) #define ICCR1_SCLI BIT(1) #define ICCR1_SDAI BIT(0) @@ -69,6 +70,7 @@ #define ICMR3_ACKBT BIT(3) #define ICFER_FMPE BIT(7) +#define ICFER_MALE BIT(1) #define ICIER_TIE BIT(7) #define ICIER_TEIE BIT(6) @@ -82,6 +84,8 @@ #define RIIC_INIT_MSG -1 +#define RIIC_RECOVERY_CLK_CNT 9 + enum riic_reg_list { RIIC_ICCR1 = 0, RIIC_ICCR2, @@ -151,13 +155,16 @@ static int riic_bus_barrier(struct riic_dev *riic) ret = readb_poll_timeout(riic->base + riic->info->regs[RIIC_ICCR2], val, !(val & ICCR2_BBSY), 10, riic->adapter.timeout); if (ret) - return ret; + goto i2c_recover; if ((riic_readb(riic, RIIC_ICCR1) & (ICCR1_SDAI | ICCR1_SCLI)) != (ICCR1_SDAI | ICCR1_SCLI)) - return -EBUSY; + goto i2c_recover; return 0; + +i2c_recover: + return i2c_recover_bus(&riic->adapter); } static int riic_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num) @@ -332,7 +339,7 @@ static const struct i2c_algorithm riic_algo = { .functionality = riic_func, }; -static int riic_init_hw(struct riic_dev *riic) +static int riic_init_hw(struct riic_dev *riic, bool recover) { int ret; unsigned long rate; @@ -414,9 +421,11 @@ static int riic_init_hw(struct riic_dev *riic) rate / total_ticks, ((brl + 3) * 100) / (brl + brh + 6), 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) - return ret; + if (!recover) { + ret = pm_runtime_resume_and_get(dev); + if (ret) + return ret; + } /* Changing the order of accessing IICRST and ICE may break things! */ riic_writeb(riic, ICCR1_IICRST | ICCR1_SOWP, RIIC_ICCR1); @@ -434,8 +443,74 @@ static int riic_init_hw(struct riic_dev *riic) riic_clear_set_bit(riic, ICCR1_IICRST, 0, RIIC_ICCR1); - pm_runtime_mark_last_busy(dev); - pm_runtime_put_autosuspend(dev); + if (!recover) { + pm_runtime_mark_last_busy(dev); + pm_runtime_put_autosuspend(dev); + } + return 0; +} + +static int riic_recover_bus(struct i2c_adapter *adap) +{ + struct riic_dev *riic = i2c_get_adapdata(adap); + struct device *dev = riic->adapter.dev.parent; + int ret; + u8 val; + + ret = riic_init_hw(riic, true); + if (ret) + return ret; + + /* output extra SCL clock cycles with master arbitration-lost detection disabled */ + riic_clear_set_bit(riic, ICFER_MALE, 0, RIIC_ICFER); + + for (unsigned int i = 0; i < RIIC_RECOVERY_CLK_CNT; i++) { + riic_clear_set_bit(riic, 0, ICCR1_CLO, RIIC_ICCR1); + ret = readb_poll_timeout(riic->base + riic->info->regs[RIIC_ICCR1], val, + !(val & ICCR1_CLO), 0, 100); + if (ret) { + dev_err(dev, "SCL clock cycle timeout\n"); + return ret; + } + } + + /* + * The last clock cycle may have driven the SDA line high, so add a + * short delay to allow the line to stabilize before checking the status. + */ + udelay(5); + + /* + * If an incomplete byte write occurs, the SDA line may remain low + * even after 9 clock pulses, indicating the bus is not released. + * To resolve this, send an additional clock pulse to simulate a STOP + * condition and ensure proper bus release. + */ + if ((riic_readb(riic, RIIC_ICCR1) & (ICCR1_SDAI | ICCR1_SCLI)) != + (ICCR1_SDAI | ICCR1_SCLI)) { + riic_clear_set_bit(riic, 0, ICCR1_CLO, RIIC_ICCR1); + ret = readb_poll_timeout(riic->base + riic->info->regs[RIIC_ICCR1], val, + !(val & ICCR1_CLO), 0, 100); + if (ret) { + dev_err(dev, "SCL clock cycle timeout occurred while issuing the STOP condition\n"); + return ret; + } + /* delay to make sure SDA line goes back HIGH again */ + udelay(5); + } + + /* clear any flags set */ + riic_writeb(riic, 0, RIIC_ICSR2); + /* read back register to confirm writes */ + riic_readb(riic, RIIC_ICSR2); + + /* restore back ICFER_MALE */ + riic_clear_set_bit(riic, 0, ICFER_MALE, RIIC_ICFER); + + if ((riic_readb(riic, RIIC_ICCR1) & (ICCR1_SDAI | ICCR1_SCLI)) != + (ICCR1_SDAI | ICCR1_SCLI)) + return -EINVAL; + return 0; } @@ -447,6 +522,10 @@ static const struct riic_irq_desc riic_irqs[] = { { .res_num = 5, .isr = riic_tend_isr, .name = "riic-nack" }, }; +static struct i2c_bus_recovery_info riic_bri = { + .recover_bus = riic_recover_bus, +}; + static int riic_i2c_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -493,6 +572,7 @@ static int riic_i2c_probe(struct platform_device *pdev) strscpy(adap->name, "Renesas RIIC adapter", sizeof(adap->name)); adap->owner = THIS_MODULE; adap->algo = &riic_algo; + adap->bus_recovery_info = &riic_bri; adap->dev.parent = dev; adap->dev.of_node = dev->of_node; @@ -505,7 +585,7 @@ static int riic_i2c_probe(struct platform_device *pdev) pm_runtime_use_autosuspend(dev); pm_runtime_enable(dev); - ret = riic_init_hw(riic); + ret = riic_init_hw(riic, false); if (ret) goto out; @@ -613,7 +693,7 @@ static int riic_i2c_resume(struct device *dev) if (ret) return ret; - ret = riic_init_hw(riic); + ret = riic_init_hw(riic, false); if (ret) { /* * In case this happens there is no way to recover from this