mirror of
https://github.com/torvalds/linux.git
synced 2024-12-23 11:21:33 +00:00
74ba9207e1
Based on 1 normalized pattern(s): this program is free software you can redistribute it and or modify it under the terms of the gnu general public license as published by the free software foundation either version 2 of the license or at your option any later version this program is distributed in the hope that it will be useful but without any warranty without even the implied warranty of merchantability or fitness for a particular purpose see the gnu general public license for more details you should have received a copy of the gnu general public license along with this program if not write to the free software foundation inc 675 mass ave cambridge ma 02139 usa extracted by the scancode license scanner the SPDX license identifier GPL-2.0-or-later has been chosen to replace the boilerplate/reference in 441 file(s). Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Michael Ellerman <mpe@ellerman.id.au> (powerpc) Reviewed-by: Richard Fontana <rfontana@redhat.com> Reviewed-by: Allison Randal <allison@lohutok.net> Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org> Cc: linux-spdx@vger.kernel.org Link: https://lkml.kernel.org/r/20190520071858.739733335@linutronix.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
89 lines
2.0 KiB
C
89 lines
2.0 KiB
C
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
/*
|
|
* ISA Plug & Play support
|
|
* Copyright (c) by Jaroslav Kysela <perex@perex.cz>
|
|
*/
|
|
|
|
#include <linux/module.h>
|
|
#include <linux/isapnp.h>
|
|
#include <linux/proc_fs.h>
|
|
#include <linux/init.h>
|
|
#include <linux/uaccess.h>
|
|
|
|
extern struct pnp_protocol isapnp_protocol;
|
|
|
|
static struct proc_dir_entry *isapnp_proc_bus_dir = NULL;
|
|
|
|
static loff_t isapnp_proc_bus_lseek(struct file *file, loff_t off, int whence)
|
|
{
|
|
return fixed_size_llseek(file, off, whence, 256);
|
|
}
|
|
|
|
static ssize_t isapnp_proc_bus_read(struct file *file, char __user * buf,
|
|
size_t nbytes, loff_t * ppos)
|
|
{
|
|
struct pnp_dev *dev = PDE_DATA(file_inode(file));
|
|
int pos = *ppos;
|
|
int cnt, size = 256;
|
|
|
|
if (pos >= size)
|
|
return 0;
|
|
if (nbytes >= size)
|
|
nbytes = size;
|
|
if (pos + nbytes > size)
|
|
nbytes = size - pos;
|
|
cnt = nbytes;
|
|
|
|
if (!access_ok(buf, cnt))
|
|
return -EINVAL;
|
|
|
|
isapnp_cfg_begin(dev->card->number, dev->number);
|
|
for (; pos < 256 && cnt > 0; pos++, buf++, cnt--) {
|
|
unsigned char val;
|
|
val = isapnp_read_byte(pos);
|
|
__put_user(val, buf);
|
|
}
|
|
isapnp_cfg_end();
|
|
|
|
*ppos = pos;
|
|
return nbytes;
|
|
}
|
|
|
|
static const struct file_operations isapnp_proc_bus_file_operations = {
|
|
.owner = THIS_MODULE,
|
|
.llseek = isapnp_proc_bus_lseek,
|
|
.read = isapnp_proc_bus_read,
|
|
};
|
|
|
|
static int isapnp_proc_attach_device(struct pnp_dev *dev)
|
|
{
|
|
struct pnp_card *bus = dev->card;
|
|
struct proc_dir_entry *de, *e;
|
|
char name[16];
|
|
|
|
if (!(de = bus->procdir)) {
|
|
sprintf(name, "%02x", bus->number);
|
|
de = bus->procdir = proc_mkdir(name, isapnp_proc_bus_dir);
|
|
if (!de)
|
|
return -ENOMEM;
|
|
}
|
|
sprintf(name, "%02x", dev->number);
|
|
e = dev->procent = proc_create_data(name, S_IFREG | S_IRUGO, de,
|
|
&isapnp_proc_bus_file_operations, dev);
|
|
if (!e)
|
|
return -ENOMEM;
|
|
proc_set_size(e, 256);
|
|
return 0;
|
|
}
|
|
|
|
int __init isapnp_proc_init(void)
|
|
{
|
|
struct pnp_dev *dev;
|
|
|
|
isapnp_proc_bus_dir = proc_mkdir("bus/isapnp", NULL);
|
|
protocol_for_each_dev(&isapnp_protocol, dev) {
|
|
isapnp_proc_attach_device(dev);
|
|
}
|
|
return 0;
|
|
}
|