From patchwork Thu Jul 25 20:45:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 814395 Delivered-To: patch@linaro.org Received: by 2002:adf:e641:0:b0:367:895a:4699 with SMTP id b1csp567038wrn; Thu, 25 Jul 2024 13:48:38 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWYna/G+7ziYV4rKmLIpyZbef3bIQThZl6vvCNelK79B/u0burVYuNDS3+QW6WLDMA2rGD+F++tykGS7B2D14zV X-Google-Smtp-Source: AGHT+IE6XQjRBOYXJfkGSrVg285ECPhYNhqL+Ovw2ENvAbBVvL8Eek1ZHGrd8Bpsi2hmIlxZPwTO X-Received: by 2002:a05:651c:541:b0:2ef:a504:65b8 with SMTP id 38308e7fff4ca-2f039cb7d36mr34084651fa.13.1721940518206; Thu, 25 Jul 2024 13:48:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721940518; cv=none; d=google.com; s=arc-20160816; b=s7ZCrA58JZuYcv9HMsIGzhRGNWL7cHcIp9VkedjYxsLkbHgwbAsb9pBHcQrPHaBg2f t4DV3zdzuavHp5SCi7rrQv3jlUjbtVPYVsH3jcDHxcXg1Ajey+2z0bMhy2p8WrPguxsf bHFcEgD3dPGsN2+iH6MSPC7c0MMLQRKef5wwqq3jtf9u7uUit6feiB7scjxPXRcfcMCu YejD3Q7H/s8SkKcDnR8lm7BosKLyZg/5oJNmLvcyN7cDoWClJSRdDFodNE78GLEnAu2r nTxAgzOX/ITd5rMrCnS+p+SMBJq0AliBnVsks45YrKKjE86j7emOKeOp88hBLX0GyQh9 6+dw== 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=UKZxndUm2Msgg2mExU+W8UaV4CoWdCztEVfBzyKLJLg=; fh=W7sjkx7URgFqavx9S9P+TNW0/5i8VmrK1b0nrENkxNY=; b=IlpxU9STuTzpLiEphB6E0q5mZwX5fID/BJYgv9ab9gKa0/w0+oaAGN2F3W2upoFSso tjAY8IjWWm13jvv644QaIa2iUdIa+eb/4pUwYmx9cnIHaIJuIGv7/c8x6KSfdNF4PySh S7at6e2BsISIiUupRMwR9arK1/2lVBbBtHD4jLNJpePT+aiiaTs5v+8moS0uYzbhIA1V Ymm+33NEPh+NFIS8H4GHyYwWxRIYZ6imrYL6wUBZvEcN5529EGAYVu60csaR0oymP+hD tauGBOzcufVekOFnZdGol0JIRMOhEwkT+RmrP0v2rwGRgcpd8hRbwJVrPf6MmirhPD/e dPcQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Z4l6rPUG; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 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. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id 38308e7fff4ca-2f03d169bf3si6031441fa.468.2024.07.25.13.48.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jul 2024 13:48:38 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Z4l6rPUG; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 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 10C64886DD; Thu, 25 Jul 2024 22:45:45 +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="Z4l6rPUG"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A11C488636; Thu, 25 Jul 2024 22:45:38 +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-ot1-x32c.google.com (mail-ot1-x32c.google.com [IPv6:2607:f8b0:4864:20::32c]) (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 50628884CC for ; Thu, 25 Jul 2024 22:45:36 +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-ot1-x32c.google.com with SMTP id 46e09a7af769-704494efa7cso175192a34.3 for ; Thu, 25 Jul 2024 13:45:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721940334; x=1722545134; 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=UKZxndUm2Msgg2mExU+W8UaV4CoWdCztEVfBzyKLJLg=; b=Z4l6rPUGSpw7T6VbXNuFIpWKpQq+8gqymKCZGtoN2tFBLHVcJj2+mjmkHEcQNvGALA +deWUbhlgjB75sxGsYjbtkI/2NWcltCZvpttnagDmIjBFS8C2bXFrbxqczJhc/8Wo0GW 6tLRYJlYuwlrJt/xTKpbJ1m0OMZ6UzkIgkDnqYPzVHsk2x1AHQKXPs1QouMsfMAL9EL3 k86OPidBNYBoPFC6vz3popO4zQW+1Z4b4fLz7JD0hBtgxo644+at/W9D/HwX2capKqxU MSEtPhFUzramYvxAKRoTPd97tco8pBlxuPCcJuySK6FFwkRh7dRhuuTBCbmf14U9JHgy FI3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721940334; x=1722545134; 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=UKZxndUm2Msgg2mExU+W8UaV4CoWdCztEVfBzyKLJLg=; b=uQAyQ7f7e2Pvso6o5NzGHlehQ0untJkFqI5et3Exx76/ueFPxBPcwqyoRe2q6PvHyD OtlYRgkuq/+XpH/DNENAj58vA/YqCdsjMywvcrxk106iFhw+jmaZ8d/SHXtlny+8hiVU jHOLfLXZ5HURAr4FeVaWDv3M29QM6/ciOPRNMiMi4Jerjs7xDsXWrXndRh22qXhfWSdr OO9AyBUfyZ1jdpnkX99JiEzWxj4gLlgTv5ekOcAexYOM2yhOX8uYYHdJuUHVq+g3ggVe RFQyBWxyAXrJMIxHTez5CLQzXgB345bk3KEoTScYUjCn8a5nW/I/jip5W0PAyN70HmgX FSew== X-Forwarded-Encrypted: i=1; AJvYcCUgLO1pw1Xrw9pBN6I6E1WztrIWmlcBSngJnXBq28YfyCO5QYG4t8PL8kXr3nlBRxAn9AV51zsp+sA/Xwr9wySKsjB0EA== X-Gm-Message-State: AOJu0Yz5nFNmVPJno9N1mfk2r2CxUMSumuqU6/xL9ZLpN1CFHMRHM+8s FJpIUn+7NqG+sVrwZwcQkS70IH9MpnYRDwi4unq140L8cu7kqpeL8hmtPiXOYQM= X-Received: by 2002:a05:6830:63ca:b0:703:63d3:9ef7 with SMTP id 46e09a7af769-7093223cc11mr4167637a34.14.1721940334705; Thu, 25 Jul 2024 13:45:34 -0700 (PDT) Received: from localhost ([136.62.192.75]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-70930720f62sm453467a34.37.2024.07.25.13.45.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jul 2024 13:45:34 -0700 (PDT) From: Sam Protsenko To: Jaehoon Chung Cc: Minkyu Kang , Minkyu Kang , Tom Rini , 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 v4 18/38] mmc: exynos_dw_mmc: Fix getting private data in exynos_dwmci_board_init() Date: Thu, 25 Jul 2024 15:45:00 -0500 Message-Id: <20240725204520.18134-19-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240725204520.18134-1-semen.protsenko@linaro.org> References: <20240725204520.18134-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 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);