Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp26519imn; Thu, 28 Jul 2022 20:55:08 -0700 (PDT) X-Google-Smtp-Source: AA6agR5JQhYllqZDOEACAdnqflNpK0fLAAVwi9Yl/p2mZnpv4xkUiVkltBBfrsybzEwX/blnK2PP X-Received: by 2002:a17:902:ba8e:b0:16d:9ecb:d1c1 with SMTP id k14-20020a170902ba8e00b0016d9ecbd1c1mr1982133pls.53.1659066908310; Thu, 28 Jul 2022 20:55:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659066908; cv=none; d=google.com; s=arc-20160816; b=rBdByJ9/5KkqFQoATqO6gitp/fJ0yz+hMnoyLqgRqfMuODgjZIhrqKct1dgc4gLej1 qu3PJ0UluXgm3i0mAYXmLYBuK2YyiKkC67KVvjDliEx1B/p/+R1PkFtqYP9xF1+15+xz q2zrHC20BsYya7L/qQmDGB20zbGUUCk5yEMoGhevm8wSuziEYDn1hiAKtnedugmaJabj 90yrx3zqzrvOznQ0AjIlLdio+lFDKLukl+utKgFkX9rjE1yE8Y10ogGfm6Ux7MoViHjk cQftFmdZ4OKgU9xeRxtt7qcNcXuIvsCbwMEs1O/9SDhoH8OogH6/JKW4c0DfoE7zgxoS aXJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=VqJty/jAzkS9ddhZQ1LDWqDzmo4hUT9KrNKCMusTL4A=; b=gbEDV8dOc6qNoqdjmIATwIXcUNAg/DlkCsCKMgzmOFNze3RTx68MSu7WjhsBVj3ipF YXnjVdTcKOnPo+dfKCeCn5lL+je1hyrxLIFwsM6PL9BvefbBRS2Ia4/IKsG1VmJYW9P+ /nTRICeKLMLimvsxhsoBzYI3tZchZOueEw+I7iM7jPE1FFiyvVxUlX9TsQMQ2nwmNIyz T1BnPEScr1wC6EbB3ZvqizCN4kaC8Pkplj+hjdHG5wAMjmPB59IoQ6xjlHDMgZxJUgV5 AaP8N7bopnGhfdEMnFkX321HUsT5bqEt67tcO44nBBkNuxcmkjmxwncw3y9OLFe3iY+r H7HQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=FlPfnteP; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id pc10-20020a17090b3b8a00b001ef9af2d81asi3451147pjb.63.2022.07.28.20.54.53; Thu, 28 Jul 2022 20:55:08 -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=@gmail.com header.s=20210112 header.b=FlPfnteP; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234435AbiG2Dxi (ORCPT + 99 others); Thu, 28 Jul 2022 23:53:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234234AbiG2DxU (ORCPT ); Thu, 28 Jul 2022 23:53:20 -0400 Received: from mail-pg1-x52c.google.com (mail-pg1-x52c.google.com [IPv6:2607:f8b0:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 805047E83C for ; Thu, 28 Jul 2022 20:52:42 -0700 (PDT) Received: by mail-pg1-x52c.google.com with SMTP id bh13so3078920pgb.4 for ; Thu, 28 Jul 2022 20:52:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=VqJty/jAzkS9ddhZQ1LDWqDzmo4hUT9KrNKCMusTL4A=; b=FlPfntePR/J/cEvMPOmNckBJmON2t0BOxiMCZwbuKxVMJVJ3RL9U0W+4++BtQa0ZaI 3+OJoGYekSFqxNRUOyokFw4gHIrslHTMLcNnUffuKSWwwGhcB4t31Un5lj0ibI/4S6gF m0fdAPM4OlSHLsKBbcCh1Yp21moOKqU4FIVJapUqSca0nlEgdvtBZGoy/gjMRMtJ3JFX 0zJ4F1mU8PIDkCONY9XMxkuKo36NE4ntbSwaWgCBgxrCh5CNFkjQwDmhfg0ZNiPC2bDK 7gkM4XSuUptSl/i8Px/id6GOslM4VcO4Qz04h2j+c/s4ejnETiyk4VLV9Iq51ywnOx1Z aO7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=VqJty/jAzkS9ddhZQ1LDWqDzmo4hUT9KrNKCMusTL4A=; b=LZQZop/iqa8+pSPxPwa6iyeT47l3AEyE+Bv+deNOrLI9k/lqJzpVYzrvUuDvJAH7gf +5cz7XqT0XpnfZlyTZtxxZn0E6vraAv6ToIf4UGo3mbKOn+dznVCQ7sX0rlednqZx+H3 J/5LVg+TelOINHxaJw/lxK1fuCS1wD6Kq+V1nTO/Vpocbd03IWOMlWuceIEtYCiqUVsJ NeX1sUBSI4wKdCOoFoNDVsQQs1GcBWsJRiUs9yDXlXJCLmxbluhZ7Ho8QF1DnqSkMKhi cU+yi0jKUWrEVYsgdk9lSgpa8dKuPQ7Ty+iXCsQDEPDaTmmtFPEHALGHCApCK4g0HSGK FvaA== X-Gm-Message-State: AJIora/Wzgyi5WvLMAMxLdi+83+SStoOcYHZLoXyyFbSIIYLh0nX95mk l8rACpUbvwF49z9q2m4uEmbScXqv0Wyw+g== X-Received: by 2002:a63:d64e:0:b0:41a:b83d:1b2a with SMTP id d14-20020a63d64e000000b0041ab83d1b2amr1429057pgj.122.1659066761783; Thu, 28 Jul 2022 20:52:41 -0700 (PDT) Received: from tong-desktop.local ([2600:1700:3ec7:421f:a06b:5560:ec65:277f]) by smtp.googlemail.com with ESMTPSA id h14-20020a170902680e00b0016d2d2c7df1sm2135478plk.188.2022.07.28.20.52.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Jul 2022 20:52:41 -0700 (PDT) From: Tong Zhang To: Greg Kroah-Hartman , Dan Carpenter , Tong Zhang , Jakub Kicinski , Colin Ian King , Saurav Girepunje , Nathan Chancellor , Johan Hovold , linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev Cc: Zheyu Ma Subject: [PATCH v3 0/3] staging: rtl8192u: fix rmmod warn when device is renamed Date: Thu, 28 Jul 2022 20:52:17 -0700 Message-Id: <20220729035230.226172-1-ztong0001@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There are 4 debug files created under /proc/net/[Devname] by rtl8192u_usb. Devname could be wlan0 initially, however it could be renamed later to e.g. enx00e04c000002. This will cause problem during debug file teardown since it uses netdev->name which is no longer wlan0. To solve this problem, add a notifier to handle device renaming. Also, due to this is purely for debuging as files are created read only, move this to debugfs like other NIC drivers do instead of using procfs. The directory structure after this patch set will be like the following /sys/kernel/debug/r8192u_usb/wlan0/stats-rx /sys/kernel/debug/r8192u_usb/wlan0/stats-rx /sys/kernel/debug/r8192u_usb/wlan0/stats-ap /sys/kernel/debug/r8192u_usb/wlan0/registers Also note that we cannot simply do debugfs_lookup to find out old dentry since by the time the notifier is called, netdev->name is already changed to new name. So here we still save the original dentry. Reported-by: Zheyu Ma Tested-by: Zheyu Ma Reviewed-by: Dan Carpenter Signed-off-by: Tong Zhang v2: break down patch and fix pointer check v3: removed unnecessary checks, casts and move debug files under module's own directory, only minor change compared to v2 Tong Zhang (3): staging: rtl8192u: move debug stuff to its own file staging: rtl8192u: move debug files to debugfs staging: rtl8192u: fix rmmod warn when device is renamed drivers/staging/rtl8192u/Makefile | 1 + drivers/staging/rtl8192u/r8192U.h | 9 + drivers/staging/rtl8192u/r8192U_core.c | 226 ++++------------------ drivers/staging/rtl8192u/r8192U_debugfs.c | 189 ++++++++++++++++++ 4 files changed, 242 insertions(+), 183 deletions(-) create mode 100644 drivers/staging/rtl8192u/r8192U_debugfs.c -- 2.25.1