From mboxrd@z Thu Jan 1 00:00:00 1970 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 91C2DC64EC3 for ; Fri, 3 Feb 2023 19:09:40 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id BA9E6856F4; Fri, 3 Feb 2023 20:09:34 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com 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=gmail.com header.i=@gmail.com header.b="T+TOfNmT"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E19A585F93; Fri, 3 Feb 2023 20:09:27 +0100 (CET) Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) (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 BADC685F91 for ; Fri, 3 Feb 2023 20:09:24 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=saproj@gmail.com Received: by mail-ej1-x62f.google.com with SMTP id lu11so18063234ejb.3 for ; Fri, 03 Feb 2023 11:09:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=RO9UhRzE/auOW0eZkRNnKUbxSCRZc/FQFUorVQ9Mfgg=; b=T+TOfNmTLew2sNTbpBX2r3s63elpJKbqXhiCKcFvIu5CnnUy1TeSR/uE9BiyA5sApI RM5B7y+PK882OptdXxT6Os1BD+dDXZi+gjEGYYFmT7FSRCRSlmcrDEXss0f/+RBqOvmX enhOWOZyBLU+33Q10/2yH0uRXuQ0OQkAvT0o09uyGBD8bpJrLpLm/luDXGwrkTUr3m0c pGF9XkvsI+oT1Ef6I+zdSFoECkTzf9THQ98CVYQ1hgXxZnJVFNoNqRVA1LstG65IJ48f 0V6IFmqAUcnGCd+uSpBuirfC4TLHjrPPu4flvNCGbQiB8XMkeuJoJppD34YdUWuzv4Xb KuDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=RO9UhRzE/auOW0eZkRNnKUbxSCRZc/FQFUorVQ9Mfgg=; b=gRXLLHi+QRAC6BexY4nRBNpKoMZmslXCqc98lWdLIvbTHtZ/iMg+Sj8x3qIHyc4p2b O5zApxno9321XqYlonbgvVr0XMmGsFi/ZleZseXGD0pKtLzC1HIy6g7700Voz623x3gV KxRHHPLdnmiHinWax8wLoY5VVPhDXYxhA+KdWHxO2K12grJeCJNz90Jmsqnnb5qCU5Xq Gu1wTYlQq3EokSmvHxl4cZhQrZg4ro1irNet11Vy+e36AyuaIiec6xGe6AeR5armjdCq 6SKGwYFM1tRI58Jc9CZe0PQ+94HLrpZEdzJiMC7AOfibPdckIMypQoJbRBkYERsWk4VB wljg== X-Gm-Message-State: AO0yUKU+bAGtMmWZgDcXovV4S5TM2MQuf7NvroYAFwRVYSiqnFR9cKo8 hPArZH5dp6lv5mTf1VyTYO2M/zfDkSA= X-Google-Smtp-Source: AK7set/X17ejb0AcKZhN/KYAsLvmVxy8CMe6V3JHpSRh+0iFYMPkAbOmTN4sB5moHlFjhT3bPMM9dA== X-Received: by 2002:a17:907:6d96:b0:88d:ba89:183c with SMTP id sb22-20020a1709076d9600b0088dba89183cmr7748638ejc.13.1675451364299; Fri, 03 Feb 2023 11:09:24 -0800 (PST) Received: from saproj-Latitude-5501.yandex.net ([2a02:6b8:0:40c:d7f7:41cb:f2:d80c]) by smtp.gmail.com with ESMTPSA id y14-20020a170906448e00b008787becf3a8sm1753762ejo.79.2023.02.03.11.09.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Feb 2023 11:09:24 -0800 (PST) From: Sergei Antonov To: u-boot@lists.denx.de, rfried.dev@gmail.com, joe.hershberger@ni.com Cc: Sergei Antonov Subject: [PATCH v3 2/3] net: ftmac100: simplify priv->iobase casting Date: Fri, 3 Feb 2023 22:09:03 +0300 Message-Id: <20230203190904.2448780-2-saproj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230203190904.2448780-1-saproj@gmail.com> References: <20230203190904.2448780-1-saproj@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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.6 at phobos.denx.de X-Virus-Status: Clean Replace 'phys_addr_t iobase' with 'struct ftmac100 *ftmac100' in struct ftmac100_data. It allows to remove casting in a number of places. Since priv->iobase is phys_addr_t, use phys_to_virt() to make a pointer from it. Signed-off-by: Sergei Antonov --- v2 -> v3: Fix the following warning by using phys_to_virt() to get a pointer from phys_addr_t. (ae350_rv32) drivers/net/ftmac100.c:317:26: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast] (ae350_rv32) 317 | priv->ftmac100 = (struct ftmac100 *)pdata->iobase; v1 -> v2: no change drivers/net/ftmac100.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/net/ftmac100.c b/drivers/net/ftmac100.c index 7c89d7f67b8d..e7b9d88ea9cd 100644 --- a/drivers/net/ftmac100.c +++ b/drivers/net/ftmac100.c @@ -28,7 +28,7 @@ struct ftmac100_data { struct ftmac100_rxdes rxdes[PKTBUFSRX]; int rx_index; const char *name; - phys_addr_t iobase; + struct ftmac100 *ftmac100; }; /* @@ -36,7 +36,7 @@ struct ftmac100_data { */ static void ftmac100_reset(struct ftmac100_data *priv) { - struct ftmac100 *ftmac100 = (struct ftmac100 *)(uintptr_t)priv->iobase; + struct ftmac100 *ftmac100 = priv->ftmac100; debug ("%s()\n", __func__); @@ -57,7 +57,7 @@ static void ftmac100_reset(struct ftmac100_data *priv) static void ftmac100_set_mac(struct ftmac100_data *priv , const unsigned char *mac) { - struct ftmac100 *ftmac100 = (struct ftmac100 *)(uintptr_t)priv->iobase; + struct ftmac100 *ftmac100 = priv->ftmac100; unsigned int maddr = mac[0] << 8 | mac[1]; unsigned int laddr = mac[2] << 24 | mac[3] << 16 | mac[4] << 8 | mac[5]; @@ -72,7 +72,7 @@ static void ftmac100_set_mac(struct ftmac100_data *priv , */ static void _ftmac100_halt(struct ftmac100_data *priv) { - struct ftmac100 *ftmac100 = (struct ftmac100 *)(uintptr_t)priv->iobase; + struct ftmac100 *ftmac100 = priv->ftmac100; debug ("%s()\n", __func__); writel (0, &ftmac100->maccr); } @@ -82,7 +82,7 @@ static void _ftmac100_halt(struct ftmac100_data *priv) */ static int _ftmac100_init(struct ftmac100_data *priv, unsigned char enetaddr[6]) { - struct ftmac100 *ftmac100 = (struct ftmac100 *)(uintptr_t)priv->iobase; + struct ftmac100 *ftmac100 = priv->ftmac100; struct ftmac100_txdes *txdes = priv->txdes; struct ftmac100_rxdes *rxdes = priv->rxdes; unsigned int maccr; @@ -187,7 +187,7 @@ static int __ftmac100_recv(struct ftmac100_data *priv) */ static int _ftmac100_send(struct ftmac100_data *priv, void *packet, int length) { - struct ftmac100 *ftmac100 = (struct ftmac100 *)(uintptr_t)priv->iobase; + struct ftmac100 *ftmac100 = priv->ftmac100; struct ftmac100_txdes *curr_des = priv->txdes; ulong start; @@ -314,7 +314,7 @@ static int ftmac100_of_to_plat(struct udevice *dev) struct eth_pdata *pdata = dev_get_plat(dev); const char *mac; pdata->iobase = dev_read_addr(dev); - priv->iobase = pdata->iobase; + priv->ftmac100 = phys_to_virt(pdata->iobase); mac = dtbmacaddr(0); if (mac) memcpy(pdata->enetaddr , mac , 6); -- 2.34.1