From patchwork Wed Sep 4 02:09:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 1980415 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=HG8bQWlV; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=sifive.com header.i=@sifive.com header.a=rsa-sha256 header.s=google header.b=dElHaULF; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Wz5Yx4NP5z1yXY for ; Wed, 4 Sep 2024 12:10:45 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=2IWUwyQP+I0ODbyl6lsB3Ph34gowSP7AUJd5mCiHCQ8=; b=HG8bQWlVipRudu BeK7VU/6SUtAQMI/ClOmf+yAyxNPBSrLvpZHux3EsFebzE+xFG5r79010EGvk2+OGUYLf5+ohdLcC SOMp+lx71wGPwn3aqZrEEBU8zVuXCAw81joGCp9xRz+5Su8aUybGofEC7krnCiT5E6AdmUIsEA0Vc diDw8/n6GsAD9n3rPNp8+tZPLi4/ClVpHzvslIDK8XMKMt0c0YrmBauz5kficI2Y83HS0EciKNTQ9 j3oZRuJEhnVajl0GOVQgN0vhZzgVet1BN3mxwj4PJ8N8Z6oueICd5vcOTKMEvkt23xMpOS8eOSfV0 xBgt/1m5xsN+48kLQchg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1slfTi-00000002YTz-1Mj7; Wed, 04 Sep 2024 02:10:38 +0000 Received: from mail-pj1-x1035.google.com ([2607:f8b0:4864:20::1035]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1slfTf-00000002YSO-0b5y for opensbi@lists.infradead.org; Wed, 04 Sep 2024 02:10:36 +0000 Received: by mail-pj1-x1035.google.com with SMTP id 98e67ed59e1d1-2d87a1f0791so3159506a91.2 for ; Tue, 03 Sep 2024 19:10:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1725415834; x=1726020634; darn=lists.infradead.org; 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=x5pm52FJ4As9yuMZ2wlQJb/RvjNLLHpCup1XKUJodm8=; b=dElHaULF9e2upHAwHm3nCLrJMHSfK42DHeS/yQycbhk3iSfWvNBR9CNNrlJoNThKRd zc9nBDdoA0ZDXNes+2+pPq/VbOygyS3R+7p0ViOFEIQEet+sZ6iQrbw25mSkS9cUt1xr o5T7dmzlSghAtXB6h+6iKatiyIiZMREfzk+jxDc+puYkOoCEBAIy5UGcmGFH7lumJngN OlV0dY/QayAoNhZZ8rXmBjBLZYE+qG4xxUv79fHirAYtrTeNZq6xDkDW+fyyyOsi4tsd CI4RCXti+GRYc1KAwd4uqnz6Yg4PMCRhWwiEV4mC66eZJJKM9UUWzqGPcZ7MJp9Gvx0k OpWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725415834; x=1726020634; 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=x5pm52FJ4As9yuMZ2wlQJb/RvjNLLHpCup1XKUJodm8=; b=oO6FEXgGBFlBZ43J5pBY6kU8oRSupS9Na7aR0qh1puwEmukyQOAQjqpguhM5rH9Oux G06hdPjcDRDHKnnLwF/3xy+xsmXJajYZ3tsajEZ8yMcI2y9l2HgEffd+PNApVTH0WFNj SgqapN8BR+CsnfI6WXF1a7upeHPHCsS+3T+GpwL2h4IIEWN6PBjeWDjbi9oo1HjcD9gG MsJDZ2QPiC2BMfgydnMQX07PnvrgNW5lB1bGZ42UwKiZuNckoBVmctU3OnI9iamWlVYE DeR8oji5GZnifn8mUnOk5o7NZlk2f4P0ItVKFmFzb3a2+rdTMYY1+XUe60Gv1DpQw/XM 7lFw== X-Gm-Message-State: AOJu0YxEVzD3eynLQ0HMWKPgojFVZkI+MShphjTPI9TjdVgScSfGhB0h tPe7fiHpE/MUOexLXNXeO/mrOAWmmJdN1MlWp7PMZhb3l4lEYzOXrWyCqvWwIyhvU8oJtfPTNOx 7nEsjKnnHFT+Ckz9lMeUX7jFpuv6l7Pdo4amlAsYhhYUZ3zuoH+74s3fQgXXF2pFnZQ3gjmIIkC 9lkphxZ1IQB/my21Gtnodw2laBti/tHEOetXSca1F704SQgxSnPdw= X-Google-Smtp-Source: AGHT+IGbfOOIQqXg4IZS+z9CEV4nO2nhXNO+4ndcZ9KYOfobB7QSlR/PUQAdxsPYpSUK0tn/+M0FQw== X-Received: by 2002:a17:90a:b016:b0:2d8:40be:263a with SMTP id 98e67ed59e1d1-2d8973a5691mr11632611a91.34.1725415833747; Tue, 03 Sep 2024 19:10:33 -0700 (PDT) Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2d8af988d0esm6738385a91.45.2024.09.03.19.10.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Sep 2024 19:10:30 -0700 (PDT) From: Samuel Holland To: opensbi@lists.infradead.org Subject: [PATCH 3/3] lib: utils/regmap: Use FDT node offset as regmap ID Date: Tue, 3 Sep 2024 19:09:39 -0700 Message-ID: <20240904021006.3653559-4-samuel.holland@sifive.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240904021006.3653559-1-samuel.holland@sifive.com> References: <20240904021006.3653559-1-samuel.holland@sifive.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240903_191035_223855_06118FD6 X-CRM114-Status: GOOD ( 16.64 ) X-Spam-Score: -2.1 (--) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Since the FDT is not modified during driver initialization, node offsets are just as suitable as phandles for use as identifiers: they are stable and unique. With this change, it is no longer necessar [...] Content analysis details: (-2.1 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:1035 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.0 T_SCC_BODY_TEXT_LINE No description available. X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Since the FDT is not modified during driver initialization, node offsets are just as suitable as phandles for use as identifiers: they are stable and unique. With this change, it is no longer necessary to pass the phandle to the driver init functions, so these init functions now use the same prototype as other kinds of drivers. This matches what is already done for I2C adapters. Signed-off-by: Samuel Holland Reviewed-by: Anup Patel --- include/sbi_utils/regmap/fdt_regmap.h | 2 +- lib/utils/regmap/fdt_regmap.c | 14 +++++++------- lib/utils/regmap/fdt_regmap_syscon.c | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/include/sbi_utils/regmap/fdt_regmap.h b/include/sbi_utils/regmap/fdt_regmap.h index 86e72442..de946f27 100644 --- a/include/sbi_utils/regmap/fdt_regmap.h +++ b/include/sbi_utils/regmap/fdt_regmap.h @@ -17,7 +17,7 @@ struct fdt_phandle_args; /** FDT based regmap driver */ struct fdt_regmap { const struct fdt_match *match_table; - int (*init)(const void *fdt, int nodeoff, u32 phandle, + int (*init)(const void *fdt, int nodeoff, const struct fdt_match *match); }; diff --git a/lib/utils/regmap/fdt_regmap.c b/lib/utils/regmap/fdt_regmap.c index f02d2f07..933938fb 100644 --- a/lib/utils/regmap/fdt_regmap.c +++ b/lib/utils/regmap/fdt_regmap.c @@ -16,7 +16,7 @@ extern struct fdt_regmap *fdt_regmap_drivers[]; extern unsigned long fdt_regmap_drivers_size; -static int fdt_regmap_init(const void *fdt, int nodeoff, u32 phandle) +static int fdt_regmap_init(const void *fdt, int nodeoff) { int pos, rc; struct fdt_regmap *drv; @@ -27,7 +27,7 @@ static int fdt_regmap_init(const void *fdt, int nodeoff, u32 phandle) drv = fdt_regmap_drivers[pos]; match = fdt_match_node(fdt, nodeoff, drv->match_table); if (match && drv->init) { - rc = drv->init(fdt, nodeoff, phandle, match); + rc = drv->init(fdt, nodeoff, match); if (rc == SBI_ENODEV) continue; if (rc) @@ -39,20 +39,20 @@ static int fdt_regmap_init(const void *fdt, int nodeoff, u32 phandle) return SBI_ENOSYS; } -static int fdt_regmap_find(const void *fdt, int nodeoff, u32 phandle, +static int fdt_regmap_find(const void *fdt, int nodeoff, struct regmap **out_rmap) { int rc; - struct regmap *rmap = regmap_find(phandle); + struct regmap *rmap = regmap_find(nodeoff); if (!rmap) { /* Regmap not found so initialize matching driver */ - rc = fdt_regmap_init(fdt, nodeoff, phandle); + rc = fdt_regmap_init(fdt, nodeoff); if (rc) return rc; /* Try to find regmap again */ - rmap = regmap_find(phandle); + rmap = regmap_find(nodeoff); if (!rmap) return SBI_ENOSYS; } @@ -75,7 +75,7 @@ int fdt_regmap_get_by_phandle(const void *fdt, u32 phandle, if (pnodeoff < 0) return pnodeoff; - return fdt_regmap_find(fdt, pnodeoff, phandle, out_rmap); + return fdt_regmap_find(fdt, pnodeoff, out_rmap); } int fdt_regmap_get(const void *fdt, int nodeoff, struct regmap **out_rmap) diff --git a/lib/utils/regmap/fdt_regmap_syscon.c b/lib/utils/regmap/fdt_regmap_syscon.c index a95f2515..ba559086 100644 --- a/lib/utils/regmap/fdt_regmap_syscon.c +++ b/lib/utils/regmap/fdt_regmap_syscon.c @@ -159,7 +159,7 @@ static int regmap_syscon_write_be32(struct regmap *rmap, unsigned int reg, return 0; } -static int regmap_syscon_init(const void *fdt, int nodeoff, u32 phandle, +static int regmap_syscon_init(const void *fdt, int nodeoff, const struct fdt_match *match) { struct syscon_regmap *srm; @@ -188,7 +188,7 @@ static int regmap_syscon_init(const void *fdt, int nodeoff, u32 phandle, goto fail_free_syscon; srm->addr = addr; - srm->rmap.id = phandle; + srm->rmap.id = nodeoff; srm->rmap.reg_shift = 0; srm->rmap.reg_stride = srm->reg_io_width * 8; srm->rmap.reg_base = 0;