From 6898c902b76b3d55022a44da95fbe38569458dd9 Mon Sep 17 00:00:00 2001 From: Pavel Machek Date: Wed, 25 Dec 2002 21:55:05 -0800 Subject: [PATCH] amd756 and amd8111 sensors support Add support for amd756 and amd8111 sensors --- include/linux/i2c-id.h | 1 + include/linux/i2c-proc.h | 25 ++ include/linux/sensors.h | 690 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 716 insertions(+) create mode 100644 include/linux/sensors.h (limited to 'include/linux') diff --git a/include/linux/i2c-id.h b/include/linux/i2c-id.h index 8a52e78b89f0..2b6394004ea1 100644 --- a/include/linux/i2c-id.h +++ b/include/linux/i2c-id.h @@ -233,6 +233,7 @@ #define I2C_HW_SMBUS_ALI1535 0x07 #define I2C_HW_SMBUS_SIS630 0x08 #define I2C_HW_SMBUS_SIS645 0x09 +#define I2C_HW_SMBUS_AMD8111 0x0a /* --- ISA pseudo-adapter */ #define I2C_HW_ISA 0x00 diff --git a/include/linux/i2c-proc.h b/include/linux/i2c-proc.h index 4a4c33db48d5..ccdd2a95b1d1 100644 --- a/include/linux/i2c-proc.h +++ b/include/linux/i2c-proc.h @@ -348,6 +348,31 @@ struct i2c_address_data { {NULL}}; \ SENSORS_INSMOD +#define SENSORS_INSMOD_8(chip1,chip2,chip3,chip4,chip5,chip6,chip7,chip8) \ + enum chips { any_chip, chip1, chip2, chip3, chip4, chip5, chip6, chip7, chip8 }; \ + SENSORS_MODULE_PARM(force, \ + "List of adapter,address pairs to boldly assume " \ + "to be present"); \ + SENSORS_MODULE_PARM_FORCE(chip1); \ + SENSORS_MODULE_PARM_FORCE(chip2); \ + SENSORS_MODULE_PARM_FORCE(chip3); \ + SENSORS_MODULE_PARM_FORCE(chip4); \ + SENSORS_MODULE_PARM_FORCE(chip5); \ + SENSORS_MODULE_PARM_FORCE(chip6); \ + SENSORS_MODULE_PARM_FORCE(chip7); \ + SENSORS_MODULE_PARM_FORCE(chip8); \ + static struct i2c_force_data forces[] = {{force,any_chip}, \ + {force_ ## chip1,chip1}, \ + {force_ ## chip2,chip2}, \ + {force_ ## chip3,chip3}, \ + {force_ ## chip4,chip4}, \ + {force_ ## chip5,chip5}, \ + {force_ ## chip6,chip6}, \ + {force_ ## chip7,chip7}, \ + {force_ ## chip8,chip8}, \ + {NULL}}; \ + SENSORS_INSMOD + typedef int i2c_found_addr_proc(struct i2c_adapter *adapter, int addr, unsigned short flags, int kind); diff --git a/include/linux/sensors.h b/include/linux/sensors.h new file mode 100644 index 000000000000..31998faab1e6 --- /dev/null +++ b/include/linux/sensors.h @@ -0,0 +1,690 @@ +/* + sensors.h - Part of lm_sensors, Linux kernel modules for hardware + monitoring + Copyright (c) 1998, 1999 Frodo Looijaard + + 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. +*/ + +#ifndef SENSORS_NSENSORS_H +#define SENSORS_NSENSORS_H + +#define LM_DATE "20020915" +#define LM_VERSION "2.6.5" + +#include + +#define LM78_SYSCTL_IN0 1000 /* Volts * 100 */ +#define LM78_SYSCTL_IN1 1001 +#define LM78_SYSCTL_IN2 1002 +#define LM78_SYSCTL_IN3 1003 +#define LM78_SYSCTL_IN4 1004 +#define LM78_SYSCTL_IN5 1005 +#define LM78_SYSCTL_IN6 1006 +#define LM78_SYSCTL_FAN1 1101 /* Rotations/min */ +#define LM78_SYSCTL_FAN2 1102 +#define LM78_SYSCTL_FAN3 1103 +#define LM78_SYSCTL_TEMP 1200 /* Degrees Celcius * 10 */ +#define LM78_SYSCTL_VID 1300 /* Volts * 100 */ +#define LM78_SYSCTL_FAN_DIV 2000 /* 1, 2, 4 or 8 */ +#define LM78_SYSCTL_ALARMS 2001 /* bitvector */ + +#define LM78_ALARM_IN0 0x0001 +#define LM78_ALARM_IN1 0x0002 +#define LM78_ALARM_IN2 0x0004 +#define LM78_ALARM_IN3 0x0008 +#define LM78_ALARM_IN4 0x0100 +#define LM78_ALARM_IN5 0x0200 +#define LM78_ALARM_IN6 0x0400 +#define LM78_ALARM_FAN1 0x0040 +#define LM78_ALARM_FAN2 0x0080 +#define LM78_ALARM_FAN3 0x0800 +#define LM78_ALARM_TEMP 0x0010 +#define LM78_ALARM_BTI 0x0020 +#define LM78_ALARM_CHAS 0x1000 +#define LM78_ALARM_FIFO 0x2000 +#define LM78_ALARM_SMI_IN 0x4000 + +#define W83781D_SYSCTL_IN0 1000 /* Volts * 100 */ +#define W83781D_SYSCTL_IN1 1001 +#define W83781D_SYSCTL_IN2 1002 +#define W83781D_SYSCTL_IN3 1003 +#define W83781D_SYSCTL_IN4 1004 +#define W83781D_SYSCTL_IN5 1005 +#define W83781D_SYSCTL_IN6 1006 +#define W83781D_SYSCTL_IN7 1007 +#define W83781D_SYSCTL_IN8 1008 +#define W83781D_SYSCTL_FAN1 1101 /* Rotations/min */ +#define W83781D_SYSCTL_FAN2 1102 +#define W83781D_SYSCTL_FAN3 1103 +#define W83781D_SYSCTL_TEMP1 1200 /* Degrees Celcius * 10 */ +#define W83781D_SYSCTL_TEMP2 1201 /* Degrees Celcius * 10 */ +#define W83781D_SYSCTL_TEMP3 1202 /* Degrees Celcius * 10 */ +#define W83781D_SYSCTL_VID 1300 /* Volts * 1000 */ +#define W83781D_SYSCTL_VRM 1301 +#define W83781D_SYSCTL_PWM1 1401 +#define W83781D_SYSCTL_PWM2 1402 +#define W83781D_SYSCTL_PWM3 1403 +#define W83781D_SYSCTL_PWM4 1404 +#define W83781D_SYSCTL_SENS1 1501 /* 1, 2, or Beta (3000-5000) */ +#define W83781D_SYSCTL_SENS2 1502 +#define W83781D_SYSCTL_SENS3 1503 +#define W83781D_SYSCTL_RT1 1601 /* 32-entry table */ +#define W83781D_SYSCTL_RT2 1602 /* 32-entry table */ +#define W83781D_SYSCTL_RT3 1603 /* 32-entry table */ +#define W83781D_SYSCTL_FAN_DIV 2000 /* 1, 2, 4 or 8 */ +#define W83781D_SYSCTL_ALARMS 2001 /* bitvector */ +#define W83781D_SYSCTL_BEEP 2002 /* bitvector */ + +#define W83781D_ALARM_IN0 0x0001 +#define W83781D_ALARM_IN1 0x0002 +#define W83781D_ALARM_IN2 0x0004 +#define W83781D_ALARM_IN3 0x0008 +#define W83781D_ALARM_IN4 0x0100 +#define W83781D_ALARM_IN5 0x0200 +#define W83781D_ALARM_IN6 0x0400 +#define W83782D_ALARM_IN7 0x10000 +#define W83782D_ALARM_IN8 0x20000 +#define W83781D_ALARM_FAN1 0x0040 +#define W83781D_ALARM_FAN2 0x0080 +#define W83781D_ALARM_FAN3 0x0800 +#define W83781D_ALARM_TEMP1 0x0010 +#define W83781D_ALARM_TEMP23 0x0020 /* 781D only */ +#define W83781D_ALARM_TEMP2 0x0020 /* 782D/783S */ +#define W83781D_ALARM_TEMP3 0x2000 /* 782D only */ +#define W83781D_ALARM_CHAS 0x1000 + +#define LM75_SYSCTL_TEMP 1200 /* Degrees Celcius * 10 */ + +#define ADM1021_SYSCTL_TEMP 1200 +#define ADM1021_SYSCTL_REMOTE_TEMP 1201 +#define ADM1021_SYSCTL_DIE_CODE 1202 +#define ADM1021_SYSCTL_ALARMS 1203 + +#define ADM1021_ALARM_TEMP_HIGH 0x40 +#define ADM1021_ALARM_TEMP_LOW 0x20 +#define ADM1021_ALARM_RTEMP_HIGH 0x10 +#define ADM1021_ALARM_RTEMP_LOW 0x08 +#define ADM1021_ALARM_RTEMP_NA 0x04 + +#define GL518_SYSCTL_VDD 1000 /* Volts * 100 */ +#define GL518_SYSCTL_VIN1 1001 +#define GL518_SYSCTL_VIN2 1002 +#define GL518_SYSCTL_VIN3 1003 +#define GL518_SYSCTL_FAN1 1101 /* RPM */ +#define GL518_SYSCTL_FAN2 1102 +#define GL518_SYSCTL_TEMP 1200 /* Degrees Celcius * 10 */ +#define GL518_SYSCTL_FAN_DIV 2000 /* 1, 2, 4 or 8 */ +#define GL518_SYSCTL_ALARMS 2001 /* bitvector */ +#define GL518_SYSCTL_BEEP 2002 /* bitvector */ +#define GL518_SYSCTL_FAN1OFF 2003 +#define GL518_SYSCTL_ITERATE 2004 + +#define GL518_ALARM_VDD 0x01 +#define GL518_ALARM_VIN1 0x02 +#define GL518_ALARM_VIN2 0x04 +#define GL518_ALARM_VIN3 0x08 +#define GL518_ALARM_TEMP 0x10 +#define GL518_ALARM_FAN1 0x20 +#define GL518_ALARM_FAN2 0x40 + +#define GL520_SYSCTL_VDD 1000 /* Volts * 100 */ +#define GL520_SYSCTL_VIN1 1001 +#define GL520_SYSCTL_VIN2 1002 +#define GL520_SYSCTL_VIN3 1003 +#define GL520_SYSCTL_VIN4 1004 +#define GL520_SYSCTL_FAN1 1101 /* RPM */ +#define GL520_SYSCTL_FAN2 1102 +#define GL520_SYSCTL_TEMP1 1200 /* Degrees Celcius * 10 */ +#define GL520_SYSCTL_TEMP2 1201 /* Degrees Celcius * 10 */ +#define GL520_SYSCTL_VID 1300 +#define GL520_SYSCTL_FAN_DIV 2000 /* 1, 2, 4 or 8 */ +#define GL520_SYSCTL_ALARMS 2001 /* bitvector */ +#define GL520_SYSCTL_BEEP 2002 /* bitvector */ +#define GL520_SYSCTL_FAN1OFF 2003 +#define GL520_SYSCTL_CONFIG 2004 + +#define GL520_ALARM_VDD 0x01 +#define GL520_ALARM_VIN1 0x02 +#define GL520_ALARM_VIN2 0x04 +#define GL520_ALARM_VIN3 0x08 +#define GL520_ALARM_TEMP1 0x10 +#define GL520_ALARM_FAN1 0x20 +#define GL520_ALARM_FAN2 0x40 +#define GL520_ALARM_TEMP2 0x80 +#define GL520_ALARM_VIN4 0x80 + +#define EEPROM_SYSCTL1 1000 +#define EEPROM_SYSCTL2 1001 +#define EEPROM_SYSCTL3 1002 +#define EEPROM_SYSCTL4 1003 +#define EEPROM_SYSCTL5 1004 +#define EEPROM_SYSCTL6 1005 +#define EEPROM_SYSCTL7 1006 +#define EEPROM_SYSCTL8 1007 +#define EEPROM_SYSCTL9 1008 +#define EEPROM_SYSCTL10 1009 +#define EEPROM_SYSCTL11 1010 +#define EEPROM_SYSCTL12 1011 +#define EEPROM_SYSCTL13 1012 +#define EEPROM_SYSCTL14 1013 +#define EEPROM_SYSCTL15 1014 +#define EEPROM_SYSCTL16 1015 + +#define LM80_SYSCTL_IN0 1000 /* Volts * 100 */ +#define LM80_SYSCTL_IN1 1001 +#define LM80_SYSCTL_IN2 1002 +#define LM80_SYSCTL_IN3 1003 +#define LM80_SYSCTL_IN4 1004 +#define LM80_SYSCTL_IN5 1005 +#define LM80_SYSCTL_IN6 1006 +#define LM80_SYSCTL_FAN1 1101 /* Rotations/min */ +#define LM80_SYSCTL_FAN2 1102 +#define LM80_SYSCTL_TEMP 1250 /* Degrees Celcius * 100 */ +#define LM80_SYSCTL_FAN_DIV 2000 /* 1, 2, 4 or 8 */ +#define LM80_SYSCTL_ALARMS 2001 /* bitvector */ + +#define ADM9240_SYSCTL_IN0 1000 /* Volts * 100 */ +#define ADM9240_SYSCTL_IN1 1001 +#define ADM9240_SYSCTL_IN2 1002 +#define ADM9240_SYSCTL_IN3 1003 +#define ADM9240_SYSCTL_IN4 1004 +#define ADM9240_SYSCTL_IN5 1005 +#define ADM9240_SYSCTL_FAN1 1101 /* Rotations/min */ +#define ADM9240_SYSCTL_FAN2 1102 +#define ADM9240_SYSCTL_TEMP 1250 /* Degrees Celcius * 100 */ +#define ADM9240_SYSCTL_FAN_DIV 2000 /* 1, 2, 4 or 8 */ +#define ADM9240_SYSCTL_ALARMS 2001 /* bitvector */ +#define ADM9240_SYSCTL_ANALOG_OUT 2002 +#define ADM9240_SYSCTL_VID 2003 + +#define ADM9240_ALARM_IN0 0x0001 +#define ADM9240_ALARM_IN1 0x0002 +#define ADM9240_ALARM_IN2 0x0004 +#define ADM9240_ALARM_IN3 0x0008 +#define ADM9240_ALARM_IN4 0x0100 +#define ADM9240_ALARM_IN5 0x0200 +#define ADM9240_ALARM_FAN1 0x0040 +#define ADM9240_ALARM_FAN2 0x0080 +#define ADM9240_ALARM_TEMP 0x0010 +#define ADM9240_ALARM_CHAS 0x1000 + +#define ADM1024_SYSCTL_IN0 1000 /* Volts * 100 */ +#define ADM1024_SYSCTL_IN1 1001 +#define ADM1024_SYSCTL_IN2 1002 +#define ADM1024_SYSCTL_IN3 1003 +#define ADM1024_SYSCTL_IN4 1004 +#define ADM1024_SYSCTL_IN5 1005 +#define ADM1024_SYSCTL_FAN1 1101 /* Rotations/min */ +#define ADM1024_SYSCTL_FAN2 1102 +#define ADM1024_SYSCTL_TEMP 1250 /* Degrees Celcius * 100 */ +#define ADM1024_SYSCTL_TEMP1 1290 /* Degrees Celcius */ +#define ADM1024_SYSCTL_TEMP2 1295 /* Degrees Celcius */ +#define ADM1024_SYSCTL_FAN_DIV 2000 /* 1, 2, 4 or 8 */ +#define ADM1024_SYSCTL_ALARMS 2001 /* bitvector */ +#define ADM1024_SYSCTL_ANALOG_OUT 2002 +#define ADM1024_SYSCTL_VID 2003 + +#define ADM1024_ALARM_IN0 0x0001 +#define ADM1024_ALARM_IN1 0x0002 +#define ADM1024_ALARM_IN2 0x0004 +#define ADM1024_ALARM_IN3 0x0008 +#define ADM1024_ALARM_IN4 0x0100 +#define ADM1024_ALARM_IN5 0x0200 +#define ADM1024_ALARM_FAN1 0x0040 +#define ADM1024_ALARM_FAN2 0x0080 +#define ADM1024_ALARM_TEMP 0x0010 +#define ADM1024_ALARM_TEMP1 0x0020 +#define ADM1024_ALARM_TEMP2 0x0001 +#define ADM1024_ALARM_CHAS 0x1000 + +#define ADM1025_SYSCTL_IN0 1000 /* Volts * 100 */ +#define ADM1025_SYSCTL_IN1 1001 +#define ADM1025_SYSCTL_IN2 1002 +#define ADM1025_SYSCTL_IN3 1003 +#define ADM1025_SYSCTL_IN4 1004 +#define ADM1025_SYSCTL_IN5 1005 +#define ADM1025_SYSCTL_RTEMP 1251 +#define ADM1025_SYSCTL_TEMP 1250 /* Degrees Celcius * 100 */ +#define ADM1025_SYSCTL_ALARMS 2001 /* bitvector */ +#define ADM1025_SYSCTL_ANALOG_OUT 2002 +#define ADM1025_SYSCTL_VID 2003 +#define ADM1025_SYSCTL_VRM 2004 + +#define ADM1025_ALARM_IN0 0x0001 +#define ADM1025_ALARM_IN1 0x0002 +#define ADM1025_ALARM_IN2 0x0004 +#define ADM1025_ALARM_IN3 0x0008 +#define ADM1025_ALARM_IN4 0x0100 +#define ADM1025_ALARM_IN5 0x0200 +#define ADM1025_ALARM_RTEMP 0x0020 +#define ADM1025_ALARM_TEMP 0x0010 + +#define LTC1710_SYSCTL_SWITCH_1 1000 +#define LTC1710_SYSCTL_SWITCH_2 1001 + +#define LM80_ALARM_IN0 0x0001 +#define LM80_ALARM_IN1 0x0002 +#define LM80_ALARM_IN2 0x0004 +#define LM80_ALARM_IN3 0x0008 +#define LM80_ALARM_IN4 0x0010 +#define LM80_ALARM_IN5 0x0020 +#define LM80_ALARM_IN6 0x0040 +#define LM80_ALARM_FAN1 0x0400 +#define LM80_ALARM_FAN2 0x0800 +#define LM80_ALARM_TEMP_HOT 0x0100 +#define LM80_ALARM_TEMP_OS 0x2000 +#define LM80_ALARM_CHAS 0x1000 +#define LM80_ALARM_BTI 0x0200 +#define LM80_ALARM_INT_IN 0x0080 + +#define MAXI_SYSCTL_FAN1 1101 /* Rotations/min */ +#define MAXI_SYSCTL_FAN2 1102 /* Rotations/min */ +#define MAXI_SYSCTL_FAN3 1103 /* Rotations/min */ +#define MAXI_SYSCTL_FAN4 1104 /* Rotations/min */ +#define MAXI_SYSCTL_TEMP1 1201 /* Degrees Celcius */ +#define MAXI_SYSCTL_TEMP2 1202 /* Degrees Celcius */ +#define MAXI_SYSCTL_TEMP3 1203 /* Degrees Celcius */ +#define MAXI_SYSCTL_TEMP4 1204 /* Degrees Celcius */ +#define MAXI_SYSCTL_TEMP5 1205 /* Degrees Celcius */ +#define MAXI_SYSCTL_TEMP6 1206 /* Degrees Celcius */ +#define MAXI_SYSCTL_PLL 1301 /* MHz */ +#define MAXI_SYSCTL_VID1 1401 /* Volts / 6.337, for nba just Volts */ +#define MAXI_SYSCTL_VID2 1402 /* Volts */ +#define MAXI_SYSCTL_VID3 1403 /* Volts */ +#define MAXI_SYSCTL_VID4 1404 /* Volts */ +#define MAXI_SYSCTL_VID5 1405 /* Volts */ +#define MAXI_SYSCTL_LCD1 1501 /* Line 1 of LCD */ +#define MAXI_SYSCTL_LCD2 1502 /* Line 2 of LCD */ +#define MAXI_SYSCTL_LCD3 1503 /* Line 3 of LCD */ +#define MAXI_SYSCTL_LCD4 1504 /* Line 4 of LCD */ +#define MAXI_SYSCTL_ALARMS 2001 /* Bitvector (see below) */ + +#define MAXI_ALARM_VID4 0x0001 +#define MAXI_ALARM_TEMP2 0x0002 +#define MAXI_ALARM_VID1 0x0004 +#define MAXI_ALARM_VID2 0x0008 +#define MAXI_ALARM_VID3 0x0010 +#define MAXI_ALARM_PLL 0x0080 +#define MAXI_ALARM_TEMP4 0x0100 +#define MAXI_ALARM_TEMP5 0x0200 +#define MAXI_ALARM_FAN1 0x1000 +#define MAXI_ALARM_FAN2 0x2000 +#define MAXI_ALARM_FAN3 0x4000 + +#define MAXI_ALARM_FAN 0x0100 /* To be used with MaxiLife'99 */ +#define MAXI_ALARM_VID 0x0200 /* The MSB specifies which sensor */ +#define MAXI_ALARM_TEMP 0x0400 /* in the alarm group failed, i.e.: */ +#define MAXI_ALARM_VADD 0x0800 /* 0x0402 = TEMP2 failed = CPU2 temp */ + +#define SIS5595_SYSCTL_IN0 1000 /* Volts * 100 */ +#define SIS5595_SYSCTL_IN1 1001 +#define SIS5595_SYSCTL_IN2 1002 +#define SIS5595_SYSCTL_IN3 1003 +#define SIS5595_SYSCTL_IN4 1004 +#define SIS5595_SYSCTL_FAN1 1101 /* Rotations/min */ +#define SIS5595_SYSCTL_FAN2 1102 +#define SIS5595_SYSCTL_TEMP 1200 /* Degrees Celcius * 10 */ +#define SIS5595_SYSCTL_FAN_DIV 2000 /* 1, 2, 4 or 8 */ +#define SIS5595_SYSCTL_ALARMS 2001 /* bitvector */ + +#define SIS5595_ALARM_IN0 0x01 +#define SIS5595_ALARM_IN1 0x02 +#define SIS5595_ALARM_IN2 0x04 +#define SIS5595_ALARM_IN3 0x08 +#define SIS5595_ALARM_BTI 0x20 +#define SIS5595_ALARM_FAN1 0x40 +#define SIS5595_ALARM_FAN2 0x80 +#define SIS5595_ALARM_IN4 0x8000 +#define SIS5595_ALARM_TEMP 0x8000 + +#define VIA686A_SYSCTL_IN0 1000 +#define VIA686A_SYSCTL_IN1 1001 +#define VIA686A_SYSCTL_IN2 1002 +#define VIA686A_SYSCTL_IN3 1003 +#define VIA686A_SYSCTL_IN4 1004 +#define VIA686A_SYSCTL_FAN1 1101 +#define VIA686A_SYSCTL_FAN2 1102 +#define VIA686A_SYSCTL_TEMP 1200 +#define VIA686A_SYSCTL_TEMP2 1201 +#define VIA686A_SYSCTL_TEMP3 1202 +#define VIA686A_SYSCTL_FAN_DIV 2000 +#define VIA686A_SYSCTL_ALARMS 2001 + +#define VIA686A_ALARM_IN0 0x01 +#define VIA686A_ALARM_IN1 0x02 +#define VIA686A_ALARM_IN2 0x04 +#define VIA686A_ALARM_IN3 0x08 +#define VIA686A_ALARM_TEMP 0x10 +#define VIA686A_ALARM_FAN1 0x40 +#define VIA686A_ALARM_FAN2 0x80 +#define VIA686A_ALARM_IN4 0x100 +#define VIA686A_ALARM_TEMP2 0x800 +#define VIA686A_ALARM_CHAS 0x1000 +#define VIA686A_ALARM_TEMP3 0x8000 + +#define ICSPLL_SYSCTL1 1000 + +#define BT869_SYSCTL_STATUS 1000 +#define BT869_SYSCTL_NTSC 1001 +#define BT869_SYSCTL_HALF 1002 +#define BT869_SYSCTL_RES 1003 +#define BT869_SYSCTL_COLORBARS 1004 +#define BT869_SYSCTL_DEPTH 1005 +#define BT869_SYSCTL_SVIDEO 1006 + +#define MATORB_SYSCTL_DISP 1000 + +#define THMC50_SYSCTL_TEMP 1200 /* Degrees Celcius */ +#define THMC50_SYSCTL_REMOTE_TEMP 1201 /* Degrees Celcius */ +#define THMC50_SYSCTL_INTER 1202 +#define THMC50_SYSCTL_INTER_MASK 1203 +#define THMC50_SYSCTL_DIE_CODE 1204 +#define THMC50_SYSCTL_ANALOG_OUT 1205 + +#define DDCMON_SYSCTL_ID 1010 +#define DDCMON_SYSCTL_SIZE 1011 +#define DDCMON_SYSCTL_SYNC 1012 +#define DDCMON_SYSCTL_TIMINGS 1013 +#define DDCMON_SYSCTL_SERIAL 1014 + +#define LM87_SYSCTL_IN0 1000 /* Volts * 100 */ +#define LM87_SYSCTL_IN1 1001 +#define LM87_SYSCTL_IN2 1002 +#define LM87_SYSCTL_IN3 1003 +#define LM87_SYSCTL_IN4 1004 +#define LM87_SYSCTL_IN5 1005 +#define LM87_SYSCTL_AIN1 1006 +#define LM87_SYSCTL_AIN2 1007 +#define LM87_SYSCTL_FAN1 1102 +#define LM87_SYSCTL_FAN2 1103 +#define LM87_SYSCTL_TEMP1 1250 /* Degrees Celcius * 100 */ +#define LM87_SYSCTL_TEMP2 1251 /* Degrees Celcius * 100 */ +#define LM87_SYSCTL_TEMP3 1252 /* Degrees Celcius * 100 */ +#define LM87_SYSCTL_FAN_DIV 2000 /* 1, 2, 4 or 8 */ +#define LM87_SYSCTL_ALARMS 2001 /* bitvector */ +#define LM87_SYSCTL_ANALOG_OUT 2002 +#define LM87_SYSCTL_VID 2003 +#define LM87_SYSCTL_VRM 2004 + +#define LM87_ALARM_IN0 0x0001 +#define LM87_ALARM_IN1 0x0002 +#define LM87_ALARM_IN2 0x0004 +#define LM87_ALARM_IN3 0x0008 +#define LM87_ALARM_TEMP1 0x0010 +#define LM87_ALARM_TEMP2 0x0020 +#define LM87_ALARM_TEMP3 0x0020 /* same?? */ +#define LM87_ALARM_FAN1 0x0040 +#define LM87_ALARM_FAN2 0x0080 +#define LM87_ALARM_IN4 0x0100 +#define LM87_ALARM_IN5 0x0200 +#define LM87_ALARM_RESERVED1 0x0400 +#define LM87_ALARM_RESERVED2 0x0800 +#define LM87_ALARM_CHAS 0x1000 +#define LM87_ALARM_THERM_SIG 0x2000 +#define LM87_ALARM_TEMP2_FAULT 0x4000 +#define LM87_ALARM_TEMP3_FAULT 0x08000 + +#define PCF8574_SYSCTL_READ 1000 +#define PCF8574_SYSCTL_WRITE 1001 + +#define MTP008_SYSCTL_IN0 1000 /* Volts * 100 */ +#define MTP008_SYSCTL_IN1 1001 +#define MTP008_SYSCTL_IN2 1002 +#define MTP008_SYSCTL_IN3 1003 +#define MTP008_SYSCTL_IN4 1004 +#define MTP008_SYSCTL_IN5 1005 +#define MTP008_SYSCTL_IN6 1006 +#define MTP008_SYSCTL_FAN1 1101 /* Rotations/min */ +#define MTP008_SYSCTL_FAN2 1102 +#define MTP008_SYSCTL_FAN3 1103 +#define MTP008_SYSCTL_TEMP1 1200 /* Degrees Celcius * 10 */ +#define MTP008_SYSCTL_TEMP2 1201 /* Degrees Celcius * 10 */ +#define MTP008_SYSCTL_TEMP3 1202 /* Degrees Celcius * 10 */ +#define MTP008_SYSCTL_VID 1300 /* Volts * 100 */ +#define MTP008_SYSCTL_PWM1 1401 +#define MTP008_SYSCTL_PWM2 1402 +#define MTP008_SYSCTL_PWM3 1403 +#define MTP008_SYSCTL_SENS1 1501 /* 1, 2, or Beta (3000-5000) */ +#define MTP008_SYSCTL_SENS2 1502 +#define MTP008_SYSCTL_SENS3 1503 +#define MTP008_SYSCTL_FAN_DIV 2000 /* 1, 2, 4 or 8 */ +#define MTP008_SYSCTL_ALARMS 2001 /* bitvector */ +#define MTP008_SYSCTL_BEEP 2002 /* bitvector */ + +#define MTP008_ALARM_IN0 0x0001 +#define MTP008_ALARM_IN1 0x0002 +#define MTP008_ALARM_IN2 0x0004 +#define MTP008_ALARM_IN3 0x0008 +#define MTP008_ALARM_IN4 0x0100 +#define MTP008_ALARM_IN5 0x0200 +#define MTP008_ALARM_IN6 0x0400 +#define MTP008_ALARM_FAN1 0x0040 +#define MTP008_ALARM_FAN2 0x0080 +#define MTP008_ALARM_FAN3 0x0800 +#define MTP008_ALARM_TEMP1 0x0010 +#define MTP008_ALARM_TEMP2 0x0100 +#define MTP008_ALARM_TEMP3 0x0200 + +#define DS1621_SYSCTL_TEMP 1200 /* Degrees Celcius * 10 */ +#define DS1621_SYSCTL_ALARMS 2001 /* bitvector */ +#define DS1621_ALARM_TEMP_HIGH 0x40 +#define DS1621_ALARM_TEMP_LOW 0x20 +#define DS1621_SYSCTL_ENABLE 2002 +#define DS1621_SYSCTL_CONTINUOUS 2003 +#define DS1621_SYSCTL_POLARITY 2004 + +#define IT87_SYSCTL_IN0 1000 /* Volts * 100 */ +#define IT87_SYSCTL_IN1 1001 +#define IT87_SYSCTL_IN2 1002 +#define IT87_SYSCTL_IN3 1003 +#define IT87_SYSCTL_IN4 1004 +#define IT87_SYSCTL_IN5 1005 +#define IT87_SYSCTL_IN6 1006 +#define IT87_SYSCTL_IN7 1007 +#define IT87_SYSCTL_IN8 1008 +#define IT87_SYSCTL_FAN1 1101 /* Rotations/min */ +#define IT87_SYSCTL_FAN2 1102 +#define IT87_SYSCTL_FAN3 1103 +#define IT87_SYSCTL_TEMP1 1200 /* Degrees Celcius * 10 */ +#define IT87_SYSCTL_TEMP2 1201 /* Degrees Celcius * 10 */ +#define IT87_SYSCTL_TEMP3 1202 /* Degrees Celcius * 10 */ +#define IT87_SYSCTL_VID 1300 /* Volts * 100 */ +#define IT87_SYSCTL_FAN_DIV 2000 /* 1, 2, 4 or 8 */ +#define IT87_SYSCTL_ALARMS 2004 /* bitvector */ + +#define IT87_ALARM_IN0 0x000100 +#define IT87_ALARM_IN1 0x000200 +#define IT87_ALARM_IN2 0x000400 +#define IT87_ALARM_IN3 0x000800 +#define IT87_ALARM_IN4 0x001000 +#define IT87_ALARM_IN5 0x002000 +#define IT87_ALARM_IN6 0x004000 +#define IT87_ALARM_IN7 0x008000 +#define IT87_ALARM_FAN1 0x0001 +#define IT87_ALARM_FAN2 0x0002 +#define IT87_ALARM_FAN3 0x0004 +#define IT87_ALARM_TEMP1 0x00010000 +#define IT87_ALARM_TEMP2 0x00020000 +#define IT87_ALARM_TEMP3 0x00040000 + +#define FSCPOS_SYSCTL_VOLT0 1000 /* 12 volt supply */ +#define FSCPOS_SYSCTL_VOLT1 1001 /* 5 volt supply */ +#define FSCPOS_SYSCTL_VOLT2 1002 /* batterie voltage*/ +#define FSCPOS_SYSCTL_FAN0 1101 /* state, min, ripple, actual value fan 0 */ +#define FSCPOS_SYSCTL_FAN1 1102 /* state, min, ripple, actual value fan 1 */ +#define FSCPOS_SYSCTL_FAN2 1103 /* state, min, ripple, actual value fan 2 */ +#define FSCPOS_SYSCTL_TEMP0 1201 /* state and value of sensor 0, cpu die */ +#define FSCPOS_SYSCTL_TEMP1 1202 /* state and value of sensor 1, motherboard */ +#define FSCPOS_SYSCTL_TEMP2 1203 /* state and value of sensor 2, chassis */ +#define FSCPOS_SYSCTL_REV 2000 /* Revision */ +#define FSCPOS_SYSCTL_EVENT 2001 /* global event status */ +#define FSCPOS_SYSCTL_CONTROL 2002 /* global control byte */ +#define FSCPOS_SYSCTL_WDOG 2003 /* state, min, ripple, actual value fan 2 */ + +#define FSCSCY_SYSCTL_VOLT0 1000 /* 12 volt supply */ +#define FSCSCY_SYSCTL_VOLT1 1001 /* 5 volt supply */ +#define FSCSCY_SYSCTL_VOLT2 1002 /* batterie voltage*/ +#define FSCSCY_SYSCTL_FAN0 1101 /* state, min, ripple, actual value fan 0 */ +#define FSCSCY_SYSCTL_FAN1 1102 /* state, min, ripple, actual value fan 1 */ +#define FSCSCY_SYSCTL_FAN2 1103 /* state, min, ripple, actual value fan 2 */ +#define FSCSCY_SYSCTL_FAN3 1104 /* state, min, ripple, actual value fan 3 */ +#define FSCSCY_SYSCTL_FAN4 1105 /* state, min, ripple, actual value fan 4 */ +#define FSCSCY_SYSCTL_FAN5 1106 /* state, min, ripple, actual value fan 5 */ +#define FSCSCY_SYSCTL_TEMP0 1201 /* state and value of sensor 0, cpu die */ +#define FSCSCY_SYSCTL_TEMP1 1202 /* state and value of sensor 1, motherboard */ +#define FSCSCY_SYSCTL_TEMP2 1203 /* state and value of sensor 2, chassis */ +#define FSCSCY_SYSCTL_TEMP3 1204 /* state and value of sensor 3, chassis */ +#define FSCSCY_SYSCTL_REV 2000 /* Revision */ +#define FSCSCY_SYSCTL_EVENT 2001 /* global event status */ +#define FSCSCY_SYSCTL_CONTROL 2002 /* global control byte */ +#define FSCSCY_SYSCTL_WDOG 2003 /* state, min, ripple, actual value fan 2 */ +#define FSCSCY_SYSCTL_PCILOAD 2004 /* PCILoad value */ +#define FSCSCY_SYSCTL_INTRUSION 2005 /* state, control for intrusion sensor */ + +#define PCF8591_SYSCTL_AIN_CONF 1000 /* Analog input configuration */ +#define PCF8591_SYSCTL_CH0 1001 /* Input channel 1 */ +#define PCF8591_SYSCTL_CH1 1002 /* Input channel 2 */ +#define PCF8591_SYSCTL_CH2 1003 /* Input channel 3 */ +#define PCF8591_SYSCTL_CH3 1004 /* Input channel 4 */ +#define PCF8591_SYSCTL_AOUT_ENABLE 1005 /* Analog output enable flag */ +#define PCF8591_SYSCTL_AOUT 1006 /* Analog output */ + +#define ARP_SYSCTL1 1000 +#define ARP_SYSCTL2 1001 +#define ARP_SYSCTL3 1002 +#define ARP_SYSCTL4 1003 +#define ARP_SYSCTL5 1004 +#define ARP_SYSCTL6 1005 +#define ARP_SYSCTL7 1006 +#define ARP_SYSCTL8 1007 + +#define SMSC47M1_SYSCTL_FAN1 1101 /* Rotations/min */ +#define SMSC47M1_SYSCTL_FAN2 1102 +#define SMSC47M1_SYSCTL_PWM1 1401 +#define SMSC47M1_SYSCTL_PWM2 1402 +#define SMSC47M1_SYSCTL_FAN_DIV 2000 /* 1, 2, 4 or 8 */ +#define SMSC47M1_SYSCTL_ALARMS 2004 /* bitvector */ + +#define SMSC47M1_ALARM_FAN1 0x0001 +#define SMSC47M1_ALARM_FAN2 0x0002 + +#define VT1211_SYSCTL_IN0 1000 +#define VT1211_SYSCTL_IN1 1001 +#define VT1211_SYSCTL_IN2 1002 +#define VT1211_SYSCTL_IN3 1003 +#define VT1211_SYSCTL_IN4 1004 +#define VT1211_SYSCTL_IN5 1005 +#define VT1211_SYSCTL_IN6 1006 +#define VT1211_SYSCTL_FAN1 1101 +#define VT1211_SYSCTL_FAN2 1102 +#define VT1211_SYSCTL_TEMP 1200 +#define VT1211_SYSCTL_TEMP2 1201 +#define VT1211_SYSCTL_TEMP3 1202 +#define VT1211_SYSCTL_TEMP4 1203 +#define VT1211_SYSCTL_TEMP5 1204 +#define VT1211_SYSCTL_TEMP6 1205 +#define VT1211_SYSCTL_TEMP7 1206 +#define VT1211_SYSCTL_VID 1300 +#define VT1211_SYSCTL_PWM1 1401 +#define VT1211_SYSCTL_PWM2 1402 +#define VT1211_SYSCTL_VRM 1600 +#define VT1211_SYSCTL_UCH 1700 +#define VT1211_SYSCTL_FAN_DIV 2000 +#define VT1211_SYSCTL_ALARMS 2001 + +#define VT1211_ALARM_IN1 0x01 +#define VT1211_ALARM_IN2 0x02 +#define VT1211_ALARM_IN5 0x04 +#define VT1211_ALARM_IN3 0x08 +#define VT1211_ALARM_TEMP 0x10 +#define VT1211_ALARM_FAN1 0x40 +#define VT1211_ALARM_FAN2 0x80 +#define VT1211_ALARM_IN4 0x100 +#define VT1211_ALARM_IN6 0x200 +#define VT1211_ALARM_TEMP2 0x800 +#define VT1211_ALARM_CHAS 0x1000 +#define VT1211_ALARM_TEMP3 0x8000 +/* duplicates */ +#define VT1211_ALARM_IN0 VT1211_ALARM_TEMP +#define VT1211_ALARM_TEMP4 VT1211_ALARM_IN1 +#define VT1211_ALARM_TEMP5 VT1211_ALARM_IN2 +#define VT1211_ALARM_TEMP6 VT1211_ALARM_IN3 +#define VT1211_ALARM_TEMP7 VT1211_ALARM_IN4 + +#define LM92_SYSCTL_ALARMS 2001 /* high, low, critical */ +#define LM92_SYSCTL_TEMP 1200 /* high, low, critical, hysterisis, input */ + +#define LM92_ALARM_TEMP_HIGH 0x01 +#define LM92_ALARM_TEMP_LOW 0x02 +#define LM92_ALARM_TEMP_CRIT 0x04 +#define LM92_TEMP_HIGH 0x08 +#define LM92_TEMP_LOW 0x10 +#define LM92_TEMP_CRIT 0x20 +#define LM92_TEMP_HYST 0x40 +#define LM92_TEMP_INPUT 0x80 + +#define VT8231_SYSCTL_IN0 1000 +#define VT8231_SYSCTL_IN1 1001 +#define VT8231_SYSCTL_IN2 1002 +#define VT8231_SYSCTL_IN3 1003 +#define VT8231_SYSCTL_IN4 1004 +#define VT8231_SYSCTL_IN5 1005 +#define VT8231_SYSCTL_IN6 1006 +#define VT8231_SYSCTL_FAN1 1101 +#define VT8231_SYSCTL_FAN2 1102 +#define VT8231_SYSCTL_TEMP 1200 +#define VT8231_SYSCTL_TEMP2 1201 +#define VT8231_SYSCTL_TEMP3 1202 +#define VT8231_SYSCTL_TEMP4 1203 +#define VT8231_SYSCTL_TEMP5 1204 +#define VT8231_SYSCTL_TEMP6 1205 +#define VT8231_SYSCTL_TEMP7 1206 +#define VT8231_SYSCTL_VID 1300 +#define VT8231_SYSCTL_PWM1 1401 +#define VT8231_SYSCTL_PWM2 1402 +#define VT8231_SYSCTL_VRM 1600 +#define VT8231_SYSCTL_UCH 1700 +#define VT8231_SYSCTL_FAN_DIV 2000 +#define VT8231_SYSCTL_ALARMS 2001 + +#define VT8231_ALARM_IN1 0x01 +#define VT8231_ALARM_IN2 0x02 +#define VT8231_ALARM_IN5 0x04 +#define VT8231_ALARM_IN3 0x08 +#define VT8231_ALARM_TEMP 0x10 +#define VT8231_ALARM_FAN1 0x40 +#define VT8231_ALARM_FAN2 0x80 +#define VT8231_ALARM_IN4 0x100 +#define VT8231_ALARM_IN6 0x200 +#define VT8231_ALARM_TEMP2 0x800 +#define VT8231_ALARM_CHAS 0x1000 +#define VT8231_ALARM_TEMP3 0x8000 +/* duplicates */ +#define VT8231_ALARM_IN0 VT8231_ALARM_TEMP +#define VT8231_ALARM_TEMP4 VT8231_ALARM_IN1 +#define VT8231_ALARM_TEMP5 VT8231_ALARM_IN2 +#define VT8231_ALARM_TEMP6 VT8231_ALARM_IN3 +#define VT8231_ALARM_TEMP7 VT8231_ALARM_IN4 + +#define SMARTBATT_SYSCTL_I 1001 +#define SMARTBATT_SYSCTL_V 1002 +#define SMARTBATT_SYSCTL_TEMP 1003 +#define SMARTBATT_SYSCTL_TIME 1004 +#define SMARTBATT_SYSCTL_ALARMS 1005 +#define SMARTBATT_SYSCTL_CHARGE 1006 + + +#endif /* def SENSORS_SENSORS_H */ -- cgit v1.2.3 From a83c24f33622b86c3cb2a53f959a042d67ab7258 Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Wed, 25 Dec 2002 23:27:03 -0800 Subject: [FB] Fix minor typos wrt readq/writeq support on 64-bit targets. --- drivers/video/cfbcopyarea.c | 2 +- include/linux/fb.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'include/linux') diff --git a/drivers/video/cfbcopyarea.c b/drivers/video/cfbcopyarea.c index 43c030ff9ad7..f99a1692d5cb 100644 --- a/drivers/video/cfbcopyarea.c +++ b/drivers/video/cfbcopyarea.c @@ -38,7 +38,7 @@ #define BYTES_PER_LONG 4 #else #define FB_WRITEL fb_writeq -#define FB_READL fb_readq(x) +#define FB_READL fb_readq #define SHIFT_PER_LONG 6 #define BYTES_PER_LONG 8 #endif diff --git a/include/linux/fb.h b/include/linux/fb.h index 23dd4c02ddec..188da2f94589 100644 --- a/include/linux/fb.h +++ b/include/linux/fb.h @@ -424,9 +424,11 @@ struct fb_info { #define fb_readb __raw_readb #define fb_readw __raw_readw #define fb_readl __raw_readl +#define fb_readq __raw_readq #define fb_writeb __raw_writeb #define fb_writew __raw_writew #define fb_writel __raw_writel +#define fb_writeq __raw_writeq #define fb_memset memset_io #else -- cgit v1.2.3 From 61426cf2ce361f3b06fbe855f5cc56df2e24edd2 Mon Sep 17 00:00:00 2001 From: David Brownell Date: Thu, 26 Dec 2002 17:39:46 -0800 Subject: [PATCH] usbcore dma updates (and doc) Attached is a patch leveraging some of the new generic dma stuff: - Replaces dma mapping calls in usbcore with generic equivalents. This is a minor code shrink (which we'd hoped could happen). - Pass dma mask along, so net drivers can notice it'd be good to set NETIF_F_HIGHDMA; or scsi ones can set highmem_io. (Some Intel EHCI setups are able to support this kind of DMA.) - Updates one net driver (usbnet) to set NETIF_F_HIGHDMA when appropriate, mostly as an example (since I can't test this). - Provides Documentation/usb/dma.txt, describing current APIs. (Unchanged by this patch, except dma mask visibility.) - Converted another info() to dev_info(), and likewise a couple dbg() to dev_dbg() conversions in the modified routine. The number of FIXMEs was conserved: the generic API doesn't yet fix the error reporting bugs in the PCI-specific mapping API. --- Documentation/usb/dma.txt | 104 ++++++++++++++++++++++++++++++++++++++++ drivers/usb/core/buffer.c | 100 ++------------------------------------- drivers/usb/core/hcd-pci.c | 3 +- drivers/usb/core/hcd.c | 20 +++----- drivers/usb/core/hcd.h | 37 --------------- drivers/usb/core/usb.c | 105 +++++++++++++++++------------------------ drivers/usb/host/ehci-hcd.c | 7 +-- drivers/usb/host/ohci-sa1111.c | 3 +- drivers/usb/net/usbnet.c | 11 ++++- include/linux/usb.h | 16 +++---- 10 files changed, 184 insertions(+), 222 deletions(-) create mode 100644 Documentation/usb/dma.txt (limited to 'include/linux') diff --git a/Documentation/usb/dma.txt b/Documentation/usb/dma.txt new file mode 100644 index 000000000000..fae537186570 --- /dev/null +++ b/Documentation/usb/dma.txt @@ -0,0 +1,104 @@ +In Linux 2.5 kernels (and later), USB device drivers have additional control +over how DMA may be used to perform I/O operations. The APIs are detailed +in the kernel usb programming guide (kerneldoc, from the source code). + + +API OVERVIEW + +The big picture is that USB drivers can continue to ignore most DMA issues, +though they still must provide DMA-ready buffers (see DMA-mapping.txt). +That's how they've worked through the 2.4 (and earlier) kernels. + +OR: they can now be DMA-aware. + +- New calls enable DMA-aware drivers, letting them allocate dma buffers and + manage dma mappings for existing dma-ready buffers (see below). + +- URBs have an additional "transfer_dma" field, as well as a transfer_flags + bit saying if it's valid. (Control requests also needed "setup_dma".) + +- "usbcore" will map those DMA addresses, if a DMA-aware driver didn't do it + first and set URB_NO_DMA_MAP. HCDs don't manage dma mappings for urbs. + +- There's a new "generic DMA API", parts of which are usable by USB device + drivers. Never use dma_set_mask() on any USB interface or device; that + would potentially break all devices sharing that bus. + + +ELIMINATING COPIES + +It's good to avoid making CPUs copy data needlessly. The costs can add up, +and effects like cache-trashing can impose subtle penalties. + +- When you're allocating a buffer for DMA purposes anyway, use the buffer + primitives. Think of them as kmalloc and kfree that give you the right + kind of addresses to store in urb->transfer_buffer and urb->transfer_dma, + while guaranteeing that hidden copies through DMA "bounce" buffers won't + slow things down. You'd also set URB_NO_DMA_MAP in urb->transfer_flags: + + void *usb_buffer_alloc (struct usb_device *dev, size_t size, + int mem_flags, dma_addr_t *dma); + + void usb_buffer_free (struct usb_device *dev, size_t size, + void *addr, dma_addr_t dma); + + The memory buffer returned is "dma-coherent"; sometimes you might need to + force a consistent memory access ordering by using memory barriers. It's + not using a streaming DMA mapping, so it's good for small transfers on + systems where the I/O would otherwise tie up an IOMMU mapping. + + Asking for 1/Nth of a page (as well as asking for N pages) is reasonably + space-efficient. + +- Devices on some EHCI controllers could handle DMA to/from high memory. + Driver probe() routines can notice this using a generic DMA call, then + tell higher level code (network, scsi, etc) about it like this: + + if (dma_supported (&intf->dev, 0xffffffffffffffffULL)) + net->features |= NETIF_F_HIGHDMA; + + That can eliminate dma bounce buffering of requests that originate (or + terminate) in high memory, in cases where the buffers aren't allocated + with usb_buffer_alloc() but instead are dma-mapped. + + +WORKING WITH EXISTING BUFFERS + +Existing buffers aren't usable for DMA without first being mapped into the +DMA address space of the device. + +- When you're using scatterlists, you can map everything at once. On some + systems, this kicks in an IOMMU and turns the scatterlists into single + DMA transactions: + + int usb_buffer_map_sg (struct usb_device *dev, unsigned pipe, + struct scatterlist *sg, int nents); + + void usb_buffer_dmasync_sg (struct usb_device *dev, unsigned pipe, + struct scatterlist *sg, int n_hw_ents); + + void usb_buffer_unmap_sg (struct usb_device *dev, unsigned pipe, + struct scatterlist *sg, int n_hw_ents); + + It's probably easier to use the new usb_sg_*() calls, which do the DMA + mapping and apply other tweaks to make scatterlist i/o be fast. + +- Some drivers may prefer to work with the model that they're mapping large + buffers, synchronizing their safe re-use. (If there's no re-use, then let + usbcore do the map/unmap.) Large periodic transfers make good examples + here, since it's cheaper to just synchronize the buffer than to unmap it + each time an urb completes and then re-map it on during resubmission. + + These calls all work with initialized urbs: urb->dev, urb->pipe, + urb->transfer_buffer, and urb->transfer_buffer_length must all be + valid when these calls are used: + + struct urb *usb_buffer_map (struct urb *urb); + + void usb_buffer_dmasync (struct urb *urb); + + void usb_buffer_unmap (struct urb *urb); + + The calls manage urb->transfer_dma for you, and set URB_NO_DMA_MAP so that + usbcore won't map or unmap the buffer. + diff --git a/drivers/usb/core/buffer.c b/drivers/usb/core/buffer.c index 4f4211af98b6..6e4392596750 100644 --- a/drivers/usb/core/buffer.c +++ b/drivers/usb/core/buffer.c @@ -24,11 +24,14 @@ /* - * DMA-Consistent Buffers + * DMA-Coherent Buffers */ /* FIXME tune these based on pool statistics ... */ static const size_t pool_max [HCD_BUFFER_POOLS] = { + /* platforms without dma-friendly caches might need to + * prevent cacheline sharing... + */ 32, 128, 512, @@ -133,98 +136,3 @@ void hcd_buffer_free ( } pci_free_consistent (hcd->pdev, size, addr, dma); } - - -/* - * DMA-Mappings for arbitrary memory buffers - */ - -int hcd_buffer_map ( - struct usb_bus *bus, - void *addr, - dma_addr_t *dma, - size_t size, - int direction -) { - struct usb_hcd *hcd = bus->hcpriv; - - // FIXME pci_map_single() has no standard failure mode! - *dma = pci_map_single (hcd->pdev, addr, size, - (direction == USB_DIR_IN) - ? PCI_DMA_FROMDEVICE - : PCI_DMA_TODEVICE); - return 0; -} - -void hcd_buffer_dmasync ( - struct usb_bus *bus, - dma_addr_t dma, - size_t size, - int direction -) { - struct usb_hcd *hcd = bus->hcpriv; - - pci_dma_sync_single (hcd->pdev, dma, size, - (direction == USB_DIR_IN) - ? PCI_DMA_FROMDEVICE - : PCI_DMA_TODEVICE); -} - -void hcd_buffer_unmap ( - struct usb_bus *bus, - dma_addr_t dma, - size_t size, - int direction -) { - struct usb_hcd *hcd = bus->hcpriv; - - pci_unmap_single (hcd->pdev, dma, size, - (direction == USB_DIR_IN) - ? PCI_DMA_FROMDEVICE - : PCI_DMA_TODEVICE); -} - -int hcd_buffer_map_sg ( - struct usb_bus *bus, - struct scatterlist *sg, - int *n_hw_ents, - int nents, - int direction -) { - struct usb_hcd *hcd = bus->hcpriv; - - // FIXME pci_map_sg() has no standard failure mode! - *n_hw_ents = pci_map_sg(hcd->pdev, sg, nents, - (direction == USB_DIR_IN) - ? PCI_DMA_FROMDEVICE - : PCI_DMA_TODEVICE); - return 0; -} - -void hcd_buffer_sync_sg ( - struct usb_bus *bus, - struct scatterlist *sg, - int n_hw_ents, - int direction -) { - struct usb_hcd *hcd = bus->hcpriv; - - pci_dma_sync_sg(hcd->pdev, sg, n_hw_ents, - (direction == USB_DIR_IN) - ? PCI_DMA_FROMDEVICE - : PCI_DMA_TODEVICE); -} - -void hcd_buffer_unmap_sg ( - struct usb_bus *bus, - struct scatterlist *sg, - int n_hw_ents, - int direction -) { - struct usb_hcd *hcd = bus->hcpriv; - - pci_unmap_sg(hcd->pdev, sg, n_hw_ents, - (direction == USB_DIR_IN) - ? PCI_DMA_FROMDEVICE - : PCI_DMA_TODEVICE); -} diff --git a/drivers/usb/core/hcd-pci.c b/drivers/usb/core/hcd-pci.c index e66aaac9fa78..9ca856cd6a42 100644 --- a/drivers/usb/core/hcd-pci.c +++ b/drivers/usb/core/hcd-pci.c @@ -138,7 +138,8 @@ clean_2: hcd->pdev = dev; hcd->self.bus_name = dev->slot_name; hcd->product_desc = dev->dev.name; - hcd->controller = &dev->dev; + hcd->self.controller = &dev->dev; + hcd->controller = hcd->self.controller; if ((retval = hcd_buffer_create (hcd)) != 0) { clean_3: diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index 74a3993826fd..624beac700b4 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c @@ -1031,19 +1031,19 @@ static int hcd_submit_urb (struct urb *urb, int mem_flags) /* lower level hcd code should use *_dma exclusively */ if (!(urb->transfer_flags & URB_NO_DMA_MAP)) { if (usb_pipecontrol (urb->pipe)) - urb->setup_dma = pci_map_single ( - hcd->pdev, + urb->setup_dma = dma_map_single ( + hcd->controller, urb->setup_packet, sizeof (struct usb_ctrlrequest), - PCI_DMA_TODEVICE); + DMA_TO_DEVICE); if (urb->transfer_buffer_length != 0) - urb->transfer_dma = pci_map_single ( - hcd->pdev, + urb->transfer_dma = dma_map_single ( + hcd->controller, urb->transfer_buffer, urb->transfer_buffer_length, usb_pipein (urb->pipe) - ? PCI_DMA_FROMDEVICE - : PCI_DMA_TODEVICE); + ? DMA_FROM_DEVICE + : DMA_TO_DEVICE); } status = hcd->driver->urb_enqueue (hcd, urb, mem_flags); @@ -1265,12 +1265,6 @@ struct usb_operations usb_hcd_operations = { .deallocate = hcd_free_dev, .buffer_alloc = hcd_buffer_alloc, .buffer_free = hcd_buffer_free, - .buffer_map = hcd_buffer_map, - .buffer_dmasync = hcd_buffer_dmasync, - .buffer_unmap = hcd_buffer_unmap, - .buffer_map_sg = hcd_buffer_map_sg, - .buffer_dmasync_sg = hcd_buffer_sync_sg, - .buffer_unmap_sg = hcd_buffer_unmap_sg, }; EXPORT_SYMBOL (usb_hcd_operations); diff --git a/drivers/usb/core/hcd.h b/drivers/usb/core/hcd.h index 0db63cf30e7a..99cb0f4b2c84 100644 --- a/drivers/usb/core/hcd.h +++ b/drivers/usb/core/hcd.h @@ -145,26 +145,6 @@ struct usb_operations { dma_addr_t *dma); void (*buffer_free)(struct usb_bus *bus, size_t size, void *addr, dma_addr_t dma); - - int (*buffer_map) (struct usb_bus *bus, - void *addr, dma_addr_t *dma, - size_t size, int direction); - void (*buffer_dmasync) (struct usb_bus *bus, - dma_addr_t dma, - size_t size, int direction); - void (*buffer_unmap) (struct usb_bus *bus, - dma_addr_t dma, - size_t size, int direction); - - int (*buffer_map_sg) (struct usb_bus *bus, - struct scatterlist *sg, int *n_hw_ents, - int nents, int direction); - void (*buffer_dmasync_sg) (struct usb_bus *bus, - struct scatterlist *sg, - int n_hw_ents, int direction); - void (*buffer_unmap_sg) (struct usb_bus *bus, - struct scatterlist *sg, - int n_hw_ents, int direction); }; /* each driver provides one of these, and hardware init support */ @@ -248,23 +228,6 @@ void *hcd_buffer_alloc (struct usb_bus *bus, size_t size, void hcd_buffer_free (struct usb_bus *bus, size_t size, void *addr, dma_addr_t dma); -int hcd_buffer_map (struct usb_bus *bus, - void *addr, dma_addr_t *dma, - size_t size, int direction); -void hcd_buffer_dmasync (struct usb_bus *bus, - dma_addr_t dma, - size_t size, int direction); -void hcd_buffer_unmap (struct usb_bus *bus, - dma_addr_t dma, - size_t size, int direction); -int hcd_buffer_map_sg (struct usb_bus *bus, struct scatterlist *sg, - int *n_hw_ents, int nents, int direction); -void hcd_buffer_sync_sg (struct usb_bus *bus, struct scatterlist *sg, - int n_hw_ents, int direction); - -void hcd_buffer_unmap_sg (struct usb_bus *bus, struct scatterlist *sg, - int n_hw_ents, int direction); - /* generic bus glue, needed for host controllers that don't use PCI */ extern struct usb_operations usb_hcd_operations; extern void usb_hcd_irq (int irq, void *__hcd, struct pt_regs *r); diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c index 1325fc9b8a09..df15296da8a6 100644 --- a/drivers/usb/core/usb.c +++ b/drivers/usb/core/usb.c @@ -41,6 +41,11 @@ #endif #include +#include +#include +#include +#include + #include "hcd.h" #include "usb.h" @@ -803,7 +808,7 @@ void usb_disconnect(struct usb_device **pdev) *pdev = NULL; - info("USB disconnect on device %d", dev->devnum); + dev_info (dev->dev, "USB disconnect, address %d\n", dev->devnum); /* Free up all the children before we remove this device */ for (i = 0; i < USB_MAXCHILDREN; i++) { @@ -812,7 +817,7 @@ void usb_disconnect(struct usb_device **pdev) usb_disconnect(child); } - dbg ("unregistering interfaces on device %d", dev->devnum); + dev_dbg (dev->dev, "unregistering interfaces\n"); if (dev->actconfig) { for (i = 0; i < dev->actconfig->desc.bNumInterfaces; i++) { struct usb_interface *interface = &dev->actconfig->interface[i]; @@ -822,7 +827,7 @@ void usb_disconnect(struct usb_device **pdev) } } - dbg ("unregistering the device %d", dev->devnum); + dev_dbg (dev->dev, "unregistering device\n"); /* Free the device number and remove the /proc/bus/usb entry */ if (dev->devnum > 0) { clear_bit(dev->devnum, dev->bus->devmap.devicemap); @@ -980,6 +985,9 @@ int usb_new_device(struct usb_device *dev, struct device *parent) sprintf (&dev->dev.bus_id[0], "%d-%s", dev->bus->busnum, dev->devpath); + /* dma masks come from the controller; readonly, except to hcd */ + dev->dev.dma_mask = parent->dma_mask; + /* USB device state == default ... it's not usable yet */ /* USB 2.0 section 5.5.3 talks about ep0 maxpacket ... @@ -1104,6 +1112,7 @@ int usb_new_device(struct usb_device *dev, struct device *parent) interface->dev.parent = &dev->dev; interface->dev.driver = NULL; interface->dev.bus = &usb_bus_type; + interface->dev.dma_mask = parent->dma_mask; sprintf (&interface->dev.bus_id[0], "%d-%s:%d", dev->bus->busnum, dev->devpath, desc->bInterfaceNumber); @@ -1206,24 +1215,21 @@ void usb_buffer_free ( struct urb *usb_buffer_map (struct urb *urb) { struct usb_bus *bus; - struct usb_operations *op; + struct device *controller; if (!urb || usb_pipecontrol (urb->pipe) || !urb->dev || !(bus = urb->dev->bus) - || !(op = bus->op) - || !op->buffer_map) + || !(controller = bus->controller)) return 0; - if (op->buffer_map (bus, - urb->transfer_buffer, - &urb->transfer_dma, - urb->transfer_buffer_length, + urb->transfer_dma = dma_map_single (controller, + urb->transfer_buffer, urb->transfer_buffer_length, usb_pipein (urb->pipe) - ? USB_DIR_IN - : USB_DIR_OUT)) - return 0; + ? DMA_FROM_DEVICE : DMA_TO_DEVICE); + // FIXME generic api broken like pci, can't report errors + // if (urb->transfer_dma == DMA_ADDR_INVALID) return 0; urb->transfer_flags |= URB_NO_DMA_MAP; return urb; } @@ -1235,22 +1241,19 @@ struct urb *usb_buffer_map (struct urb *urb) void usb_buffer_dmasync (struct urb *urb) { struct usb_bus *bus; - struct usb_operations *op; + struct device *controller; if (!urb || !(urb->transfer_flags & URB_NO_DMA_MAP) || !urb->dev || !(bus = urb->dev->bus) - || !(op = bus->op) - || !op->buffer_dmasync) + || !(controller = bus->controller)) return; - op->buffer_dmasync (bus, - urb->transfer_dma, - urb->transfer_buffer_length, + dma_sync_single (controller, + urb->transfer_dma, urb->transfer_buffer_length, usb_pipein (urb->pipe) - ? USB_DIR_IN - : USB_DIR_OUT); + ? DMA_FROM_DEVICE : DMA_TO_DEVICE); } /** @@ -1262,23 +1265,21 @@ void usb_buffer_dmasync (struct urb *urb) void usb_buffer_unmap (struct urb *urb) { struct usb_bus *bus; - struct usb_operations *op; + struct device *controller; if (!urb || !(urb->transfer_flags & URB_NO_DMA_MAP) || !urb->dev || !(bus = urb->dev->bus) - || !(op = bus->op) - || !op->buffer_unmap) + || !(controller = bus->controller)) return; - op->buffer_unmap (bus, - urb->transfer_dma, - urb->transfer_buffer_length, + dma_unmap_single (controller, + urb->transfer_dma, urb->transfer_buffer_length, usb_pipein (urb->pipe) - ? USB_DIR_IN - : USB_DIR_OUT); + ? DMA_FROM_DEVICE : DMA_TO_DEVICE); } + /** * usb_buffer_map_sg - create scatterlist DMA mapping(s) for an endpoint * @dev: device to which the scatterlist will be mapped @@ -1297,6 +1298,7 @@ void usb_buffer_unmap (struct urb *urb) * to complete before starting the next I/O. This is particularly easy * to do with scatterlists. Just allocate and submit one URB for each DMA * mapping entry returned, stopping on the first error or when all succeed. + * Better yet, use the usb_sg_*() calls, which do that (and more) for you. * * This call would normally be used when translating scatterlist requests, * rather than usb_buffer_map(), since on some hardware (with IOMMUs) it @@ -1308,26 +1310,17 @@ int usb_buffer_map_sg (struct usb_device *dev, unsigned pipe, struct scatterlist *sg, int nents) { struct usb_bus *bus; - struct usb_operations *op; - int n_hw_ents; + struct device *controller; if (!dev || usb_pipecontrol (pipe) || !(bus = dev->bus) - || !(op = bus->op) - || !op->buffer_map_sg) - return -1; - - if (op->buffer_map_sg (bus, - sg, - &n_hw_ents, - nents, - usb_pipein (pipe) - ? USB_DIR_IN - : USB_DIR_OUT)) + || !(controller = bus->controller)) return -1; - return n_hw_ents; + // FIXME generic api broken like pci, can't report errors + return dma_map_sg (controller, sg, nents, + usb_pipein (pipe) ? DMA_FROM_DEVICE : DMA_TO_DEVICE); } /** @@ -1344,20 +1337,15 @@ void usb_buffer_dmasync_sg (struct usb_device *dev, unsigned pipe, struct scatterlist *sg, int n_hw_ents) { struct usb_bus *bus; - struct usb_operations *op; + struct device *controller; if (!dev || !(bus = dev->bus) - || !(op = bus->op) - || !op->buffer_dmasync_sg) + || !(controller = bus->controller)) return; - op->buffer_dmasync_sg (bus, - sg, - n_hw_ents, - usb_pipein (pipe) - ? USB_DIR_IN - : USB_DIR_OUT); + dma_sync_sg (controller, sg, n_hw_ents, + usb_pipein (pipe) ? DMA_FROM_DEVICE : DMA_TO_DEVICE); } /** @@ -1373,20 +1361,15 @@ void usb_buffer_unmap_sg (struct usb_device *dev, unsigned pipe, struct scatterlist *sg, int n_hw_ents) { struct usb_bus *bus; - struct usb_operations *op; + struct device *controller; if (!dev || !(bus = dev->bus) - || !(op = bus->op) - || !op->buffer_unmap_sg) + || !(controller = bus->controller)) return; - op->buffer_unmap_sg (bus, - sg, - n_hw_ents, - usb_pipein (pipe) - ? USB_DIR_IN - : USB_DIR_OUT); + dma_unmap_sg (controller, sg, n_hw_ents, + usb_pipein (pipe) ? DMA_FROM_DEVICE : DMA_TO_DEVICE); } diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index 48d9b806fcb2..239e398861df 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c @@ -405,9 +405,10 @@ static int ehci_start (struct usb_hcd *hcd) * streaming mappings for I/O buffers, like pci_map_single(), * can return segments above 4GB, if the device allows. * - * NOTE: layered drivers can't yet tell when we enable that, - * so they can't pass this info along (like NETIF_F_HIGHDMA) - * (or like Scsi_Host.highmem_io) ... usb_bus.flags? + * NOTE: the dma mask is visible through dma_supported(), so + * drivers can pass this info along ... like NETIF_F_HIGHDMA, + * Scsi_Host.highmem_io, and so forth. It's readonly to all + * host side drivers though. */ if (HCC_64BIT_ADDR (hcc_params)) { writel (0, &ehci->regs->segment); diff --git a/drivers/usb/host/ohci-sa1111.c b/drivers/usb/host/ohci-sa1111.c index d03fce1c7da5..11d4fed34233 100644 --- a/drivers/usb/host/ohci-sa1111.c +++ b/drivers/usb/host/ohci-sa1111.c @@ -176,7 +176,8 @@ int usb_hcd_sa1111_probe (const struct hc_driver *driver, hcd->irq = dev->irq[1]; hcd->regs = dev->mapbase; hcd->pdev = SA1111_FAKE_PCIDEV; - hcd->controller = &dev->dev; + hcd->self.controller = &dev->dev; + hcd->controller = hcd->self.controller; retval = hcd_buffer_create (hcd); if (retval != 0) { diff --git a/drivers/usb/net/usbnet.c b/drivers/usb/net/usbnet.c index 17eb48408556..bf8ca2f5daf3 100644 --- a/drivers/usb/net/usbnet.c +++ b/drivers/usb/net/usbnet.c @@ -146,6 +146,11 @@ #endif #include +#include +#include +#include +#include + /* minidrivers _could_ be individually configured */ #define CONFIG_USB_AN2720 @@ -2169,9 +2174,13 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod) memcpy (net->dev_addr, node_id, sizeof node_id); // point-to-point link ... we always use Ethernet headers - // supports win32 interop and the bridge driver. + // supports win32 interop (some devices) and the bridge driver. ether_setup (net); + // possible with some EHCI controllers + if (dma_supported (&udev->dev, 0xffffffffffffffffULL)) + net->features |= NETIF_F_HIGHDMA; + net->change_mtu = usbnet_change_mtu; net->get_stats = usbnet_get_stats; net->hard_start_xmit = usbnet_start_xmit; diff --git a/include/linux/usb.h b/include/linux/usb.h index 88557d5957a7..b1d92b8c585f 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h @@ -28,14 +28,6 @@ static __inline__ void wait_ms(unsigned int ms) mdelay(ms); } -/* - * USB device number allocation bitmap. There's one bitmap - * per USB tree. - */ -struct usb_devmap { - unsigned long devicemap[128 / (8*sizeof(unsigned long))]; -}; - struct usb_device; /*-------------------------------------------------------------------------*/ @@ -159,10 +151,16 @@ int __usb_get_extra_descriptor(char *buffer, unsigned size, struct usb_operations; +/* USB device number allocation bitmap */ +struct usb_devmap { + unsigned long devicemap[128 / (8*sizeof(unsigned long))]; +}; + /* - * Allocated per bus we have + * Allocated per bus (tree of devices) we have: */ struct usb_bus { + struct device *controller; /* host/master side hardware */ int busnum; /* Bus number (in order of reg) */ char *bus_name; /* stable id (PCI slot_name etc) */ -- cgit v1.2.3 From 9e314023895e31d1decb8e55505bcb852eb7507b Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Thu, 26 Dec 2002 19:33:42 -0800 Subject: [PATCH] USB: remove private_data pointer from struct usb_interface, as it shouldn't be used anymore Also added usb_get_intfdata() and usb_set_intfdata() functions to set the struct usb_interface private pointer easier. --- drivers/usb/core/usb.c | 4 ++-- drivers/usb/misc/usbtest.c | 1 - include/linux/usb.h | 11 ++++++++++- 3 files changed, 12 insertions(+), 4 deletions(-) (limited to 'include/linux') diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c index df15296da8a6..134a79120215 100644 --- a/drivers/usb/core/usb.c +++ b/drivers/usb/core/usb.c @@ -298,7 +298,7 @@ void usb_driver_claim_interface(struct usb_driver *driver, struct usb_interface dbg("%s driver claimed interface %p", driver->name, iface); iface->driver = driver; - iface->private_data = priv; + usb_set_intfdata(iface, priv); } /** @@ -341,7 +341,7 @@ void usb_driver_release_interface(struct usb_driver *driver, struct usb_interfac return; iface->driver = NULL; - iface->private_data = NULL; + usb_set_intfdata(iface, NULL); } /** diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c index 7d6ee5ba3e86..222f066e63f9 100644 --- a/drivers/usb/misc/usbtest.c +++ b/drivers/usb/misc/usbtest.c @@ -978,7 +978,6 @@ static void usbtest_disconnect (struct usb_interface *intf) dev_set_drvdata (&intf->dev, 0); info ("unbound %s", dev->id); - kfree (intf->private_data); } /* Basic testing only needs a device that can source or sink bulk traffic. diff --git a/include/linux/usb.h b/include/linux/usb.h index b1d92b8c585f..e0d1269dc779 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h @@ -111,12 +111,21 @@ struct usb_interface { struct usb_driver *driver; /* driver */ kdev_t kdev; /* node this interface is bound to */ struct device dev; /* interface specific device info */ - void *private_data; }; #define to_usb_interface(d) container_of(d, struct usb_interface, dev) #define interface_to_usbdev(intf) \ container_of(intf->dev.parent, struct usb_device, dev) +static inline void *usb_get_intfdata (struct usb_interface *intf) +{ + return dev_get_drvdata (&intf->dev); +} + +static inline void usb_set_intfdata (struct usb_interface *intf, void *data) +{ + return dev_set_drvdata (&intf->dev, data); +} + /* USB_DT_CONFIG: Configuration descriptor information. * * USB_DT_OTHER_SPEED_CONFIG is the same descriptor, except that the -- cgit v1.2.3 From acdc277a1ab96e584127f465c9323d0ae8a3f47a Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Thu, 26 Dec 2002 23:04:08 -0800 Subject: [FB] fb_blank is an fbops hook, not a standalone function. --- drivers/video/console/fbcon.c | 2 +- include/linux/fb.h | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) (limited to 'include/linux') diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c index 6b3bc39bc559..6933d2d3d39c 100644 --- a/drivers/video/console/fbcon.c +++ b/drivers/video/console/fbcon.c @@ -1993,7 +1993,7 @@ static int fbcon_blank(struct vc_data *vc, int blank) update_screen(vc->vc_num); return 0; } else - return fb_blank(blank, info); + return info->fbops->fb_blank(blank, info); } static void fbcon_free_font(struct display *p) diff --git a/include/linux/fb.h b/include/linux/fb.h index 188da2f94589..1edbaf1b14be 100644 --- a/include/linux/fb.h +++ b/include/linux/fb.h @@ -449,7 +449,6 @@ struct fb_info { extern int fb_set_var(struct fb_var_screeninfo *var, struct fb_info *info); extern int fb_pan_display(struct fb_var_screeninfo *var, struct fb_info *info); -extern int fb_blank(int blank, struct fb_info *info); extern int soft_cursor(struct fb_info *info, struct fb_cursor *cursor); extern void cfb_fillrect(struct fb_info *info, struct fb_fillrect *rect); extern void cfb_copyarea(struct fb_info *info, struct fb_copyarea *area); -- cgit v1.2.3 From 6c56ca7bd3310403f595c5329e3b468acc0639fd Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Fri, 27 Dec 2002 00:15:49 -0800 Subject: Cset exclude: rth@are.twiddle.net|ChangeSet|20021227230408|33498 --- drivers/video/console/fbcon.c | 2 +- include/linux/fb.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'include/linux') diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c index 6933d2d3d39c..6b3bc39bc559 100644 --- a/drivers/video/console/fbcon.c +++ b/drivers/video/console/fbcon.c @@ -1993,7 +1993,7 @@ static int fbcon_blank(struct vc_data *vc, int blank) update_screen(vc->vc_num); return 0; } else - return info->fbops->fb_blank(blank, info); + return fb_blank(blank, info); } static void fbcon_free_font(struct display *p) diff --git a/include/linux/fb.h b/include/linux/fb.h index 1edbaf1b14be..188da2f94589 100644 --- a/include/linux/fb.h +++ b/include/linux/fb.h @@ -449,6 +449,7 @@ struct fb_info { extern int fb_set_var(struct fb_var_screeninfo *var, struct fb_info *info); extern int fb_pan_display(struct fb_var_screeninfo *var, struct fb_info *info); +extern int fb_blank(int blank, struct fb_info *info); extern int soft_cursor(struct fb_info *info, struct fb_cursor *cursor); extern void cfb_fillrect(struct fb_info *info, struct fb_fillrect *rect); extern void cfb_copyarea(struct fb_info *info, struct fb_copyarea *area); -- cgit v1.2.3 From d92e1bbd4a82f39cfaf7b0dd7d9d5e4f5d2907ee Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 27 Dec 2002 03:29:40 -0800 Subject: [PATCH] USB: rename usb_free_dev() to usb_put_dev() This was done to make the next reference count patch easier, and because almost everyone was already calling usb_put_dev() anyway... --- drivers/usb/core/hub.c | 4 ++-- drivers/usb/core/usb.c | 7 +++---- drivers/usb/host/ehci-hcd.c | 2 +- drivers/usb/host/hc_sl811_rh.c | 2 +- drivers/usb/host/ohci-hcd.c | 2 +- drivers/usb/host/uhci-hcd.c | 2 +- include/linux/usb.h | 3 +-- 7 files changed, 10 insertions(+), 12 deletions(-) (limited to 'include/linux') diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index e48f6d646bf8..d013ec009f87 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -876,7 +876,7 @@ static void usb_hub_port_connect_change(struct usb_hub *hubstate, int port, /* Reset the device, and detect its speed */ if (usb_hub_port_reset(hub, port, dev, delay)) { - usb_free_dev(dev); + usb_put_dev(dev); break; } @@ -928,7 +928,7 @@ static void usb_hub_port_connect_change(struct usb_hub *hubstate, int port, goto done; /* Free the configuration if there was an error */ - usb_free_dev(dev); + usb_put_dev(dev); /* Switch to a long reset time */ delay = HUB_LONG_RESET_TIME; diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c index 134a79120215..815a2e2ee8ad 100644 --- a/drivers/usb/core/usb.c +++ b/drivers/usb/core/usb.c @@ -716,7 +716,7 @@ struct usb_device *usb_get_dev (struct usb_device *dev) } /** - * usb_free_dev - free a usb device structure when all users of it are finished. + * usb_put_dev - free a usb device structure when all users of it are finished. * @dev: device that's been disconnected * Context: !in_interrupt () * @@ -727,7 +727,7 @@ struct usb_device *usb_get_dev (struct usb_device *dev) * gone, everything is cleaned up, so it's time to get rid of these last * records of this device. */ -void usb_free_dev(struct usb_device *dev) +void usb_put_dev(struct usb_device *dev) { if (atomic_dec_and_test(&dev->refcnt)) { if (dev->bus->op->deallocate) @@ -738,7 +738,6 @@ void usb_free_dev(struct usb_device *dev) } } - /** * usb_get_current_frame_number - return current bus frame number * @dev: the device whose bus is being queried @@ -1454,7 +1453,7 @@ EXPORT_SYMBOL(usb_device_probe); EXPORT_SYMBOL(usb_device_remove); EXPORT_SYMBOL(usb_alloc_dev); -EXPORT_SYMBOL(usb_free_dev); +EXPORT_SYMBOL(usb_put_dev); EXPORT_SYMBOL(usb_get_dev); EXPORT_SYMBOL(usb_hub_tt_clear_buffer); diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index 239e398861df..3da8c9b228ef 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c @@ -476,7 +476,7 @@ done2: ehci_ready (ehci); ehci_reset (ehci); bus->root_hub = 0; - usb_free_dev (udev); + usb_put_dev (udev); retval = -ENODEV; goto done2; } diff --git a/drivers/usb/host/hc_sl811_rh.c b/drivers/usb/host/hc_sl811_rh.c index 786bb4dec196..203a909fdcd5 100644 --- a/drivers/usb/host/hc_sl811_rh.c +++ b/drivers/usb/host/hc_sl811_rh.c @@ -566,7 +566,7 @@ static int rh_connect_rh (hci_t * hci) hci->bus->root_hub = usb_dev; usb_connect (usb_dev); if (usb_new_device (usb_dev) != 0) { - usb_free_dev (usb_dev); + usb_put_dev (usb_dev); return -ENODEV; } diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c index af15bea5fa45..17a794b3ce54 100644 --- a/drivers/usb/host/ohci-hcd.c +++ b/drivers/usb/host/ohci-hcd.c @@ -515,7 +515,7 @@ static int hc_start (struct ohci_hcd *ohci) usb_connect (udev); udev->speed = USB_SPEED_FULL; if (usb_register_root_hub (udev, ohci->hcd.controller) != 0) { - usb_free_dev (udev); + usb_put_dev (udev); ohci->hcd.self.root_hub = NULL; disable (ohci); ohci->hc_control &= ~OHCI_CTRL_HCFS; diff --git a/drivers/usb/host/uhci-hcd.c b/drivers/usb/host/uhci-hcd.c index f258f2b92ccb..3b5768ee1812 100644 --- a/drivers/usb/host/uhci-hcd.c +++ b/drivers/usb/host/uhci-hcd.c @@ -2280,7 +2280,7 @@ err_alloc_skelqh: uhci->term_td = NULL; err_alloc_term_td: - usb_free_dev(udev); + usb_put_dev(udev); hcd->self.root_hub = NULL; err_alloc_root_hub: diff --git a/include/linux/usb.h b/include/linux/usb.h index e0d1269dc779..c3c2c69ff244 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h @@ -261,8 +261,7 @@ struct usb_device { extern struct usb_device *usb_alloc_dev(struct usb_device *parent, struct usb_bus *); extern struct usb_device *usb_get_dev(struct usb_device *dev); -extern void usb_free_dev(struct usb_device *); -#define usb_put_dev usb_free_dev +extern void usb_put_dev(struct usb_device *dev); /* mostly for devices emulating SCSI over USB */ extern int usb_reset_device(struct usb_device *dev); -- cgit v1.2.3 From b14d209d075901fe9faacbf973c2379025345edd Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 27 Dec 2002 07:29:19 -0800 Subject: [PATCH] USB: use the driver model to handle reference counting of struct usb_device --- drivers/usb/core/config.c | 1 + drivers/usb/core/usb.c | 78 ++++++++++++++++++++++++++++++----------------- include/linux/usb.h | 1 - 3 files changed, 51 insertions(+), 29 deletions(-) (limited to 'include/linux') diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c index 3a3dfdc54e97..69a4e2f83045 100644 --- a/drivers/usb/core/config.c +++ b/drivers/usb/core/config.c @@ -108,6 +108,7 @@ static int usb_parse_interface(struct usb_interface *interface, unsigned char *b interface->act_altsetting = 0; interface->num_altsetting = 0; interface->max_altsetting = USB_ALTSETTINGALLOC; + device_initialize(&interface->dev); interface->altsetting = kmalloc(sizeof(*interface->altsetting) * interface->max_altsetting, GFP_KERNEL); diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c index 815a2e2ee8ad..6a3c6fe12cb8 100644 --- a/drivers/usb/core/usb.c +++ b/drivers/usb/core/usb.c @@ -23,6 +23,13 @@ */ #include + +#ifdef CONFIG_USB_DEBUG + #define DEBUG +#else + #undef DEBUG +#endif + #include #include #include @@ -33,12 +40,6 @@ #include #include #include - -#ifdef CONFIG_USB_DEBUG - #define DEBUG -#else - #undef DEBUG -#endif #include #include @@ -677,13 +678,14 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent, struct usb_bus *bus) memset(dev, 0, sizeof(*dev)); + device_initialize(&dev->dev); + usb_bus_get(bus); if (!parent) dev->devpath [0] = '0'; dev->bus = bus; dev->parent = parent; - atomic_set(&dev->refcnt, 1); INIT_LIST_HEAD(&dev->filelist); init_MUTEX(&dev->serialize); @@ -695,7 +697,7 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent, struct usb_bus *bus) } /** - * usb_get_dev - increments the reference count of the device + * usb_get_dev - increments the reference count of the usb device structure * @dev: the device being referenced * * Each live reference to a device should be refcounted. @@ -708,36 +710,54 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent, struct usb_bus *bus) */ struct usb_device *usb_get_dev (struct usb_device *dev) { - if (dev) { - atomic_inc (&dev->refcnt); - return dev; - } - return NULL; + struct device *tmp; + + if (!dev) + return NULL; + + tmp = get_device(&dev->dev); + if (tmp) + return to_usb_device(tmp); + else + return NULL; } /** - * usb_put_dev - free a usb device structure when all users of it are finished. + * usb_put_dev - release a use of the usb device structure * @dev: device that's been disconnected - * Context: !in_interrupt () * * Must be called when a user of a device is finished with it. When the last * user of the device calls this function, the memory of the device is freed. - * - * Used by hub and virtual root hub drivers. The device is completely - * gone, everything is cleaned up, so it's time to get rid of these last - * records of this device. */ void usb_put_dev(struct usb_device *dev) { - if (atomic_dec_and_test(&dev->refcnt)) { - if (dev->bus->op->deallocate) - dev->bus->op->deallocate(dev); - usb_destroy_configuration (dev); - usb_bus_put (dev->bus); - kfree (dev); - } + if (dev) + put_device(&dev->dev); +} + +/** + * usb_release_dev - free a usb device structure when all users of it are finished. + * @dev: device that's been disconnected + * + * Will be called only by the device core when all users of this usb device are + * done. + */ +static void usb_release_dev(struct device *dev) +{ + struct usb_device *udev; + + udev = to_usb_device(dev); + if (!udev) + return; + + if (udev->bus && udev->bus->op && udev->bus->op->deallocate) + udev->bus->op->deallocate(udev); + usb_destroy_configuration (udev); + usb_bus_put (udev->bus); + kfree (udev); } + /** * usb_get_current_frame_number - return current bus frame number * @dev: the device whose bus is being queried @@ -980,6 +1000,8 @@ int usb_new_device(struct usb_device *dev, struct device *parent) dev->dev.parent = parent; dev->dev.driver = &usb_generic_driver; dev->dev.bus = &usb_bus_type; + dev->dev.release = usb_release_dev; + usb_get_dev(dev); if (dev->dev.bus_id[0] == 0) sprintf (&dev->dev.bus_id[0], "%d-%s", dev->bus->busnum, dev->devpath); @@ -1096,7 +1118,7 @@ int usb_new_device(struct usb_device *dev, struct device *parent) #endif /* put into sysfs, with device and config specific files */ - err = device_register (&dev->dev); + err = device_add (&dev->dev); if (err) return err; usb_create_driverfs_dev_files (dev); @@ -1130,7 +1152,7 @@ int usb_new_device(struct usb_device *dev, struct device *parent) desc->bInterfaceNumber); } dbg ("%s - registering %s", __FUNCTION__, interface->dev.bus_id); - device_register (&interface->dev); + device_add (&interface->dev); usb_create_driverfs_intf_files (interface); } diff --git a/include/linux/usb.h b/include/linux/usb.h index c3c2c69ff244..bcbfa72423c3 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h @@ -217,7 +217,6 @@ struct usb_device { struct usb_tt *tt; /* low/full speed dev, highspeed hub */ int ttport; /* device port on that tt hub */ - atomic_t refcnt; /* Reference count */ struct semaphore serialize; unsigned int toggle[2]; /* one bit for each endpoint ([0] = IN, [1] = OUT) */ -- cgit v1.2.3 From 85cabc0ce214a39ce7b5d68e50604333e8562c12 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Fri, 27 Dec 2002 19:09:40 -0800 Subject: Get rid of atari-specific "ide_intr_lock" from generic IDE code --- drivers/ide/ide-io.c | 4 ++-- drivers/ide/ide.c | 12 ++---------- include/asm-m68k/ide.h | 14 ++++++++------ include/linux/ide.h | 4 ++-- 4 files changed, 14 insertions(+), 20 deletions(-) (limited to 'include/linux') diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c index 89e956d8b011..64ee462aaa97 100644 --- a/drivers/ide/ide-io.c +++ b/drivers/ide/ide-io.c @@ -743,7 +743,7 @@ void ide_do_request (ide_hwgroup_t *hwgroup, int masked_irq) ide_startstop_t startstop; /* for atari only: POSSIBLY BROKEN HERE(?) */ - ide_get_lock(&ide_intr_lock, ide_intr, hwgroup); + ide_get_lock(ide_intr, hwgroup); /* necessary paranoia: ensure IRQs are masked on local CPU */ local_irq_disable(); @@ -783,7 +783,7 @@ void ide_do_request (ide_hwgroup_t *hwgroup, int masked_irq) */ /* for atari only */ - ide_release_lock(&ide_intr_lock); + ide_release_lock(); hwgroup->busy = 0; } diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c index 9b4130b92ae6..3c07fbefa9bf 100644 --- a/drivers/ide/ide.c +++ b/drivers/ide/ide.c @@ -181,14 +181,6 @@ spinlock_t ide_lock __cacheline_aligned_in_smp = SPIN_LOCK_UNLOCKED; static int ide_scan_direction; /* THIS was formerly 2.2.x pci=reverse */ -#ifdef IDE_ARCH_LOCK -/* - * ide_lock is used by the Atari code to obtain access to the IDE interrupt, - * which is shared between several drivers. - */ -static int ide_intr_lock; -#endif /* IDE_ARCH_LOCK */ - #ifdef CONFIG_IDEDMA_AUTO int noautodma = 0; #else @@ -2097,12 +2089,12 @@ void __init ide_init_builtin_drivers (void) #ifdef CONFIG_BLK_DEV_IDE if (ide_hwifs[0].io_ports[IDE_DATA_OFFSET]) - ide_get_lock(&ide_intr_lock, NULL, NULL); /* for atari only */ + ide_get_lock(NULL, NULL); /* for atari only */ (void) ideprobe_init(); if (ide_hwifs[0].io_ports[IDE_DATA_OFFSET]) - ide_release_lock(&ide_intr_lock); /* for atari only */ + ide_release_lock(); /* for atari only */ #endif /* CONFIG_BLK_DEV_IDE */ #ifdef CONFIG_PROC_FS diff --git a/include/asm-m68k/ide.h b/include/asm-m68k/ide.h index 1471687982a9..6b451e47441c 100644 --- a/include/asm-m68k/ide.h +++ b/include/asm-m68k/ide.h @@ -147,26 +147,28 @@ static __inline__ void ide_init_default_hwifs(void) #ifdef CONFIG_ATARI #define ATA_ARCH_LOCK -static __inline__ void ide_release_lock (int *ide_lock) +extern int ide_intr_lock; + +static __inline__ void ide_release_lock (void) { if (MACH_IS_ATARI) { - if (*ide_lock == 0) { + if (ide_intr_lock == 0) { printk("ide_release_lock: bug\n"); return; } - *ide_lock = 0; + ide_intr_lock = 0; stdma_release(); } } -static __inline__ void ide_get_lock (int *ide_lock, void (*handler)(int, void *, struct pt_regs *), void *data) +static __inline__ void ide_get_lock(void (*handler)(int, void *, struct pt_regs *), void *data) { if (MACH_IS_ATARI) { - if (*ide_lock == 0) { + if (ide_intr_lock == 0) { if (in_interrupt() > 0) panic( "Falcon IDE hasn't ST-DMA lock in interrupt" ); stdma_lock(handler, data); - *ide_lock = 1; + ide_intr_lock = 1; } } } diff --git a/include/linux/ide.h b/include/linux/ide.h index 033e94a6d6e4..2e2718ebfd98 100644 --- a/include/linux/ide.h +++ b/include/linux/ide.h @@ -360,8 +360,8 @@ extern int ide_irq_lock; /* Currently only Atari needs it */ #ifndef IDE_ARCH_LOCK -# define ide_release_lock(lock) do {} while (0) -# define ide_get_lock(lock, hdlr, data) do {} while (0) +# define ide_release_lock() do {} while (0) +# define ide_get_lock(hdlr, data) do {} while (0) #endif /* IDE_ARCH_LOCK */ /* -- cgit v1.2.3 From 33dfd4fe2bf28981189797be51961fe315d6651b Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Fri, 27 Dec 2002 19:15:20 -0800 Subject: [PATCH] Mac/m68k Nubus updates Mac/m68k Nubus updates (from Ray Knight in 2.4.x) - Add missing Nubus devices. --- include/linux/nubus.h | 51 ++++++++++++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 21 deletions(-) (limited to 'include/linux') diff --git a/include/linux/nubus.h b/include/linux/nubus.h index a3fd37b33fdd..870e66a96286 100644 --- a/include/linux/nubus.h +++ b/include/linux/nubus.h @@ -28,18 +28,18 @@ enum nubus_category { }; enum nubus_type_network { - NUBUS_TYPE_ETHERNET = 0x0001, - NUBUS_TYPE_RS232 = 0x0002 + NUBUS_TYPE_ETHERNET = 0x0001, + NUBUS_TYPE_RS232 = 0x0002 }; enum nubus_type_display { - NUBUS_TYPE_VIDEO = 0x0001 + NUBUS_TYPE_VIDEO = 0x0001 }; enum nubus_type_cpu { - NUBUS_TYPE_68020 = 0x0003, - NUBUS_TYPE_68030 = 0x0004, - NUBUS_TYPE_68040 = 0x0005 + NUBUS_TYPE_68020 = 0x0003, + NUBUS_TYPE_68030 = 0x0004, + NUBUS_TYPE_68040 = 0x0005 }; /* Known tuples: (according to TattleTech and Slots) @@ -80,22 +80,24 @@ enum nubus_type_cpu { /* Add known DrSW values here */ enum nubus_drsw { /* NUBUS_CAT_DISPLAY */ - NUBUS_DRSW_APPLE = 0x0001, - NUBUS_DRSW_APPLE_HIRES = 0x0013, /* MacII HiRes card driver */ + NUBUS_DRSW_APPLE = 0x0001, + NUBUS_DRSW_APPLE_HIRES = 0x0013, /* MacII HiRes card driver */ /* NUBUS_CAT_NETWORK */ - NUBUS_DRSW_CABLETRON = 0x0001, - NUBUS_DRSW_SONIC_LC = 0x0001, - NUBUS_DRSW_KINETICS = 0x0103, - NUBUS_DRSW_ASANTE = 0x0104, - NUBUS_DRSW_DAYNA = 0x010b, - NUBUS_DRSW_FARALLON = 0x010c, - NUBUS_DRSW_APPLE_SN = 0x010f, - NUBUS_DRSW_FOCUS = 0x011a, - NUBUS_DRSW_ASANTE_CS = 0x011d, /* use asante SMC9194 driver */ + NUBUS_DRSW_CABLETRON = 0x0001, + NUBUS_DRSW_SONIC_LC = 0x0001, + NUBUS_DRSW_KINETICS = 0x0103, + NUBUS_DRSW_ASANTE = 0x0104, + NUBUS_DRSW_DAYNA = 0x010b, + NUBUS_DRSW_FARALLON = 0x010c, + NUBUS_DRSW_APPLE_SN = 0x010f, + NUBUS_DRSW_DAYNA2 = 0x0115, + NUBUS_DRSW_FOCUS = 0x011a, + NUBUS_DRSW_ASANTE_CS = 0x011d, /* use asante SMC9194 driver */ + NUBUS_DRSW_DAYNA_LC = 0x011e, /* NUBUS_CAT_CPU */ - NUBUS_DRSW_NONE = 0x0000, + NUBUS_DRSW_NONE = 0x0000, }; /* DrHW: Uniquely identifies the hardware interface to a board (or at @@ -106,11 +108,13 @@ enum nubus_drsw { enum nubus_drhw { /* NUBUS_CAT_DISPLAY */ NUBUS_DRHW_APPLE_TFB = 0x0001, /* Toby frame buffer card */ + NUBUS_DRHW_APPLE_HRVC = 0x0013, /* Mac II High Res Video card */ NUBUS_DRHW_APPLE_RBV1 = 0x0018, /* IIci RBV video */ NUBUS_DRHW_APPLE_MDC = 0x0019, /* Macintosh Display Card */ NUBUS_DRHW_APPLE_SONORA = 0x0022, /* Sonora built-in video */ + NUBUS_DRHW_APPLE_JET = 0x0029, /* Jet framebuffer (DuoDock) */ NUBUS_DRHW_APPLE_VALKYRIE = 0x002e, - NUBUS_DRHW_APPLE_JET = 0x0029, /* Jet framebuffer (DuoDock) */ + NUBUS_DRHW_THUNDER24 = 0x02cb, /* SuperMac Thunder/24 */ /* NUBUS_CAT_NETWORK */ NUBUS_DRHW_INTERLAN = 0x0100, @@ -119,6 +123,11 @@ enum nubus_drhw { NUBUS_DRHW_CABLETRON = 0x0109, NUBUS_DRHW_ASANTE_LC = 0x010f, NUBUS_DRHW_SONIC = 0x0110, + NUBUS_DRHW_SONIC_NB = 0x0118, + NUBUS_DRHW_SONIC_LC = 0x0119, + + /* NUBUS_CAT_COMMUNICATIONS */ + NUBUS_DRHW_DOVEFAX = 0x0100, }; /* Resource IDs: These are the identifiers for the various weird and @@ -153,8 +162,8 @@ enum nubus_board_res_id { NUBUS_RESID_SECONDINIT = 0x0026, /* Not sure why Apple put these next two in here */ - NUBUS_RESID_VIDNAMES = 0x0041, - NUBUS_RESID_VIDMODES = 0x007e + NUBUS_RESID_VIDNAMES = 0x0041, + NUBUS_RESID_VIDMODES = 0x007e }; /* Fields within the vendor info directory */ -- cgit v1.2.3 From 8ad65876172145c1d26caa837bf5ebe4fe4db7fb Mon Sep 17 00:00:00 2001 From: Robert Love Date: Sat, 28 Dec 2002 04:09:48 -0800 Subject: [PATCH] deprecated function attribute This patch adds support for usage of the attribute as "deprecated" and is backward-compatible. Usage is: int deprecated foo(void) etc.. If we mark a function as deprecated, then each use of the function emits a warning like: foo.c:12: warning: `baz' is deprecated (declared at bar.c:60) Which is very informative, giving both the location of each usage and where the little bastard is declared. --- include/linux/compiler.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'include/linux') diff --git a/include/linux/compiler.h b/include/linux/compiler.h index 6b19413b47a6..51cfdb71594b 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h @@ -13,6 +13,19 @@ #define likely(x) __builtin_expect((x),1) #define unlikely(x) __builtin_expect((x),0) +/* + * Allow us to mark functions as 'deprecated' and have gcc emit a nice + * warning for each use, in hopes of speeding the functions removal. + * Usage is: + * int deprecated foo(void) + * and then gcc will emit a warning for each usage of the function. + */ +#if __GNUC__ >= 3 +#define deprecated __attribute__((deprecated)) +#else +#define deprecated +#endif + /* This macro obfuscates arithmetic on a variable address so that gcc shouldn't recognize the original var, and make assumptions about it */ #define RELOC_HIDE(ptr, off) \ -- cgit v1.2.3 From ed8ea4d42880cb197dbe21041f1182a82f775e07 Mon Sep 17 00:00:00 2001 From: William Stinson Date: Sat, 28 Dec 2002 04:15:23 -0800 Subject: [PATCH] mark check_region "deprecated" This marks check_region "deprecated". This gives a nice warning messages for programs that still use check_region for example: drivers/parport/parport_pc.c:2215: warning: `__check_region' is deprecated (declared at include/linux/ioport.h:111) --- include/linux/ioport.h | 3 ++- kernel/resource.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'include/linux') diff --git a/include/linux/ioport.h b/include/linux/ioport.h index 020bd1596ab9..7c48dfa36962 100644 --- a/include/linux/ioport.h +++ b/include/linux/ioport.h @@ -8,6 +8,7 @@ #ifndef _LINUX_IOPORT_H #define _LINUX_IOPORT_H +#include /* * Resources are tree-like, allowing * nesting etc.. @@ -107,7 +108,7 @@ extern struct resource * __request_region(struct resource *, unsigned long start #define check_mem_region(start,n) __check_region(&iomem_resource, (start), (n)) #define release_mem_region(start,n) __release_region(&iomem_resource, (start), (n)) -extern int __check_region(struct resource *, unsigned long, unsigned long); +extern int deprecated __check_region(struct resource *, unsigned long, unsigned long); extern void __release_region(struct resource *, unsigned long, unsigned long); #define get_ioport_list(buf) get_resource_list(&ioport_resource, buf, PAGE_SIZE) diff --git a/kernel/resource.c b/kernel/resource.c index 9664ad073db7..7e23211ac0a9 100644 --- a/kernel/resource.c +++ b/kernel/resource.c @@ -237,7 +237,7 @@ struct resource * __request_region(struct resource *parent, unsigned long start, return res; } -int __check_region(struct resource *parent, unsigned long start, unsigned long n) +int deprecated __check_region(struct resource *parent, unsigned long start, unsigned long n) { struct resource * res; -- cgit v1.2.3 From a869e179069a3ef64870eec58ee2aaf1a59a6070 Mon Sep 17 00:00:00 2001 From: Hirofumi Ogawa Date: Sat, 28 Dec 2002 23:54:15 -0800 Subject: [PATCH] Simplify ramfs_getattr() and move it to the generic libfs.c This moves ramfs_getattr() to fs/libfs.c as simple_getattr() --- fs/libfs.c | 9 +++++++++ fs/ramfs/inode.c | 24 +----------------------- include/linux/fs.h | 1 + kernel/ksyms.c | 1 + 4 files changed, 12 insertions(+), 23 deletions(-) (limited to 'include/linux') diff --git a/fs/libfs.c b/fs/libfs.c index 813bc9046bcd..e3d30987c919 100644 --- a/fs/libfs.c +++ b/fs/libfs.c @@ -6,6 +6,15 @@ #include #include +int simple_getattr(struct vfsmount *mnt, struct dentry *dentry, + struct kstat *stat) +{ + struct inode *inode = dentry->d_inode; + generic_fillattr(inode, stat); + stat->blocks = inode->i_mapping->nrpages << (PAGE_CACHE_SHIFT - 9); + return 0; +} + int simple_statfs(struct super_block *sb, struct statfs *buf) { buf->f_type = sb->s_magic; diff --git a/fs/ramfs/inode.c b/fs/ramfs/inode.c index 09709443911f..15418ab4f490 100644 --- a/fs/ramfs/inode.c +++ b/fs/ramfs/inode.c @@ -116,28 +116,6 @@ static int ramfs_create(struct inode *dir, struct dentry *dentry, int mode) return ramfs_mknod(dir, dentry, mode | S_IFREG, 0); } -static int ramfs_getattr(struct vfsmount *mnt, struct dentry *dentry, - struct kstat *stat) -{ - struct inode *inode = dentry->d_inode; - - stat->dev = inode->i_sb->s_dev; - stat->ino = inode->i_ino; - stat->mode = inode->i_mode; - stat->nlink = inode->i_nlink; - stat->uid = inode->i_uid; - stat->gid = inode->i_gid; - stat->rdev = kdev_t_to_nr(inode->i_rdev); - stat->atime = inode->i_atime; - stat->mtime = inode->i_mtime; - stat->ctime = inode->i_ctime; - stat->size = inode->i_size; - stat->blocks = inode->i_mapping->nrpages << (PAGE_CACHE_SHIFT - 9); - stat->blksize = inode->i_blksize; - - return 0; -} - static int ramfs_symlink(struct inode * dir, struct dentry *dentry, const char * symname) { struct inode *inode; @@ -171,7 +149,7 @@ static struct file_operations ramfs_file_operations = { }; static struct inode_operations ramfs_file_inode_operations = { - .getattr = ramfs_getattr, + .getattr = simple_getattr, }; static struct inode_operations ramfs_dir_inode_operations = { diff --git a/include/linux/fs.h b/include/linux/fs.h index 500cb3ac421e..5c00caf3edf1 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1300,6 +1300,7 @@ extern int dcache_dir_open(struct inode *, struct file *); extern int dcache_dir_close(struct inode *, struct file *); extern loff_t dcache_dir_lseek(struct file *, loff_t, int); extern int dcache_readdir(struct file *, void *, filldir_t); +extern int simple_getattr(struct vfsmount *, struct dentry *, struct kstat *); extern int simple_statfs(struct super_block *, struct statfs *); extern int simple_link(struct dentry *, struct inode *, struct dentry *); extern int simple_unlink(struct inode *, struct dentry *); diff --git a/kernel/ksyms.c b/kernel/ksyms.c index f634f12d4bef..cd49778dd1f3 100644 --- a/kernel/ksyms.c +++ b/kernel/ksyms.c @@ -299,6 +299,7 @@ EXPORT_SYMBOL(dcache_dir_open); EXPORT_SYMBOL(dcache_dir_close); EXPORT_SYMBOL(dcache_dir_lseek); EXPORT_SYMBOL(dcache_readdir); +EXPORT_SYMBOL(simple_getattr); EXPORT_SYMBOL(simple_statfs); EXPORT_SYMBOL(simple_lookup); EXPORT_SYMBOL(simple_dir_operations); -- cgit v1.2.3 From 6b57bcef60f1413afd6c69bb5d1bc64415005da5 Mon Sep 17 00:00:00 2001 From: Randy Dunlap Date: Sun, 29 Dec 2002 00:01:53 -0800 Subject: [PATCH] fix "deprecated" typos This corrects the misspellings of "deprecated" in a few places. --- drivers/video/aty128fb.c | 2 +- include/asm-arm/arch-arc/io.h | 2 +- include/asm-arm/arch-cl7500/io.h | 2 +- include/asm-arm/arch-rpc/io.h | 2 +- include/asm-arm/memory.h | 4 ++-- include/asm-arm/setup.h | 2 +- include/linux/ax25.h | 2 +- net/ax25/af_ax25.c | 2 +- 8 files changed, 9 insertions(+), 9 deletions(-) (limited to 'include/linux') diff --git a/drivers/video/aty128fb.c b/drivers/video/aty128fb.c index 69f2d8d618c3..5545dbdb50ac 100644 --- a/drivers/video/aty128fb.c +++ b/drivers/video/aty128fb.c @@ -1415,7 +1415,7 @@ aty128fb_setup(char *options) } #endif #ifdef CONFIG_ALL_PPC - /* vmode and cmode depreciated */ + /* vmode and cmode deprecated */ if (!strncmp(this_opt, "vmode:", 6)) { unsigned int vmode = simple_strtoul(this_opt+6, NULL, 0); if (vmode > 0 && vmode <= VMODE_MAX) diff --git a/include/asm-arm/arch-arc/io.h b/include/asm-arm/arch-arc/io.h index 11c9ce687ab4..5aab0c88953f 100644 --- a/include/asm-arm/arch-arc/io.h +++ b/include/asm-arm/arch-arc/io.h @@ -246,7 +246,7 @@ DECLARE_IO(int,l,"") #define outw(v,p) (__builtin_constant_p((p)) ? __outwc(v,p) : __outw(v,p)) #define outl(v,p) (__builtin_constant_p((p)) ? __outlc(v,p) : __outl(v,p)) #define __ioaddr(p) (__builtin_constant_p((p)) ? __ioaddr(p) : __ioaddrc(p)) -/* the following macro is depreciated */ +/* the following macro is deprecated */ #define ioaddr(port) __ioaddr((port)) /* diff --git a/include/asm-arm/arch-cl7500/io.h b/include/asm-arm/arch-cl7500/io.h index 376ca94ebb9c..16a926084d5f 100644 --- a/include/asm-arm/arch-cl7500/io.h +++ b/include/asm-arm/arch-cl7500/io.h @@ -236,7 +236,7 @@ DECLARE_IO(int,l,"") #define outw(v,p) (__builtin_constant_p((p)) ? __outwc(v,p) : __outw(v,p)) #define outl(v,p) (__builtin_constant_p((p)) ? __outlc(v,p) : __outl(v,p)) #define __ioaddr(p) (__builtin_constant_p((p)) ? __ioaddr(p) : __ioaddrc(p)) -/* the following macro is depreciated */ +/* the following macro is deprecated */ #define ioaddr(port) __ioaddr((port)) #endif diff --git a/include/asm-arm/arch-rpc/io.h b/include/asm-arm/arch-rpc/io.h index cb39453f5c9f..3a1c18ad63bb 100644 --- a/include/asm-arm/arch-rpc/io.h +++ b/include/asm-arm/arch-rpc/io.h @@ -238,7 +238,7 @@ DECLARE_IO(int,l,"") #define outw(v,p) (__builtin_constant_p((p)) ? __outwc(v,p) : __outw(v,p)) #define outl(v,p) (__builtin_constant_p((p)) ? __outlc(v,p) : __outl(v,p)) #define __ioaddr(p) (__builtin_constant_p((p)) ? __ioaddr(p) : __ioaddrc(p)) -/* the following macro is depreciated */ +/* the following macro is deprecated */ #define ioaddr(port) __ioaddr((port)) #define insb(p,d,l) __raw_readsb(__ioaddr(p),d,l) diff --git a/include/asm-arm/memory.h b/include/asm-arm/memory.h index c936883e5f0e..38682a28d121 100644 --- a/include/asm-arm/memory.h +++ b/include/asm-arm/memory.h @@ -44,7 +44,7 @@ static inline void *phys_to_virt(unsigned long x) /* * Virtual <-> DMA view memory address translations * Again, these are *only* valid on the kernel direct mapped RAM - * memory. Use of these is *depreciated*. + * memory. Use of these is *deprecated*. */ #define virt_to_bus(x) (__virt_to_bus((unsigned long)(x))) #define bus_to_virt(x) ((void *)(__bus_to_virt((unsigned long)(x)))) @@ -109,7 +109,7 @@ static inline void *phys_to_virt(unsigned long x) #define page_to_phys(page) (page_to_pfn(page) << PAGE_SHIFT) /* - * We should really eliminate virt_to_bus() here - it's depreciated. + * We should really eliminate virt_to_bus() here - it's deprecated. */ #define page_to_bus(page) (virt_to_bus(page_address(page))) diff --git a/include/asm-arm/setup.h b/include/asm-arm/setup.h index 38f4ba0ecc67..f3319e9b4f29 100644 --- a/include/asm-arm/setup.h +++ b/include/asm-arm/setup.h @@ -68,7 +68,7 @@ struct tag_ramdisk { /* describes where the compressed ramdisk image lives (virtual address) */ /* * this one accidentally used virtual addresses - as such, - * its depreciated. + * it's deprecated. */ #define ATAG_INITRD 0x54410005 diff --git a/include/linux/ax25.h b/include/linux/ax25.h index 6dfc8fc9116d..56c11f0dbd80 100644 --- a/include/linux/ax25.h +++ b/include/linux/ax25.h @@ -85,7 +85,7 @@ struct ax25_ctl_struct { }; /* this will go away. Please do not export to user land */ -struct ax25_info_struct_depreciated { +struct ax25_info_struct_deprecated { unsigned int n2, n2count; unsigned int t1, t1timer; unsigned int t2, t2timer; diff --git a/net/ax25/af_ax25.c b/net/ax25/af_ax25.c index 82a847128a31..1eedb5ed6cb2 100644 --- a/net/ax25/af_ax25.c +++ b/net/ax25/af_ax25.c @@ -1786,7 +1786,7 @@ static int ax25_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) warned=1; } - if (copy_to_user((void *)arg, &ax25_info, sizeof(struct ax25_info_struct_depreciated))) { + if (copy_to_user((void *)arg, &ax25_info, sizeof(struct ax25_info_struct_deprecated))) { res = -EFAULT; break; } -- cgit v1.2.3 From 2cdea2157dfbe0ea2a28bf6d4dc6c53013e4088f Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Sun, 29 Dec 2002 00:35:42 -0800 Subject: [PATCH] more deprectation bits Rename the deprecated attribute to __deprecated to make it obvious this is something special and to avoid namespace clashes. Mark old module interfaces deprecated. --- include/linux/compiler.h | 4 ++-- include/linux/ioport.h | 2 +- include/linux/module.h | 34 ++++++++++++++++++++++++++-------- kernel/resource.c | 2 +- 4 files changed, 30 insertions(+), 12 deletions(-) (limited to 'include/linux') diff --git a/include/linux/compiler.h b/include/linux/compiler.h index 51cfdb71594b..f88889740949 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h @@ -21,9 +21,9 @@ * and then gcc will emit a warning for each usage of the function. */ #if __GNUC__ >= 3 -#define deprecated __attribute__((deprecated)) +#define __deprecated __attribute__((deprecated)) #else -#define deprecated +#define __deprecated #endif /* This macro obfuscates arithmetic on a variable address so that gcc diff --git a/include/linux/ioport.h b/include/linux/ioport.h index 7c48dfa36962..edd1eadb98b8 100644 --- a/include/linux/ioport.h +++ b/include/linux/ioport.h @@ -108,7 +108,7 @@ extern struct resource * __request_region(struct resource *, unsigned long start #define check_mem_region(start,n) __check_region(&iomem_resource, (start), (n)) #define release_mem_region(start,n) __release_region(&iomem_resource, (start), (n)) -extern int deprecated __check_region(struct resource *, unsigned long, unsigned long); +extern int __deprecated __check_region(struct resource *, unsigned long, unsigned long); extern void __release_region(struct resource *, unsigned long, unsigned long); #define get_ioport_list(buf) get_resource_list(&ioport_resource, buf, PAGE_SIZE) diff --git a/include/linux/module.h b/include/linux/module.h index 2392edcc3307..c033488d6eeb 100644 --- a/include/linux/module.h +++ b/include/linux/module.h @@ -296,9 +296,20 @@ extern spinlock_t modlist_lock; #define symbol_request(x) try_then_request_module(symbol_get(x), "symbol:" #x) /* BELOW HERE ALL THESE ARE OBSOLETE AND WILL VANISH */ -#define __MOD_INC_USE_COUNT(mod) \ - do { __unsafe(mod); (void)try_module_get(mod); } while(0) -#define __MOD_DEC_USE_COUNT(mod) module_put(mod) +static inline void __deprecated __MOD_INC_USE_COUNT(struct module *module) +{ + __unsafe(module); + /* + * Yes, we ignore the retval here, that's why it's deprecated. + */ + try_module_get(module); +} + +static inline void __deprecated __MOD_DEC_USE_COUNT(struct module *module) +{ + module_put(module); +} + #define SET_MODULE_OWNER(dev) ((dev)->owner = THIS_MODULE) struct obsolete_modparm { @@ -319,14 +330,21 @@ struct obsolete_modparm __parm_##var __attribute__((section("__obsparm"))) = \ /* People do this inside their init routines, when the module isn't "live" yet. They should no longer be doing that, but meanwhile... */ +static inline void __deprecated _MOD_INC_USE_COUNT(struct module *module) +{ + __unsafe(module); + #if defined(CONFIG_MODULE_UNLOAD) && defined(MODULE) -#define MOD_INC_USE_COUNT \ - do { __unsafe(THIS_MODULE); local_inc(&THIS_MODULE->ref[get_cpu()].count); put_cpu(); } while (0) + local_inc(&module->ref[get_cpu()].count); + put_cpu(); #else -#define MOD_INC_USE_COUNT \ - do { __unsafe(THIS_MODULE); (void)try_module_get(THIS_MODULE); } while (0) + try_module_get(module); #endif -#define MOD_DEC_USE_COUNT module_put(THIS_MODULE) +} +#define MOD_INC_USE_COUNT \ + _MOD_INC_USE_COUNT(THIS_MODULE) +#define MOD_DEC_USE_COUNT \ + __MOD_DEC_USE_COUNT(THIS_MODULE) #define try_inc_mod_count(mod) try_module_get(mod) #define EXPORT_NO_SYMBOLS extern int module_dummy_usage; diff --git a/kernel/resource.c b/kernel/resource.c index 7e23211ac0a9..83d04826245d 100644 --- a/kernel/resource.c +++ b/kernel/resource.c @@ -237,7 +237,7 @@ struct resource * __request_region(struct resource *parent, unsigned long start, return res; } -int deprecated __check_region(struct resource *parent, unsigned long start, unsigned long n) +int __deprecated __check_region(struct resource *parent, unsigned long start, unsigned long n) { struct resource * res; -- cgit v1.2.3 From afe0458b256d78a37ba9f244cce29e141e1c658a Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Sun, 29 Dec 2002 00:40:46 -0800 Subject: [PATCH] avoid deprecated module functions in core code A second start at removing them from kernel/*.c and fs/*.c. Note that module_put is fine for a NULL argument. --- crypto/api.c | 3 +-- drivers/block/genhd.c | 6 ++---- fs/block_dev.c | 11 +++++------ fs/dquot.c | 3 +-- fs/exec.c | 17 ++++++++++------- fs/nls/nls_base.c | 3 +-- fs/partitions/check.c | 3 +-- include/linux/binfmts.h | 8 +------- include/linux/fs.h | 4 ++-- include/linux/personality.h | 18 ------------------ kernel/exec_domain.c | 7 ++----- kernel/exit.c | 6 +++--- kernel/fork.c | 14 ++++++++------ kernel/intermodule.c | 2 +- 14 files changed, 38 insertions(+), 67 deletions(-) (limited to 'include/linux') diff --git a/crypto/api.c b/crypto/api.c index 626437fb5dea..64886f4d6335 100644 --- a/crypto/api.c +++ b/crypto/api.c @@ -29,8 +29,7 @@ static inline int crypto_alg_get(struct crypto_alg *alg) static inline void crypto_alg_put(struct crypto_alg *alg) { - if (alg->cra_module) - __MOD_DEC_USE_COUNT(alg->cra_module); + module_put(alg->cra_module); } struct crypto_alg *crypto_alg_lookup(const char *name) diff --git a/drivers/block/genhd.c b/drivers/block/genhd.c index 98a62d7c7a6b..c133b454b2fb 100644 --- a/drivers/block/genhd.c +++ b/drivers/block/genhd.c @@ -168,15 +168,13 @@ retry: best = p->range; *part = dev - p->dev; if (p->lock && p->lock(dev, data) < 0) { - if (owner) - __MOD_DEC_USE_COUNT(owner); + module_put(owner); continue; } read_unlock(&gendisk_lock); disk = probe(dev, part, data); /* Currently ->owner protects _only_ ->probe() itself. */ - if (owner) - __MOD_DEC_USE_COUNT(owner); + module_put(owner); if (disk) return disk; goto retry; diff --git a/fs/block_dev.c b/fs/block_dev.c index e6fc5b1984e3..2e0b69ff70a1 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c @@ -623,8 +623,7 @@ static int do_open(struct block_device *bdev, struct inode *inode, struct file * } } else { put_disk(disk); - if (owner) - __MOD_DEC_USE_COUNT(owner); + module_put(owner); if (bdev->bd_contains == bdev) { if (bdev->bd_disk->fops->open) { ret = bdev->bd_disk->fops->open(inode, file); @@ -651,8 +650,7 @@ out_first: blkdev_put(bdev->bd_contains, BDEV_RAW); bdev->bd_contains = NULL; put_disk(disk); - if (owner) - __MOD_DEC_USE_COUNT(owner); + module_put(owner); out: up(&bdev->bd_sem); unlock_kernel(); @@ -723,9 +721,10 @@ int blkdev_put(struct block_device *bdev, int kind) } if (!bdev->bd_openers) { struct module *owner = disk->fops->owner; + put_disk(disk); - if (owner) - __MOD_DEC_USE_COUNT(owner); + module_put(owner); + bdev->bd_disk = NULL; bdev->bd_inode->i_data.backing_dev_info = &default_backing_dev_info; if (bdev != bdev->bd_contains) { diff --git a/fs/dquot.c b/fs/dquot.c index 5da20a7049ce..8781f7201a87 100644 --- a/fs/dquot.c +++ b/fs/dquot.c @@ -111,8 +111,7 @@ static struct quota_format_type *find_quota_format(int id) static void put_quota_format(struct quota_format_type *fmt) { - if (fmt->qf_owner) - __MOD_DEC_USE_COUNT(fmt->qf_owner); + module_put(fmt->qf_owner); } /* diff --git a/fs/exec.c b/fs/exec.c index 1699f5bdf92e..901b8e12388f 100644 --- a/fs/exec.c +++ b/fs/exec.c @@ -102,8 +102,7 @@ int unregister_binfmt(struct linux_binfmt * fmt) static inline void put_binfmt(struct linux_binfmt * fmt) { - if (fmt->module) - __MOD_DEC_USE_COUNT(fmt->module); + module_put(fmt->module); } /* @@ -1108,14 +1107,18 @@ out_file: return retval; } -void set_binfmt(struct linux_binfmt *new) +int set_binfmt(struct linux_binfmt *new) { struct linux_binfmt *old = current->binfmt; - if (new && new->module) - __MOD_INC_USE_COUNT(new->module); + + if (new) { + if (!try_module_get(new->module)) + return -1; + } current->binfmt = new; - if (old && old->module) - __MOD_DEC_USE_COUNT(old->module); + if (old) + module_put(old->module); + return 0; } #define CORENAME_MAX_SIZE 64 diff --git a/fs/nls/nls_base.c b/fs/nls/nls_base.c index 0af5e08cb950..3ea711688341 100644 --- a/fs/nls/nls_base.c +++ b/fs/nls/nls_base.c @@ -245,8 +245,7 @@ struct nls_table *load_nls(char *charset) void unload_nls(struct nls_table *nls) { - if (nls->owner) - __MOD_DEC_USE_COUNT(nls->owner); + module_put(nls->owner); } wchar_t charset2uni[256] = { diff --git a/fs/partitions/check.c b/fs/partitions/check.c index da216ea3efa6..b1d436feb241 100644 --- a/fs/partitions/check.c +++ b/fs/partitions/check.c @@ -565,8 +565,7 @@ char *partition_name(dev_t dev) dname->name = NULL; if (hd) { dname->name = disk_name(hd, part, dname->namebuf); - if (hd->fops->owner) - __MOD_DEC_USE_COUNT(hd->fops->owner); + module_put(hd->fops->owner); put_disk(hd); } if (!dname->name) { diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h index ae1b454395b5..bd929e344d75 100644 --- a/include/linux/binfmts.h +++ b/include/linux/binfmts.h @@ -58,13 +58,7 @@ extern int copy_strings(int argc,char ** argv,struct linux_binprm *bprm); extern int copy_strings_kernel(int argc,char ** argv,struct linux_binprm *bprm); extern void compute_creds(struct linux_binprm *binprm); extern int do_coredump(long signr, int exit_code, struct pt_regs * regs); -extern void set_binfmt(struct linux_binfmt *new); - - -#if 0 -/* this went away now */ -#define change_ldt(a,b) setup_arg_pages(a,b) -#endif +extern int set_binfmt(struct linux_binfmt *new); #endif /* __KERNEL__ */ #endif /* _LINUX_BINFMTS_H */ diff --git a/include/linux/fs.h b/include/linux/fs.h index 5c00caf3edf1..6c3188b991e6 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -983,13 +983,13 @@ struct super_block *get_sb_pseudo(struct file_system_type *, char *, /* Alas, no aliases. Too much hassle with bringing module.h everywhere */ #define fops_get(fops) \ (((fops) && (fops)->owner) \ - ? ( try_inc_mod_count((fops)->owner) ? (fops) : NULL ) \ + ? (try_inc_mod_count((fops)->owner) ? (fops) : NULL) \ : (fops)) #define fops_put(fops) \ do { \ if ((fops) && (fops)->owner) \ - __MOD_DEC_USE_COUNT((fops)->owner); \ + module_put((fops)->owner); \ } while(0) extern int register_filesystem(struct file_system_type *); diff --git a/include/linux/personality.h b/include/linux/personality.h index ca5d403e49ff..33802c8eeedb 100644 --- a/include/linux/personality.h +++ b/include/linux/personality.h @@ -107,22 +107,4 @@ struct exec_domain { #define set_personality(pers) \ ((current->personality == pers) ? 0 : __set_personality(pers)) -/* - * Load an execution domain. - */ -#define get_exec_domain(ep) \ -do { \ - if (ep != NULL && ep->module != NULL) \ - __MOD_INC_USE_COUNT(ep->module); \ -} while (0) - -/* - * Unload an execution domain. - */ -#define put_exec_domain(ep) \ -do { \ - if (ep != NULL && ep->module != NULL) \ - __MOD_DEC_USE_COUNT(ep->module); \ -} while (0) - #endif /* _LINUX_PERSONALITY_H */ diff --git a/kernel/exec_domain.c b/kernel/exec_domain.c index e0b31f7f5243..162a5c23e606 100644 --- a/kernel/exec_domain.c +++ b/kernel/exec_domain.c @@ -172,7 +172,7 @@ __set_personality(u_long personality) fsp = copy_fs_struct(current->fs); if (fsp == NULL) { - put_exec_domain(ep); + module_put(ep->module); return -ENOMEM;; } @@ -194,10 +194,7 @@ __set_personality(u_long personality) current_thread_info()->exec_domain = ep; set_fs_altroot(); - put_exec_domain(oep); - - printk(KERN_DEBUG "[%s:%d]: set personality to %lx\n", - current->comm, current->pid, personality); + module_put(oep->module); return 0; } diff --git a/kernel/exit.c b/kernel/exit.c index 5e7fcdaa6221..6adea537242a 100644 --- a/kernel/exit.c +++ b/kernel/exit.c @@ -664,9 +664,9 @@ fake_volatile: if (current->leader) disassociate_ctty(1); - put_exec_domain(tsk->thread_info->exec_domain); - if (tsk->binfmt && tsk->binfmt->module) - __MOD_DEC_USE_COUNT(tsk->binfmt->module); + module_put(tsk->thread_info->exec_domain->module); + if (tsk->binfmt) + module_put(tsk->binfmt->module); tsk->exit_code = code; exit_notify(); diff --git a/kernel/fork.c b/kernel/fork.c index b8771509f285..6f7298827344 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -743,10 +743,11 @@ static struct task_struct *copy_process(unsigned long clone_flags, if (nr_threads >= max_threads) goto bad_fork_cleanup_count; - get_exec_domain(p->thread_info->exec_domain); + if (!try_module_get(p->thread_info->exec_domain->module)) + goto bad_fork_cleanup_count; - if (p->binfmt && p->binfmt->module) - __MOD_INC_USE_COUNT(p->binfmt->module); + if (p->binfmt && !try_module_get(p->binfmt->module)) + goto bad_fork_cleanup_put_domain; #ifdef CONFIG_PREEMPT /* @@ -958,9 +959,10 @@ bad_fork_cleanup_security: bad_fork_cleanup: if (p->pid > 0) free_pidmap(p->pid); - put_exec_domain(p->thread_info->exec_domain); - if (p->binfmt && p->binfmt->module) - __MOD_DEC_USE_COUNT(p->binfmt->module); + if (p->binfmt) + module_put(p->binfmt->module); +bad_fork_cleanup_put_domain: + module_put(p->thread_info->exec_domain->module); bad_fork_cleanup_count: atomic_dec(&p->user->processes); free_uid(p->user); diff --git a/kernel/intermodule.c b/kernel/intermodule.c index a6cd1d08afa4..9228ca4fe035 100644 --- a/kernel/intermodule.c +++ b/kernel/intermodule.c @@ -166,7 +166,7 @@ void inter_module_put(const char *im_name) ime = list_entry(tmp, struct inter_module_entry, list); if (strcmp(ime->im_name, im_name) == 0) { if (ime->owner) - __MOD_DEC_USE_COUNT(ime->owner); + module_put(ime->owner); spin_unlock(&ime_lock); return; } -- cgit v1.2.3 From 35bc6f3f8db6a6412fcb6fb9a251a1083094ca47 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Sun, 29 Dec 2002 01:47:53 -0800 Subject: [PATCH] Embed __this_module in module itself. Rather than have the module loader the module structure and resolve the symbols __this_module to it, make __this_module a real structure inside the module, using the linkonce trick we used for module names. This saves us an allocation (saving a page per module on archs which need the module structure close by), and means we don't have to fill in a few module fields. --- include/linux/init.h | 5 +-- include/linux/module.h | 34 ++++++++-------- kernel/module.c | 103 ++++++++++++++++++++++--------------------------- 3 files changed, 66 insertions(+), 76 deletions(-) (limited to 'include/linux') diff --git a/include/linux/init.h b/include/linux/init.h index 46b1ef190c52..b7c6363478aa 100644 --- a/include/linux/init.h +++ b/include/linux/init.h @@ -147,14 +147,13 @@ struct obs_kernel_param { #define module_init(initfn) \ static inline initcall_t __inittest(void) \ { return initfn; } \ - int __initfn(void) __attribute__((alias(#initfn))); + int init_module(void) __attribute__((alias(#initfn))); /* This is only required if you want to be unloadable. */ #define module_exit(exitfn) \ static inline exitcall_t __exittest(void) \ { return exitfn; } \ - void __exitfn(void) __attribute__((alias(#exitfn))); - + void cleanup_module(void) __attribute__((alias(#exitfn))); #define __setup(str,func) /* nothing */ #endif diff --git a/include/linux/module.h b/include/linux/module.h index c033488d6eeb..3a411c8c6575 100644 --- a/include/linux/module.h +++ b/include/linux/module.h @@ -40,12 +40,11 @@ struct kernel_symbol char name[MODULE_NAME_LEN]; }; -#ifdef MODULE +/* These are either module local, or the kernel's dummy ones. */ +extern int init_module(void); +extern void cleanup_module(void); -#ifdef KBUILD_MODNAME -static const char __module_name[MODULE_NAME_LEN] __attribute__((section(".gnu.linkonce.modname"))) = \ - __stringify(KBUILD_MODNAME); -#endif +#ifdef MODULE /* For replacement modutils, use an alias not a pointer. */ #define MODULE_GENERIC_TABLE(gtype,name) \ @@ -56,9 +55,6 @@ static const struct gtype##_id * __module_##gtype##_table \ extern const struct gtype##_id __mod_##gtype##_table \ __attribute__ ((unused, alias(__stringify(name)))) -/* This is magically filled in by the linker, but THIS_MODULE must be - a constant so it works in initializers. */ -extern struct module __this_module; #define THIS_MODULE (&__this_module) #else /* !MODULE */ @@ -176,7 +172,7 @@ struct module /* The command line arguments (may be mangled). People like keeping pointers to this stuff */ - char args[0]; + char *args; }; /* FIXME: It'd be nice to isolate modules during init, too, so they @@ -289,6 +285,19 @@ static inline const char *module_address_lookup(unsigned long addr, } #endif /* CONFIG_MODULES */ +#if defined(MODULE) && defined(KBUILD_MODNAME) +/* We make the linker do some of the work. */ +struct module __this_module +__attribute__((section(".gnu.linkonce.this_module"))) = { + .name = __stringify(KBUILD_MODNAME), + .symbols = { .owner = &__this_module }, + .init = init_module, +#ifdef CONFIG_MODULE_UNLOAD + .exit = cleanup_module, +#endif +}; +#endif /* MODULE && KBUILD_MODNAME */ + /* For archs to search exception tables */ extern struct list_head extables; extern spinlock_t modlist_lock; @@ -360,13 +369,6 @@ extern int module_dummy_usage; && __mod_between((p),(n),(m)->module_init,(m)->init_size)) \ || __mod_between((p),(n),(m)->module_core,(m)->core_size)) -/* Old-style "I'll just call it init_module and it'll be run at - insert". Use module_init(myroutine) instead. */ -#ifdef MODULE -#define init_module(voidarg) __initfn(void) -#define cleanup_module(voidarg) __exitfn(void) -#endif - /* * The exception and symbol tables, and the lock * to protect them. diff --git a/kernel/module.c b/kernel/module.c index 2209ab07e733..fe995b8d8ea9 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -60,6 +60,13 @@ struct sizes unsigned long core_size; }; +/* Stub function for modules which don't have an initfn */ +int init_module(void) +{ + return 0; +} +EXPORT_SYMBOL(init_module); + /* Find a symbol, return value and the symbol group */ static unsigned long __find_symbol(const char *name, struct kernel_symbol_group **group) @@ -357,6 +364,12 @@ static inline int try_force(unsigned int flags) } #endif /* CONFIG_MODULE_FORCE_UNLOAD */ +/* Stub function for modules which don't have an exitfn */ +void cleanup_module(void) +{ +} +EXPORT_SYMBOL(cleanup_module); + asmlinkage long sys_delete_module(const char *name_user, unsigned int flags) { @@ -406,7 +419,8 @@ sys_delete_module(const char *name_user, unsigned int flags) } /* If it has an init func, it must have an exit func to unload */ - if ((mod->init && !mod->exit) || mod->unsafe) { + if ((mod->init != init_module && mod->exit == cleanup_module) + || mod->unsafe) { forced = try_force(flags); if (!forced) { /* This module can't be removed */ @@ -453,8 +467,7 @@ sys_delete_module(const char *name_user, unsigned int flags) destroy: /* Final destruction now noone is using it. */ - if (mod->exit) - mod->exit(); + mod->exit(); free_module(mod); out: @@ -474,7 +487,7 @@ static void print_unload_info(struct seq_file *m, struct module *mod) if (mod->unsafe) seq_printf(m, " [unsafe]"); - if (mod->init && !mod->exit) + if (mod->init != init_module && mod->exit == cleanup_module) seq_printf(m, " [permanent]"); seq_printf(m, "\n"); @@ -708,15 +721,15 @@ static void free_module(struct module *mod) list_del(&mod->extable.list); spin_unlock_irq(&modlist_lock); - /* These may be NULL, but that's OK */ - module_free(mod, mod->module_init); - module_free(mod, mod->module_core); - /* Module unload stuff */ module_unload_free(mod); - /* Finally, free the module structure */ - module_free(mod, mod); + /* This may be NULL, but that's OK */ + module_free(mod, mod->module_init); + kfree(mod->args); + + /* Finally, free the core (containing the module structure) */ + module_free(mod, mod->module_core); } void *__symbol_get(const char *symbol) @@ -771,27 +784,6 @@ static void *copy_section(const char *name, return dest; } -/* Look for the special symbols */ -static int grab_private_symbols(Elf_Shdr *sechdrs, - unsigned int symbolsec, - const char *strtab, - struct module *mod) -{ - Elf_Sym *sym = (void *)sechdrs[symbolsec].sh_offset; - unsigned int i; - - for (i = 1; i < sechdrs[symbolsec].sh_size/sizeof(*sym); i++) { - if (symbol_is("__initfn", strtab + sym[i].st_name)) - mod->init = (void *)sym[i].st_value; -#ifdef CONFIG_MODULE_UNLOAD - if (symbol_is("__exitfn", strtab + sym[i].st_name)) - mod->exit = (void *)sym[i].st_value; -#endif - } - - return 0; -} - /* Deal with the given section */ static int handle_section(const char *name, Elf_Shdr *sechdrs, @@ -810,9 +802,6 @@ static int handle_section(const char *name, case SHT_RELA: ret = apply_relocate_add(sechdrs, strtab, symindex, i, mod); break; - case SHT_SYMTAB: - ret = grab_private_symbols(sechdrs, i, strtab, mod); - break; default: DEBUGP("Ignoring section %u: %s\n", i, sechdrs[i].sh_type==SHT_NULL ? "NULL": @@ -920,9 +909,6 @@ static void simplify_symbols(Elf_Shdr *sechdrs, strtab + sym[i].st_name, mod, &ksg); - /* We fake up "__this_module" */ - if (symbol_is("__this_module", strtab+sym[i].st_name)) - sym[i].st_value = (unsigned long)mod; } } } @@ -964,9 +950,9 @@ static struct module *load_module(void *umod, { Elf_Ehdr *hdr; Elf_Shdr *sechdrs; - char *secstrings; + char *secstrings, *args; unsigned int i, symindex, exportindex, strindex, setupindex, exindex, - modnameindex, obsparmindex; + modindex, obsparmindex; long arglen; unsigned long common_length; struct sizes sizes, used; @@ -1007,7 +993,7 @@ static struct module *load_module(void *umod, exportindex = setupindex = obsparmindex = 0; /* And these should exist, but gcc whinges if we don't init them */ - symindex = strindex = exindex = modnameindex = 0; + symindex = strindex = exindex = modindex = 0; /* Find where important sections are */ for (i = 1; i < hdr->e_shnum; i++) { @@ -1016,10 +1002,10 @@ static struct module *load_module(void *umod, DEBUGP("Symbol table in section %u\n", i); symindex = i; } else if (strcmp(secstrings+sechdrs[i].sh_name, - ".gnu.linkonce.modname") == 0) { - /* This module's name */ - DEBUGP("Module name in section %u\n", i); - modnameindex = i; + ".gnu.linkonce.this_module") == 0) { + /* The module struct */ + DEBUGP("Module in section %u\n", i); + modindex = i; } else if (strcmp(secstrings+sechdrs[i].sh_name, "__ksymtab") == 0) { /* Exported symbols. */ @@ -1058,39 +1044,35 @@ static struct module *load_module(void *umod, #endif } - if (!modnameindex) { - DEBUGP("Module has no name!\n"); + if (!modindex) { + printk(KERN_WARNING "No module found in object\n"); err = -ENOEXEC; goto free_hdr; } + mod = (void *)hdr + sechdrs[modindex].sh_offset; - /* Now allocate space for the module proper, and copy name and args. */ + /* Now copy in args */ err = strlen_user(uargs); if (err < 0) goto free_hdr; arglen = err; - mod = module_alloc(sizeof(*mod) + arglen+1); - if (!mod) { + args = kmalloc(arglen+1, GFP_KERNEL); + if (!args) { err = -ENOMEM; goto free_hdr; } - memset(mod, 0, sizeof(*mod) + arglen+1); - if (copy_from_user(mod->args, uargs, arglen) != 0) { + if (copy_from_user(args, uargs, arglen+1) != 0) { err = -EFAULT; goto free_mod; } - strncpy(mod->name, (char *)hdr + sechdrs[modnameindex].sh_offset, - sizeof(mod->name)-1); if (find_module(mod->name)) { err = -EEXIST; goto free_mod; } - mod->symbols.owner = mod; mod->state = MODULE_STATE_COMING; - module_unload_init(mod); /* How much space will we need? (Common area in first) */ common_length = read_commons(hdr, &sechdrs[symindex]); @@ -1139,6 +1121,9 @@ static struct module *load_module(void *umod, if (IS_ERR(ptr)) goto cleanup; sechdrs[i].sh_offset = (unsigned long)ptr; + /* Have we just copied __this_module across? */ + if (i == modindex) + mod = ptr; } else { sechdrs[i].sh_offset += (unsigned long)hdr; } @@ -1147,6 +1132,9 @@ static struct module *load_module(void *umod, if (used.init_size > mod->init_size || used.core_size > mod->core_size) BUG(); + /* Now we've moved module, initialize linked lists, etc. */ + module_unload_init(mod); + /* Fix up syms, so that st_value is a pointer to location. */ simplify_symbols(sechdrs, symindex, strindex, mod->module_core, mod); @@ -1183,6 +1171,7 @@ static struct module *load_module(void *umod, if (err < 0) goto cleanup; + mod->args = args; if (obsparmindex) { err = obsolete_params(mod->name, mod->args, (struct obsolete_modparm *) @@ -1215,7 +1204,7 @@ static struct module *load_module(void *umod, free_core: module_free(mod, mod->module_core); free_mod: - module_free(mod, mod); + kfree(args); free_hdr: vfree(hdr); if (err < 0) return ERR_PTR(err); @@ -1266,7 +1255,7 @@ sys_init_module(void *umod, up(&module_mutex); /* Start the module */ - ret = mod->init ? mod->init() : 0; + ret = mod->init(); if (ret < 0) { /* Init routine failed: abort. Try to protect us from buggy refcounters. */ -- cgit v1.2.3 From bfafc871ca1ea430dd7422fdfdfe0fa2e959c566 Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Sun, 29 Dec 2002 01:48:01 -0800 Subject: [PATCH] Trivial patch for param.h: make it const. Add a const declaration to the __module_param_call so __param section gets more correct attributes. --- include/linux/moduleparam.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/linux') diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h index 92a1bc154e8e..e52553263640 100644 --- a/include/linux/moduleparam.h +++ b/include/linux/moduleparam.h @@ -39,7 +39,7 @@ struct kparam_string { writable. */ #define __module_param_call(prefix, name, set, get, arg, perm) \ static char __param_str_##name[] __initdata = prefix #name; \ - static struct kernel_param __param_##name \ + static struct kernel_param const __param_##name \ __attribute__ ((unused,__section__ ("__param"))) \ = { __param_str_##name, perm, set, get, arg } -- cgit v1.2.3 From bec7aa00ffe5b1270837b965fdfe80be3e8e6e2e Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Sun, 29 Dec 2002 03:26:34 -0800 Subject: [PATCH] more module warning fixes this is only for the module-related warning introduced by my __deprecated patch. --- drivers/block/paride/paride.c | 15 ++++------ drivers/char/busmouse.c | 7 ++--- drivers/hotplug/pci_hotplug_core.c | 52 ++++++++++++++++------------------- drivers/ide/ide.c | 6 ++-- drivers/ieee1394/ieee1394_core.c | 23 +++++----------- drivers/isdn/capi/kcapi.c | 3 +- drivers/md/dm-target.c | 14 +++++----- drivers/media/dvb/dvb-core/dvb_i2c.c | 23 +++++----------- drivers/media/video/cpia.c | 3 +- drivers/mtd/chips/chipreg.c | 6 ++-- drivers/net/irda/sir_dev.c | 9 ++---- drivers/net/irda/sir_dongle.c | 7 ++--- drivers/s390/block/dasd.c | 3 +- drivers/s390/block/dasd_ioctl.c | 2 +- drivers/s390/char/tape_core.c | 3 +- drivers/scsi/fcal.c | 10 +++++-- drivers/scsi/pluto.c | 8 ++++-- drivers/serial/core.c | 6 ++-- drivers/usb/media/ov511.c | 32 +++++++++++---------- drivers/usb/media/usbvideo.c | 8 ++++-- include/linux/mtd/map.h | 5 +--- include/linux/mtd/mtd.h | 3 +- net/core/dev.c | 9 ++---- net/ipv4/xfrm_policy.c | 3 +- net/rxrpc/call.c | 2 +- sound/core/control.c | 10 ++----- sound/core/info.c | 10 ++----- sound/core/oss/mixer_oss.c | 8 +----- sound/core/oss/pcm_oss.c | 10 ++----- sound/core/pcm_native.c | 12 ++------ sound/core/rawmidi.c | 10 ++----- sound/core/seq/oss/seq_oss_synth.c | 10 ++----- sound/core/seq/seq_ports.c | 10 ++----- sound/core/seq/seq_virmidi.c | 10 ++----- sound/core/timer.c | 8 +----- sound/drivers/opl3/opl3_seq.c | 8 +----- sound/isa/gus/gus_main.c | 8 +----- sound/isa/wavefront/wavefront_fx.c | 9 +----- sound/isa/wavefront/wavefront_synth.c | 9 +----- sound/oss/audio.c | 26 ++++++++---------- sound/oss/midibuf.c | 6 ++-- sound/oss/mpu401.c | 18 ++++++------ sound/oss/sequencer.c | 22 ++++++--------- sound/oss/soundcard.c | 10 +++---- sound/synth/emux/emux_seq.c | 12 ++------ 45 files changed, 172 insertions(+), 316 deletions(-) (limited to 'include/linux') diff --git a/drivers/block/paride/paride.c b/drivers/block/paride/paride.c index 3c1161767acf..0b19343f6969 100644 --- a/drivers/block/paride/paride.c +++ b/drivers/block/paride/paride.c @@ -175,8 +175,7 @@ void pi_release(PIA * pi) #endif /* !CONFIG_PARPORT */ if (pi->proto->release_proto) pi->proto->release_proto(pi); - if (pi->proto->owner) - __MOD_DEC_USE_COUNT(pi->proto->owner); + module_put(pi->proto->owner); } EXPORT_SYMBOL(pi_release); @@ -238,7 +237,6 @@ int pi_register(PIP * pr) printk("paride: protocol table full\n"); return 0; } - MOD_INC_USE_COUNT; protocols[k] = pr; pr->index = k; printk("paride: %s registered as protocol %d\n", pr->name, k); @@ -256,7 +254,6 @@ void pi_unregister(PIP * pr) return; } protocols[pr->index] = 0; - MOD_DEC_USE_COUNT; } EXPORT_SYMBOL(pi_unregister); @@ -392,14 +389,13 @@ int pi_init(PIA * pi, int autoprobe, int port, int mode, if (!proto) continue; /* still racy */ - if (proto->owner) - __MOD_INC_USE_COUNT(proto->owner); + if (!try_module_get(proto->owner)) + continue; pi->proto = proto; pi->private = 0; if (proto->init_proto && proto->init_proto(pi) < 0) { pi->proto = NULL; - if (proto->owner) - __MOD_DEC_USE_COUNT(proto->owner); + module_put(proto->owner); continue; } if (delay == -1) @@ -432,8 +428,7 @@ int pi_init(PIA * pi, int autoprobe, int port, int mode, } if (pi->proto->release_proto) pi->proto->release_proto(pi); - if (proto->owner) - __MOD_DEC_USE_COUNT(proto->owner); + module_put(proto->owner); } if (!pi->port) { diff --git a/drivers/char/busmouse.c b/drivers/char/busmouse.c index 29362e24aa4c..85baa0cdf51b 100644 --- a/drivers/char/busmouse.c +++ b/drivers/char/busmouse.c @@ -175,8 +175,7 @@ static int busmouse_release(struct inode *inode, struct file *file) if (--mse->active == 0) { if (mse->ops->release) ret = mse->ops->release(inode, file); - if (mse->ops->owner) - __MOD_DEC_USE_COUNT(mse->ops->owner); + module_put(mse->ops->owner); mse->ready = 0; } unlock_kernel(); @@ -207,8 +206,8 @@ static int busmouse_open(struct inode *inode, struct file *file) ret = 0; if (mse->ops->open) { ret = mse->ops->open(inode, file); - if (ret && mse->ops->owner) - __MOD_DEC_USE_COUNT(mse->ops->owner); + if (ret) + module_put(mse->ops->owner); } if (ret) diff --git a/drivers/hotplug/pci_hotplug_core.c b/drivers/hotplug/pci_hotplug_core.c index b03104c8edd1..5e4c1748b7d1 100644 --- a/drivers/hotplug/pci_hotplug_core.c +++ b/drivers/hotplug/pci_hotplug_core.c @@ -561,19 +561,19 @@ static void fs_remove_file (struct dentry *dentry) up(&parent->d_inode->i_sem); } +/* yuck, WFT is this? */ #define GET_STATUS(name,type) \ static int get_##name (struct hotplug_slot *slot, type *value) \ { \ struct hotplug_slot_ops *ops = slot->ops; \ int retval = 0; \ - if (ops->owner) \ - __MOD_INC_USE_COUNT(ops->owner); \ - if (ops->get_##name) \ - retval = ops->get_##name (slot, value); \ - else \ - *value = slot->info->name; \ - if (ops->owner) \ - __MOD_DEC_USE_COUNT(ops->owner); \ + if (try_module_get(ops->owner)) { \ + if (ops->get_##name) \ + retval = ops->get_##name (slot, value); \ + else \ + *value = slot->info->name; \ + module_put(ops->owner); \ + } \ return retval; \ } @@ -665,21 +665,19 @@ static ssize_t power_write_file (struct file *file, const char *ubuff, size_t co case 0: if (!slot->ops->disable_slot) break; - if (slot->ops->owner) - __MOD_INC_USE_COUNT(slot->ops->owner); - retval = slot->ops->disable_slot(slot); - if (slot->ops->owner) - __MOD_DEC_USE_COUNT(slot->ops->owner); + if (try_module_get(slot->ops->owner)) { + retval = slot->ops->disable_slot(slot); + module_put(slot->ops->owner); + } break; case 1: if (!slot->ops->enable_slot) break; - if (slot->ops->owner) - __MOD_INC_USE_COUNT(slot->ops->owner); - retval = slot->ops->enable_slot(slot); - if (slot->ops->owner) - __MOD_DEC_USE_COUNT(slot->ops->owner); + if (try_module_get(slot->ops->owner)) { + retval = slot->ops->enable_slot(slot); + module_put(slot->ops->owner); + } break; default: @@ -773,11 +771,10 @@ static ssize_t attention_write_file (struct file *file, const char *ubuff, size_ dbg (" - attention = %d\n", attention); if (slot->ops->set_attention_status) { - if (slot->ops->owner) - __MOD_INC_USE_COUNT(slot->ops->owner); - retval = slot->ops->set_attention_status(slot, attention); - if (slot->ops->owner) - __MOD_DEC_USE_COUNT(slot->ops->owner); + if (try_module_get(slot->ops->owner)) { + retval = slot->ops->set_attention_status(slot, attention); + module_put(slot->ops->owner); + } } exit: @@ -1011,11 +1008,10 @@ static ssize_t test_write_file (struct file *file, const char *ubuff, size_t cou dbg ("test = %d\n", test); if (slot->ops->hardware_test) { - if (slot->ops->owner) - __MOD_INC_USE_COUNT(slot->ops->owner); - retval = slot->ops->hardware_test(slot, test); - if (slot->ops->owner) - __MOD_DEC_USE_COUNT(slot->ops->owner); + if (try_module_get(slot->ops->owner)) { + retval = slot->ops->hardware_test(slot, test); + module_put(slot->ops->owner); + } } exit: diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c index 3c07fbefa9bf..0ae396abfcc1 100644 --- a/drivers/ide/ide.c +++ b/drivers/ide/ide.c @@ -1336,14 +1336,12 @@ int ata_attach(ide_drive_t *drive) continue; spin_unlock(&drivers_lock); if (driver->attach(drive) == 0) { - if (driver->owner) - __MOD_DEC_USE_COUNT(driver->owner); + module_put(driver->owner); drive->gendev.driver = &driver->gen_driver; return 0; } spin_lock(&drivers_lock); - if (driver->owner) - __MOD_DEC_USE_COUNT(driver->owner); + module_put(driver->owner); } spin_unlock(&drivers_lock); spin_lock(&drives_lock); diff --git a/drivers/ieee1394/ieee1394_core.c b/drivers/ieee1394/ieee1394_core.c index 0b251ee098c1..b5e00b4b12b5 100644 --- a/drivers/ieee1394/ieee1394_core.c +++ b/drivers/ieee1394/ieee1394_core.c @@ -1135,28 +1135,19 @@ static int ieee1394_dispatch_open(struct inode *inode, struct file *file) unloading while the file is open, and will be dropped by the VFS when the file is released. */ - - if(THIS_MODULE) - __MOD_DEC_USE_COUNT((struct module*) THIS_MODULE); - - /* note that if ieee1394 is compiled into the kernel, - THIS_MODULE will be (void*) NULL, hence the if and - the cast are necessary */ - + module_put(THIS_MODULE); } else { - - /* if the open() failed, then we need to drop the - extra reference we gave to the task-specific - driver */ - - if(module) - __MOD_DEC_USE_COUNT(module); - /* point the file's f_ops back to ieee1394. The VFS will then decrement ieee1394's reference count immediately after this function returns. */ file->f_op = &ieee1394_chardev_ops; + + /* if the open() failed, then we need to drop the + extra reference we gave to the task-specific + driver */ + module_put(module); + } return retval; diff --git a/drivers/isdn/capi/kcapi.c b/drivers/isdn/capi/kcapi.c index 949a9497b0b5..337124784e9c 100644 --- a/drivers/isdn/capi/kcapi.c +++ b/drivers/isdn/capi/kcapi.c @@ -91,8 +91,7 @@ capi_ctr_get(struct capi_ctr *card) static inline void capi_ctr_put(struct capi_ctr *card) { - if (card->owner) - __MOD_DEC_USE_COUNT(card->owner); + module_put(card->owner); DBG("MOD_COUNT DEC"); } diff --git a/drivers/md/dm-target.c b/drivers/md/dm-target.c index 6bf8310ac1e9..886302cbd2b1 100644 --- a/drivers/md/dm-target.c +++ b/drivers/md/dm-target.c @@ -44,11 +44,11 @@ static struct tt_internal *get_target_type(const char *name) read_lock(&_lock); ti = __find_target_type(name); - - if (ti) { - if (ti->use == 0 && ti->tt.module) - __MOD_INC_USE_COUNT(ti->tt.module); - ti->use++; + if (ti && ti->use == 0) { + if (try_module_get(ti->tt.module)) + ti->use++; + else + ti = NULL; } read_unlock(&_lock); @@ -86,8 +86,8 @@ void dm_put_target_type(struct target_type *t) struct tt_internal *ti = (struct tt_internal *) t; read_lock(&_lock); - if (--ti->use == 0 && ti->tt.module) - __MOD_DEC_USE_COUNT(ti->tt.module); + if (--ti->use == 0) + module_put(ti->tt.module); if (ti->use < 0) BUG(); diff --git a/drivers/media/dvb/dvb-core/dvb_i2c.c b/drivers/media/dvb/dvb-core/dvb_i2c.c index e9a48ba1af9f..9eefbf4513d1 100644 --- a/drivers/media/dvb/dvb-core/dvb_i2c.c +++ b/drivers/media/dvb/dvb-core/dvb_i2c.c @@ -63,18 +63,11 @@ int register_i2c_client (struct dvb_i2c_bus *i2c, struct dvb_i2c_device *dev) static void try_attach_device (struct dvb_i2c_bus *i2c, struct dvb_i2c_device *dev) { - if (dev->owner) { - if (!MOD_CAN_QUERY(dev->owner)) - return; - - __MOD_INC_USE_COUNT(dev->owner); - } - - if (dev->attach (i2c) == 0) { - register_i2c_client (i2c, dev); - } else { - if (dev->owner) - __MOD_DEC_USE_COUNT(dev->owner); + if (try_module_get(dev->owner)) { + if (dev->attach(i2c) == 0) + register_i2c_client(i2c, dev); + else + module_put(dev->owner); } } @@ -82,10 +75,8 @@ void try_attach_device (struct dvb_i2c_bus *i2c, struct dvb_i2c_device *dev) static void detach_device (struct dvb_i2c_bus *i2c, struct dvb_i2c_device *dev) { - dev->detach (i2c); - - if (dev->owner) - __MOD_DEC_USE_COUNT(dev->owner); + dev->detach(i2c); + module_put(dev->owner); } diff --git a/drivers/media/video/cpia.c b/drivers/media/video/cpia.c index 1abef42a5896..bcc26db53c6a 100644 --- a/drivers/media/video/cpia.c +++ b/drivers/media/video/cpia.c @@ -3158,8 +3158,7 @@ static int reset_camera(struct cam_data *cam) static void put_cam(struct cpia_camera_ops* ops) { - if (ops->owner) - __MOD_DEC_USE_COUNT(ops->owner); + module_put(ops->owner); } /* ------------------------- V4L interface --------------------- */ diff --git a/drivers/mtd/chips/chipreg.c b/drivers/mtd/chips/chipreg.c index da5512cd14e3..efdd7ee41d34 100644 --- a/drivers/mtd/chips/chipreg.c +++ b/drivers/mtd/chips/chipreg.c @@ -71,15 +71,13 @@ struct mtd_info *do_map_probe(char *name, struct map_info *map) return NULL; ret = drv->probe(map); -#ifdef CONFIG_MODULES + /* We decrease the use count here. It may have been a probe-only module, which is no longer required from this point, having given us a handle on (and increased the use count of) the actual driver code. */ - if(drv->module) - __MOD_DEC_USE_COUNT(drv->module); -#endif + module_put(drv->module); if (ret) return ret; diff --git a/drivers/net/irda/sir_dev.c b/drivers/net/irda/sir_dev.c index a73fe2c3db70..a27737026547 100644 --- a/drivers/net/irda/sir_dev.c +++ b/drivers/net/irda/sir_dev.c @@ -502,8 +502,7 @@ errout_stop: errout_free: sirdev_free_buffers(dev); errout_dec: - if (drv->owner) - __MOD_DEC_USE_COUNT(drv->owner); + module_put(drv->owner); return -EAGAIN; } @@ -533,11 +532,7 @@ static int sirdev_close(struct net_device *ndev) drv->stop_dev(dev); sirdev_free_buffers(dev); - - lock_kernel(); - if (drv->owner) - __MOD_DEC_USE_COUNT(drv->owner); - unlock_kernel(); + module_put(drv->owner); out: dev->speed = 0; diff --git a/drivers/net/irda/sir_dongle.c b/drivers/net/irda/sir_dongle.c index 6384215dc27e..cf7a17a002d3 100644 --- a/drivers/net/irda/sir_dongle.c +++ b/drivers/net/irda/sir_dongle.c @@ -121,8 +121,7 @@ int sirdev_get_dongle(struct sir_dev *dev, IRDA_DONGLE type) out_reject: dev->dongle_drv = NULL; - if (drv->owner) - __MOD_DEC_USE_COUNT(drv->owner); + module_put(drv->owner); out_unlock: up(&dongle_list_lock); return err; @@ -137,9 +136,7 @@ int sirdev_put_dongle(struct sir_dev *dev) drv->close(dev); /* close this dongle instance */ dev->dongle_drv = NULL; /* unlink the dongle driver */ - - if (drv->owner) - __MOD_DEC_USE_COUNT(drv->owner);/* decrement driver's module refcount */ + module_put(drv->owner);/* decrement driver's module refcount */ } return 0; diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c index 6f0cfa5c66bc..8eedee623a04 100644 --- a/drivers/s390/block/dasd.c +++ b/drivers/s390/block/dasd.c @@ -1757,8 +1757,7 @@ dasd_release(struct inode *inp, struct file *filp) } if (atomic_dec_return(&device->open_count) == 0) { invalidate_buffers(inp->i_rdev); - if (device->discipline->owner) - __MOD_DEC_USE_COUNT(device->discipline->owner); + module_put(device->discipline->owner); } return 0; } diff --git a/drivers/s390/block/dasd_ioctl.c b/drivers/s390/block/dasd_ioctl.c index def999eb4334..9047d68fb20a 100644 --- a/drivers/s390/block/dasd_ioctl.c +++ b/drivers/s390/block/dasd_ioctl.c @@ -115,7 +115,7 @@ dasd_ioctl(struct inode *inp, struct file *filp, if (try_inc_mod_count(ioctl->owner) != 0) continue; rc = ioctl->handler(bdev, no, data); - __MOD_DEC_USE_COUNT(ioctl->owner); + module_put(ioctl->owner); } else rc = ioctl->handler(bdev, no, data); return rc; diff --git a/drivers/s390/char/tape_core.c b/drivers/s390/char/tape_core.c index 23c48e2e6381..af71fadf2f52 100644 --- a/drivers/s390/char/tape_core.c +++ b/drivers/s390/char/tape_core.c @@ -857,8 +857,7 @@ tape_release(struct tape_device *device) spin_lock(get_ccwdev_lock(device->cdev)); if (device->tape_state == TS_IN_USE) tape_state_set(device, TS_UNUSED); - if (device->discipline->owner) - __MOD_DEC_USE_COUNT(device->discipline->owner); + module_put(device->discipline->owner); spin_unlock(get_ccwdev_lock(device->cdev)); return 0; } diff --git a/drivers/scsi/fcal.c b/drivers/scsi/fcal.c index ffeacdf56718..f8d8fa5adfb6 100644 --- a/drivers/scsi/fcal.c +++ b/drivers/scsi/fcal.c @@ -138,10 +138,14 @@ int __init fcal_detect(Scsi_Host_Template *tpnt) continue; } + if (!try_module_get(fc->module)) { + kfree(ages); + scsi_unregister(host); + continue; + } + nfcals++; - if (fc->module) __MOD_INC_USE_COUNT(fc->module); - fcal = (struct fcal *)host->hostdata; fc->fcp_register(fc, TYPE_SCSI_FCP, 0); @@ -193,7 +197,7 @@ int fcal_release(struct Scsi_Host *host) struct fcal *fcal = (struct fcal *)host->hostdata; fc_channel *fc = fcal->fc; - if (fc->module) __MOD_DEC_USE_COUNT(fc->module); + module_put(fc->module); fc->fcp_register(fc, TYPE_SCSI_FCP, 1); FCALND((" releasing fcal.\n")); diff --git a/drivers/scsi/pluto.c b/drivers/scsi/pluto.c index 84024bc0adb9..3c3452557f8b 100644 --- a/drivers/scsi/pluto.c +++ b/drivers/scsi/pluto.c @@ -232,10 +232,14 @@ int __init pluto_detect(Scsi_Host_Template *tpnt) continue; } + if (!try_module_get(fc->module)) { + kfree(ages); + scsi_unregister(host); + continue; + } + nplutos++; - if (fc->module) __MOD_INC_USE_COUNT(fc->module); - pluto = (struct pluto *)host->hostdata; host->max_id = inq->targets; diff --git a/drivers/serial/core.c b/drivers/serial/core.c index aacb4225f2e6..4e4c736318bb 100644 --- a/drivers/serial/core.c +++ b/drivers/serial/core.c @@ -1294,8 +1294,7 @@ static void uart_close(struct tty_struct *tty, struct file *filp) wake_up_interruptible(&info->open_wait); done: - if (drv->owner) - __MOD_DEC_USE_COUNT(drv->owner); + module_put(drv->owner); } static void uart_wait_until_sent(struct tty_struct *tty, int timeout) @@ -1665,8 +1664,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp) return retval; out: - if (drv->owner) - __MOD_DEC_USE_COUNT(drv->owner); + module_put(drv->owner); fail: return retval; } diff --git a/drivers/usb/media/ov511.c b/drivers/usb/media/ov511.c index 272b32873d7e..6d3c093afa1d 100644 --- a/drivers/usb/media/ov511.c +++ b/drivers/usb/media/ov511.c @@ -3278,19 +3278,23 @@ request_decompressor(struct usb_ov511 *ov) err("Unknown bridge"); } - if (ov->decomp_ops) { - if (!ov->decomp_ops->owner) { - ov->decomp_ops = NULL; - unlock_kernel(); - return -ENOSYS; - } - __MOD_INC_USE_COUNT(ov->decomp_ops->owner); - unlock_kernel(); - return 0; - } else { - unlock_kernel(); - return -ENOSYS; + if (!ov->decomp_ops) + goto nosys; + + if (!ov->decomp_ops->owner) { + ov->decomp_ops = NULL; + goto nosys; } + + if (!try_module_get(ov->decomp_ops->owner)) + goto nosys; + + unlock_kernel(); + return 0; + + nosys: + unlock_kernel(); + return -ENOSYS; } /* Unlocks decompression module and nulls ov->decomp_ops. Safe to call even @@ -3306,8 +3310,8 @@ release_decompressor(struct usb_ov511 *ov) lock_kernel(); - if (ov->decomp_ops && ov->decomp_ops->owner) { - __MOD_DEC_USE_COUNT(ov->decomp_ops->owner); + if (ov->decomp_ops) { + module_put(ov->decomp_ops->owner); released = 1; } diff --git a/drivers/usb/media/usbvideo.c b/drivers/usb/media/usbvideo.c index 6620d403ba9c..4c81b621ff76 100644 --- a/drivers/usb/media/usbvideo.c +++ b/drivers/usb/media/usbvideo.c @@ -730,6 +730,7 @@ EXPORT_SYMBOL(usbvideo_SayAndWait); /* ******************************************************************** */ +/* XXX: this piece of crap really wants some error handling.. */ static void usbvideo_ClientIncModCount(struct uvd *uvd) { if (uvd == NULL) { @@ -744,7 +745,10 @@ static void usbvideo_ClientIncModCount(struct uvd *uvd) err("%s: uvd->handle->md_module == NULL", __FUNCTION__); return; } - __MOD_INC_USE_COUNT(uvd->handle->md_module); + if (!try_module_get(uvd->handle->md_module)) { + err("%s: try_module_get() == 0", __FUNCTION__); + return; + } } static void usbvideo_ClientDecModCount(struct uvd *uvd) @@ -761,7 +765,7 @@ static void usbvideo_ClientDecModCount(struct uvd *uvd) err("%s: uvd->handle->md_module == NULL", __FUNCTION__); return; } - __MOD_DEC_USE_COUNT(uvd->handle->md_module); + module_put(uvd->handle->md_module); } int usbvideo_register( diff --git a/include/linux/mtd/map.h b/include/linux/mtd/map.h index 94ffed22315b..ad8dfcbda17d 100644 --- a/include/linux/mtd/map.h +++ b/include/linux/mtd/map.h @@ -81,10 +81,7 @@ static inline void map_destroy(struct mtd_info *mtd) if (map->fldrv->destroy) map->fldrv->destroy(mtd); -#ifdef CONFIG_MODULES - if (map->fldrv->module) - __MOD_DEC_USE_COUNT(map->fldrv->module); -#endif + module_put(map->fldrv->module); kfree(mtd); } diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h index ae5bfe3e10fb..52d38241e91e 100644 --- a/include/linux/mtd/mtd.h +++ b/include/linux/mtd/mtd.h @@ -224,8 +224,7 @@ static inline struct mtd_info *get_mtd_device(struct mtd_info *mtd, int num) static inline void put_mtd_device(struct mtd_info *mtd) { - if (mtd->module) - __MOD_DEC_USE_COUNT(mtd->module); + module_put(mtd->module); } diff --git a/net/core/dev.c b/net/core/dev.c index e48cb774fe0f..97e772ff5f82 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -703,8 +703,7 @@ int dev_open(struct net_device *dev) ret = dev->open(dev); if (ret) { clear_bit(__LINK_STATE_START, &dev->state); - if (dev->owner) - __MOD_DEC_USE_COUNT(dev->owner); + module_put(dev->owner); } } } else { @@ -829,16 +828,14 @@ int dev_close(struct net_device *dev) #endif /* - * Tell people we are down + * Tell people we are down */ notifier_call_chain(&netdev_chain, NETDEV_DOWN, dev); /* * Drop the module refcount */ - if (dev->owner) - __MOD_DEC_USE_COUNT(dev->owner); - + module_put(dev->owner); return 0; } diff --git a/net/ipv4/xfrm_policy.c b/net/ipv4/xfrm_policy.c index d21d597e7be1..fe30556f78d6 100644 --- a/net/ipv4/xfrm_policy.c +++ b/net/ipv4/xfrm_policy.c @@ -200,8 +200,7 @@ struct xfrm_type *xfrm_get_type(u8 proto) void xfrm_put_type(struct xfrm_type *type) { - if (type->owner) - __MOD_DEC_USE_COUNT(type->owner); + module_put(type->owner); } static inline unsigned long make_jiffies(long secs) diff --git a/net/rxrpc/call.c b/net/rxrpc/call.c index 6bba546eece7..a0e81b58191d 100644 --- a/net/rxrpc/call.c +++ b/net/rxrpc/call.c @@ -435,7 +435,7 @@ void rxrpc_put_call(struct rxrpc_call *call) rxrpc_put_message(msg); } - if (call->owner) __MOD_DEC_USE_COUNT(call->owner); + module_put(call->owner); down_write(&rxrpc_calls_sem); list_del(&call->call_link); diff --git a/sound/core/control.c b/sound/core/control.c index 6dce340429ff..7de5256c19fc 100644 --- a/sound/core/control.c +++ b/sound/core/control.c @@ -40,12 +40,6 @@ typedef struct _snd_kctl_ioctl { static DECLARE_RWSEM(snd_ioctl_rwsem); static LIST_HEAD(snd_control_ioctls); -static inline void dec_mod_count(struct module *module) -{ - if (module) - __MOD_DEC_USE_COUNT(module); -} - static int snd_ctl_open(struct inode *inode, struct file *file) { int cardnum = SNDRV_MINOR_CARD(minor(inode->i_rdev)); @@ -88,7 +82,7 @@ static int snd_ctl_open(struct inode *inode, struct file *file) return 0; __error: - dec_mod_count(card->module); + module_put(card->module); __error2: snd_card_file_remove(card, file); __error1: @@ -135,7 +129,7 @@ static int snd_ctl_release(struct inode *inode, struct file *file) up_write(&card->controls_rwsem); snd_ctl_empty_read_queue(ctl); snd_magic_kfree(ctl); - dec_mod_count(card->module); + module_put(card->module); snd_card_file_remove(card, file); #ifdef LINUX_2_2 MOD_DEC_USE_COUNT; diff --git a/sound/core/info.c b/sound/core/info.c index 808f46456976..0ae2541810a6 100644 --- a/sound/core/info.c +++ b/sound/core/info.c @@ -36,12 +36,6 @@ * */ -static inline void dec_mod_count(struct module *module) -{ - if (module) - __MOD_DEC_USE_COUNT(module); -} - int snd_info_check_reserved_words(const char *str) { static char *reserved[] = @@ -407,7 +401,7 @@ static int snd_info_entry_open(struct inode *inode, struct file *file) return 0; __error: - dec_mod_count(entry->module); + module_put(entry->module); __error1: #ifdef LINUX_2_2 MOD_DEC_USE_COUNT; @@ -450,7 +444,7 @@ static int snd_info_entry_release(struct inode *inode, struct file *file) data->file_private_data); break; } - dec_mod_count(entry->module); + module_put(entry->module); #ifdef LINUX_2_2 MOD_DEC_USE_COUNT; #endif diff --git a/sound/core/oss/mixer_oss.c b/sound/core/oss/mixer_oss.c index 0d6aecd9016c..088bf5ea33c1 100644 --- a/sound/core/oss/mixer_oss.c +++ b/sound/core/oss/mixer_oss.c @@ -34,12 +34,6 @@ MODULE_AUTHOR("Jaroslav Kysela "); MODULE_DESCRIPTION("Mixer OSS emulation for ALSA."); MODULE_LICENSE("GPL"); -static inline void dec_mod_count(struct module *module) -{ - if (module) - __MOD_DEC_USE_COUNT(module); -} - static int snd_mixer_oss_open(struct inode *inode, struct file *file) { int cardnum = SNDRV_MINOR_OSS_CARD(minor(inode->i_rdev)); @@ -82,7 +76,7 @@ static int snd_mixer_oss_release(struct inode *inode, struct file *file) if (file->private_data) { fmixer = (snd_mixer_oss_file_t *) file->private_data; - dec_mod_count(fmixer->card->module); + module_put(fmixer->card->module); #ifdef LINUX_2_2 MOD_DEC_USE_COUNT; #endif diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c index c6e18a7e0d0a..4febec2769c2 100644 --- a/sound/core/oss/pcm_oss.c +++ b/sound/core/oss/pcm_oss.c @@ -71,12 +71,6 @@ static inline void snd_leave_user(mm_segment_t fs) set_fs(fs); } -static inline void dec_mod_count(struct module *module) -{ - if (module) - __MOD_DEC_USE_COUNT(module); -} - int snd_pcm_oss_plugin_clear(snd_pcm_substream_t *substream) { snd_pcm_runtime_t *runtime = substream->runtime; @@ -1617,7 +1611,7 @@ static int snd_pcm_oss_open(struct inode *inode, struct file *file) return err; __error: - dec_mod_count(pcm->card->module); + module_put(pcm->card->module); __error2: snd_card_file_remove(pcm->card, file); __error1: @@ -1644,7 +1638,7 @@ static int snd_pcm_oss_release(struct inode *inode, struct file *file) snd_pcm_oss_release_file(pcm_oss_file); up(&pcm->open_mutex); wake_up(&pcm->open_wait); - dec_mod_count(pcm->card->module); + module_put(pcm->card->module); snd_card_file_remove(pcm->card, file); #ifdef LINUX_2_2 MOD_DEC_USE_COUNT; diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c index 773d3a10c567..57f2a9c0f4a2 100644 --- a/sound/core/pcm_native.c +++ b/sound/core/pcm_native.c @@ -76,14 +76,6 @@ static inline void snd_leave_user(mm_segment_t fs) set_fs(fs); } -static inline void dec_mod_count(struct module *module) -{ - if (module) - __MOD_DEC_USE_COUNT(module); -} - - - int snd_pcm_info(snd_pcm_substream_t * substream, snd_pcm_info_t *info) { snd_pcm_runtime_t * runtime; @@ -1833,7 +1825,7 @@ int snd_pcm_open(struct inode *inode, struct file *file) return err; __error: - dec_mod_count(pcm->card->module); + module_put(pcm->card->module); __error2: snd_card_file_remove(pcm->card, file); __error1: @@ -1863,7 +1855,7 @@ int snd_pcm_release(struct inode *inode, struct file *file) snd_pcm_release_file(pcm_file); up(&pcm->open_mutex); wake_up(&pcm->open_wait); - dec_mod_count(pcm->card->module); + module_put(pcm->card->module); snd_card_file_remove(pcm->card, file); #ifdef LINUX_2_2 MOD_DEC_USE_COUNT; diff --git a/sound/core/rawmidi.c b/sound/core/rawmidi.c index 18dc962f094d..a03924780f93 100644 --- a/sound/core/rawmidi.c +++ b/sound/core/rawmidi.c @@ -58,12 +58,6 @@ snd_rawmidi_t *snd_rawmidi_devices[SNDRV_CARDS * SNDRV_RAWMIDI_DEVICES]; static DECLARE_MUTEX(register_mutex); -static inline void dec_mod_count(struct module *module) -{ - if (module) - __MOD_DEC_USE_COUNT(module); -} - static inline unsigned short snd_rawmidi_file_flags(struct file *file) { switch (file->f_mode & (FMODE_READ | FMODE_WRITE)) { @@ -345,7 +339,7 @@ int snd_rawmidi_kernel_open(int cardnum, int device, int subdevice, snd_rawmidi_done_buffer(output); kfree(output); } - dec_mod_count(rmidi->card->module); + module_put(rmidi->card->module); up(&rmidi->open_mutex); __error1: #ifdef LINUX_2_2 @@ -504,7 +498,7 @@ int snd_rawmidi_kernel_release(snd_rawmidi_file_t * rfile) rmidi->streams[SNDRV_RAWMIDI_STREAM_OUTPUT].substream_opened--; } up(&rmidi->open_mutex); - dec_mod_count(rmidi->card->module); + module_put(rmidi->card->module); #ifdef LINUX_2_2 MOD_DEC_USE_COUNT; #endif diff --git a/sound/core/seq/oss/seq_oss_synth.c b/sound/core/seq/oss/seq_oss_synth.c index 9cc61a3cd426..837ef15abb69 100644 --- a/sound/core/seq/oss/seq_oss_synth.c +++ b/sound/core/seq/oss/seq_oss_synth.c @@ -83,12 +83,6 @@ static spinlock_t register_lock = SPIN_LOCK_UNLOCKED; static seq_oss_synth_t *get_synthdev(seq_oss_devinfo_t *dp, int dev); static void reset_channels(seq_oss_synthinfo_t *info); -static inline void dec_mod_count(struct module *module) -{ - if (module) - __MOD_DEC_USE_COUNT(module); -} - /* * global initialization */ @@ -245,7 +239,7 @@ snd_seq_oss_synth_setup(seq_oss_devinfo_t *dp) continue; } if (rec->oper.open(&info->arg, rec->private_data) < 0) { - dec_mod_count(rec->oper.owner); + module_put(rec->oper.owner); snd_use_lock_free(&rec->use_lock); continue; } @@ -322,7 +316,7 @@ snd_seq_oss_synth_cleanup(seq_oss_devinfo_t *dp) if (rec->opened) { debug_printk(("synth %d closed\n", i)); rec->oper.close(&info->arg); - dec_mod_count(rec->oper.owner); + module_put(rec->oper.owner); rec->opened--; } snd_use_lock_free(&rec->use_lock); diff --git a/sound/core/seq/seq_ports.c b/sound/core/seq/seq_ports.c index 8f5d7ed2b4d8..14943f8fecb8 100644 --- a/sound/core/seq/seq_ports.c +++ b/sound/core/seq/seq_ports.c @@ -55,12 +55,6 @@ much elements are in array. */ -static inline void dec_mod_count(struct module *module) -{ - if (module) - __MOD_DEC_USE_COUNT(module); -} - /* return pointer to port structure - port is locked if found */ client_port_t *snd_seq_port_use_ptr(client_t *client, int num) { @@ -413,7 +407,7 @@ static int subscribe_port(client_t *client, client_port_t *port, port_subs_info_ if (grp->open && (port->callback_all || grp->count == 1)) { err = grp->open(port->private_data, info); if (err < 0) { - dec_mod_count(port->owner); + module_put(port->owner); grp->count--; } } @@ -438,7 +432,7 @@ static int unsubscribe_port(client_t *client, client_port_t *port, if (send_ack && client->type == USER_CLIENT) snd_seq_client_notify_subscription(port->addr.client, port->addr.port, info, SNDRV_SEQ_EVENT_PORT_UNSUBSCRIBED); - dec_mod_count(port->owner); + module_put(port->owner); return err; } diff --git a/sound/core/seq/seq_virmidi.c b/sound/core/seq/seq_virmidi.c index d4fcb6aa085c..0719b6ad0ee8 100644 --- a/sound/core/seq/seq_virmidi.c +++ b/sound/core/seq/seq_virmidi.c @@ -53,12 +53,6 @@ MODULE_AUTHOR("Takashi Iwai "); MODULE_DESCRIPTION("Virtual Raw MIDI client on Sequencer"); MODULE_LICENSE("GPL"); -static inline void dec_mod_count(struct module *module) -{ - if (module) - __MOD_DEC_USE_COUNT(module); -} - /* * initialize an event record */ @@ -303,7 +297,7 @@ static int snd_virmidi_unsubscribe(void *private_data, snd_seq_port_subscribe_t rdev = snd_magic_cast(snd_virmidi_dev_t, private_data, return -EINVAL); rdev->flags &= ~SNDRV_VIRMIDI_SUBSCRIBE; - dec_mod_count(rdev->card->module); + module_put(rdev->card->module); return 0; } @@ -331,7 +325,7 @@ static int snd_virmidi_unuse(void *private_data, snd_seq_port_subscribe_t *info) rdev = snd_magic_cast(snd_virmidi_dev_t, private_data, return -EINVAL); rdev->flags &= ~SNDRV_VIRMIDI_USE; - dec_mod_count(rdev->card->module); + module_put(rdev->card->module); return 0; } diff --git a/sound/core/timer.c b/sound/core/timer.c index e16dfdda8a95..1b571b00728d 100644 --- a/sound/core/timer.c +++ b/sound/core/timer.c @@ -80,12 +80,6 @@ static int snd_timer_dev_unregister(snd_device_t *device); static void snd_timer_reschedule(snd_timer_t * timer, unsigned long ticks_left); -static inline void dec_mod_count(struct module *module) -{ - if (module) - __MOD_DEC_USE_COUNT(module); -} - /* * create a timer instance with the given owner string. * when timer is not NULL, increments the module counter @@ -325,7 +319,7 @@ int snd_timer_close(snd_timer_instance_t * timeri) kfree(timeri->owner); kfree(timeri); if (timer && timer->card) - dec_mod_count(timer->card->module); + module_put(timer->card->module); return 0; } diff --git a/sound/drivers/opl3/opl3_seq.c b/sound/drivers/opl3/opl3_seq.c index 2651522d72e5..c622456c6136 100644 --- a/sound/drivers/opl3/opl3_seq.c +++ b/sound/drivers/opl3/opl3_seq.c @@ -35,12 +35,6 @@ int use_internal_drums = 0; MODULE_PARM(use_internal_drums, "i"); MODULE_PARM_DESC(use_internal_drums, "Enable internal OPL2/3 drums."); -static inline void dec_mod_count(struct module *module) -{ - if (module) - __MOD_DEC_USE_COUNT(module); -} - int snd_opl3_synth_use_inc(opl3_t * opl3) { if (!try_inc_mod_count(opl3->card->module)) @@ -51,7 +45,7 @@ int snd_opl3_synth_use_inc(opl3_t * opl3) void snd_opl3_synth_use_dec(opl3_t * opl3) { - dec_mod_count(opl3->card->module); + module_put(opl3->card->module); } int snd_opl3_synth_setup(opl3_t * opl3) diff --git a/sound/isa/gus/gus_main.c b/sound/isa/gus/gus_main.c index 04fa4a649ab6..a3473afd0118 100644 --- a/sound/isa/gus/gus_main.c +++ b/sound/isa/gus/gus_main.c @@ -39,12 +39,6 @@ MODULE_LICENSE("GPL"); static int snd_gus_init_dma_irq(snd_gus_card_t * gus, int latches); -static inline void dec_mod_count(struct module *module) -{ - if (module) - __MOD_DEC_USE_COUNT(module); -} - int snd_gus_use_inc(snd_gus_card_t * gus) { MOD_INC_USE_COUNT; @@ -57,7 +51,7 @@ int snd_gus_use_inc(snd_gus_card_t * gus) void snd_gus_use_dec(snd_gus_card_t * gus) { - dec_mod_count(gus->card->module); + module_put(gus->card->module); MOD_DEC_USE_COUNT; } diff --git a/sound/isa/wavefront/wavefront_fx.c b/sound/isa/wavefront/wavefront_fx.c index 75aaca8a9fb9..817b6d807a86 100644 --- a/sound/isa/wavefront/wavefront_fx.c +++ b/sound/isa/wavefront/wavefront_fx.c @@ -33,13 +33,6 @@ #define FX_MSB_TRANSFER 0x02 /* transfer after DSP MSB byte written */ #define FX_AUTO_INCR 0x04 /* auto-increment DSP address after transfer */ -static inline void -dec_mod_count(struct module *module) -{ - if (module) - __MOD_DEC_USE_COUNT(module); -} - static int wavefront_fx_idle (snd_wavefront_t *dev) @@ -164,7 +157,7 @@ int snd_wavefront_fx_release (snd_hwdep_t *hw, struct file *file) { - dec_mod_count(hw->card->module); + module_put(hw->card->module); MOD_DEC_USE_COUNT; return 0; } diff --git a/sound/isa/wavefront/wavefront_synth.c b/sound/isa/wavefront/wavefront_synth.c index 5f0058dc08ca..f3e26ef9473f 100644 --- a/sound/isa/wavefront/wavefront_synth.c +++ b/sound/isa/wavefront/wavefront_synth.c @@ -233,13 +233,6 @@ static wavefront_command wavefront_commands[] = { { 0x00 } }; -static inline void -dec_mod_count(struct module *module) -{ - if (module) - __MOD_DEC_USE_COUNT(module); -} - static const char * wavefront_errorstr (int errnum) @@ -1623,7 +1616,7 @@ int snd_wavefront_synth_release (snd_hwdep_t *hw, struct file *file) { - dec_mod_count(hw->card->module); + module_put(hw->card->module); MOD_DEC_USE_COUNT; return 0; } diff --git a/sound/oss/audio.c b/sound/oss/audio.c index 74e3c282c14f..91101d990e49 100644 --- a/sound/oss/audio.c +++ b/sound/oss/audio.c @@ -88,19 +88,20 @@ int audio_open(int dev, struct file *file) return -ENXIO; driver = audio_devs[dev]->d; - if (driver->owner) - __MOD_INC_USE_COUNT(driver->owner); + + if (!try_module_get(driver->owner)) + return -ENODEV; if ((ret = DMAbuf_open(dev, mode)) < 0) goto error_1; if ( (coprocessor = audio_devs[dev]->coproc) != NULL ) { - if (coprocessor->owner) - __MOD_INC_USE_COUNT(coprocessor->owner); + if (!try_module_get(coprocessor->owner)) + goto error_2; if ((ret = coprocessor->open(coprocessor->devc, COPR_PCM)) < 0) { printk(KERN_WARNING "Sound: Can't access coprocessor device\n"); - goto error_2; + goto error_3; } } @@ -119,14 +120,14 @@ int audio_open(int dev, struct file *file) * Clean-up stack: this is what needs (un)doing if * we can't open the audio device ... */ + error_3: + module_put(coprocessor->owner); + error_2: - if (coprocessor->owner) - __MOD_DEC_USE_COUNT(coprocessor->owner); DMAbuf_release(dev, mode); error_1: - if (driver->owner) - __MOD_DEC_USE_COUNT(driver->owner); + module_put(driver->owner); return ret; } @@ -200,14 +201,11 @@ void audio_release(int dev, struct file *file) if ( (coprocessor = audio_devs[dev]->coproc) != NULL ) { coprocessor->close(coprocessor->devc, COPR_PCM); - - if (coprocessor->owner) - __MOD_DEC_USE_COUNT(coprocessor->owner); + module_put(coprocessor->owner); } DMAbuf_release(dev, mode); - if (audio_devs[dev]->d->owner) - __MOD_DEC_USE_COUNT (audio_devs[dev]->d->owner); + module_put(audio_devs[dev]->d->owner); } static void translate_bytes(const unsigned char *table, unsigned char *buff, int n) diff --git a/sound/oss/midibuf.c b/sound/oss/midibuf.c index 58b330ecad1f..30f8c7f67971 100644 --- a/sound/oss/midibuf.c +++ b/sound/oss/midibuf.c @@ -170,8 +170,7 @@ int MIDIbuf_open(int dev, struct file *file) * Interrupts disabled. Be careful */ - if (midi_devs[dev]->owner) - __MOD_INC_USE_COUNT (midi_devs[dev]->owner); + module_put(midi_devs[dev]->owner); if ((err = midi_devs[dev]->open(dev, mode, midi_input_intr, midi_output_intr)) < 0) @@ -254,8 +253,7 @@ void MIDIbuf_release(int dev, struct file *file) midi_in_buf[dev] = NULL; midi_out_buf[dev] = NULL; - if (midi_devs[dev]->owner) - __MOD_DEC_USE_COUNT (midi_devs[dev]->owner); + module_put(midi_devs[dev]->owner); } int MIDIbuf_write(int dev, struct file *file, const char *buf, int count) diff --git a/sound/oss/mpu401.c b/sound/oss/mpu401.c index a8817a2d8d02..c8d9d59ef915 100644 --- a/sound/oss/mpu401.c +++ b/sound/oss/mpu401.c @@ -498,8 +498,10 @@ static int mpu401_open(int dev, int mode, if ( (coprocessor = midi_devs[dev]->coproc) != NULL ) { - if (coprocessor->owner) - __MOD_INC_USE_COUNT(coprocessor->owner); + if (!try_module_get(coprocessor->owner)) { + mpu401_close(dev); + return err; + } if ((err = coprocessor->open(coprocessor->devc, COPR_MIDI)) < 0) { @@ -537,9 +539,7 @@ static void mpu401_close(int dev) coprocessor = midi_devs[dev]->coproc; if (coprocessor) { coprocessor->close(coprocessor->devc, COPR_MIDI); - - if (coprocessor->owner) - __MOD_DEC_USE_COUNT(coprocessor->owner); + module_put(coprocessor->owner); } devc->opened = 0; } @@ -838,8 +838,8 @@ static int mpu_synth_open(int dev, int mode) coprocessor = midi_devs[midi_dev]->coproc; if (coprocessor) { - if (coprocessor->owner) - __MOD_INC_USE_COUNT(coprocessor->owner); + if (!try_module_get(coprocessor->owner)) + return err; if ((err = coprocessor->open(coprocessor->devc, COPR_MIDI)) < 0) { @@ -876,9 +876,7 @@ static void mpu_synth_close(int dev) coprocessor = midi_devs[midi_dev]->coproc; if (coprocessor) { coprocessor->close(coprocessor->devc, COPR_MIDI); - - if (coprocessor->owner) - __MOD_DEC_USE_COUNT(coprocessor->owner); + module_put(coprocessor->owner); } devc->opened = 0; devc->mode = 0; diff --git a/sound/oss/sequencer.c b/sound/oss/sequencer.c index 860e21734e9e..8a2f0055f1ac 100644 --- a/sound/oss/sequencer.c +++ b/sound/oss/sequencer.c @@ -1041,8 +1041,8 @@ int sequencer_open(int dev, struct file *file) if (synth_devs[i]==NULL) continue; - if (synth_devs[i]->owner) - __MOD_INC_USE_COUNT (synth_devs[i]->owner); + if (!try_module_get(synth_devs[i]->owner)) + continue; if ((tmp = synth_devs[i]->open(i, mode)) < 0) { @@ -1072,8 +1072,8 @@ int sequencer_open(int dev, struct file *file) for (i = 0; i < max_mididev; i++) if (!midi_opened[i] && midi_devs[i]) { - if (midi_devs[i]->owner) - __MOD_INC_USE_COUNT (midi_devs[i]->owner); + if (!try_module_get(midi_devs[i]->owner)) + continue; if ((retval = midi_devs[i]->open(i, mode, sequencer_midi_input, sequencer_midi_output)) >= 0) @@ -1084,9 +1084,8 @@ int sequencer_open(int dev, struct file *file) } if (seq_mode == SEQ_2) { - if (tmr->owner) - __MOD_INC_USE_COUNT (tmr->owner); - tmr->open(tmr_no, seq_mode); + if (try_module_get(tmr->owner)) + tmr->open(tmr_no, seq_mode); } init_waitqueue_head(&seq_sleeper); @@ -1169,8 +1168,7 @@ void sequencer_release(int dev, struct file *file) { synth_devs[i]->close(i); - if (synth_devs[i]->owner) - __MOD_DEC_USE_COUNT (synth_devs[i]->owner); + module_put(synth_devs[i]->owner); if (synth_devs[i]->midi_dev) midi_opened[synth_devs[i]->midi_dev] = 0; @@ -1181,15 +1179,13 @@ void sequencer_release(int dev, struct file *file) { if (midi_opened[i]) { midi_devs[i]->close(i); - if (midi_devs[i]->owner) - __MOD_DEC_USE_COUNT (midi_devs[i]->owner); + module_put(midi_devs[i]->owner); } } if (seq_mode == SEQ_2) { tmr->close(tmr_no); - if (tmr->owner) - __MOD_DEC_USE_COUNT (tmr->owner); + module_put(tmr->owner); } if (obsolete_api_used) diff --git a/sound/oss/soundcard.c b/sound/oss/soundcard.c index 4d29d0ec11a5..89988a1b3814 100644 --- a/sound/oss/soundcard.c +++ b/sound/oss/soundcard.c @@ -222,9 +222,9 @@ static int sound_open(struct inode *inode, struct file *file) } if (dev && (dev >= num_mixers || mixer_devs[dev] == NULL)) return -ENXIO; - - if (mixer_devs[dev]->owner) - __MOD_INC_USE_COUNT (mixer_devs[dev]->owner); + + if (!try_module_get(mixer_devs[dev]->owner)) + return -ENXIO; break; case SND_DEV_SEQ: @@ -261,9 +261,7 @@ static int sound_release(struct inode *inode, struct file *file) DEB(printk("sound_release(dev=%d)\n", dev)); switch (dev & 0x0f) { case SND_DEV_CTL: - dev >>= 4; - if (mixer_devs[dev]->owner) - __MOD_DEC_USE_COUNT (mixer_devs[dev]->owner); + module_put(mixer_devs[dev >> 4]->owner); break; case SND_DEV_SEQ: diff --git a/sound/synth/emux/emux_seq.c b/sound/synth/emux/emux_seq.c index 3175511d87f9..0dd6ef8c376c 100644 --- a/sound/synth/emux/emux_seq.c +++ b/sound/synth/emux/emux_seq.c @@ -61,12 +61,6 @@ static snd_midi_op_t emux_ops = { /* */ -static inline void dec_mod_count(struct module *module) -{ - if (module) - __MOD_DEC_USE_COUNT(module); -} - /* * Initialise the EMUX Synth by creating a client and registering * a series of ports. @@ -283,7 +277,7 @@ snd_emux_inc_count(snd_emux_t *emu) if (!try_inc_mod_count(emu->ops.owner)) goto __error; if (!try_inc_mod_count(emu->card->module)) { - dec_mod_count(emu->ops.owner); + module_put(emu->ops.owner); __error: emu->used--; return 0; @@ -298,11 +292,11 @@ snd_emux_inc_count(snd_emux_t *emu) void snd_emux_dec_count(snd_emux_t *emu) { - dec_mod_count(emu->ops.owner); + module_put(emu->ops.owner); emu->used--; if (emu->used <= 0) snd_emux_terminate_all(emu); - dec_mod_count(emu->card->module); + module_put(emu->card->module); } -- cgit v1.2.3