Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp2619555lqt; Mon, 22 Apr 2024 17:02:22 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUd6i2FUVf2rvwfQACUzMQzXFCcNEIZXC6BIhq22qFZlsD1t67+lvIIw4Tgt89M2C5OvNfxwUNTZ8UCSKkMonPcXdMSBGY2Lrttda9pjw== X-Google-Smtp-Source: AGHT+IHsufwBvzkFlzRgMgPUCkoTFlfgmy7OBbcF4GeeS9/9YJH//qkBR84iePd2Q3SlMLJVK7Sn X-Received: by 2002:a05:6a21:3384:b0:1a7:92dc:29f2 with SMTP id yy4-20020a056a21338400b001a792dc29f2mr13350725pzb.49.1713830541766; Mon, 22 Apr 2024 17:02:21 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713830541; cv=pass; d=google.com; s=arc-20160816; b=N3nyn4FXMe+BTReW+A70SflPOSDFV1vI0sOIiNOt/xA5gUIfiuTXwmTkD3qMTgEU41 XI5ljKf0KLmZ/wuyPL7Z1z9yGxkdkxpPpIT7zJxrVIBtnPaLE98PTgsTXvN4bOdg3hGo Qu+zGtAaUgUYrSoZk2JElDbKZQz9s5xOotSvOHTmkgYMxL/pNFR1soXt+nnx6ARWYAPX vYgZ/8WZzYQAh+vJRIJ5bRhFJDepkG2//Tnd2uTYhyMYSX00LHqaDsC8q1wyRoSTYMEG I3fFhRuhtPyEd1r/5mr3d6Gybg/ghmCL/Mrw85KbJXe9hQ0/s/0PtLk8MmiIhouXf9VN Hxbw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=FOagD4XNh0Xd0MMBJ0QnANM1e5Nwfj50Z0Ad7260JkQ=; fh=KOHpmywNaLz+419FBaT9sT1JaHUwfXdFASOwqRsZRWM=; b=wW4mmMKA1dgI2DsUKgkwBv/lAzcTWp7mEpz8wlbnHfzI9yd6OSNv80jP10QEAWY+R8 sinWZdhIq3VBisZja3Uf9rIDjbIfNxk00wCfxXObYF9L20LlrvvaBKzo+2ezslBcDEdE lceKHazqKlclMFtV4gRNJWAvTewafqhzdX+htGHlN4z/zQudQCHSlnV34ddpp+i924hk X9QLH1C+cXUJmgDAxuguTsNb3+9FZ2EI5Gzf1f6sqJaAxriaGcoTyt+q/Pc8M7fcfGIC RCYIa1EONBHiAwlNihpa43GP1ikrzsIX8N3ZRQsIJjDfqmVdEYNX2U3YzuiGQ1JOdma+ au7w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=HRhCKKII; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-154217-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-154217-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id e11-20020a63500b000000b005f0a5246e88si8398159pgb.392.2024.04.22.17.02.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Apr 2024 17:02:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-154217-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=HRhCKKII; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-154217-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-154217-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 4A5F5B25326 for ; Mon, 22 Apr 2024 23:53:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C215347A48; Mon, 22 Apr 2024 23:53:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="HRhCKKII" Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5870746436; Mon, 22 Apr 2024 23:53:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713829988; cv=none; b=PGz2+sWWSnUpp/n0AyVbkBwHW3C87ERsKByodygroCWVE+gNVf4QFM2nZ51wW+0eouMB0RzGxcNnGJllUghx99uAyqDZ2LdVbFObmorwgHp6sGCeMW3TrGSOB8ipGFtlDhwFYTjJRtYnBMfAdPzaLjg7WwZ1osdxHiqLZz1W8O4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713829988; c=relaxed/simple; bh=ReEUZRtSW1NtsWR44K1jxu43AC533vf5fFJ2VNxO5Ok=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=AVvP6pbia3G9y+Cdz8LGDFSge/pj3XzgK420pT/aGQbnLdMoBpZRXo7tlPjWptdZhNKqvEJ1NKzDs/QO1Va5xKHn7tQwFauV0KZi8nQCsmZLNL9SQ2orK2YTq7KXgdi0dzY6y9/o2RH01IOzdqWwBl3KHhnkqK/oqEAtkqJVm90= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=HRhCKKII; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Received: from pps.filterd (m0279867.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 43MLifbB016015; Mon, 22 Apr 2024 23:53:03 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding:content-type; s=qcppdkim1; bh=FOagD4X Nh0Xd0MMBJ0QnANM1e5Nwfj50Z0Ad7260JkQ=; b=HRhCKKIIHjxKdLcxn6i+lD5 Sa28qbPtpxRY4XJedAm2aiKBY517ktm3Ap49JZtQoQeKTzUxJgwYg6YFJ34GlD5s Ui8xvQd4p9Qj7B3KfKB1t0BygVE/5zWSbEzbLLhksc2rjM2ab2dXKFe0Zna9fIRZ wAZ5ZSKNICTDa3IdciogVByLK9ONb9rFOH3pl499L+mifK1ZHociMR7GLiua8mlq AGwktpT7PKT5CgHfZE9R5VGi+PrAAzH0VrL56QqKUIWUXhpkXLjSnfrFn3/6o/N4 lsR2eOFOt44G0ifgu6anKcaTdKpKTdFYuo28HwBIVf6sRdUn9szaLQkxhpE06ag= = Received: from nalasppmta02.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3xnn82sw2a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 22 Apr 2024 23:53:03 +0000 (GMT) Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 43MNr2hB004483 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 22 Apr 2024 23:53:02 GMT Received: from hu-obabatun-lv.qualcomm.com (10.49.16.6) by nalasex01b.na.qualcomm.com (10.47.209.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Mon, 22 Apr 2024 16:52:58 -0700 From: Oreoluwa Babatunde To: , CC: , , , Oreoluwa Babatunde Subject: [PATCH] of: reserved_mem: Remove the use of phandle from the reserved_mem APIs Date: Mon, 22 Apr 2024 16:52:43 -0700 Message-ID: <20240422235243.2878536-1-quic_obabatun@quicinc.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: nalasex01a.na.qualcomm.com (10.47.209.196) To nalasex01b.na.qualcomm.com (10.47.209.197) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: A_IOoqzBMNY9_vF4UKugrP7LNjpPArZa X-Proofpoint-ORIG-GUID: A_IOoqzBMNY9_vF4UKugrP7LNjpPArZa X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-04-22_16,2024-04-22_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 lowpriorityscore=0 suspectscore=0 adultscore=0 clxscore=1011 bulkscore=0 malwarescore=0 spamscore=0 impostorscore=0 priorityscore=1501 mlxlogscore=823 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2404010003 definitions=main-2404220100 The __find_rmem() function is the only place that references the phandle field of the reserved_mem struct. __find_rmem() is used to match a device_node object to its corresponding entry in the reserved_mem array using its phandle value. But, there is already a function called of_reserved_mem_lookup() which carries out the same action using the name of the node. Using the of_reserved_mem_lookup() function is more reliable because every node is gauranteed to have a name, but not all nodes will have a phandle. Nodes are only assigned a phandle if they are explicitly defined in the DT using "phandle = ", or if they are referenced by another node in the DT. Hence, If the phandle field is empty, then __find_rmem() will return a false negative. Hence, delete the __find_rmem() function and switch to using the of_reserved_mem_lookup() function to find the corresponding entry of a device_node in the reserved_mem array. Since the phandle field of the reserved_mem struct is now unused, delete that as well. Signed-off-by: Oreoluwa Babatunde --- drivers/of/of_reserved_mem.c | 26 +++----------------------- include/linux/of_reserved_mem.h | 1 - 2 files changed, 3 insertions(+), 24 deletions(-) diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c index 8236ecae2953..bdf41b5b1ae5 100644 --- a/drivers/of/of_reserved_mem.c +++ b/drivers/of/of_reserved_mem.c @@ -437,18 +437,9 @@ void __init fdt_init_reserved_mem(void) for (i = 0; i < reserved_mem_count; i++) { struct reserved_mem *rmem = &reserved_mem[i]; unsigned long node = rmem->fdt_node; - int len; - const __be32 *prop; int err = 0; bool nomap; - nomap = of_get_flat_dt_prop(node, "no-map", NULL) != NULL; - prop = of_get_flat_dt_prop(node, "phandle", &len); - if (!prop) - prop = of_get_flat_dt_prop(node, "linux,phandle", &len); - if (prop) - rmem->phandle = of_read_number(prop, len/4); - if (rmem->size == 0) err = __reserved_mem_alloc_size(node, rmem->name, &rmem->base, &rmem->size); @@ -457,6 +448,8 @@ void __init fdt_init_reserved_mem(void) if (err != 0 && err != -ENOENT) { pr_info("node %s compatible matching fail\n", rmem->name); + + nomap = of_get_flat_dt_prop(node, "no-map", NULL) != NULL; if (nomap) memblock_clear_nomap(rmem->base, rmem->size); else @@ -477,19 +470,6 @@ void __init fdt_init_reserved_mem(void) } } -static inline struct reserved_mem *__find_rmem(struct device_node *node) -{ - unsigned int i; - - if (!node->phandle) - return NULL; - - for (i = 0; i < reserved_mem_count; i++) - if (reserved_mem[i].phandle == node->phandle) - return &reserved_mem[i]; - return NULL; -} - struct rmem_assigned_device { struct device *dev; struct reserved_mem *rmem; @@ -534,7 +514,7 @@ int of_reserved_mem_device_init_by_idx(struct device *dev, return 0; } - rmem = __find_rmem(target); + rmem = of_reserved_mem_lookup(target); of_node_put(target); if (!rmem || !rmem->ops || !rmem->ops->device_init) diff --git a/include/linux/of_reserved_mem.h b/include/linux/of_reserved_mem.h index 4de2a24cadc9..e338282da652 100644 --- a/include/linux/of_reserved_mem.h +++ b/include/linux/of_reserved_mem.h @@ -11,7 +11,6 @@ struct reserved_mem_ops; struct reserved_mem { const char *name; unsigned long fdt_node; - unsigned long phandle; const struct reserved_mem_ops *ops; phys_addr_t base; phys_addr_t size; -- 2.34.1