Commit 75b6d5db authored by Linus Torvalds's avatar Linus Torvalds

Merge bk://ppc.bkbits.net/for-linus-ppc

into penguin.transmeta.com:/home/penguin/torvalds/repositories/kernel/linux
parents 3627be6d 97229062
Sony Programmable I/O Control Device Driver Readme
--------------------------------------------------
Copyright (C) 2001-2002 Stelian Pop <stelian@popies.net>
Copyright (C) 2001-2003 Stelian Pop <stelian@popies.net>
Copyright (C) 2001-2002 Alcôve <www.alcove.com>
Copyright (C) 2001 Michael Ashley <m.ashley@unsw.edu.au>
Copyright (C) 2001 Junichi Morita <jun1m@mars.dti.ne.jp>
......@@ -44,7 +44,7 @@ Several options can be passed to the sonypi driver, either by adding them
to /etc/modules.conf file, when the driver is compiled as a module or by
adding the following to the kernel command line (in your bootloader):
sonypi=minor[,verbose[,fnkeyinit[,camera[,compat[,mask]]]]]
sonypi=minor[,verbose[,fnkeyinit[,camera[,compat[,mask[,useinput]]]]]]
where:
......@@ -97,6 +97,11 @@ where:
SONYPI_MEYE_MASK 0x0400
SONYPI_MEMORYSTICK_MASK 0x0800
useinput: if set (which is the default) jogdial events are
forwarded to the input subsystem as mouse wheel
events.
Module use:
-----------
......
Vaio Picturebook Motion Eye Camera Driver Readme
------------------------------------------------
Copyright (C) 2001-2002 Stelian Pop <stelian@popies.net>
Copyright (C) 2001-2003 Stelian Pop <stelian@popies.net>
Copyright (C) 2001-2002 Alcôve <www.alcove.com>
Copyright (C) 2000 Andrew Tridgell <tridge@samba.org>
......
......@@ -39,12 +39,12 @@ cflags-$(CONFIG_MPENTIUM4) += $(call check_gcc,-march=pentium4,-march=i686)
cflags-$(CONFIG_MK6) += $(call check_gcc,-march=k6,-march=i586)
cflags-$(CONFIG_MK7) += $(call check_gcc,-march=athlon,-march=i686 -malign-functions=4)
cflags-$(CONFIG_MK8) += $(call check_gcc,-march=k8,$(call check_gcc,-march=athlon,-march=i686 -malign-functions=4))
cflags-$(CONFIG_MCRUSOE) += -march=i686 -malign-functions=0 -malign-jumps=0 -malign-loops=0
cflags-$(CONFIG_MCRUSOE) += -march=i686
cflags-$(CONFIG_MCRUSOE) += $(call check_gcc,-falign-functions=0 -falign-jumps=0 -falign-loops=0,-malign-functions=0 -malign-jumps=0 -malign-loops=0)
cflags-$(CONFIG_MWINCHIPC6) += $(call check_gcc,-march=winchip-c6,-march=i586)
cflags-$(CONFIG_MWINCHIP2) += $(call check_gcc,-march=winchip2,-march=i586)
cflags-$(CONFIG_MWINCHIP3D) += -march=i586
cflags-$(CONFIG_MCYRIXIII) += $(call check_gcc,-march=c3,-march=i486)
# The alignment flags change with gcc 3.2
cflags-$(CONFIG_MCYRIXIII) += $(call check_gcc,-falign-functions=0 -falign-jumps=0 -falign-loops=0,-malign-functions=0 -malign-jumps=0 -malign-loops=0)
cflags-$(CONFIG_MVIAC3_2) += $(call check_gcc,-march=c3-2,-march=i686)
......
......@@ -173,9 +173,10 @@ ENTRY(lcall27)
ENTRY(ret_from_fork)
# NOTE: this function takes a parameter but it's unused on x86.
pushl %eax
call schedule_tail
GET_THREAD_INFO(%ebp)
popl %eax
jmp syscall_exit
/*
......
......@@ -423,8 +423,12 @@ int dump_task_regs(struct task_struct *tsk, elf_gregset_t *regs)
* so the performance issues may eventually be a valid point.
* More important, however, is the fact that this allows us much
* more flexibility.
*
* The return value (in %eax) will be the "prev" task after
* the task-switch, and shows up in ret_from_fork in entry.S,
* for example.
*/
void __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
struct task_struct * __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
{
struct thread_struct *prev = &prev_p->thread,
*next = &next_p->thread;
......@@ -495,6 +499,7 @@ void __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
*/
tss->bitmap = INVALID_IO_BITMAP_OFFSET;
}
return prev_p;
}
asmlinkage int sys_fork(struct pt_regs regs)
......
......@@ -613,18 +613,6 @@ static void request_events(void *send_info)
atomic_set(&kcs_info->req_events, 1);
}
static int new_user(void *send_info)
{
if (!try_module_get(THIS_MODULE))
return -EBUSY;
return 0;
}
static void user_left(void *send_info)
{
module_put(THIS_MODULE);
}
/* Call every 10 ms. */
#define KCS_TIMEOUT_TIME_USEC 10000
#define KCS_USEC_PER_JIFFY (1000000/HZ)
......@@ -718,11 +706,10 @@ static void kcs_irq_handler(int irq, void *data, struct pt_regs *regs)
static struct ipmi_smi_handlers handlers =
{
sender: sender,
request_events: request_events,
new_user: new_user,
user_left: user_left,
set_run_to_completion: set_run_to_completion
.owner = THIS_MODULE,
.sender = sender,
.request_events = request_events,
.set_run_to_completion = set_run_to_completion,
};
static unsigned char ipmi_kcs_dev_rev;
......
......@@ -485,13 +485,14 @@ int ipmi_create_user(unsigned int if_num,
new_user->intf = ipmi_interfaces[if_num];
new_user->gets_events = 0;
rv = new_user->intf->handlers->new_user(new_user->intf->send_info);
if (rv)
if (!try_module_get(new_user->intf->handlers->owner)) {
rv = -ENODEV;
goto out_unlock;
}
write_lock_irqsave(&(new_user->intf->users_lock), flags);
list_add_tail(&(new_user->link), &(new_user->intf->users));
write_unlock_irqrestore(&(new_user->intf->users_lock), flags);
write_lock_irqsave(&new_user->intf->users_lock, flags);
list_add_tail(&new_user->link, &new_user->intf->users);
write_unlock_irqrestore(&new_user->intf->users_lock, flags);
out_unlock:
if (rv) {
......@@ -563,12 +564,12 @@ int ipmi_destroy_user(ipmi_user_t user)
unsigned long flags;
down_read(&interfaces_sem);
write_lock_irqsave(&(intf->users_lock), flags);
write_lock_irqsave(&intf->users_lock, flags);
rv = ipmi_destroy_user_nolock(user);
if (!rv)
intf->handlers->user_left(intf->send_info);
module_put(intf->handlers->owner);
write_unlock_irqrestore(&(intf->users_lock), flags);
write_unlock_irqrestore(&intf->users_lock, flags);
up_read(&interfaces_sem);
return rv;
}
......
/*
* Sony Programmable I/O Control Device driver for VAIO
*
* Copyright (C) 2001-2002 Stelian Pop <stelian@popies.net>
* Copyright (C) 2001-2003 Stelian Pop <stelian@popies.net>
*
* Copyright (C) 2001-2002 Alcve <www.alcove.com>
*
......@@ -33,6 +33,7 @@
#include <linux/config.h>
#include <linux/module.h>
#include <linux/input.h>
#include <linux/pci.h>
#include <linux/sched.h>
#include <linux/init.h>
......@@ -56,6 +57,7 @@ static int verbose; /* = 0 */
static int fnkeyinit; /* = 0 */
static int camera; /* = 0 */
static int compat; /* = 0 */
static int useinput = 1;
static unsigned long mask = 0xffffffff;
/* Inits the queue */
......@@ -335,6 +337,22 @@ void sonypi_irq(int irq, void *dev_id, struct pt_regs *regs) {
return;
found:
#if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
if (useinput) {
struct input_dev *jog_dev = &sonypi_device.jog_dev;
if (event == SONYPI_EVENT_JOGDIAL_PRESSED)
input_report_key(jog_dev, BTN_MIDDLE, 1);
else if (event == SONYPI_EVENT_ANYBUTTON_RELEASED)
input_report_key(jog_dev, BTN_MIDDLE, 0);
else if ((event == SONYPI_EVENT_JOGDIAL_UP) ||
(event == SONYPI_EVENT_JOGDIAL_UP_PRESSED))
input_report_rel(jog_dev, REL_WHEEL, 1);
else if ((event == SONYPI_EVENT_JOGDIAL_DOWN) ||
(event == SONYPI_EVENT_JOGDIAL_DOWN_PRESSED))
input_report_rel(jog_dev, REL_WHEEL, -1);
input_sync(jog_dev);
}
#endif /* CONFIG_INPUT || CONFIG_INPUT_MODULE */
sonypi_pushq(event);
}
......@@ -579,7 +597,7 @@ struct miscdevice sonypi_misc_device = {
-1, "sonypi", &sonypi_misc_fops
};
#if CONFIG_PM
#ifdef CONFIG_PM
static int sonypi_pm_callback(struct pm_dev *dev, pm_request_t rqst, void *data) {
static int old_camera_power;
......@@ -594,14 +612,14 @@ static int sonypi_pm_callback(struct pm_dev *dev, pm_request_t rqst, void *data)
sonypi_type2_dis();
else
sonypi_type1_dis();
#if !defined(CONFIG_ACPI)
#ifndef CONFIG_ACPI
/* disable ACPI mode */
if (fnkeyinit)
outb(0xf1, 0xb2);
#endif
break;
case PM_RESUME:
#if !defined(CONFIG_ACPI)
#ifndef CONFIG_ACPI
/* Enable ACPI mode to get Fn key events */
if (fnkeyinit)
outb(0xf0, 0xb2);
......@@ -692,7 +710,7 @@ static int __devinit sonypi_probe(struct pci_dev *pcidev) {
goto out3;
}
#if !defined(CONFIG_ACPI)
#ifndef CONFIG_ACPI
/* Enable ACPI mode to get Fn key events */
if (fnkeyinit)
outb(0xf0, 0xb2);
......@@ -715,14 +733,15 @@ static int __devinit sonypi_probe(struct pci_dev *pcidev) {
SONYPI_DRIVER_MINORVERSION);
printk(KERN_INFO "sonypi: detected %s model, "
"verbose = %d, fnkeyinit = %s, camera = %s, "
"compat = %s, mask = 0x%08lx\n",
"compat = %s, mask = 0x%08lx, useinput = %s\n",
(sonypi_device.model == SONYPI_DEVICE_MODEL_TYPE1) ?
"type1" : "type2",
verbose,
fnkeyinit ? "on" : "off",
camera ? "on" : "off",
compat ? "on" : "off",
mask);
mask,
useinput ? "on" : "off");
printk(KERN_INFO "sonypi: enabled at irq=%d, port1=0x%x, port2=0x%x\n",
sonypi_device.irq,
sonypi_device.ioport1, sonypi_device.ioport2);
......@@ -730,7 +749,24 @@ static int __devinit sonypi_probe(struct pci_dev *pcidev) {
printk(KERN_INFO "sonypi: device allocated minor is %d\n",
sonypi_misc_device.minor);
#if CONFIG_PM
#if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
if (useinput) {
/* Initialize the Input Drivers: */
sonypi_device.jog_dev.evbit[0] = BIT(EV_KEY) | BIT(EV_REL);
sonypi_device.jog_dev.keybit[LONG(BTN_MOUSE)] = BIT(BTN_MIDDLE);
sonypi_device.jog_dev.relbit[0] = BIT(REL_WHEEL);
sonypi_device.jog_dev.name = (char *) kmalloc(
sizeof(SONYPI_INPUTNAME), GFP_KERNEL);
sprintf(sonypi_device.jog_dev.name, SONYPI_INPUTNAME);
sonypi_device.jog_dev.id.bustype = BUS_ISA;
sonypi_device.jog_dev.id.vendor = PCI_VENDOR_ID_SONY;
input_register_device(&sonypi_device.jog_dev);
printk(KERN_INFO "%s installed.\n", sonypi_device.jog_dev.name);
}
#endif /* CONFIG_INPUT || CONFIG_INPUT_MODULE */
#ifdef CONFIG_PM
sonypi_device.pm = pm_register(PM_PCI_DEV, 0, sonypi_pm_callback);
#endif
......@@ -746,18 +782,26 @@ static int __devinit sonypi_probe(struct pci_dev *pcidev) {
static void __devexit sonypi_remove(void) {
#if CONFIG_PM
#ifdef CONFIG_PM
pm_unregister(sonypi_device.pm);
#endif
sonypi_call2(0x81, 0); /* make sure we don't get any more events */
#if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
if (useinput) {
input_unregister_device(&sonypi_device.jog_dev);
kfree(sonypi_device.jog_dev.name);
}
#endif /* CONFIG_INPUT || CONFIG_INPUT_MODULE */
if (camera)
sonypi_camera_off();
if (sonypi_device.model == SONYPI_DEVICE_MODEL_TYPE2)
sonypi_type2_dis();
else
sonypi_type1_dis();
#if !defined(CONFIG_ACPI)
#ifndef CONFIG_ACPI
/* disable ACPI mode */
if (fnkeyinit)
outb(0xf1, 0xb2);
......@@ -787,7 +831,7 @@ static void __exit sonypi_cleanup_module(void) {
#ifndef MODULE
static int __init sonypi_setup(char *str) {
int ints[7];
int ints[8];
str = get_options(str, ARRAY_SIZE(ints), ints);
if (ints[0] <= 0)
......@@ -808,6 +852,9 @@ static int __init sonypi_setup(char *str) {
if (ints[0] == 5)
goto out;
mask = ints[6];
if (ints[0] == 6)
goto out;
useinput = ints[7];
out:
return 1;
}
......@@ -836,5 +883,7 @@ MODULE_PARM(compat,"i");
MODULE_PARM_DESC(compat, "set this if you want to enable backward compatibility mode");
MODULE_PARM(mask, "i");
MODULE_PARM_DESC(mask, "set this to the mask of event you want to enable (see doc)");
MODULE_PARM(useinput, "i");
MODULE_PARM_DESC(useinput, "if you have a jogdial, set this if you would like it to use the modern Linux Input Driver system");
EXPORT_SYMBOL(sonypi_camera_command);
/*
* Sony Programmable I/O Control Device driver for VAIO
*
* Copyright (C) 2001-2002 Stelian Pop <stelian@popies.net>
* Copyright (C) 2001-2003 Stelian Pop <stelian@popies.net>
*
* Copyright (C) 2001-2002 Alcve <www.alcove.com>
*
......@@ -37,7 +37,7 @@
#ifdef __KERNEL__
#define SONYPI_DRIVER_MAJORVERSION 1
#define SONYPI_DRIVER_MINORVERSION 17
#define SONYPI_DRIVER_MINORVERSION 18
#define SONYPI_DEVICE_MODEL_TYPE1 1
#define SONYPI_DEVICE_MODEL_TYPE2 2
......@@ -45,6 +45,7 @@
#include <linux/config.h>
#include <linux/types.h>
#include <linux/pci.h>
#include <linux/input.h>
#include <linux/pm.h>
#include <linux/acpi.h>
#include "linux/sonypi.h"
......@@ -334,6 +335,9 @@ struct sonypi_queue {
unsigned char buf[SONYPI_BUF_SIZE];
};
/* The name of the Jog Dial for the input device drivers */
#define SONYPI_INPUTNAME "Sony VAIO Jog Dial"
struct sonypi_device {
struct pci_dev *dev;
u16 irq;
......@@ -347,7 +351,10 @@ struct sonypi_device {
struct sonypi_queue queue;
int open_count;
int model;
#if CONFIG_PM
#if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
struct input_dev jog_dev;
#endif
#ifdef CONFIG_PM
struct pm_dev *pm;
#endif
};
......@@ -363,7 +370,7 @@ struct sonypi_device {
printk(KERN_WARNING "sonypi command failed at %s : %s (line %d)\n", __FILE__, __FUNCTION__, __LINE__); \
}
#if !defined(CONFIG_ACPI)
#ifndef CONFIG_ACPI
extern int verbose;
static inline int ec_write(u8 addr, u8 value) {
......
......@@ -11,6 +11,7 @@
*/
#include <linux/config.h>
#include <linux/module.h>
#include <linux/types.h>
#include <linux/list.h>
#include <linux/init.h>
......@@ -69,8 +70,10 @@ int hpsb_ref_host(struct hpsb_host *host)
spin_lock_irqsave(&hosts_lock, flags);
list_for_each(lh, &hosts) {
if (host == list_entry(lh, struct hpsb_host, host_list)) {
if (host->driver->devctl(host, MODIFY_USAGE, 1)) {
host->driver->devctl(host, MODIFY_USAGE, 1);
if (try_module_get(host->driver->owner)) {
/* we're doing this twice and don't seem
to undo it.. --hch */
(void)try_module_get(host->driver->owner);
host->refcount++;
retval = 1;
}
......@@ -95,7 +98,7 @@ void hpsb_unref_host(struct hpsb_host *host)
{
unsigned long flags;
host->driver->devctl(host, MODIFY_USAGE, 0);
module_put(host->driver->owner);
spin_lock_irqsave(&hosts_lock, flags);
host->refcount--;
......
......@@ -92,12 +92,6 @@ enum devctl_cmd {
* Return void. */
CANCEL_REQUESTS,
/* Decrease host usage count if arg == 0, increase otherwise. Return
* 1 for success, 0 for failure. Increase usage may fail if the driver
* is in the process of shutting itself down. Decrease usage can not
* fail. */
MODIFY_USAGE,
/* Start or stop receiving isochronous channel in arg. Return void.
* This acts as an optimization hint, hosts are not required not to
* listen on unrequested channels. */
......@@ -147,6 +141,7 @@ enum reset_types {
};
struct hpsb_host_driver {
struct module *owner;
const char *name;
/* This function must store a pointer to the configuration ROM into the
......
......@@ -966,16 +966,6 @@ static int ohci_devctl(struct hpsb_host *host, enum devctl_cmd cmd, int arg)
dma_trm_reset(&ohci->at_resp_context);
break;
case MODIFY_USAGE:
if (arg) {
if (try_module_get(THIS_MODULE))
retval = 1;
} else {
module_put(THIS_MODULE);
retval = 1;
}
break;
case ISO_LISTEN_CHANNEL:
{
u64 mask;
......@@ -3202,6 +3192,7 @@ static quadlet_t ohci_hw_csr_reg(struct hpsb_host *host, int reg,
}
static struct hpsb_host_driver ohci1394_driver = {
.owner = THIS_MODULE,
.name = OHCI1394_DRIVER_NAME,
.get_rom = ohci_get_rom,
.transmit_packet = ohci_transmit,
......
......@@ -801,17 +801,6 @@ static int lynx_devctl(struct hpsb_host *host, enum devctl_cmd cmd, int arg)
break;
case MODIFY_USAGE:
if (arg) {
if (try_module_get(THIS_MODULE))
retval = 1;
} else {
module_put(THIS_MODULE);
retval = 1;
}
break;
case ISO_LISTEN_CHANNEL:
spin_lock_irqsave(&lynx->iso_rcv.lock, flags);
......@@ -1904,6 +1893,7 @@ static struct pci_driver lynx_pci_driver = {
};
static struct hpsb_host_driver lynx_driver = {
.owner = THIS_MODULE,
.name = PCILYNX_DRIVER_NAME,
.get_rom = get_lynx_rom,
.transmit_packet = lynx_transmit,
......
/*
* Motion Eye video4linux driver for Sony Vaio PictureBook
*
* Copyright (C) 2001-2002 Stelian Pop <stelian@popies.net>
* Copyright (C) 2001-2003 Stelian Pop <stelian@popies.net>
*
* Copyright (C) 2001-2002 Alcve <www.alcove.com>
*
......@@ -1225,6 +1225,42 @@ static struct video_device meye_template = {
.fops = &meye_fops,
};
#ifdef CONFIG_PM
static int meye_suspend(struct pci_dev *pdev, u32 state)
{
pci_save_state(pdev, meye.pm_state);
meye.pm_mchip_mode = meye.mchip_mode;
mchip_hic_stop();
mchip_set(MCHIP_MM_INTA, 0x0);
return 0;
}
static int meye_resume(struct pci_dev *pdev)
{
pci_restore_state(pdev, meye.pm_state);
pci_write_config_word(meye.mchip_dev, MCHIP_PCI_SOFTRESET_SET, 1);
mchip_delay(MCHIP_HIC_CMD, 0);
mchip_delay(MCHIP_HIC_STATUS, MCHIP_HIC_STATUS_IDLE);
wait_ms(1);
mchip_set(MCHIP_VRJ_SOFT_RESET, 1);
wait_ms(1);
mchip_set(MCHIP_MM_PCI_MODE, 5);
wait_ms(1);
mchip_set(MCHIP_MM_INTA, MCHIP_MM_INTA_HIC_1_MASK);
switch (meye.pm_mchip_mode) {
case MCHIP_HIC_MODE_CONT_OUT:
mchip_continuous_start();
break;
case MCHIP_HIC_MODE_CONT_COMP:
mchip_cont_compression_start();
break;
}
return 0;
}
#endif
static int __devinit meye_probe(struct pci_dev *pcidev,
const struct pci_device_id *ent) {
int ret;
......@@ -1391,6 +1427,10 @@ static struct pci_driver meye_driver = {
.id_table = meye_pci_tbl,
.probe = meye_probe,
.remove = __devexit_p(meye_remove),
#ifdef CONFIG_PM
.suspend = meye_suspend,
.resume = meye_resume,
#endif
};
static int __init meye_init_module(void) {
......
/*
* Motion Eye video4linux driver for Sony Vaio PictureBook
*
* Copyright (C) 2001-2002 Stelian Pop <stelian@popies.net>
* Copyright (C) 2001-2003 Stelian Pop <stelian@popies.net>
*
* Copyright (C) 2001-2002 Alcve <www.alcove.com>
*
......@@ -31,7 +31,13 @@
#define _MEYE_PRIV_H_
#define MEYE_DRIVER_MAJORVERSION 1
#define MEYE_DRIVER_MINORVERSION 5
#define MEYE_DRIVER_MINORVERSION 6
#include <linux/config.h>
#include <linux/types.h>
#include <linux/pci.h>
#include <linux/sonypi.h>
#include <linux/meye.h>
/****************************************************************************/
/* Motion JPEG chip registers */
......@@ -309,6 +315,10 @@ struct meye {
struct video_device video_dev; /* video device parameters */
struct video_picture picture; /* video picture parameters */
struct meye_params params; /* additional parameters */
#ifdef CONFIG_PM
u32 pm_state[16]; /* PCI configuration space */
u8 pm_mchip_mode; /* old mchip mode */
#endif
};
#endif
......@@ -91,6 +91,7 @@
MODULE_AUTHOR(MODULEAUTHOR);
MODULE_DESCRIPTION(my_NAME);
MODULE_LICENSE("GPL");
/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
int __init isense_init(void)
......
......@@ -270,6 +270,13 @@ static __inline__ int __get_order(unsigned long size)
#define mptscsih_sync_irq(_irq) synchronize_irq()
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,58)
#define mpt_inc_use_count()
#define mpt_dec_use_count()
#else
#define mpt_inc_use_count() MOD_INC_USE_COUNT
#define mpt_dec_use_count() MOD_DEC_USE_COUNT
#endif
/*}-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
......
......@@ -184,7 +184,7 @@ typedef struct _MSG_SCSI_IO_RAID_PT_REPLY
/****************************************************************************/
/* Mailbox request structure */
/* Mailbox reqeust structure */
/****************************************************************************/
typedef struct _MSG_MAILBOX_REQUEST
......
......@@ -49,7 +49,7 @@
* (mailto:sjralston1@netscape.net)
* (mailto:Pam.Delaney@lsil.com)
*
* $Id: mptbase.c,v 1.125 2002/12/03 21:26:32 pdelaney Exp $
* $Id: mptbase.c,v 1.126 2002/12/16 15:28:45 pdelaney Exp $
*/
/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
/*
......@@ -123,8 +123,10 @@ MODULE_LICENSE("GPL");
/*
* cmd line parameters
*/
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,59)
MODULE_PARM(PortIo, "0-1i");
MODULE_PARM_DESC(PortIo, "[0]=Use mmap, 1=Use port io");
#endif
static int PortIo = 0;
#ifdef MFCNT
......@@ -580,8 +582,6 @@ mpt_base_reply(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *reply)
dcprintk((MYIOC_s_INFO_FMT "config_complete (mf=%p,mr=%p)\n",
ioc->name, mf, reply));
DBG_DUMP_REPLY_FRAME(reply)
pCfg = * ((CONFIGPARMS **)((u8 *) mf + ioc->req_sz - sizeof(void *)));
if (pCfg) {
......@@ -686,7 +686,7 @@ mpt_register(MPT_CALLBACK cbfunc, MPT_DRIVER_CLASS dclass)
MptEvHandlers[i] = NULL;
last_drv_idx = i;
if (cbfunc != mpt_base_reply) {
MOD_INC_USE_COUNT;
mpt_inc_use_count();
}
break;
}
......@@ -706,7 +706,7 @@ mpt_register(MPT_CALLBACK cbfunc, MPT_DRIVER_CLASS dclass)
void
mpt_deregister(int cb_idx)
{
if (cb_idx && (cb_idx < MPT_MAX_PROTOCOL_DRIVERS)) {
if ((cb_idx >= 0) && (cb_idx < MPT_MAX_PROTOCOL_DRIVERS)) {
MptCallbacks[cb_idx] = NULL;
MptDriverClass[cb_idx] = MPTUNKNOWN_DRIVER;
MptEvHandlers[cb_idx] = NULL;
......@@ -716,7 +716,7 @@ mpt_deregister(int cb_idx)
isense_idx++;
if (cb_idx != mpt_base_index) {
MOD_DEC_USE_COUNT;
mpt_dec_use_count();
}
}
}
......@@ -2107,9 +2107,7 @@ MakeIocReady(MPT_ADAPTER *ioc, int force, int sleepFlag)
* Loop here waiting for IOC to come READY.
*/
ii = 0;
cntdn = HZ * 15;
if (sleepFlag != CAN_SLEEP)
cntdn *= 10; /* 1500 iterations @ 1msec per */
cntdn = ((sleepFlag == CAN_SLEEP) ? HZ : 1000) * 15; /* 15 seconds */
while ((ioc_state = mpt_GetIocState(ioc, 1)) != MPI_IOC_STATE_READY) {
if (ioc_state == MPI_IOC_STATE_OPERATIONAL) {
......@@ -2483,9 +2481,7 @@ SendIocInit(MPT_ADAPTER *ioc, int sleepFlag)
* LoopInit and TargetDiscovery!
*/
count = 0;
cntdn = HZ * 60; /* chg'd from 30 to 60 seconds */
if (sleepFlag != CAN_SLEEP)
cntdn *= 10; /* scale for 1msec delays */
cntdn = ((sleepFlag == CAN_SLEEP) ? HZ : 1000) * 60; /* 60 seconds */
state = mpt_GetIocState(ioc, 1);
while (state != MPI_IOC_STATE_OPERATIONAL && --cntdn) {
if (sleepFlag == CAN_SLEEP) {
......@@ -3478,10 +3474,8 @@ SendIocReset(MPT_ADAPTER *ioc, u8 reset_type, int sleepFlag)
/* FW ACK'd request, wait for READY state
*/
cntdn = HZ * 15;
count = 0;
if (sleepFlag != CAN_SLEEP)
cntdn *= 10; /* 1500 iterations @ 1msec per */
cntdn = ((sleepFlag == CAN_SLEEP) ? HZ : 1000) * 15; /* 15 seconds */
while ((state = mpt_GetIocState(ioc, 1)) != MPI_IOC_STATE_READY) {
cntdn--;
......@@ -3640,9 +3634,6 @@ PrimeIocFifos(MPT_ADAPTER *ioc)
}
spin_unlock_irqrestore(&ioc->FreeQlock, flags);
#ifdef MFCNT
ioc->mfcnt = 0;
#endif
if (ioc->sense_buf_pool == NULL) {
sz = (ioc->req_depth * MPT_SENSE_BUFFER_ALLOC);
......@@ -3822,10 +3813,12 @@ mpt_handshake_req_reply_wait(MPT_ADAPTER *ioc, int reqBytes, u32 *req,
static int
WaitForDoorbellAck(MPT_ADAPTER *ioc, int howlong, int sleepFlag)
{
int cntdn = HZ * howlong;
int cntdn;
int count = 0;
u32 intstat;
cntdn = ((sleepFlag == CAN_SLEEP) ? HZ : 1000) * howlong;
if (sleepFlag == CAN_SLEEP) {
while (--cntdn) {
intstat = CHIPREG_READ32(&ioc->chip->IntStatus);
......@@ -3836,7 +3829,6 @@ WaitForDoorbellAck(MPT_ADAPTER *ioc, int howlong, int sleepFlag)
count++;
}
} else {
cntdn *= 10; /* convert to msec */
while (--cntdn) {
intstat = CHIPREG_READ32(&ioc->chip->IntStatus);
if (! (intstat & MPI_HIS_IOP_DOORBELL_STATUS))
......@@ -3844,7 +3836,6 @@ WaitForDoorbellAck(MPT_ADAPTER *ioc, int howlong, int sleepFlag)
mdelay (1);
count++;
}
count /= 10;
}
if (cntdn) {
......@@ -3873,10 +3864,11 @@ WaitForDoorbellAck(MPT_ADAPTER *ioc, int howlong, int sleepFlag)
static int
WaitForDoorbellInt(MPT_ADAPTER *ioc, int howlong, int sleepFlag)
{
int cntdn = HZ * howlong;
int cntdn;
int count = 0;
u32 intstat;
cntdn = ((sleepFlag == CAN_SLEEP) ? HZ : 1000) * howlong;
if (sleepFlag == CAN_SLEEP) {
while (--cntdn) {
intstat = CHIPREG_READ32(&ioc->chip->IntStatus);
......@@ -3887,7 +3879,6 @@ WaitForDoorbellInt(MPT_ADAPTER *ioc, int howlong, int sleepFlag)
count++;
}
} else {
cntdn *= 10; /* convert to msec */
while (--cntdn) {
intstat = CHIPREG_READ32(&ioc->chip->IntStatus);
if (intstat & MPI_HIS_DOORBELL_INTERRUPT)
......@@ -3895,7 +3886,6 @@ WaitForDoorbellInt(MPT_ADAPTER *ioc, int howlong, int sleepFlag)
mdelay(1);
count++;
}
count /= 10;
}
if (cntdn) {
......@@ -4953,7 +4943,6 @@ mpt_ioc_reset(MPT_ADAPTER *ioc, int reset_phase)
/* Search the configQ for internal commands.
* Flush the Q, and wake up all suspended threads.
*/
#if 1
spin_lock_irqsave(&ioc->FreeQlock, flags);
if (! Q_IS_EMPTY(&ioc->configQ)){
pCfg = (CONFIGPARMS *)ioc->configQ.head;
......@@ -4970,23 +4959,6 @@ mpt_ioc_reset(MPT_ADAPTER *ioc, int reset_phase)
} while (pCfg != (CONFIGPARMS *)&ioc->configQ);
}
spin_unlock_irqrestore(&ioc->FreeQlock, flags);
#else
while (1) {
spin_lock_irqsave(&ioc->FreeQlock, flags);
if (! Q_IS_EMPTY(&ioc->configQ)){
spin_unlock_irqrestore(&ioc->FreeQlock, flags);
break;
}
pCfg = (CONFIGPARMS *)ioc->configQ.head;
Q_DEL_ITEM(&pCfg->linkage);
spin_unlock_irqrestore(&ioc->FreeQlock, flags);
pCfg->status = MPT_CONFIG_ERROR;
pCfg->wait_done = 1;
wake_up(&mpt_waitq);
}
#endif
}
return 1; /* currently means nothing really */
......@@ -5845,7 +5817,7 @@ mpt_register_ascqops_strings(void *ascqTable, int ascqtbl_sz, const char **opsTa
isense_idx = last_drv_idx;
r = 1;
}
MOD_INC_USE_COUNT;
mpt_inc_use_count();
return r;
}
......@@ -5864,7 +5836,7 @@ mpt_deregister_ascqops_strings(void)
mpt_ScsiOpcodesPtr = NULL;
printk(KERN_INFO MYNAM ": English readable SCSI-3 strings disabled)-:\n");
isense_idx = -1;
MOD_DEC_USE_COUNT;
mpt_dec_use_count();
}
/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
......
......@@ -13,7 +13,7 @@
* (mailto:sjralston1@netscape.net)
* (mailto:Pam.Delaney@lsil.com)
*
* $Id: mptbase.h,v 1.141 2002/12/03 21:26:32 pdelaney Exp $
* $Id: mptbase.h,v 1.144 2003/01/28 21:31:56 pdelaney Exp $
*/
/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
/*
......@@ -80,8 +80,8 @@
#define COPYRIGHT "Copyright (c) 1999-2002 " MODULEAUTHOR
#endif
#define MPT_LINUX_VERSION_COMMON "2.03.01.01"
#define MPT_LINUX_PACKAGE_NAME "@(#)mptlinux-2.03.01.01"
#define MPT_LINUX_VERSION_COMMON "2.05.00.03"
#define MPT_LINUX_PACKAGE_NAME "@(#)mptlinux-2.05.00.03"
#define WHAT_MAGIC_STRING "@" "(" "#" ")"
#define show_mptmod_ver(s,ver) \
......@@ -383,12 +383,9 @@ typedef struct _VirtDevice {
u8 maxWidth; /* 0 if narrow, 1 if wide*/
u8 negoFlags; /* bit field, 0 if WDTR/SDTR/QAS allowed */
u8 raidVolume; /* set, if RAID Volume */
#ifdef ABORT_FIX
u8 numAborts;
#else
u8 rsvd;
#endif
u16 rsvd1raid;
u8 type; /* byte 0 of Inquiry data */
u8 cflags; /* controller flags */
u8 rsvd1raid;
int npaths;
u16 fc_phys_lun;
u16 fc_xlat_lun;
......@@ -400,11 +397,8 @@ typedef struct _VirtDevice {
ScsiCmndTracker WaitQ;
ScsiCmndTracker SentQ;
ScsiCmndTracker DoneQ;
u32 num_luns;
//--- LUN split here?
#ifdef MPT_SAVE_AUTOSENSE
u8 sense[SCSI_STD_SENSE_BYTES]; /* 18 */
u8 rsvd2[2]; /* alignment */
#endif
u32 luns; /* Max LUNs is 32 */
u8 inq_data[SCSI_STD_INQUIRY_BYTES]; /* 36 */
u8 pad0[4];
......@@ -428,13 +422,15 @@ typedef struct _VirtDevice {
* Fibre Channel (SCSI) target device and associated defines...
*/
#define MPT_TARGET_DEFAULT_DV_STATUS 0
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,55)
#define MPT_TARGET_FLAGS_CONFIGURED 0x02
#define MPT_TARGET_FLAGS_Q_YES 0x08
#else
#define MPT_TARGET_FLAGS_VALID_NEGO 0x01
#define MPT_TARGET_FLAGS_VALID_INQUIRY 0x02
#ifdef MPT_SAVE_AUTOSENSE
#define MPT_TARGET_FLAGS_VALID_SENSE 0x04
#endif
#define MPT_TARGET_FLAGS_Q_YES 0x08
#define MPT_TARGET_FLAGS_VALID_56 0x10
#endif
#define MPT_TARGET_NO_NEGO_WIDE 0x01
#define MPT_TARGET_NO_NEGO_SYNC 0x02
......@@ -603,7 +599,7 @@ typedef struct _MPT_ADAPTER
dma_addr_t sense_buf_pool_dma;
u32 sense_buf_low_dma;
int mtrr_reg;
struct pci_dev *pcidev;
struct pci_dev *pcidev; /* struct pci_dev pointer */
u8 *memmap; /* mmap address */
struct Scsi_Host *sh; /* Scsi Host pointer */
ScsiCfgData spi_data; /* Scsi config. data */
......@@ -764,6 +760,13 @@ typedef struct _mpt_sge {
#define dcprintk(x)
#endif
#if defined(MPT_DEBUG_SCSI) || defined(MPT_DEBUG) || defined(MPT_DEBUG_MSG_FRAME)
#define dsprintk(x) printk x
#else
#define dsprintk(x)
#endif
#define MPT_INDEX_2_MFPTR(ioc,idx) \
(MPT_FRAME_HDR*)( (u8*)(ioc)->req_frames + (ioc)->req_sz * (idx) )
......@@ -1050,7 +1053,7 @@ extern int mpt_ASCQ_TableSz;
#define offsetof(t, m) ((size_t) (&((t *)0)->m))
#endif
#if defined(__alpha__) || defined(__sparc_v9__) || defined(__ia64__)
#if defined(__alpha__) || defined(__sparc_v9__) || defined(__ia64__) || defined(__x86_64__)
#define CAST_U32_TO_PTR(x) ((void *)(u64)x)
#define CAST_PTR_TO_U32(x) ((u32)(u64)x)
#else
......
......@@ -102,6 +102,9 @@
#define my_VERSION MPT_LINUX_VERSION_COMMON
#define MYNAM "mptctl"
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,62)
EXPORT_NO_SYMBOLS;
#endif
MODULE_AUTHOR(MODULEAUTHOR);
MODULE_DESCRIPTION(my_NAME);
MODULE_LICENSE("GPL");
......@@ -135,7 +138,7 @@ static int mptctl_eventreport (unsigned long arg);
static int mptctl_replace_fw (unsigned long arg);
static int mptctl_do_reset(unsigned long arg);
static int mptctl_hp_hostinfo(unsigned long arg);
static int mptctl_hp_hostinfo(unsigned long arg, unsigned int cmd);
static int mptctl_hp_targetinfo(unsigned long arg);
/*
......@@ -658,25 +661,19 @@ mptctl_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned
dctlprintk((MYIOC_s_INFO_FMT ": mptctl_ioctl()\n", iocp->name));
switch(cmd) {
case MPTFWDOWNLOAD:
if (cmd == MPTFWDOWNLOAD)
ret = mptctl_fw_download(arg);
break;
case MPTCOMMAND:
else if (cmd == MPTCOMMAND)
ret = mptctl_mpt_command(arg);
break;
case MPTHARDRESET:
else if (cmd == MPTHARDRESET)
ret = mptctl_do_reset(arg);
break;
case HP_GETHOSTINFO:
ret = mptctl_hp_hostinfo(arg);
break;
case HP_GETTARGETINFO:
else if ((cmd & ~IOCSIZE_MASK) == (HP_GETHOSTINFO & ~IOCSIZE_MASK))
ret = mptctl_hp_hostinfo(arg, _IOC_SIZE(cmd));
else if (cmd == HP_GETTARGETINFO)
ret = mptctl_hp_targetinfo(arg);
break;
default:
else
ret = -EINVAL;
}
up(&mptctl_syscall_sem_ioc[iocp->id]);
......@@ -873,7 +870,7 @@ mptctl_do_fw_download(int ioc, char *ufwbuf, size_t fwlen)
* 96 8
* 64 4
*/
maxfrags = (iocp->req_sz - sizeof(MPIHeader_t) - sizeof(FWDownloadTCSGE_t))
maxfrags = (iocp->req_sz - sizeof(MPIHeader_t) - sizeof(FWDownloadTCSGE_t))
/ (sizeof(dma_addr_t) + sizeof(u32));
if (numfrags > maxfrags) {
ret = -EMLINK;
......@@ -1227,10 +1224,16 @@ mptctl_getiocinfo (unsigned long arg, unsigned int data_size)
u8 revision;
dctlprintk((": mptctl_getiocinfo called.\n"));
if (data_size == sizeof(struct mpt_ioctl_iocinfo))
cim_rev = 1;
else if (data_size == (sizeof(struct mpt_ioctl_iocinfo) - sizeof(struct mpt_ioctl_pci_info)))
/* Add of PCI INFO results in unaligned access for
* IA64 and Sparc. Reset long to int. Return no PCI
* data for obsolete format.
*/
if (data_size == sizeof(struct mpt_ioctl_iocinfo_rev0))
cim_rev = 0;
else if (data_size == sizeof(struct mpt_ioctl_iocinfo))
cim_rev = 1;
else if (data_size == (sizeof(struct mpt_ioctl_iocinfo_rev0)+12))
cim_rev = 0; /* obsolete */
else
return -EFAULT;
......@@ -1414,7 +1417,7 @@ mptctl_gettargetinfo (unsigned long arg)
/* Get number of devices
*/
if ( (sh = ioc->sh) != NULL) {
if ((sh = ioc->sh) != NULL) {
max_id = sh->max_id - 1;
hd = (MPT_SCSI_HOST *) sh->hostdata;
......@@ -1437,9 +1440,8 @@ mptctl_gettargetinfo (unsigned long arg)
pdata++;
if (maxWordsLeft <= 0) {
if (maxWordsLeft <= 0)
break;
}
}
}
}
......@@ -1712,7 +1714,7 @@ mptctl_replace_fw (unsigned long arg)
/* Allocate memory for the new FW image
*/
newFwSize = karg.newImageSize;
fwmem = mpt_alloc_fw_memory(ioc, newFwSize, &num_frags, &alloc_sz);
fwmem = mpt_alloc_fw_memory(ioc, newFwSize, &num_frags, &alloc_sz);
if (fwmem == NULL)
return -ENOMEM;
......@@ -1732,7 +1734,7 @@ mptctl_replace_fw (unsigned long arg)
}
/* Free the old FW image
/* Free the old FW image
*/
if (ioc->cached_fw) {
mpt_free_fw_memory(ioc, 0);
......@@ -1905,6 +1907,7 @@ mptctl_do_mpt_command (struct mpt_ioctl_command karg, char *mfPtr, int local)
case MPI_FUNCTION_FW_UPLOAD:
case MPI_FUNCTION_SCSI_ENCLOSURE_PROCESSOR:
case MPI_FUNCTION_FW_DOWNLOAD:
case MPI_FUNCTION_FC_PRIMITIVE_SEND:
break;
case MPI_FUNCTION_SCSI_IO_REQUEST:
......@@ -2032,7 +2035,7 @@ mptctl_do_mpt_command (struct mpt_ioctl_command karg, char *mfPtr, int local)
break;
case MPI_FUNCTION_SCSI_TASK_MGMT:
{
{
MPT_SCSI_HOST *hd = NULL;
if ((ioc->sh == NULL) || ((hd = (MPT_SCSI_HOST *)ioc->sh->hostdata) == NULL)) {
printk(KERN_ERR "%s@%d::mptctl_do_mpt_command - "
......@@ -2065,7 +2068,7 @@ mptctl_do_mpt_command (struct mpt_ioctl_command karg, char *mfPtr, int local)
}
if ((pInit->Flags != 0) || (pInit->MaxDevices != ioc->facts.MaxDevices) ||
(pInit->MaxBuses != ioc->facts.MaxBuses) ||
(pInit->MaxBuses != ioc->facts.MaxBuses) ||
(pInit->ReplyFrameSize != cpu_to_le16(ioc->reply_sz)) ||
(pInit->HostMfaHighAddr != high_addr) ||
(pInit->SenseBufferHighAddr != sense_high)) {
......@@ -2097,7 +2100,6 @@ mptctl_do_mpt_command (struct mpt_ioctl_command karg, char *mfPtr, int local)
MPI_FUNCTION_FC_LINK_SRVC_BUF_POST
MPI_FUNCTION_FC_LINK_SRVC_RSP
MPI_FUNCTION_FC_ABORT
MPI_FUNCTION_FC_PRIMITIVE_SEND
MPI_FUNCTION_LAN_SEND
MPI_FUNCTION_LAN_RECEIVE
MPI_FUNCTION_LAN_RESET
......@@ -2395,7 +2397,7 @@ mptctl_do_mpt_command (struct mpt_ioctl_command karg, char *mfPtr, int local)
* -ENOMEM if memory allocation error
*/
static int
mptctl_hp_hostinfo(unsigned long arg)
mptctl_hp_hostinfo(unsigned long arg, unsigned int data_size)
{
hp_host_info_t *uarg = (hp_host_info_t *) arg;
MPT_ADAPTER *ioc;
......@@ -2406,9 +2408,18 @@ mptctl_hp_hostinfo(unsigned long arg)
CONFIGPARMS cfg;
ConfigPageHeader_t hdr;
int iocnum;
int rc;
int rc, cim_rev;
dctlprintk((": mptctl_hp_hostinfo called.\n"));
/* Reset long to int. Should affect IA64 and SPARC only
*/
if (data_size == sizeof(hp_host_info_t))
cim_rev = 1;
else if (data_size == (sizeof(hp_host_info_t) + 12))
cim_rev = 0; /* obsolete */
else
return -EFAULT;
if (copy_from_user(&karg, uarg, sizeof(hp_host_info_t))) {
printk(KERN_ERR "%s@%d::mptctl_hp_host_info - "
"Unable to read in hp_host_info struct @ %p\n",
......@@ -2438,7 +2449,7 @@ mptctl_hp_hostinfo(unsigned long arg)
karg.bus = pdev->bus->number;
/* Save the SCSI host no. if
* SCSI driver loaded
* SCSI driver loaded
*/
if (ioc->sh != NULL)
karg.host_no = ioc->sh->host_no;
......@@ -2526,7 +2537,7 @@ mptctl_hp_hostinfo(unsigned long arg)
if (ioc->sh != NULL) {
MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)ioc->sh->hostdata;
if (hd) {
if (hd && (cim_rev == 1)) {
karg.hard_resets = hd->hard_resets;
karg.soft_resets = hd->soft_resets;
karg.timeouts = hd->timeouts;
......@@ -2620,7 +2631,7 @@ mptctl_hp_targetinfo(unsigned long arg)
if ((rc = mpt_config(ioc, &cfg)) == 0) {
np = le32_to_cpu(pg0_alloc->NegotiatedParameters);
karg.negotiated_width = np & MPI_SCSIDEVPAGE0_NP_WIDE ?
karg.negotiated_width = np & MPI_SCSIDEVPAGE0_NP_WIDE ?
HP_BUS_WIDTH_16 : HP_BUS_WIDTH_8;
if (np & MPI_SCSIDEVPAGE0_NP_NEG_SYNC_OFFSET_MASK) {
......@@ -2699,7 +2710,7 @@ mptctl_hp_targetinfo(unsigned long arg)
/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,51)
#define owner_THIS_MODULE owner: THIS_MODULE,
#define owner_THIS_MODULE .owner = THIS_MODULE,
#else
#define owner_THIS_MODULE
#endif
......@@ -2885,6 +2896,8 @@ int __init mptctl_init(void)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,0) /*{*/
err = register_ioctl32_conversion(MPTIOCINFO, NULL);
if (++where && err) goto out_fail;
err = register_ioctl32_conversion(MPTIOCINFO1, NULL);
if (++where && err) goto out_fail;
err = register_ioctl32_conversion(MPTTARGETINFO, NULL);
if (++where && err) goto out_fail;
err = register_ioctl32_conversion(MPTTEST, NULL);
......@@ -2945,6 +2958,7 @@ int __init mptctl_init(void)
printk(KERN_ERR MYNAM ": ERROR: Failed to register ioctl32_conversion!"
" (%d:err=%d)\n", where, err);
unregister_ioctl32_conversion(MPTIOCINFO);
unregister_ioctl32_conversion(MPTIOCINFO1);
unregister_ioctl32_conversion(MPTTARGETINFO);
unregister_ioctl32_conversion(MPTTEST);
unregister_ioctl32_conversion(MPTEVENTQUERY);
......
......@@ -90,6 +90,7 @@
#endif /*}*/
#define MPTIOCINFO _IOWR(MPT_MAGIC_NUMBER,17,struct mpt_ioctl_iocinfo)
#define MPTIOCINFO1 _IOWR(MPT_MAGIC_NUMBER,17,struct mpt_ioctl_iocinfo_rev0)
#define MPTTARGETINFO _IOWR(MPT_MAGIC_NUMBER,18,struct mpt_ioctl_targetinfo)
#define MPTTEST _IOWR(MPT_MAGIC_NUMBER,19,struct mpt_ioctl_test)
#define MPTEVENTQUERY _IOWR(MPT_MAGIC_NUMBER,21,struct mpt_ioctl_eventquery)
......@@ -99,7 +100,7 @@
#define MPTFWREPLACE _IOWR(MPT_MAGIC_NUMBER,25,struct mpt_ioctl_replace_fw)
/*
* SPARC PLATFORM REMARK:
* SPARC PLATFORM REMARKS:
* IOCTL data structures that contain pointers
* will have different sizes in the driver and applications
* (as the app. will not use 8-byte pointers).
......@@ -107,6 +108,8 @@
* The driver will convert data from
* mpt_fw_xfer32 (mpt_ioctl_command32) to mpt_fw_xfer (mpt_ioctl_command)
* internally.
*
* If data structures change size, must handle as in IOCGETINFO.
*/
struct mpt_fw_xfer {
unsigned int iocnum; /* IOC unit number */
......@@ -154,11 +157,11 @@ struct mpt_ioctl_diag_reset {
struct mpt_ioctl_pci_info {
union {
struct {
unsigned long deviceNumber : 5;
unsigned long functionNumber : 3;
unsigned long busNumber : 24;
unsigned int deviceNumber : 5;
unsigned int functionNumber : 3;
unsigned int busNumber : 24;
} bits;
unsigned long asUlong;
unsigned int asUlong;
} u;
};
......@@ -189,6 +192,27 @@ struct mpt_ioctl_iocinfo {
struct mpt_ioctl_pci_info pciInfo; /* Added Rev 1 */
};
/* Original structure, must always accept these
* IOCTLs. 4 byte pads can occur based on arch with
* above structure. Wish to re-align, but cannot.
*/
struct mpt_ioctl_iocinfo_rev0 {
mpt_ioctl_header hdr;
int adapterType; /* SCSI or FCP */
int port; /* port number */
int pciId; /* PCI Id. */
int hwRev; /* hardware revision */
int subSystemDevice; /* PCI subsystem Device ID */
int subSystemVendor; /* PCI subsystem Vendor ID */
int numDevices; /* number of devices */
int FWVersion; /* FW Version (integer) */
int BIOSVersion; /* BIOS Version (integer) */
char driverVersion[MPT_IOCTL_VERSION_LENGTH]; /* Driver Version (string) */
char busChangeEvent;
char hostId;
char rsvd[2];
};
/*
* Device Information Page
* Report the number of, and ids of, all targets
......@@ -330,7 +354,7 @@ typedef struct _hp_header {
unsigned int lun;
} hp_header_t;
/*
/*
* Header:
* iocnum required (input)
* host ignored
......@@ -353,12 +377,12 @@ typedef struct _hp_host_info {
u32 bus_phys_width;
u32 base_io_addr;
u32 rsvd;
unsigned long hard_resets; /* driver initiated resets */
unsigned long soft_resets; /* ioc, external resets */
unsigned long timeouts; /* num timeouts */
unsigned int hard_resets; /* driver initiated resets */
unsigned int soft_resets; /* ioc, external resets */
unsigned int timeouts; /* num timeouts */
} hp_host_info_t;
/*
/*
* Header:
* iocnum required (input)
* host required
......
......@@ -154,7 +154,7 @@ static int mpt_lan_open(struct net_device *dev);
static int mpt_lan_reset(struct net_device *dev);
static int mpt_lan_close(struct net_device *dev);
static void mpt_lan_post_receive_buckets(void *dev_id);
static void mpt_lan_wake_post_buckets_task(struct net_device *dev,
static void mpt_lan_wake_post_buckets_task(struct net_device *dev,
int priority);
static int mpt_lan_receive_post_turbo(struct net_device *dev, u32 tmsg);
static int mpt_lan_receive_post_reply(struct net_device *dev,
......@@ -868,7 +868,7 @@ mpt_lan_sdu_send (struct sk_buff *skb, struct net_device *dev)
/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
static inline void
mpt_lan_wake_post_buckets_task(struct net_device *dev, int priority)
/*
/*
* @priority: 0 = put it on the timer queue, 1 = put it on the immediate queue
*/
{
......@@ -878,8 +878,6 @@ mpt_lan_wake_post_buckets_task(struct net_device *dev, int priority)
if (priority) {
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,41)
schedule_work(&priv->post_buckets_task);
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,40)
schedule_task(&priv->post_buckets_task);
#else
queue_task(&priv->post_buckets_task, &tq_immediate);
mark_bh(IMMEDIATE_BH);
......@@ -887,8 +885,6 @@ mpt_lan_wake_post_buckets_task(struct net_device *dev, int priority)
} else {
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,41)
schedule_delayed_work(&priv->post_buckets_task, 1);
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,40)
schedule_task(&priv->post_buckets_task);
#else
queue_task(&priv->post_buckets_task, &tq_timer);
#endif
......@@ -1191,7 +1187,7 @@ mpt_lan_receive_post_reply(struct net_device *dev,
remaining, atomic_read(&priv->buckets_out));
if ((remaining < priv->bucketthresh) &&
((atomic_read(&priv->buckets_out) - remaining) >
((atomic_read(&priv->buckets_out) - remaining) >
MPT_LAN_BUCKETS_REMAIN_MISMATCH_THRESH)) {
printk (KERN_WARNING MYNAM " Mismatch between driver's "
......@@ -1525,7 +1521,7 @@ mpt_lan_init (void)
}
/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
void __init mpt_lan_exit(void)
static void mpt_lan_exit(void)
{
int i;
......@@ -1534,10 +1530,11 @@ void __init mpt_lan_exit(void)
for (i = 0; mpt_landev[i] != NULL; i++) {
struct net_device *dev = mpt_landev[i];
printk (KERN_INFO MYNAM ": %s/%s: Fusion MPT LAN device unregistered\n",
printk (KERN_INFO ": %s/%s: Fusion MPT LAN device unregistered\n",
IOC_AND_NETDEV_NAMES_s_s(dev));
unregister_fcdev(dev);
mpt_landev[i] = (struct net_device *) 0xdeadbeef; /* Debug */
//mpt_landev[i] = (struct net_device *) 0xdeadbeef; /* Debug */
mpt_landev[i] = NULL;
}
if (LanCtx >= 0) {
......@@ -1550,9 +1547,10 @@ void __init mpt_lan_exit(void)
}
/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,59)
MODULE_PARM(tx_max_out_p, "i");
MODULE_PARM(max_buckets_out, "i"); // Debug stuff. FIXME!
#endif
module_init(mpt_lan_init);
module_exit(mpt_lan_exit);
......
......@@ -21,11 +21,7 @@
#include <linux/miscdevice.h>
#include <linux/spinlock.h>
#include <linux/version.h>
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,41)
#include <linux/tqueue.h>
#else
#include <linux/workqueue.h>
#endif
#include <linux/delay.h>
// #include <linux/trdevice.h>
......
This diff is collapsed.
......@@ -72,7 +72,7 @@
/*
* Try to keep these at 2^N-1
*/
#define MPT_FC_CAN_QUEUE 63
#define MPT_FC_CAN_QUEUE 127
#if defined MPT_SCSI_USE_NEW_EH
#define MPT_SCSI_CAN_QUEUE 127
#else
......@@ -148,59 +148,18 @@ struct mptscsih_driver_setup
* Issue discovered 20001213 by: sshirron
*/
#define MPT_SCSIHOST_NEED_ENTRY_EXIT_HOOKUPS 1
#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,4,0)
# if LINUX_VERSION_CODE == KERNEL_VERSION(2,4,0)
/*
* Super HACK! -by sralston:-(
* (good grief; heaven help me!)
*/
# include <linux/capability.h>
# if !defined(CAP_LEASE) && !defined(MODULE)
# undef MPT_SCSIHOST_NEED_ENTRY_EXIT_HOOKUPS
# endif
# else
# ifndef MODULE
# undef MPT_SCSIHOST_NEED_ENTRY_EXIT_HOOKUPS
# endif
# endif
#endif
/*
* tq_scheduler disappeared @ lk-2.4.0-test12
* (right when <linux/sched.h> newly defined TQ_ACTIVE)
* tq_struct reworked in 2.5.41. Include workqueue.h.
*/
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,41)
# include <linux/sched.h>
# include <linux/workqueue.h>
#define SCHEDULE_TASK(x) \
if (schedule_work(x) == 0) { \
/*MOD_DEC_USE_COUNT*/; \
}
#else
#define HAVE_TQ_SCHED 1
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
# include <linux/sched.h>
# ifdef TQ_ACTIVE
# undef HAVE_TQ_SCHED
# endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,40)
# undef HAVE_TQ_SCHED
#endif
#endif
#ifdef HAVE_TQ_SCHED
#define SCHEDULE_TASK(x) \
/*MOD_INC_USE_COUNT*/; \
(x)->next = NULL; \
queue_task(x, &tq_scheduler)
#else
#define SCHEDULE_TASK(x) \
/*MOD_INC_USE_COUNT*/; \
if (schedule_task(x) == 0) { \
/*MOD_DEC_USE_COUNT*/; \
}
#endif
#endif
/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
......@@ -217,11 +176,9 @@ struct mptscsih_driver_setup
#define x_scsi_taskmgmt_bh mptscsih_taskmgmt_bh
#define x_scsi_old_abort mptscsih_old_abort
#define x_scsi_old_reset mptscsih_old_reset
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,52)
#define x_scsi_slave_alloc mptscsih_slave_alloc
#define x_scsi_slave_configure mptscsih_slave_configure
#else
#define x_scsi_select_queue_depths mptscsih_select_queue_depths
#endif
#define x_scsi_slave_destroy mptscsih_slave_destroy
#define x_scsi_proc_info mptscsih_proc_info
/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
......@@ -232,41 +189,19 @@ extern int x_scsi_detect(Scsi_Host_Template *);
extern int x_scsi_release(struct Scsi_Host *host);
extern const char *x_scsi_info(struct Scsi_Host *);
extern int x_scsi_queuecommand(Scsi_Cmnd *, void (*done)(Scsi_Cmnd *));
#ifdef MPT_SCSI_USE_NEW_EH
extern int x_scsi_abort(Scsi_Cmnd *);
extern int x_scsi_bus_reset(Scsi_Cmnd *);
extern int x_scsi_dev_reset(Scsi_Cmnd *);
extern int x_scsi_host_reset(Scsi_Cmnd *);
#else
extern int x_scsi_old_abort(Scsi_Cmnd *);
extern int x_scsi_old_reset(Scsi_Cmnd *, unsigned int);
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,45)
extern int x_scsi_bios_param(struct scsi_device * sdev, struct block_device *bdev,
sector_t capacity, int *ip);
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,28)
extern int x_scsi_bios_param(Disk *, struct block_device *, int *);
#else
extern int x_scsi_bios_param(Disk *, kdev_t, int *);
#endif
extern void x_scsi_taskmgmt_bh(void *);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,52)
extern int x_scsi_slave_alloc(Scsi_Device *);
extern int x_scsi_slave_configure(Scsi_Device *);
#else
extern void x_scsi_select_queue_depths(struct Scsi_Host *, Scsi_Device *);
#endif
extern void x_scsi_slave_destroy(Scsi_Device *);
extern int x_scsi_proc_info(char *, char **, off_t, int, int, int);
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0)
#define PROC_SCSI_DECL
#else
#define PROC_SCSI_DECL proc_name: "mptscsih",
#endif
#ifdef MPT_SCSI_USE_NEW_EH
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,52)
#define PROC_SCSI_DECL .proc_name = "mptscsih",
#define MPT_SCSIHOST { \
PROC_SCSI_DECL \
......@@ -277,7 +212,9 @@ extern int x_scsi_proc_info(char *, char **, off_t, int, int, int);
.info = x_scsi_info, \
.command = NULL, \
.queuecommand = x_scsi_queuecommand, \
.slave_alloc = x_scsi_slave_alloc, \
.slave_configure = x_scsi_slave_configure, \
.slave_destroy = x_scsi_slave_destroy, \
.eh_strategy_handler = NULL, \
.eh_abort_handler = x_scsi_abort, \
.eh_device_reset_handler = x_scsi_dev_reset, \
......@@ -293,58 +230,6 @@ extern int x_scsi_proc_info(char *, char **, off_t, int, int, int);
.use_clustering = ENABLE_CLUSTERING, \
}
#else /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,1) */
#define MPT_SCSIHOST { \
.next = NULL, \
PROC_SCSI_DECL \
.proc_info = x_scsi_proc_info, \
.name = "MPT SCSI Host", \
.detect = x_scsi_detect, \
.release = x_scsi_release, \
.info = x_scsi_info, \
.command = NULL, \
.queuecommand = x_scsi_queuecommand, \
.eh_strategy_handler = NULL, \
.eh_abort_handler = x_scsi_abort, \
.eh_device_reset_handler = x_scsi_dev_reset, \
.eh_bus_reset_handler = x_scsi_bus_reset, \
.eh_host_reset_handler = NULL, \
.bios_param = x_scsi_bios_param, \
.can_queue = MPT_SCSI_CAN_QUEUE, \
.this_id = -1, \
.sg_tablesize = MPT_SCSI_SG_DEPTH, \
.cmd_per_lun = MPT_SCSI_CMD_PER_LUN, \
.unchecked_isa_dma = 0, \
.use_clustering = ENABLE_CLUSTERING, \
.use_new_eh_code = 1 \
}
#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,1) */
#else /* MPT_SCSI_USE_NEW_EH */
#define MPT_SCSIHOST { \
.next = NULL, \
PROC_SCSI_DECL \
.name = "MPT SCSI Host", \
.detect = x_scsi_detect, \
.release = x_scsi_release, \
.info = x_scsi_info, \
.command = NULL, \
.queuecommand = x_scsi_queuecommand, \
.abort = x_scsi_old_abort, \
.reset = x_scsi_old_reset, \
.bios_param = x_scsi_bios_param, \
.can_queue = MPT_SCSI_CAN_QUEUE, \
.this_id = -1, \
.sg_tablesize = MPT_SCSI_SG_DEPTH, \
.cmd_per_lun = MPT_SCSI_CMD_PER_LUN, \
.unchecked_isa_dma = 0, \
.use_clustering = ENABLE_CLUSTERING \
}
#endif /* MPT_SCSI_USE_NEW_EH */
/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
......
......@@ -172,44 +172,6 @@ int pci_visit_dev (struct pci_visit *fn, struct pci_dev_wrapped *wrapped_dev,
}
EXPORT_SYMBOL(pci_visit_dev);
/**
* pci_is_dev_in_use - query devices' usage
* @dev: PCI device to query
*
* Queries whether a given PCI device is in use by a driver or not.
* Returns 1 if the device is in use, 0 if it is not.
*/
int pci_is_dev_in_use(struct pci_dev *dev)
{
/*
* dev->driver will be set if the device is in use by a new-style
* driver -- otherwise, check the device's regions to see if any
* driver has claimed them.
*/
int i;
int inuse = 0;
if (dev->driver) {
/* Assume driver feels responsible */
return 1;
}
for (i = 0; !dev->driver && !inuse && (i < 6); i++) {
if (!pci_resource_start(dev, i))
continue;
if (pci_resource_flags(dev, i) & IORESOURCE_IO) {
inuse = check_region(pci_resource_start(dev, i),
pci_resource_len(dev, i));
} else if (pci_resource_flags(dev, i) & IORESOURCE_MEM) {
inuse = check_mem_region(pci_resource_start(dev, i),
pci_resource_len(dev, i));
}
}
return inuse;
}
EXPORT_SYMBOL(pci_is_dev_in_use);
/**
* pci_remove_device_safe - remove an unused hotplug device
* @dev: the device to remove
......@@ -221,9 +183,8 @@ EXPORT_SYMBOL(pci_is_dev_in_use);
*/
int pci_remove_device_safe(struct pci_dev *dev)
{
if (pci_is_dev_in_use(dev)) {
if (pci_dev_driver(dev))
return -EBUSY;
}
pci_remove_device(dev);
return 0;
}
......
......@@ -244,7 +244,14 @@ static const lookup_t service_table[] = {
static int register_callback(socket_info_t *s, void (*handler)(void *, unsigned int), void * info)
{
return s->ss_entry->register_callback(s->sock, handler, info);
int error;
if (handler && !try_module_get(s->ss_entry->owner))
return -ENODEV;
error = s->ss_entry->register_callback(s->sock, handler, info);
if (!handler)
module_put(s->ss_entry->owner);
return error;
}
static int get_socket_status(socket_info_t *s, int *val)
......
......@@ -394,11 +394,6 @@ static int hs_register_callback(unsigned int sock,
DPRINTK("hs_register_callback(%d)\n", sock);
sp->handler = handler;
sp->handler_info = info;
if (handler == 0) {
MOD_DEC_USE_COUNT;
} else {
MOD_INC_USE_COUNT;
}
return 0;
}
......@@ -891,18 +886,19 @@ static void hs_interrupt(int irq, void *dev, struct pt_regs *regs)
/*============================================================*/
static struct pccard_operations hs_operations = {
hs_init,
hs_suspend,
hs_register_callback,
hs_inquire_socket,
hs_get_status,
hs_get_socket,
hs_set_socket,
hs_get_io_map,
hs_set_io_map,
hs_get_mem_map,
hs_set_mem_map,
hs_proc_setup
.owner = THIS_MODULE,
.init = hs_init,
.suspend = hs_suspend,
.register_callback = hs_register_callback,
.inquire_socket = hs_inquire_socket,
.get_status = hs_get_status,
.get_socket = hs_get_socket,
.set_socket = hs_set_socket,
.get_io_map = hs_get_io_map,
.set_io_map = hs_set_io_map,
.get_mem_map = hs_get_mem_map,
.set_mem_map = hs_set_mem_map,
.proc_setup = hs_proc_setup,
};
static int hs_init_socket(hs_socket_t *sp, int irq, unsigned long mem_base,
......
......@@ -55,6 +55,7 @@ static struct pci_driver i82092aa_pci_drv = {
/* the pccard structure and its functions */
static struct pccard_operations i82092aa_operations = {
.owner = THIS_MODULE,
.init = i82092aa_init,
.suspend = i82092aa_suspend,
.register_callback = i82092aa_register_callback,
......@@ -465,11 +466,6 @@ static int i82092aa_register_callback(unsigned int sock, void (*handler)(void *,
enter("i82092aa_register_callback");
sockets[sock].handler = handler;
sockets[sock].info = info;
if (handler == NULL) {
MOD_DEC_USE_COUNT;
} else {
MOD_INC_USE_COUNT;
}
leave("i82092aa_register_callback");
return 0;
} /* i82092aa_register_callback */
......
......@@ -1018,11 +1018,6 @@ static int pcic_register_callback(unsigned int sock, void (*handler)(void *, uns
{
socket[sock].handler = handler;
socket[sock].info = info;
if (handler == NULL) {
MOD_DEC_USE_COUNT;
} else {
MOD_INC_USE_COUNT;
}
return 0;
} /* pcic_register_callback */
......@@ -1568,18 +1563,19 @@ static int pcic_suspend(unsigned int sock)
}
static struct pccard_operations pcic_operations = {
pcic_init,
pcic_suspend,
pcic_register_callback,
pcic_inquire_socket,
pcic_get_status,
pcic_get_socket,
pcic_set_socket,
pcic_get_io_map,
pcic_set_io_map,
pcic_get_mem_map,
pcic_set_mem_map,
pcic_proc_setup
.owner = THIS_MODULE,
.init = pcic_init,
.suspend = pcic_suspend,
.register_callback = pcic_register_callback,
.inquire_socket = pcic_inquire_socket,
.get_status = pcic_get_status,
.get_socket = pcic_get_socket,
.set_socket = pcic_set_socket,
.get_io_map = pcic_get_io_map,
.set_io_map = pcic_set_io_map,
.get_mem_map = pcic_get_mem_map,
.set_mem_map = pcic_set_mem_map,
.proc_setup = pcic_proc_setup,
};
/*====================================================================*/
......
......@@ -66,10 +66,6 @@ static int pci_register_callback(unsigned int sock, void (*handler)(void *, unsi
socket->handler = handler;
socket->info = info;
if (handler)
MOD_INC_USE_COUNT;
else
MOD_DEC_USE_COUNT;
return 0;
}
......@@ -154,18 +150,19 @@ static void pci_proc_setup(unsigned int sock, struct proc_dir_entry *base)
}
static struct pccard_operations pci_socket_operations = {
pci_init_socket,
pci_suspend_socket,
pci_register_callback,
pci_inquire_socket,
pci_get_status,
pci_get_socket,
pci_set_socket,
pci_get_io_map,
pci_set_io_map,
pci_get_mem_map,
pci_set_mem_map,
pci_proc_setup
.owner = THIS_MODULE,
.init = pci_init_socket,
.suspend = pci_suspend_socket,
.register_callback = pci_register_callback,
.inquire_socket = pci_inquire_socket,
.get_status = pci_get_status,
.get_socket = pci_get_socket,
.set_socket = pci_set_socket,
.get_io_map = pci_get_io_map,
.set_io_map = pci_set_io_map,
.get_mem_map = pci_get_mem_map,
.set_mem_map = pci_set_mem_map,
.proc_setup = pci_proc_setup,
};
static int __devinit add_pci_socket(int nr, struct pci_dev *dev, struct pci_socket_ops *ops)
......
......@@ -380,9 +380,7 @@ sa1100_pcmcia_register_callback(unsigned int sock,
if (handler == NULL) {
skt->handler = NULL;
MOD_DEC_USE_COUNT;
} else {
MOD_INC_USE_COUNT;
skt->handler_info = info;
skt->handler = handler;
}
......@@ -854,6 +852,7 @@ sa1100_pcmcia_proc_setup(unsigned int sock, struct proc_dir_entry *base)
#endif /* defined(CONFIG_PROC_FS) */
static struct pccard_operations sa1100_pcmcia_operations = {
.owner = THIS_MODULE,
.init = sa1100_pcmcia_sock_init,
.suspend = sa1100_pcmcia_suspend,
.register_callback = sa1100_pcmcia_register_callback,
......
......@@ -638,11 +638,6 @@ static int tcic_register_callback(unsigned int lsock, void (*handler)(void *, un
{
socket_table[lsock].handler = handler;
socket_table[lsock].info = info;
if (handler == NULL) {
MOD_DEC_USE_COUNT;
} else {
MOD_INC_USE_COUNT;
}
return 0;
} /* tcic_register_callback */
......@@ -1003,6 +998,7 @@ static int tcic_suspend(unsigned int sock)
}
static struct pccard_operations tcic_operations = {
.owner = THIS_MODULE,
.init = tcic_init,
.suspend = tcic_suspend,
.register_callback = tcic_register_callback,
......
......@@ -9,26 +9,24 @@
#ifdef __KERNEL__
struct task_struct; /* one of the stranger aspects of C forward declarations.. */
extern void FASTCALL(__switch_to(struct task_struct *prev, struct task_struct *next));
extern struct task_struct * FASTCALL(__switch_to(struct task_struct *prev, struct task_struct *next));
#define switch_to(prev,next,last) do { \
unsigned long esi,edi; \
asm volatile("pushfl\n\t" \
"pushl %%esi\n\t" \
"pushl %%edi\n\t" \
"pushl %%ebp\n\t" \
"movl %%esp,%0\n\t" /* save ESP */ \
"movl %2,%%esp\n\t" /* restore ESP */ \
"movl %5,%%esp\n\t" /* restore ESP */ \
"movl $1f,%1\n\t" /* save EIP */ \
"pushl %3\n\t" /* restore EIP */ \
"pushl %6\n\t" /* restore EIP */ \
"jmp __switch_to\n" \
"1:\t" \
"popl %%ebp\n\t" \
"popl %%edi\n\t" \
"popl %%esi\n\t" \
"popfl\n\t" \
:"=m" (prev->thread.esp),"=m" (prev->thread.eip) \
"popfl" \
:"=m" (prev->thread.esp),"=m" (prev->thread.eip), \
"=a" (last),"=S" (esi),"=D" (edi) \
:"m" (next->thread.esp),"m" (next->thread.eip), \
"a" (prev), "d" (next)); \
"2" (prev), "d" (next)); \
} while (0)
#define _set_base(addr,base) do { unsigned long __pr; \
......
......@@ -62,6 +62,7 @@
{ \
.state = 0, \
.thread_info = &init_thread_info, \
.usage = ATOMIC_INIT(2), \
.flags = 0, \
.lock_depth = -1, \
.prio = MAX_PRIO-20, \
......
......@@ -78,6 +78,8 @@ struct ipmi_smi_msg
struct ipmi_smi_handlers
{
struct module *owner;
/* Called to enqueue an SMI message to be sent. This
operation is not allowed to fail. If an error occurs, it
should report back the error in a received message. It may
......@@ -93,15 +95,6 @@ struct ipmi_smi_handlers
events from the BMC we are attached to. */
void (*request_events)(void *send_info);
/* Called when someone is using the interface, so the module can
adjust it's use count. Return zero if successful, or an
errno if not. */
int (*new_user)(void *send_info);
/* Called when someone is no longer using the interface, so the
module can adjust it's use count. */
void (*user_left)(void *send_info);
/* Called when the interface should go into "run to
completion" mode. If this call sets the value to true, the
interface should make sure that all messages are flushed
......
/*
* Motion Eye video4linux driver for Sony Vaio PictureBook
*
* Copyright (C) 2001-2002 Stelian Pop <stelian@popies.net>
* Copyright (C) 2001-2003 Stelian Pop <stelian@popies.net>
*
* Copyright (C) 2001-2002 Alcve <www.alcove.com>
*
......
/*
* Sony Programmable I/O Control Device driver for VAIO
*
* Copyright (C) 2001-2002 Stelian Pop <stelian@popies.net>
* Copyright (C) 2001-2003 Stelian Pop <stelian@popies.net>
*
* Copyright (C) 2001-2002 Alcve <www.alcove.com>
*
......
......@@ -84,6 +84,7 @@ struct rpc_auth {
* Client authentication ops
*/
struct rpc_authops {
struct module *owner;
rpc_authflavor_t au_flavor; /* flavor (RPC_AUTH_*) */
#ifdef RPC_DEBUG
char * au_name;
......
......@@ -126,6 +126,7 @@ typedef struct cb_bridge_map {
* Socket operations.
*/
struct pccard_operations {
struct module *owner;
int (*init)(unsigned int sock);
int (*suspend)(unsigned int sock);
int (*register_callback)(unsigned int sock, void (*handler)(void *, unsigned int), void * info);
......
......@@ -66,12 +66,7 @@ void release_task(struct task_struct * p)
BUG_ON(p->state < TASK_ZOMBIE);
if (p != current)
wait_task_inactive(p);
atomic_dec(&p->user->processes);
security_task_free(p);
free_uid(p->user);
write_lock_irq(&tasklist_lock);
if (unlikely(p->ptrace))
__ptrace_unlink(p);
......
......@@ -74,6 +74,19 @@ int nr_processes(void)
void __put_task_struct(struct task_struct *tsk)
{
WARN_ON(!(tsk->state & (TASK_DEAD | TASK_ZOMBIE)));
WARN_ON(atomic_read(&tsk->usage));
WARN_ON(tsk == current);
security_task_free(tsk);
free_uid(tsk->user);
/*
* The task cache is effectively disabled right now.
* Do we want it? The slab cache already has per-cpu
* stuff, but the thread info (usually a order-1 page
* allocation) doesn't.
*/
if (tsk != current) {
free_thread_info(tsk->thread_info);
kmem_cache_free(task_struct_cachep,tsk);
......@@ -217,7 +230,9 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
*tsk = *orig;
tsk->thread_info = ti;
ti->task = tsk;
atomic_set(&tsk->usage,1);
/* One for us, one for whoever does the "release_task()" (usually parent) */
atomic_set(&tsk->usage,2);
return tsk;
}
......
......@@ -581,6 +581,8 @@ static inline void finish_task_switch(task_t *prev)
finish_arch_switch(rq, prev);
if (mm)
mmdrop(mm);
if (prev->state & (TASK_DEAD | TASK_ZOMBIE))
put_task_struct(prev);
}
/**
......@@ -1185,7 +1187,7 @@ asmlinkage void schedule(void)
* schedule() atomically, we ignore that path for now.
* Otherwise, whine if we are scheduling when we should not be.
*/
if (likely(current->state != TASK_ZOMBIE)) {
if (likely(!(current->state & (TASK_DEAD | TASK_ZOMBIE)))) {
if (unlikely(in_atomic())) {
printk(KERN_ERR "bad: scheduling while atomic!\n");
dump_stack();
......
......@@ -8,6 +8,7 @@
#include <linux/types.h>
#include <linux/sched.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/errno.h>
#include <linux/socket.h>
......@@ -65,6 +66,8 @@ rpcauth_create(rpc_authflavor_t pseudoflavor, struct rpc_clnt *clnt)
if (flavor >= RPC_AUTH_MAXFLAVOR || !(ops = auth_flavors[flavor]))
return NULL;
if (!try_module_get(ops->owner))
return NULL;
clnt->cl_auth = ops->create(clnt, pseudoflavor);
return clnt->cl_auth;
}
......@@ -73,6 +76,8 @@ void
rpcauth_destroy(struct rpc_auth *auth)
{
auth->au_ops->destroy(auth);
module_put(auth->au_ops->owner);
kfree(auth);
}
static spinlock_t rpc_credcache_lock = SPIN_LOCK_UNLOCKED;
......
......@@ -438,8 +438,6 @@ gss_create(struct rpc_clnt *clnt, rpc_authflavor_t flavor)
struct rpc_auth * auth;
dprintk("RPC: creating GSS authenticator for client %p\n",clnt);
if (!try_module_get(THIS_MODULE))
return NULL;
if (!(gss_auth = kmalloc(sizeof(*gss_auth), GFP_KERNEL)))
goto out_dec;
gss_auth->mech = gss_pseudoflavor_to_mech(flavor);
......@@ -470,7 +468,6 @@ gss_create(struct rpc_clnt *clnt, rpc_authflavor_t flavor)
err_free:
kfree(gss_auth);
out_dec:
module_put(THIS_MODULE);
return NULL;
}
......@@ -485,9 +482,6 @@ gss_destroy(struct rpc_auth *auth)
rpc_unlink(gss_auth->path);
rpcauth_free_credcache(auth);
kfree(auth);
module_put(THIS_MODULE);
}
/* gss_destroy_cred (and gss_destroy_ctx) are used to clean up after failure
......@@ -691,6 +685,7 @@ gss_validate(struct rpc_task *task, u32 *p)
}
static struct rpc_authops authgss_ops = {
.owner = THIS_MODULE,
.au_flavor = RPC_AUTH_GSS,
#ifdef RPC_DEBUG
.au_name = "RPCSEC_GSS",
......
......@@ -8,6 +8,7 @@
#include <linux/types.h>
#include <linux/socket.h>
#include <linux/module.h>
#include <linux/in.h>
#include <linux/utsname.h>
#include <linux/sunrpc/clnt.h>
......@@ -41,7 +42,6 @@ nul_destroy(struct rpc_auth *auth)
{
dprintk("RPC: destroying NULL authenticator %p\n", auth);
rpcauth_free_credcache(auth);
kfree(auth);
}
/*
......@@ -125,6 +125,7 @@ nul_validate(struct rpc_task *task, u32 *p)
}
struct rpc_authops authnull_ops = {
.owner = THIS_MODULE,
.au_flavor = RPC_AUTH_NULL,
#ifdef RPC_DEBUG
.au_name = "NULL",
......
......@@ -8,6 +8,7 @@
#include <linux/types.h>
#include <linux/sched.h>
#include <linux/module.h>
#include <linux/socket.h>
#include <linux/in.h>
#include <linux/sunrpc/clnt.h>
......@@ -60,7 +61,6 @@ unx_destroy(struct rpc_auth *auth)
{
dprintk("RPC: destroying UNIX authenticator %p\n", auth);
rpcauth_free_credcache(auth);
kfree(auth);
}
static struct rpc_cred *
......@@ -219,6 +219,7 @@ unx_validate(struct rpc_task *task, u32 *p)
}
struct rpc_authops authunix_ops = {
.owner = THIS_MODULE,
.au_flavor = RPC_AUTH_UNIX,
#ifdef RPC_DEBUG
.au_name = "UNIX",
......
......@@ -14,6 +14,8 @@ build-targets := $(host-progs) empty.o
modpost-objs := modpost.o file2alias.o
clean-files := elfconfig.h
# Let clean descend into subdirs
subdir- := lxdialog kconfig
......
......@@ -150,8 +150,6 @@ void *snd_hammerfall_get_buffer (struct pci_dev *pcidev, dma_addr_t *dmaaddr)
for (i = 0; i < NBUFS; i++) {
rbuf = &hammerfall_buffers[i];
if (rbuf->flags == HAMMERFALL_BUF_ALLOCATED) {
if (! try_module_get(THIS_MODULE))
return NULL;
rbuf->flags |= HAMMERFALL_BUF_USED;
rbuf->pci = pcidev;
*dmaaddr = rbuf->addr;
......@@ -171,7 +169,6 @@ void snd_hammerfall_free_buffer (struct pci_dev *pcidev, void *addr)
rbuf = &hammerfall_buffers[i];
if (rbuf->buf == addr && rbuf->pci == pcidev) {
rbuf->flags &= ~HAMMERFALL_BUF_USED;
module_put(THIS_MODULE);
return;
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment