Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F2C90C6FD18 for ; Tue, 18 Apr 2023 16:47:23 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C840386129; Tue, 18 Apr 2023 18:46:35 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=kwiboo.se 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=kwiboo.se header.i=@kwiboo.se header.b="Rn4fz0e7"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 19CC886101; Tue, 18 Apr 2023 18:46:30 +0200 (CEST) Received: from s.wrqvwxzv.outbound-mail.sendgrid.net (s.wrqvwxzv.outbound-mail.sendgrid.net [149.72.154.232]) (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 B5D7285F00 for ; Tue, 18 Apr 2023 18:46:27 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=kwiboo.se Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=bounces+31435339-7456-u-boot=lists.denx.de@em2124.kwiboo.se DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kwiboo.se; h=from:subject:in-reply-to:references:mime-version:to:cc: content-transfer-encoding:content-type:cc:content-type:from:subject:to; s=s1; bh=8nSSHha+yaIAWPVs18WCRC/F76aJSOWqgQq6NiZIrVA=; b=Rn4fz0e7JQzJBOJPAQeHOrbJS02lOQB0ORjD+CooM6eWwBYdPaPccEDp58Zg6t5Mcr7y l2n1TXhxhF+5x7JaDvCXujhoR66QUPV7/xkLzwviL93ziRnSMrZZLHlbKCeeY4WjHN/T7M C70x/WefIdKCFVo3b4XoUhMhG/NBUkXHA6rfAAUBnJceFk2gHvOLQmWrwVx5ShiuoSpKAC aJuljudCZ1oWRn0WezPu6HiemtX1XLquUt8nBTJBzZcF8lMW+WFxcwon2oGWEGvk5VIMAp bwlaeqg08kHmLsSNld4etu/u13ZQv7ELyqrqhwTWGFwUM0dLmqiaJM1PYaqH9spw== Received: by filterdrecv-59cb65cf6d-4lbfg with SMTP id filterdrecv-59cb65cf6d-4lbfg-1-643EC961-3C 2023-04-18 16:46:26.050575625 +0000 UTC m=+3538383.129464849 Received: from bionic.localdomain (unknown) by geopod-ismtpd-4 (SG) with ESMTP id EZaJB9okRBSlmajAAF-L3w Tue, 18 Apr 2023 16:46:25.839 +0000 (UTC) From: Jonas Karlman Subject: [PATCH v2 03/17] mmc: rockchip_sdhci: Fix use of device private data Date: Tue, 18 Apr 2023 16:46:26 +0000 (UTC) Message-Id: <20230418164618.2571309-4-jonas@kwiboo.se> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230418164618.2571309-1-jonas@kwiboo.se> References: <20230418164618.2571309-1-jonas@kwiboo.se> MIME-Version: 1.0 X-SG-EID: =?us-ascii?Q?TdbjyGynYnRZWhH+7lKUQJL+ZxmxpowvO2O9SQF5CwCVrYgcwUXgU5DKUU3QxA?= =?us-ascii?Q?fZekEeQsTe+RrMu3cja6a0h4gSK0=2FngxdTUXNIt?= =?us-ascii?Q?leuvX8gau3zcTEapQMuVhpiWi8Z8AHWFLlkSSHz?= =?us-ascii?Q?wTpFo89KH6h4XjgPUn0vbB09sV58bWVvbKLDwKh?= =?us-ascii?Q?5PM2zrE85snxwhEDzD3WIiAhPvIqP41vRgvMrn3?= =?us-ascii?Q?pBYxIwYMLFAoNwJvDtV6vqT+PImUKo5Ws+1T3S?= To: Kever Yang , Simon Glass , Philipp Tomsich , Peng Fan , Jaehoon Chung Cc: u-boot@lists.denx.de, Jonas Karlman , Eugen Hristev X-Entity-ID: P7KYpSJvGCELWjBME/J5tg== Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii 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 The device private data is misused in rockchip_sdhci_of_to_plat and rockchip_sdhci_execute_tuning. In these functions dev_get_priv is assigned to struct sdhci_host: struct sdhci_host *host = dev_get_priv(dev); Instead, the sdhci host should refer to host in struct rockchip_sdhc: struct rockchip_sdhc *priv = dev_get_priv(dev); struct sdhci_host *host = &priv->host; Because host is the first member in struct rockchip_sdhc this is not a real problem, lets fix it anyway and also use priv name consistently. Signed-off-by: Jonas Karlman --- v2: - No change drivers/mmc/rockchip_sdhci.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/mmc/rockchip_sdhci.c b/drivers/mmc/rockchip_sdhci.c index e1409dd2c749..ae28840f6081 100644 --- a/drivers/mmc/rockchip_sdhci.c +++ b/drivers/mmc/rockchip_sdhci.c @@ -450,7 +450,8 @@ static int rockchip_sdhci_set_ios_post(struct sdhci_host *host) static int rockchip_sdhci_execute_tuning(struct mmc *mmc, u8 opcode) { - struct sdhci_host *host = dev_get_priv(mmc->dev); + struct rockchip_sdhc *priv = dev_get_priv(mmc->dev); + struct sdhci_host *host = &priv->host; char tuning_loop_counter = SDHCI_TUNING_LOOP_COUNT; struct mmc_cmd cmd; u32 ctrl, blk_size; @@ -531,9 +532,9 @@ static int rockchip_sdhci_probe(struct udevice *dev) struct sdhci_data *data = (struct sdhci_data *)dev_get_driver_data(dev); struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev); struct rockchip_sdhc_plat *plat = dev_get_plat(dev); - struct rockchip_sdhc *prv = dev_get_priv(dev); + struct rockchip_sdhc *priv = dev_get_priv(dev); struct mmc_config *cfg = &plat->cfg; - struct sdhci_host *host = &prv->host; + struct sdhci_host *host = &priv->host; struct clk clk; int ret; @@ -547,8 +548,8 @@ static int rockchip_sdhci_probe(struct udevice *dev) printf("%s fail to get clk\n", __func__); } - prv->emmc_clk = clk; - prv->dev = dev; + priv->emmc_clk = clk; + priv->dev = dev; if (data->get_phy) { ret = data->get_phy(dev); @@ -566,7 +567,7 @@ static int rockchip_sdhci_probe(struct udevice *dev) host->quirks = SDHCI_QUIRK_WAIT_SEND_CMD; host->mmc = &plat->mmc; - host->mmc->priv = &prv->host; + host->mmc->priv = &priv->host; host->mmc->dev = dev; upriv->mmc = host->mmc; @@ -580,8 +581,9 @@ static int rockchip_sdhci_probe(struct udevice *dev) static int rockchip_sdhci_of_to_plat(struct udevice *dev) { struct rockchip_sdhc_plat *plat = dev_get_plat(dev); - struct sdhci_host *host = dev_get_priv(dev); + struct rockchip_sdhc *priv = dev_get_priv(dev); struct mmc_config *cfg = &plat->cfg; + struct sdhci_host *host = &priv->host; int ret; host->name = dev->name; -- 2.40.0