Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4320046imu; Mon, 14 Jan 2019 20:25:44 -0800 (PST) X-Google-Smtp-Source: ALg8bN4h3BclxhHRj3ytfOtleDYbkQZcUYK2UJIn7SvqmOo7tXhf9M45lDgOAKkph8Gt003PpvxO X-Received: by 2002:a63:8ac4:: with SMTP id y187mr2015434pgd.446.1547526344527; Mon, 14 Jan 2019 20:25:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547526344; cv=none; d=google.com; s=arc-20160816; b=ATnze0dqmpOSg9JZOzA62dDuikYivQC7ZAnh2citUI0ih6LPsxDfpKyRK4uTepwdW8 7ujtmqCpWYxrHa3MLlaukqgdF2U+Xx+KiK3VQlOUOjRiwOGalTSdK9982xvJUyIf6WhN kuFx8qT0t2uZSA7oP147qNvWkEEC6jc7vi4ek/J02JI9pWbaJG/MM57fcc9QD9WlOAl4 2FN2BDaFewibaqRc/ZiDC6yUUBRerMnpBKcRWCvtrMO4ESAWh65tAZHtZlFHIFx8fXNk Dz+MxjKL0ldipwF84yGVHksYm75SgOWnqy7cK978zQ7xczeIhDgzhsBhEXfok8u5z8G/ v5NQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:subject:from:references:in-reply-to :message-id:cc:to; bh=V9Mq36ImmnlZ7juzYLEgMxYqNHBSHs4kpnQ8NVdRNK4=; b=AjHXxF+wEt8rs4XujGgZr89r6daT0DN1kIg0KLz28owL9T+6QDkV0PiqKujJkYGkk/ qi0D89yfIW7S+y27iqTW+EhRTPSaOr2jYiBgiLHjLNrdi+9ad4QmpuQQgW6DI5h15TgC U9uQQmGXfkIMlzGKy/hWnvi19SOqWzqrIumifJg54Ke+BEmKuRe0jiFYnHq7F5ju4G2o Pa1EG2VNJp6z5Q21ZRAZPdyogSHsWzGDXpu1zkGBKbgqggaKOMvofvSS/5FC8zQW5nML dTbWwSghnBWKEw2khy968/t1lSyXk9N0r0GLGjFTYYSg3f7cJe0vfN0NQY+gHkOEfLzT lEJA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h9si2238829pli.418.2019.01.14.20.25.28; Mon, 14 Jan 2019 20:25:44 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728238AbfAOEW3 (ORCPT + 99 others); Mon, 14 Jan 2019 23:22:29 -0500 Received: from kvm5.telegraphics.com.au ([98.124.60.144]:37482 "EHLO kvm5.telegraphics.com.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728145AbfAOEW1 (ORCPT ); Mon, 14 Jan 2019 23:22:27 -0500 Received: by kvm5.telegraphics.com.au (Postfix, from userid 502) id 552DE29E67; Mon, 14 Jan 2019 23:22:24 -0500 (EST) To: Arnd Bergmann , Greg Kroah-Hartman , Geert Uytterhoeven Cc: linux-kernel@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linuxppc-dev@lists.ozlabs.org Message-Id: <833b60b5efaac347849e2bd438f383f921f7469a.1547525936.git.fthain@telegraphics.com.au> In-Reply-To: References: From: Finn Thain Subject: [PATCH v9 10/22] m68k/atari: Implement arch_nvram_ops methods and enable CONFIG_HAVE_ARCH_NVRAM_OPS Date: Tue, 15 Jan 2019 15:18:56 +1100 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Atari RTC NVRAM uses a checksum so implement the remaining arch_nvram_ops methods for the set_checksum and initialize ioctls. Enable CONFIG_HAVE_ARCH_NVRAM_OPS. Acked-by: Geert Uytterhoeven Signed-off-by: Finn Thain --- Changed since v8: - Moved the HAVE_ARCH_NVRAM_OPS symbol to common code as suggested by Christoph Hellwig. - Renamed functions to avoid name collisions with nvram.h. Changed since v7: - Changed the default for CONFIG_NVRAM, because "select NVRAM" was removed from ATARI_SCSI in patch 1. --- arch/Kconfig | 3 +++ arch/m68k/Kconfig.machine | 1 + arch/m68k/atari/nvram.c | 24 ++++++++++++++++++++++++ drivers/char/Kconfig | 3 ++- 4 files changed, 30 insertions(+), 1 deletion(-) diff --git a/arch/Kconfig b/arch/Kconfig index 4cfb6de48f79..87393fb8141c 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -701,6 +701,9 @@ config HAVE_ARCH_HASH file which provides platform-specific implementations of some functions in or fs/namei.c. +config HAVE_ARCH_NVRAM_OPS + bool + config ISA_BUS_API def_bool ISA diff --git a/arch/m68k/Kconfig.machine b/arch/m68k/Kconfig.machine index 328ba83d735b..ad584e3eb8f7 100644 --- a/arch/m68k/Kconfig.machine +++ b/arch/m68k/Kconfig.machine @@ -16,6 +16,7 @@ config ATARI bool "Atari support" depends on MMU select MMU_MOTOROLA if MMU + select HAVE_ARCH_NVRAM_OPS help This option enables support for the 68000-based Atari series of computers (including the TT, Falcon and Medusa). If you plan to use diff --git a/arch/m68k/atari/nvram.c b/arch/m68k/atari/nvram.c index e75adebe6e7d..c347fd206ddf 100644 --- a/arch/m68k/atari/nvram.c +++ b/arch/m68k/atari/nvram.c @@ -74,6 +74,26 @@ static void __nvram_set_checksum(void) __nvram_write_byte(sum, ATARI_CKS_LOC + 1); } +static long atari_nvram_set_checksum(void) +{ + spin_lock_irq(&rtc_lock); + __nvram_set_checksum(); + spin_unlock_irq(&rtc_lock); + return 0; +} + +static long atari_nvram_initialize(void) +{ + loff_t i; + + spin_lock_irq(&rtc_lock); + for (i = 0; i < NVRAM_BYTES; ++i) + __nvram_write_byte(0, i); + __nvram_set_checksum(); + spin_unlock_irq(&rtc_lock); + return 0; +} + static ssize_t atari_nvram_read(char *buf, size_t count, loff_t *ppos) { char *p = buf; @@ -113,6 +133,8 @@ static ssize_t atari_nvram_write(char *buf, size_t count, loff_t *ppos) static ssize_t atari_nvram_get_size(void) { + if (!MACH_IS_ATARI) + return -ENODEV; return NVRAM_BYTES; } @@ -120,6 +142,8 @@ const struct nvram_ops arch_nvram_ops = { .read = atari_nvram_read, .write = atari_nvram_write, .get_size = atari_nvram_get_size, + .set_checksum = atari_nvram_set_checksum, + .initialize = atari_nvram_initialize, }; EXPORT_SYMBOL(arch_nvram_ops); diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig index a8cac68de177..ce9979529cf3 100644 --- a/drivers/char/Kconfig +++ b/drivers/char/Kconfig @@ -244,7 +244,8 @@ source "drivers/char/hw_random/Kconfig" config NVRAM tristate "/dev/nvram support" - depends on X86 || GENERIC_NVRAM + depends on X86 || GENERIC_NVRAM || HAVE_ARCH_NVRAM_OPS + default M68K ---help--- If you say Y here and create a character special file /dev/nvram with major number 10 and minor number 144 using mknod ("man mknod"), -- 2.19.2