root/lm-sensors/trunk/mkpatch/mkpatch.pl @ 706

Revision 706, 24.2 KB (checked in by frodo, 14 years ago)

Removal of kernel 2.0 and 2.1 compatibility: pass three

Modified mkpatch and documentation

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
Line 
1#!/usr/bin/perl
2
3#    mkpatch - Create patches against the Linux kernel
4#    Copyright (c) 1999  Frodo Looijaard <frodol@dds.nl>
5#
6#    This program is free software; you can redistribute it and/or modify
7#    it under the terms of the GNU General Public License as published by
8#    the Free Software Foundation; either version 2 of the License, or
9#    (at your option) any later version.
10#
11#    This program is distributed in the hope that it will be useful,
12#    but WITHOUT ANY WARRANTY; without even the implied warranty of
13#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14#    GNU General Public License for more details.
15#
16#    You should have received a copy of the GNU General Public License
17#    along with this program; if not, write to the Free Software
18#    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19
20use strict;
21
22use vars qw($temp);
23$temp = "mkpatch/.temp";
24
25# Generate a diff between the old kernel file and the new I2C file. We
26# arrange the headers to tell us the old tree was under directory
27# `linux-old', and the new tree under `linux'.
28# $_[0]: sensors package root (like /tmp/sensors)
29# $_[1]: Linux kernel tree (like /usr/src/linux)
30# $_[2]: Name of the kernel file
31# $_[3]: Name of the patched file
32sub print_diff
33{
34  my ($package_root,$kernel_root,$kernel_file,$package_file) = @_;
35  my ($diff_command,$dummy);
36
37  $diff_command = "diff -u2";
38  if ( -e "$kernel_root/$kernel_file") {
39    $diff_command .= " $kernel_root/$kernel_file ";
40  } else {
41    $diff_command .= " /dev/null ";
42  }
43  if ( -e "$package_root/$package_file") {
44    $diff_command .= " $package_root/$package_file ";
45  } else {
46    $diff_command .= " /dev/null";
47  }
48  open INPUT, "$diff_command|" or die "Can't execute `$diff_command'";
49  $dummy = <INPUT>;
50  $dummy = <INPUT>;
51  print "--- linux-old/$kernel_file\t".`date`;
52  print "+++ linux/$kernel_file\t".`date`;
53   
54  while (<INPUT>) {
55    print;
56  }
57  close INPUT;
58}
59
60# This generates diffs for kernel file Documentation/Configure.help. This
61# file contains the help texts that can be displayed during `make *config'
62# for the kernel.
63# The new texts are put at the end of the file, or just before the
64# lm_sensors texts.
65# Of course, care is taken old lines are removed.
66# $_[0]: i2c package root (like /tmp/i2c)
67# $_[1]: Linux kernel tree (like /usr/src/linux)
68sub gen_Documentation_Configure_help
69{
70  my ($package_root,$kernel_root) = @_;
71  my $kernel_file = "Documentation/Configure.help";
72  my $package_file = $temp;
73
74  open INPUT,"$kernel_root/$kernel_file"
75        or die "Can't open `$kernel_root/$kernel_file'";
76  open OUTPUT,">$package_root/$package_file"
77        or die "Can't open $package_root/$package_file";
78  MAIN: while(<INPUT>) {
79    if (m@I2C mainboard interfaces@ or 
80           m@Acer Labs ALI 1533 and 1543C@ or
81           m@Apple Hydra Mac I/O@ or
82           m@Intel 82371AB PIIX4\(E\)@ or
83           m@VIA Technologies, Inc. VT82C586B@ or
84           m@Pseudo ISA adapter \(for hardware sensors modules\)@ or
85           m@Analog Devices ADM1021 and compatibles@ or
86           m@Analog Devices ADM9240 and compatibles@ or
87           m@Genesys Logic GL518SM@ or
88           m@National Semiconductors LM75@ or
89           m@National Semiconductors LM78@ or
90           m@National Semiconductors LM80@ or
91           m@Silicon Integrated Systems Corp. SiS5595@ or
92           m@Winbond W83781D, W83782D and W83783S@ or
93           m@EEprom \(DIMM\) reader@ or
94           m@Linear Technologies LTC1710@) {
95      $_ = <INPUT>;
96      $_ = <INPUT>;
97      $_ = <INPUT> while not m@^\S@ and not eof(INPUT);
98      redo MAIN;
99    }
100    if (eof(INPUT)) {
101      print OUTPUT <<'EOF'
102I2C mainboard interfaces
103CONFIG_I2C_MAINBOARD
104  Many modern mainboards have some kind of I2C interface integrated. This
105  is often in the form of a SMBus, or System Management Bus, which is
106  basically the same as I2C but which uses only a subset of the I2C
107  protocol.
108
109  You will also want the latest user-space utilties: you can find them
110  in the lm_sensors package, which you can download at
111  http://www.lm-sensors.nu
112
113Acer Labs ALI 1533 and 1543C
114CONFIG_I2C_ALI15X3
115  If you say yes to this option, support will be included for the Acer
116  Labs ALI 1533 and 1543C mainboard I2C interfaces. This can also be
117  built as a module which can be inserted and removed while the kernel
118  is running.
119
120Apple Hydra Mac I/O
121CONFIG_I2C_HYDRA
122  If you say yes to this option, support will be included for the
123  Hydra mainboard I2C interface. This can also be built as a module
124  which can be inserted and removed while the kernel is running.
125
126Intel 82371AB PIIX4(E)
127CONFIG_I2C_PIIX4
128  If you say yes to this option, support will be included for the
129  Intel PIIX4 and PIIX4E mainboard I2C interfaces. This can also be
130  built as a module which can be inserted and removed while the kernel
131  is running.
132
133VIA Technologies, Inc. VT82C586B
134CONFIG_I2C_VIA
135  If you say yes to this option, support will be included for the VIA
136  Technologies I2C adapter found on some motherboards. This can also
137  be built as a module which can be inserted and removed while the
138  kernel is running.
139
140Pseudo ISA adapter (for hardware sensors modules)
141CONFIG_I2C_ISA
142  This provides support for accessing some hardware sensor chips over
143  the ISA bus rather than the I2C or SMBus. If you want to do this,
144  say yes here. This feature can also be built as a module which can
145  be inserted and removed while the kernel is running.
146
147  You will also need the latest user-space utilties: you can find them
148  in the lm_sensors package, which you can download at
149  http://www.lm-sensors.nu
150
151Analog Devices ADM1021 and compatibles
152CONFIG_SENSORS_ADM1021
153  If you say yes here you get support for Analog Devices ADM1021
154  sensor chips and clones: the Maxim MAX1617 and MAX1617A, the
155  TI THMC10 and the XEON processor built-in sensor. This can also
156  be built as a module which can be inserted and removed while the
157  kernel is running.
158
159  You will also need the latest user-space utilties: you can find them
160  in the lm_sensors package, which you can download at
161  http://www.lm-sensors.nu
162
163Analog Devices ADM9240 and compatibles
164CONFIG_SENSORS_ADM9240
165  If you say yes here you get support for Analog Devices ADM9240
166  sensor chips and clones: the Dallas Semiconductors DS1780 and
167  the National Semiconductors LM81. This can also be built as a
168  module which can be inserted and removed while the kernel is
169  running.
170
171  You will also need the latest user-space utilties: you can find them
172  in the lm_sensors package, which you can download at
173  http://www.lm-sensors.nu
174
175Genesys Logic GL518SM
176CONFIG_SENSORS_GL518SM
177  If you say yes here you get support for Genesys Logic GL518SM sensor
178  chips.  This can also be built as a module which can be inserted and
179  removed while the kernel is running.
180
181  You will also need the latest user-space utilties: you can find them
182  in the lm_sensors package, which you can download at
183  http://www.lm-sensors.nu
184
185National Semiconductors LM75
186CONFIG_SENSORS_LM75
187  If you say yes here you get support for National Semiconductor LM75
188  sensor chips. This can also be built as a module which can be
189  inserted and removed while the kernel is running.
190
191  You will also need the latest user-space utilties: you can find them
192  in the lm_sensors package, which you can download at
193  http://www.lm-sensors.nu
194
195National Semiconductors LM78
196CONFIG_SENSORS_LM78
197  If you say yes here you get support for National Semiconductor LM78
198  sensor chips family: the LM78-J and LM79. Many clone chips will
199  also work at least somewhat with this driver. This can also be built
200  as a module which can be inserted and removed while the kernel is
201  running.
202
203  You will also need the latest user-space utilties: you can find them
204  in the lm_sensors package, which you can download at
205  http://www.lm-sensors.nu
206
207National Semiconductors LM80
208CONFIG_SENSORS_LM80
209  If you say yes here you get support for National Semiconductor LM80
210  sensor chips. This can also be built as a module which can be
211  inserted and removed while the kernel is running.
212
213  You will also need the latest user-space utilties: you can find them
214  in the lm_sensors package, which you can download at
215  http://www.lm-sensors.nu
216
217Silicon Integrated Systems Corp. SiS5595
218CONFIG_SENSORS_SIS5595
219  If you say yes here you get support for Silicon Integrated Systems
220  Corp.  SiS5595 sensor chips. This can also be built as a module
221  which can be inserted and removed while the kernel is running.
222
223  You will also need the latest user-space utilties: you can find them
224  in the lm_sensors package, which you can download at
225  http://www.lm-sensors.nu
226
227Winbond W83781D, W83782D and W83783S
228CONFIG_SENSORS_W83781D
229  If you say yes here you get support for the Winbond W8378x series
230  of sensor chips: the W83781D, W83782D, W83783S and W83682HF. This
231  can also be built as a module which can be inserted and removed
232  while the kernel is running.
233
234  You will also need the latest user-space utilties: you can find them
235  in the lm_sensors package, which you can download at
236  http://www.lm-sensors.nu
237
238EEprom (DIMM) reader
239CONFIG_SENSORS_EEPROM
240  If you say yes here you get read-only access to the EEPROM data
241  available on modern memory DIMMs, and which could theoretically
242  also be available on other devices. This can also be built as a
243  module which can be inserted and removed while the kernel is
244  running.
245
246  You will also need the latest user-space utilties: you can find them
247  in the lm_sensors package, which you can download at
248  http://www.lm-sensors.nu
249
250Linear Technologies LTC1710
251CONFIG_SENSORS_LTC1710
252  If you say yes here you get support for Linear Technologies LTC1710
253  sensor chips. This can also be built as a module which can be
254  inserted and removed while the kernel is running.
255
256  You will also need the latest user-space utilties: you can find them
257  in the lm_sensors package, which you can download at
258  http://www.lm-sensors.nu
259
260EOF
261    }
262    print OUTPUT;
263  }
264  close INPUT;
265  close OUTPUT;
266  print_diff $package_root,$kernel_root,$kernel_file,$package_file;
267}
268
269
270# This generates diffs for the main Linux Makefile.
271# Three lines which add drivers/sensors/sensors.a to the DRIVERS list are
272# put just before the place where the architecture Makefile is included.
273# Of course, care is taken old lines are removed.
274# $_[0]: sensors package root (like /tmp/sensors)
275# $_[1]: Linux kernel tree (like /usr/src/linux)
276sub gen_Makefile
277{
278  my ($package_root,$kernel_root) = @_;
279  my $kernel_file = "Makefile";
280  my $package_file = $temp;
281
282  open INPUT,"$kernel_root/$kernel_file"
283        or die "Can't open `$kernel_root/$kernel_file'";
284  open OUTPUT,">$package_root/$package_file"
285        or die "Can't open $package_root/$package_file";
286  MAIN: while(<INPUT>) {
287    if (m@CONFIG_SENSORS@) {
288      $_ = <INPUT> while not m@endif@;
289      $_ = <INPUT>;
290      $_ = <INPUT> if m@^$@;
291      redo MAIN;
292    }
293    if (m@include arch/\$\(ARCH\)/Makefile@) {
294      print OUTPUT <<'EOF';
295ifeq ($(CONFIG_SENSORS),y)
296DRIVERS := $(DRIVERS) drivers/sensors/sensors.a
297endif
298
299EOF
300    }
301    print OUTPUT;
302  }
303  close INPUT;
304  close OUTPUT;
305  print_diff $package_root,$kernel_root,$kernel_file,$package_file;
306}
307
308# This generates diffs for drivers/Makefile
309# First, `sensors' is added to the ALL_SUB_DIRS list. Next, a couple of lines
310# to add sensors to the SUB_DIRS and/or MOD_SUB_DIRS lists is put right before
311# Rules.make is included.
312# Of course, care is taken old lines are removed.
313# $_[0]: sensors package root (like /tmp/sensors)
314# $_[1]: Linux kernel tree (like /usr/src/linux)
315sub gen_drivers_Makefile
316{
317  my ($package_root,$kernel_root) = @_;
318  my $kernel_file = "drivers/Makefile";
319  my $package_file = $temp;
320  my $sensors_present;
321  my $pr1 = 0;
322  my $pr2 = 0;
323
324  open INPUT,"$kernel_root/$kernel_file"
325        or die "Can't open `$kernel_root/$kernel_file'";
326  open OUTPUT,">$package_root/$package_file"
327        or die "Can't open $package_root/$package_file";
328  MAIN: while(<INPUT>) {
329    if (m@^ALL_SUB_DIRS\s*:=@) {
330      $pr1 = 1;
331      $sensors_present = 0;
332      while (m@\\$@) {
333        $sensors_present = 1 if m@sensors@;
334        print OUTPUT;
335        $_ = <INPUT>;
336      }
337      $sensors_present = 1 if m@sensors@;
338      s@$@ sensors@ if (not $sensors_present);
339      print OUTPUT;
340      $_ = <INPUT>;
341      redo MAIN;
342    } 
343    if (m@CONFIG_SENSORS@) {
344      $_ = <INPUT> while not m@^endif@;
345      $_ = <INPUT>;
346      $_ = <INPUT> if m@^$@;
347      redo MAIN;
348    } 
349    if (m@^include \$\(TOPDIR\)/Rules.make$@) {
350      $pr2 = 1;
351      print OUTPUT <<'EOF';
352ifeq ($(CONFIG_SENSORS),y)
353SUB_DIRS += sensors
354MOD_SUB_DIRS += sensors
355else
356  ifeq ($(CONFIG_SENSORS),m)
357  MOD_SUB_DIRS += sensors
358  endif
359endif
360
361EOF
362    }
363    print OUTPUT;
364  }
365  close INPUT;
366  close OUTPUT;
367  die "Automatic patch generation for `drivers/Makefile' failed.\n".
368      "Contact the authors please!" if $pr1 == 0 or $pr2 == 0;
369  print_diff $package_root,$kernel_root,$kernel_file,$package_file;
370}
371
372# This generates diffs for drivers/char/Config.in
373# It adds a line just before CONFIG_APM or main_menu_option lines to include
374# the sensors Config.in.
375# Of course, care is taken old lines are removed.
376# $_[0]: sensors package root (like /tmp/sensors)
377# $_[1]: Linux kernel tree (like /usr/src/linux)
378sub gen_drivers_char_Config_in
379{
380  my ($package_root,$kernel_root) = @_;
381  my $kernel_file = "drivers/char/Config.in";
382  my $package_file = $temp;
383  my $pr1 = 0;
384
385  open INPUT,"$kernel_root/$kernel_file"
386        or die "Can't open `$kernel_root/$kernel_file'";
387  open OUTPUT,">$package_root/$package_file"
388        or die "Can't open $package_root/$package_file";
389  MAIN: while(<INPUT>) {
390    if (m@source drivers/i2c/Config.in@) {
391      $pr1 = 1;
392      print OUTPUT;
393      print OUTPUT "\nsource drivers/sensors/Config.in\n";
394      $_ = <INPUT>;
395      redo MAIN;
396    }
397    if (m@sensors@) {
398      $_ = <INPUT>;
399      $_ = <INPUT> if m@^$@;
400      redo MAIN;
401    }
402    print OUTPUT;
403  }
404  close INPUT;
405  close OUTPUT;
406  die "Automatic patch generation for `drivers/Makefile' failed.\n".
407      "Contact the authors please!" if $pr1 == 0;
408  print_diff $package_root,$kernel_root,$kernel_file,$package_file;
409}
410 
411
412# This generates diffs for drivers/char/mem.c They are a bit intricate.
413# Lines are generated at the beginning to declare sensors_init_all
414# At the bottom, a call to sensors_init_all is added when the
415# new lm_sensors stuff is configured in.
416# Of course, care is taken old lines are removed.
417# $_[0]: sensors package root (like /tmp/sensors)
418# $_[1]: Linux kernel tree (like /usr/src/linux)
419sub gen_drivers_char_mem_c
420{
421  my ($package_root,$kernel_root) = @_;
422  my $kernel_file = "drivers/char/mem.c";
423  my $package_file = $temp;
424  my $right_place = 0;
425  my $done = 0;
426  my $atstart = 1;
427  my $pr1 = 0;
428  my $pr2 = 0;
429
430  open INPUT,"$kernel_root/$kernel_file"
431        or die "Can't open `$kernel_root/$kernel_file'";
432  open OUTPUT,">$package_root/$package_file"
433        or die "Can't open $package_root/$package_file";
434  MAIN: while(<INPUT>) {
435    if ($atstart and m@#ifdef@) {
436      $pr1 = 1;
437      print OUTPUT << 'EOF';
438#ifdef CONFIG_SENSORS
439extern void sensors_init_all(void);
440#endif
441EOF
442      $atstart = 0;
443    }
444    if (not $right_place and m@CONFIG_SENSORS@) {
445      $_ = <INPUT> while not m@#endif@;
446      $_ = <INPUT>;
447      redo MAIN;
448    }
449    $right_place = 1 if (m@lp_init\(\);@);
450    if ($right_place and not $done and
451        m@CONFIG_SENSORS@) {
452      $_ = <INPUT> while not m@#endif@;
453      $_ = <INPUT>;
454      $_ = <INPUT> if m@^$@;
455      redo MAIN;
456    }
457    if ($right_place and not $done and m@return 0;@) {
458      $pr2 = 1;
459      print OUTPUT <<'EOF';
460#ifdef CONFIG_SENSORS
461        sensors_init_all();
462#endif
463
464EOF
465      $done = 1;
466    }
467    print OUTPUT;
468  }
469  close INPUT;
470  close OUTPUT;
471  die "Automatic patch generation for `drivers/char/mem.c' failed.\n".
472      "Contact the authors please!" if $pr1 == 0 or $pr2 == 0;
473  print_diff $package_root,$kernel_root,$kernel_file,$package_file;
474}
475
476
477# This generates diffs for drivers/i2c/Config.in
478# Several adapter drivers that are included in the lm_sensors package are
479# added at the first and onlu sensors marker.
480# Of course, care is taken old lines are removed.
481# $_[0]: sensors package root (like /tmp/sensors)
482# $_[1]: Linux kernel tree (like /usr/src/linux)
483sub gen_drivers_i2c_Config_in
484{
485  my ($package_root,$kernel_root) = @_;
486  my $kernel_file = "drivers/i2c/Config.in";
487  my $package_file = "$temp";
488  my $pr1 = 0;
489
490  open INPUT,"$kernel_root/$kernel_file"
491        or die "Can't open `$kernel_root/$kernel_file'";
492  open OUTPUT,">$package_root/$package_file"
493        or die "Can't open $package_root/$package_file";
494  while(<INPUT>) {
495    if (m@sensors code starts here@) {
496      $pr1++;
497      print OUTPUT;
498      while (<INPUT>) {
499        last if m@sensors code ends here@;
500      }
501      print OUTPUT << 'EOF';
502  bool 'I2C mainboard interfaces' CONFIG_I2C_MAINBOARD
503  if [ "$CONFIG_I2C_MAINBOARD" = "y" ]; then
504    tristate '  Acer Labs ALI 1533 and 1543C' CONFIG_I2C_ALI15X3
505    dep_tristate '  Apple Hydra Mac I/O' CONFIG_I2C_HYDRA $CONFIG_I2C_ALGOBIT
506    tristate '  Intel 82371AB PIIX4(E)' CONFIG_I2C_PIIX4
507    dep_tristate '  VIA Technologies, Inc. VT82C586B' CONFIG_I2C_VIA $CONFIG_I2C_ALGOBIT
508    tristate '  Pseudo ISA adapter (for hardware sensors modules)' CONFIG_I2C_ISA
509  fi
510
511EOF
512    }
513    print OUTPUT;
514  }
515  close INPUT;
516  close OUTPUT;
517  die "Automatic patch generation for `drivers/i2c/Config.in' failed.\n".
518      "Contact the authors please!" if $pr1 != 1;
519  print_diff $package_root,$kernel_root,$kernel_file,$package_file;
520}
521
522# This generates diffs for drivers/i2c/Makefile.
523# Lines to add correct files to M_OBJS and/or L_OBJS are added just before
524# Rules.make is included
525# Of course, care is taken old lines are removed.
526# $_[0]: sensors package root (like /tmp/sensors)
527# $_[1]: Linux kernel tree (like /usr/src/linux)
528sub gen_drivers_i2c_Makefile
529{
530  my ($package_root,$kernel_root) = @_;
531  my $kernel_file = "drivers/i2c/Makefile";
532  my $package_file = $temp;
533  my $pr1 = 0;
534
535  open INPUT,"$kernel_root/$kernel_file"
536        or die "Can't open `$kernel_root/$kernel_file'";
537  open OUTPUT,">$package_root/$package_file"
538        or die "Can't open $package_root/$package_file";
539  while(<INPUT>) {
540    if (m@sensors code starts here@) {
541      $pr1 ++;
542      print OUTPUT;
543      while (<INPUT>) {
544        last if m@sensors code ends here@;
545      }
546      print OUTPUT << 'EOF';
547ifeq ($(CONFIG_I2C_ALI15X3),y)
548  L_OBJS += i2c-ali15x3.o
549else 
550  ifeq ($(CONFIG_I2C_ALI15X3),m)
551    M_OBJS += i2c-ali15x3.o
552  endif
553endif
554
555ifeq ($(CONFIG_I2C_HYDRA),y)
556  L_OBJS += i2c-hydra.o
557else 
558  ifeq ($(CONFIG_I2C_HYDRA),m)
559    M_OBJS += i2c-hydra.o
560  endif
561endif
562
563ifeq ($(CONFIG_I2C_PIIX4),y)
564  L_OBJS += i2c-piix4.o
565else 
566  ifeq ($(CONFIG_I2C_PIIX4),m)
567    M_OBJS += i2c-piix4.o
568  endif
569endif
570
571ifeq ($(CONFIG_I2C_VIA),y)
572  L_OBJS += i2c-via.o
573else 
574  ifeq ($(CONFIG_I2C_VIA),m)
575    M_OBJS += i2c-via.o
576  endif
577endif
578
579ifeq ($(CONFIG_I2C_ISA),y)
580  L_OBJS += i2c-isa.o
581else 
582  ifeq ($(CONFIG_I2C_ISA),m)
583    M_OBJS += i2c-isa.o
584  endif
585endif
586
587EOF
588    }
589    print OUTPUT;
590  }
591  close INPUT;
592  close OUTPUT;
593  die "Automatic patch generation for `drivers/i2c/Makefile' failed.\n".
594      "Contact the authors please!" if $pr1 != 1;
595  print_diff $package_root,$kernel_root,$kernel_file,$package_file;
596}
597
598# This generates diffs for drivers/i2c/i2c-core.c
599# Lines are generated at the beginning to declare several *_init functions.
600# At the bottom, calls to them are added when the sensors stuff is configured
601# in.
602# $_[0]: sensors package root (like /tmp/sensors)
603# $_[1]: Linux kernel tree (like /usr/src/linux)
604sub gen_drivers_i2c_i2c_core_c
605{
606  my ($package_root,$kernel_root) = @_;
607  my $kernel_file = "drivers/i2c/i2c-core.c";
608  my $package_file = $temp;
609  my $patch_nr = 1;
610
611  open INPUT,"$kernel_root/$kernel_file"
612        or die "Can't open `$kernel_root/$kernel_file'";
613  open OUTPUT,">$package_root/$package_file"
614        or die "Can't open $package_root/$package_file";
615  while(<INPUT>) {
616    if (m@sensors code starts here@) {
617      print OUTPUT;
618      while (<INPUT>) {
619        last if m@sensors code ends here@;
620      }
621      if ($patch_nr == 1) {
622        print OUTPUT << 'EOF';
623#ifdef CONFIG_I2C_ALI15X3
624        extern int i2c_ali15x3_init(void);
625#endif
626#ifdef CONFIG_I2C_HYDRA
627        extern int i2c_hydra_init(void);
628#endif
629#ifdef CONFIG_I2C_PIIX4
630        extern int i2c_piix4_init(void);
631#endif
632#ifdef CONFIG_I2C_VIA
633        extern int i2c_via_init(void);
634#endif
635#ifdef CONFIG_I2C_ISA
636        extern int i2c_isa_init(void);
637#endif
638EOF
639      } elsif ($patch_nr == 2) {
640      print OUTPUT << 'EOF';
641#ifdef CONFIG_I2C_ALI15X3
642        i2c_ali15x3_init();
643#endif
644#ifdef CONFIG_I2C_HYDRA
645        i2c_hydra_init();
646#endif
647#ifdef CONFIG_I2C_PIIX4
648        i2c_piix4_init();
649#endif
650#ifdef CONFIG_I2C_VIA
651        i2c_via_init();
652#endif
653#ifdef CONFIG_I2C_ISA
654        i2c_isa_init();
655#endif
656EOF
657      }
658      $patch_nr ++;
659    }
660    print OUTPUT;
661  }
662  close INPUT;
663  close OUTPUT;
664  die "Automatic patch generation for `drivers/i2c/i2c-core.c' failed.\n".
665      "Contact the authors please!" if $patch_nr != 3;
666  print_diff $package_root,$kernel_root,$kernel_file,$package_file;
667}
668
669# Generate the diffs for the list of MAINTAINERS
670# $_[0]: i2c package root (like /tmp/i2c)
671# $_[1]: Linux kernel tree (like /usr/src/linux)
672sub gen_MAINTAINERS
673{
674  my ($package_root,$kernel_root) = @_;
675  my $kernel_file = "MAINTAINERS";
676  my $package_file = $temp;
677  my $done = 0;
678
679  open INPUT,"$kernel_root/$kernel_file"
680        or die "Can't open `$kernel_root/$kernel_file'";
681  open OUTPUT,">$package_root/$package_file"
682        or die "Can't open $package_root/$package_file";
683  MAIN: while(<INPUT>) {
684    if (m@SENSORS DRIVERS@) {
685       $_=<INPUT> while not m@^$@;
686       $_=<INPUT>;
687       redo MAIN;
688    }
689    if (not $done and (m@SGI VISUAL WORKSTATION 320 AND 540@)) {
690      print OUTPUT <<'EOF';
691SENSORS DRIVERS
692P:      Frodo Looijaard
693M:      frodol@dds.nl
694P:      Philip Edelbrock
695M:      phil@netroedge.com
696L:      lm78@stimpy.netroedge.com
697W:      http://www.lm-sensors.nu/
698S:      Maintained
699
700EOF
701      $done = 1;
702    }
703    print OUTPUT;
704  }
705  close INPUT;
706  close OUTPUT;
707  die "Automatic patch generation for `MAINTAINERS' failed.\n".
708      "Contact the authors please!" if $done == 0;
709  print_diff $package_root,$kernel_root,$kernel_file,$package_file;
710}
711
712
713# Main function
714sub main
715{
716  my ($package_root,$kernel_root,%files,%includes,$package_file,$kernel_file);
717  my ($diff_command,$dummy,$data0,$data1,$sedscript,$version_string);
718
719  # --> Read the command-lineo
720  $package_root = $ARGV[0];
721  die "Package root `$package_root' is not found\n" 
722        unless -d "$package_root/mkpatch";
723  $kernel_root = $ARGV[1];
724  die "Kernel root `$kernel_root' is not found\n" 
725        unless -f "$kernel_root/Rules.make";
726
727  # --> Read FILES
728  open INPUT, "$package_root/mkpatch/FILES" 
729        or die "Can't open `$package_root/mkpatch/FILES'";
730  while (<INPUT>) {
731    ($data0,$data1) = /(\S+)\s+(\S+)/;
732    $files{$data0} = $data1;
733  } 
734  close INPUT;
735
736  # --> Read INCLUDES
737  open INPUT, "$package_root/mkpatch/INCLUDES" 
738        or die "Can't open `$package_root/mkpatch/INCLUDES'";
739  while (<INPUT>) {
740    ($data0,$data1) = /(\S+)\s+(\S+)/;
741    $includes{$data0} = $data1;
742    $sedscript .= 's,(#\s*include\s*)'.$data0.'(\s*),\1'."$data1".'\2, ; ';
743  } 
744  close INPUT;
745
746  die "First apply the i2c patches to `$kernel_root'!" 
747       if ! -d "$kernel_root/drivers/i2c";
748
749  # --> Read "version.h"
750  open INPUT, "$package_root/version.h"
751        or die "Can't open `$package_root/version.h'";
752  $version_string .= $_ while <INPUT>;
753  close INPUT;
754 
755  # --> Start generating
756  foreach $package_file (sort keys %files) {
757    open INPUT,"$package_root/$package_file" 
758          or die "Can't open `$package_root/$package_file'";
759    open OUTPUT,">$package_root/$temp"
760          or die "Can't open `$package_root/$temp'";
761    while (<INPUT>) {
762      eval $sedscript;
763      if (m@#\s*include\s*"version.h"@) {
764        print OUTPUT $version_string;
765      } else {
766        print OUTPUT;
767      }
768    }
769    close INPUT;
770    close OUTPUT;
771
772    $kernel_file = $files{$package_file};
773    print_diff $package_root,$kernel_root,$kernel_file,$temp;
774  }
775
776  gen_Makefile $package_root, $kernel_root;
777  gen_drivers_Makefile $package_root, $kernel_root;
778  gen_drivers_char_Config_in $package_root, $kernel_root;
779  gen_drivers_char_mem_c $package_root, $kernel_root;
780  gen_drivers_i2c_Config_in $package_root, $kernel_root;
781  gen_drivers_i2c_Makefile $package_root, $kernel_root;
782  gen_drivers_i2c_i2c_core_c $package_root, $kernel_root;
783  gen_Documentation_Configure_help $package_root, $kernel_root;
784  gen_MAINTAINERS $package_root, $kernel_root;
785}
786
787main;
788
Note: See TracBrowser for help on using the browser.