From patchwork Sat Jul 25 07:46:14 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Finn Thain X-Patchwork-Id: 499922 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id D88D91402ED for ; Sat, 25 Jul 2015 18:10:13 +1000 (AEST) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id BAEB81A2BBF for ; Sat, 25 Jul 2015 18:10:13 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Received: from kvm5.telegraphics.com.au (kvm5.telegraphics.com.au [98.124.60.144]) by lists.ozlabs.org (Postfix) with ESMTP id E2C1C1A0616 for ; Sat, 25 Jul 2015 17:56:51 +1000 (AEST) Received: by kvm5.telegraphics.com.au (Postfix, from userid 502) id A37CE294E9; Sat, 25 Jul 2015 03:56:48 -0400 (EDT) Message-Id: <20150725074603.183300268@telegraphics.com.au> User-Agent: quilt/0.50-1 Date: Sat, 25 Jul 2015 17:46:14 +1000 From: Finn Thain To: , , , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Arnd Bergmann , Greg Kroah-Hartman Subject: [RFC v5 15/26] powerpc: Implement arch_nvram_ops.get_size() and remove old nvram_* exports References: <20150725074559.543547894@telegraphics.com.au> Content-Disposition: inline; filename=ppc32-introduce-nvram_ops-get_size X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" Implement arch_nvram_ops for PPC32 and make use of it in the generic_nvram misc device module so that the nvram_* function exports can be removed. Signed-off-by: Finn Thain --- arch/powerpc/include/asm/nvram.h | 3 --- arch/powerpc/kernel/setup_32.c | 10 +++++++--- drivers/char/generic_nvram.c | 24 ++++++++++++------------ 3 files changed, 19 insertions(+), 18 deletions(-) Index: linux/arch/powerpc/include/asm/nvram.h =================================================================== --- linux.orig/arch/powerpc/include/asm/nvram.h 2015-07-25 17:45:38.000000000 +1000 +++ linux/arch/powerpc/include/asm/nvram.h 2015-07-25 17:45:41.000000000 +1000 @@ -98,7 +98,4 @@ extern int nvram_write_os_partition(stru unsigned int err_type, unsigned int error_log_cnt); -/* Determine NVRAM size */ -extern ssize_t nvram_get_size(void); - #endif /* _ASM_POWERPC_NVRAM_H */ Index: linux/arch/powerpc/kernel/setup_32.c =================================================================== --- linux.orig/arch/powerpc/kernel/setup_32.c 2015-07-25 17:45:38.000000000 +1000 +++ linux/arch/powerpc/kernel/setup_32.c 2015-07-25 17:45:41.000000000 +1000 @@ -186,13 +186,12 @@ void nvram_write_byte(unsigned char val, } EXPORT_SYMBOL(nvram_write_byte); -ssize_t nvram_get_size(void) +static ssize_t ppc_nvram_get_size(void) { if (ppc_md.nvram_size) return ppc_md.nvram_size(); - return -1; + return -ENODEV; } -EXPORT_SYMBOL(nvram_get_size); void nvram_sync(void) { @@ -201,6 +200,11 @@ void nvram_sync(void) } EXPORT_SYMBOL(nvram_sync); +const struct nvram_ops arch_nvram_ops = { + .get_size = ppc_nvram_get_size, +}; +EXPORT_SYMBOL(arch_nvram_ops); + #endif /* CONFIG_NVRAM */ int __init ppc_init(void) Index: linux/drivers/char/generic_nvram.c =================================================================== --- linux.orig/drivers/char/generic_nvram.c 2015-07-25 17:45:38.000000000 +1000 +++ linux/drivers/char/generic_nvram.c 2015-07-25 17:45:41.000000000 +1000 @@ -27,8 +27,6 @@ #include #endif -#define NVRAM_SIZE 8192 - static DEFINE_MUTEX(nvram_mutex); static ssize_t nvram_len; @@ -149,20 +147,22 @@ static struct miscdevice nvram_dev = { int __init nvram_init(void) { - int ret = 0; + int ret; - printk(KERN_INFO "Generic non-volatile memory driver v%s\n", - NVRAM_VERSION); - ret = misc_register(&nvram_dev); - if (ret != 0) - goto out; + if (arch_nvram_ops.get_size == NULL) + return -ENODEV; - nvram_len = nvram_get_size(); + nvram_len = arch_nvram_ops.get_size(); if (nvram_len < 0) - nvram_len = NVRAM_SIZE; + return nvram_len; -out: - return ret; + ret = misc_register(&nvram_dev); + if (ret) + return ret; + + pr_info("Generic non-volatile memory driver v%s\n", NVRAM_VERSION); + + return 0; } void __exit nvram_cleanup(void)