From patchwork Fri Dec 27 11:51:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prabhakar X-Patchwork-Id: 13921765 X-Patchwork-Delegate: geert@linux-m68k.org Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) (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 95D0042070; Fri, 27 Dec 2024 11:52:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735300329; cv=none; b=kIVIAkh3OsgqyneuDAk671PZV+6AKcQJRo4pGPE0yUjK9by+ByedArC6nrfHO9Q7rH3uO5xHj7UL7c2S0ZbydcrHux9a8807UsUEi/aT743Cte9tKHGWHOfkJMUlyX5g7clobN1h2vMhj8yvK/XVEBAQUNOwv+kyI3gqSMgj/S0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735300329; c=relaxed/simple; bh=lrzpHr/DFhrf8Bni+hCjVrbzYexPvT8SpQ48LcVmilE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lQzKFmMgzZ09jx5X7YMmXqmUj+GFjZpcHt6fpC4dhUPevjA8DD7mwW8PoPSQ3Pm6FUZtRsn+Vr8Fb3DcAq7itpjMFsilmY6tVQAxx9ww3x0Y/9XvOn+17SGeduE8iZRW0xHeyVT6oe9JWs9Iu32vQUfhJo71NGcKYrXTixC6dnc= 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=g53+7UkB; arc=none smtp.client-ip=209.85.214.182 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="g53+7UkB" Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-216395e151bso63220695ad.0; Fri, 27 Dec 2024 03:52:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1735300326; x=1735905126; 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=g6ssRe+un38eDrKoU2iPeM3GHtYdMNvqdXI/VFe25BE=; b=g53+7UkBBKztnGrQVrZBzRhu4Q31NGcQhr3ooPd021vf004UREiQjOTQGiv4EEjK+K BCPi00Xv/DZ5NNkRjbRXw0DEuW1/ZhZqvE70SRwIkbDLnyyyqiXgdP6ejzuvw9MXAZzD 3LXotVRTCFDkeZHLi8iLBrUeSDpb4ZTpilt3dH3IkQ3hAuDYa+PXLLzWUIUSWTCRwgOP vvTCP/zyPhKkPUFfdLTLaLWfZuH9n6byr9AmMLk5BoC+F4l5wcZO57qSSxmkg0uduDsZ 80l6TVYPT5r1pMm4cnvQD2SEwsVQJfx9ntpumucpslWLKgP2Bc22dCCn3/PfmOky19Fq 5uOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735300326; x=1735905126; 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=g6ssRe+un38eDrKoU2iPeM3GHtYdMNvqdXI/VFe25BE=; b=b1pfsiGU/ujDgnqZN1hTN/f95f5cD+eW7XpsH47aksV/vLaK0mOBM4brqK8kTtImod tBo4x9YlYoRR9KKQUBUeTB2DFd5jzQz3vYVlxsqOWYgoZsKIurtah2UILn0AnZdbS1yL JO6gdgMxXVHJpq1XYwsXGMyn7oNc/6XoW7DYdKO7Rulfz1BCP+wYBOpBMRqjn8mu2KfC hizQme5X0rPJIAUME1Ud4HEIigPo3KCR4vcRc5SAa0lOEQDQeG9gQvT+6NqlyrQFI2U1 y8UtDZ5dBauvOUvVZF9tcjICvdBfqb15UoJTpz4r1+Is7GcXLlHNteVRFSKGTz4ZyNbs oZ4g== X-Forwarded-Encrypted: i=1; AJvYcCWVTCvJotIsJ3sjNmu72+ExPik6AfhTFBuRAwZhox0B1+4/i++BGuLi5vfauRJhDFGRsxTjEJe03HOedp81@vger.kernel.org, AJvYcCXdxEQtgPxCqSbmHul8BocYj4nBGu/AREFx6ChLLPY9DjhJSrPNYwdmcz5rV57CiRss32qfjHJZp1w=@vger.kernel.org X-Gm-Message-State: AOJu0YwRcVB2J8+oP76nJ6y1CaTZcmC0vU8iW1eO9pmC52dXbiseat37 sm1bIW9AypTZKbolLdR/iqPDmHMgHmLl+cScDGZby1eUTcefXgq4 X-Gm-Gg: ASbGncu1x4CROYCPfD359686UkJEXOcndfb/TpadzGN9IqdlOc+fBqXmWCWMQqR69yU zQUWcVWGBuSDVYy42rVFMABF7l540LatWS18Ew6yPUgXIT6ezrP2xnFObzit9GGB+nyq/ti52FG RIUFHWYwQOPfPr5BFMs2O0xlojQWNiMo/dHZy6pD2bzfX/VSJqtsn5Ybo0xD+5m2cCGiQZwcGQ5 RyZ5pixIrhF55BDAWrbLM7rHj73nm+FjF6uDzxpEj90cj8h8gbgWU4cTJvhAotURaCy1nm3YsLa 7Tg3sGc= X-Google-Smtp-Source: AGHT+IH976eqe87smpQrJsBmFfU4YlGmuUtVPebyMpbeHhKOiQIG0hRM7WOw5glEbHrVK7JixxoTXw== X-Received: by 2002:a05:6a20:2d24:b0:1e1:b0e8:11dc with SMTP id adf61e73a8af0-1e5e1fa14a4mr32499414637.21.1735300325718; Fri, 27 Dec 2024 03:52:05 -0800 (PST) Received: from prasmi.. ([2401:4900:1c07:9010:ac08:3a91:844a:cc65]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8dbcbbsm14363990b3a.97.2024.12.27.03.52.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Dec 2024 03:52:05 -0800 (PST) From: Prabhakar X-Google-Original-From: Prabhakar To: Chris Brandt , Andi Shyti , Geert Uytterhoeven , Wolfram Sang , 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 v3 1/8] i2c: riic: Use dev_err_probe in probe and riic_init_hw functions Date: Fri, 27 Dec 2024 11:51:47 +0000 Message-ID: <20241227115154.56154-2-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241227115154.56154-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20241227115154.56154-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. 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 --- 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 9264adc97ca9..e1babd5077d4 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 (%lu). Too slow.\n", + (unsigned long)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)) @@ -470,10 +467,9 @@ static int riic_i2c_probe(struct platform_device *pdev) ret = devm_request_irq(dev, ret, 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 Dec 27 11:51:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prabhakar X-Patchwork-Id: 13921766 X-Patchwork-Delegate: geert@linux-m68k.org Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) (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 A9B0C1F2C27; Fri, 27 Dec 2024 11:52:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735300332; cv=none; b=o7wO6utz8FR01Kp3EGMnX0nx6PSCF0X5ITClWgCwviVrcVVhkdfU3Vj60X1TXRjMlzCUiGP9VFP5Sh5fe+EPhi2qCdimwGnMG8HJCwKjZykBtDq2f5VRHC2dX9gvAzqw7RaA/CxJgDGxdF6gVWCQZJx+PCreS5Zf9UNXysAsrL4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735300332; c=relaxed/simple; bh=r6NwWr0EMAA4jcLLbT4+7BFeJ73HJpxC3n+D0mkfyOI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bnanbedlGjQ9btjL8EVZ/UPPCeaV4Jt6pBUpRHBpGSs4CN+LsWHSOcsbKZOEGj7wPDYIlHVuRL7syoDNtN+aMf1MUk7PRitS05+sNyBoDv2zKnAu8pWs8nq8g1iqw6RK9Db+98hSN8dGqsj56sny1Flo36HrGZX5raqnrFEsInw= 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=Jf571Xf/; arc=none smtp.client-ip=209.85.214.174 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="Jf571Xf/" Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-21669fd5c7cso87991985ad.3; Fri, 27 Dec 2024 03:52:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1735300330; x=1735905130; 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=15965UaUMUIQcX8R2+qIbEDBP9ZN9hIvP+Qalpqa8Qo=; b=Jf571Xf/d1uSny8gDHis+WmFd3HtvmWnE58e81ira+QZEG69cYFWAdAhdBHArxZsP3 fakYIV/b92lohVXKOsQv7wo/oP9jvB9YZmL0zgCKpIBXdeHtpOFj3cCEDe2Dbp4ZW+4M AP6+yvfjxwoemyy02o1eyfCwxgb0f/SriO5Cwrw16JXVY1m8XU2DYbX4IzgdNrkYbjbU 2yUqo4A9kcXwOOjaKhbtB+puVRmNqUH+3WXe87jJGPdzUpwR0qBVTj3PPsj4cfdbp8nx ou/CWFT4CCclAUsmxEPdBJHZ8pw7mahffDqszwbdo3tarcG5L3IFs6wao5ueFL+eGrZ5 KNtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735300330; x=1735905130; 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=15965UaUMUIQcX8R2+qIbEDBP9ZN9hIvP+Qalpqa8Qo=; b=CEKAV2yI9O7NT5SMzqdO2iJuJYy1ZwtSaHiRwvb6MUp00q8Xubzzo/2nZt4X/UNYL9 dW9GvWX9itircAKhaxu8VGwVUQ0YtsiaEQfkeHTpj0EpC5o4pUFIgOuhJjMC7lgJNo7K gtyTRmP5YIk0btM6+Dj3cWI1EX5Bj6Q0CtDLiYh9bKoQPxs4UXLIy+rCUqcBaAAyj7h1 0riGaZw8WueEfPdlWjQO7xPY5HUvwz2vG1XA47rI2FkJ03eDMrTN9a3T9gI+/6dmUf/Y C4/nOOz2UIvGkrsZ9E+16VMFXWHcmYZ+28qdTY48t6MbXooy2Pjv96VBXanONCZxujiI em7g== X-Forwarded-Encrypted: i=1; AJvYcCU/oQOmxdyGJacGEJ33/XaY0yvuVRVFSgkOaVAjjEqpsTQkuH3Oqq1GzPhCiObOJf+PPSEJn45TS4EddDmH@vger.kernel.org, AJvYcCVYK6miJ95/2TAUT4JAmLMje1UMhQ0i/OhLdWZcH3cjN1DIDoymNP0YVKKSNXt+P9+iUGNTJmob+kk=@vger.kernel.org X-Gm-Message-State: AOJu0YzUbKjpv85SknGuZe3KSKXTiPrwi4aoMNzFv+i4AR8bA1N+2vT7 PhNBGcb8RbIIQNBgiFE+XGs24KjdPyyf8YKDOyHaCrlDFmK4Jkh4 X-Gm-Gg: ASbGncv5Ya9LDJFvtGaD9PGgg2jfllBkjEhibBIpeyunOhFbb7C/ZMfKOnwI50CN+Cj 5COmfLGfTmzheVN/t1kUyGE8Tb5jUaoV+ky8EtFY0KWQa5QN4khU5kgLmYzZNeS6cpRsoJUhfat q0hwPdj2ujJO+zL2v9uwBDwWgI1KTo3Wf2JSr/2/l4n6MyhnoCan9aboAAu0rC3JAn/Pqbxj3sd gVv8g/1Cl8ObBZQEj9p1186+gYMXNryFC9gC0ZAdLda4sA2t8HVCKm3vlqoSJe1JvrDhIbh/XqS PyuItzQ= X-Google-Smtp-Source: AGHT+IHeDK1oFL3avB4RSV1GAEhoTKrJ9m3cdlJ7UqZ7wvUv5W10qtZta9ibPc2BnJQWnZoo3sjnpA== X-Received: by 2002:a05:6a00:858b:b0:72a:a7a4:9b21 with SMTP id d2e1a72fcca58-72abdd20f03mr39572625b3a.5.1735300329846; Fri, 27 Dec 2024 03:52:09 -0800 (PST) Received: from prasmi.. ([2401:4900:1c07:9010:ac08:3a91:844a:cc65]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8dbcbbsm14363990b3a.97.2024.12.27.03.52.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Dec 2024 03:52:09 -0800 (PST) From: Prabhakar X-Google-Original-From: Prabhakar To: Chris Brandt , Andi Shyti , Geert Uytterhoeven , Wolfram Sang , 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 v3 2/8] i2c: riic: Use local `dev` pointer in `dev_err_probe()` Date: Fri, 27 Dec 2024 11:51:48 +0000 Message-ID: <20241227115154.56154-3-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241227115154.56154-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20241227115154.56154-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 --- 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 e1babd5077d4..01195ffd4c07 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 Dec 27 11:51:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prabhakar X-Patchwork-Id: 13921767 X-Patchwork-Delegate: geert@linux-m68k.org Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com [209.85.216.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 AEB1C1F37A0; Fri, 27 Dec 2024 11:52:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735300336; cv=none; b=l5Dmzugm1Fk+IcqD4VYPrdUzxU0xfH+UJLCKsmlLwunrktCJ6jGbkmAmFSkwW3YJq2+VE5V7xKuX/r2+dEy9SPiBzY/VLumQqUFWqAz6OnFvNbG63j+lLA3KooJ8m21lQ0fHPOdF2JW30dcHOEBldpLAxQ1iYF7EVe6dtUAsAGU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735300336; c=relaxed/simple; bh=tF5pB82Fr4P93kY9OUCzA/qRcS817oSbil+H6fqsdT4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=c5NyXlxWpSeA0NgJ0AKQR4PSHHF5zZSGqQrNBmv2fo0z7hyUJhenJ9KOt98EisluAd6FoALhE3ntGQCkL5LKwK9HxzHAMfhsvPHRYy+6/SDOmcGjT9Iis9f8LvlY3aATQyT1WMbAuhQOmqKODhAY4B2Kq18D5ads4m/4i50e8kU= 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=LX6mFccE; arc=none smtp.client-ip=209.85.216.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="LX6mFccE" Received: by mail-pj1-f47.google.com with SMTP id 98e67ed59e1d1-2f43da61ba9so7361246a91.2; Fri, 27 Dec 2024 03:52:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1735300334; x=1735905134; 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=/F3RfUKbaIaxAALUEZajWYhDqOeq2DVl0PqlMpbhTjA=; b=LX6mFccECGLXpFp20xBMZfozF+YbXuCbXffC4oEgdOA5NT5wWGUY2MM4FV05c+UYwT hGR+4Zb5MyxWEgUwsA0NCEspKOJsCBPxm9hG2NLK+v/PpDqpoKmHYp8x6LSuwl8Pc7sK 0a4oRNLye6dD9Sa+UABWH+/nqqV+pEhDdJYIYz3Ip0knSW8dLs8LRxrARR7rbJtxaQ12 N86T6+Rlfoo3x1u/4Lk8hqgnYZbhxFBBXREbahPA6HNDyTcHYIEjw0sDlh8Mm766wlZ4 jpEsv71vlf6zndKuf0T24po3I6aU4nv94+gcU3DWA/QkPwV7lT8lelP+GDlZMJFWZorq 6NIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735300334; x=1735905134; 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=/F3RfUKbaIaxAALUEZajWYhDqOeq2DVl0PqlMpbhTjA=; b=BM8kugTNitNNml56bd9D5v7fATqbbjXaF+JCIMpPKYLV76pNX/Z/QvMz6hDb93MPNZ F/ivVmtwWUlOyWZW9vdU2apI8QPfoZ57Y/YDFkMu2RyXQOUxFf02ge1efbjOR1QAjdB7 1aRNYXzAlElG/6MPDqU+eWt180qDi7xBVK87ANEEEBmAS2racPh193t1chqnYhK/nko5 tq4WBoV0Jy00f9ct0cTwUKJ7jQB1cl0gxs6PQQIieJSsDSB2vGwmd/NEp4bCx7/SWVsN 5IqY9b30YYDcnVRlSoS1ZaRDh9GFEjLAxaTI6XjpjLQ4htHXiF77ZXJfURerfNJeMLPJ w0Hw== X-Forwarded-Encrypted: i=1; AJvYcCUkWRua9FTvTjQs14GYf2CpvD7UuM4EjgK5Rubnf4xabRAeLSewGSfzkk2DzL0SWRrBwvGlBl+zJQs=@vger.kernel.org, AJvYcCVaDFkHCo5e+aBfHN46Hq4/5GCrApZ21PfIJJ5SVkR/EoTQZWyrUrsfyzi/An09dBmJiVRumyKmkjh9NtKT@vger.kernel.org X-Gm-Message-State: AOJu0YzeU/vxgPKNATbsfFB6XkMdpyZsiaeu8fMLaB02e13/q5gfPJ2a IfBtatrGKX3s/N8K+TsC9+xxltTrsMc4FJXfM1I035JetDWBPsXY X-Gm-Gg: ASbGncuxDA9hKauwNfqIupCFB55p3T1+aBDinb0MJlgfXKDp/M8rBH9bCl1Zu5UG4t0 WdguNoXY0kjq7AwM3a7qAxHzoS2c4giWcvfsVXbyQU1fSbxlTxLhzunXH+f24j7BzE+hAnNx5/i 9plN3LbF7to+41bVbbWv5dNfteeeVAHAIWQkqFduq+ooJrtyz8NSL5Czc3MRWYqGOQN4K3gM/Uq YLyFv5LqWAFwwGZojlpwYBxzgzj44XTv8vDePxQBNrzPoZyeSu9S7OBqARBPDoNaDWOjNwVNFrw UmsVVHM= X-Google-Smtp-Source: AGHT+IHLwYFvGgSYPxCebbz4fj5SBO8nugJBfDkBINneFZcGegTyPZtN17rtAvD2uDCT/CD44i2A2w== X-Received: by 2002:a05:6a00:35c9:b0:71e:6c3f:2fb6 with SMTP id d2e1a72fcca58-72abde65a60mr45834856b3a.8.1735300333965; Fri, 27 Dec 2024 03:52:13 -0800 (PST) Received: from prasmi.. ([2401:4900:1c07:9010:ac08:3a91:844a:cc65]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8dbcbbsm14363990b3a.97.2024.12.27.03.52.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Dec 2024 03:52:13 -0800 (PST) From: Prabhakar X-Google-Original-From: Prabhakar To: Chris Brandt , Andi Shyti , Geert Uytterhoeven , Wolfram Sang , 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 v3 3/8] i2c: riic: Use BIT macro consistently Date: Fri, 27 Dec 2024 11:51:49 +0000 Message-ID: <20241227115154.56154-4-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241227115154.56154-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20241227115154.56154-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 --- v2->v3 - Collected RB and tested tags v1->v2 - Collected RB tag from Geert --- drivers/i2c/busses/i2c-riic.c | 36 +++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/drivers/i2c/busses/i2c-riic.c b/drivers/i2c/busses/i2c-riic.c index 01195ffd4c07..954e066d61a8 100644 --- a/drivers/i2c/busses/i2c-riic.c +++ b/drivers/i2c/busses/i2c-riic.c @@ -46,32 +46,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 Fri Dec 27 11:51:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prabhakar X-Patchwork-Id: 13921768 X-Patchwork-Delegate: geert@linux-m68k.org Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) (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 BA2CD1F238A; Fri, 27 Dec 2024 11:52:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735300340; cv=none; b=VAWLhNfNR+1BBvWpwzjCp7aepHPejucorekMM67UbM8LssQV0faW4/J7Wa7e1W2t9p9aPM4u9KFu5K/zMgGCjJJOqTA1zMkke0UUVksppfQ3fhIldLcyYZ7BEW29VPxI4X0HVe92Ena6X/gjFBL8UF6Q6z7bgjuZtii87jJxm7k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735300340; c=relaxed/simple; bh=44Vs6/FM4VZrYo/0laOqRhsRYTez9Z5iEd8n1v/03Is=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OdrvSupHPnpcTdB0232IYXo2Y3+zu85X20S6LIEya3fOfVbxFOBRpQXYu3+4t87C+EyPra9kvEWbija3nXCXWSRw0DAcBmrTT/IG2XrcF2zICM+r/oGPNyHIHkWMOc0WtZyqY3zC6u7voQrs6eN4/0MhxxIwqr68Njzs10Fed5U= 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=VUMqhjTV; arc=none smtp.client-ip=209.85.214.169 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="VUMqhjTV" Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-216634dd574so59061925ad.2; Fri, 27 Dec 2024 03:52:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1735300338; x=1735905138; 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=tfAmnIKpqRHJaVZJ7etBHUJeCgioZCtC9Hj99Qd9EOQ=; b=VUMqhjTVenFGPz+1Mri1riPctbC+mQoAN3OADyDGte70mv7jPVivV7p02R712ZEmYP IVO1e544/snaELj49MBpCLnuD+7+uOgj6fXI2bpyzHHBZQfUz6cO0kLua46nGRfBqj1u WSHON2o0yRunDgGRQuLP6B9Qr19tGbw+A1wUBTPhmlNQV6MvGuxp4Y769Z27IJcCm64S 2sF4mst+u0dy/mUKhSGoaKmSAvQY4reCk41JowqjFFqlpwxsBffb0aj8Eo1we18vbliJ +0SuXzUMAMxddiEirLH9/H4M6cRTAS7WTEEUUUQO2v6HRW+y2PwfR3Y9AXBRpnNr5aWN vFtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735300338; x=1735905138; 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=tfAmnIKpqRHJaVZJ7etBHUJeCgioZCtC9Hj99Qd9EOQ=; b=X2wUadA27+V01ANHLZPiN8q5p6UxZnP5CRORQcUUHizygR+BVZ5NVQZidXFPWY56Jo 0FuyUIkst7Z/m4BmStsOlOEtF2DHgdnMltUEnrchios/3S6UbGEMjiz2uxPdP1XGTpO3 t5ZK1M+5QGPyANCh0BiSQb4JKvjqFakhK3fFF7flpUEviulOCGfnCKzW8X+W6RUsJAQH 9ZjZtmPTGe00cvKqDqAjSpsGokLwsEf6J0u+9BSg258jURbMb/hUX0ta8PsmvOSfq7qp lGMZi8DtQD1hYlUGnVIV2G/+bs1hUgiIENpPlxdp6962MbbUJu3QJ0NNwmtHOBWyi6ys kxSQ== X-Forwarded-Encrypted: i=1; AJvYcCV0P10oU1nSKmohlAwvGyWN/YYOFoB0HCG9gh1JvMMb3ziKkti/0aWo+ogTw12DfwjsYeZDbuuElBEGWcwb@vger.kernel.org, AJvYcCWHGSlWxBLNwPL6xceCSTGcRGAMflp4jNvbmH0/2bKzh2vixlJP1arrBMZzHjvnj1d4rOLtdkkBGBQ=@vger.kernel.org X-Gm-Message-State: AOJu0Yyn2Fn0MkVa52+RPUQj4XUtUVbJ61kl/76X26iI92yTjuhx9V2x DqtJYh17RqnUKTX54Yj7/soHMCr++0X1V6KIHATuHQATVCYTlelQ X-Gm-Gg: ASbGnctMN2nIoRkS6PyZfmo8akfNBDdQOPSSsNeaM5zSlJBiYF3BNmEDKAlGflC05yN l+2ywbAG5jEe0py3AAFpH66AJCNJoUP1rTRM5nmNkienjgfjY6a9UJyqFIPI72g+1lxxabxUfv8 vLiVKjU3r39CIFIJ44hBZmvOYW0xRpVeNSyIzl/wBVXcILI82AzkE6/s80Xe6OQxeNsyypcbKyc lHk+m15Q93xVTNpQKYmVkXnVMH0/4mGKdWlSKmaE1mV+YC0BBFwCXIIX1SeUUGhAcgoglm9xUY+ mw6oZek= X-Google-Smtp-Source: AGHT+IGqzvw5ipqPXXi1vkrtY3GowQtnwgigMSDq5w2y1Vm5ZYnqM+rp2/eJ2CoTPhLElPzEM3xmng== X-Received: by 2002:a05:6a21:78a8:b0:1e1:f281:8cfd with SMTP id adf61e73a8af0-1e5e04643a3mr42481329637.15.1735300338068; Fri, 27 Dec 2024 03:52:18 -0800 (PST) Received: from prasmi.. ([2401:4900:1c07:9010:ac08:3a91:844a:cc65]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8dbcbbsm14363990b3a.97.2024.12.27.03.52.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Dec 2024 03:52:17 -0800 (PST) From: Prabhakar X-Google-Original-From: Prabhakar To: Chris Brandt , Andi Shyti , Geert Uytterhoeven , Wolfram Sang , 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 v3 4/8] i2c: riic: Use GENMASK() macro for bitmask definitions Date: Fri, 27 Dec 2024 11:51:50 +0000 Message-ID: <20241227115154.56154-5-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241227115154.56154-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20241227115154.56154-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 --- 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 954e066d61a8..ddae4b74a86b 100644 --- a/drivers/i2c/busses/i2c-riic.c +++ b/drivers/i2c/busses/i2c-riic.c @@ -55,7 +55,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) @@ -73,7 +73,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 Dec 27 11:51:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prabhakar X-Patchwork-Id: 13921769 X-Patchwork-Delegate: geert@linux-m68k.org Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) (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 08E021F3D26; Fri, 27 Dec 2024 11:52:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735300344; cv=none; b=XXWB5Fu/CNwBj1k7iSrDOqayMweo04gjrGt+NGQKlKGMI8DpfgIIX8iM4qVOENH6SDRbPJFehOjlu57HdYhAxh/Zcb7EgJv6QesnxtYJjtxokx1e+tYum/RL8scHYqLs2rM1iEYwWyImY6atfXFR9WflotPvldgK2neDWo0OFdg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735300344; c=relaxed/simple; bh=pWYrPctcHjB+u0MD5MK8kQG+ASNgsWEjBAQzgKyQI9s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rI7RalXCUGUlht8p+FfgQwEb5LFl+VsDydCLpWcDGvc9trEmnmHf4qnzbed2gNehQpWhY5G2D75V9gYtvhuZ4Tw4nyN9Mnwri3vPjD5pKImOHdvmjwnynJDIQvv5tLKEQGH65wAfrLy7+XSquQOMib6K/R8m+XM+sJh8TrD6YKY= 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=E9ge8OQK; arc=none smtp.client-ip=209.85.214.178 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="E9ge8OQK" Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-2162c0f6a39so95378365ad.0; Fri, 27 Dec 2024 03:52:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1735300342; x=1735905142; 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=N8oY5oTbQVZDPH/A0GVWyEqZ6b/K+sdv50js6rIf5Sk=; b=E9ge8OQKJMoDnLT26Ht2nlncKtgAIrSO0o+wQuhWcTcKzJClc8ozqygpVkCSF0+G6w TuRLtHOLhYmjMm3W6cQ/SrsmhDlNmcOa0gvO55wdMcRSvxKEvDlJylEPEI0x8Oh46naE /icivn3ALWS4d5QEpIld50YijN+uiP4TTAsUB5WCeBwXLLWiJk9SL7/wrFsQ7VC/yTd+ oJE/lhikjFpVKRvx8WxnZoOnCSlCrH22JUb7sp5lMXtAWsXrwpeK8tOxWWUDB+6bv0tZ bsKBV1WG6y4f1gMZSWJ8DI1VTcKthM4pyyuPwctNXn1wbpxDbi70rxiGHp+p7R4j8hds 9plw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735300342; x=1735905142; 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=N8oY5oTbQVZDPH/A0GVWyEqZ6b/K+sdv50js6rIf5Sk=; b=hq5f6D8CrS7WG2JBdTRRc7QaVbJg+x4umW5KZAqGwHWGWVn3advHHUCotxrwYq7+RE x0ed82E7v0+NguARL4/Qc7FiZQQjKiWdblbG/6f7cxJP6k4cGlJDtDxu0S9rendt+pEt fNi/rbczkMFpr3sv+O/oNIAgAAb3A0Ub2gmL9oo9kctaMQPYvLDS2Ed3FXBFOC0p0soT oy0MTv+qqGhSus1jzR6rwvIBxVlm/6xTmvcCTdR67zqTkAbpzbXn8vPBYwUHqsQpt3t+ cKGt/aJOj48btkH3hE/svkRplmD/wfKr3qGptIEmfJFaFWcIijBtvxAFecCLwYureCQc ke8w== X-Forwarded-Encrypted: i=1; AJvYcCU7AdMg421wqbiQnIDtB6qv7/m9WSnEIySEw5b444UX7aY/gb7q6XT+d1HbxJRfrszk21OGnW5uFMo=@vger.kernel.org, AJvYcCVp9hUCWx24S5x0nPNrhruuDZxYJpvF5YZYU5Pn7tZVD/919Acy14w8bB9T99my/rpOqD6DowN0u+duw9fT@vger.kernel.org X-Gm-Message-State: AOJu0YyNQw3s9FKPM4EkvQTAc8cozczZZoQk7kP+VkjXDDtbnxnN6ALV i1ZYTOUwuCkMx+1exmmvez/hxSShDurOInKkcD1D9uRwADXphXiH X-Gm-Gg: ASbGncv0W6H8XM+11Fk/TIPEMe0bWWjWt5Sj03KnwE7opGWp3xVGlQ0cT7YT7DxlOwj g6rN3XLBVJj2iau3lTkNgX3QKhgPsr8Z6pav8CMR8z5HLq56VzVP7RHjaEorNkkLlbwWdcn6nb7 Yreu/lMIgDDhS/jYQQrz7yVE8rSjoV1yXbdEPDC8MASisIjHwxRSj9iPJrg+6YZfaGjJ9PHPnxf xcCwFpoorBkidXS9W/4w5/4FxHEUQ2bgdu8BA55i9czyLts1DVqkU5wZr/LyVwo9BmINxRdzPh1 SPJAUkU= X-Google-Smtp-Source: AGHT+IHhOrlXifDprZrXy/XB3FzmU5oowjgUWr7eScjm2AeiT3HSQ6NsqfJduujIZteUgCktiysOuw== X-Received: by 2002:a05:6a21:3291:b0:1e1:a434:296f with SMTP id adf61e73a8af0-1e5c6ef034bmr43880502637.10.1735300342244; Fri, 27 Dec 2024 03:52:22 -0800 (PST) Received: from prasmi.. ([2401:4900:1c07:9010:ac08:3a91:844a:cc65]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8dbcbbsm14363990b3a.97.2024.12.27.03.52.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Dec 2024 03:52:21 -0800 (PST) From: Prabhakar X-Google-Original-From: Prabhakar To: Chris Brandt , Andi Shyti , Geert Uytterhoeven , Wolfram Sang , 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 v3 5/8] i2c: riic: Make use of devres helper to request deasserted reset line Date: Fri, 27 Dec 2024 11:51:51 +0000 Message-ID: <20241227115154.56154-6-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241227115154.56154-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20241227115154.56154-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 --- 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 ddae4b74a86b..edf2212e96ea 100644 --- a/drivers/i2c/busses/i2c-riic.c +++ b/drivers/i2c/busses/i2c-riic.c @@ -422,11 +422,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; @@ -447,18 +442,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++) { ret = platform_get_irq(pdev, riic_irqs[i].res_num); From patchwork Fri Dec 27 11:51:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prabhakar X-Patchwork-Id: 13921770 X-Patchwork-Delegate: geert@linux-m68k.org Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) (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 010721F3D27; Fri, 27 Dec 2024 11:52:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735300348; cv=none; b=QkCiiqXgVcsLdDLbgE8r5/Ulrpz/FT93a9SLzxrnzes0RtYvLXRouVs6vY9syfAdTI/F6s1RzPbudOQ1i89/w6rplr6TgFNSCvpz/UH+q6+LKmsbnn/3unUxwa20uUR1OK68/oBHLfcA62N/h0IAmxjv1ookENlOdihsdI5Uii4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735300348; c=relaxed/simple; bh=D/DsT1pJOp2v92eWJ6q2fpcaxKGx/oBC/neVfd9Jws4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sGIR0uvIrACitsLahYyrm+xO8mXsVVRs8TTXkPWPUDuMA66zv4YNs2Uug2GQF6Xnyzsrv2JevFjHFSqur8gapiPRsbM0tvhX7j7LjVjS7mT90R+P6QBf2RUfV311KT4jYHY+Qbyu4MCIT9+BVQ9AzyCQ2DXw00+XP7BeZ+wacQg= 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=ZjVNsgTk; arc=none smtp.client-ip=209.85.214.174 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="ZjVNsgTk" Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-2161eb95317so89874805ad.1; Fri, 27 Dec 2024 03:52:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1735300346; x=1735905146; 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=8MX7zL6e/eANjDZsXHEbEpyJVdlNQUXGXrD7nBKxrgM=; b=ZjVNsgTkmcGTzEnCYj5B8+yQjftcpoAsYs7FPOPPY74ilbcfdHCYfC0/dom6kZ7p9k bOVdKcITA2TrjTAB9LJrXa4Ny32pCx9O0Pj/nbt0iHJR6buApdErbLyGUA9zJsmcG07b hCkS2Yd1ManjUm9mtBXVcBkffec1iibD3co/426L9PBFrma4Aqd9v9OFJN8tayc4pLlP 3t3YqGpsMaial6l+JYNq49KXGcybby+TGjBg2Gcu5ju3mUA1otR3PZAuBKIorNn8vl4I elc6KFAYpMbx8i8GLZ+tp4jwzwvmCa/KclEZiPs+zX0zWT+oE0Sycdl2RpogxrDhUryp YKQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735300346; x=1735905146; 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=8MX7zL6e/eANjDZsXHEbEpyJVdlNQUXGXrD7nBKxrgM=; b=vxGHtYRiVP3V45D14X0Gqbh2I8nPbGRUc7Fumus9GAangF1lEJwx7kUgHDQ/rU/2Gr VrhELPZddnd4pTs1f0wiSGL2TRiONT+I5sACl2PtPApMtYorkGMWIE28FacPVDJCu8iF z3AFHbKK1kXSJco/86xcFtSXXup6WLNd1AWNj/Ju5p9kSAFBITRKe0sEP7czWSBblsC4 qNkdhdpxp/8S4J2mKemAYmJQF7ME282nylJtUDqPJZ0uBzACigH6Y5ZSFtDvtuTz3Pvj le7YCkLfzCiOD7dVl6+UOk9RxZl8r6l+GGWhuHas9oRwm+Ve0NOWHVvSgeNW+pYBbksU y1yQ== X-Forwarded-Encrypted: i=1; AJvYcCVgx4tjgyq6Oipc0fL5Yqe+h7B+E1pWVgPvfAhRZUtC1C5FUBeBfcTbt3f2nZPDBC/5ej2DEA3kXb/JMra+@vger.kernel.org, AJvYcCW1sl1z/1gIKFWKYvM3hthtpHflj0Gv7Mz7dGD+tXX/AeHSinSgBhbOw9xbcGCD0sWFS9eSOBV5YZ8=@vger.kernel.org X-Gm-Message-State: AOJu0YxwxUVzl+V89w5ziaiMf/h59ZeYFTcE6h83UPqIzTbDWXQECva9 69BhdW1Wcc1oWxp/S/IKgX4P2w7jPy7tXqmtnEWASvJ4GUQ/Pkdu X-Gm-Gg: ASbGncu2Mu4HlNlTVKntU6eZJcWLMWUec21h+4JMzZdiOQkorlXo1/gGhETjik51x9b jr6quU+HMHWcfyrmID8fCjDtFDEMm5LmlEDX/EH/JJedP+B2S929gXWcb6of+wc+ORqX8LmPyyp IUNW29ZfVa9rQijlcm5CE+UYfB4S6STasrr0A1y2tnqztEHO1LGlA/a3nd/6Xfy8IrVrINy4W8l pk88dIRw1g7u4zOfKR1iljV6w70x6nwgZHPSfYGNA1ApRFohq/a8BAWsWEt0BlEhphdAPkWHN/+ 8ReNVZ4= X-Google-Smtp-Source: AGHT+IHVYuJMQbzX2/MmsJlcNCQV6d6xSNOiE++9sMeb34z/sZ8avS7a8K8n+uzFcSL564OuhFGLeA== X-Received: by 2002:a05:6a21:1505:b0:1e0:9cc2:84b1 with SMTP id adf61e73a8af0-1e5e0800447mr44647770637.30.1735300346360; Fri, 27 Dec 2024 03:52:26 -0800 (PST) Received: from prasmi.. ([2401:4900:1c07:9010:ac08:3a91:844a:cc65]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8dbcbbsm14363990b3a.97.2024.12.27.03.52.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Dec 2024 03:52:25 -0800 (PST) From: Prabhakar X-Google-Original-From: Prabhakar To: Chris Brandt , Andi Shyti , Geert Uytterhoeven , Wolfram Sang , 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 v3 6/8] i2c: riic: Mark riic_irqs array as const Date: Fri, 27 Dec 2024 11:51:52 +0000 Message-ID: <20241227115154.56154-7-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241227115154.56154-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20241227115154.56154-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 --- 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 edf2212e96ea..378887b133a5 100644 --- a/drivers/i2c/busses/i2c-riic.c +++ b/drivers/i2c/busses/i2c-riic.c @@ -414,7 +414,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 Dec 27 11:51:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prabhakar X-Patchwork-Id: 13921771 X-Patchwork-Delegate: geert@linux-m68k.org Received: from mail-pj1-f43.google.com (mail-pj1-f43.google.com [209.85.216.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 571461F4263; Fri, 27 Dec 2024 11:52:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735300353; cv=none; b=TMxRXel90vFF9tQ9DpEC+Xsc/4QkWoMo19MMrm6VRTZzyfDjwq9B8sey7jhwf5VC/BRQYLfcVynUvTmUB5ga0RtxyZcA6pIz6nPmXH0BdQZFc0371CW0+XiTItzk2Tasp5oZ6Olra8YqVMc9vaCwGsSJDzxNvvQSu0dxFiVNbaY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735300353; c=relaxed/simple; bh=64StuxBrvBnQvmF+a4yvTMMg+o+iA0UY3EvIwVFalTo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VSxkNuTsgeg7kCobqT1hFe2MA3McsdaciiVR+fczhezSg7+90JNXquVe09K36CIJxaXkexZyZJ3+HwMoD8AFgYrZW9ztN667iKNR7pa6wdOatLjQZ6Y2bU0rRYT3DAb/bxlbQK5O/NGe7hJ4BGPI/Mv61+NAwXCSIfz1v/U/AgY= 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=Lar2jGjq; arc=none smtp.client-ip=209.85.216.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="Lar2jGjq" Received: by mail-pj1-f43.google.com with SMTP id 98e67ed59e1d1-2f441904a42so9105247a91.1; Fri, 27 Dec 2024 03:52:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1735300350; x=1735905150; 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=F68oBqhMh44dH9Aw6MBNH7MGeSmZg+ZawOT9qNwzoiM=; b=Lar2jGjqlI+KcECaHSxzm2JuJaWrneC590c4LpMEQGpZBsELjROqdRUxkw7Y6hR6Wn 8G78kxFP9S2nYsiJ5bXF9j0Q/SkNS3d7z05Kd7+BQvnUqjwkXc9K91KXDyAFQ5zaXbxS 6lMYDij+WxFoXbs+XfvGKb+Rwd+VMHu0jEp23yCxEqVgkfomwBUgB/wsngG+eK9s7wHg RZbiVVD6GBDLayefrFfmEsiSy2NamIsvAHtBIf7Mg2mGKVb/UB9um5pWgkxtlHCwGtMt t+vkVVMNasvALP2w4E5lLZHkTa8B1xDkUBAdjkW1Cm7GiXRCmszytq0gC8YtCc6C66SI ttFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735300350; x=1735905150; 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=F68oBqhMh44dH9Aw6MBNH7MGeSmZg+ZawOT9qNwzoiM=; b=qr+TEPHlhiOzsYB9NOTgfRF6lTJ8xRcX+l72GSacjg4tc4sZUgdU9AEnOhhCk231yK PSCuiWpe5pqFRtZQnwncCfY79BggWm4LDaQPHJlljQz0102wak8C24goKE2QBwDig01v +O6o2rD3u1ejnIy5euqGUvz2zt1J7mSuqjBz01LkeFA+xwpKHi0S83BSDa4T8X7kiOg8 5zWWORSOQ1TVL0SbCscW5s2LsGYl+FYCBYIcRzX1o9GL6MY8PR/Kno97sWjG/Hp5yYwo Lrpzc4VASR+p2gCEaQ72qb2udyc8bbjSwMrnBxunuMHQNOmADlhVfypDgIJS7qsWMvCT vM1g== X-Forwarded-Encrypted: i=1; AJvYcCVWPOAoXcmXnzmcPZHmzF68A8Ko3cSyfqVn8pR8RtZN+gBwGqYkJjceqWjY2QBQhPg1uhipi8JTXS4=@vger.kernel.org, AJvYcCXMbEuLbI4EOIJkn9t33RcaSnVHx35oBxIm4cjqd8jgrnGFD1zwtdWusznu0TXpyc/um3dh9SV+iw7VZ54W@vger.kernel.org X-Gm-Message-State: AOJu0YwZN3FDHP9feYCfxSiv0je3C0IUUpgHE7CTNhXCz/xsd/XoxoKu 6oSnBa50g/CF4RYoeoQM8XsG0OrbdSbN2GlAjoAKjeNSpaM9Rkx+ X-Gm-Gg: ASbGncvZSlEwfueLJROvMWc1oINx5yXxmCiSLni8Cme31Kr4uFm981PJDdjIdS0G1no OO1ZIQ33sKfs0q62dB339devB/+svnRfUhAr9/tsgVCceheVKrt8W8ikUQnGwKo26tynQsS/tkP NzuIvty1JttgGN8LQAsrFw56gGdMTmPEAyBaqzTNwN1WwCrumw3Hoch0PpJpCgm6+kkNb59RaPV hwT+5PWvFGGtJjvRcXixNNXmiOr0jH5KYuaamNfjQrLcRbC5ekJDMKyOkqLKid2kt7mRNKBngsK M63+HfQ= X-Google-Smtp-Source: AGHT+IE+GHwcp2U0mfwQBqgIzk2BUQI+hEo1INr+GTD4RMqz/gzyNVwPGRV/amtwD6RtAHtD1sBkbA== X-Received: by 2002:a05:6a00:2181:b0:72a:a7a4:b641 with SMTP id d2e1a72fcca58-72abdebb873mr31587017b3a.18.1735300350475; Fri, 27 Dec 2024 03:52:30 -0800 (PST) Received: from prasmi.. ([2401:4900:1c07:9010:ac08:3a91:844a:cc65]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8dbcbbsm14363990b3a.97.2024.12.27.03.52.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Dec 2024 03:52:30 -0800 (PST) From: Prabhakar X-Google-Original-From: Prabhakar To: Chris Brandt , Andi Shyti , Geert Uytterhoeven , Wolfram Sang , 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 v3 7/8] i2c: riic: Use predefined macro and simplify clock tick calculation Date: Fri, 27 Dec 2024 11:51:53 +0000 Message-ID: <20241227115154.56154-8-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241227115154.56154-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20241227115154.56154-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 `NANO` macro for clarity. Simplify the code by introducing a `ns_per_tick` variable to store `NANO / rate`, reducing redundancy and improving readability. 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 --- 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 378887b133a5..a2d0cde5ac54 100644 --- a/drivers/i2c/busses/i2c-riic.c +++ b/drivers/i2c/busses/i2c-riic.c @@ -45,6 +45,7 @@ #include #include #include +#include #define ICCR1_ICE BIT(7) #define ICCR1_IICRST BIT(6) @@ -312,6 +313,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; @@ -375,8 +377,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 = NANO / 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) @@ -386,8 +389,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 Dec 27 11:51:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prabhakar X-Patchwork-Id: 13921772 X-Patchwork-Delegate: geert@linux-m68k.org Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) (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 B406B1F4279; Fri, 27 Dec 2024 11:52:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735300357; cv=none; b=Uthgi2A9vWWl+2w8VjmsurfJt3FKgaUVnfl6qsrXHvUOoi3F0dv+KMkVlGsOqoMKTYDTGx2IdI66AD/kBYoHm5ZAtnwFRC2oKzplyT003XXCPnF1ye+UZy+lOLnN+Qan88CvfurHkgPJ1iaodLUJqxPK0z9J9nhk0b1u74SmJrI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735300357; c=relaxed/simple; bh=og/4mZT4bNYEAKSmR/ylW3YHosMHCE9n6VPZsM7lb2w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=vE6BT3d10xNrOG1yUC2YKazFOsfF9Qzfi9g2AYR9/QT9Bp1AE30D+YfuR5/OzuttZvV3yQ3TcMIGh2wNqSCTebC83OrLcoKu36+j7f8bJpvUismaE1Wa4Z6I1b9RFEZQPi3KJKPk45JulI3ly6BH1WFE1n2y8A4r91Lcpj53jhc= 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=hIxsAGcZ; arc=none smtp.client-ip=209.85.214.180 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="hIxsAGcZ" Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-2162c0f6a39so95380435ad.0; Fri, 27 Dec 2024 03:52:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1735300355; x=1735905155; 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=SxrnLWAApnmijlLFIQl/ov451ANyf6P2dk6YwXU3Ne0=; b=hIxsAGcZprTJ9n0qGJ7I0qoR+Kxgx3yZG0YL+1EfLTlwFcR2jCXAZhnf0IbRCKcGYz i7N/PDYTdh4XqRB0DoIpQZf5V0arOZCYnDrZe1cqI9rXvmS0MREJVcifAmAzQDtPA31t +L3QLhenIEGWIxJHyj657feZv25PieYZYMq/kqKjrvPl/rITgRBvfKdqDrvvd6QdCBks mPdOBWvffWikXN/aWFbx1Dd2sWL+r6ZPLIvHny4qt+eGovzQ4kxll2Et4etBwq6jcido JrDh5vWzv/DpWJDcPS/3bdgZOJyOp6Tf3DP1OwwP3HCqN79EjurzNyaxjWevyhhizcCi Otsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735300355; x=1735905155; 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=SxrnLWAApnmijlLFIQl/ov451ANyf6P2dk6YwXU3Ne0=; b=Q4ZGl7b4OWu3/4n0nfHvuhLY08rCv1299Y0anGZbdpnbZkJDZ+ULkVVtp5+n1jeKwr L9oeveUdQRMwwxwySE0LaSqsXSdRUZiqUFd7QD0MBur9TVLpJOrswFdUz+pmEmJ/V/cD 0FaBVGg+PWhkIJdFfv025FXf/YeHqUn+1KlybG0lvbzEk2hZCKVn/bFgcqSy1gXqH1FQ RIdrFwes0jhOI1u/8NK7nDM9yNQA1vM2bipjips9zfS3gw1skc1aLIxGSInymOQGQSJ8 7VJ21220Bdzcic+VpQgYba8oymOj3yQ58Ic4H3mBrfBZUbxGBjpjsK23GHeSIK0RX65A 6Gsw== X-Forwarded-Encrypted: i=1; AJvYcCWmpjDmripYji9X/65K9fSs9on3sg2RxURu9803il9C0nR29xHNnsENC8Vmro7RUGcYvp1ztaP+XIIqDGiW@vger.kernel.org, AJvYcCWuUgyfi6iw7hW8f/2/gRxRMxE5lqESe9eSNGdusWO/3Fq5oIrsrCGub1lDwllmfiiOYNl0rXIsFLQ=@vger.kernel.org X-Gm-Message-State: AOJu0YycNfOK78dUn7wS6kVWPmGMkXxJxljJwfkqAp6e4GH5Ygiqmy34 va4UmEJFeRSSapEMF88tRHQqQtmEQd1abz3LqA22u0u1HUpUr63l X-Gm-Gg: ASbGncsrZAelDGAkSvlVHUqMJfg8vlLMtibW2QyEofcmVsiAO2o/5kSAPjK3ufXUV0H iwHrphrMjLD5Xy3xRkoKJT+IzUll6E8qDpBheNlPq99UC0hqUvFFG08rh8SQshhYeLRj0zHCG++ a19GFfQYzVG8BEDJr/ZS0I36WhMpRu5WzxPYBO5x5zlOi+GhTb121AMEGne1ppkJ4e/AEee6tbL 2+GLUCeKjmdMX6jlvblVgosggaoI205LudHp/gKe5gqtGjmBZdPfqMakF7uJHr1RPcvYlxKkUDa ozeDOoY= X-Google-Smtp-Source: AGHT+IHtSLgnEjDMksHOF6grV+q2mjiLXJSbkTz7D07bHxrB0gSSLrsfjF9hKxiqgbgqLdyJ+6xAsA== X-Received: by 2002:a05:6a21:648c:b0:1e2:2e4:6893 with SMTP id adf61e73a8af0-1e5e1e2979bmr43579802637.9.1735300354864; Fri, 27 Dec 2024 03:52:34 -0800 (PST) Received: from prasmi.. ([2401:4900:1c07:9010:ac08:3a91:844a:cc65]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8dbcbbsm14363990b3a.97.2024.12.27.03.52.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Dec 2024 03:52:34 -0800 (PST) From: Prabhakar X-Google-Original-From: Prabhakar To: Chris Brandt , Andi Shyti , Geert Uytterhoeven , Wolfram Sang , 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 v3 8/8] i2c: riic: Add `riic_bus_barrier()` to check bus availability Date: Fri, 27 Dec 2024 11:51:54 +0000 Message-ID: <20241227115154.56154-9-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241227115154.56154-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20241227115154.56154-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 --- 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 a2d0cde5ac54..cf20e75da044 100644 --- a/drivers/i2c/busses/i2c-riic.c +++ b/drivers/i2c/busses/i2c-riic.c @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -50,6 +51,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) @@ -135,6 +138,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 -EBUSY; + + 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); @@ -147,13 +171,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);