From patchwork Wed Mar 1 15:22:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 62961 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp3693403wrd; Wed, 1 Mar 2023 07:26:53 -0800 (PST) X-Google-Smtp-Source: AK7set9cngcZl9rT5g1XY2hW34k6ECbn8OUkiehKxD53hbV8LFfnqcxu55bYqa69i/z3AGwaIJYd X-Received: by 2002:a17:906:ccca:b0:8b1:7e1a:ef22 with SMTP id ot10-20020a170906ccca00b008b17e1aef22mr6491801ejb.45.1677684413068; Wed, 01 Mar 2023 07:26:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677684413; cv=none; d=google.com; s=arc-20160816; b=oOmHkTYBGZD1cmxc9yq6KWGe7C7VPv9xLlICdubPyScUn8cg8drPPryosTKIVzalHj 4JV1/p7MFS8SeS4eZAT13Bkphkk1SEc9JYsyvPGdv80iGlcUT1elKDIeToZDF6lhIc5H H3JsfolB3srQR9iYEU7t29OYfGhFM/IycHdlr9+DPVhO9Me7eOgmJFbe5h26Xguqbb+x oJNfGM8i+uLy95Ef2Kl61m83js0nT92UFKI9vPo1HhSEa1dBqm19PvxmrkP+zCrDf27k AcGpfzokTOFbHgBw01qvbkdv44b68wXDC7aUyIlNkofYM1R//dWQm8rjeRx3sHmGoJ8c l4YQ== 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=Q/yvRwDf0AdtbTrlrjDEi4BXF/Fzx1LyWUDN6tw49lM=; b=1BLqRoHNn7uyD/NWteEH6L3Zd2Mbk0yMQFQSASqNMUmKXopIwY2ts32mrZuBfip5NE SDXD7OkcwH8QqAwCEfRBXCJ/fsDuY8k7X0E2N57iZgwmozA9hc79GUkktBYvPL2xeV6a ex5onb5F9KmnpA9KV6rp0NHyyHqYd+HcN0++CPSLYvgohOdNadEXD5P2qGcWJpVFDNzi 4L6s4cUGCqx0wk4XU6i9A2mcNSLmtD+DZxTFUTfUg0iV+CBK0AfG2JP2x5G0Zjt8xVQR w0x/fRao3KuXw+8yGgErPmOq3/L16JMe+DIeBqUXCm2yGcsRcgGq62uIqRI6Kd4rQnld DabQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b="QaO/w24J"; 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=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r14-20020aa7cfce000000b004beb39bf058si593232edy.83.2023.03.01.07.26.30; Wed, 01 Mar 2023 07:26:53 -0800 (PST) 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=@bootlin.com header.s=gm1 header.b="QaO/w24J"; 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=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230380AbjCAPXZ (ORCPT + 99 others); Wed, 1 Mar 2023 10:23:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230330AbjCAPW4 (ORCPT ); Wed, 1 Mar 2023 10:22:56 -0500 Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3CE761BA; Wed, 1 Mar 2023 07:22:52 -0800 (PST) Received: (Authenticated sender: miquel.raynal@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id 3F1476000E; Wed, 1 Mar 2023 15:22:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1677684171; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Q/yvRwDf0AdtbTrlrjDEi4BXF/Fzx1LyWUDN6tw49lM=; b=QaO/w24JvA08uvMecfKs3r8CgraP6VjdyZkEd/5pug68+pTJmHBixd1HJCmMo85/zrv3bn 56M8cs3BeKlGKeLmp1uYGwwGSEDlr8IoNrVry0MpPTXW0lUNAm7pF0wEUrO/l8mbnDPhG9 S5lj3Q4dae8TjES7TMFm1P9IPjQIBqwJxo7jWBbL8sI6PAP8LUgd0oJ0fN3gIzLRORP5Ts JwITliC2/ZSI0S3UwCttilFc3fzJKMQiaAX3wu/IuvhiJAuAh/2nf3LkY70bgFh7OE9sHA wISD71WHqi/EZyx+EMDKv6oKIUlu8lAfukcjNFr7n+/NL+EAbslHgeNSnjjT1Q== From: Miquel Raynal To: Srinivas Kandagatla , Cc: Greg Kroah-Hartman , Michael Walle , devicetree@vger.kernel.org, Rob Herring , Frank Rowand , Robert Marko , Luka Perkov , Thomas Petazzoni , rafal@milecki.pl, Miquel Raynal Subject: [PATCH 8/8] nvmem: layouts: onie-tlv: Convert layout driver into a module Date: Wed, 1 Mar 2023 16:22:39 +0100 Message-Id: <20230301152239.531194-9-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230301152239.531194-1-miquel.raynal@bootlin.com> References: <20230301152239.531194-1-miquel.raynal@bootlin.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759179611372156489?= X-GMAIL-MSGID: =?utf-8?q?1759179611372156489?= The nvmem core has already been converted to accept layout drivers compiled as modules. So in order to make this change effective we need to convert this driver so it can also be compiled as a module. We then need to expose the match table, provide MODULE_* macros, use module_init/exit() instead of the early subsys_initcall() and of course update the Kconfig symbol type to tristate. Signed-off-by: Miquel Raynal --- drivers/nvmem/layouts/Kconfig | 2 +- drivers/nvmem/layouts/onie-tlv.c | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/drivers/nvmem/layouts/Kconfig b/drivers/nvmem/layouts/Kconfig index 3f2d73282242..7ff1ee1c1f05 100644 --- a/drivers/nvmem/layouts/Kconfig +++ b/drivers/nvmem/layouts/Kconfig @@ -12,7 +12,7 @@ config NVMEM_LAYOUT_SL28_VPD If unsure, say N. config NVMEM_LAYOUT_ONIE_TLV - bool "ONIE tlv support" + tristate "ONIE tlv support" select CRC32 help Say Y here if you want to support the Open Compute Project ONIE diff --git a/drivers/nvmem/layouts/onie-tlv.c b/drivers/nvmem/layouts/onie-tlv.c index 767f39fff717..d45b7301a69d 100644 --- a/drivers/nvmem/layouts/onie-tlv.c +++ b/drivers/nvmem/layouts/onie-tlv.c @@ -230,6 +230,7 @@ static const struct of_device_id onie_tlv_of_match_table[] = { { .compatible = "onie,tlv-layout", }, {}, }; +MODULE_DEVICE_TABLE(of, onie_tlv_of_match_table); static struct nvmem_layout onie_tlv_layout = { .name = "ONIE tlv layout", @@ -241,4 +242,16 @@ static int __init onie_tlv_init(void) { return nvmem_layout_register(&onie_tlv_layout); } -subsys_initcall(onie_tlv_init); + +static void __exit onie_tlv_exit(void) +{ + nvmem_layout_unregister(&onie_tlv_layout); +} + +module_init(onie_tlv_init); +module_exit(onie_tlv_exit); + +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Miquel Raynal "); +MODULE_DESCRIPTION("NVMEM layout driver for Onie TLV table parsing"); +MODULE_ALIAS("NVMEM layout driver for Onie TLV table parsing");