/* * * mwavedd.c -- mwave device driver * * * Written By: Mike Sullivan IBM Corporation * * Copyright (C) 1999 IBM Corporation * * 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. * * NO WARRANTY * THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR * CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT * LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is * solely responsible for determining the appropriateness of using and * distributing the Program and assumes all risks associated with its * exercise of rights under this Agreement, including but not limited to * the risks and costs of program errors, damage to or loss of data, * programs or equipment, and unavailability or interruption of operations. * * DISCLAIMER OF LIABILITY * NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED * HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES * * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * * 10/23/2000 - Alpha Release * First release to the public */ #include <linux/module.h> #include <linux/kernel.h> #include <linux/fs.h> #include <linux/init.h> #include <linux/major.h> #include <linux/miscdevice.h> #include <linux/device.h> #include <linux/serial.h> #include <linux/sched.h> #include <linux/spinlock.h> #include <linux/mutex.h> #include <linux/delay.h> #include <linux/serial_8250.h> #include <linux/nospec.h> #include "smapi.h" #include "mwavedd.h" #include "3780i.h" #include "tp3780i.h" MODULE_DESCRIPTION(…) …; MODULE_AUTHOR(…) …; MODULE_LICENSE(…) …; /* * These parameters support the setting of MWave resources. Note that no * checks are made against other devices (ie. superio) for conflicts. * We'll depend on users using the tpctl utility to do that for now */ static DEFINE_MUTEX(mwave_mutex); int mwave_debug = …; int mwave_3780i_irq = …; int mwave_3780i_io = …; int mwave_uart_irq = …; int mwave_uart_io = …; module_param(mwave_debug, int, 0); module_param_hw(mwave_3780i_irq, int, irq, 0); module_param_hw(mwave_3780i_io, int, ioport, 0); module_param_hw(mwave_uart_irq, int, irq, 0); module_param_hw(mwave_uart_io, int, ioport, 0); static int mwave_open(struct inode *inode, struct file *file); static int mwave_close(struct inode *inode, struct file *file); static long mwave_ioctl(struct file *filp, unsigned int iocmd, unsigned long ioarg); MWAVE_DEVICE_DATA mwave_s_mdd; static int mwave_open(struct inode *inode, struct file *file) { … } static int mwave_close(struct inode *inode, struct file *file) { … } static long mwave_ioctl(struct file *file, unsigned int iocmd, unsigned long ioarg) { … } static ssize_t mwave_read(struct file *file, char __user *buf, size_t count, loff_t * ppos) { … } static ssize_t mwave_write(struct file *file, const char __user *buf, size_t count, loff_t * ppos) { … } static int register_serial_portandirq(unsigned int port, int irq) { … } static const struct file_operations mwave_fops = …; static struct miscdevice mwave_misc_dev = …; #if 0 /* totally b0rked */ /* * sysfs support <[email protected]> */ struct device mwave_device; /* Prevent code redundancy, create a macro for mwave_show_* functions. */ #define mwave_show_function … /* All of our attributes are read attributes. */ #define mwave_dev_rd_attr … mwave_dev_rd_attr (3780i_dma, "%i\n", usDspDma); mwave_dev_rd_attr (3780i_irq, "%i\n", usDspIrq); mwave_dev_rd_attr (3780i_io, "%#.4x\n", usDspBaseIO); mwave_dev_rd_attr (uart_irq, "%i\n", usUartIrq); mwave_dev_rd_attr (uart_io, "%#.4x\n", usUartBaseIO); static struct device_attribute * const mwave_dev_attrs[] = { &dev_attr_3780i_dma, &dev_attr_3780i_irq, &dev_attr_3780i_io, &dev_attr_uart_irq, &dev_attr_uart_io, }; #endif /* * mwave_init is called on module load * * mwave_exit is called on module unload * mwave_exit is also used to clean up after an aborted mwave_init */ static void mwave_exit(void) { … } module_exit(mwave_exit); static int __init mwave_init(void) { … } module_init(…) …;