From patchwork Fri Sep 27 21:45:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 831029 Delivered-To: patch@linaro.org Received: by 2002:a5d:66c8:0:b0:367:895a:4699 with SMTP id k8csp968817wrw; Fri, 27 Sep 2024 14:46:30 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCU0yFtf/3Cv8l5mApmJ+ZkvHKegAhH7OjbsLr55ykQuCIy3uImvHRuW/rJlYZYA78sGqw8Tow==@linaro.org X-Google-Smtp-Source: AGHT+IFi3M0WIsMwTcHDAsnPKRXTTxuT/7UdBsltoYN7HeMNDULpuPTTpmCeZZVHdtHjDA8o75ZS X-Received: by 2002:a05:6214:3d8a:b0:6c3:508a:fec6 with SMTP id 6a1803df08f44-6cb3b5e8dd7mr87001816d6.17.1727473590023; Fri, 27 Sep 2024 14:46:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1727473590; cv=none; d=google.com; s=arc-20240605; b=dXST2NV2wMw7Mwif0vwSE2r2/M5NUPNCwVMgA+MewN12OC8MuuwmjVKBW189F/Blf/ 5a58HWtVbIwiUOkcvffF4oUM2EE/PnsjOJjFXIPYSIRuNfKnCVnVrtli22zJsw6ccquK rNGLg9/i6EmhVTuTsPlhH0+blm2jBwmiKWZfaYQyEN53aYyqkzG6Xs+3VUioKJAVii80 IX/PsVnUhdnS1TsngxMZYz8LmRg0wyMf/M/j8g360lDVnn6Gf9PuhU9/SSAp+5Afeegr 6BUn/y1QW7/DY9FUl82F4MPxqzFVRD2jjVrF1atus/pMLtjVwlKUNXnFSOAI0vGlLBuO riKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=Tq/WU8YFou4tlFTr5oZ2aHrtwQxQNFO3jd7/jY9s2dw=; fh=g3QeHlbvb1KMMNFLUbXIUYUDrJCyu1ADbrLKZLJdjPs=; b=jicRfuxFU1JQNa5Q/3Psr43CjoaeuIOQD59V6kLRy/0+Bu9ochhpLfFEUe0M+1szGx 0v3G7AiiNgpAU8/c+QBLxFo/2OANhKQ7Uv68V8QMwBTBha8faXomHDWliWVbCNaJdGrh ZqfZ/FFMM+Jc7ufJqm+z5Rv56oWDAOQeYbzPEwC5S5cvSyqcOtTVZILG97MKNSjgQPzB 3Oi+lc59n1jgWVzS2VmPSPGU+RFTLp4fSWbZVDWiNI8ib4ESsRyzUSYcN9wOsd9w1S6e OEXxwhzc1MoQRBWvFbnetgYgAWlOQWVjd50sMyj9mq9qX0DbHTmC79qBFpjccd3Y9SE3 RZeg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AiQIJV9i; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6cb3b6c80ddsi31801966d6.559.2024.09.27.14.46.29 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 27 Sep 2024 14:46:30 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AiQIJV9i; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1suIme-00043F-Rl; Fri, 27 Sep 2024 17:45:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1suImd-0003xY-BC for qemu-devel@nongnu.org; Fri, 27 Sep 2024 17:45:51 -0400 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1suImb-0003uL-H3 for qemu-devel@nongnu.org; Fri, 27 Sep 2024 17:45:50 -0400 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-42cd74c0d16so23948515e9.1 for ; Fri, 27 Sep 2024 14:45:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1727473541; x=1728078341; darn=nongnu.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=Tq/WU8YFou4tlFTr5oZ2aHrtwQxQNFO3jd7/jY9s2dw=; b=AiQIJV9iswhWv7xNmxJS/55KZIHsUX5nPKpfD/KMi4F0ZJ3i7o/rPNbMJ4I5xqdTXA uB0/mdPLgGX6AeRJVYyWYyQwYGJ86GdgNC24ADTMRP9WZb5bv461SmTPKkffVFHe/Iqo og/yq26oBoj+tHinuEl877OkTbFUd3vMQuiXE1a/Rhdz8blfMr+YyCwRDJbbyNTZs31r hQbQnBvm5e/eIkbX75cy2pMPm2QqF1FM0yxCc11Gf4+gipP4cOwf2ABj5mTQgjSEfsVR pSuxHE1T2Q78yb4VRvxKXPBF1y/ghDVDaXkyp4umbqCLDYgngYHql8g5RVCcRdyUWApT JJ2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727473541; x=1728078341; 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=Tq/WU8YFou4tlFTr5oZ2aHrtwQxQNFO3jd7/jY9s2dw=; b=kI/fx4Xw6YgmDZTFJhEZ2wU04uLs4jvSGpqEI2820EpvKsVAGUfKdg8PbWLZJRTfD8 byUqMcAoYR2dEMLkupt7gTJFLJyuli/10xxMe+xaydjSWxJVtpcFUBeKsFUd1fpj9BrN RUNjXbmX0qJ3ipQFSpBUIF6/NW4ozekcxTrT4wTk1Ve5ZseppO4eTfgih9Jrt3n+xvd8 Fe3SCDCpBRSXVuAvfv17I8NBw9pGFMnVRBoWmKey2JWTFWq74SpgQJG3aT+quzF7Bgrh wITZbRyvFwj5AjJ5yqoD9JYqGppr/oZyjVrypLFJUJFjIYegZfoOP6sQm18g34TL2rqj yYQA== X-Gm-Message-State: AOJu0YyNMvnlWMJ+p1Y7TfIAfgaogje0ZutvxaHeen+Vi7COggnDckYt zeqELAnRdeBkzbsVMlJe+k/e0KjRYwVQK3PM2j4lYn76EDktvnNVFkXE7q2F5L0uHZLIH4azItc + X-Received: by 2002:a05:600c:4f86:b0:42c:bae0:f066 with SMTP id 5b1f17b1804b1-42f58434768mr30930125e9.13.1727473541180; Fri, 27 Sep 2024 14:45:41 -0700 (PDT) Received: from localhost.localdomain ([176.187.217.136]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42e96a36292sm84637645e9.32.2024.09.27.14.45.38 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 27 Sep 2024 14:45:39 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Daniel Henrique Barboza , Nicholas Piggin , David Gibson , qemu-ppc@nongnu.org, Alexey Kardashevskiy , Harsh Prateek Bora , Jason Wang , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 1/4] hw/ppc/spapr_nvdimm: Simplify LD/ST API uses Date: Fri, 27 Sep 2024 23:45:28 +0200 Message-ID: <20240927214531.20242-2-philmd@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240927214531.20242-1-philmd@linaro.org> References: <20240927214531.20242-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32b; envelope-from=philmd@linaro.org; helo=mail-wm1-x32b.google.com X-Spam_score_int: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org ldn/stn methods handle the access size, no need for the switch case. Signed-off-by: Philippe Mathieu-Daudé --- hw/ppc/spapr_nvdimm.c | 47 ++++--------------------------------------- 1 file changed, 4 insertions(+), 43 deletions(-) diff --git a/hw/ppc/spapr_nvdimm.c b/hw/ppc/spapr_nvdimm.c index 7d2dfe5e3d..5af0b13370 100644 --- a/hw/ppc/spapr_nvdimm.c +++ b/hw/ppc/spapr_nvdimm.c @@ -250,7 +250,6 @@ static target_ulong h_scm_read_metadata(PowerPCCPU *cpu, SpaprDrc *drc = spapr_drc_by_index(drc_index); NVDIMMDevice *nvdimm; NVDIMMClass *ddc; - uint64_t data = 0; uint8_t buf[8] = { 0 }; if (!drc || !drc->dev || @@ -272,24 +271,7 @@ static target_ulong h_scm_read_metadata(PowerPCCPU *cpu, ddc = NVDIMM_GET_CLASS(nvdimm); ddc->read_label_data(nvdimm, buf, len, offset); - switch (len) { - case 1: - data = ldub_p(buf); - break; - case 2: - data = lduw_be_p(buf); - break; - case 4: - data = ldl_be_p(buf); - break; - case 8: - data = ldq_be_p(buf); - break; - default: - g_assert_not_reached(); - } - - args[0] = data; + args[0] = ldn_be_p(buf, len); return H_SUCCESS; } @@ -325,31 +307,10 @@ static target_ulong h_scm_write_metadata(PowerPCCPU *cpu, return H_P2; } - switch (len) { - case 1: - if (data & 0xffffffffffffff00) { - return H_P2; - } - stb_p(buf, data); - break; - case 2: - if (data & 0xffffffffffff0000) { - return H_P2; - } - stw_be_p(buf, data); - break; - case 4: - if (data & 0xffffffff00000000) { - return H_P2; - } - stl_be_p(buf, data); - break; - case 8: - stq_be_p(buf, data); - break; - default: - g_assert_not_reached(); + if (len < 8 && extract64(data, 8 * len, 64 - 8 * len)) { + return H_P2; } + stn_be_p(buf, data, len); ddc = NVDIMM_GET_CLASS(nvdimm); ddc->write_label_data(nvdimm, buf, len, offset); From patchwork Fri Sep 27 21:45:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 831031 Delivered-To: patch@linaro.org Received: by 2002:a5d:66c8:0:b0:367:895a:4699 with SMTP id k8csp968874wrw; Fri, 27 Sep 2024 14:46:42 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXLlBszjqTWAP1JIkjfAHiEPyrQJrWqGnAQe1W9Gj54bOxpfrZnZW0jTQdly6S86ixj46/UHg==@linaro.org X-Google-Smtp-Source: AGHT+IGH9vps/N9KJWMe5/Xr8+xl4Ssf9yZHkkcNzES+W1ED+8t0qcLiye6JkQOKpyL2ZpfeQkaG X-Received: by 2002:a05:620a:284a:b0:7ac:ba88:cade with SMTP id af79cd13be357-7ae378c63a3mr745328385a.63.1727473602072; Fri, 27 Sep 2024 14:46:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1727473602; cv=none; d=google.com; s=arc-20240605; b=ftnRIzxJIz5ihQpKpIceqKzlA8FgO/YhQKI5IV2d2dvXS7pyX+3OvXXXm4rdMWuoEi +pSW1L3HDV8tBlM+AxKFi+2D9KR8Gnvy9nBc0DCJmTWYavxDess/3fWtGlZgeNLNKOcu ka5hOWb5GbRR3zk3bLN4Ht8AxpejLhOiN9XsCyjUJG8CkGASGH4H5XFhU7fE8YkiwIf6 JkC0LnPcs8XvjZQKi5fuuIfOD3BpJkz4UI16n5uG5pXzOsmz3OJlsDyHDCzv10655Uaf rCo5XQIvfxfUElTVQje6jxT2sKAiTQivluHf0CTj4zI2nrgK/oMs5wBEKNQQElX58jYU n1Bw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=22wtNkwk6lzPh2EtQj85F8jLpnswm9ZtwKSArURcwyA=; fh=g3QeHlbvb1KMMNFLUbXIUYUDrJCyu1ADbrLKZLJdjPs=; b=SVWlhMAYU4uJOa1ffmT6563vaFeN8r4Y/YFdvA4MZJR86evQoyNy5Lw2F50HZVXKlo dbl9KUWzboenOsox6YacyHd+yTxNHMdLlQAWqOOh8tGky0EPNz0h1zZ9gsbOyE0LNNSM LuYmPtpS2vgiLVjYThTQ3Dhx63M73TN2CFj6p2F5/gFthskwXYvXucVvJaC4sHsIWvZB NcwxOHz9T8dnu6nLXwCX4tSCotIDoOX1TyKsnGuAgcEF7dGBQ1CJG1X8D/WRkymddpNB PRJ3HjYpFYyx1AasxM0STCLtjnN9eQgiDYDLmdY0qirrkKPIGKI6Nq7DjyEqG49M+lh3 McUw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kckBDP6G; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7ae3787168fsi320276085a.680.2024.09.27.14.46.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 27 Sep 2024 14:46:42 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kckBDP6G; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1suImg-0004B1-M2; Fri, 27 Sep 2024 17:45:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1suIme-00041w-E1 for qemu-devel@nongnu.org; Fri, 27 Sep 2024 17:45:52 -0400 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1suImc-0003ul-D7 for qemu-devel@nongnu.org; Fri, 27 Sep 2024 17:45:52 -0400 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-42cb57f8b41so31140305e9.0 for ; Fri, 27 Sep 2024 14:45:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1727473548; x=1728078348; darn=nongnu.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=22wtNkwk6lzPh2EtQj85F8jLpnswm9ZtwKSArURcwyA=; b=kckBDP6Gj8mRwxqqub8ykpcyjo9SSY8HO2InTJsE555j0cClfcPJckjrJ24KZ98AQU 83o24sXLCICkhf3uykxlhbqGTcCXJMGtBmiySu0cHK928bCb9axT4eG2HFLZ0+WsEbQJ FTTz41TczOF11z9UYtlDAOp9gej0nucMJOMlvF40BFbrTBRJVk97TXykdNgLcc/edTKY rm2546QzsSmRueIjv6n/uYy2XoXWdleXrjm3CzXvMlbx7R78ujFnRAF+GRQ0OuTkj6FY Cs35ndeETsiI2jQlqMTEYrE3gpKxfvz3akxBfvJPZYgJ1PtjwBXD61T+C14sQ6Waq+nv RJ3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727473548; x=1728078348; 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=22wtNkwk6lzPh2EtQj85F8jLpnswm9ZtwKSArURcwyA=; b=M9V3JONEa4gPPBVK70xsldO1OvbjauMECKzAj1T1u7CgtmOcj4iBYu6c0xs48Jiw/e tLfbKIm7gJXRDZhNf/zy+r1AwMnxqgVwXWAMXBJlHUzcE780WsrqOEp7u41IhF0vuISC 9B/U1ZA2wRCKvr4+VkKD6NZy50ho/4skY07I980MZLpM34jM8TIcR2JxzxwLRFck276S +eF4sIFW5RpjpNWlWGgCtnsdE7UMorGZKLMaOWSFweLuPrTe8P69S1lhgql+EUYx0KQc vXZdb76GZFPMr9yYnbxX57i/dBhLC4n6J6lyH7h5k5rBBs7AD/C/C72fF5vtnrgyVNqv NWRA== X-Gm-Message-State: AOJu0YwgLmB9KI+4i70IkHJCJbSS+naK0TCxIurEzOP81xj93hly3n+T 0p0t3n8JKQD+Haab6rH62vNGF2+W8jl1bmEHhF8nG1JS5/MHyqbHlIptWBnYaTGFAGUuDC0j9LF e X-Received: by 2002:a05:600c:1d1e:b0:42b:ac3d:3abc with SMTP id 5b1f17b1804b1-42f584976b0mr42968425e9.24.1727473548533; Fri, 27 Sep 2024 14:45:48 -0700 (PDT) Received: from localhost.localdomain ([176.187.217.136]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37cd564ce91sm3460609f8f.2.2024.09.27.14.45.45 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 27 Sep 2024 14:45:47 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Daniel Henrique Barboza , Nicholas Piggin , David Gibson , qemu-ppc@nongnu.org, Alexey Kardashevskiy , Harsh Prateek Bora , Jason Wang , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 2/4] hw/ppc/spapr_vof: Simplify LD/ST API uses Date: Fri, 27 Sep 2024 23:45:29 +0200 Message-ID: <20240927214531.20242-3-philmd@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240927214531.20242-1-philmd@linaro.org> References: <20240927214531.20242-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::332; envelope-from=philmd@linaro.org; helo=mail-wm1-x332.google.com X-Spam_score_int: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Directly call ldn_be_p once instead of ldl_be_p / ldq_be_p. Signed-off-by: Philippe Mathieu-Daudé --- hw/ppc/spapr_vof.c | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/hw/ppc/spapr_vof.c b/hw/ppc/spapr_vof.c index c02eaacfed..d238a44d88 100644 --- a/hw/ppc/spapr_vof.c +++ b/hw/ppc/spapr_vof.c @@ -136,26 +136,17 @@ bool spapr_vof_setprop(MachineState *ms, const char *path, const char *propname, vof->bootargs = g_strndup(val, vallen); return true; } - if (strcmp(propname, "linux,initrd-start") == 0) { - if (vallen == sizeof(uint32_t)) { - spapr->initrd_base = ldl_be_p(val); - return true; + switch (vallen) { + case 4: + case 8: + if (strcmp(propname, "linux,initrd-start") == 0) { + spapr->initrd_base = ldn_be_p(val, vallen); } - if (vallen == sizeof(uint64_t)) { - spapr->initrd_base = ldq_be_p(val); - return true; - } - return false; - } - if (strcmp(propname, "linux,initrd-end") == 0) { - if (vallen == sizeof(uint32_t)) { - spapr->initrd_size = ldl_be_p(val) - spapr->initrd_base; - return true; - } - if (vallen == sizeof(uint64_t)) { - spapr->initrd_size = ldq_be_p(val) - spapr->initrd_base; - return true; + if (strcmp(propname, "linux,initrd-end") == 0) { + spapr->initrd_size = ldn_be_p(val, vallen); } + return true; + default: return false; } } From patchwork Fri Sep 27 21:45:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 831032 Delivered-To: patch@linaro.org Received: by 2002:a5d:66c8:0:b0:367:895a:4699 with SMTP id k8csp968880wrw; Fri, 27 Sep 2024 14:46:44 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX3lEPFilAoSUZpnzcGqJ4RLqJhymJJ2pyydAm04eauX5XE31YxNDN1y8acGCqw6YG+tLZrKA==@linaro.org X-Google-Smtp-Source: AGHT+IGZFwB2k0OtLR2Xt9Lt47z6f112Vf8i/WkzY7rj1GsAACMzuIPgGhP1V2vZq4SeHDfZr1Xp X-Received: by 2002:a05:620a:1987:b0:7ad:c2ab:c693 with SMTP id af79cd13be357-7ae378d6077mr631918885a.64.1727473603825; Fri, 27 Sep 2024 14:46:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1727473603; cv=none; d=google.com; s=arc-20240605; b=cEnr+P9nv8UwfRoRMBDaUM7NP3hpbM2wvp2QKTHDNz4RSMDgA1xfVsziqweiAkbxK+ jLnGXlJvb8wqLPIJhoVVBKLHjgQoeJOp5wXfWCAHrX9+V25fL0/Yf93RfBXNvD6gVpwV DEDMTwdqmGvFVHZ7etQZ5JBX4osGG4Hr79QSqL/nMmDKMl+eys5zDwfathD+4u9K8zSt sNHo6ocNZegHiVyr+5DfVGgk3v6jBEbj8yiKvxrSYG5e6aSm1XhzCT7HuFkAoLMD/xhq bXwGnLGmH6TqWDkY0rQM8Cs8dSE/SqTwvpjMiQ+RYyur33N4b4M6Z+T0Ds1UJbreZ7p6 uh7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=Fbocd4kmjbgTZkW00sKJRg9Q/JlRfFmMDabLRJXpjXw=; fh=g3QeHlbvb1KMMNFLUbXIUYUDrJCyu1ADbrLKZLJdjPs=; b=DD86l4eKgiuyErSyz+rzDSsfqXkOmYpXV57q1xoCih/+clhlpOu2JeeOo/F+Tbju9/ JZoOIXKZfp6/ikazRfawNcabqbi4+N2hrEatKcypIbcBiIDChmDW+Hnt5bVcsMX9Fg6M /8XEH/C2UEK/lucX/g2GY7phWvTPzr1uNUITMvLn3RPhk6UATo/eCF1J3Vde6sQIqr9f m2rhfSeCeaUcAFT85PZqP7k/1+hwBTa4HdOB1TJEZ/boLBerqvgg0eTkvhAiqDYYEQlA 7f/PzgMhveLxd7K7xBo1WiUVQt/Ko7BnV2zxfomINCnSgo+Kr7HBVeqf5900T/J/2Nde p5zw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=K4SJx18e; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7ae378557e2si313685485a.484.2024.09.27.14.46.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 27 Sep 2024 14:46:43 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=K4SJx18e; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1suIml-0004Ss-4J; Fri, 27 Sep 2024 17:45:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1suImk-0004Pa-7i for qemu-devel@nongnu.org; Fri, 27 Sep 2024 17:45:58 -0400 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1suImi-0003w1-Oa for qemu-devel@nongnu.org; Fri, 27 Sep 2024 17:45:58 -0400 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-42cbb08a1a5so23862415e9.3 for ; Fri, 27 Sep 2024 14:45:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1727473555; x=1728078355; darn=nongnu.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=Fbocd4kmjbgTZkW00sKJRg9Q/JlRfFmMDabLRJXpjXw=; b=K4SJx18e3KP8qa1ATO9TlXGNmoSyGlFxcD0ybXAGMZvYR2Gyu3aHwbpKbhyMWk3IhW 4B67Rvbkb6W1K+xEF7eeSDIemCPvbqe2la+YW3DeZwIahQTkTGQ8SFl7Ajnsi3aE6LQY NkEFgQlAlOTvyUB0qaKb+riX4olt2uMfmWMCTbXyU+l2VD1A+FKjqJkAALOjmoE0mriA wHKUDtN+dbgyy2b6NqUFzWY9eeOBf99E1ej368gnNeJp1x3Z3+arROwwVcebgsfHuUVO eF5fbpxx53K1B0sNc6aQvbfun5gg6Mdgku0VpFUW6QinR4dp4LyfbhZbfUYI8YH8NMaR gryw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727473555; x=1728078355; 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=Fbocd4kmjbgTZkW00sKJRg9Q/JlRfFmMDabLRJXpjXw=; b=ZMa8kCXHlrvEWd04n9UJZnQ4HmXmv3Gj0WS3tToemRYcgg4aP/GQ7vgbX/3pZ5+68x szKhi09RCnCUFGjzfqlRSJ0YvUEO6et25pLiuYWPKbMa9SvlXcSigh+8M5wdVE4JQAhu TmGW/ZGZFiLg5sWmKG6QvBOtecejdm37K8fgfaNGt1BwdvXggdO+ETBBttdnS+mcOgWz FH4SqG2axah7qmowbZiwDe+ivieDyD5jugI6UpcwOCSj5EQbkJUwWTjLYZwRJw/KbhSG Kgyik35hOI/Jac/iwyrFAq/zRmIh06BuXBbGksa0WVQAYVnBOiDurDh6KQW0grKpP5WA QRFg== X-Gm-Message-State: AOJu0YxgJUdzY3udCtJD8uSTJMBz5pcoLYf31UPUfSWYGT9IlvgQHRRk 24q77CsIYKibFZJ4pDjFKQJXRrnC42Pv3ECTMRO/P43ngmjLxC88/rt0mCfBo6BPPzEFUlstOWJ L X-Received: by 2002:a05:600c:45ce:b0:42c:df54:1908 with SMTP id 5b1f17b1804b1-42f5844ba2bmr35683315e9.18.1727473554875; Fri, 27 Sep 2024 14:45:54 -0700 (PDT) Received: from localhost.localdomain ([176.187.217.136]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42e96a52308sm84020965e9.43.2024.09.27.14.45.52 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 27 Sep 2024 14:45:54 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Daniel Henrique Barboza , Nicholas Piggin , David Gibson , qemu-ppc@nongnu.org, Alexey Kardashevskiy , Harsh Prateek Bora , Jason Wang , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 3/4] hw/ppc/vof: Simplify LD/ST API uses Date: Fri, 27 Sep 2024 23:45:30 +0200 Message-ID: <20240927214531.20242-4-philmd@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240927214531.20242-1-philmd@linaro.org> References: <20240927214531.20242-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=philmd@linaro.org; helo=mail-wm1-x32f.google.com X-Spam_score_int: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Directly call ldn_be_p once instead of be32_to_cpu / ldq_be_p. Signed-off-by: Philippe Mathieu-Daudé --- hw/ppc/vof.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/hw/ppc/vof.c b/hw/ppc/vof.c index b5b6514d79..fb152efbe0 100644 --- a/hw/ppc/vof.c +++ b/hw/ppc/vof.c @@ -645,11 +645,7 @@ static void vof_dt_memory_available(void *fdt, GArray *claimed, uint64_t base) mem0_reg = fdt_getprop(fdt, offset, "reg", &proplen); g_assert(mem0_reg && proplen == sizeof(uint32_t) * (ac + sc)); - if (sc == 2) { - mem0_end = ldq_be_p(mem0_reg + sizeof(uint32_t) * ac); - } else { - mem0_end = be32_to_cpu(*(uint32_t *)(mem0_reg + sizeof(uint32_t) * ac)); - } + mem0_end = ldn_be_p(mem0_reg + sizeof(uint32_t) * ac, 4 * sc); g_array_sort(claimed, of_claimed_compare_func); vof_claimed_dump(claimed); From patchwork Fri Sep 27 21:45:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 831033 Delivered-To: patch@linaro.org Received: by 2002:a5d:66c8:0:b0:367:895a:4699 with SMTP id k8csp969026wrw; Fri, 27 Sep 2024 14:47:13 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWZHnac70wzfqbDWXSneXPjXdMOjzspjumMQjWcdOkMhjri7k6YjLIPUR/RjYNFtq6B9hQ4Ew==@linaro.org X-Google-Smtp-Source: AGHT+IEZfDjF1qoIkeeHDIJBi5hHEPUrHLaDc1fE8UN9vF0891d83Fl8gXi9BmIKMu4W37mDw62B X-Received: by 2002:a05:620a:2492:b0:7a8:364:80b0 with SMTP id af79cd13be357-7ae378c2cf8mr480789685a.47.1727473633538; Fri, 27 Sep 2024 14:47:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1727473633; cv=none; d=google.com; s=arc-20240605; b=eyvIEbYvzLL+2dOYbQMmI/cK/Iw6B71MH/aoQRpObKhENPpM9hHOtXkdA3vNgFHAW1 ZN1kq/n/qKwYC9K11hE3bN8WpKFwiqe1B10bPMffH1ExG2Ote1pPWSVRfe33im+++5VJ by5Q09qUTGNSAZ4bdB9PPxmy0l+bG6ohb/6uINZNi1jzo6G0sge/KJcCHP8iVIgtZF5f ftYhrMpnR8gYGUTxNZxSEj3cgSkkiW5fofpEmFd0SPct+i08Xb9+y8CgZmbPqIGZLnL5 bOM4t6HFc2he4nOMFAYqIbcaRQexVpH6JR/oD1togxNR31LnUzJm96z/PzJ+OT7csIBo tPNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=e1vHxexCTLbdRB8r0KvJgoIHaBve1hvZ62MNg9aoNm0=; fh=g3QeHlbvb1KMMNFLUbXIUYUDrJCyu1ADbrLKZLJdjPs=; b=EQwJMUo3igZLKy0gwy+I5P3WMTKRSdyYCLyOTbzzzH5iz+UvCbfDfTlrSGWf0Oj+Y0 47gIFwaANwpciB5u50JU/8XevmEPk1mFWUXPVWZMQ7Klj0jRappPKtSMhndYybzli1fl NY4bqeLDb9Ui1s5Qxh/m9NuruydNXOZ+Sj/pL9p+2nGlz/lbqtckA1QYpb9VOSPi0ypY dcUao37s218vFQ9Bju2lvySqof1/BEoaGx01gjmcyhfAblqNre1SZpAmVZ6N6bfE4h7v N4ay8bvaK29Rjvtcq6ZbRBGmhMntwnkiKgkQBzJceP+l5c+bh2KlsHdirMbsiXp4KugT Gryw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NiCuqekY; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7ae378713dbsi305579085a.576.2024.09.27.14.47.13 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 27 Sep 2024 14:47:13 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NiCuqekY; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1suIms-0004pA-2N; Fri, 27 Sep 2024 17:46:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1suImq-0004n7-Fb for qemu-devel@nongnu.org; Fri, 27 Sep 2024 17:46:04 -0400 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1suImo-0003ws-Uo for qemu-devel@nongnu.org; Fri, 27 Sep 2024 17:46:04 -0400 Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-37a413085cbso2572286f8f.1 for ; Fri, 27 Sep 2024 14:46:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1727473561; x=1728078361; darn=nongnu.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=e1vHxexCTLbdRB8r0KvJgoIHaBve1hvZ62MNg9aoNm0=; b=NiCuqekYQvacC/zN+941Yi6PEy/hLXyBY7AG4dS3FtRi8PXf2cI+Zx2j6l3PDD5YQv kq+UgfRubfUT2i2mRi1hmcnIKb0wKcRKrjUJPbRgwdf/+1JmBoHs7k898U/KTOKoH4Io fjzS75vVlUMd7Aa8vkmD4vEc0qMzv8AcKoXX91L73Bsr7aoNPGOhbsBwOM4M/+9u5G+N gs9RoMiRTAZnv8mbdsIoH+MnU8CWU5WIQdtYVBui47x0XTi/Z93v7Rp7QGC35VQfPkRL 10BZ/aqLqaKjSIWZcMz3UHy/+7fyaFZQHWmUoQo+G5O+jzOBK3rWMGMOIccts1jcm5LU FKHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727473561; x=1728078361; 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=e1vHxexCTLbdRB8r0KvJgoIHaBve1hvZ62MNg9aoNm0=; b=UyEiW1Uc6wsjHEKbguLTDz06I1XAe94yvLpxeAywg9ZTuHgpe/A8+AeGXxEz8lvGqQ W1/U7SkdmvEleF6gdyY5sRLMfdcjMSHHrD0z6QLpVDiqW8BrGJRDP+An06ybloDSJc2L ldHNncqmrxwA1I+Om1XGGUXTOj0y62/jGViIPhCRM0hS6O4Kt4dzXeCGGf7Mr+Ny+stQ OUpDhRGKKHz9GWOr2W8XMrQT8oF06CsJOFxvUsq2DlGAg+KGbGyTy7DQ+1FV0G/dyh3y Pb0u/7xb4S764zC8v2CUDOiGOWH/PcP4w686zGaFKdx4FSyrQ2Cwwvcft8/odYF8yOVB Xq5A== X-Gm-Message-State: AOJu0YyeOe4KzXBFml+5nc4vlB3YNcoGlwacVPo32dmacXMx25d63v8s /REI6tY6gk0+0EUUAT9BzBxR/7XC/6t96wB9xqzfRMjLI/CN3lsR6+M0+c21GanGk5WRfu4a9Q+ P X-Received: by 2002:a5d:500f:0:b0:374:ba78:9013 with SMTP id ffacd0b85a97d-37cd568e21cmr2908343f8f.9.1727473561121; Fri, 27 Sep 2024 14:46:01 -0700 (PDT) Received: from localhost.localdomain ([176.187.217.136]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37cd574282esm3373982f8f.104.2024.09.27.14.45.59 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 27 Sep 2024 14:46:00 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Daniel Henrique Barboza , Nicholas Piggin , David Gibson , qemu-ppc@nongnu.org, Alexey Kardashevskiy , Harsh Prateek Bora , Jason Wang , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 4/4] net/l2tpv3: Simplify LD/ST API uses Date: Fri, 27 Sep 2024 23:45:31 +0200 Message-ID: <20240927214531.20242-5-philmd@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240927214531.20242-1-philmd@linaro.org> References: <20240927214531.20242-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::432; envelope-from=philmd@linaro.org; helo=mail-wr1-x432.google.com X-Spam_score_int: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Directly call ldn_be_p once instead of ldl_be_p / ldq_be_p. Signed-off-by: Philippe Mathieu-Daudé --- net/l2tpv3.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/net/l2tpv3.c b/net/l2tpv3.c index b5547cb917..7a0d5dcfe9 100644 --- a/net/l2tpv3.c +++ b/net/l2tpv3.c @@ -318,11 +318,7 @@ static int l2tpv3_verify_header(NetL2TPV3State *s, uint8_t *buf) */ if (s->cookie) { - if (s->cookie_is_64) { - cookie = ldq_be_p(buf + s->cookie_offset); - } else { - cookie = ldl_be_p(buf + s->cookie_offset) & 0xffffffffULL; - } + cookie = ldn_be_p(buf + s->cookie_offset, s->cookie_is_64 ? 8 : 4); if (cookie != s->rx_cookie) { if (!s->header_mismatch) { error_report("unknown cookie id");