From nobody Sun Feb 8 17:47:43 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 67C7CC6FD1D for ; Mon, 27 Mar 2023 22:46:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231717AbjC0WqS (ORCPT ); Mon, 27 Mar 2023 18:46:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229844AbjC0WqP (ORCPT ); Mon, 27 Mar 2023 18:46:15 -0400 Received: from thorn.bewilderbeest.net (thorn.bewilderbeest.net [IPv6:2605:2700:0:5::4713:9cab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C90FB1BE1 for ; Mon, 27 Mar 2023 15:46:14 -0700 (PDT) Received: from hatter.bewilderbeest.net (174-21-172-149.tukw.qwest.net [174.21.172.149]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: zev) by thorn.bewilderbeest.net (Postfix) with ESMTPSA id 5564E6E0; Mon, 27 Mar 2023 15:46:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bewilderbeest.net; s=thorn; t=1679957174; bh=L6bjh3nzL4FxrijRbntIGwR2Sk25I75O/1vW83a/498=; h=From:To:Cc:Subject:Date:From; b=jCYRA/ZjowslwnigucIbcVrhRDs3MlStV70ahHY9IK2AFPen/Tl02fwfd7LohvJ3F QjcbS7xr97W/NusH2F5kThyT4NzeL5Ebi5ewls0g//4GjSlvmE3Z9TARMQ2K8Sw7JI yhmsx45XSTHh84TbtgX0qTKjlg6s9PYzLyAFKikI= From: Zev Weiss To: Iwona Winiarska Cc: Zev Weiss , Andrew Jeffery , Joel Stanley , linux-arm-kernel@lists.infradead.org, linux-aspeed@lists.ozlabs.org, linux-kernel@vger.kernel.org, openbmc@lists.ozlabs.org Subject: [PATCH] peci: Constify struct peci_controller_ops Date: Mon, 27 Mar 2023 15:43:15 -0700 Message-Id: <20230327224315.11135-1-zev@bewilderbeest.net> X-Mailer: git-send-email 2.40.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" As with most ops structs, we never modify it at runtime, and keeping function pointers in read-only memory is generally a good thing security-wise. Signed-off-by: Zev Weiss Reviewed-by: Iwona Winiarska --- drivers/peci/controller/peci-aspeed.c | 2 +- drivers/peci/core.c | 4 ++-- include/linux/peci.h | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/peci/controller/peci-aspeed.c b/drivers/peci/controlle= r/peci-aspeed.c index 731c5d8f75c6..7fdc25afcf2f 100644 --- a/drivers/peci/controller/peci-aspeed.c +++ b/drivers/peci/controller/peci-aspeed.c @@ -468,7 +468,7 @@ static void aspeed_peci_property_setup(struct aspeed_pe= ci *priv) ASPEED_PECI_CMD_TIMEOUT_MS_DEFAULT, &priv->cmd_timeout_ms); } =20 -static struct peci_controller_ops aspeed_ops =3D { +static const struct peci_controller_ops aspeed_ops =3D { .xfer =3D aspeed_peci_xfer, }; =20 diff --git a/drivers/peci/core.c b/drivers/peci/core.c index 9c8cf07e51c7..0f83a9c6093b 100644 --- a/drivers/peci/core.c +++ b/drivers/peci/core.c @@ -44,7 +44,7 @@ int peci_controller_scan_devices(struct peci_controller *= controller) } =20 static struct peci_controller *peci_controller_alloc(struct device *dev, - struct peci_controller_ops *ops) + const struct peci_controller_ops *ops) { struct peci_controller *controller; int ret; @@ -113,7 +113,7 @@ static void unregister_controller(void *_controller) * Return: Pointer to the newly allocated controller or ERR_PTR() in case = of failure. */ struct peci_controller *devm_peci_controller_add(struct device *dev, - struct peci_controller_ops *ops) + const struct peci_controller_ops *ops) { struct peci_controller *controller; int ret; diff --git a/include/linux/peci.h b/include/linux/peci.h index 06e6ef935297..9b3d36aff431 100644 --- a/include/linux/peci.h +++ b/include/linux/peci.h @@ -42,13 +42,13 @@ struct peci_controller_ops { */ struct peci_controller { struct device dev; - struct peci_controller_ops *ops; + const struct peci_controller_ops *ops; struct mutex bus_lock; /* held for the duration of xfer */ u8 id; }; =20 struct peci_controller *devm_peci_controller_add(struct device *parent, - struct peci_controller_ops *ops); + const struct peci_controller_ops *ops); =20 static inline struct peci_controller *to_peci_controller(void *d) { --=20 2.40.0.5.gf6e3b97ba6d2.dirty