Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1875931iob; Fri, 29 Apr 2022 15:11:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxxgLM+DhYNstMXquoYFnPYdFPrE155hAglgHDZrVA9ZoKXp+n8iGfXNg54vaZ0K5u7XltL X-Received: by 2002:a05:6512:b11:b0:44a:2ead:daf2 with SMTP id w17-20020a0565120b1100b0044a2eaddaf2mr958605lfu.642.1651270299193; Fri, 29 Apr 2022 15:11:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651270299; cv=none; d=google.com; s=arc-20160816; b=Dk5v/yLrPTxVEOHOsjqPhjxMugeaxgt9btlOm66Of6d8PPkN+6pqb9/q7oErHPu1JV VzYK41dJmmXCsvPz5Sh8fWuk+HJ0YeSFrlHtSxYELBz82R5Jw3ztH6BjgvfoMkvuhvU2 8Li4JyKz70uijvdlNxiU8TaWHn6DNuoXt7hr3ITla5Jvo44rAqIFy5JV9/ShyK3SjAB1 lWATtQW4SZmIcbkxSwwJ7q50mL8vjIFmvS3Php5yC/ggOX1B5y9550sdR+UEZkbQUaQO PDZjq2KbJkowSr6vWW06iOTQMd9yPfmyIF+LTYoWu+Y5145aG1OVQAFtCqX7KNmCNsU8 LElQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:user-agent:references:in-reply-to :subject:cc:to:from:date:content-transfer-encoding:mime-version :dkim-signature; bh=es0PSQekIsrCkXSWsT/g4+RRJjGr5RMyR8HYTLziDzY=; b=OGsHZHMB94y+aF/k1c3K9+iecxKQsslS0xxWHBM65DQTTN+kXpPkEGtD5hAXymseyI 4viLowDCx3td7gZIDq9a4LC7FYozcpQDEh9CzLyDy4Bzxz29w4QHSCGpDRMIXbtlEqFI ITxyY75l4ugFdf7fLqYnndHHiMAc/oH7Gkt37jcOac0OdutZQ7dhWwWGiMpT5FgIp512 fAKm8IazSO7ukPrSv8FWOPY2PPEwEvGW5q1u5PmCPhTLU1kNJYXxwShMSvsJv6W2uBWJ d6pdotdlZCFFT7Z7I2Pp7+dmZEmU5o5lTVB6JVIL40HotcvjI5SeJTjxHOk7UpuCuYQg WYSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b=LR5P7lh+; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m9-20020a2ea589000000b0024f03f548casi8434493ljp.463.2022.04.29.15.11.10; Fri, 29 Apr 2022 15:11:39 -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=@walle.cc header.s=mail2016061301 header.b=LR5P7lh+; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356707AbiD2JsK (ORCPT + 99 others); Fri, 29 Apr 2022 05:48:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244541AbiD2JsJ (ORCPT ); Fri, 29 Apr 2022 05:48:09 -0400 Received: from ssl.serverraum.org (ssl.serverraum.org [176.9.125.105]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78498BF514 for ; Fri, 29 Apr 2022 02:44:51 -0700 (PDT) Received: from ssl.serverraum.org (web.serverraum.org [172.16.0.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ssl.serverraum.org (Postfix) with ESMTPSA id 8763D22238; Fri, 29 Apr 2022 11:44:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2016061301; t=1651225490; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=es0PSQekIsrCkXSWsT/g4+RRJjGr5RMyR8HYTLziDzY=; b=LR5P7lh+xBnddAHSoSStD2hEY1vfyhYmKhAv64wrj2P6xLwX5aUF2Pj1ceewHPg/B5p/nd JvSfUdQWjGxWwbTc52mhKjIsMTX9nspMJDhGNhxGH7Pkm2fSNDB6MSWAeMZtarkA5NYGFy YOqEA0OJvZsuJDtcsRoGuycQ5vMa2RE= MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Fri, 29 Apr 2022 11:44:49 +0200 From: Michael Walle To: Pratyush Yadav Cc: Tudor Ambarus , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org Subject: Re: [PATCH v2 2/2] mtd: spi-nor: expose internal parameters via debugfs In-Reply-To: <20220429045731.sjhlkyxfxw4zvfxt@ti.com> References: <20220428122840.1496876-1-michael@walle.cc> <20220428122840.1496876-2-michael@walle.cc> <20220429045731.sjhlkyxfxw4zvfxt@ti.com> User-Agent: Roundcube Webmail/1.4.13 Message-ID: X-Sender: michael@walle.cc X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,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 Hi, >> +#define SNOR_F_NAME(name) [ilog2(SNOR_F_##name)] = #name >> +static const char *const snor_f_names[] = { >> + SNOR_F_NAME(HAS_SR_TB), >> + SNOR_F_NAME(NO_OP_CHIP_ERASE), >> + SNOR_F_NAME(BROKEN_RESET), >> + SNOR_F_NAME(4B_OPCODES), >> + SNOR_F_NAME(HAS_4BAIT), >> + SNOR_F_NAME(HAS_LOCK), >> + SNOR_F_NAME(HAS_16BIT_SR), >> + SNOR_F_NAME(NO_READ_CR), >> + SNOR_F_NAME(HAS_SR_TB_BIT6), >> + SNOR_F_NAME(HAS_4BIT_BP), >> + SNOR_F_NAME(HAS_SR_BP3_BIT6), >> + SNOR_F_NAME(IO_MODE_EN_VOLATILE), >> + SNOR_F_NAME(SOFT_RESET), >> + SNOR_F_NAME(SWP_IS_VOLATILE), >> +}; >> +#undef SNOR_F_NAME > > You said you would add a comment here. Changed your mind? No, it just slipped through. >> +void spi_nor_debugfs_register(struct spi_nor *nor) >> +{ >> + struct dentry *d; >> + int ret; >> + >> + /* Create rootdir once. Will never be deleted again. */ >> + if (!rootdir) >> + rootdir = debugfs_create_dir("spi-nor", NULL); > > If I compile SPI NOR as module, I insmod it, rmmod it, and then insmod > it again, I get: > > [ 360.623465] spi-nor spi0.0: mt35xu512aba (65536 Kbytes) > [ 360.623478] debugfs: Directory 'spi-nor' with parent '/' already > present! > [ 360.632237] spi-nor spi1.0: mt25qu512a (65536 Kbytes) > > I guess when you remove the module, rootdir also gets destroyed, and > then gets re-initialized on probing again. I am not familiar enough > with > the debugfs APIs to suggest a fix though. Thanks for testing. And yes, you are right. I've changed that code quite a few times for this damn subdirectory. But it seems I didn't get it right. Usually, it's created in the module_init() but since we just have an implicit one (and I don't really want to change that), that's not an option. Some subsystems don't create a subdirectory at all, which doesn't appeal to me. I'll first lookup if the directory is already there, if it is, use it, if not, create it. That should work. FWIW, the mvpp2 network card driver does it too. -michael