diff --git a/mkpatch/Config.in b/mkpatch/Config.in new file mode 100644 index 00000000..c5eba054 --- /dev/null +++ b/mkpatch/Config.in @@ -0,0 +1,25 @@ +# +# Character device configuration +# +mainmenu_option next_comment +comment 'Hardware sensors support' + +dep_tristate 'Hardware sensors support' CONFIG_SENSORS $CONFIG_I2C + +if [ "$CONFIG_SENSORS" != "n" ]; then + dep_tristate ' Analog Devices ADM1021 and compatibles' CONFIG_SENSORS_ADM1021 $CONFIG_SENSORS + dep_tristate ' Analog Devices ADM9240 and compatibles' CONFIG_SENSORS_ADM9240 $CONFIG_SENSORS + dep_tristate ' Genesys Logic GL518SM' CONFIG_SENSORS_GL518SM $CONFIG_SENSORS + dep_tristate ' National Semiconductors LM75' CONFIG_SENSORS_LM75 $CONFIG_SENSORS + dep_tristate ' National Semiconductors LM78' CONFIG_SENSORS_LM78 $CONFIG_SENSORS + dep_tristate ' National Semiconductors LM80' CONFIG_SENSORS_LM80 $CONFIG_SENSORS + dep_tristate ' Silicon Integrated Systems Corp. SiS5595' CONFIG_SENSORS_SIS5595 $CONFIG_SENSORS + dep_tristate ' Western Digital W83781D, W83782D and W83783S' CONFIG_SENSORS_W83781D $CONFIG_SENSORS + dep_bool ' Other I2C devices' CONFIG_SENSORS_OTHER CONFIG_SENSORS + if [ "$CONFIG_SENSORS_OTHER" = "y" ] ; then + dep_tristate ' EEprom (DIMM) reader ' CONFIG_SENSORS_EEPROM $CONFIG_SENSORS_OTHER + dep_tristate ' Linear Technologies LTC1710 ' CONFIG_SENSORS_LTC1710 $CONFIG_SENSORS_OTHER + fi +fi + +endmenu diff --git a/mkpatch/FILES b/mkpatch/FILES new file mode 100644 index 00000000..c3a76f4e --- /dev/null +++ b/mkpatch/FILES @@ -0,0 +1,17 @@ +kernel/busses/i2c-ali15x3.c drivers/i2c/i2c-ali15x3.c +kernel/busses/i2c-hydra.c drivers/i2c/i2c-hydra.c +kernel/busses/i2c-isa.c drivers/i2c/i2c-isa.c +kernel/busses/i2c-piix4.c drivers/i2c/i2c-piix4.c +kernel/busses/i2c-via.c drivers/i2c/i2c-via.c +kernel/sensors.c drivers/sensors/sensors.c +kernel/chips/adm1021.c drivers/sensors/adm1021.c +kernel/chips/adm9024.c drivers/sensors/adm9024.c +kernel/chips/gl518sm.c drivers/sensors/gl518sm.c +kernel/chips/lm75.c drivers/sensors/lm75.c +kernel/chips/lm78.c drivers/sensors/lm78.c +kernel/chips/lm80.c drivers/sensors/lm80.c +kernel/chips/ltc1710.c drivers/sensors/ltc1710.c +kernel/chips/sis5595.c drivers/sensors/sis5595.c +kernel/chips/w83781d.c drivers/sensors/w83781d.c +kernel/include/i2c-isa.h include/linux/i2c-isa.h +kernel/include/sensors.h include/linux/sensors.h diff --git a/mkpatch/INCLUDES b/mkpatch/INCLUDES new file mode 100644 index 00000000..e8ff8c0f --- /dev/null +++ b/mkpatch/INCLUDES @@ -0,0 +1,2 @@ +"i2c-isa.h" +"sensors.h" diff --git a/mkpatch/Makefile b/mkpatch/Makefile new file mode 100644 index 00000000..30d5273f --- /dev/null +++ b/mkpatch/Makefile @@ -0,0 +1,109 @@ +# +# Makefile for the kernel hardware sensors drivers. +# + +SUB_DIRS := +MOD_SUB_DIRS := $(SUB_DIRS) +ALL_SUB_DIRS := $(SUB_DIRS) +MOD_LIST_NAME := MISC_MODULES + +L_TARGET := sensors.a +MX_OBJS := +M_OBJS := +LX_OBJS := +L_OBJS := + +# ----- +# i2c core components +# ----- + +ifeq ($(CONFIG_SENSORS),y) + LX_OBJS += sensors.o +else + ifeq ($(CONFIG_SENSORS),m) + MX_OBJS += sensors.o + endif +endif + +ifeq ($(CONFIG_SENSORS_ADM1021),y) + L_OBJS += adm1021.o +else + ifeq ($(CONFIG_SENSORS_ADM1021),m) + M_OBJS += adm1021.o + endif +endif + +ifeq ($(CONFIG_SENSORS_ADM9024),y) + L_OBJS += adm9024.o +else + ifeq ($(CONFIG_SENSORS_ADM9024),m) + M_OBJS += adm9024.o + endif +endif + +ifeq ($(CONFIG_SENSORS_EEPROM),y) + L_OBJS += eeprom.o +else + ifeq ($(CONFIG_SENSORS_EEPROM),m) + M_OBJS += eeprom.o + endif +endif + +ifeq ($(CONFIG_SENSORS_GL518SM),y) + L_OBJS += gl518sm.o +else + ifeq ($(CONFIG_SENSORS_GL518SM),m) + M_OBJS += gl518sm.o + endif +endif + +ifeq ($(CONFIG_SENSORS_LM75),y) + L_OBJS += lm75.o +else + ifeq ($(CONFIG_SENSORS_LM75),m) + M_OBJS += lm75.o + endif +endif + +ifeq ($(CONFIG_SENSORS_LM78),y) + L_OBJS += lm78.o +else + ifeq ($(CONFIG_SENSORS_LM78),m) + M_OBJS += lm78.o + endif +endif + +ifeq ($(CONFIG_SENSORS_LM80),y) + L_OBJS += lm80.o +else + ifeq ($(CONFIG_SENSORS_LM80),m) + M_OBJS += lm80.o + endif +endif + +ifeq ($(CONFIG_SENSORS_LTC1710),y) + L_OBJS += ltc1710.o +else + ifeq ($(CONFIG_SENSORS_LTC1710),m) + M_OBJS += ltc1710.o + endif +endif + +ifeq ($(CONFIG_SENSORS_SIS5595),y) + L_OBJS += sis5595.o +else + ifeq ($(CONFIG_SENSORS_SIS5595),m) + M_OBJS += sis5595.o + endif +endif + +ifeq ($(CONFIG_SENSORS_W83781D),y) + L_OBJS += w83781d.o +else + ifeq ($(CONFIG_SENSORS_W83781D),m) + M_OBJS += w83781d.o + endif +endif + +include $(TOPDIR)/Rules.make + diff --git a/mkpatch/mkpatch.pl b/mkpatch/mkpatch.pl new file mode 100755 index 00000000..f8997939 --- /dev/null +++ b/mkpatch/mkpatch.pl @@ -0,0 +1,278 @@ +#!/usr/bin/perl + +# mkpatch - Create patches against the Linux kernel +# Copyright (c) 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. + +use strict; + +# $_[0]: sensors package root (like /tmp/sensors) +# $_[1]: Linux kernel tree (like /usr/src/linux) +# $_[2]: Name of the kernel file +# $_[3]: Name of the patched file +sub print_diff +{ + my ($package_root,$kernel_root,$kernel_file,$package_file) = @_; + my ($diff_command,$dummy); + + $diff_command = "diff -u2 $kernel_root/$kernel_file "; + $diff_command .= "$package_root/$package_file"; + open INPUT, "$diff_command|"; + $dummy = ; + $dummy = ; + print "--- linux-old/$kernel_file\t".`date`; + print "+++ linux/$kernel_file\t".`date`; + + while () { + print; + } + close INPUT; +} + +# $_[0]: sensors package root (like /tmp/sensors) +# $_[1]: Linux kernel tree (like /usr/src/linux) +sub gen_Makefile +{ + my ($package_root,$kernel_root) = @_; + my $kernel_file = "Makefile"; + my $package_file = "mkpatch/.temp"; + + open INPUT,"$kernel_root/$kernel_file" + or die "Can't open `$kernel_root/$kernel_file'"; + open OUTPUT,">$package_root/mkpatch/.temp" + or die "Can't open $package_root/$package_file"; + while() { + if (m@CONFIG_SENSORS@) { + $_ = while not m@endif@; + $_ = ; + $_ = if m@^$@; + } + if (m@include arch/\$\(ARCH\)/Makefile@) { + print OUTPUT <<'EOF'; +ifeq ($(CONFIG_SENSORS),y) +DRIVERS := $(DRIVERS) drivers/sensors/sensors.a +endif + +EOF + } + print OUTPUT; + } + close INPUT; + close OUTPUT; + print_diff $package_root,$kernel_root,$kernel_file,$package_file; +} + +# $_[0]: sensors package root (like /tmp/sensors) +# $_[1]: Linux kernel tree (like /usr/src/linux) +sub gen_drivers_Makefile +{ + my ($package_root,$kernel_root) = @_; + my $kernel_file = "drivers/Makefile"; + my $package_file = "mkpatch/.temp"; + my $sensors_present; + + open INPUT,"$kernel_root/$kernel_file" + or die "Can't open `$kernel_root/$kernel_file'"; + open OUTPUT,">$package_root/mkpatch/.temp" + or die "Can't open $package_root/$package_file"; + while() { + if (m@^ALL_SUB_DIRS\s*:=@) { + $sensors_present = 0; + while (m@\\$@) { + $sensors_present = 1 if m@sensors@; + print OUTPUT; + $_ = ; + } + $sensors_present = 1 if m@sensors@; + s@$@ sensors@ if (not $sensors_present); + } + if (m@CONFIG_SENSORS@) { + $_ = while not m@^endif@; + $_ = ; + $_ = if m@^$@; + } + if (m@^include \$\(TOPDIR\)/Rules.make$@) { + print OUTPUT <<'EOF'; +ifeq ($(CONFIG_SENSORS),y) +SUB_DIRS += sensors +MOD_SUB_DIRS += sensors +else + ifeq ($(CONFIG_SENSORS),m) + MOD_SUB_DIRS += sensors + endif +endif + +EOF + } + print OUTPUT; + } + close INPUT; + close OUTPUT; + print_diff $package_root,$kernel_root,$kernel_file,$package_file; +} + +# $_[0]: sensors package root (like /tmp/sensors) +# $_[1]: Linux kernel tree (like /usr/src/linux) +sub gen_drivers_char_Config_in +{ + my ($package_root,$kernel_root) = @_; + my $kernel_file = "drivers/char/Config.in"; + my $package_file = "mkpatch/.temp"; + my $ready = 0; + my $done = 0; + + open INPUT,"$kernel_root/$kernel_file" + or die "Can't open `$kernel_root/$kernel_file'"; + open OUTPUT,">$package_root/mkpatch/.temp" + or die "Can't open $package_root/$package_file"; + while() { + if (m@source drivers/i2c/Config.in@) { + print OUTPUT; + $_ = 'source drivers/sensors/Config.in'; + } + if (m@sensors@) { + $_ = ; + $_ = if (m@^$@); + } + } + close INPUT; + close OUTPUT; + print_diff $package_root,$kernel_root,$kernel_file,$package_file; +} + + +# $_[0]: sensors package root (like /tmp/sensors) +# $_[1]: Linux kernel tree (like /usr/src/linux) +sub gen_drivers_char_mem_c +{ + my ($package_root,$kernel_root) = @_; + my $kernel_file = "drivers/char/mem.c"; + my $package_file = "mkpatch/.temp"; + my $right_place = 0; + my $with_video = 0; + my $done = 0; + my $atstart = 1; + + open INPUT,"$kernel_root/$kernel_file" + or die "Can't open `$kernel_root/$kernel_file'"; + open OUTPUT,">$package_root/mkpatch/.temp" + or die "Can't open $package_root/$package_file"; + while() { + if ($atstart and m@#ifdef@) { + print OUTPUT << 'EOF'; +#ifdef CONFIG_I2C +extern void i2c_init_all(void); +#endif +EOF + $atstart = 0; + } + if (not $right_place and m@CONFIG_I2C@) { + $_ = while not m@#endif@; + $_ = ; + } + $with_video = 1 if m@CONFIG_VIDEO_BT848@; + $right_place = 1 if (m@lp_init\(\);@); + if ($right_place and not $done and + (m@CONFIG_I2C@ or m@CONFIG_VIDEO_BT848@ or m@return 0;@)) { + if (not m@return 0;@) { + $_ = while not m@#endif@; + $_ = ; + $_ = if m@^$@; + } + if ($with_video) { + print OUTPUT '#if defined(CONFIG_I2C) || defined(CONFIG_VIDEO_BT848)'; + } else { + print OUTPUT '#ifdef CONFIG_I2C'; + } + print OUTPUT <<'EOF'; + + i2c_init_all(); +#endif + +EOF + $done = 1; + } + print OUTPUT; + } + close INPUT; + close OUTPUT; + print_diff $package_root,$kernel_root,$kernel_file,$package_file; +} + + +sub main +{ + my ($package_root,$kernel_root,%files,%includes,$package_file,$kernel_file); + my ($diff_command,$dummy,$data0,$data1,$sedscript); + + # --> Read the command-lineo + $package_root = $ARGV[0]; + die "Package root `$package_root' is not found\n" + unless -d "$package_root/mkpatch"; + $kernel_root = $ARGV[1]; + die "Kernel root `$kernel_root' is not found\n" + unless -f "$kernel_root/Rules.make"; + + # --> Read FILES + open INPUT, "$package_root/mkpatch/FILES" + or die "Can't open `$package_root/mkpatch/FILES'"; + while () { + ($data0,$data1) = /(\S+)\s+(\S+)/; + $files{$data0} = $data1; + } + close INPUT; + + # --> Read INCLUDES + open INPUT, "$package_root/mkpatch/INCLUDES" + or die "Can't open `$package_root/mkpatch/INCLUDES'"; + while () { + ($data0,$data1) = /(\S+)\s+(\S+)/; + $includes{$data0} = $data1; + $sedscript .= 's,(#\s*include\s*)'.$data0.'(\s*),\1'."$data1".'\2, ; '; + } + close INPUT; + + # --> Start generating + foreach $package_file (keys %files) { + $kernel_file = $files{$package_file}; + $diff_command = "diff -u2 "; + if ( -f "$kernel_root/$kernel_file") { + $diff_command .= "$kernel_root/$kernel_file"; + } else { + $diff_command .= "/dev/null"; + } + $diff_command .= " $package_root/$package_file"; + open INPUT, "$diff_command|"; + $dummy = ; + $dummy = ; + print "--- linux-old/$kernel_file\t".`date`; + print "+++ linux/$kernel_file\t".`date`; + + while () { + eval $sedscript; + print; + } + close INPUT; + } + + gen_Makefile $package_root, $kernel_root; + gen_drivers_Makefile $package_root, $kernel_root; + gen_drivers_char_Config_in $package_root, $kernel_root; +# gen_drivers_char_mem_c $package_root, $kernel_root; +} + +main; +