Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp742405pxb; Wed, 29 Sep 2021 08:47:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwjuUNZ3k8SrkuGVcYgnId0FZ3cyeaHRJjITAaK/4+nniSKca4l5TKNAAibZmyHIpti7ekD X-Received: by 2002:a05:6402:44c:: with SMTP id p12mr691325edw.145.1632930476218; Wed, 29 Sep 2021 08:47:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632930476; cv=none; d=google.com; s=arc-20160816; b=1DCNq4zFTN6VFriy5NyURVuAM2CjEizVCqmHblr5AMx26YOGmVH6u8Ey+v3sZSxkSy 6FyldK5wIS+okpH8EOYxEgxqUfefptVT+BvxttesWAaFrdiLMO7PbRbvfh49sGe+lOLY QF3EyzXhZgWQOoYTmXrBjoEB8TtUavtj/YggiEHaTCIZsfiSppzBG6RsGez4fCRBWgHm p4RFI/kc/RZf74876EQ+oyXPlEoZLQUMQV9hb5S/U+Yg+gUJXTX0N4C6TgQBaVTzCcyY eDNSgEET+k/Zs82uOThQXNttPMsJ62cNm1dpF0dvYggyaBDhfUBIdC7QWPebu7nBY8qk r+gg== 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=TO54FDsoCMWCMt79Pdb9/ZG9fjkHhkFEnzaM9kEuuFY=; b=bdJA2brtNY7d8oWWZY195gnTCFZmm/GXAPV5gsKLD21tkT3oQkHK+kyWP8vyofhhx1 VrNVDalEXCQ9x7NQFGIjEJ6OKzzDnpHYH6Q+GwWCsGFAEpI7doSNUvgSacc/ovOIdD3M TAhX3gHQmKMbxicGFknkvGO62MECbboU3sKo0Cn4u3qh5zITlkZYoi0uZRcURg3w2RYL V8q4dTIJejK7q59EeIptRgJKFzGJwaMt8roxraep+SOCjq27T0ZicPZxrxvCer4yhTuf S4SU5nCqZ2nfzxVEYhmaeKYBCURMrumORlQjw8XNX/ZDfRD4mH9yvYx1hN5pAf6ox7qW dTkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bewilderbeest.net header.s=thorn header.b=VRFSmCsu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=bewilderbeest.net Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m12si338753edd.470.2021.09.29.08.47.18; Wed, 29 Sep 2021 08:47:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@bewilderbeest.net header.s=thorn header.b=VRFSmCsu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=bewilderbeest.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343510AbhI2L4M (ORCPT + 99 others); Wed, 29 Sep 2021 07:56:12 -0400 Received: from thorn.bewilderbeest.net ([71.19.156.171]:52975 "EHLO thorn.bewilderbeest.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343496AbhI2L4F (ORCPT ); Wed, 29 Sep 2021 07:56:05 -0400 Received: from hatter.bewilderbeest.net (71-212-29-146.tukw.qwest.net [71.212.29.146]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: zev) by thorn.bewilderbeest.net (Postfix) with ESMTPSA id 0769E703; Wed, 29 Sep 2021 04:54:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bewilderbeest.net; s=thorn; t=1632916464; bh=TO54FDsoCMWCMt79Pdb9/ZG9fjkHhkFEnzaM9kEuuFY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VRFSmCsuA73GFLA2ZHn1JHXvx/nQv0K/qCNkNKiFrd2PdnRnKilrKd5z0zpb3mwwH mSZgbq9RE1MUVuwlHAVYZi9Rp3ApmmZLsJOloly5AU1DJZgNyb0U4dHpnVjvDRVb5a 8eBWHqXed0OrO6Yx+f50VYXSZriDiFVU7p46SiRU= From: Zev Weiss To: openbmc@lists.ozlabs.org Cc: Greg Kroah-Hartman , Jeremy Kerr , Joel Stanley , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Zev Weiss , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/6] mtd: core: clear out unregistered devices a bit more Date: Wed, 29 Sep 2021 04:54:04 -0700 Message-Id: <20210929115409.21254-3-zev@bewilderbeest.net> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210929115409.21254-1-zev@bewilderbeest.net> References: <20210929115409.21254-1-zev@bewilderbeest.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This allows an MTD device that has been unregistered to be easily re-registered later without triggering "already registered" warnings in mtd_device_parse_register() and add_mtd_device(). Signed-off-by: Zev Weiss --- drivers/mtd/mtdcore.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c index c8fd7f758938..e22266f63ae9 100644 --- a/drivers/mtd/mtdcore.c +++ b/drivers/mtd/mtdcore.c @@ -747,6 +747,9 @@ int del_mtd_device(struct mtd_info *mtd) device_unregister(&mtd->dev); + /* Clear dev so mtd can be safely re-registered later if desired */ + memset(&mtd->dev, 0, sizeof(mtd->dev)); + idr_remove(&mtd_idr, mtd->index); of_node_put(mtd_get_of_node(mtd)); @@ -1018,8 +1021,10 @@ int mtd_device_unregister(struct mtd_info *master) { int err; - if (master->_reboot) + if (master->_reboot) { unregister_reboot_notifier(&master->reboot_notifier); + memset(&master->reboot_notifier, 0, sizeof(master->reboot_notifier)); + } if (master->otp_user_nvmem) nvmem_unregister(master->otp_user_nvmem); -- 2.33.0