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

Configure Feed

Select the types of activity you want to include in your feed.

at v6.18-rc4 99 lines 2.1 kB view raw
1// SPDX-License-Identifier: GPL-2.0-or-later 2/* 3 * EISA "eeprom" support routines 4 * 5 * Copyright (C) 2001 Thomas Bogendoerfer <tsbogend at parisc-linux.org> 6 */ 7 8#include <linux/module.h> 9#include <linux/init.h> 10#include <linux/kernel.h> 11#include <linux/miscdevice.h> 12#include <linux/slab.h> 13#include <linux/fs.h> 14#include <asm/io.h> 15#include <linux/uaccess.h> 16#include <asm/eisa_eeprom.h> 17 18static loff_t eisa_eeprom_llseek(struct file *file, loff_t offset, int origin) 19{ 20 return fixed_size_llseek(file, offset, origin, HPEE_MAX_LENGTH); 21} 22 23static ssize_t eisa_eeprom_read(struct file * file, 24 char __user *buf, size_t count, loff_t *ppos ) 25{ 26 unsigned char *tmp; 27 ssize_t ret; 28 int i; 29 30 if (*ppos < 0 || *ppos >= HPEE_MAX_LENGTH) 31 return 0; 32 33 count = *ppos + count < HPEE_MAX_LENGTH ? count : HPEE_MAX_LENGTH - *ppos; 34 tmp = kmalloc(count, GFP_KERNEL); 35 if (tmp) { 36 for (i = 0; i < count; i++) 37 tmp[i] = readb(eisa_eeprom_addr+(*ppos)++); 38 39 if (copy_to_user (buf, tmp, count)) 40 ret = -EFAULT; 41 else 42 ret = count; 43 kfree (tmp); 44 } else 45 ret = -ENOMEM; 46 47 return ret; 48} 49 50static int eisa_eeprom_open(struct inode *inode, struct file *file) 51{ 52 if (file->f_mode & FMODE_WRITE) 53 return -EINVAL; 54 55 return 0; 56} 57 58static int eisa_eeprom_release(struct inode *inode, struct file *file) 59{ 60 return 0; 61} 62 63/* 64 * The various file operations we support. 65 */ 66static const struct file_operations eisa_eeprom_fops = { 67 .owner = THIS_MODULE, 68 .llseek = eisa_eeprom_llseek, 69 .read = eisa_eeprom_read, 70 .open = eisa_eeprom_open, 71 .release = eisa_eeprom_release, 72}; 73 74static struct miscdevice eisa_eeprom_dev = { 75 EISA_EEPROM_MINOR, 76 "eisa_eeprom", 77 &eisa_eeprom_fops 78}; 79 80static int __init eisa_eeprom_init(void) 81{ 82 int retval; 83 84 if (!eisa_eeprom_addr) 85 return -ENODEV; 86 87 retval = misc_register(&eisa_eeprom_dev); 88 if (retval < 0) { 89 printk(KERN_ERR "EISA EEPROM: cannot register misc device.\n"); 90 return retval; 91 } 92 93 printk(KERN_INFO "EISA EEPROM at 0x%px\n", eisa_eeprom_addr); 94 return 0; 95} 96 97MODULE_LICENSE("GPL"); 98 99module_init(eisa_eeprom_init);