From patchwork Thu Aug 8 03:14:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 817682 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e11:0:b0:367:895a:4699 with SMTP id p17csp675355wrt; Wed, 7 Aug 2024 20:18:15 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCV/62YlGay5A6oaBPprVLjU/JwI1+Q3aGb0w1VqAiyAXAVSEaR9WHtOClWGPbgQQ1o/ZBJjK+aRT/qvDpxiMa5+ X-Google-Smtp-Source: AGHT+IE5mWu7F8v/o9kfTOjB94t08v1m7i0budmtmylchJ2B1+gZsUsG0E+CbpcfsjCK54Dp40v2 X-Received: by 2002:a17:907:d862:b0:a7a:b73f:7584 with SMTP id a640c23a62f3a-a8090dae9eemr32155766b.34.1723087095538; Wed, 07 Aug 2024 20:18:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1723087095; cv=none; d=google.com; s=arc-20160816; b=culoXyQw9bJtBTP7ZAyjqkvINCJ7a+U4R5w4Vp6SMlzZcnCuh6LWkeOb+tcI6QK7WM Hd1jLVAggR9imXqtUYiQj/UbfmYIZjUjikvZInPdlegexqYMqKd0Ge56aJylunhhQ0+M +DSbpDQlh98khtG+8ft8vgIx9gCvC+MqpSVNzlUA0DFZyLHdbYlznYX5/mIvr9Q3uqKV W9LkMsl4IMryr+77JiMYl2HiscqQ6Enoe0ke+CEqqvpDJ4FOWPrhjND+xEfNHtNq5KdP a0nkwQefc264JO6eM7Y5FpOWZ6kmoqTmG0X5fuUKopLZSPEm1uKIVmk5rhmZY3zGasWo PZLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Kz94lu9Gp6TTEliC2UjCP43PfkTbwokeD+M420iZUXQ=; fh=yvl+kpBaVqMWB3peqLkJjcUxXsl/SmjtEu6CcNX2EV4=; b=lW9f+q5gb5De48m+fozFtGOx5zYrtiIcil6BHLHnH5vci6hObP8bKMiuDlqgSM8xY7 0Ti3gphxpyx/0g/cmTuL7zF9yBK44yDYOEItzpTNumt+iR0k1STAL3jTEw2QhZT6K7UB 0WW0Su6LD22jl9cONvDGvorWRdlT+pbTn9MGfL2GRSxNqVPJApj6zWOTV2iAEVUYZBiE +A3qbb9Ij5Tt7VEeezDiXyWxq0UNEPBRdqWMty7b5eqi39IcCggU8C9d4k/SC5ta/HTQ WrWLValHuxg1jyVPq7zRK0c8RcjXJCTr6tBahBnKwEMiOsp2pk5fr7wgEaFKa5n8Hvua UE3w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=InPJ+CcP; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id a640c23a62f3a-a7dc9d66412si796329166b.290.2024.08.07.20.18.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Aug 2024 20:18:15 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=InPJ+CcP; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9F73A88B9E; Thu, 8 Aug 2024 05:15:11 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="InPJ+CcP"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 788E988AE5; Thu, 8 Aug 2024 05:15:04 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-oi1-x233.google.com (mail-oi1-x233.google.com [IPv6:2607:f8b0:4864:20::233]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 9280C88B03 for ; Thu, 8 Aug 2024 05:15:00 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=semen.protsenko@linaro.org Received: by mail-oi1-x233.google.com with SMTP id 5614622812f47-3db1657c0fdso417298b6e.1 for ; Wed, 07 Aug 2024 20:15:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723086898; x=1723691698; darn=lists.denx.de; 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=Kz94lu9Gp6TTEliC2UjCP43PfkTbwokeD+M420iZUXQ=; b=InPJ+CcPHRbNG/idGC8Jm8NpDaQdXuIbOzlARdtUYsyCy5BBKsWfIoBolMz/6Tg8a/ 9k9rogqgs5RxWyYVRWlRDVzpWPUuQN0ZhArhFXeLdU3bgGwUrWbxvr2a2iiYldva/CUx rOFIlRsUTdHAtbbNCI+zB54IBAQKvCjPlTnarrxVOYXMcsIDMr6/PW76/Bfc0BRhoieg voorpgyB70bxUDpgHvKO2d8Gxs+YeRfZ/jTCEPXV9wSQXdtx9c8wmbD2yDOPy+NTmmv5 D/O5uhJr8h+i6+EPDHc4JkgvaSS+1aSlqUGh3WRSoRWLSeqXIGZVI1TotzVF/mPyEf2B WabQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723086898; x=1723691698; 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=Kz94lu9Gp6TTEliC2UjCP43PfkTbwokeD+M420iZUXQ=; b=FOHgod+AXNUhl6obrztFRVqGOgPElf/huFlvEQSKp/r5ULAv3aPlp/E+P2AtB7FEqi 1c8GzZt16P/Tw+AjRKUeAUIZO0UwYD+YtGMo6zK38mk99s9MYErMLiwJdeLfUQCn0K6/ 1qA+PMKEY9UnLpFCQ6+ChQySocR7JoB1+urDqREYXFEGxwxWtSkdtPIC8IlXF3X+hjGV LaWgfPsHaGP+SpUYe2P/oKmzzkMnv+NN8MrY0jn9vzJqPNG7levxClMUjN8o1ZSe8Gon Wj1KZitOA4Wvk8vmKyFMmmS5wBnoHtMoU9LD6EMaOSOs13SSde/zUOS/xnlVly8YLw+4 h/Bg== X-Forwarded-Encrypted: i=1; AJvYcCUVEzDjiiClc1YYH2Yp9EcgowK0xeta3yLTNOhXeKlGIZqvfUoPh+QfNLH9oTezrVcXfECh7CbWzZjEnMire+fbh6M1UQ== X-Gm-Message-State: AOJu0YyAqWY1cTrkYVLpkTmsGTgKToA32hv2Z9gpkbSpBWXN43NOMQbD HdwsXnKenNI7kz+kku/Ncw1GChzXMRR9Rigw0MWaZZVNTe8jEp2mjQz5rcHN0+g= X-Received: by 2002:a05:6871:b21:b0:261:1fdc:494a with SMTP id 586e51a60fabf-2692b6a54c5mr778607fac.21.1723086898130; Wed, 07 Aug 2024 20:14:58 -0700 (PDT) Received: from localhost ([136.62.192.75]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-2689a2f2b2asm4339525fac.16.2024.08.07.20.14.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Aug 2024 20:14:57 -0700 (PDT) From: Sam Protsenko To: Minkyu Kang , Minkyu Kang , Jaehoon Chung Cc: Tom Rini , Henrik Grimler , Peng Fan , Simon Glass , Quentin Schulz , Philipp Tomsich , Kever Yang , Eugeniy Paltsev , Peter Robinson , Jonas Karlman , Yang Xiwen , Ferass El Hafidi , Sean Anderson , u-boot@lists.denx.de, uboot-snps-arc@synopsys.com Subject: [PATCH v5 18/38] mmc: exynos_dw_mmc: Fix getting private data in exynos_dwmci_board_init() Date: Wed, 7 Aug 2024 22:14:24 -0500 Message-Id: <20240808031444.9619-19-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240808031444.9619-1-semen.protsenko@linaro.org> References: <20240808031444.9619-1-semen.protsenko@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean In case of CONFIG_DM_MMC, host->priv actually holds (struct udevice *), and not (struct dwmci_exynos_priv_data *). This makes *priv pointer invalid and may lead to Synchronous Abort during its dereference later in exynos_dwmci_board_init(). Fix it by extracting exynos_dwmmc_get_priv() helper from exynos_dwmci_clksel() and using it for getting the private data in exynos_dwmci_board_init() Fixes: 3537ee879e04 ("mmc: exynos_dw_mmc: support the Driver mode for Exynos") Signed-off-by: Sam Protsenko --- Changes in v5: - (none) Changes in v4: - (none) Changes in v3: - (none) Changes in v2: - (none) drivers/mmc/exynos_dw_mmc.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/drivers/mmc/exynos_dw_mmc.c b/drivers/mmc/exynos_dw_mmc.c index a86d58663c1b..aa542c13fea8 100644 --- a/drivers/mmc/exynos_dw_mmc.c +++ b/drivers/mmc/exynos_dw_mmc.c @@ -41,18 +41,24 @@ struct dwmci_exynos_priv_data { u32 sdr_timing; }; +static struct dwmci_exynos_priv_data *exynos_dwmmc_get_priv( + struct dwmci_host *host) +{ +#ifdef CONFIG_DM_MMC + return container_of(host, struct dwmci_exynos_priv_data, host); +#else + return host->priv; +#endif +} + /* * Function used as callback function to initialise the * CLKSEL register for every mmc channel. */ static int exynos_dwmci_clksel(struct dwmci_host *host) { -#ifdef CONFIG_DM_MMC - struct dwmci_exynos_priv_data *priv = - container_of(host, struct dwmci_exynos_priv_data, host); -#else - struct dwmci_exynos_priv_data *priv = host->priv; -#endif + struct dwmci_exynos_priv_data *priv = exynos_dwmmc_get_priv(host); + dwmci_writel(host, DWMCI_CLKSEL, priv->sdr_timing); return 0; @@ -82,7 +88,7 @@ unsigned int exynos_dwmci_get_clk(struct dwmci_host *host, uint freq) static void exynos_dwmci_board_init(struct dwmci_host *host) { - struct dwmci_exynos_priv_data *priv = host->priv; + struct dwmci_exynos_priv_data *priv = exynos_dwmmc_get_priv(host); if (host->quirks & DWMCI_QUIRK_DISABLE_SMU) { dwmci_writel(host, EMMCP_MPSBEGIN0, 0);