From patchwork Wed May 22 23:31:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 798197 Delivered-To: patch@linaro.org Received: by 2002:ab3:6414:0:b0:267:d849:ee76 with SMTP id j20csp918432lte; Wed, 22 May 2024 16:35:15 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUBfFcR+lYAm8mYjgkYfdZl82ckpWa0y4Y9Cip0LYkF+zP2QIfJaJU8Wl78oCtRxAxw06Ju3d+m7i4yei7QDsJW X-Google-Smtp-Source: AGHT+IFIBv8pUfjWDVBemw+zsu+ZPrIwZu7hUECMjbGJpOiBnk12j39ztMCnDwf4P8e6Sd34nrXv X-Received: by 2002:a50:9f47:0:b0:574:eb69:fadf with SMTP id 4fb4d7f45d1cf-57832c46f01mr2039564a12.36.1716420915362; Wed, 22 May 2024 16:35:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1716420915; cv=none; d=google.com; s=arc-20160816; b=XAnqQahef4WDvjuMMzwDtKxLZqZZ/s8MnUaT/2iLV5nCpNzlOh/xDp3AU+qnXZ0s+l w+nWvT4YoWVPWCnWdnlRVJi4RC9RYRAOwwUxUsSVibf/0uT5l4OBRbF0HhXODg3Rqjib YMruSRW1tU2rm8ExddE35tBQ6jMcnhMh0j8qNDU3LWzXts+BBMotqXwHwfuC1t9cZGjR EDHUk7O7C9LS81K0Ete2EJnRBckten1rkzDo0EnJMae/cVmOY7SVGIp2L2Lge7qbAhOy sgKRRdfQ44CEYMpjZ3tZBKRe699+WoPlcELY/FqF+U+7pk6zHLmzEPHU4srHJiPSPOId IW5g== 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=H0FlBtORU2YphyJoC9ALjRrQBtrihTvdGD8zX7T+j5s=; fh=yBKuVf8QZHGmUgrTJgIeYBtCONuDgiv3h+nY4Er7I2k=; b=kPPBKcGU1OLuqzgSmIBswRSkgLm4S7nc7K1XzwfjlE7bl3mrScprIMZ2bM5wJaYXyh x2vqAsjT/RAw9tp0BqtQP7dGTKjNqwE8m4y7WPCUeIUqm0uYDSKdYYt2m5NRdEXB3V/9 NzmTGvJ4kk/C4N9ySAFG2TIolzNzaAKEBv37Jx3AQl8wQ2spelS22oZYJu7r4sZ/XOph 9ELnZ520tWxPLTKZuj+aA2bFBlXsmRg+/JYh1piChouP6rX/532r4umlu6PpPsQ1Ngyz 8Q1FZ8f5QT76t/vA6Kxks1m5Yi0ewx5zwp9hgdtz6SlrG6cIFhpJyEcOt+D/SpLDKXL8 mG2g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GRXLJ5XL; 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 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 4fb4d7f45d1cf-574f7af8f24si9371946a12.233.2024.05.22.16.35.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 May 2024 16:35:15 -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=GRXLJ5XL; 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 Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 545398855B; Thu, 23 May 2024 01:32:05 +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="GRXLJ5XL"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id CAD6A88582; Thu, 23 May 2024 01:31:59 +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-oo1-xc36.google.com (mail-oo1-xc36.google.com [IPv6:2607:f8b0:4864:20::c36]) (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 D979D88554 for ; Thu, 23 May 2024 01:31:55 +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-oo1-xc36.google.com with SMTP id 006d021491bc7-5b52b0d0dfeso2087724eaf.0 for ; Wed, 22 May 2024 16:31:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1716420714; x=1717025514; 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=H0FlBtORU2YphyJoC9ALjRrQBtrihTvdGD8zX7T+j5s=; b=GRXLJ5XLPAA5WfMn7TwdrB+I24gtNDk9VhbJgSt1rDWPzvR9XbUzyFiDUeoZkWREP4 17ZyiR/v9On81KzFtLdkFoK6jOBPml45gYYc2KwyWGrFw+tXuMPH3idijK+c0yBSrZpR TU9oN8A0r0l5YyYSqnEfWHEjc9mGfB7DaQ+rRit02iNMVbz8Am3VpWzdUslmRY9qi1u/ pa57vZtnj/8DOzaVLy18n5fbyaDu/cepTrztF+xVdd2HF5QdUU6aLLk3xlv617LZb0pL NZ6u9/dufsuTpjcnTsTTNJI/YYwX1I/usn7fNqgyyRQKCVVIOzxEkxBqKj/vlaNmXxpi kmIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716420714; x=1717025514; 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=H0FlBtORU2YphyJoC9ALjRrQBtrihTvdGD8zX7T+j5s=; b=A6Qvj5G5nFbJRmBiPPJjt3i3YmAThQ2t3AaRgDMEC0ClfkYQer7XyHxsjxM6syGT6N ofWA3XhT9yV/Qqjh4MYPXJx2cUNEKpW62/TAB/gNAa1Nl08rkSYGBI3qVH9enYSMRP41 Hw1sfFuvvh4cQYw7QJbV3fF1OSJhrtQLDZ1FuHJJg/ZDyef8H8JJvnQ95vA/u4H6heeh VZIy7tndxBiB+41CcVu7Xj9153Q2Ujmo3xOyiZEZMfYuC2OG3X9Rbpe2v4/uCK4CEcll t9wseDGJUcp4vfmL5EVmM7iCZxaXW+1Fp0Zk94BMC/61hp6m34j8XYAXVwdDsM9lGTa+ jSFw== X-Forwarded-Encrypted: i=1; AJvYcCWIgt0dBtbvfjVX7p7xoibRmTrDiaEKQ4MlNHxTuU3206QeiMoQueOTdtD/RNPJbG9/Opya8C4rSTPYM1Xr6MLV4Qhz5A== X-Gm-Message-State: AOJu0YzypNXVDreN10qGF9CPp+83bdR3bc3GHXdDvKjHsuzUdZb/984Z YfqTv/gvD7lc1K+h71y5aNgZpilgzZlpVIR67yCjE0C3ui4uOmxh0rIwuI0NjN0= X-Received: by 2002:a05:6820:502:b0:5b2:3f04:8d04 with SMTP id 006d021491bc7-5b6a2ef48a1mr3859670eaf.4.1716420712583; Wed, 22 May 2024 16:31:52 -0700 (PDT) Received: from localhost ([136.62.192.75]) by smtp.gmail.com with ESMTPSA id 006d021491bc7-5b26ddcc6acsm6202956eaf.24.2024.05.22.16.31.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 May 2024 16:31:52 -0700 (PDT) From: Sam Protsenko To: Tom Rini , Minkyu Kang , Peng Fan , Jaehoon Chung , Simon Glass Cc: 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 20/42] mmc: exynos_dw_mmc: Fix getting private data in exynos_dwmci_board_init() Date: Wed, 22 May 2024 18:31:13 -0500 Message-Id: <20240522233135.26835-21-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240522233135.26835-1-semen.protsenko@linaro.org> References: <20240522233135.26835-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 --- 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 1f69e193f601..8e80bd6a059f 100644 --- a/drivers/mmc/exynos_dw_mmc.c +++ b/drivers/mmc/exynos_dw_mmc.c @@ -42,18 +42,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; @@ -83,7 +89,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);