From patchwork Tue Nov 1 23:05:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ahelenia_Ziemia=C5=84ska?= X-Patchwork-Id: 13959 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp3262717wru; Tue, 1 Nov 2022 16:08:32 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5dNg8cik1HHEcfmWZOZSCS4ooVoNmsig1HS9ckDZggidcWj62EEdQwZZEBynQoM8QtPp4Z X-Received: by 2002:a17:902:8212:b0:186:a260:50a0 with SMTP id x18-20020a170902821200b00186a26050a0mr21551968pln.157.1667344112010; Tue, 01 Nov 2022 16:08:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667344112; cv=none; d=google.com; s=arc-20160816; b=hyPkEfjBUsd9/ly6QDbOflhSACKdW3yc4rDzhuDZl7XfHGkmcZD8ivMJPu+imZTfCR qbOa7Jq/Adv9YJac0mp/PHa5LrxB7dBlVJaQsV6AutKpMYfQb1QtTFyqlqHshkimheLl 9YGFt91076fYwaqtiN32lOfuBKBZVRb6woGwxOg996leJGFEltPGfS0KP9m3veY8vck7 g4rvgUqIJTUGmDOxeFTqGRHUwKXK0YP1xa3pVAq83ooSji0y8iBI9rKaBBsUxXZPYfLC fNwAAdoPbW8KHT/R6uVmLODiaWW64dBbkbdZ4Sqv1EszrHCxGei/psZCZjec1V/eZh4O 82hg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:from:date :dkim-signature; bh=WWV7pijMMpmwZSzoLsehpTXPuoVkU3MsYZrwlaXFv5g=; b=XB+N+1tTQ9QVvxqiV5iMrzaoUXHYnNsqQwu4JKZrlckkvOcYmcdT1C3wItUUWj4HUS 0+Zc/+lLdv/PRLpN/f/lhB5242JAyIKVnZ5synjYeMJR8vFhKG72fwUh65mET+PtTnrD jBBDTIVvI36oLYLuDSvT8Crde7P73guwVJ781+LFWLySMITpOWFQn4oKWFyP1eYL2NP6 ukavyYhCifwekCZt9QSmiNyZ03onxSgAMMMH8Yr7YMn1XKVOT3ZJBcd6ZN+2WJOhusHw 57IhPVzw/6cRa7aFtfYD4Q/Qzk8cw9Em87ciBwOzNlOLHYrOMcfDILMZUpfmKC1nAp7B bIbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nabijaczleweli.xyz header.s=202205 header.b=jRaknn+S; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nabijaczleweli.xyz Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id be9-20020a656e49000000b003fea0415b5asi13530947pgb.834.2022.11.01.16.08.19; Tue, 01 Nov 2022 16:08:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@nabijaczleweli.xyz header.s=202205 header.b=jRaknn+S; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nabijaczleweli.xyz Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231501AbiKAXIA (ORCPT + 99 others); Tue, 1 Nov 2022 19:08:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231484AbiKAXGQ (ORCPT ); Tue, 1 Nov 2022 19:06:16 -0400 Received: from tarta.nabijaczleweli.xyz (unknown [139.28.40.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 079A12098A; Tue, 1 Nov 2022 16:05:51 -0700 (PDT) Received: from tarta.nabijaczleweli.xyz (unknown [192.168.1.250]) by tarta.nabijaczleweli.xyz (Postfix) with ESMTPSA id 356824E34; Wed, 2 Nov 2022 00:05:51 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nabijaczleweli.xyz; s=202205; t=1667343951; bh=DTGJTbh0Y3OZJ4sMCmhd7AQI6rV6WGDqYy9+7OtkP0g=; h=Date:From:Cc:Subject:References:In-Reply-To:From; b=jRaknn+SVS7PT5GviE9Sxf2OAtvKhNWKfthc8UvaNxbB/SWX54frattUzN3lvGPAw c8XZJjH165y6r7hcYSAvh2tSkEIeEbMeiRgJXxyS0kkHliwNxvexRKW8JUPDRx8BKq JtGxag4wGnoKneMN+jQ0gl7A6o8t9kFks7vLTaPvAL5WrULIf6aKCI+PND2q0NHnT4 3uvcAd1xHm68J7j0m2a0tkvwh/WfjMWAbTClhppRpK6Nipw3uHuT0KHtposJXKR8+w iAaCIE5u0pZO2dwtpEag/Jy5fbEegDuWozvZMIM4byIOwq/E/PTKB0ABWB8sHMtI21 jtQGh9QyAGtnU65X77KX+xqk8/FSnM6ljxOmOgV3G1ERkhMefA1BkXUbD+nPpbVt2a vWzJUzd1AZ8MffL7KtCQP3VqRvkHsDw2cnEQ0Fu2PiiU8Y9OES+WHvwHp6I4GcpAaK uENUpqg/7agizU8LSK9DgLulwzWvPd/a4D/HQ/+5BqBclpWb1iRhiG+Y9BnqcrewrZ y8vp+Zyre1ob7cBipUh05Iz8fh7keNXvTMiEi/3yCwplnUuLU93irXdJwtJ4aGs7HN vPCSnVE9/BP+gr7EZJB8m/SRL1r1Qa2MBTfsqVlXxQ3v0jz0xH5W/umhycNLNO20xb mydErc6Nm7kfRBFK4ExBbDnE= Date: Wed, 2 Nov 2022 00:05:50 +0100 From: Ahelenia =?utf-8?q?Ziemia=C5=84ska?= Cc: Jonathan Corbet , Federico Vaga , Alex Shi , Yanteng Si , Hu Haowen , Thomas Sailer , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Greg Kroah-Hartman , Jiri Slaby , Kees Cook , Yury Norov , Marc Kleine-Budde , "Jason A. Donenfeld" , Wolfram Sang , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc-tw-discuss@lists.sourceforge.net, linux-hams@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH v2 11/15] hdlcdrv: remove HDLCDRV_MAGIC Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20220429 X-Spam-Status: No, score=2.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FROM_SUSPICIOUS_NTLD, MISSING_HEADERS,PDS_OTHER_BAD_TLD,PDS_RDNS_DYNAMIC_FP,RDNS_DYNAMIC, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: ** X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748337019209562076?= X-GMAIL-MSGID: =?utf-8?q?1748337019209562076?= We have largely moved away from this approach, and we have better debugging instrumentation nowadays: kill it. Additionally, ~half HDLCDRV_MAGIC checks just early-exit instead of noting the bug, so they're detrimental, if anything. Link: https://lore.kernel.org/linux-doc/YyMlovoskUcHLEb7@kroah.com/ Signed-off-by: Ahelenia Ziemiańska --- Documentation/process/magic-number.rst | 1 - .../translations/it_IT/process/magic-number.rst | 1 - .../translations/zh_CN/process/magic-number.rst | 1 - .../translations/zh_TW/process/magic-number.rst | 1 - drivers/net/hamradio/baycom_par.c | 1 - drivers/net/hamradio/baycom_ser_fdx.c | 3 +-- drivers/net/hamradio/baycom_ser_hdx.c | 3 +-- drivers/net/hamradio/hdlcdrv.c | 9 +++------ include/linux/hdlcdrv.h | 2 -- 9 files changed, 5 insertions(+), 17 deletions(-) diff --git a/Documentation/process/magic-number.rst b/Documentation/process/magic-number.rst index c1c68c713cbc..3b3e607e1cbc 100644 --- a/Documentation/process/magic-number.rst +++ b/Documentation/process/magic-number.rst @@ -70,6 +70,5 @@ Magic Name Number Structure File ===================== ================ ======================== ========================================== FASYNC_MAGIC 0x4601 fasync_struct ``include/linux/fs.h`` SLIP_MAGIC 0x5302 slip ``drivers/net/slip.h`` -HDLCDRV_MAGIC 0x5ac6e778 hdlcdrv_state ``include/linux/hdlcdrv.h`` CCB_MAGIC 0xf2691ad2 ccb ``drivers/scsi/ncr53c8xx.c`` ===================== ================ ======================== ========================================== diff --git a/Documentation/translations/it_IT/process/magic-number.rst b/Documentation/translations/it_IT/process/magic-number.rst index 5b609ca78a14..e8c659b6a743 100644 --- a/Documentation/translations/it_IT/process/magic-number.rst +++ b/Documentation/translations/it_IT/process/magic-number.rst @@ -76,6 +76,5 @@ Nome magico Numero Struttura File ===================== ================ ======================== ========================================== FASYNC_MAGIC 0x4601 fasync_struct ``include/linux/fs.h`` SLIP_MAGIC 0x5302 slip ``drivers/net/slip.h`` -HDLCDRV_MAGIC 0x5ac6e778 hdlcdrv_state ``include/linux/hdlcdrv.h`` CCB_MAGIC 0xf2691ad2 ccb ``drivers/scsi/ncr53c8xx.c`` ===================== ================ ======================== ========================================== diff --git a/Documentation/translations/zh_CN/process/magic-number.rst b/Documentation/translations/zh_CN/process/magic-number.rst index ab4d4e32b61f..2105af32187c 100644 --- a/Documentation/translations/zh_CN/process/magic-number.rst +++ b/Documentation/translations/zh_CN/process/magic-number.rst @@ -59,6 +59,5 @@ Linux 魔术数 ===================== ================ ======================== ========================================== FASYNC_MAGIC 0x4601 fasync_struct ``include/linux/fs.h`` SLIP_MAGIC 0x5302 slip ``drivers/net/slip.h`` -HDLCDRV_MAGIC 0x5ac6e778 hdlcdrv_state ``include/linux/hdlcdrv.h`` CCB_MAGIC 0xf2691ad2 ccb ``drivers/scsi/ncr53c8xx.c`` ===================== ================ ======================== ========================================== diff --git a/Documentation/translations/zh_TW/process/magic-number.rst b/Documentation/translations/zh_TW/process/magic-number.rst index a6131d978189..793a0ae9fb7c 100644 --- a/Documentation/translations/zh_TW/process/magic-number.rst +++ b/Documentation/translations/zh_TW/process/magic-number.rst @@ -62,6 +62,5 @@ Linux 魔術數 ===================== ================ ======================== ========================================== FASYNC_MAGIC 0x4601 fasync_struct ``include/linux/fs.h`` SLIP_MAGIC 0x5302 slip ``drivers/net/slip.h`` -HDLCDRV_MAGIC 0x5ac6e778 hdlcdrv_state ``include/linux/hdlcdrv.h`` CCB_MAGIC 0xf2691ad2 ccb ``drivers/scsi/ncr53c8xx.c`` ===================== ================ ======================== ========================================== diff --git a/drivers/net/hamradio/baycom_par.c b/drivers/net/hamradio/baycom_par.c index fd7da5bb1fa5..e1cf3ed42df6 100644 --- a/drivers/net/hamradio/baycom_par.c +++ b/drivers/net/hamradio/baycom_par.c @@ -418,7 +418,6 @@ static int baycom_ioctl(struct net_device *dev, void __user *data, return -EINVAL; bc = netdev_priv(dev); - BUG_ON(bc->hdrv.magic != HDLCDRV_MAGIC); if (cmd != SIOCDEVPRIVATE) return -ENOIOCTLCMD; diff --git a/drivers/net/hamradio/baycom_ser_fdx.c b/drivers/net/hamradio/baycom_ser_fdx.c index 646f605e358f..65113cb6de8d 100644 --- a/drivers/net/hamradio/baycom_ser_fdx.c +++ b/drivers/net/hamradio/baycom_ser_fdx.c @@ -252,7 +252,7 @@ static irqreturn_t ser12_interrupt(int irq, void *dev_id) unsigned char iir, msr; unsigned int txcount = 0; - if (!bc || bc->hdrv.magic != HDLCDRV_MAGIC) + if (!bc) return IRQ_NONE; /* fast way out for shared irq */ if ((iir = inb(IIR(dev->base_addr))) & 1) @@ -507,7 +507,6 @@ static int baycom_ioctl(struct net_device *dev, void __user *data, return -EINVAL; bc = netdev_priv(dev); - BUG_ON(bc->hdrv.magic != HDLCDRV_MAGIC); if (cmd != SIOCDEVPRIVATE) return -ENOIOCTLCMD; diff --git a/drivers/net/hamradio/baycom_ser_hdx.c b/drivers/net/hamradio/baycom_ser_hdx.c index 5d1ab4840753..df33e5cdb5c2 100644 --- a/drivers/net/hamradio/baycom_ser_hdx.c +++ b/drivers/net/hamradio/baycom_ser_hdx.c @@ -365,7 +365,7 @@ static irqreturn_t ser12_interrupt(int irq, void *dev_id) struct baycom_state *bc = netdev_priv(dev); unsigned char iir; - if (!dev || !bc || bc->hdrv.magic != HDLCDRV_MAGIC) + if (!dev || !bc) return IRQ_NONE; /* fast way out */ if ((iir = inb(IIR(dev->base_addr))) & 1) @@ -561,7 +561,6 @@ static int baycom_ioctl(struct net_device *dev, void __user *data, return -EINVAL; bc = netdev_priv(dev); - BUG_ON(bc->hdrv.magic != HDLCDRV_MAGIC); if (cmd != SIOCDEVPRIVATE) return -ENOIOCTLCMD; diff --git a/drivers/net/hamradio/hdlcdrv.c b/drivers/net/hamradio/hdlcdrv.c index 2263029d1a20..60abd6008cc7 100644 --- a/drivers/net/hamradio/hdlcdrv.c +++ b/drivers/net/hamradio/hdlcdrv.c @@ -158,7 +158,7 @@ void hdlcdrv_receiver(struct net_device *dev, struct hdlcdrv_state *s) int i; unsigned int mask1, mask2, mask3, mask4, mask5, mask6, word; - if (!s || s->magic != HDLCDRV_MAGIC) + if (!s) return; if (test_and_set_bit(0, &s->hdlcrx.in_hdlc_rx)) return; @@ -257,7 +257,7 @@ void hdlcdrv_transmitter(struct net_device *dev, struct hdlcdrv_state *s) struct sk_buff *skb; int pkt_len; - if (!s || s->magic != HDLCDRV_MAGIC) + if (!s) return; if (test_and_set_bit(0, &s->hdlctx.in_hdlc_tx)) return; @@ -364,7 +364,7 @@ static void start_tx(struct net_device *dev, struct hdlcdrv_state *s) void hdlcdrv_arbitrate(struct net_device *dev, struct hdlcdrv_state *s) { - if (!s || s->magic != HDLCDRV_MAGIC || s->hdlctx.ptt || !s->skb) + if (!s || s->hdlctx.ptt || !s->skb) return; if (s->ch_params.fulldup) { start_tx(dev, s); @@ -701,7 +701,6 @@ struct net_device *hdlcdrv_register(const struct hdlcdrv_ops *ops, * initialize part of the hdlcdrv_state struct */ s = netdev_priv(dev); - s->magic = HDLCDRV_MAGIC; s->ops = ops; dev->base_addr = baseaddr; dev->irq = irq; @@ -723,8 +722,6 @@ void hdlcdrv_unregister(struct net_device *dev) { struct hdlcdrv_state *s = netdev_priv(dev); - BUG_ON(s->magic != HDLCDRV_MAGIC); - if (s->opened && s->ops->close) s->ops->close(dev); unregister_netdev(dev); diff --git a/include/linux/hdlcdrv.h b/include/linux/hdlcdrv.h index 5d70c3f98f5b..809ad0f5c99c 100644 --- a/include/linux/hdlcdrv.h +++ b/include/linux/hdlcdrv.h @@ -13,7 +13,6 @@ #include #include -#define HDLCDRV_MAGIC 0x5ac6e778 #define HDLCDRV_HDLCBUFFER 32 /* should be a power of 2 for speed reasons */ #define HDLCDRV_BITBUFFER 256 /* should be a power of 2 for speed reasons */ #undef HDLCDRV_LOOPBACK /* define for HDLC debugging purposes */ @@ -84,7 +83,6 @@ struct hdlcdrv_ops { }; struct hdlcdrv_state { - int magic; int opened; const struct hdlcdrv_ops *ops;