Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc/nvram: Allow byte length reads from mmio NVRAM driver

Add a byte length read and write interface compatible with the
nvram_generic driver interface to the mmio driver.

Signed-off-by: Martyn Welch <martyn.welch@gefanuc.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>

authored by

Martyn Welch and committed by
Benjamin Herrenschmidt
690a2d07 ae142e0c

+32
+32
arch/powerpc/sysdev/mmio_nvram.c
··· 53 53 return count; 54 54 } 55 55 56 + static unsigned char mmio_nvram_read_val(int addr) 57 + { 58 + unsigned long flags; 59 + unsigned char val; 60 + 61 + if (addr >= mmio_nvram_len) 62 + return 0xff; 63 + 64 + spin_lock_irqsave(&mmio_nvram_lock, flags); 65 + 66 + val = ioread8(mmio_nvram_start + addr); 67 + 68 + spin_unlock_irqrestore(&mmio_nvram_lock, flags); 69 + 70 + return val; 71 + } 72 + 56 73 static ssize_t mmio_nvram_write(char *buf, size_t count, loff_t *index) 57 74 { 58 75 unsigned long flags; ··· 87 70 88 71 *index += count; 89 72 return count; 73 + } 74 + 75 + void mmio_nvram_write_val(int addr, unsigned char val) 76 + { 77 + unsigned long flags; 78 + 79 + if (addr < mmio_nvram_len) { 80 + spin_lock_irqsave(&mmio_nvram_lock, flags); 81 + 82 + iowrite8(val, mmio_nvram_start + addr); 83 + 84 + spin_unlock_irqrestore(&mmio_nvram_lock, flags); 85 + } 90 86 } 91 87 92 88 static ssize_t mmio_nvram_get_size(void) ··· 144 114 printk(KERN_INFO "mmio NVRAM, %luk at 0x%lx mapped to %p\n", 145 115 mmio_nvram_len >> 10, nvram_addr, mmio_nvram_start); 146 116 117 + ppc_md.nvram_read_val = mmio_nvram_read_val; 118 + ppc_md.nvram_write_val = mmio_nvram_write_val; 147 119 ppc_md.nvram_read = mmio_nvram_read; 148 120 ppc_md.nvram_write = mmio_nvram_write; 149 121 ppc_md.nvram_size = mmio_nvram_get_size;