From patchwork Sat Jul 24 21:47:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 485570 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 17D26C432BE for ; Sat, 24 Jul 2021 21:48:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0146860E90 for ; Sat, 24 Jul 2021 21:48:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230370AbhGXVIL (ORCPT ); Sat, 24 Jul 2021 17:08:11 -0400 Received: from smtp-relay-canonical-1.canonical.com ([185.125.188.121]:43816 "EHLO smtp-relay-canonical-1.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229982AbhGXVHn (ORCPT ); Sat, 24 Jul 2021 17:07:43 -0400 Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-canonical-1.canonical.com (Postfix) with ESMTPS id F36083F351 for ; Sat, 24 Jul 2021 21:48:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1627163291; bh=ov7yn4H0ornXwxrX1ZBFt/XnbBsClxe6Xsh+B5h5Cag=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=BjN0/bNBaiaHopwYXYLf3BdjG40rIjk9OiBA7Am9VklfQ3JD2ee+x5ZgiGtm9KM4e ZGr56xLuygUtRzN0watEHfSjmWidd6bhi1OjPqrmaXrrFP6bLoCoY3aNLxbR0FWolR URPbx4ZSC6BfpiKJ+F5RjeMzt77v2q0Z68WUhR2bwXHCSgcqenbPm8BodLx5iU2xwZ iKxO3SeO6tuBN9TDHlX9GTtFq48aF8RTCJX3qBepy+BsFOvqsyOmUNMHl79PWrFBAX U3iaQKDuB3HOUnsJ2v5ziIEoGGHBZ/pzFEk8pWMu9gehaodnm7OTYnEjXOsI0Ds/en 6+WTOrTwW5a8A== Received: by mail-ej1-f71.google.com with SMTP id p6-20020a17090635c6b02904f7606bd58fso1063913ejb.11 for ; Sat, 24 Jul 2021 14:48:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ov7yn4H0ornXwxrX1ZBFt/XnbBsClxe6Xsh+B5h5Cag=; b=UZldUX0FJcvQIBMZiG5EsmeN1FkX6wqADM+JTGHH8TC2XYiqOdsRpk1POpvvFUe75Y 7BBg4P2gG1afoN14cQDLJDTaiORsAIiaIGauTCRcw/nJhpdbjDOdLOw05SnbCf/bVX1N MPOCjX94FS/NvydeuMX/92RMnX1e8wpckpelul+FNbjyQyChhBjjDIpwgrHERrh3ZowT d0IhoNRVKyDVy8wqnfXPWi000qLSkKfzdechzvjdkeoDxJ/k+F2g5dm+Sv8SWouEuRjy a5+tNa2k9oaks3wthY2mUpcxG21XyTit1Rs0Qfaj/41vtt5phHk0qjmppURs+i0bjMGo xgew== X-Gm-Message-State: AOAM532WZDxRObOcnmUz4rG7S7F2mw+LwFwiUqEpxjik9h6oKLnRnzuV I2K9/00YUQJVe/Vw0Bwed1+7Cnw2ivRImEXieixk3VySqG88ieqw5/xrHfg+kJV8O4Lxhu2ucqa RPL97c7nCOXi3MKUqCy4nckPnXLywbZdd/A== X-Received: by 2002:a17:906:5e4c:: with SMTP id b12mr10085421eju.230.1627163288266; Sat, 24 Jul 2021 14:48:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw4DjgiuYIHPq50fWezEY5ArO3iNlytrDP/udlFADjFqzzpxgUDWdNRebg5J3N9yopeTwgO0Q== X-Received: by 2002:a17:906:5e4c:: with SMTP id b12mr10085415eju.230.1627163288139; Sat, 24 Jul 2021 14:48:08 -0700 (PDT) Received: from localhost.localdomain ([86.32.47.9]) by smtp.gmail.com with ESMTPSA id j5sm8383005edv.10.2021.07.24.14.48.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Jul 2021 14:48:07 -0700 (PDT) From: Krzysztof Kozlowski To: Krzysztof Kozlowski , Charles Gorand , Krzysztof Opasiak , Mark Greer , Bongsu Jeon , "David S. Miller" , Jakub Kicinski , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-wireless@vger.kernel.org Subject: [PATCH 01/12] nfc: constify payload argument in nci_send_cmd() Date: Sat, 24 Jul 2021 23:47:32 +0200 Message-Id: <20210724214743.121884-2-krzysztof.kozlowski@canonical.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210724214743.121884-1-krzysztof.kozlowski@canonical.com> References: <20210724214743.121884-1-krzysztof.kozlowski@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The nci_send_cmd() payload argument is passed directly to skb_put_data() which already accepts a pointer to const, so make it const as well for correctness and safety. Signed-off-by: Krzysztof Kozlowski --- include/net/nfc/nci_core.h | 2 +- net/nfc/nci/core.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/net/nfc/nci_core.h b/include/net/nfc/nci_core.h index 1df0f8074c9d..bf573eca07ca 100644 --- a/include/net/nfc/nci_core.h +++ b/include/net/nfc/nci_core.h @@ -360,7 +360,7 @@ int nci_core_rsp_packet(struct nci_dev *ndev, __u16 opcode, int nci_core_ntf_packet(struct nci_dev *ndev, __u16 opcode, struct sk_buff *skb); void nci_rx_data_packet(struct nci_dev *ndev, struct sk_buff *skb); -int nci_send_cmd(struct nci_dev *ndev, __u16 opcode, __u8 plen, void *payload); +int nci_send_cmd(struct nci_dev *ndev, __u16 opcode, __u8 plen, const void *payload); int nci_send_data(struct nci_dev *ndev, __u8 conn_id, struct sk_buff *skb); int nci_conn_max_data_pkt_payload_size(struct nci_dev *ndev, __u8 conn_id); void nci_data_exchange_complete(struct nci_dev *ndev, struct sk_buff *skb, diff --git a/net/nfc/nci/core.c b/net/nfc/nci/core.c index da7fe9db1b00..09967b836361 100644 --- a/net/nfc/nci/core.c +++ b/net/nfc/nci/core.c @@ -1332,7 +1332,7 @@ int nci_send_frame(struct nci_dev *ndev, struct sk_buff *skb) EXPORT_SYMBOL(nci_send_frame); /* Send NCI command */ -int nci_send_cmd(struct nci_dev *ndev, __u16 opcode, __u8 plen, void *payload) +int nci_send_cmd(struct nci_dev *ndev, __u16 opcode, __u8 plen, const void *payload) { struct nci_ctrl_hdr *hdr; struct sk_buff *skb; From patchwork Sat Jul 24 21:47:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 485790 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9C3FEC4338F for ; Sat, 24 Jul 2021 21:48:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8141160E0C for ; Sat, 24 Jul 2021 21:48:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229549AbhGXVHo (ORCPT ); Sat, 24 Jul 2021 17:07:44 -0400 Received: from smtp-relay-canonical-1.canonical.com ([185.125.188.121]:43790 "EHLO smtp-relay-canonical-1.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229756AbhGXVHm (ORCPT ); Sat, 24 Jul 2021 17:07:42 -0400 Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-canonical-1.canonical.com (Postfix) with ESMTPS id F0F003F34A for ; Sat, 24 Jul 2021 21:48:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1627163291; bh=Cafb+vZCXBE2r3BRcaIZ4Rw/4xen96i9AebcqjRz32w=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ETov9SBDlfzMSbiFrBOkupRwtJuQl263c69IASFeJ0RlqiOcblqkBgL6KMXEcQrIF xFF2FurwjxSmqwV2UlowiyMt5vWQ+pEhBTAJaKVqzszYl8WKWo7dl/8DTk87YeVYex TwjjkO5iLiIRy5O86hBxFXN23zZe0kI9jle7/CCwGakkF0G3vB2vm7d6NBEVcnN+Rk li84F5RcBZi2W71p4hFhJ9pZZgMEBtZWKTet8SOtq0eMWej8wquIpA3uXCT5GNWqxW 8TXFxdy4VhBIqH8dVS/yaFRW1NiLK07/r6yQ8T4kiqYRd0AhSF9e5NmOpEfGjEuUIV nmCRrUDuijlWg== Received: by mail-ed1-f69.google.com with SMTP id c20-20020a0564021014b029039994f9cab9so2756869edu.22 for ; Sat, 24 Jul 2021 14:48:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Cafb+vZCXBE2r3BRcaIZ4Rw/4xen96i9AebcqjRz32w=; b=ruu1RZrAhzYi7GKoTkGGiQMIMX4W0wA0IxW0YAe3OTcVivZaOpZKdng6BHnJPLULvc yjxsbFHt91LJe5M4eJcx0nVu/C63u/0uXUSeCy9htEHWeSe8Zc8qCg+WtCGC55qldGEN zMi9ePyUolcY73hT733H3rXAp2AOsTgPkrff+ByDR/xLwaNxJXN21rx5HIR3AIy2M0WC RHt67CJa49aYPa1HYJagxPt5gOzkgc2yMCteuX2S2th90Y0cbtG7jAdRPSvzhw4z3IuQ kMCBPed0WriEXd45ZT9l6+mK18uNHxKC2c2RWX23BcFBDiAN1AdbMzLaPz3bciAhtS8D cHcQ== X-Gm-Message-State: AOAM53276AWS826CLvf1NTKHwJ0ehdFG8xom1tdn4kgPq+xL08E8aQ3C lweqSFPchq4tKzFuyjJXySu8xT38tOsoZuXpsK/KUOqBhz0MD62chm9oohN61OSE7VYA6yf5Ky4 bweFvc29C1v7AD61oX4cpTMPF+szJS2SJtg== X-Received: by 2002:a05:6402:1a3c:: with SMTP id be28mr13064451edb.15.1627163289663; Sat, 24 Jul 2021 14:48:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyFUM58aGKaHxO58kMsTBI7SVyFqHtKLuVZn+D1yBUPCbhbairNSRS8WTZxryZ7vHJNqJ3THg== X-Received: by 2002:a05:6402:1a3c:: with SMTP id be28mr13064438edb.15.1627163289515; Sat, 24 Jul 2021 14:48:09 -0700 (PDT) Received: from localhost.localdomain ([86.32.47.9]) by smtp.gmail.com with ESMTPSA id j5sm8383005edv.10.2021.07.24.14.48.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Jul 2021 14:48:09 -0700 (PDT) From: Krzysztof Kozlowski To: Krzysztof Kozlowski , Charles Gorand , Krzysztof Opasiak , Mark Greer , Bongsu Jeon , "David S. Miller" , Jakub Kicinski , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-wireless@vger.kernel.org Subject: [PATCH 02/12] nfc: constify nci_ops Date: Sat, 24 Jul 2021 23:47:33 +0200 Message-Id: <20210724214743.121884-3-krzysztof.kozlowski@canonical.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210724214743.121884-1-krzysztof.kozlowski@canonical.com> References: <20210724214743.121884-1-krzysztof.kozlowski@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The struct nci_ops is modified by NFC core in only one case: nci_allocate_device() receives too many proprietary commands (prop_ops) to configure. This is a build time known constrain, so a graceful handling of such case is not necessary. Instead, fail the nci_allocate_device() and add BUILD_BUG_ON() to places which set these. This allows to constify the struct nci_ops (consisting of function pointers) for correctness and safety. Signed-off-by: Krzysztof Kozlowski --- drivers/nfc/fdp/fdp.c | 3 ++- drivers/nfc/nfcmrvl/main.c | 2 +- drivers/nfc/nxp-nci/core.c | 2 +- drivers/nfc/st-nci/core.c | 3 ++- drivers/nfc/virtual_ncidev.c | 2 +- include/net/nfc/nci_core.h | 4 ++-- net/nfc/nci/core.c | 5 ++--- 7 files changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/nfc/fdp/fdp.c b/drivers/nfc/fdp/fdp.c index 528745862738..73f51848a693 100644 --- a/drivers/nfc/fdp/fdp.c +++ b/drivers/nfc/fdp/fdp.c @@ -675,7 +675,7 @@ static struct nci_driver_ops fdp_prop_ops[] = { }, }; -static struct nci_ops nci_ops = { +static const struct nci_ops nci_ops = { .open = fdp_nci_open, .close = fdp_nci_close, .send = fdp_nci_send, @@ -718,6 +718,7 @@ int fdp_nci_probe(struct fdp_i2c_phy *phy, struct nfc_phy_ops *phy_ops, NFC_PROTO_NFC_DEP_MASK | NFC_PROTO_ISO15693_MASK; + BUILD_BUG_ON(ARRAY_SIZE(fdp_prop_ops) > NCI_MAX_PROPRIETARY_CMD); ndev = nci_allocate_device(&nci_ops, protocols, tx_headroom, tx_tailroom); if (!ndev) { diff --git a/drivers/nfc/nfcmrvl/main.c b/drivers/nfc/nfcmrvl/main.c index a4620b480c4f..6e9e7ce8792c 100644 --- a/drivers/nfc/nfcmrvl/main.c +++ b/drivers/nfc/nfcmrvl/main.c @@ -81,7 +81,7 @@ static int nfcmrvl_nci_fw_download(struct nci_dev *ndev, return nfcmrvl_fw_dnld_start(ndev, firmware_name); } -static struct nci_ops nfcmrvl_nci_ops = { +static const struct nci_ops nfcmrvl_nci_ops = { .open = nfcmrvl_nci_open, .close = nfcmrvl_nci_close, .send = nfcmrvl_nci_send, diff --git a/drivers/nfc/nxp-nci/core.c b/drivers/nfc/nxp-nci/core.c index 2b0c7232e91f..518e2afb43a8 100644 --- a/drivers/nfc/nxp-nci/core.c +++ b/drivers/nfc/nxp-nci/core.c @@ -83,7 +83,7 @@ static int nxp_nci_send(struct nci_dev *ndev, struct sk_buff *skb) return r; } -static struct nci_ops nxp_nci_ops = { +static const struct nci_ops nxp_nci_ops = { .open = nxp_nci_open, .close = nxp_nci_close, .send = nxp_nci_send, diff --git a/drivers/nfc/st-nci/core.c b/drivers/nfc/st-nci/core.c index 110ff1281e5f..f6fce34a77da 100644 --- a/drivers/nfc/st-nci/core.c +++ b/drivers/nfc/st-nci/core.c @@ -94,7 +94,7 @@ static struct nci_driver_ops st_nci_prop_ops[] = { }, }; -static struct nci_ops st_nci_ops = { +static const struct nci_ops st_nci_ops = { .init = st_nci_init, .open = st_nci_open, .close = st_nci_close, @@ -131,6 +131,7 @@ int st_nci_probe(struct llt_ndlc *ndlc, int phy_headroom, | NFC_PROTO_ISO15693_MASK | NFC_PROTO_NFC_DEP_MASK; + BUILD_BUG_ON(ARRAY_SIZE(st_nci_prop_ops) > NCI_MAX_PROPRIETARY_CMD); ndlc->ndev = nci_allocate_device(&st_nci_ops, protocols, phy_headroom, phy_tailroom); if (!ndlc->ndev) { diff --git a/drivers/nfc/virtual_ncidev.c b/drivers/nfc/virtual_ncidev.c index f73ee0bf3593..b914ab2c2109 100644 --- a/drivers/nfc/virtual_ncidev.c +++ b/drivers/nfc/virtual_ncidev.c @@ -65,7 +65,7 @@ static int virtual_nci_send(struct nci_dev *ndev, struct sk_buff *skb) return 0; } -static struct nci_ops virtual_nci_ops = { +static const struct nci_ops virtual_nci_ops = { .open = virtual_nci_open, .close = virtual_nci_close, .send = virtual_nci_send diff --git a/include/net/nfc/nci_core.h b/include/net/nfc/nci_core.h index bf573eca07ca..5dae7e2cbc49 100644 --- a/include/net/nfc/nci_core.h +++ b/include/net/nfc/nci_core.h @@ -194,7 +194,7 @@ struct nci_hci_dev { /* NCI Core structures */ struct nci_dev { struct nfc_dev *nfc_dev; - struct nci_ops *ops; + const struct nci_ops *ops; struct nci_hci_dev *hci_dev; int tx_headroom; @@ -267,7 +267,7 @@ struct nci_dev { }; /* ----- NCI Devices ----- */ -struct nci_dev *nci_allocate_device(struct nci_ops *ops, +struct nci_dev *nci_allocate_device(const struct nci_ops *ops, __u32 supported_protocols, int tx_headroom, int tx_tailroom); diff --git a/net/nfc/nci/core.c b/net/nfc/nci/core.c index 09967b836361..a7d26f2791b0 100644 --- a/net/nfc/nci/core.c +++ b/net/nfc/nci/core.c @@ -1129,7 +1129,7 @@ static struct nfc_ops nci_nfc_ops = { * @tx_headroom: Reserved space at beginning of skb * @tx_tailroom: Reserved space at end of skb */ -struct nci_dev *nci_allocate_device(struct nci_ops *ops, +struct nci_dev *nci_allocate_device(const struct nci_ops *ops, __u32 supported_protocols, int tx_headroom, int tx_tailroom) { @@ -1152,8 +1152,7 @@ struct nci_dev *nci_allocate_device(struct nci_ops *ops, if (ops->n_prop_ops > NCI_MAX_PROPRIETARY_CMD) { pr_err("Too many proprietary commands: %zd\n", ops->n_prop_ops); - ops->prop_ops = NULL; - ops->n_prop_ops = 0; + goto free_nci; } ndev->tx_headroom = tx_headroom; From patchwork Sat Jul 24 21:47:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 485788 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D253CC4338F for ; Sat, 24 Jul 2021 21:49:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BE3E160E90 for ; Sat, 24 Jul 2021 21:49:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229931AbhGXVIj (ORCPT ); Sat, 24 Jul 2021 17:08:39 -0400 Received: from smtp-relay-canonical-0.canonical.com ([185.125.188.120]:58412 "EHLO smtp-relay-canonical-0.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229971AbhGXVHn (ORCPT ); Sat, 24 Jul 2021 17:07:43 -0400 Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-canonical-0.canonical.com (Postfix) with ESMTPS id 04A3D3F35B for ; Sat, 24 Jul 2021 21:48:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1627163292; bh=HMf7kqYi2lIBuMtdvTj3OQjTri7oTHLzgmpSExYTBzw=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=f6M8baFGvdeMwcUPfGXvnxECTTzTmXEnXNhdEP6r2KHsqEalNMz2I9tmdrQNTQc1W 8na6i1lE4XHUFDQZQ3WJdBccwGYzK2ClaCSo1XO/M5JU07U66I4NhFlHeRIjQzpZRR vKDLwUDNeJ+iIjgZ6Mz3/qWDkJS3u9V9bsj/4p/GlKvoum81qGOdALiMbI4Jhc1b5c vbjddqGPnngMD+onevXfpkDWs4N00iPpIl5D5KS1dEBihw1ET2VlHbzOHSUsUlrNw9 mYPxg/lRUaQ8/R1oZTzKt8mnDJCGyGiZo7W6bY5Hc/SRcDCL63b0zpfiCODSCSaj6Q mmlpNHTnIWLtw== Received: by mail-ej1-f69.google.com with SMTP id a19-20020a1709063e93b0290551ea218ea2so1081838ejj.5 for ; Sat, 24 Jul 2021 14:48:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=HMf7kqYi2lIBuMtdvTj3OQjTri7oTHLzgmpSExYTBzw=; b=P+t9D8vQz7C2ur+mWJyVz00QJ+b9Fg8BQLrQdNRFFTbIWeqzK7keja71ZZgV0JK7o3 PZiZa7NHlqzSvXG9++KxFxSjiyXAZtxf525qrp3VTUz9pJ0MiMlgUfSeIka/Mowub28o DQW7NsLZZQGpaJQCwN30cxY8K0fQwuftoYJP0POTtGlUoPNb4ZFsEGdAr3klhJVeJmJ9 yvPv5xTB6gwBTWbbmY8TGyrzRH0tH4gc4jL1tUP3iK6eQYdETUoyCQvEW4Qa/XIyHaQx FNRnc02vNCw+IfPze1NPM6mzkn5BJ8n2fQ6VOJiTeEwpQmeqsfszyxBBXvuZnrSPP4vF nkrQ== X-Gm-Message-State: AOAM531lHGYhTqjxZhz2Bk9O5AZtL3MGuIevMwJuI7yNICV0P1A7l1fW IbiWRbkFbp0ngWOMM6zTuT+hNmQrxsvrC2Jq94QpN4+qjrMX+yaSLo1MU3adtSORNLeGW6XN7RD wlcTupA1Fh7croxJGQjvK7xIV8Dm8cx4uig== X-Received: by 2002:a50:8a89:: with SMTP id j9mr12845879edj.226.1627163291308; Sat, 24 Jul 2021 14:48:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwd4RK7rN/a4XS7Agkz5BbHQ1x3eZGsYYyx6EQXs4h6bYFyxMm86+u03VzFoh6LPSZbpiQ4BQ== X-Received: by 2002:a50:8a89:: with SMTP id j9mr12845871edj.226.1627163291195; Sat, 24 Jul 2021 14:48:11 -0700 (PDT) Received: from localhost.localdomain ([86.32.47.9]) by smtp.gmail.com with ESMTPSA id j5sm8383005edv.10.2021.07.24.14.48.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Jul 2021 14:48:10 -0700 (PDT) From: Krzysztof Kozlowski To: Krzysztof Kozlowski , Charles Gorand , Krzysztof Opasiak , Mark Greer , Bongsu Jeon , "David S. Miller" , Jakub Kicinski , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-wireless@vger.kernel.org Subject: [PATCH 03/12] nfc: s3fwrn5: constify nci_ops Date: Sat, 24 Jul 2021 23:47:34 +0200 Message-Id: <20210724214743.121884-4-krzysztof.kozlowski@canonical.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210724214743.121884-1-krzysztof.kozlowski@canonical.com> References: <20210724214743.121884-1-krzysztof.kozlowski@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org s3fwrn5 driver modifies static struct nci_ops only to set prop_ops. Since prop_ops is build time constant with known size, it can be made const. This allows to removeo the function setting the prop_ops - s3fwrn5_nci_get_prop_ops(). Signed-off-by: Krzysztof Kozlowski --- drivers/nfc/s3fwrn5/core.c | 7 +++---- drivers/nfc/s3fwrn5/nci.c | 8 +------- drivers/nfc/s3fwrn5/nci.h | 2 +- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/drivers/nfc/s3fwrn5/core.c b/drivers/nfc/s3fwrn5/core.c index 865d3e3d1528..1c412007fabb 100644 --- a/drivers/nfc/s3fwrn5/core.c +++ b/drivers/nfc/s3fwrn5/core.c @@ -143,11 +143,13 @@ static int s3fwrn5_nci_post_setup(struct nci_dev *ndev) return nci_core_init(info->ndev); } -static struct nci_ops s3fwrn5_nci_ops = { +static const struct nci_ops s3fwrn5_nci_ops = { .open = s3fwrn5_nci_open, .close = s3fwrn5_nci_close, .send = s3fwrn5_nci_send, .post_setup = s3fwrn5_nci_post_setup, + .prop_ops = s3fwrn5_nci_prop_ops, + .n_prop_ops = ARRAY_SIZE(s3fwrn5_nci_prop_ops), }; int s3fwrn5_probe(struct nci_dev **ndev, void *phy_id, struct device *pdev, @@ -167,9 +169,6 @@ int s3fwrn5_probe(struct nci_dev **ndev, void *phy_id, struct device *pdev, s3fwrn5_set_mode(info, S3FWRN5_MODE_COLD); - s3fwrn5_nci_get_prop_ops(&s3fwrn5_nci_ops.prop_ops, - &s3fwrn5_nci_ops.n_prop_ops); - info->ndev = nci_allocate_device(&s3fwrn5_nci_ops, S3FWRN5_NFC_PROTOCOLS, 0, 0); if (!info->ndev) diff --git a/drivers/nfc/s3fwrn5/nci.c b/drivers/nfc/s3fwrn5/nci.c index f042d3eaf8f6..819e3474a437 100644 --- a/drivers/nfc/s3fwrn5/nci.c +++ b/drivers/nfc/s3fwrn5/nci.c @@ -20,7 +20,7 @@ static int s3fwrn5_nci_prop_rsp(struct nci_dev *ndev, struct sk_buff *skb) return 0; } -static struct nci_driver_ops s3fwrn5_nci_prop_ops[] = { +struct nci_driver_ops s3fwrn5_nci_prop_ops[4] = { { .opcode = nci_opcode_pack(NCI_GID_PROPRIETARY, NCI_PROP_SET_RFREG), @@ -43,12 +43,6 @@ static struct nci_driver_ops s3fwrn5_nci_prop_ops[] = { }, }; -void s3fwrn5_nci_get_prop_ops(struct nci_driver_ops **ops, size_t *n) -{ - *ops = s3fwrn5_nci_prop_ops; - *n = ARRAY_SIZE(s3fwrn5_nci_prop_ops); -} - #define S3FWRN5_RFREG_SECTION_SIZE 252 int s3fwrn5_nci_rf_configure(struct s3fwrn5_info *info, const char *fw_name) diff --git a/drivers/nfc/s3fwrn5/nci.h b/drivers/nfc/s3fwrn5/nci.h index a80f0fb082a8..5c22c5315f79 100644 --- a/drivers/nfc/s3fwrn5/nci.h +++ b/drivers/nfc/s3fwrn5/nci.h @@ -50,7 +50,7 @@ struct nci_prop_fw_cfg_rsp { __u8 status; }; -void s3fwrn5_nci_get_prop_ops(struct nci_driver_ops **ops, size_t *n); +extern struct nci_driver_ops s3fwrn5_nci_prop_ops[4]; int s3fwrn5_nci_rf_configure(struct s3fwrn5_info *info, const char *fw_name); #endif /* __LOCAL_S3FWRN5_NCI_H_ */ From patchwork Sat Jul 24 21:47:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 485571 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3136CC4338F for ; Sat, 24 Jul 2021 21:48:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 18C7960E0C for ; Sat, 24 Jul 2021 21:48:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230133AbhGXVIH (ORCPT ); Sat, 24 Jul 2021 17:08:07 -0400 Received: from smtp-relay-canonical-0.canonical.com ([185.125.188.120]:58424 "EHLO smtp-relay-canonical-0.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229588AbhGXVHo (ORCPT ); Sat, 24 Jul 2021 17:07:44 -0400 Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-canonical-0.canonical.com (Postfix) with ESMTPS id 18C453F365 for ; Sat, 24 Jul 2021 21:48:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1627163293; bh=UnOWzB6PFujT/DWlS5nVosxLJqokbjOw4vZz2zLdo+w=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=qXJ8r3xxM1+s/NnrNkC51L8YBOq1NF1HGPkzjHxG8FVxQ+FKW0JhEuFF/SEXfIZDp 5OFKL12bkxnmMR0nUxzZetMWgZEk9aKmE7W4f5R1QEyYx73vzVYYGtA38wJRpARfDl F21OKIQCy4tyfta56eqVzdbjo+onXzpAXlAO2yQ4ijIPKqF581LvoN3PPbsoySlKCe vl6TOfQivgiW8LxPcmra0/bINoJb5oayf7coWW4L0eBSOrjiYF/Iq6jK2CmE40xfHz pTOYECFdO+YY6H3RMNYUHHZ8JLSCc3mOyRgFmPpYLvQNmWpb8k+/jsXIYrqOyRGqW4 t3PkfKlYAQB5g== Received: by mail-ed1-f70.google.com with SMTP id b13-20020a056402278db029039c013d5b80so2803368ede.7 for ; Sat, 24 Jul 2021 14:48:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=UnOWzB6PFujT/DWlS5nVosxLJqokbjOw4vZz2zLdo+w=; b=gKeBXk582FNSSaBQwlTnbxfs8hJ6CssSD+qqHMosKw/5DwuGJ+XoY3Y/r/gmQ9cATH CpSHR18SwvIpWaGDSQLn8Qf+H6mdAlwbb4rXjLR/S1NFk8TbPtNGIKwXJTe58xlxd9z/ ZQze3VOZyjqMKmHAw2ggnU/xGKkhWhEO6nfo3RRlx3B7P64DktIxpBVM2gtqzcnPf6WI C6W6J9hjpnUa3B3oZdn2AsQ4oO7443PLExWRxA01BpAnFzGxzAeJA75gXATPyHde20ST L0VRJrrmmH5rXYdLwbv08onDn0V4vnPzA1r84Eo7YS0z+GE1sbe6ZWhs/lWjimuQwSJU +sWg== X-Gm-Message-State: AOAM530HHTlYV9oxKfoe0Zx25cb5ZPJt0BGBbdUe2c29HzzlpiyrXMua m2XXUi3bO6lhxmozKaJxqx66RcyeDyNg4FaOwySNMBWBpHFH3nmQGoyRzGEbAxC0qE7DYMKFAVZ xN5qXW4xfkftJBMoXIVJPoIQz7Pc2CXXpMQ== X-Received: by 2002:a17:906:f15:: with SMTP id z21mr10466741eji.177.1627163292622; Sat, 24 Jul 2021 14:48:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwcC7JbUplW/EECe6Pj5DymoKEbtDHlyJUdE09NwDpBM4vPpQiH5q7A9qSREZv1RYkK2nQ3Kg== X-Received: by 2002:a17:906:f15:: with SMTP id z21mr10466728eji.177.1627163292493; Sat, 24 Jul 2021 14:48:12 -0700 (PDT) Received: from localhost.localdomain ([86.32.47.9]) by smtp.gmail.com with ESMTPSA id j5sm8383005edv.10.2021.07.24.14.48.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Jul 2021 14:48:12 -0700 (PDT) From: Krzysztof Kozlowski To: Krzysztof Kozlowski , Charles Gorand , Krzysztof Opasiak , Mark Greer , Bongsu Jeon , "David S. Miller" , Jakub Kicinski , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-wireless@vger.kernel.org Subject: [PATCH 04/12] nfc: constify nci_driver_ops (prop_ops and core_ops) Date: Sat, 24 Jul 2021 23:47:35 +0200 Message-Id: <20210724214743.121884-5-krzysztof.kozlowski@canonical.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210724214743.121884-1-krzysztof.kozlowski@canonical.com> References: <20210724214743.121884-1-krzysztof.kozlowski@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Neither the core nor the drivers modify the passed pointer to struct nci_driver_ops (consisting of function pointers), so make it a pointer to const for correctness and safety. Signed-off-by: Krzysztof Kozlowski --- drivers/nfc/fdp/fdp.c | 4 ++-- drivers/nfc/s3fwrn5/nci.c | 2 +- drivers/nfc/s3fwrn5/nci.h | 2 +- drivers/nfc/st-nci/core.c | 2 +- include/net/nfc/nci_core.h | 4 ++-- net/nfc/nci/core.c | 16 ++++++++-------- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/drivers/nfc/fdp/fdp.c b/drivers/nfc/fdp/fdp.c index 73f51848a693..4d88a617d0e8 100644 --- a/drivers/nfc/fdp/fdp.c +++ b/drivers/nfc/fdp/fdp.c @@ -651,7 +651,7 @@ static int fdp_nci_core_get_config_rsp_packet(struct nci_dev *ndev, return 0; } -static struct nci_driver_ops fdp_core_ops[] = { +static const struct nci_driver_ops fdp_core_ops[] = { { .opcode = NCI_OP_CORE_GET_CONFIG_RSP, .rsp = fdp_nci_core_get_config_rsp_packet, @@ -662,7 +662,7 @@ static struct nci_driver_ops fdp_core_ops[] = { }, }; -static struct nci_driver_ops fdp_prop_ops[] = { +static const struct nci_driver_ops fdp_prop_ops[] = { { .opcode = nci_opcode_pack(NCI_GID_PROP, NCI_OP_PROP_PATCH_OID), .rsp = fdp_nci_prop_patch_rsp_packet, diff --git a/drivers/nfc/s3fwrn5/nci.c b/drivers/nfc/s3fwrn5/nci.c index 819e3474a437..e374e670b36b 100644 --- a/drivers/nfc/s3fwrn5/nci.c +++ b/drivers/nfc/s3fwrn5/nci.c @@ -20,7 +20,7 @@ static int s3fwrn5_nci_prop_rsp(struct nci_dev *ndev, struct sk_buff *skb) return 0; } -struct nci_driver_ops s3fwrn5_nci_prop_ops[4] = { +const struct nci_driver_ops s3fwrn5_nci_prop_ops[4] = { { .opcode = nci_opcode_pack(NCI_GID_PROPRIETARY, NCI_PROP_SET_RFREG), diff --git a/drivers/nfc/s3fwrn5/nci.h b/drivers/nfc/s3fwrn5/nci.h index 5c22c5315f79..c2d906591e9e 100644 --- a/drivers/nfc/s3fwrn5/nci.h +++ b/drivers/nfc/s3fwrn5/nci.h @@ -50,7 +50,7 @@ struct nci_prop_fw_cfg_rsp { __u8 status; }; -extern struct nci_driver_ops s3fwrn5_nci_prop_ops[4]; +extern const struct nci_driver_ops s3fwrn5_nci_prop_ops[4]; int s3fwrn5_nci_rf_configure(struct s3fwrn5_info *info, const char *fw_name); #endif /* __LOCAL_S3FWRN5_NCI_H_ */ diff --git a/drivers/nfc/st-nci/core.c b/drivers/nfc/st-nci/core.c index f6fce34a77da..72bb51efdf9c 100644 --- a/drivers/nfc/st-nci/core.c +++ b/drivers/nfc/st-nci/core.c @@ -86,7 +86,7 @@ static int st_nci_prop_rsp_packet(struct nci_dev *ndev, return 0; } -static struct nci_driver_ops st_nci_prop_ops[] = { +static const struct nci_driver_ops st_nci_prop_ops[] = { { .opcode = nci_opcode_pack(NCI_GID_PROPRIETARY, ST_NCI_CORE_PROP), diff --git a/include/net/nfc/nci_core.h b/include/net/nfc/nci_core.h index 5dae7e2cbc49..e7118e0cc3b1 100644 --- a/include/net/nfc/nci_core.h +++ b/include/net/nfc/nci_core.h @@ -82,10 +82,10 @@ struct nci_ops { void (*hci_cmd_received)(struct nci_dev *ndev, u8 pipe, u8 cmd, struct sk_buff *skb); - struct nci_driver_ops *prop_ops; + const struct nci_driver_ops *prop_ops; size_t n_prop_ops; - struct nci_driver_ops *core_ops; + const struct nci_driver_ops *core_ops; size_t n_core_ops; }; diff --git a/net/nfc/nci/core.c b/net/nfc/nci/core.c index a7d26f2791b0..50c625940fa3 100644 --- a/net/nfc/nci/core.c +++ b/net/nfc/nci/core.c @@ -1363,12 +1363,12 @@ int nci_send_cmd(struct nci_dev *ndev, __u16 opcode, __u8 plen, const void *payl EXPORT_SYMBOL(nci_send_cmd); /* Proprietary commands API */ -static struct nci_driver_ops *ops_cmd_lookup(struct nci_driver_ops *ops, - size_t n_ops, - __u16 opcode) +static const struct nci_driver_ops *ops_cmd_lookup(const struct nci_driver_ops *ops, + size_t n_ops, + __u16 opcode) { size_t i; - struct nci_driver_ops *op; + const struct nci_driver_ops *op; if (!ops || !n_ops) return NULL; @@ -1383,10 +1383,10 @@ static struct nci_driver_ops *ops_cmd_lookup(struct nci_driver_ops *ops, } static int nci_op_rsp_packet(struct nci_dev *ndev, __u16 rsp_opcode, - struct sk_buff *skb, struct nci_driver_ops *ops, + struct sk_buff *skb, const struct nci_driver_ops *ops, size_t n_ops) { - struct nci_driver_ops *op; + const struct nci_driver_ops *op; op = ops_cmd_lookup(ops, n_ops, rsp_opcode); if (!op || !op->rsp) @@ -1396,10 +1396,10 @@ static int nci_op_rsp_packet(struct nci_dev *ndev, __u16 rsp_opcode, } static int nci_op_ntf_packet(struct nci_dev *ndev, __u16 ntf_opcode, - struct sk_buff *skb, struct nci_driver_ops *ops, + struct sk_buff *skb, const struct nci_driver_ops *ops, size_t n_ops) { - struct nci_driver_ops *op; + const struct nci_driver_ops *op; op = ops_cmd_lookup(ops, n_ops, ntf_opcode); if (!op || !op->ntf) From patchwork Sat Jul 24 21:47:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 485789 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D05E3C4320A for ; Sat, 24 Jul 2021 21:48:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B9B6B60E92 for ; Sat, 24 Jul 2021 21:48:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230340AbhGXVIJ (ORCPT ); Sat, 24 Jul 2021 17:08:09 -0400 Received: from smtp-relay-canonical-1.canonical.com ([185.125.188.121]:43822 "EHLO smtp-relay-canonical-1.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230037AbhGXVHn (ORCPT ); Sat, 24 Jul 2021 17:07:43 -0400 Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-canonical-1.canonical.com (Postfix) with ESMTPS id 5F27D3F34F for ; Sat, 24 Jul 2021 21:48:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1627163294; bh=TRvw0HQBwkRWiCVdnew4mISwB8bEYreQOGEzMw+3FDE=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Uwl9yb5XfzSQu3st/zKdkLRMQrM9b2gtitzKKHjz3H37JtbglJxFS29wbwaU1bxMP Jxto/eWpc0EELuGAkAQWN1bnVjLKsquNxOz3uE02DjaIbLtSpUWaS/3fWEWLqBfl9p ejXYlGILw1js32tzB+g4VlFWHqI102sLRriNEnWpmR69eQmtYoyk9DQmG0laftEvRq w6FVDiTACZpK3eficWa3+gxmsa/RGwb8X6sw39WBbDY7WFuSfkp7m84Ecz0IG14K1k 0E1EhKPRB6O0NpNWYmi4+7CTt47VqjkwI5Pmo7dLP5xMoQRKamFNfyBHgtwGu1F4gm xILqELMaS6oPQ== Received: by mail-ed1-f69.google.com with SMTP id u25-20020aa7d8990000b02903bb6a903d90so3137edq.17 for ; Sat, 24 Jul 2021 14:48:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TRvw0HQBwkRWiCVdnew4mISwB8bEYreQOGEzMw+3FDE=; b=VadzLDZkpBgBgSqlct3UqCvNIHtlr8t9+F4OTOj5A+OYLyFiFk7DPZqfLQe5n0kAbA njlOC/b01r72QhGHD1pBs3/I9jE5ShDMT2RCn/kGuQLZ9r+Bo06YweDurGScf9NpOcK7 T6y55u4Spy0B200Bi0MdgJGc7SDDGVHuBmSmSMWBnurg1p5uMUuZ+DMEA1CjWnNqEFO7 mR3kZDv3jZ2HMDfTN52WAD5ciC367kMoCOyguAIbfG+APjI6bjdv4CwZUn+4GX48OPT1 nUfwPmNMrX6Q8McIMM+AZmX39HDQp6KOMzt+cYViVimuerIHAmDJuASvTLzFtf9UrUjt sgDw== X-Gm-Message-State: AOAM533gYxQsECgL1rlvbQJitvMKgxGVZZNcSDqZvU6SmAj2DCnHJUhe Z4yY99Z77aic6j9ingHsm8Vm3OXPYNf2CyIyMjGD25uopUs81a8YnsBlFWbUrgXN9/BucNN37bn 3ZeiwV3tRQXFCYcusSXkenw+LBTn15s1CsA== X-Received: by 2002:aa7:dcc5:: with SMTP id w5mr13195993edu.355.1627163293903; Sat, 24 Jul 2021 14:48:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJydqlPQsnsgxgUFeE4aqnx+klbnZbZjTRdJ6m+Vh6/VUS7hHDK60X6grtI4ap93g2wZMDIlsQ== X-Received: by 2002:aa7:dcc5:: with SMTP id w5mr13195980edu.355.1627163293682; Sat, 24 Jul 2021 14:48:13 -0700 (PDT) Received: from localhost.localdomain ([86.32.47.9]) by smtp.gmail.com with ESMTPSA id j5sm8383005edv.10.2021.07.24.14.48.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Jul 2021 14:48:13 -0700 (PDT) From: Krzysztof Kozlowski To: Krzysztof Kozlowski , Charles Gorand , Krzysztof Opasiak , Mark Greer , Bongsu Jeon , "David S. Miller" , Jakub Kicinski , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-wireless@vger.kernel.org Subject: [PATCH 05/12] nfc: constify nfc_phy_ops Date: Sat, 24 Jul 2021 23:47:36 +0200 Message-Id: <20210724214743.121884-6-krzysztof.kozlowski@canonical.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210724214743.121884-1-krzysztof.kozlowski@canonical.com> References: <20210724214743.121884-1-krzysztof.kozlowski@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Neither the core nor the drivers modify the passed pointer to struct nfc_phy_ops (consisting of function pointers), so make it a pointer to const for correctness and safety. Signed-off-by: Krzysztof Kozlowski --- drivers/nfc/fdp/fdp.c | 4 ++-- drivers/nfc/fdp/fdp.h | 2 +- drivers/nfc/fdp/i2c.c | 2 +- drivers/nfc/mei_phy.c | 2 +- drivers/nfc/mei_phy.h | 2 +- drivers/nfc/microread/i2c.c | 2 +- drivers/nfc/microread/microread.c | 8 ++++---- drivers/nfc/microread/microread.h | 6 +++--- drivers/nfc/pn544/i2c.c | 2 +- drivers/nfc/pn544/pn544.c | 9 +++++---- drivers/nfc/pn544/pn544.h | 7 ++++--- drivers/nfc/st-nci/i2c.c | 2 +- drivers/nfc/st-nci/ndlc.c | 6 +++--- drivers/nfc/st-nci/ndlc.h | 8 ++++---- drivers/nfc/st-nci/spi.c | 2 +- drivers/nfc/st21nfca/core.c | 2 +- drivers/nfc/st21nfca/i2c.c | 2 +- drivers/nfc/st21nfca/st21nfca.h | 4 ++-- 18 files changed, 37 insertions(+), 35 deletions(-) diff --git a/drivers/nfc/fdp/fdp.c b/drivers/nfc/fdp/fdp.c index 4d88a617d0e8..3e542b7389cb 100644 --- a/drivers/nfc/fdp/fdp.c +++ b/drivers/nfc/fdp/fdp.c @@ -38,7 +38,7 @@ #define NCI_OP_PROP_SET_PDATA_OID 0x23 struct fdp_nci_info { - struct nfc_phy_ops *phy_ops; + const struct nfc_phy_ops *phy_ops; struct fdp_i2c_phy *phy; struct nci_dev *ndev; @@ -687,7 +687,7 @@ static const struct nci_ops nci_ops = { .n_core_ops = ARRAY_SIZE(fdp_core_ops), }; -int fdp_nci_probe(struct fdp_i2c_phy *phy, struct nfc_phy_ops *phy_ops, +int fdp_nci_probe(struct fdp_i2c_phy *phy, const struct nfc_phy_ops *phy_ops, struct nci_dev **ndevp, int tx_headroom, int tx_tailroom, u8 clock_type, u32 clock_freq, u8 *fw_vsc_cfg) diff --git a/drivers/nfc/fdp/fdp.h b/drivers/nfc/fdp/fdp.h index ead3b21ccae6..dc048d4b977e 100644 --- a/drivers/nfc/fdp/fdp.h +++ b/drivers/nfc/fdp/fdp.h @@ -21,7 +21,7 @@ struct fdp_i2c_phy { uint16_t next_read_size; }; -int fdp_nci_probe(struct fdp_i2c_phy *phy, struct nfc_phy_ops *phy_ops, +int fdp_nci_probe(struct fdp_i2c_phy *phy, const struct nfc_phy_ops *phy_ops, struct nci_dev **ndev, int tx_headroom, int tx_tailroom, u8 clock_type, u32 clock_freq, u8 *fw_vsc_cfg); void fdp_nci_remove(struct nci_dev *ndev); diff --git a/drivers/nfc/fdp/i2c.c b/drivers/nfc/fdp/i2c.c index c5596e514648..98e1876c9468 100644 --- a/drivers/nfc/fdp/i2c.c +++ b/drivers/nfc/fdp/i2c.c @@ -120,7 +120,7 @@ static int fdp_nci_i2c_write(void *phy_id, struct sk_buff *skb) return r; } -static struct nfc_phy_ops i2c_phy_ops = { +static const struct nfc_phy_ops i2c_phy_ops = { .write = fdp_nci_i2c_write, .enable = fdp_nci_i2c_enable, .disable = fdp_nci_i2c_disable, diff --git a/drivers/nfc/mei_phy.c b/drivers/nfc/mei_phy.c index e56cea716cd2..41146bb99474 100644 --- a/drivers/nfc/mei_phy.c +++ b/drivers/nfc/mei_phy.c @@ -362,7 +362,7 @@ static void nfc_mei_phy_disable(void *phy_id) phy->powered = 0; } -struct nfc_phy_ops mei_phy_ops = { +const struct nfc_phy_ops mei_phy_ops = { .write = nfc_mei_phy_write, .enable = nfc_mei_phy_enable, .disable = nfc_mei_phy_disable, diff --git a/drivers/nfc/mei_phy.h b/drivers/nfc/mei_phy.h index 51bd44f5f3b8..2b1edb3eba15 100644 --- a/drivers/nfc/mei_phy.h +++ b/drivers/nfc/mei_phy.h @@ -45,7 +45,7 @@ struct nfc_mei_phy { int hard_fault; }; -extern struct nfc_phy_ops mei_phy_ops; +extern const struct nfc_phy_ops mei_phy_ops; struct nfc_mei_phy *nfc_mei_phy_alloc(struct mei_cl_device *device); void nfc_mei_phy_free(struct nfc_mei_phy *phy); diff --git a/drivers/nfc/microread/i2c.c b/drivers/nfc/microread/i2c.c index dd78d987e6c9..f91760c78455 100644 --- a/drivers/nfc/microread/i2c.c +++ b/drivers/nfc/microread/i2c.c @@ -225,7 +225,7 @@ static irqreturn_t microread_i2c_irq_thread_fn(int irq, void *phy_id) return IRQ_HANDLED; } -static struct nfc_phy_ops i2c_phy_ops = { +static const struct nfc_phy_ops i2c_phy_ops = { .write = microread_i2c_write, .enable = microread_i2c_enable, .disable = microread_i2c_disable, diff --git a/drivers/nfc/microread/microread.c b/drivers/nfc/microread/microread.c index b1d3975e8a81..a5d5c3ec65f9 100644 --- a/drivers/nfc/microread/microread.c +++ b/drivers/nfc/microread/microread.c @@ -152,7 +152,7 @@ static struct nfc_hci_gate microread_gates[] = { #define MICROREAD_CMD_TAILROOM 2 struct microread_info { - struct nfc_phy_ops *phy_ops; + const struct nfc_phy_ops *phy_ops; void *phy_id; struct nfc_hci_dev *hdev; @@ -641,9 +641,9 @@ static struct nfc_hci_ops microread_hci_ops = { .event_received = microread_event_received, }; -int microread_probe(void *phy_id, struct nfc_phy_ops *phy_ops, char *llc_name, - int phy_headroom, int phy_tailroom, int phy_payload, - struct nfc_hci_dev **hdev) +int microread_probe(void *phy_id, const struct nfc_phy_ops *phy_ops, + char *llc_name, int phy_headroom, int phy_tailroom, + int phy_payload, struct nfc_hci_dev **hdev) { struct microread_info *info; unsigned long quirks = 0; diff --git a/drivers/nfc/microread/microread.h b/drivers/nfc/microread/microread.h index 044f5e456375..76152d7aa53c 100644 --- a/drivers/nfc/microread/microread.h +++ b/drivers/nfc/microread/microread.h @@ -10,9 +10,9 @@ #define DRIVER_DESC "NFC driver for microread" -int microread_probe(void *phy_id, struct nfc_phy_ops *phy_ops, char *llc_name, - int phy_headroom, int phy_tailroom, int phy_payload, - struct nfc_hci_dev **hdev); +int microread_probe(void *phy_id, const struct nfc_phy_ops *phy_ops, + char *llc_name, int phy_headroom, int phy_tailroom, + int phy_payload, struct nfc_hci_dev **hdev); void microread_remove(struct nfc_hci_dev *hdev); diff --git a/drivers/nfc/pn544/i2c.c b/drivers/nfc/pn544/i2c.c index de59e439c369..37d26f01986b 100644 --- a/drivers/nfc/pn544/i2c.c +++ b/drivers/nfc/pn544/i2c.c @@ -515,7 +515,7 @@ static irqreturn_t pn544_hci_i2c_irq_thread_fn(int irq, void *phy_id) return IRQ_HANDLED; } -static struct nfc_phy_ops i2c_phy_ops = { +static const struct nfc_phy_ops i2c_phy_ops = { .write = pn544_hci_i2c_write, .enable = pn544_hci_i2c_enable, .disable = pn544_hci_i2c_disable, diff --git a/drivers/nfc/pn544/pn544.c b/drivers/nfc/pn544/pn544.c index b788870473e8..23faa46bb486 100644 --- a/drivers/nfc/pn544/pn544.c +++ b/drivers/nfc/pn544/pn544.c @@ -108,7 +108,7 @@ static struct nfc_hci_gate pn544_gates[] = { #define PN544_CMDS_HEADROOM 2 struct pn544_hci_info { - struct nfc_phy_ops *phy_ops; + const struct nfc_phy_ops *phy_ops; void *phy_id; struct nfc_hci_dev *hdev; @@ -901,9 +901,10 @@ static struct nfc_hci_ops pn544_hci_ops = { .disable_se = pn544_hci_disable_se, }; -int pn544_hci_probe(void *phy_id, struct nfc_phy_ops *phy_ops, char *llc_name, - int phy_headroom, int phy_tailroom, int phy_payload, - fw_download_t fw_download, struct nfc_hci_dev **hdev) +int pn544_hci_probe(void *phy_id, const struct nfc_phy_ops *phy_ops, + char *llc_name, int phy_headroom, int phy_tailroom, + int phy_payload, fw_download_t fw_download, + struct nfc_hci_dev **hdev) { struct pn544_hci_info *info; u32 protocols; diff --git a/drivers/nfc/pn544/pn544.h b/drivers/nfc/pn544/pn544.h index 5634ba215ead..c6fe3e11e0c8 100644 --- a/drivers/nfc/pn544/pn544.h +++ b/drivers/nfc/pn544/pn544.h @@ -16,9 +16,10 @@ typedef int (*fw_download_t)(void *context, const char *firmware_name, u8 hw_variant); -int pn544_hci_probe(void *phy_id, struct nfc_phy_ops *phy_ops, char *llc_name, - int phy_headroom, int phy_tailroom, int phy_payload, - fw_download_t fw_download, struct nfc_hci_dev **hdev); +int pn544_hci_probe(void *phy_id, const struct nfc_phy_ops *phy_ops, + char *llc_name, int phy_headroom, int phy_tailroom, + int phy_payload, fw_download_t fw_download, + struct nfc_hci_dev **hdev); void pn544_hci_remove(struct nfc_hci_dev *hdev); #endif /* __LOCAL_PN544_H_ */ diff --git a/drivers/nfc/st-nci/i2c.c b/drivers/nfc/st-nci/i2c.c index 46981405e8b1..ccf6152ebb9f 100644 --- a/drivers/nfc/st-nci/i2c.c +++ b/drivers/nfc/st-nci/i2c.c @@ -186,7 +186,7 @@ static irqreturn_t st_nci_irq_thread_fn(int irq, void *phy_id) return IRQ_HANDLED; } -static struct nfc_phy_ops i2c_phy_ops = { +static const struct nfc_phy_ops i2c_phy_ops = { .write = st_nci_i2c_write, .enable = st_nci_i2c_enable, .disable = st_nci_i2c_disable, diff --git a/drivers/nfc/st-nci/ndlc.c b/drivers/nfc/st-nci/ndlc.c index 5d74c674368a..e9dc313b333e 100644 --- a/drivers/nfc/st-nci/ndlc.c +++ b/drivers/nfc/st-nci/ndlc.c @@ -253,9 +253,9 @@ static void ndlc_t2_timeout(struct timer_list *t) schedule_work(&ndlc->sm_work); } -int ndlc_probe(void *phy_id, struct nfc_phy_ops *phy_ops, struct device *dev, - int phy_headroom, int phy_tailroom, struct llt_ndlc **ndlc_id, - struct st_nci_se_status *se_status) +int ndlc_probe(void *phy_id, const struct nfc_phy_ops *phy_ops, + struct device *dev, int phy_headroom, int phy_tailroom, + struct llt_ndlc **ndlc_id, struct st_nci_se_status *se_status) { struct llt_ndlc *ndlc; diff --git a/drivers/nfc/st-nci/ndlc.h b/drivers/nfc/st-nci/ndlc.h index 066e2fd75238..c24ce9b0df52 100644 --- a/drivers/nfc/st-nci/ndlc.h +++ b/drivers/nfc/st-nci/ndlc.h @@ -16,7 +16,7 @@ struct st_nci_se_status; /* Low Level Transport description */ struct llt_ndlc { struct nci_dev *ndev; - struct nfc_phy_ops *ops; + const struct nfc_phy_ops *ops; void *phy_id; struct timer_list t1_timer; @@ -45,8 +45,8 @@ int ndlc_open(struct llt_ndlc *ndlc); void ndlc_close(struct llt_ndlc *ndlc); int ndlc_send(struct llt_ndlc *ndlc, struct sk_buff *skb); void ndlc_recv(struct llt_ndlc *ndlc, struct sk_buff *skb); -int ndlc_probe(void *phy_id, struct nfc_phy_ops *phy_ops, struct device *dev, - int phy_headroom, int phy_tailroom, struct llt_ndlc **ndlc_id, - struct st_nci_se_status *se_status); +int ndlc_probe(void *phy_id, const struct nfc_phy_ops *phy_ops, + struct device *dev, int phy_headroom, int phy_tailroom, + struct llt_ndlc **ndlc_id, struct st_nci_se_status *se_status); void ndlc_remove(struct llt_ndlc *ndlc); #endif /* __LOCAL_NDLC_H__ */ diff --git a/drivers/nfc/st-nci/spi.c b/drivers/nfc/st-nci/spi.c index 250d56f204c3..a620c34790e6 100644 --- a/drivers/nfc/st-nci/spi.c +++ b/drivers/nfc/st-nci/spi.c @@ -198,7 +198,7 @@ static irqreturn_t st_nci_irq_thread_fn(int irq, void *phy_id) return IRQ_HANDLED; } -static struct nfc_phy_ops spi_phy_ops = { +static const struct nfc_phy_ops spi_phy_ops = { .write = st_nci_spi_write, .enable = st_nci_spi_enable, .disable = st_nci_spi_disable, diff --git a/drivers/nfc/st21nfca/core.c b/drivers/nfc/st21nfca/core.c index 6ca0d2f56b18..583c36d4ff67 100644 --- a/drivers/nfc/st21nfca/core.c +++ b/drivers/nfc/st21nfca/core.c @@ -935,7 +935,7 @@ static struct nfc_hci_ops st21nfca_hci_ops = { .se_io = st21nfca_hci_se_io, }; -int st21nfca_hci_probe(void *phy_id, struct nfc_phy_ops *phy_ops, +int st21nfca_hci_probe(void *phy_id, const struct nfc_phy_ops *phy_ops, char *llc_name, int phy_headroom, int phy_tailroom, int phy_payload, struct nfc_hci_dev **hdev, struct st21nfca_se_status *se_status) diff --git a/drivers/nfc/st21nfca/i2c.c b/drivers/nfc/st21nfca/i2c.c index 7a9f4d71707e..9dc9693a7356 100644 --- a/drivers/nfc/st21nfca/i2c.c +++ b/drivers/nfc/st21nfca/i2c.c @@ -482,7 +482,7 @@ static irqreturn_t st21nfca_hci_irq_thread_fn(int irq, void *phy_id) return IRQ_HANDLED; } -static struct nfc_phy_ops i2c_phy_ops = { +static const struct nfc_phy_ops i2c_phy_ops = { .write = st21nfca_hci_i2c_write, .enable = st21nfca_hci_i2c_enable, .disable = st21nfca_hci_i2c_disable, diff --git a/drivers/nfc/st21nfca/st21nfca.h b/drivers/nfc/st21nfca/st21nfca.h index 5e0de0fef1d4..cb6ad916be91 100644 --- a/drivers/nfc/st21nfca/st21nfca.h +++ b/drivers/nfc/st21nfca/st21nfca.h @@ -144,7 +144,7 @@ struct st21nfca_se_info { }; struct st21nfca_hci_info { - struct nfc_phy_ops *phy_ops; + const struct nfc_phy_ops *phy_ops; void *phy_id; struct nfc_hci_dev *hdev; @@ -163,7 +163,7 @@ struct st21nfca_hci_info { struct st21nfca_vendor_info vendor_info; }; -int st21nfca_hci_probe(void *phy_id, struct nfc_phy_ops *phy_ops, +int st21nfca_hci_probe(void *phy_id, const struct nfc_phy_ops *phy_ops, char *llc_name, int phy_headroom, int phy_tailroom, int phy_payload, struct nfc_hci_dev **hdev, struct st21nfca_se_status *se_status); From patchwork Sat Jul 24 21:49:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 485569 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3D9EFC4320A for ; Sat, 24 Jul 2021 21:49:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 20D4C60E98 for ; Sat, 24 Jul 2021 21:49:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229756AbhGXVJI (ORCPT ); Sat, 24 Jul 2021 17:09:08 -0400 Received: from smtp-relay-canonical-0.canonical.com ([185.125.188.120]:58604 "EHLO smtp-relay-canonical-0.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229964AbhGXVJH (ORCPT ); Sat, 24 Jul 2021 17:09:07 -0400 Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-canonical-0.canonical.com (Postfix) with ESMTPS id 812323F352 for ; Sat, 24 Jul 2021 21:49:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1627163378; bh=lqncaONSiNw90ZsWSl9AH9IIEf03wH8Ti3Z9kPsi5zE=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=HRA3Gnoa+RlPT5s4iYQ0//vnLXwsCMTAgsCwe0RJAtpRR3Kbeu32owHXgc+aEZfAA WWHBL8dUverPoyPV/3Ru/Ym0PIwH2byzNfSJYPEXdH2IcS16JmKflArQhYSWIEbjU9 tRSYyvirb03zhiAGBruCJHi9ioPjnOKEUumEy67XuZhtEQRB1iBl8TPNLhM9TSpmq8 li7tABDEEPPtSUBnGlVmO8SAc0P/WXLcbygnvZsXBSwDJWUurOSx9ofJBE0aGCswv9 F0A2x8CMU0R/oD0vbc27/fsaxf0AAMVHYa1RXR6XGpUbsdm2tRGUOjeff9gNLg0hJD YnDePwXSSJNIQ== Received: by mail-ed1-f72.google.com with SMTP id z15-20020a50f14f0000b02903aa750a46efso2819464edl.8 for ; Sat, 24 Jul 2021 14:49:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lqncaONSiNw90ZsWSl9AH9IIEf03wH8Ti3Z9kPsi5zE=; b=ZQfHdZY1cbbS3WCXdxvXM3PEGUz3ZEajT2INBqJkC2WjfDpCUSOSiOpDwn++sb4NDR kRaUJwk2VGHciUSOgq/fDLUGqVaLRlgvBJtpGH36kidqkhdLg3BF1ITRkV2LZrfweLxh B61eKL4tgPX9nLxsMnuXlUeZGfg1U+z0Ci2dltIA07P9r0+/Fs6ZOUqFIMikez741m3J nauVsGLsP4Oi0g99kh7CK6CEgd+Rf7H6i80DdkIKdjMcIy5DELnJm1Oa3CTrmkagOJJQ e71uNlmVdtm8TcP1auuiaZK4ZVJlDNn6SQ2h3eoaizFh5vu4utT17zTd0VwbJwmaNJMf XG/g== X-Gm-Message-State: AOAM5313VDJkEaWgn87bDyRrHiGXJ2v3eP+MXP5FtbW1Em3KT1LRkVIm nBiteuCnvSo4DPqFJjlbrbDZ4aNWT+7VGt6S7QUAtNeFeQfxoAo1LCcL0OJMmQoyrhVl7M7S1eW yUG95g4V1wAslenBsa0hSv0hnXAfhYvqZHQ== X-Received: by 2002:a50:ce45:: with SMTP id k5mr12994090edj.168.1627163378121; Sat, 24 Jul 2021 14:49:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzs2MCWxVY/iIgBmUT84/VHcn/wv31k1R7oXnENH/7sKHYpMW13rHzV1X6lKvVGgvVFlM+aqQ== X-Received: by 2002:a50:ce45:: with SMTP id k5mr12994078edj.168.1627163378020; Sat, 24 Jul 2021 14:49:38 -0700 (PDT) Received: from localhost.localdomain ([86.32.47.9]) by smtp.gmail.com with ESMTPSA id s10sm12821908ejc.39.2021.07.24.14.49.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Jul 2021 14:49:37 -0700 (PDT) From: Krzysztof Kozlowski To: Krzysztof Kozlowski , Charles Gorand , Krzysztof Opasiak , Mark Greer , Bongsu Jeon , "David S. Miller" , Jakub Kicinski , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-wireless@vger.kernel.org Subject: [PATCH 06/12] nfc: st21nfca: constify file-scope arrays Date: Sat, 24 Jul 2021 23:49:22 +0200 Message-Id: <20210724214928.122096-1-krzysztof.kozlowski@canonical.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210724214743.121884-1-krzysztof.kozlowski@canonical.com> References: <20210724214743.121884-1-krzysztof.kozlowski@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Driver only reads len_seq and wait_tab variables. Signed-off-by: Krzysztof Kozlowski --- drivers/nfc/st21nfca/i2c.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/nfc/st21nfca/i2c.c b/drivers/nfc/st21nfca/i2c.c index 9dc9693a7356..1b44a37a71aa 100644 --- a/drivers/nfc/st21nfca/i2c.c +++ b/drivers/nfc/st21nfca/i2c.c @@ -76,8 +76,8 @@ struct st21nfca_i2c_phy { struct mutex phy_lock; }; -static u8 len_seq[] = { 16, 24, 12, 29 }; -static u16 wait_tab[] = { 2, 3, 5, 15, 20, 40}; +static const u8 len_seq[] = { 16, 24, 12, 29 }; +static const u16 wait_tab[] = { 2, 3, 5, 15, 20, 40}; #define I2C_DUMP_SKB(info, skb) \ do { \ From patchwork Sat Jul 24 21:49:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 485787 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0B495C4320E for ; Sat, 24 Jul 2021 21:49:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E7AD260E95 for ; Sat, 24 Jul 2021 21:49:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230232AbhGXVJR (ORCPT ); Sat, 24 Jul 2021 17:09:17 -0400 Received: from smtp-relay-canonical-1.canonical.com ([185.125.188.121]:43940 "EHLO smtp-relay-canonical-1.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229913AbhGXVJN (ORCPT ); Sat, 24 Jul 2021 17:09:13 -0400 Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-canonical-1.canonical.com (Postfix) with ESMTPS id 6E9423F347 for ; Sat, 24 Jul 2021 21:49:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1627163384; bh=8/lOVqtLlrSxrgAjgKwuhobiXfoOTrJXfIMYxVc5wEI=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=uPNnQhdEAOCzH2L6cQMDbSfbrB3zPA0eMtrNgy1ySxgPXtang5omSeNREo8lyb5Cs PZd9DR5fcj5K1kEUTOm3qlLdk3/QnBOfPUkvrDcEYHAMbO+wIPn7u68a/dNBeTlgdu 9IU1Zcvh13ZopGu/xjgpoH2RA5KTP2iglj1wEAf9rIYklRa7w9P9R/n953tzkpUt5q UDmOr9iepa7RlyGhMbEN9E4SoaZkIWJ4f1uW9S77lVoWFjS8sRo44UbOEatd6/1Rqc M1Wdc/YzDxC+DeoORlH66IvO2a/QhSkvpKVjH6EkBpQCWa4d9wQ5K8kYDIv32mPMOv EwXG45/ao7n4g== Received: by mail-ed1-f69.google.com with SMTP id s8-20020a0564020148b02903948b71f25cso2801773edu.4 for ; Sat, 24 Jul 2021 14:49:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8/lOVqtLlrSxrgAjgKwuhobiXfoOTrJXfIMYxVc5wEI=; b=lo18rhhmT4h6XRaYygN16ueR1C/6A79nYy+DZn187sNrOZhJZU7rKIDNN0J9uixwM5 /n99mSmf9SGI9IuVM8kQmGK62YleSXiw9Umz3YmXoH7y0rGevqrfS/fO88hbbRIt/igf ZZcl+xB/QIrYtUveAG2Pg+W7PeVifcyjscPHXjnlR4bU57X0ERZC2hsDw46cIX6RjlPH C5Wy30hTCFkOoX8a5chuSqF2GcmijN6f+tTheUaRTKhdTgmR7CBzeZx4ryMIL2JyOFNG Z6yjcx+NP0abJBPLuqtCosIPTxrhFjrU+kN89KqniEFj/g7efN/g20YoFiG5bwrjXTz1 7mQQ== X-Gm-Message-State: AOAM5329OTiGfpBgBuo3bnw26lHX7A06v2YO5InBRgjm6MUYEobvYC5v 0x7y9Hc3PdltBQNSzLB8S2YR70J3DTyhUJl9JMv4BUhHUrjjde6bo5NFFco/zg8QHWQ1AquPwMh yXoixX9L3zYF1mOrApexOGmWqAZcAhmtspQ== X-Received: by 2002:a17:906:d8a7:: with SMTP id qc7mr3971697ejb.372.1627163383058; Sat, 24 Jul 2021 14:49:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJya/AXEPictz92OXpo2PxX7m6G5Q6xQNJW0Zkvfy1aeBNxUMcplrM79QV8bZACZbD1hbJCwVw== X-Received: by 2002:a17:906:d8a7:: with SMTP id qc7mr3971683ejb.372.1627163382928; Sat, 24 Jul 2021 14:49:42 -0700 (PDT) Received: from localhost.localdomain ([86.32.47.9]) by smtp.gmail.com with ESMTPSA id s10sm12821908ejc.39.2021.07.24.14.49.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Jul 2021 14:49:42 -0700 (PDT) From: Krzysztof Kozlowski To: Krzysztof Kozlowski , Charles Gorand , Krzysztof Opasiak , Mark Greer , Bongsu Jeon , "David S. Miller" , Jakub Kicinski , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-wireless@vger.kernel.org Subject: [PATCH 07/12] nfc: constify pointer to nfc_vendor_cmd Date: Sat, 24 Jul 2021 23:49:23 +0200 Message-Id: <20210724214928.122096-2-krzysztof.kozlowski@canonical.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210724214743.121884-1-krzysztof.kozlowski@canonical.com> References: <20210724214743.121884-1-krzysztof.kozlowski@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Neither the core nor the drivers modify the passed pointer to struct nfc_vendor_cmd, so make it a pointer to const for correctness and safety. Signed-off-by: Krzysztof Kozlowski --- drivers/nfc/st-nci/vendor_cmds.c | 2 +- drivers/nfc/st21nfca/vendor_cmds.c | 2 +- include/net/nfc/hci.h | 2 +- include/net/nfc/nci_core.h | 2 +- include/net/nfc/nfc.h | 4 ++-- net/nfc/netlink.c | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/nfc/st-nci/vendor_cmds.c b/drivers/nfc/st-nci/vendor_cmds.c index 94b600029a2a..30d2912d1a05 100644 --- a/drivers/nfc/st-nci/vendor_cmds.c +++ b/drivers/nfc/st-nci/vendor_cmds.c @@ -371,7 +371,7 @@ static int st_nci_manufacturer_specific(struct nfc_dev *dev, void *data, return nfc_vendor_cmd_reply(msg); } -static struct nfc_vendor_cmd st_nci_vendor_cmds[] = { +static const struct nfc_vendor_cmd st_nci_vendor_cmds[] = { { .vendor_id = ST_NCI_VENDOR_OUI, .subcmd = FACTORY_MODE, diff --git a/drivers/nfc/st21nfca/vendor_cmds.c b/drivers/nfc/st21nfca/vendor_cmds.c index 62332ca91554..74882866dbaf 100644 --- a/drivers/nfc/st21nfca/vendor_cmds.c +++ b/drivers/nfc/st21nfca/vendor_cmds.c @@ -295,7 +295,7 @@ static int st21nfca_hci_loopback(struct nfc_dev *dev, void *data, return r; } -static struct nfc_vendor_cmd st21nfca_vendor_cmds[] = { +static const struct nfc_vendor_cmd st21nfca_vendor_cmds[] = { { .vendor_id = ST21NFCA_VENDOR_OUI, .subcmd = FACTORY_MODE, diff --git a/include/net/nfc/hci.h b/include/net/nfc/hci.h index b35f37a57686..2daec8036be9 100644 --- a/include/net/nfc/hci.h +++ b/include/net/nfc/hci.h @@ -168,7 +168,7 @@ void nfc_hci_set_clientdata(struct nfc_hci_dev *hdev, void *clientdata); void *nfc_hci_get_clientdata(struct nfc_hci_dev *hdev); static inline int nfc_hci_set_vendor_cmds(struct nfc_hci_dev *hdev, - struct nfc_vendor_cmd *cmds, + const struct nfc_vendor_cmd *cmds, int n_cmds) { return nfc_set_vendor_cmds(hdev->ndev, cmds, n_cmds); diff --git a/include/net/nfc/nci_core.h b/include/net/nfc/nci_core.h index e7118e0cc3b1..00f2c60971d7 100644 --- a/include/net/nfc/nci_core.h +++ b/include/net/nfc/nci_core.h @@ -343,7 +343,7 @@ static inline void *nci_get_drvdata(struct nci_dev *ndev) } static inline int nci_set_vendor_cmds(struct nci_dev *ndev, - struct nfc_vendor_cmd *cmds, + const struct nfc_vendor_cmd *cmds, int n_cmds) { return nfc_set_vendor_cmds(ndev->nfc_dev, cmds, n_cmds); diff --git a/include/net/nfc/nfc.h b/include/net/nfc/nfc.h index 2cd3a261bcbc..31672021d071 100644 --- a/include/net/nfc/nfc.h +++ b/include/net/nfc/nfc.h @@ -188,7 +188,7 @@ struct nfc_dev { struct rfkill *rfkill; - struct nfc_vendor_cmd *vendor_cmds; + const struct nfc_vendor_cmd *vendor_cmds; int n_vendor_cmds; struct nfc_ops *ops; @@ -297,7 +297,7 @@ void nfc_send_to_raw_sock(struct nfc_dev *dev, struct sk_buff *skb, u8 payload_type, u8 direction); static inline int nfc_set_vendor_cmds(struct nfc_dev *dev, - struct nfc_vendor_cmd *cmds, + const struct nfc_vendor_cmd *cmds, int n_cmds) { if (dev->vendor_cmds || dev->n_vendor_cmds) diff --git a/net/nfc/netlink.c b/net/nfc/netlink.c index 722f7ef891e1..70467a82be8f 100644 --- a/net/nfc/netlink.c +++ b/net/nfc/netlink.c @@ -1531,7 +1531,7 @@ static int nfc_genl_vendor_cmd(struct sk_buff *skb, struct genl_info *info) { struct nfc_dev *dev; - struct nfc_vendor_cmd *cmd; + const struct nfc_vendor_cmd *cmd; u32 dev_idx, vid, subcmd; u8 *data; size_t data_len; From patchwork Sat Jul 24 21:49:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 485567 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0B4EEC4338F for ; Sat, 24 Jul 2021 21:50:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EA60F60E90 for ; Sat, 24 Jul 2021 21:50:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230433AbhGXVJZ (ORCPT ); Sat, 24 Jul 2021 17:09:25 -0400 Received: from smtp-relay-canonical-1.canonical.com ([185.125.188.121]:43972 "EHLO smtp-relay-canonical-1.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230274AbhGXVJU (ORCPT ); Sat, 24 Jul 2021 17:09:20 -0400 Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-canonical-1.canonical.com (Postfix) with ESMTPS id 0DB383F32A for ; Sat, 24 Jul 2021 21:49:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1627163391; bh=ydfFaHKHi19ltLLH8d1w1IAXq4hz0eleT+vI32JJiWk=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=leM0wxQ2r7FPy/IBWitd7f2svw6xPL/mONdJUG+skUR6tFlnPyj95r51X0Aw12xGa jHWxXrcqLk5zstjOCt1nTb3dUHoT5F6M2IscayF9wT6028Wyr8c770efx5EmpJ2bpa HS7pzFDKarHF+AOcBz5l/UzxwzZ8geVNgwSwPtnHNGg2ChZyNQRO2YKwDeLKmMIYG4 qV9/h/psR3ySyybUa9pBwiiJqU0EpATR8p+K9HaRccbs/Om+fwDoHfVkRbAib4foR+ MHFAS5mdbRnd6q1uoaJQsXZZEK5E5aZuAssP8zDtei12UFLPkWBJ2Cc+RsTeAiHRod E5XgymLxayACA== Received: by mail-ed1-f71.google.com with SMTP id b4-20020a05640202c4b02903948bc39fd5so2779592edx.13 for ; Sat, 24 Jul 2021 14:49:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ydfFaHKHi19ltLLH8d1w1IAXq4hz0eleT+vI32JJiWk=; b=lztWlFTof5ZDdsXmCsADfaEbwZjdrCw5QzsqDsQx8B4WIILrfbO9vDoGztlG9BAe28 UPYjdDxkz7hdjMfrcpBj40KY1JPUtD9UrlaHioYznXCZEnodWdNr/sV27+DtyFm1R0/L DuqWKcC7R1DE5+AfGcPXZfa5RVGPJZE4fN+ByW0FoxS8gHTcRFX/Y3sCwMbyJQCNPEoT t9D1CR3Pgv02m0nk0oWuZHL8cPkgLmsrKCcbw5m+RVSK12Ero+k2okdNSpnJgUYQGG39 cbxzNc+i9zlvGk724sQSbXt+X4A6cpEQAe1BhRN1EqlOv0RgtC04zfkgDMxu5bjUBZUs uALw== X-Gm-Message-State: AOAM532pvOndDUWkOL2MOpfEnmfvoiCk3hagm73GnAuMPGxgzVB7pdkE WaW0IO7aUAGagUnOgOwkEjD3Em9wtPDbzEGQjXGBBDAjQ93pYwoIGCZWz3V+pdrbyieZF6yP0cF eoRskDJqQKgZT0Oo4lqdYXl3shbwA9NBmvA== X-Received: by 2002:a05:6402:2319:: with SMTP id l25mr7064707eda.383.1627163390852; Sat, 24 Jul 2021 14:49:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzVmroArzmZZewaThv5NERtSr6DdqGjVj6PwhmXYk16ol5TEWO2j+oQ71hzjvO1anxFeNOqpw== X-Received: by 2002:a05:6402:2319:: with SMTP id l25mr7064689eda.383.1627163390689; Sat, 24 Jul 2021 14:49:50 -0700 (PDT) Received: from localhost.localdomain ([86.32.47.9]) by smtp.gmail.com with ESMTPSA id s10sm12821908ejc.39.2021.07.24.14.49.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Jul 2021 14:49:50 -0700 (PDT) From: Krzysztof Kozlowski To: Krzysztof Kozlowski , Charles Gorand , Krzysztof Opasiak , Mark Greer , Bongsu Jeon , "David S. Miller" , Jakub Kicinski , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-wireless@vger.kernel.org Subject: [PATCH 08/12] nfc: constify nfc_hci_gate Date: Sat, 24 Jul 2021 23:49:24 +0200 Message-Id: <20210724214928.122096-3-krzysztof.kozlowski@canonical.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210724214743.121884-1-krzysztof.kozlowski@canonical.com> References: <20210724214743.121884-1-krzysztof.kozlowski@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Neither the core nor the drivers modify the passed pointer to struct nfc_hci_gate, so make it a pointer to const for correctness and safety. Signed-off-by: Krzysztof Kozlowski --- drivers/nfc/microread/microread.c | 2 +- drivers/nfc/pn544/pn544.c | 2 +- drivers/nfc/st21nfca/core.c | 2 +- net/nfc/hci/core.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/nfc/microread/microread.c b/drivers/nfc/microread/microread.c index a5d5c3ec65f9..151a0631ec72 100644 --- a/drivers/nfc/microread/microread.c +++ b/drivers/nfc/microread/microread.c @@ -131,7 +131,7 @@ #define MICROREAD_ELT_ID_SE2 0x04 #define MICROREAD_ELT_ID_SE3 0x05 -static struct nfc_hci_gate microread_gates[] = { +static const struct nfc_hci_gate microread_gates[] = { {MICROREAD_GATE_ID_ADM, MICROREAD_PIPE_ID_ADMIN}, {MICROREAD_GATE_ID_LOOPBACK, MICROREAD_PIPE_ID_HDS_LOOPBACK}, {MICROREAD_GATE_ID_IDT, MICROREAD_PIPE_ID_HDS_IDT}, diff --git a/drivers/nfc/pn544/pn544.c b/drivers/nfc/pn544/pn544.c index 23faa46bb486..f4d09ebba5c8 100644 --- a/drivers/nfc/pn544/pn544.c +++ b/drivers/nfc/pn544/pn544.c @@ -86,7 +86,7 @@ enum pn544_state { #define PN544_HCI_CMD_ATTREQUEST 0x12 #define PN544_HCI_CMD_CONTINUE_ACTIVATION 0x13 -static struct nfc_hci_gate pn544_gates[] = { +static const struct nfc_hci_gate pn544_gates[] = { {NFC_HCI_ADMIN_GATE, NFC_HCI_INVALID_PIPE}, {NFC_HCI_LOOPBACK_GATE, NFC_HCI_INVALID_PIPE}, {NFC_HCI_ID_MGMT_GATE, NFC_HCI_INVALID_PIPE}, diff --git a/drivers/nfc/st21nfca/core.c b/drivers/nfc/st21nfca/core.c index 583c36d4ff67..675f8a342869 100644 --- a/drivers/nfc/st21nfca/core.c +++ b/drivers/nfc/st21nfca/core.c @@ -72,7 +72,7 @@ static DECLARE_BITMAP(dev_mask, ST21NFCA_NUM_DEVICES); -static struct nfc_hci_gate st21nfca_gates[] = { +static const struct nfc_hci_gate st21nfca_gates[] = { {NFC_HCI_ADMIN_GATE, NFC_HCI_ADMIN_PIPE}, {NFC_HCI_LINK_MGMT_GATE, NFC_HCI_LINK_MGMT_PIPE}, {ST21NFCA_DEVICE_MGNT_GATE, ST21NFCA_DEVICE_MGNT_PIPE}, diff --git a/net/nfc/hci/core.c b/net/nfc/hci/core.c index 3481941be70b..e37d30302b06 100644 --- a/net/nfc/hci/core.c +++ b/net/nfc/hci/core.c @@ -447,7 +447,7 @@ static void nfc_hci_cmd_timeout(struct timer_list *t) } static int hci_dev_connect_gates(struct nfc_hci_dev *hdev, u8 gate_count, - struct nfc_hci_gate *gates) + const struct nfc_hci_gate *gates) { int r; while (gate_count--) { From patchwork Sat Jul 24 21:49:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 485786 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E7DDCC4320E for ; Sat, 24 Jul 2021 21:50:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D16B960E98 for ; Sat, 24 Jul 2021 21:50:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230504AbhGXVJ3 (ORCPT ); Sat, 24 Jul 2021 17:09:29 -0400 Received: from smtp-relay-canonical-1.canonical.com ([185.125.188.121]:43998 "EHLO smtp-relay-canonical-1.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230344AbhGXVJW (ORCPT ); Sat, 24 Jul 2021 17:09:22 -0400 Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-canonical-1.canonical.com (Postfix) with ESMTPS id 425C93F34F for ; Sat, 24 Jul 2021 21:49:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1627163393; bh=6J2lTgqHYzy3l3MCZfIFQGtEtcoxxKRMkHa94SdSjak=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Auw3vH/4t/KArtwICGNCg02LtuX3rsWgfguOwhLmmM40Tz2Z9hWlSsD9mjyL4CX00 DcE6qAn1tMxbzGPrIC1/yyl4UkiFmzBJyGdmBLHEWSJxSlYaqqp1byhwwTLzrzf5WH SiU0vNUzz4TpwFUCiDF4LLa7Utium/5kxT54NhSRgwSFcBDmWJdQkgBSpsQ6fMTeT8 KrMyYs4ijB2t/5n9UfKr1fUg/9t074ggVDryG8dmoTtQdPDXatIovy/eaH2KylIORq tt27XfveZ6MzXAhp3H7b98teMlNS2Lh86EQpB96Jlo7DK+px9MvczZzI2ayaxy2NbI 7Qyd/0grRPk5w== Received: by mail-ed1-f72.google.com with SMTP id i89-20020a50b0620000b02903b8906e05b4so2753467edd.19 for ; Sat, 24 Jul 2021 14:49:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6J2lTgqHYzy3l3MCZfIFQGtEtcoxxKRMkHa94SdSjak=; b=AXaYyL9znFhHF9U8rU+2J7z7oWvIDL7XOYG9UgsRR1SVsDHV+vVXs3AdEKSfgUell5 POWNNPGYk8iJ8Dn67xe8iatTMhgdfiYClB4qc9wOviAdS9Es8wGpBssRL0N8DgvZ1wfJ qUc2Yx6Lwz4COrtXxHlyimb76tOUNGUcm/JqcnKBZ3HJZ46pekBhuR3wIH4Md5lnWcn+ 8y2cJpQDP84x/g6mcOVrVJbSkoxcw8ua1TfizgnAamoWKx8tVDHCYuGHM5q8iM7YuTmB 78eJt6jTGryH2I38CKlPfjtOeLNaoaByw71y8TFZTKGDGxcK8tSjpb3qMJ7thjrdlk7R 5FDA== X-Gm-Message-State: AOAM53313sjYQ2zyBTv732gCKamCR2nUfZXypHdlvicTPWJNzFCZAWow 1XWY5AjQSEziaCj8hakMCklvweHWfUBcVmobTd0EcanwoYE/8O8OYzG4Q7N+vJFVwETvwgcPH/+ sBqPYGCFeI55kYqCW7TFKvJQ/hhLPWxV3+g== X-Received: by 2002:aa7:d143:: with SMTP id r3mr13186663edo.110.1627163392075; Sat, 24 Jul 2021 14:49:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJynYqsTng3py05vnEd/zOimw7GtW4mRC4/+/JHfPY2EnELDBn9UeX+yaAenZaRxe7Mt5Rc8fA== X-Received: by 2002:aa7:d143:: with SMTP id r3mr13186647edo.110.1627163391958; Sat, 24 Jul 2021 14:49:51 -0700 (PDT) Received: from localhost.localdomain ([86.32.47.9]) by smtp.gmail.com with ESMTPSA id s10sm12821908ejc.39.2021.07.24.14.49.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Jul 2021 14:49:51 -0700 (PDT) From: Krzysztof Kozlowski To: Krzysztof Kozlowski , Charles Gorand , Krzysztof Opasiak , Mark Greer , Bongsu Jeon , "David S. Miller" , Jakub Kicinski , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-wireless@vger.kernel.org Subject: [PATCH 09/12] nfc: constify nfc_ops Date: Sat, 24 Jul 2021 23:49:25 +0200 Message-Id: <20210724214928.122096-4-krzysztof.kozlowski@canonical.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210724214743.121884-1-krzysztof.kozlowski@canonical.com> References: <20210724214743.121884-1-krzysztof.kozlowski@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Neither the core nor the drivers modify the passed pointer to struct nfc_ops, so make it a pointer to const for correctness and safety. Signed-off-by: Krzysztof Kozlowski --- drivers/nfc/pn533/pn533.c | 2 +- include/net/nfc/nfc.h | 4 ++-- net/nfc/core.c | 2 +- net/nfc/digital_core.c | 2 +- net/nfc/hci/core.c | 2 +- net/nfc/nci/core.c | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/nfc/pn533/pn533.c b/drivers/nfc/pn533/pn533.c index cd64bfe20402..2f3f3fe9a0ba 100644 --- a/drivers/nfc/pn533/pn533.c +++ b/drivers/nfc/pn533/pn533.c @@ -2623,7 +2623,7 @@ static int pn533_dev_down(struct nfc_dev *nfc_dev) return ret; } -static struct nfc_ops pn533_nfc_ops = { +static const struct nfc_ops pn533_nfc_ops = { .dev_up = pn533_dev_up, .dev_down = pn533_dev_down, .dep_link_up = pn533_dep_link_up, diff --git a/include/net/nfc/nfc.h b/include/net/nfc/nfc.h index 31672021d071..85b698794b14 100644 --- a/include/net/nfc/nfc.h +++ b/include/net/nfc/nfc.h @@ -191,14 +191,14 @@ struct nfc_dev { const struct nfc_vendor_cmd *vendor_cmds; int n_vendor_cmds; - struct nfc_ops *ops; + const struct nfc_ops *ops; struct genl_info *cur_cmd_info; }; #define to_nfc_dev(_dev) container_of(_dev, struct nfc_dev, dev) extern struct class nfc_class; -struct nfc_dev *nfc_allocate_device(struct nfc_ops *ops, +struct nfc_dev *nfc_allocate_device(const struct nfc_ops *ops, u32 supported_protocols, int tx_headroom, int tx_tailroom); diff --git a/net/nfc/core.c b/net/nfc/core.c index 573c80c6ff7a..6ade54149b73 100644 --- a/net/nfc/core.c +++ b/net/nfc/core.c @@ -1048,7 +1048,7 @@ struct nfc_dev *nfc_get_device(unsigned int idx) * @tx_headroom: reserved space at beginning of skb * @tx_tailroom: reserved space at end of skb */ -struct nfc_dev *nfc_allocate_device(struct nfc_ops *ops, +struct nfc_dev *nfc_allocate_device(const struct nfc_ops *ops, u32 supported_protocols, int tx_headroom, int tx_tailroom) { diff --git a/net/nfc/digital_core.c b/net/nfc/digital_core.c index 5044c7db577e..8f2572decccd 100644 --- a/net/nfc/digital_core.c +++ b/net/nfc/digital_core.c @@ -732,7 +732,7 @@ static int digital_in_send(struct nfc_dev *nfc_dev, struct nfc_target *target, return rc; } -static struct nfc_ops digital_nfc_ops = { +static const struct nfc_ops digital_nfc_ops = { .dev_up = digital_dev_up, .dev_down = digital_dev_down, .start_poll = digital_start_poll, diff --git a/net/nfc/hci/core.c b/net/nfc/hci/core.c index e37d30302b06..b33fe4ee1581 100644 --- a/net/nfc/hci/core.c +++ b/net/nfc/hci/core.c @@ -928,7 +928,7 @@ static int hci_fw_download(struct nfc_dev *nfc_dev, const char *firmware_name) return hdev->ops->fw_download(hdev, firmware_name); } -static struct nfc_ops hci_nfc_ops = { +static const struct nfc_ops hci_nfc_ops = { .dev_up = hci_dev_up, .dev_down = hci_dev_down, .start_poll = hci_start_poll, diff --git a/net/nfc/nci/core.c b/net/nfc/nci/core.c index 50c625940fa3..400d66c4e210 100644 --- a/net/nfc/nci/core.c +++ b/net/nfc/nci/core.c @@ -1102,7 +1102,7 @@ static int nci_fw_download(struct nfc_dev *nfc_dev, const char *firmware_name) return ndev->ops->fw_download(ndev, firmware_name); } -static struct nfc_ops nci_nfc_ops = { +static const struct nfc_ops nci_nfc_ops = { .dev_up = nci_dev_up, .dev_down = nci_dev_down, .start_poll = nci_start_poll, From patchwork Sat Jul 24 21:49:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 485566 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B2DFBC43216 for ; Sat, 24 Jul 2021 21:50:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9848360E95 for ; Sat, 24 Jul 2021 21:50:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230168AbhGXVJk (ORCPT ); Sat, 24 Jul 2021 17:09:40 -0400 Received: from smtp-relay-canonical-1.canonical.com ([185.125.188.121]:44046 "EHLO smtp-relay-canonical-1.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230340AbhGXVJZ (ORCPT ); Sat, 24 Jul 2021 17:09:25 -0400 Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-canonical-1.canonical.com (Postfix) with ESMTPS id 3E5313F35A for ; Sat, 24 Jul 2021 21:49:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1627163395; bh=m3401JaeR7hF/iAuWRTaY4DOgJxinOQknlb5Rbk0RYA=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=iMw6cNKSAKr8nEOaP/CELlGoUsjsOW76upGW2t5VJHRDJkVwRPAKE+zwL0OJk5Xts 9nOBtbKVkc4DrUDqsZ9JVOcmcWwKezUVQ+QFJszjSKSNHtGWOWO5A2wjEj9KVlmtNb Oagrp4mldV9hTM7LMhTLWFbCvF0AUwQLWoFbPURoKncIqLRQ6ceXYIfmOjdqKNdkS/ l0+JOzwfjSxZT0FvXXfMO+hPX7ZQgNTN1JQwNOSk2/zI8uunfSnNpKpyJlhpngmL3z VNTmqVeqh8dyt+u8OBQ2L2jkv3doEDjo1/ksFEoggNBAaKqlaaB1rFK9HB1rCv5MSu FkejFJ6JuGutw== Received: by mail-ed1-f71.google.com with SMTP id eg50-20020a05640228b2b02903a2e0d2acb7so1620443edb.16 for ; Sat, 24 Jul 2021 14:49:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=m3401JaeR7hF/iAuWRTaY4DOgJxinOQknlb5Rbk0RYA=; b=C0jEBbwxiYddbuRUxm9KE4J8Wj/asXRil+L7KOWRxOZhvJai6BQ0IEW1pwlL6Vt6gv IbgnUVL0KHk6c1qMfislQ5nigBgKvi5X6QYaF2JnIvb9gI0IQ0xFA4EcjqncCDE07a3W 1rfRJp8yoUrrtnXE6A/RXzDfpuL/fb/Mqq6DLA7s+4KB2uMwaw6DD6yd8HisK26vrNVv jBgMvhJw/x6cv9qVwrOXLitPJpAmgMl9myCiisUyYLwpPdtSHJ839EN/CZkGVezlvTv4 QBVqXZIG7XOLfrxN3PDtAyBAHt0jOz2RfJmqV4aHrcsgzc23ILJ9uoTH5XNrAFs660Wr Gp5w== X-Gm-Message-State: AOAM533DDNYoIA6B26v4fLzXshwnzbkciUDuDkiDdNhHpyQ2SNXX/FPC 0h2gYitYEJQSq5Z36BeRN+4ppw/uuQH6nIhbfR690+T0ZP7Zhv45b1r5ogjI2521bJK9NZOvGpd CrykZsQbA4XWMkLhMQYl2Hn+w8FYtBsm5RA== X-Received: by 2002:a17:907:216d:: with SMTP id rl13mr6534940ejb.190.1627163394854; Sat, 24 Jul 2021 14:49:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwgKzAQcpLMspzu45StHAw3RghPL4mRPttr3WZv3iPoIq6uG7G3+HUmNDkSk4ospeFMgRLHEw== X-Received: by 2002:a17:907:216d:: with SMTP id rl13mr6534930ejb.190.1627163394731; Sat, 24 Jul 2021 14:49:54 -0700 (PDT) Received: from localhost.localdomain ([86.32.47.9]) by smtp.gmail.com with ESMTPSA id s10sm12821908ejc.39.2021.07.24.14.49.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Jul 2021 14:49:54 -0700 (PDT) From: Krzysztof Kozlowski To: Krzysztof Kozlowski , Charles Gorand , Krzysztof Opasiak , Mark Greer , Bongsu Jeon , "David S. Miller" , Jakub Kicinski , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-wireless@vger.kernel.org Subject: [PATCH 10/12] nfc: constify nfc_hci_ops Date: Sat, 24 Jul 2021 23:49:26 +0200 Message-Id: <20210724214928.122096-5-krzysztof.kozlowski@canonical.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210724214743.121884-1-krzysztof.kozlowski@canonical.com> References: <20210724214743.121884-1-krzysztof.kozlowski@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Neither the core nor the drivers modify the passed pointer to struct nfc_hci_ops, so make it a pointer to const for correctness and safety. Signed-off-by: Krzysztof Kozlowski --- drivers/nfc/microread/microread.c | 2 +- drivers/nfc/pn544/pn544.c | 2 +- drivers/nfc/st21nfca/core.c | 2 +- include/net/nfc/hci.h | 4 ++-- net/nfc/hci/core.c | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/nfc/microread/microread.c b/drivers/nfc/microread/microread.c index 151a0631ec72..8e847524937c 100644 --- a/drivers/nfc/microread/microread.c +++ b/drivers/nfc/microread/microread.c @@ -625,7 +625,7 @@ static int microread_event_received(struct nfc_hci_dev *hdev, u8 pipe, return r; } -static struct nfc_hci_ops microread_hci_ops = { +static const struct nfc_hci_ops microread_hci_ops = { .open = microread_open, .close = microread_close, .hci_ready = microread_hci_ready, diff --git a/drivers/nfc/pn544/pn544.c b/drivers/nfc/pn544/pn544.c index f4d09ebba5c8..c2b4555ab4b7 100644 --- a/drivers/nfc/pn544/pn544.c +++ b/drivers/nfc/pn544/pn544.c @@ -881,7 +881,7 @@ static int pn544_hci_disable_se(struct nfc_hci_dev *hdev, u32 se_idx) } } -static struct nfc_hci_ops pn544_hci_ops = { +static const struct nfc_hci_ops pn544_hci_ops = { .open = pn544_hci_open, .close = pn544_hci_close, .hci_ready = pn544_hci_ready, diff --git a/drivers/nfc/st21nfca/core.c b/drivers/nfc/st21nfca/core.c index 675f8a342869..5e6c99fcfd27 100644 --- a/drivers/nfc/st21nfca/core.c +++ b/drivers/nfc/st21nfca/core.c @@ -912,7 +912,7 @@ static int st21nfca_hci_event_received(struct nfc_hci_dev *hdev, u8 pipe, } } -static struct nfc_hci_ops st21nfca_hci_ops = { +static const struct nfc_hci_ops st21nfca_hci_ops = { .open = st21nfca_hci_open, .close = st21nfca_hci_close, .load_session = st21nfca_hci_load_session, diff --git a/include/net/nfc/hci.h b/include/net/nfc/hci.h index 2daec8036be9..756c11084f65 100644 --- a/include/net/nfc/hci.h +++ b/include/net/nfc/hci.h @@ -118,7 +118,7 @@ struct nfc_hci_dev { struct sk_buff_head msg_rx_queue; - struct nfc_hci_ops *ops; + const struct nfc_hci_ops *ops; struct nfc_llc *llc; @@ -151,7 +151,7 @@ struct nfc_hci_dev { }; /* hci device allocation */ -struct nfc_hci_dev *nfc_hci_allocate_device(struct nfc_hci_ops *ops, +struct nfc_hci_dev *nfc_hci_allocate_device(const struct nfc_hci_ops *ops, struct nfc_hci_init_data *init_data, unsigned long quirks, u32 protocols, diff --git a/net/nfc/hci/core.c b/net/nfc/hci/core.c index b33fe4ee1581..ff94ac774937 100644 --- a/net/nfc/hci/core.c +++ b/net/nfc/hci/core.c @@ -947,7 +947,7 @@ static const struct nfc_ops hci_nfc_ops = { .se_io = hci_se_io, }; -struct nfc_hci_dev *nfc_hci_allocate_device(struct nfc_hci_ops *ops, +struct nfc_hci_dev *nfc_hci_allocate_device(const struct nfc_hci_ops *ops, struct nfc_hci_init_data *init_data, unsigned long quirks, u32 protocols, From patchwork Sat Jul 24 21:49:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 485568 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 170A9C4320A for ; Sat, 24 Jul 2021 21:50:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 015D560E95 for ; Sat, 24 Jul 2021 21:50:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231159AbhGXVJb (ORCPT ); Sat, 24 Jul 2021 17:09:31 -0400 Received: from smtp-relay-canonical-0.canonical.com ([185.125.188.120]:58694 "EHLO smtp-relay-canonical-0.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230424AbhGXVJ0 (ORCPT ); Sat, 24 Jul 2021 17:09:26 -0400 Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-canonical-0.canonical.com (Postfix) with ESMTPS id 57AFA3F245 for ; Sat, 24 Jul 2021 21:49:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1627163396; bh=YaYGR91qsiSocIs8IC8xy1Q/DfuvgUc0SvOHFTtp8Po=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=CVQrCj9gfFjwb5m0USKzpFyTpJ4IAk1rUJXxO8G/I+lQKAuZnV/kQYpbmIBUTxaZ5 +ae+iluDBqG/xxRrmERCsfcMNXVczqKdqLGI/vFbqjpSPPeMQj9hoAb5gMyScXmrgb e7qtZ02aA0Wuf1KEDFWGmQrPL7iQqOQJsxNBgZunETffehoE5uT7GamJ5u+B8BnwtX tLRrawh2roDzenUoBGkwmLbIOLCK8hiCHsRDXeJM4Zy5OsOY/0b2VzThEGHtV9THht PBMTM7/ASqzaP/DpZ4aeVuVyitZsEOpvJQCbrqcmr+RJ/8hnOV3DWClJEVaCbOeHN3 6D9SrQNOs1xUg== Received: by mail-ed1-f70.google.com with SMTP id s8-20020a0564020148b02903948b71f25cso2801915edu.4 for ; Sat, 24 Jul 2021 14:49:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=YaYGR91qsiSocIs8IC8xy1Q/DfuvgUc0SvOHFTtp8Po=; b=Ea0X7Uglm5yUtMKn4xj8ZA4rdWN98StzMRC+rf1R8G3IyFYxIklyrlTJpuC+lx4NES VwxAdeLiu6w7CcPYIV2RPdZCj+ulI9JRSI+Ue2g0UwypgN+yakNIFqdATNGbfqZDUZ1f SaPW7DZ+6xrHowHrRhbQTtk6QkRmMlP/7Ydk9Hc1P7uQrq3sTXHZ/lTLscdusheHp8zc tIYfzgK+YnuNWbV1i0vHSELa0ArPw/ZazAZaegMmeQdijg0YaWRP6HkTWRr2QwXNXPio 3Db38xIhilGnd/XbwB11MoXntBKGCPgonAaL7nSJsHeMYQBejUyVnOHVMIbQnmwFQZGS 8Izw== X-Gm-Message-State: AOAM531mhX7SK0F9Rq1XyS95G5IfyPpM0USnEr9gBmETX7lmlebfhvql PBNRoe23BOfEQsk25j11046trygp39ROJzj8O+36Wr1SL9UiWCFbfzTKZntIUSy71B+TMlB7KTg 6pkTpPC0DkjQ0GgB33QtFTe4x4dKbhuGIBw== X-Received: by 2002:a17:907:1def:: with SMTP id og47mr10501867ejc.51.1627163396096; Sat, 24 Jul 2021 14:49:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyptb2lC5eNQ/8Ds9TdTrfNbFenR2CMYkDrtf1zT+eHhzYKImpUkxn5Xw9eViwKIQfNH0c+9g== X-Received: by 2002:a17:907:1def:: with SMTP id og47mr10501850ejc.51.1627163395950; Sat, 24 Jul 2021 14:49:55 -0700 (PDT) Received: from localhost.localdomain ([86.32.47.9]) by smtp.gmail.com with ESMTPSA id s10sm12821908ejc.39.2021.07.24.14.49.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Jul 2021 14:49:55 -0700 (PDT) From: Krzysztof Kozlowski To: Krzysztof Kozlowski , Charles Gorand , Krzysztof Opasiak , Mark Greer , Bongsu Jeon , "David S. Miller" , Jakub Kicinski , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-wireless@vger.kernel.org Subject: [PATCH 11/12] nfc: constify nfc_llc_ops Date: Sat, 24 Jul 2021 23:49:27 +0200 Message-Id: <20210724214928.122096-6-krzysztof.kozlowski@canonical.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210724214743.121884-1-krzysztof.kozlowski@canonical.com> References: <20210724214743.121884-1-krzysztof.kozlowski@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Neither the core nor the drivers modify the passed pointer to struct nfc_llc_ops, so make it a pointer to const for correctness and safety. Signed-off-by: Krzysztof Kozlowski --- Documentation/driver-api/nfc/nfc-hci.rst | 2 +- net/nfc/hci/llc.c | 2 +- net/nfc/hci/llc.h | 6 +++--- net/nfc/hci/llc_nop.c | 2 +- net/nfc/hci/llc_shdlc.c | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Documentation/driver-api/nfc/nfc-hci.rst b/Documentation/driver-api/nfc/nfc-hci.rst index eb8a1a14e919..f10fe53aa9fe 100644 --- a/Documentation/driver-api/nfc/nfc-hci.rst +++ b/Documentation/driver-api/nfc/nfc-hci.rst @@ -181,7 +181,7 @@ xmit_from_hci(): The llc must be registered with nfc before it can be used. Do that by calling:: - nfc_llc_register(const char *name, struct nfc_llc_ops *ops); + nfc_llc_register(const char *name, const struct nfc_llc_ops *ops); Again, note that the llc does not handle the physical link. It is thus very easy to mix any physical link with any llc for a given chip driver. diff --git a/net/nfc/hci/llc.c b/net/nfc/hci/llc.c index 6ab40ea17662..fc6b63de3462 100644 --- a/net/nfc/hci/llc.c +++ b/net/nfc/hci/llc.c @@ -41,7 +41,7 @@ void nfc_llc_exit(void) } } -int nfc_llc_register(const char *name, struct nfc_llc_ops *ops) +int nfc_llc_register(const char *name, const struct nfc_llc_ops *ops) { struct nfc_llc_engine *llc_engine; diff --git a/net/nfc/hci/llc.h b/net/nfc/hci/llc.h index 823ddb621e5d..d66271d211a5 100644 --- a/net/nfc/hci/llc.h +++ b/net/nfc/hci/llc.h @@ -26,20 +26,20 @@ struct nfc_llc_ops { struct nfc_llc_engine { const char *name; - struct nfc_llc_ops *ops; + const struct nfc_llc_ops *ops; struct list_head entry; }; struct nfc_llc { void *data; - struct nfc_llc_ops *ops; + const struct nfc_llc_ops *ops; int rx_headroom; int rx_tailroom; }; void *nfc_llc_get_data(struct nfc_llc *llc); -int nfc_llc_register(const char *name, struct nfc_llc_ops *ops); +int nfc_llc_register(const char *name, const struct nfc_llc_ops *ops); void nfc_llc_unregister(const char *name); int nfc_llc_nop_register(void); diff --git a/net/nfc/hci/llc_nop.c b/net/nfc/hci/llc_nop.c index a42852f36f2e..a58716f16954 100644 --- a/net/nfc/hci/llc_nop.c +++ b/net/nfc/hci/llc_nop.c @@ -71,7 +71,7 @@ static int llc_nop_xmit_from_hci(struct nfc_llc *llc, struct sk_buff *skb) return llc_nop->xmit_to_drv(llc_nop->hdev, skb); } -static struct nfc_llc_ops llc_nop_ops = { +static const struct nfc_llc_ops llc_nop_ops = { .init = llc_nop_init, .deinit = llc_nop_deinit, .start = llc_nop_start, diff --git a/net/nfc/hci/llc_shdlc.c b/net/nfc/hci/llc_shdlc.c index 1e3a90049da9..6b747856d095 100644 --- a/net/nfc/hci/llc_shdlc.c +++ b/net/nfc/hci/llc_shdlc.c @@ -820,7 +820,7 @@ static int llc_shdlc_xmit_from_hci(struct nfc_llc *llc, struct sk_buff *skb) return 0; } -static struct nfc_llc_ops llc_shdlc_ops = { +static const struct nfc_llc_ops llc_shdlc_ops = { .init = llc_shdlc_init, .deinit = llc_shdlc_deinit, .start = llc_shdlc_start, From patchwork Sat Jul 24 21:49:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 485785 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1DE00C4320E for ; Sat, 24 Jul 2021 21:50:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F350B60E90 for ; Sat, 24 Jul 2021 21:50:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230523AbhGXVJi (ORCPT ); Sat, 24 Jul 2021 17:09:38 -0400 Received: from smtp-relay-canonical-0.canonical.com ([185.125.188.120]:58728 "EHLO smtp-relay-canonical-0.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230462AbhGXVJ1 (ORCPT ); Sat, 24 Jul 2021 17:09:27 -0400 Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-canonical-0.canonical.com (Postfix) with ESMTPS id 18B8F3F35D for ; Sat, 24 Jul 2021 21:49:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1627163398; bh=i+Q0llccIqMx5SsL7f2qLyVatbD4Rx39C8icqgEfdwA=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ZE6LNOG2hJpweE4zSCqDYvmZ8Kc6rnkdC4+3YdLKjFu45IREKSf6SLC4D/DipF7k/ 9jN/X6ElGPGUk49wzMjWa5sNdja52gczIe7/wcJUNtW3OeI3jcWF7iMO6z2yxDKr/U 47YsMCztjjn81PzrLo21uKU8L1YiQ3W0G8rL7XTwgQGZ3wiuJBhO8Vtwlb6wsmB2cW PvVcR42rTS+RIZN7qw+xBsxHJSO3N2FHvxdJdkI62oHwyzOmvvQsjQJmgD+YoEsHKN C8QfRB8JaLYDwcGp2zXflsWqhdh7coZ3NRPo5VksFtE7CERJWl8NNNFtJaczXUvHw9 cWCMTFoc4Lvrw== Received: by mail-ed1-f71.google.com with SMTP id w17-20020a50fa910000b02903a66550f6f4so1573129edr.21 for ; Sat, 24 Jul 2021 14:49:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=i+Q0llccIqMx5SsL7f2qLyVatbD4Rx39C8icqgEfdwA=; b=oWKm2kpxBM0dxQSosl5U7YR1Q8k4w/s3ZhGh2GfvwhFVN1zy12Rsocfoo/zeZ2aqeJ mDCDnQhhJbJO0a/kBADLNX12Qb4i5uS3iUCenk4oSQ60ow54l4mC8GMcozjeB+b0G48p nn+jjZZTjps3XRRsYYuXBA+vGNdgdGtTr2m6/f20zu1OfBRQ9PAEHUecxZrSkie/Oqss fg0dP2bGRRPwHGqh3Zppcuc5YDSxIGoQEEJumV+CFreda18MQgt9htJ/55/9AxTsoE6+ xjzBswsfKde36hLdGvOo1p79VxSDnYCC9DbZ+S68qZF6FfPUo7AGPHQ3ZeO2a0efFzzd c+UA== X-Gm-Message-State: AOAM5313W4zYdUnEfg4Vqz+XnXQetrnQqdhEAtI/UxgfRWeMxRV2m2LP st56As4sjl5UJYoX8o40X1q2QZSYFw4FqacuKBXzmEWm2fEI62Snyel930boLfO40nB4Gsne/Qr 4DPD64+gQWe0ZOQIQM/tCWuuik1c3KQr2kQ== X-Received: by 2002:a05:6402:430e:: with SMTP id m14mr10296156edc.120.1627163397541; Sat, 24 Jul 2021 14:49:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJymDQtRzFb9UEZAtt6Ovb/j39XIvk8E2P6p5LIuQnS1n8kjgb+MF7fTYK1hCJjwQajwuR/7Qw== X-Received: by 2002:a05:6402:430e:: with SMTP id m14mr10296138edc.120.1627163397361; Sat, 24 Jul 2021 14:49:57 -0700 (PDT) Received: from localhost.localdomain ([86.32.47.9]) by smtp.gmail.com with ESMTPSA id s10sm12821908ejc.39.2021.07.24.14.49.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Jul 2021 14:49:56 -0700 (PDT) From: Krzysztof Kozlowski To: Krzysztof Kozlowski , Charles Gorand , Krzysztof Opasiak , Mark Greer , Bongsu Jeon , "David S. Miller" , Jakub Kicinski , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-wireless@vger.kernel.org Subject: [PATCH 12/12] nfc: constify nfc_digital_ops Date: Sat, 24 Jul 2021 23:49:28 +0200 Message-Id: <20210724214928.122096-7-krzysztof.kozlowski@canonical.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210724214743.121884-1-krzysztof.kozlowski@canonical.com> References: <20210724214743.121884-1-krzysztof.kozlowski@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Neither the core nor the drivers modify the passed pointer to struct nfc_digital_ops, so make it a pointer to const for correctness and safety. Signed-off-by: Krzysztof Kozlowski --- drivers/nfc/nfcsim.c | 2 +- drivers/nfc/port100.c | 2 +- drivers/nfc/st95hf/core.c | 2 +- drivers/nfc/trf7970a.c | 2 +- include/net/nfc/digital.h | 4 ++-- net/nfc/digital_core.c | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/nfc/nfcsim.c b/drivers/nfc/nfcsim.c index a9864fcdfba6..143dc49b815b 100644 --- a/drivers/nfc/nfcsim.c +++ b/drivers/nfc/nfcsim.c @@ -320,7 +320,7 @@ static int nfcsim_tg_listen(struct nfc_digital_dev *ddev, u16 timeout, return nfcsim_send(ddev, NULL, timeout, cb, arg); } -static struct nfc_digital_ops nfcsim_digital_ops = { +static const struct nfc_digital_ops nfcsim_digital_ops = { .in_configure_hw = nfcsim_in_configure_hw, .in_send_cmd = nfcsim_in_send_cmd, diff --git a/drivers/nfc/port100.c b/drivers/nfc/port100.c index 1d614f9d864a..ccb5c5fab905 100644 --- a/drivers/nfc/port100.c +++ b/drivers/nfc/port100.c @@ -1463,7 +1463,7 @@ static int port100_listen(struct nfc_digital_dev *ddev, u16 timeout, return port100_tg_send_cmd(ddev, skb, timeout, cb, arg); } -static struct nfc_digital_ops port100_digital_ops = { +static const struct nfc_digital_ops port100_digital_ops = { .in_configure_hw = port100_in_configure_hw, .in_send_cmd = port100_in_send_cmd, diff --git a/drivers/nfc/st95hf/core.c b/drivers/nfc/st95hf/core.c index 2dc788c363fd..993818742570 100644 --- a/drivers/nfc/st95hf/core.c +++ b/drivers/nfc/st95hf/core.c @@ -1037,7 +1037,7 @@ static void st95hf_abort_cmd(struct nfc_digital_dev *ddev) { } -static struct nfc_digital_ops st95hf_nfc_digital_ops = { +static const struct nfc_digital_ops st95hf_nfc_digital_ops = { .in_configure_hw = st95hf_in_configure_hw, .in_send_cmd = st95hf_in_send_cmd, diff --git a/drivers/nfc/trf7970a.c b/drivers/nfc/trf7970a.c index 33978022ae47..1aed44629aaa 100644 --- a/drivers/nfc/trf7970a.c +++ b/drivers/nfc/trf7970a.c @@ -1861,7 +1861,7 @@ static void trf7970a_abort_cmd(struct nfc_digital_dev *ddev) mutex_unlock(&trf->lock); } -static struct nfc_digital_ops trf7970a_nfc_ops = { +static const struct nfc_digital_ops trf7970a_nfc_ops = { .in_configure_hw = trf7970a_in_configure_hw, .in_send_cmd = trf7970a_send_cmd, .tg_configure_hw = trf7970a_tg_configure_hw, diff --git a/include/net/nfc/digital.h b/include/net/nfc/digital.h index 963db96bcbbb..bb3e8fdc0692 100644 --- a/include/net/nfc/digital.h +++ b/include/net/nfc/digital.h @@ -191,7 +191,7 @@ struct digital_poll_tech { struct nfc_digital_dev { struct nfc_dev *nfc_dev; - struct nfc_digital_ops *ops; + const struct nfc_digital_ops *ops; u32 protocols; @@ -236,7 +236,7 @@ struct nfc_digital_dev { void (*skb_add_crc)(struct sk_buff *skb); }; -struct nfc_digital_dev *nfc_digital_allocate_device(struct nfc_digital_ops *ops, +struct nfc_digital_dev *nfc_digital_allocate_device(const struct nfc_digital_ops *ops, __u32 supported_protocols, __u32 driver_capabilities, int tx_headroom, diff --git a/net/nfc/digital_core.c b/net/nfc/digital_core.c index 8f2572decccd..fefc03674f4f 100644 --- a/net/nfc/digital_core.c +++ b/net/nfc/digital_core.c @@ -745,7 +745,7 @@ static const struct nfc_ops digital_nfc_ops = { .im_transceive = digital_in_send, }; -struct nfc_digital_dev *nfc_digital_allocate_device(struct nfc_digital_ops *ops, +struct nfc_digital_dev *nfc_digital_allocate_device(const struct nfc_digital_ops *ops, __u32 supported_protocols, __u32 driver_capabilities, int tx_headroom, int tx_tailroom)