From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 95999343D85 for ; Tue, 29 Sep 2026 12:46:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790685984; cv=none; b=RbpT0iFhWL2LN3XXTRl37GBYqycyrEQgUNZsXRQnU8fCJPyqCpj415CiWBf+rGEGWeqMvjurn3/VH0zxt1z2dBeRRGxSsk/HGW8z7gKg9RvDe6OCLJE8mPmX4Ql3uulxBmENnCinmR/bNr4ThLsnX2vgjGpDbdU1uFpZcsKPm+0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790685984; c=relaxed/simple; bh=ldeYLu1zMUo9I2kobtt6raH0wdw4aNCBFlwgh/qZxHY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=W7kB/x8dbR6I3H6YEvoKMVr20+0o7B1bDQcnNLn3qcbS29cxCau4qtzYFxRg5qBbqigMfwtU+13pXU3iIk+tUybA0Sy6LoilhsvuwJ5r7Y4vrOxZcxrJxmt8gjPVEra1XUIvBAdCZ+IzdQHnb+kdUsAIHlDApFmoCPjnkLg3ZEA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XYzgG0gl; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="XYzgG0gl" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B4F981F00893; Tue, 29 Sep 2026 12:46:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1790685981; bh=teFa8JCVc66jtjszceSpXS3r7ylj/QuK0ApQ9yqc5xc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=XYzgG0glys+qKuZ59RjQvBPb5aw3yNfcSjD3OCA8DuDZFKSSTQWtzwYW+8vKqen/s xBaySIlrnFuCHYvUSc+pwSFAo0fuYCcM0Y4NHxv6vREt40rO9odDc0AfWc0aizVCRd 33OKcwXDB92XogHrC5Q5P6VQV13oDgtZGrUSplNcABPODfCEYsv+V2pHLcgCpVOuIV 3KdYx5+HDzlGKXBV8YMW9R6gIQWGLHtRZRQerQgCDq088leANFaJVL0tVwAlV4FDSD dUEsQwOXr2zePJCNKWMwXLcmolkxfYA4C+Rmr8XH/IZUP4eITCVXnGCcD6m2CEUcHW MqmFc02Y+CynA== From: Sasha Levin To: stable@vger.kernel.org Cc: Praveen Talari , Viken Dadhaniya , Konrad Dybcio , Mattijs Korpershoek , Andi Shyti , Sasha Levin Subject: [PATCH 7.2.y 3/4] i2c: qcom-geni: Store of_device_id data in driver private struct Date: Tue, 29 Sep 2026 08:46:16 -0400 Message-ID: <20260929124617.3453155-3-sashal@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260929124617.3453155-1-sashal@kernel.org> References: <2026092906-elude-repurpose-c794@gregkh> <20260929124617.3453155-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Praveen Talari [ Upstream commit 692e0c84db5fdd88c242eadc873d498787c94e3e ] To avoid repeatedly fetching and checking platform data across various functions, store the struct of_device_id data directly in the i2c private structure. This change enhances code maintainability and reduces redundancy. Signed-off-by: Praveen Talari Acked-by: Viken Dadhaniya Reviewed-by: Konrad Dybcio Tested-by: Mattijs Korpershoek Signed-off-by: Andi Shyti Link: https://lore.kernel.org/r/20260617-enable-i2c-on-sa8255p-v7-5-ad736dbeab57@oss.qualcomm.com Stable-dep-of: cb97bf3d4f91 ("i2c: qcom-geni: Fix hardcoded clock index in SE_GENI_CLK_SEL") Signed-off-by: Sasha Levin --- drivers/i2c/busses/i2c-qcom-geni.c | 46 ++++++++++++++++-------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/drivers/i2c/busses/i2c-qcom-geni.c b/drivers/i2c/busses/i2c-qcom-geni.c index a02977a644edf..abb993e793c37 100644 --- a/drivers/i2c/busses/i2c-qcom-geni.c +++ b/drivers/i2c/busses/i2c-qcom-geni.c @@ -77,6 +77,11 @@ enum geni_i2c_err_code { #define XFER_TIMEOUT HZ #define RST_TIMEOUT HZ +struct geni_i2c_desc { + bool no_dma_support; + unsigned int tx_fifo_depth; +}; + #define QCOM_I2C_MIN_NUM_OF_MSGS_MULTI_DESC 2 /** @@ -120,11 +125,7 @@ struct geni_i2c_dev { bool is_tx_multi_desc_xfer; u32 num_msgs; struct geni_i2c_gpi_multi_desc_xfer i2c_multi_desc_config; -}; - -struct geni_i2c_desc { - bool no_dma_support; - unsigned int tx_fifo_depth; + const struct geni_i2c_desc *dev_data; }; struct geni_i2c_err_log { @@ -941,15 +942,6 @@ static const struct i2c_algorithm geni_i2c_algo = { .functionality = geni_i2c_func, }; -#ifdef CONFIG_ACPI -static const struct acpi_device_id geni_i2c_acpi_match[] = { - { "QCOM0220"}, - { "QCOM0411" }, - { } -}; -MODULE_DEVICE_TABLE(acpi, geni_i2c_acpi_match); -#endif - static void release_gpi_dma(struct geni_i2c_dev *gi2c) { if (gi2c->rx_c) @@ -989,7 +981,6 @@ static int setup_gpi_dma(struct geni_i2c_dev *gi2c) static int geni_i2c_init(struct geni_i2c_dev *gi2c) { - const struct geni_i2c_desc *desc = NULL; u32 proto, tx_depth; bool fifo_disable; int ret; @@ -1012,8 +1003,7 @@ static int geni_i2c_init(struct geni_i2c_dev *gi2c) goto err; } - desc = device_get_match_data(gi2c->se.dev); - if (desc && desc->no_dma_support) { + if (gi2c->dev_data->no_dma_support) { fifo_disable = false; gi2c->no_dma = true; } else { @@ -1033,8 +1023,8 @@ static int geni_i2c_init(struct geni_i2c_dev *gi2c) tx_depth = geni_se_get_tx_fifo_depth(&gi2c->se); /* I2C Master Hub Serial Elements doesn't have the HW_PARAM_0 register */ - if (!tx_depth && desc) - tx_depth = desc->tx_fifo_depth; + if (!tx_depth && gi2c->se.core_clk) + tx_depth = gi2c->dev_data->tx_fifo_depth; if (!tx_depth) { ret = dev_err_probe(gi2c->se.dev, -EINVAL, @@ -1077,7 +1067,6 @@ static int geni_i2c_probe(struct platform_device *pdev) struct geni_i2c_dev *gi2c; int ret; struct device *dev = &pdev->dev; - const struct geni_i2c_desc *desc = NULL; gi2c = devm_kzalloc(dev, sizeof(*gi2c), GFP_KERNEL); if (!gi2c) @@ -1089,7 +1078,9 @@ static int geni_i2c_probe(struct platform_device *pdev) if (IS_ERR(gi2c->se.base)) return PTR_ERR(gi2c->se.base); - desc = device_get_match_data(&pdev->dev); + gi2c->dev_data = device_get_match_data(&pdev->dev); + if (!gi2c->dev_data) + return -EINVAL; ret = device_property_read_u32(dev, "clock-frequency", &gi2c->clk_freq_out); @@ -1245,13 +1236,24 @@ static const struct dev_pm_ops geni_i2c_pm_ops = { NULL) }; +static const struct geni_i2c_desc geni_i2c = {}; + static const struct geni_i2c_desc i2c_master_hub = { .no_dma_support = true, .tx_fifo_depth = 16, }; +#ifdef CONFIG_ACPI +static const struct acpi_device_id geni_i2c_acpi_match[] = { + { "QCOM0220", (kernel_ulong_t)&geni_i2c}, + { "QCOM0411", (kernel_ulong_t)&geni_i2c}, + { } +}; +MODULE_DEVICE_TABLE(acpi, geni_i2c_acpi_match); +#endif + static const struct of_device_id geni_i2c_dt_match[] = { - { .compatible = "qcom,geni-i2c" }, + { .compatible = "qcom,geni-i2c", .data = &geni_i2c }, { .compatible = "qcom,geni-i2c-master-hub", .data = &i2c_master_hub }, {} }; -- 2.53.0