From patchwork Mon Jul 22 17:57:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 813758 Delivered-To: patch@linaro.org Received: by 2002:adf:f288:0:b0:367:895a:4699 with SMTP id k8csp1986127wro; Mon, 22 Jul 2024 11:00:47 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUyB+3Zcy3B4wj2cBzVlAi/aoF37XpQVYnXf88ln70VPOsw6oMy2tp26DXfYkuu6fV7VM7FmTlueUgEF25WG4/v X-Google-Smtp-Source: AGHT+IEgFy2WB5Fb0p0e0YDqcHQMED7mycD46hojr0y8X4e6ybNRY79YkeqLvVIqPar2x+KsY+kk X-Received: by 2002:a50:d58c:0:b0:5a4:12ea:333f with SMTP id 4fb4d7f45d1cf-5a943ee0aa0mr368069a12.37.1721671247441; Mon, 22 Jul 2024 11:00:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721671247; cv=none; d=google.com; s=arc-20160816; b=h3B70oosMjP5RtiG860ZYf4Xhl/UHw+OVZCe4PR+RI09TNpa2jiwxRGVSjwY4DA4bb bYT7iGC+W/SnkGMEUWp6x9qPFBAUNe7Kjbx1NPNSRWamO/IfJP10rsKrF++J2cazMsPA Yomt7IXDSwrZbwQfzUxdCqL2EPgAZIFMiFecuvsbj9lDnZmu1C0RTjKtM9x9KKLsiIcN Cx0vJE4slfN2W7AGny1ptlCHR0YedKLqIa7EoJXiqVpbEO8OacPSDDpd0LANSdRePPGe GVJJeSb/Q/Tja7yNDJTGZpNWCgAEMaI8TElm8mctLSagY55e3MibR462Mvy1xc9CsGbW P6Cw== 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=H/9bLsSODM8QlNrXZwkKXMW66HF6+d8MEEjib5AaJSY=; fh=DqWyn26UF97RuegH/uoaT20y1xxqwkwphRctFzScl2Y=; b=N19IrwwDAPjX7jierVm8hZ/BPplA2wclkPKNQw0YP7QZqwKV8IreDxCjjSp/tPU/gf lOGMOTkEIheJpSBXHKbFKHQVhExkE8yTwAsGlvDHX+BxLzOIq4LD0d6LwG+gX4c8h33k crf1K+t5Pe1keB+nIE/vH9zK35VYpP9j9O3xz8rwfQOsPZ3P4gLb9K6IyTLHNu6niYxL lZienD5og5UDTT4Wv0rnmscUobhB6d2zqnpvWzoLhawh1Yi2392rkx7/Dzl8UNG/HWOO lFPbM6l4et+lCsam8HKwu864v3xdi0Jf+9sAXra6+/sxlieMA5++VQcVU9OfieQfwCrA zX1g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fjfedCg0; 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 4fb4d7f45d1cf-5a30c8c9fa3si4496950a12.579.2024.07.22.11.00.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jul 2024 11:00:47 -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=fjfedCg0; 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 97CE588214; Mon, 22 Jul 2024 19:58:02 +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="fjfedCg0"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6A98D884AC; Mon, 22 Jul 2024 19:57:58 +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-oa1-x29.google.com (mail-oa1-x29.google.com [IPv6:2001:4860:4864:20::29]) (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 4E573884DC for ; Mon, 22 Jul 2024 19:57:56 +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-oa1-x29.google.com with SMTP id 586e51a60fabf-260e5b2dfb5so2637409fac.3 for ; Mon, 22 Jul 2024 10:57:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721671075; x=1722275875; 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=H/9bLsSODM8QlNrXZwkKXMW66HF6+d8MEEjib5AaJSY=; b=fjfedCg0TReC3A018fXmy5Tu6uN91G9YJILAzPDYbD/Olnph3kp2PXy8FgEbGHHCW+ wVDU+TRNraXQqB+KsK3YX5JIMfVE7k9KEpcj5xwkgQZwo3V4TfQ2l6wLH9E2eS6bBt20 YjcZe2vejNXxFeFvMIuljqtN1cPg9Fn2mptWkpBzAj4L0pzRYbyrESy8Rc8RbQhCznOl z0easfrswg27r8W6rMoEENvh0lYfm3PBI3ofkGfUj+xn3tex958Rn6Gyq9i5XvOCVnEx NOktrm1QOVhI2xy4X9jFxBXETn1TKtR7Q8vpg9UQXJX+S6tPNgRqG8LVCFQ63vM3xb0C 36BA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721671075; x=1722275875; 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=H/9bLsSODM8QlNrXZwkKXMW66HF6+d8MEEjib5AaJSY=; b=m4MTk92dtpDk3nYnMH4itzN5odguaVC3niaKyyuumsIGEN85IpxTwwDbzeMIlmyzof VnzYZqUG5woWMlRtLBwpp3svL9f3wM/tb2HHHUwbSyp9xUaEjbzdiQU5JGEKmuXiI5B8 Sapj6XsenURWT1JiMduCGTA3HAfVn/VhXhZGT4pZNVhFvZDeFNxEB4dGIdXmQIEDe9FC pL2uUzaYvlBk6w0q32Ptx7YoRfNQX3AtCsO/pWCTiCz8OIwu6QkljTtZM15gt5YYYIBV RUphyZzE9h2F/hqqC3ZJWxQNUP/yTi0JDbTJmU4DHUZhVo1D3X+/xtvb1pxawsXAZrbJ HiEg== X-Forwarded-Encrypted: i=1; AJvYcCXhs27BctvFOjq7pzAL7tkxEpcbbOPd1DwpT86TszxACg1Dui7vwn8D6Gnvwm7Lk5fIQJnRhU6n6LD/+4Ii+MsX2F0GJg== X-Gm-Message-State: AOJu0YyBOlu/0IGoqkityzPobvgizNlnrKjSzH/wm7fD5uDYC6au1xqd xhUmgiLZQRwOQq39V3JpKzR1wwqgSxhl8Ce7qaGMQvwNZPs61YIr9bNpVyd0bZ0= X-Received: by 2002:a05:6871:80e:b0:261:1267:fe95 with SMTP id 586e51a60fabf-264690938d6mr395447fac.9.1721671075077; Mon, 22 Jul 2024 10:57:55 -0700 (PDT) Received: from localhost ([136.62.192.75]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-2610c76db96sm1787543fac.14.2024.07.22.10.57.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jul 2024 10:57:54 -0700 (PDT) From: Sam Protsenko To: Minkyu Kang , Minkyu Kang Cc: Tom Rini , Peng Fan , Jaehoon Chung , 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 v3 18/38] mmc: exynos_dw_mmc: Fix getting private data in exynos_dwmci_board_init() Date: Mon, 22 Jul 2024 12:57:20 -0500 Message-Id: <20240722175740.6985-19-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240722175740.6985-1-semen.protsenko@linaro.org> References: <20240722175740.6985-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 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);