Commit cfdec9c9 authored by Linus Torvalds's avatar Linus Torvalds

Import 2.1.78pre3

parent c95035fb
......@@ -209,19 +209,23 @@ symlinks:
mkdir include/linux/modules; \
fi
oldconfig: symlinks
oldconfig: symlinks scripts/split-include
$(CONFIG_SHELL) scripts/Configure -d arch/$(ARCH)/config.in
scripts/split-include include/linux/autoconf.h include/config
xconfig: symlinks
xconfig: symlinks scripts/split-include
$(MAKE) -C scripts kconfig.tk
wish -f scripts/kconfig.tk
scripts/split-include include/linux/autoconf.h include/config
menuconfig: include/linux/version.h symlinks
menuconfig: include/linux/version.h symlinks scripts/split-include
$(MAKE) -C scripts/lxdialog all
$(CONFIG_SHELL) scripts/Menuconfig arch/$(ARCH)/config.in
scripts/split-include include/linux/autoconf.h include/config
config: symlinks
config: symlinks scripts/split-include
$(CONFIG_SHELL) scripts/Configure arch/$(ARCH)/config.in
scripts/split-include include/linux/autoconf.h include/config
linuxsubdirs: dummy
set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i; done
......@@ -339,8 +343,9 @@ endif
clean: archclean
rm -f kernel/ksyms.lst include/linux/compile.h
rm -f core `find . -name '*.[oas]' ! -regex '.*lxdialog/.*' -print`
rm -f core `find . -type f -name 'core' -print`
rm -f `find . -name '*.[oas]' ! -regex '.*lxdialog/.*' -print`
rm -f `find . -type f -name 'core' -print`
rm -f `find . -name '.*.flags' -print`
rm -f vmlinux System.map
rm -f .tmp*
rm -f drivers/char/consolemap_deftbl.c drivers/char/conmakehash
......@@ -361,8 +366,9 @@ mrproper: clean
rm -f scripts/lxdialog/*.o scripts/lxdialog/lxdialog
rm -f .menuconfig.log
rm -f include/asm
rm -rf include/config
rm -f .depend `find . -name .depend -print`
rm -f .hdepend scripts/mkdep
rm -f .hdepend scripts/mkdep scripts/split-include
rm -f $(TOPDIR)/include/linux/modversions.h
rm -rf $(TOPDIR)/include/linux/modules
rm -rf modules
......@@ -380,10 +386,9 @@ sums:
find . -type f -print | sort | xargs sum > .SUMS
dep-files: scripts/mkdep archdep include/linux/version.h
scripts/mkdep init/*.c > .tmpdepend
scripts/mkdep init/*.c > .depend
scripts/mkdep `find $(FINDHPATH) -follow -name \*.h ! -name modversions.h -print` > .hdepend
set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i fastdep; done
mv .tmpdepend .depend
MODVERFILE :=
......@@ -393,6 +398,9 @@ endif
depend dep: dep-files $(MODVERFILE)
checkconfig:
perl -w scripts/checkconfig.pl `find $(FINDHPATH) $(SUBDIRS) -name '*.[hcS]' -print | sort`
ifdef CONFIGURATION
..$(CONFIGURATION):
@echo
......@@ -421,3 +429,6 @@ include Rules.make
scripts/mkdep: scripts/mkdep.c
$(HOSTCC) $(HOSTCFLAGS) -o scripts/mkdep scripts/mkdep.c
scripts/split-include: scripts/split-include.c
$(HOSTCC) $(HOSTCFLAGS) -o scripts/split-include scripts/split-include.c
......@@ -45,13 +45,18 @@ first_rule: sub_dirs
#
%.s: %.c
$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -S $< -o $@
$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$@) -S $< -o $@
%.i: %.c
$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -E $< > $@
$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$@) -E $< > $@
%.o: %.c
$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $<
$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$@) -c -o $@ $<
@ ( \
echo 'ifeq ($(strip $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$@)),$$(strip $$(CFLAGS) $$(EXTRA_CFLAGS) $$(CFLAGS_$@)))' ; \
echo 'FILES_FLAGS_UP_TO_DATE += $@' ; \
echo 'endif' \
) > .$@.flags
%.o: %.s
$(AS) $(ASFLAGS) $(EXTRA_CFLAGS) -o $@ $<
......@@ -66,29 +71,39 @@ all_targets: $(O_TARGET) $(L_TARGET)
#
ifdef O_TARGET
ALL_O = $(OX_OBJS) $(O_OBJS)
$(O_TARGET): $(ALL_O) $(TOPDIR)/include/linux/config.h
$(O_TARGET): $(ALL_O)
rm -f $@
ifneq "$(strip $(ALL_O))" ""
$(LD) $(EXTRA_LDFLAGS) -r -o $@ $(ALL_O)
else
$(AR) rcs $@
endif
@ ( \
echo 'ifeq ($(strip $(EXTRA_LDFLAGS) $(ALL_O)),$$(strip $$(EXTRA_LDFLAGS) $$(ALL_O)))' ; \
echo 'FILES_FLAGS_UP_TO_DATE += $@' ; \
echo 'endif' \
) > .$@.flags
endif # O_TARGET
#
# Rule to compile a set of .o files into one .a file
#
ifdef L_TARGET
$(L_TARGET): $(LX_OBJS) $(L_OBJS) $(TOPDIR)/include/linux/config.h
$(L_TARGET): $(LX_OBJS) $(L_OBJS)
rm -f $@
$(AR) $(EXTRA_ARFLAGS) rcs $@ $(LX_OBJS) $(L_OBJS)
@ ( \
echo 'ifeq ($(strip $(EXTRA_ARFLAGS) $(LX_OBJS) $(L_OBJS)),$$(strip $$(EXTRA_ARFLAGS) $$(LX_OBJS) $$(L_OBJS)))' ; \
echo 'FILES_FLAGS_UP_TO_DATE += $@' ; \
echo 'endif' \
) > .$@.flags
endif
#
# This make dependencies quickly
#
fastdep: dummy
$(TOPDIR)/scripts/mkdep *.[chS] > .depend
$(TOPDIR)/scripts/mkdep $(wildcard *.[chS] local.h.master) > .depend
ifdef ALL_SUB_DIRS
set -e; for i in $(ALL_SUB_DIRS); do $(MAKE) -C $$i fastdep; done
endif
......@@ -131,7 +146,7 @@ endif
ifneq "$(strip $(ALL_MOBJS))" ""
echo $(PDWN)
cd $$TOPDIR/modules; for i in $(ALL_MOBJS); do \
ln -sf ../$(PDWN)/$$i .; done
ln -sf ../$(PDWN)/$$i $$i; done
endif
#
......@@ -198,19 +213,54 @@ endif # CONFIG_MODVERSIONS
ifneq "$(strip $(SYMTAB_OBJS))" ""
$(SYMTAB_OBJS): $(TOPDIR)/include/linux/modversions.h $(SYMTAB_OBJS:.o=.c)
$(CC) $(CFLAGS) -DEXPORT_SYMTAB -c $(@:.o=.c)
$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$@) -DEXPORT_SYMTAB -c $(@:.o=.c)
@ ( \
echo 'ifeq ($(strip $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$@) -DEXPORT_SYMTAB),$$(strip $$(CFLAGS) $$(EXTRA_CFLAGS) $$(CFLAGS_$@) -DEXPORT_SYMTAB))' ; \
echo 'FILES_FLAGS_UP_TO_DATE += $@' ; \
echo 'endif' \
) > .$@.flags
endif
endif # CONFIG_MODULES
#
# include dependency files they exist
# include dependency files if they exist
#
ifeq (.depend,$(wildcard .depend))
ifneq ($(wildcard .depend),)
include .depend
endif
ifeq ($(TOPDIR)/.hdepend,$(wildcard $(TOPDIR)/.hdepend))
ifneq ($(wildcard $(TOPDIR)/.hdepend),)
include $(TOPDIR)/.hdepend
endif
#
# Find files whose flags have changed and force recompilation.
# For safety, this works in the converse direction:
# every file is forced, except those whose flags are positively up-to-date.
#
FILES_FLAGS_UP_TO_DATE :=
FILES_FLAGS_EXIST := $(wildcard .*.flags)
ifneq ($(FILES_FLAGS_EXIST),)
include $(FILES_FLAGS_EXIST)
endif
FILES_FLAGS_CHANGED := $(strip \
$(filter-out $(FILES_FLAGS_UP_TO_DATE), \
$(O_TARGET) $(O_OBJS) $(OX_OBJS) \
$(L_TARGET) $(L_OBJS) $(LX_OBJS) \
$(M_OBJS) $(MX_OBJS) \
$(MI_OBJS) $(MIX_OBJS) \
))
# A kludge: .S files don't get flag dependencies (yet),
# because that will involve changing a lot of Makefiles.
FILES_FLAGS_CHANGED := $(strip \
$(filter-out $(patsubst %.S, %.o, $(wildcard *.S)), \
$(FILES_FLAGS_CHANGED)))
ifneq ($(FILES_FLAGS_CHANGED),)
$(FILES_FLAGS_CHANGED): dummy
endif
......@@ -109,10 +109,10 @@ fi
endmenu
# Conditionally compile in the Uniform CD-ROM driver
if [ "$CONFIG_BLK_DEV_IDECD" = "y" -o "$CONFIG_BLK_DEV_SR" = "y" -o "$CONFIG_SBPCD" = "y" -o "$CONFIG_MCD" = "y" -o "$CONFIG_CM206" = "y" -o "$CONFIG_CDU31A" = "y" ]; then
if [ "$CONFIG_BLK_DEV_IDECD" = "y" -o "$CONFIG_BLK_DEV_SR" = "y" -o "$CONFIG_SBPCD" = "y" -o "$CONFIG_MCD" = "y" -o "$CONFIG_MCDX" = "y" -o "$CONFIG_CM206" = "y" -o "$CONFIG_CDU31A" = "y" ]; then
define_bool CONFIG_CDROM y
else
if [ "$CONFIG_BLK_DEV_IDECD" = "m" -o "$CONFIG_BLK_DEV_SR" = "m" -o "$CONFIG_SBPCD" = "m" -o "$CONFIG_MCD" = "m" -o "$CONFIG_CM206" = "m" -o "$CONFIG_CDU31A" = "m" ]; then
if [ "$CONFIG_BLK_DEV_IDECD" = "m" -o "$CONFIG_BLK_DEV_SR" = "m" -o "$CONFIG_SBPCD" = "m" -o "$CONFIG_MCD" = "m" -o "$CONFIG_MCDX" = "m" -o "$CONFIG_CM206" = "m" -o "$CONFIG_CDU31A" = "m" ]; then
define_bool CONFIG_CDROM m
else
define_bool CONFIG_CDROM n
......
......@@ -237,6 +237,7 @@ CONFIG_LOCKD=y
# CONFIG_NTFS_FS is not set
# CONFIG_SYSV_FS is not set
# CONFIG_AFFS_FS is not set
# CONFIG_HFS_FS is not set
# CONFIG_ROMFS_FS is not set
CONFIG_AUTOFS_FS=y
# CONFIG_UFS_FS is not set
......
......@@ -27,10 +27,8 @@
* unless you have a patch to fix it. I am working on it...)
* -Implement ide_cdrom_select_speed using the generic cdrom interface
* -Fix ide_cdrom_reset so that it works (it does nothing right now)
*
* MOSTLY DONE LIST:
* Query the drive to find what features are available
* before trying to use them.
* -Query the drive to find what features are available before trying to
* use them (like trying to close the tray in drives that can't).
*
*
* ----------------------------------
......@@ -182,10 +180,12 @@
* 4.07 Dec 17, 1997 -- fallback to set pc->stat on "tray open"
* 4.08 Dec 18, 1997 -- spew less noise when tray is empty
* -- fix speed display for ACER 24X, 18X
* 4.09 Jan 04, 1998 -- fix handling of the last block so we return
* an end of file instead of an I/O error (Gadi)
*
*************************************************************************/
#define IDECD_VERSION "4.07"
#define IDECD_VERSION "4.09"
#include <linux/config.h>
#include <linux/module.h>
......@@ -1663,7 +1663,7 @@ cdrom_read_toc (ide_drive_t *drive,
if (stat) toc->capacity = 0x1fffff;
HWIF(drive)->gd->sizes[drive->select.b.unit << PARTN_BITS]
= toc->capacity * SECTORS_PER_FRAME;
= (toc->capacity * SECTORS_PER_FRAME) >> (BLOCK_SIZE_BITS - 9);
drive->part[0].nr_sects = toc->capacity * SECTORS_PER_FRAME;
/* Remember that we've read this stuff. */
......
/* linux/drivers/cdrom/cdrom.c.
Copyright (c) 1996, 1997 David A. van Leeuwen.
Copyright (c) 1997 Erik Andersen (andersee@debian.org)
Copyright (c) 1997, 1998 Erik Andersen (andersee@debian.org)
May be copied or modified under the terms of the GNU General Public
License. See linux/COPYING for more information.
......@@ -68,14 +68,10 @@
#include <asm/uaccess.h>
#define VERSION "$Id: cdrom.c,v 2.1 1997/12/28 15:11:47 david Exp $"
#define REVISION "$Revision: 2.1 $"
#define VERSION "$Id: cdrom.c,v 2.11 1998/01/04 01:11:18 erik Exp $"
#define REVISION "Revision: 2.11"
#define FM_WRITE 0x2 /* file mode write bit */
/* When VERBOSE_STATUS_INFO is not defined, the debugging printks don't
get compiled in */
#define VERBOSE_STATUS_INFO
/* I use an error-log mask to give fine grain control over the type of
error messages dumped to the system logs. The available masks include: */
#define CD_WARNING 0x1
......@@ -83,9 +79,14 @@
#define CD_DO_IOCTL 0x4
#define CD_OPEN 0x8
#define CD_CLOSE 0x10
#define CD_COUNT_TRACKS 0x20
/* When VERBOSE_STATUS_INFO is not defined, the debugging printks don't
get compiled in at all */
#define VERBOSE_STATUS_INFO
#define ERRLOGMASK (CD_WARNING)
/* #define ERRLOGMASK (CD_WARNING|CD_OPEN|CD_CLOSE) */
/* #define ERRLOGMASK (CD_WARNING|CD_OPEN|CD_COUNT_TRACKS|CD_CLOSE) */
/* #define ERRLOGMASK (CD_WARNING|CD_REG_UNREG|CD_DO_IOCTL|CD_OPEN|CD_CLOSE) */
#ifdef VERBOSE_STATUS_INFO
......@@ -480,7 +481,7 @@ void cdrom_count_tracks(struct cdrom_device_info *cdi, tracktype* tracks)
tracks->cdi=0;
tracks->xa=0;
tracks->error=0;
cdinfo(CD_OPEN, "entering cdrom_count_tracks\n");
cdinfo(CD_COUNT_TRACKS, "entering cdrom_count_tracks\n");
if (!(cdi->ops->capability & CDC_PLAY_AUDIO)) {
tracks->error=CDS_NO_INFO;
return;
......@@ -508,10 +509,10 @@ void cdrom_count_tracks(struct cdrom_device_info *cdi, tracktype* tracks)
tracks->data++;
} else
tracks->audio++;
cdinfo(CD_OPEN, "track %d: format=%d, ctrl=%d\n",
cdinfo(CD_COUNT_TRACKS, "track %d: format=%d, ctrl=%d\n",
i, entry.cdte_format, entry.cdte_ctrl);
}
cdinfo(CD_OPEN, "disc has %d tracks: %d=audio %d=data %d=Cd-I %d=XA\n",
cdinfo(CD_COUNT_TRACKS, "disc has %d tracks: %d=audio %d=data %d=Cd-I %d=XA\n",
header.cdth_trk1, tracks->audio, tracks->data,
tracks->cdi, tracks->xa);
}
......
......@@ -416,7 +416,8 @@ static int scd_drive_status(struct cdrom_device_info *cdi, int slot_nr)
return -EINVAL;
}
return sony_spun_up ? CDS_DISC_OK : CDS_DRIVE_NOT_READY;
/*return sony_spun_up ? CDS_DISC_OK : CDS_DRIVE_NOT_READY;*/
return sony_spun_up ? CDS_DISC_OK : CDS_TRAY_OPEN;
}
static inline void
......@@ -1085,7 +1086,7 @@ handle_sony_cd_attention(void)
volatile int val;
#if DEBUG
#if 0*DEBUG
printk("Entering handle_sony_cd_attention\n");
#endif
if (is_attention())
......@@ -1166,7 +1167,7 @@ handle_sony_cd_attention(void)
}
num_consecutive_attentions = 0;
#if DEBUG
#if 0*DEBUG
printk("Leaving handle_sony_cd_attention at %d\n", __LINE__);
#endif
return(0);
......@@ -2835,8 +2836,11 @@ static int scd_tray_move(struct cdrom_device_info *cdi, int position)
sony_audio_status = CDROM_AUDIO_INVALID;
return do_sony_cd_cmd_chk("EJECT",SONY_EJECT_CMD, NULL, 0, res_reg, &res_size);
} else
return 0;
} else {
if (0 == scd_spinup())
sony_spun_up = 1;
return 0;
}
}
/*
......@@ -3230,7 +3234,6 @@ scd_open(struct cdrom_device_info *cdi, int openmode)
printk("CDU31A: Unable to set XA params: 0x%2.2x\n", res_reg[1]);
}
sony_xa_mode = 1;
printk("sony_xa_mode is set\n");
}
/* A non-XA disk. Set the parms back if necessary. */
else if (sony_xa_mode)
......@@ -3247,7 +3250,6 @@ printk("sony_xa_mode is set\n");
printk("CDU31A: Unable to reset XA params: 0x%2.2x\n", res_reg[1]);
}
sony_xa_mode = 0;
printk("sony_xa_mode is reset\n");
}
sony_spun_up = 1;
......@@ -3293,7 +3295,7 @@ static struct cdrom_device_ops scd_dops = {
scd_reset, /* hard reset */
scd_audio_ioctl, /* audio ioctl */
scd_dev_ioctl, /* device-specific ioctl */
CDC_OPEN_TRAY | CDC_LOCK | CDC_SELECT_SPEED | CDC_MULTI_SESSION |
CDC_OPEN_TRAY | CDC_CLOSE_TRAY | CDC_LOCK | CDC_SELECT_SPEED | CDC_MULTI_SESSION |
CDC_MULTI_SESSION | CDC_MCN | CDC_MEDIA_CHANGED | CDC_PLAY_AUDIO |
CDC_RESET | CDC_IOCTLS | CDC_DRIVE_STATUS, /* capability */
1, /* number of minor devices */
......@@ -3571,6 +3573,7 @@ cdu31a_init(void))
cdu31a_abort_timer.function = handle_abort_timeout;
scd_info.mask = deficiency;
strncpy(scd_info.name, "cdu31a", sizeof(scd_info.name));
if (register_cdrom(&scd_info))
{
......
......@@ -75,9 +75,6 @@ static const char *mcdx_c_version
#define mcdx_drive_map mcdx
#include "mcdx.h"
#define MCDX_QUIET 0
#ifndef HZ
#error HZ not defined
#endif
......@@ -288,7 +285,7 @@ static struct cdrom_device_ops mcdx_dops = {
NULL, /* hard reset */
mcdx_audio_ioctl, /* audio ioctl */
NULL, /* device-specific ioctl */
CDC_OPEN_TRAY | CDC_MEDIA_CHANGED | CDC_PLAY_AUDIO
CDC_OPEN_TRAY | CDC_LOCK | CDC_MEDIA_CHANGED | CDC_PLAY_AUDIO
| CDC_DRIVE_STATUS, /* capability */
0, /* number of minor devices */
};
......
......@@ -550,7 +550,6 @@ static struct cdrom_tocentry tocentry;
static struct cdrom_subchnl SC;
static struct cdrom_volctrl volctrl;
static struct cdrom_read_audio read_audio;
static struct cdrom_multisession ms_info;
static unsigned char msgnum=0;
static char msgbuf[80];
......@@ -2297,12 +2296,52 @@ static int cc_CloseTray(void)
}
i=cmd_out();
msg(DBG_LCS,"p_door_closed bit %d after\n", st_door_closed);
i=cc_ReadError();
flags_cmd_out |= f_respo2;
cc_ReadStatus(); /* command: give 1-byte status */
i=ResponseStatus();
if (famT_drive&&(i<0))
{
cc_DriveReset();
i=ResponseStatus();
#if 0
sbp_sleep(HZ);
#endif 0
i=ResponseStatus();
}
if (i<0)
{
msg(DBG_INF,"sbpcd cc_CloseTray: ResponseStatus timed out (%d).\n",i);
}
if (!(famT_drive))
{
if (!st_spinning)
{
cc_SpinUp();
if (st_check) i=cc_ReadError();
flags_cmd_out |= f_respo2;
cc_ReadStatus();
i=ResponseStatus();
} else {
}
}
i=DiskInfo();
return (i);
}
static int sbpcd_tray_move(struct cdrom_device_info *cdi, int position)
{
return position ? cc_CloseTray() : 0;
int i;
i = MINOR(cdi->dev);
switch_drive(i);
if (position == 1) {
cc_SpinDown();
} else {
return cc_CloseTray();
}
return 0;
}
/*==========================================================================*/
......@@ -2768,11 +2807,13 @@ static int cc_ReadTocDescr(void)
if (famLV_drive) D_S[d].CDsize_frm=D_S[d].size_blk+1;
}
D_S[d].diskstate_flags |= toc_bit;
msg(DBG_TOC,"TocDesc: %02X %02X %02X %08X\n",
msg(DBG_TOC,"TocDesc: xa %02X firstt %02X lastt %02X size %08X firstses %02X lastsess %02X\n",
D_S[d].xa_byte,
D_S[d].n_first_track,
D_S[d].n_last_track,
D_S[d].size_msf);
D_S[d].size_msf,
D_S[d].first_session,
D_S[d].last_session);
return (0);
}
/*==========================================================================*/
......@@ -3886,6 +3927,7 @@ static int DiskInfo(void)
msg(DBG_000,"DiskInfo entered.\n");
for (j=1;j<LOOP_COUNT;j++)
{
#if 0
i=SetSpeed();
if (i<0)
{
......@@ -3898,10 +3940,14 @@ static int DiskInfo(void)
msg(DBG_INF,"DiskInfo: cc_ModeSense returns %d\n", i);
continue;
}
#endif
i=cc_ReadCapacity();
if (i>=0) break;
msg(DBG_INF,"DiskInfo: ReadCapacity #%d returns %d\n", j, i);
#if 0
i=cc_DriveReset();
#endif
if (!fam0_drive && j == 2) break;
}
if (j==LOOP_COUNT) return (-33); /* give up */
......@@ -3946,12 +3992,36 @@ static int DiskInfo(void)
static int sbpcd_drive_status(struct cdrom_device_info *cdi, int slot_nr)
{
if (CDSL_CURRENT != slot_nr) {
/* we have no changer support */
return -EINVAL;
}
int st;
if (CDSL_CURRENT != slot_nr) {
/* we have no changer support */
return -EINVAL;
}
cc_ReadStatus();
st=ResponseStatus();
if (st<0)
{
msg(DBG_INF,"sbpcd_drive_status: timeout.\n");
return (0);
}
msg(DBG_000,"Drive Status: door_locked =%d.\n", st_door_locked);
msg(DBG_000,"Drive Status: door_closed =%d.\n", st_door_closed);
msg(DBG_000,"Drive Status: caddy_in =%d.\n", st_caddy_in);
msg(DBG_000,"Drive Status: disk_ok =%d.\n", st_diskok);
msg(DBG_000,"Drive Status: spinning =%d.\n", st_spinning);
msg(DBG_000,"Drive Status: busy =%d.\n", st_busy);
#if 0
if (!(D_S[MINOR(cdi->dev)].status_bits & p_door_closed)) return CDS_TRAY_OPEN;
if (D_S[MINOR(cdi->dev)].status_bits & p_disk_ok) return CDS_DISC_OK;
if (D_S[MINOR(cdi->dev)].status_bits & p_disk_in) return CDS_DRIVE_NOT_READY;
return D_S[d].status_bits & p1_disk_ok ? CDS_DISC_OK : CDS_DRIVE_NOT_READY;
return CDS_NO_DISC;
#else
if (D_S[MINOR(cdi->dev)].status_bits & p_spinning) return CDS_DISC_OK;
return CDS_TRAY_OPEN;
#endif
}
......@@ -4082,13 +4152,13 @@ static int sbp_status(void)
static int sbpcd_get_last_session(struct cdrom_device_info *cdi, struct cdrom_multisession *ms_infp)
{
ms_infp->addr_format = CDROM_LBA;
ms_infp->addr.lba = D_S[d].lba_multi;
if (D_S[d].f_multisession)
ms_infp->addr.lba = D_S[MINOR(cdi->dev)].lba_multi;
if (D_S[MINOR(cdi->dev)].f_multisession)
ms_infp->xa_flag=1; /* valid redirection address */
else
ms_infp->xa_flag=0; /* invalid redirection address */
return 1;
return 0;
}
/*==========================================================================*/
......@@ -4304,8 +4374,30 @@ static int sbpcd_dev_ioctl(struct cdrom_device_info *cdi, u_int cmd,
error_flag=0;
p = D_S[d].aud_buf;
if (sbpro_type==1) OUT(CDo_sel_i_d,1);
if (do_16bit) insw(CDi_data, p, read_audio.nframes*(CD_FRAMESIZE_RAW>>1));
else insb(CDi_data, p, read_audio.nframes*CD_FRAMESIZE_RAW);
if (do_16bit)
{
u_short *p2 = (u_short *) p;
for (; (u_char *) p2 < D_S[d].aud_buf + read_audio.nframes*CD_FRAMESIZE_RAW;)
{
if ((inb_p(CDi_status)&s_not_data_ready)) continue;
/* get one sample */
*p2++ = inw_p(CDi_data);
*p2++ = inw_p(CDi_data);
}
} else {
for (; p < D_S[d].aud_buf + read_audio.nframes*CD_FRAMESIZE_RAW;)
{
if ((inb_p(CDi_status)&s_not_data_ready)) continue;
/* get one sample */
*p++ = inb_p(CDi_data);
*p++ = inb_p(CDi_data);
*p++ = inb_p(CDi_data);
*p++ = inb_p(CDi_data);
}
}
if (sbpro_type==1) OUT(CDo_sel_i_d,0);
data_retrying = 0;
}
......@@ -4388,28 +4480,6 @@ static int sbpcd_dev_ioctl(struct cdrom_device_info *cdi, u_int cmd,
if(arg > 0xff) RETURN_UP(-EINVAL);
read_ahead[MAJOR(cdi->dev)] = arg;
RETURN_UP(0);
#if 0
case CDROMEJECT:
msg(DBG_IOC,"ioctl: CDROMEJECT entered.\n");
if (fam0_drive) return (0);
if (D_S[d].open_count>1) RETURN_UP(-EBUSY);
i=UnLockDoor();
D_S[d].open_count=-9; /* to get it locked next time again */
i=cc_SpinDown();
msg(DBG_IOX,"ioctl: cc_SpinDown returned %d.\n", i);
msg(DBG_TEA,"ioctl: cc_SpinDown returned %d.\n", i);
if (i<0) RETURN_UP(-EIO);
D_S[d].CD_changed=0xFF;
D_S[d].diskstate_flags=0;
D_S[d].audio_state=0;
RETURN_UP(0);
case CDROMEJECT_SW:
msg(DBG_IOC,"ioctl: CDROMEJECT_SW entered.\n");
if (fam0_drive) RETURN_UP(0);
D_S[d].f_eject=arg;
RETURN_UP(0);
#endif
default:
msg(DBG_IOC,"ioctl: unknown function request %04X\n", cmd);
RETURN_UP(-EINVAL);
......@@ -5242,54 +5312,13 @@ static int sbp_data(struct request *req)
static int sbpcd_open(struct cdrom_device_info *cdi, int purpose)
{
int i;
i = MINOR(cdi->dev);
if ((i<0) || (i>=NR_SBPCD) || (D_S[i].drv_id==-1))
{
msg(DBG_INF, "open: bad device: %04X\n", cdi->dev);
return (-ENXIO); /* no such drive */
}
MOD_INC_USE_COUNT;
down(&ioctl_read_sem);
switch_drive(i);
i=cc_ReadError();
flags_cmd_out |= f_respo2;
cc_ReadStatus(); /* command: give 1-byte status */
i=ResponseStatus();
if (famT_drive&&(i<0))
{
cc_DriveReset();
i=ResponseStatus();
#if 0
sbp_sleep(HZ);
#endif 0
i=ResponseStatus();
}
if (i<0)
{
msg(DBG_INF,"sbpcd_open: ResponseStatus timed out (%d).\n",i);
MOD_DEC_USE_COUNT;
RETURN_UP(-EIO); /* drive doesn't respond */
}
if (famT_drive) msg(DBG_TEA,"sbpcd_open: ResponseStatus=%02X\n", i);
if (!(famT_drive))
if (!st_spinning)
{
cc_SpinUp();
flags_cmd_out |= f_respo2;
cc_ReadStatus();
i=ResponseStatus();
}
if (famT_drive) msg(DBG_TEA,"sbpcd_open: status %02X\n", D_S[d].status_bits);
if (!st_door_closed||!st_caddy_in)
{
msg(DBG_INF, "sbpcd_open: no disk in drive.\n");
D_S[d].open_count=0;
MOD_DEC_USE_COUNT;
RETURN_UP(-ENXIO);
}
/*
* try to keep an "open" counter here and lock the door if 0->1.
*/
......@@ -5360,24 +5389,6 @@ static void sbpcd_release(struct cdrom_device_info * cdi)
/*
*
*/
#if 0
static struct file_operations sbpcd_fops =
{
NULL, /* lseek - default */
block_read, /* read - general block-dev read */
block_write, /* write - general block-dev write */
NULL, /* readdir - bad */
NULL, /* poll */
sbpcd_ioctl, /* ioctl */
NULL, /* mmap */
sbpcd_open, /* open */
sbpcd_release, /* release */
NULL, /* fsync */
NULL, /* fasync */
sbpcd_chk_disk_change, /* media_change */
NULL /* revalidate */
};
#endif
static int sbpcd_media_changed( struct cdrom_device_info *cdi, int disc_nr);
static struct cdrom_device_ops sbpcd_dops = {
sbpcd_open, /* open */
......@@ -5394,7 +5405,7 @@ static struct cdrom_device_ops sbpcd_dops = {
sbpcd_audio_ioctl, /* audio ioctl */
sbpcd_dev_ioctl, /* device-specific ioctl */
CDC_CLOSE_TRAY | CDC_OPEN_TRAY | CDC_LOCK | CDC_MULTI_SESSION |
CDC_MEDIA_CHANGED | CDC_MCN | CDC_PLAY_AUDIO, /* capability */
CDC_MEDIA_CHANGED | CDC_MCN | CDC_PLAY_AUDIO | CDC_IOCTLS, /* capability */
1, /* number of minor devices */
};
......@@ -5556,7 +5567,7 @@ __initfunc(int SBPCD_INIT(void))
int i=0, j=0;
int addr[2]={1, CDROM_PORT};
int port_index;
sti();
msg(DBG_INF,"sbpcd.c %s\n", VERSION);
......@@ -5630,14 +5641,6 @@ __initfunc(int SBPCD_INIT(void))
check_datarate();
msg(DBG_INI,"check_datarate done.\n");
#if 0
if (!famL_drive)
{
OUT(CDo_reset,0);
sbp_sleep(HZ);
}
#endif 0
for (j=0;j<NR_SBPCD;j++)
{
if (D_S[j].drv_id==-1) continue;
......@@ -5830,11 +5833,6 @@ static int sbpcd_chk_disk_change(kdev_t full_dev)
msg(DBG_CHK,"media_check (%d) called\n", MINOR(full_dev));
i=MINOR(full_dev);
if ( (i<0) || (i>=NR_SBPCD) || (D_S[i].drv_id==-1) )
{
msg(DBG_INF, "media_check: invalid device %04X.\n", full_dev);
return (-1);
}
if (D_S[i].CD_changed==0xFF)
{
......
......@@ -119,14 +119,14 @@
#define JUKEBOX 0
#else
#define JUKEBOX 1
#endif DISTRIBUTION
#endif /* DISTRIBUTION */
/* tray control: eject tray after last use */
#if DISTRIBUTION
#define EJECT 0
#else
#define EJECT 1
#endif DISTRIBUTION
#endif /* DISTRIBUTION */
/* max. number of audio frames to read with one */
/* request (allocates n* 2352 bytes kernel memory!) */
......@@ -570,7 +570,7 @@ pause: 8d pr 00 00 00 00 00. (0) pause (pr=00)
resume (pr=80) audio playing
Mode Select:
84 00 nn-nn ??-?? 00 (0) nn-nn: 2048 or 2340
84 00 nn-nn ??.?? 00 (0) nn-nn: 2048 or 2340
possibly defines transfer size
set_vol: 84 83 00 00 sw le 00. (0) sw(itch): lrxxxxxx (off=1)
......@@ -604,12 +604,12 @@ seek: 01 00 ll-bb-aa 00 00. (0)
seek: 01 02 mm-ss-ff 00 00. (0)
Read Data:
read: 02 xx-xx-xx nn-nn fl. (??) read nn-nn blocks of 2048 bytes,
read: 02 xx-xx-xx nn-nn fl. (?) read nn-nn blocks of 2048 bytes,
starting at block xx-xx-xx
fl=0: "lba"-, =2:"msf-bcd"-coded xx-xx-xx
Read XA-Data:
read: 03 xx-xx-xx nn-nn fl. (??) read nn-nn blocks of 2340 bytes,
read: 03 xx-xx-xx nn-nn fl. (?) read nn-nn blocks of 2340 bytes,
starting at block xx-xx-xx
fl=0: "lba"-, =2:"msf-bcd"-coded xx-xx-xx
......@@ -838,7 +838,7 @@ Read XA Parameter:
/*==========================================================================*/
/*==========================================================================*/
#endif _LINUX_SBPCD_H
#endif /* _LINUX_SBPCD_H */
/*==========================================================================*/
/*
* Overrides for Emacs so that we follow Linus's tabbing style.
......
......@@ -38,11 +38,6 @@ O_OBJS = zftape-compress.o lzrw3.o
M_OBJS = $(O_TARGET)
include $(TOPDIR)/Rules.make
#
# sorry, a special rule.
#
lzrw3.o: lzrw3.c
$(CC) $(CFLAGS) -O6 -funroll-all-loops -c $<
CFLAGS_lzrw3.o := -O6 -funroll-all-loops
include $(TOPDIR)/Rules.make
......@@ -74,17 +74,6 @@
# The 8390 drivers share the EI_DEBUG setting.
# General options for Space.c
OPTS = # -DETH0_ADDR=0x300 -DETH0_IRQ=11
WD_OPTS = #-DWD_SHMEM=0xDD000
EL2_OPTS = #-DEL2_AUI
NE_OPTS =
HP_OPTS =
PLIP_OPTS =
DEPCA_OPTS =
EWRK3_OPTS =
DE4X5_OPTS =
DEFXX_OPTS =
ELP_OPTS =
TULIP_OPTS =
CS89x0_OPTS =
CONFIG_Space.o = # -DETH0_ADDR=0x300 -DETH0_IRQ=11
CONFIG_3c503.o = # -DEL2_AUI
CONFIG_wd.o = # -DWD_SHMEM=0xDD000
......@@ -735,80 +735,5 @@ include $(TOPDIR)/Rules.make
clean:
rm -f core *.o *.a *.s
wd.o: wd.c CONFIG
$(CC) $(CPPFLAGS) $(CFLAGS) $(WD_OPTS) -c $<
3c503.o: 3c503.c CONFIG
$(CC) $(CPPFLAGS) $(CFLAGS) $(EL2_OPTS) -c $<
3c505.o: 3c505.c CONFIG
$(CC) $(CPPFLAGS) $(CFLAGS) $(ELP_OPTS) -c $<
de4x5.o: de4x5.c CONFIG
$(CC) $(CPPFLAGS) $(CFLAGS) $(DE4X5_OPTS) -c $<
ewrk3.o: ewrk3.c CONFIG
$(CC) $(CPPFLAGS) $(CFLAGS) $(EWRK3_OPTS) -c $<
depca.o: depca.c CONFIG
$(CC) $(CPPFLAGS) $(CFLAGS) $(DEPCA_OPTS) -c $<
Space.o: Space.c ../../include/linux/autoconf.h CONFIG
$(CC) $(CPPFLAGS) $(CFLAGS) $(OPTS) -c $<
net_init.o: ../../include/linux/autoconf.h
ne.o: ne.c CONFIG
$(CC) $(CPPFLAGS) $(CFLAGS) $(NE_OPTS) -c $<
hp.o: hp.c CONFIG
$(CC) $(CPPFLAGS) $(CFLAGS) $(HP_OPTS) -c $<
plip.o: plip.c CONFIG
$(CC) $(CPPFLAGS) $(CFLAGS) $(PLIP_OPTS) -c $<
slip.o: slip.c CONFIG
$(CC) $(CPPFLAGS) $(CFLAGS) -c $<
strip.o: strip.c CONFIG
$(CC) $(CPPFLAGS) $(CFLAGS) -c $<
dummy.o: dummy.c CONFIG
$(CC) $(CPPFLAGS) $(CFLAGS) -c $<
de600.o: de600.c CONFIG
$(CC) $(CPPFLAGS) $(CFLAGS) $(DE600_OPTS) -c $<
de620.o: de620.c CONFIG
$(CC) $(CPPFLAGS) $(CFLAGS) $(DE620_OPTS) -c $<
lance.o: lance.c CONFIG
$(CC) $(CPPFLAGS) $(CFLAGS) $(LANCE_OPTS) -c $<
8390.o: 8390.c 8390.h CONFIG
sdla.o: sdla.c CONFIG
dlci.o: dlci.c CONFIG
sdladrv.o: sdladrv.c CONFIG
wanpipe.o: $(WANPIPE_OBJS)
ld -r -o $@ $(WANPIPE_OBJS)
sdlamain.o: sdlamain.c CONFIG
sdla_x25.o: sdla_x25.c CONFIG
sdla_fr.o: sdla_fr.c CONFIG
sdla_ppp.o: sdla_ppp.c CONFIG
dgrs.o: dgrs.c dgrs.h CONFIG
$(CC) $(CPPFLAGS) $(CFLAGS) -c $<
ltpc.o: ltpc.c ltpc.h CONFIG
$(CC) $(CPPFLAGS) $(CFLAGS) -c $<
tulip.o: tulip.c CONFIG
$(CC) $(CPPFLAGS) $(CFLAGS) $(TULIP_OPTS) -c $<
......@@ -13,8 +13,9 @@ MIX_OBJS :=
MOD_LIST_NAME := SCSI_MODULES
SCSI_SRCS = $(wildcard $(L_OBJS:%.o=%.c))
AHA152X = -DDEBUG_AHA152X -DAUTOCONF
GDTH = #-DDEBUG_GDTH=2 -D__SERIAL__ -D__COM2__ -DGDTH_STATISTICS
CFLAGS_aha152x.o = -DDEBUG_AHA152X -DAUTOCONF
CFLAGS_gdth.o = # -DDEBUG_GDTH=2 -D__SERIAL__ -D__COM2__ -DGDTH_STATISTICS
CFLAGS_seagate.o = -DARBITRATE -DSLOW_HANDSHAKE -DFAST32 -DPARITY
.SUFFIXES:
.SUFFIXES: .c .o .h .a
......@@ -455,24 +456,14 @@ endif
include $(TOPDIR)/Rules.make
BusLogic.o: BusLogic.c FlashPoint.c
# This gives correct output but uses old-style "excessive compilation".
# This will be fixed soon (about December 1997 or January 1998).
BusLogic.o: BusLogic.c FlashPoint.c ../../include/linux/autoconf.h
$(CC) $(CFLAGS) -c BusLogic.c -o BusLogic.O
$(CC) $(CFLAGS) -c FlashPoint.c -o FlashPoint.O
$(LD) -r -o BusLogic.o BusLogic.O FlashPoint.O
rm -f BusLogic.O FlashPoint.O
aha152x.o: aha152x.c
$(CC) $(CFLAGS) $(AHA152X) -c aha152x.c
gdth.o: gdth.c gdth.h gdth_proc.c gdth_proc.h
$(CC) $(CFLAGS) $(GDTH) -c gdth.c
aic7xxx.o: aic7xxx.c aic7xxx_seq.h aic7xxx_reg.h
$(CC) $(CFLAGS) -c -o $@ aic7xxx.c
seagate.o: seagate.c
$(CC) $(CFLAGS) -DARBITRATE -DSLOW_HANDSHAKE -DFAST32 -DPARITY -c seagate.c
53c8xx_d.h 53c8xx_u.h : 53c7,8xx.scr script_asm.pl
ln -sf 53c7,8xx.scr fake.c
$(CPP) -traditional -DCHIP=810 fake.c | grep -v '^#' | perl script_asm.pl
......
......@@ -532,7 +532,7 @@ static int ad1848_mixer_ioctl(int dev, unsigned int cmd, caddr_t arg)
int val;
if (cmd == SOUND_MIXER_PRIVATE1) {
if (__get_user(val, (int *)arg))
if (get_user(val, (int *)arg))
return -EFAULT;
if (val != 0xffff) {
......@@ -546,22 +546,22 @@ static int ad1848_mixer_ioctl(int dev, unsigned int cmd, caddr_t arg)
ad_write(devc, 26, ad_read(devc, 26) | 0x40); /* Mute mono out */
}
val = devc->mixer_output_port;
return __put_user(val, (int *)arg);
return put_user(val, (int *)arg);
}
if (((cmd >> 8) & 0xff) == 'M') {
if (_SIOC_DIR(cmd) & _SIOC_WRITE)
switch (cmd & 0xff) {
case SOUND_MIXER_RECSRC:
if (__get_user(val, (int *)arg))
if (get_user(val, (int *)arg))
return -EFAULT;
val = ad1848_set_recmask(devc, val);
return __put_user(val, (int *)arg);
return put_user(val, (int *)arg);
default:
if (__get_user(val, (int *)arg))
if (get_user(val, (int *)arg))
return -EFAULT;
val = ad1848_mixer_set(devc, cmd & 0xff, val);
return __put_user(val, (int *)arg);
return put_user(val, (int *)arg);
}
else
switch (cmd & 0xff) {
......@@ -571,28 +571,28 @@ static int ad1848_mixer_ioctl(int dev, unsigned int cmd, caddr_t arg)
case SOUND_MIXER_RECSRC:
val = devc->recmask;
return __put_user(val, (int *)arg);
return put_user(val, (int *)arg);
case SOUND_MIXER_DEVMASK:
val = devc->supported_devices;
return __put_user(val, (int *)arg);
return put_user(val, (int *)arg);
case SOUND_MIXER_STEREODEVS:
val = devc->supported_devices;
if (devc->model != MD_C930)
val &= ~(SOUND_MASK_SPEAKER | SOUND_MASK_IMIX);
return __put_user(val, (int *)arg);
return put_user(val, (int *)arg);
case SOUND_MIXER_RECMASK:
val = devc->supported_rec_devices;
return __put_user(val, (int *)arg);
return put_user(val, (int *)arg);
case SOUND_MIXER_CAPS:
return __put_user(SOUND_CAP_EXCL_INPUT, (int *)arg);
return put_user(SOUND_CAP_EXCL_INPUT, (int *)arg);
default:
val = ad1848_mixer_get(devc, cmd & 0xff);
return __put_user(val, (int *)arg);
return put_user(val, (int *)arg);
}
} else
return -EINVAL;
......
......@@ -2834,115 +2834,128 @@ set_input_volumes(void)
int gus_default_mixer_ioctl(int dev, unsigned int cmd, caddr_t arg)
{
int vol, voice, val;
if (((cmd >> 8) & 0xff) == 'M') {
if (_SIOC_DIR(cmd) & _SIOC_WRITE)
switch (cmd & 0xff) {
case SOUND_MIXER_RECSRC:
if (__get_user(gus_recmask, (int *)arg))
return -EFAULT;
gus_recmask &= MIX_DEVS;
if (!(gus_recmask & (SOUND_MASK_MIC | SOUND_MASK_LINE)))
gus_recmask = SOUND_MASK_MIC;
/* Note! Input volumes are updated during next open for recording */
return __put_user(gus_recmask, (int *)arg);
case SOUND_MIXER_MIC:
if (__get_user(vol, (int *)arg))
return -EFAULT;
vol &= 0xff;
if (vol < 0)
vol = 0;
if (vol > 100)
vol = 100;
gus_mic_vol = vol;
set_input_volumes();
vol |= (vol << 8);
return __put_user(vol, (int *)arg);
int vol, val;
if (((cmd >> 8) & 0xff) != 'M')
return -EINVAL;
if (!access_ok(VERIFY_WRITE, (int *)arg, sizeof(int)))
return -EFAULT;
if (_SIOC_DIR(cmd) & _SIOC_WRITE) {
if (__get_user(val, (int *) arg))
return -EFAULT;
switch (cmd & 0xff) {
case SOUND_MIXER_RECSRC:
gus_recmask = val & MIX_DEVS;
if (!(gus_recmask & (SOUND_MASK_MIC | SOUND_MASK_LINE)))
gus_recmask = SOUND_MASK_MIC;
/* Note! Input volumes are updated during next open for recording */
val = gus_recmask;
break;
case SOUND_MIXER_MIC:
vol = val & 0xff;
if (vol < 0)
vol = 0;
if (vol > 100)
vol = 100;
gus_mic_vol = vol;
set_input_volumes();
vol |= (vol << 8);
val = vol;
break;
case SOUND_MIXER_LINE:
if (__get_user(vol, (int *)arg))
return -EFAULT;
vol &= 0xff;
if (vol < 0)
vol = 0;
if (vol > 100)
vol = 100;
gus_line_vol = vol;
set_input_volumes();
vol |= (vol << 8);
return __put_user(vol, (int *)arg);
case SOUND_MIXER_PCM:
if (__get_user(gus_pcm_volume, (int *)arg))
return -EFAULT;
gus_pcm_volume &= 0xff;
if (gus_pcm_volume < 0)
gus_pcm_volume = 0;
if (gus_pcm_volume > 100)
gus_pcm_volume = 100;
gus_audio_update_volume();
gus_pcm_volume |= (gus_pcm_volume << 8);
return __put_user(gus_pcm_volume, (int *)arg);
case SOUND_MIXER_SYNTH:
if (__get_user(gus_wave_volume, (int *)arg))
return -EFAULT;
gus_wave_volume &= 0xff;
if (gus_wave_volume < 0)
gus_wave_volume = 0;
if (gus_wave_volume > 100)
gus_wave_volume = 100;
if (active_device == GUS_DEV_WAVE)
for (voice = 0; voice < nr_voices; voice++)
dynamic_volume_change(voice); /* Apply the new vol */
gus_wave_volume |= (gus_wave_volume << 8);
return __put_user(gus_wave_volume, (int *)arg);
default:
return -EINVAL;
} else
switch (cmd & 0xff) {
/*
* Return parameters
*/
case SOUND_MIXER_RECSRC:
return __put_user(gus_recmask, (int *)arg);
case SOUND_MIXER_LINE:
vol = val & 0xff;
if (vol < 0)
vol = 0;
if (vol > 100)
vol = 100;
gus_line_vol = vol;
set_input_volumes();
vol |= (vol << 8);
val = vol;
break;
case SOUND_MIXER_PCM:
gus_pcm_volume = val & 0xff;
if (gus_pcm_volume < 0)
gus_pcm_volume = 0;
if (gus_pcm_volume > 100)
gus_pcm_volume = 100;
gus_audio_update_volume();
gus_pcm_volume |= (gus_pcm_volume << 8);
val = gus_pcm_volume;
break;
case SOUND_MIXER_SYNTH:
gus_wave_volume = val & 0xff;
if (gus_wave_volume < 0)
gus_wave_volume = 0;
if (gus_wave_volume > 100)
gus_wave_volume = 100;
if (active_device == GUS_DEV_WAVE) {
int voice;
for (voice = 0; voice < nr_voices; voice++)
dynamic_volume_change(voice); /* Apply the new vol */
}
gus_wave_volume |= (gus_wave_volume << 8);
val = gus_wave_volume;
break;
default:
return -EINVAL;
}
} else {
switch (cmd & 0xff) {
/*
* Return parameters
*/
case SOUND_MIXER_RECSRC:
val = gus_recmask;
break;
case SOUND_MIXER_DEVMASK:
return __put_user(MIX_DEVS, (int *)arg);
case SOUND_MIXER_DEVMASK:
val = MIX_DEVS;
break;
case SOUND_MIXER_STEREODEVS:
return __put_user(0, (int *)arg);
case SOUND_MIXER_STEREODEVS:
val = 0;
break;
case SOUND_MIXER_RECMASK:
val = SOUND_MASK_MIC | SOUND_MASK_LINE;
return __put_user(val, (int *)arg);
case SOUND_MIXER_RECMASK:
val = SOUND_MASK_MIC | SOUND_MASK_LINE;
break;
case SOUND_MIXER_CAPS:
return __put_user(0, (int *)arg);
case SOUND_MIXER_CAPS:
val = 0;
break;
case SOUND_MIXER_MIC:
val = gus_mic_vol | (gus_mic_vol << 8);
return __put_user(val, (int *)arg);
case SOUND_MIXER_MIC:
val = gus_mic_vol | (gus_mic_vol << 8);
break;
case SOUND_MIXER_LINE:
val = gus_line_vol | (gus_line_vol << 8);
return __put_user(val, (int *)arg);
case SOUND_MIXER_LINE:
val = gus_line_vol | (gus_line_vol << 8);
break;
case SOUND_MIXER_PCM:
val = gus_pcm_volume | (gus_pcm_volume << 8);
return __put_user(val, (int *)arg);
case SOUND_MIXER_PCM:
val = gus_pcm_volume | (gus_pcm_volume << 8);
break;
case SOUND_MIXER_SYNTH:
return __put_user(gus_wave_volume | (gus_wave_volume << 8), (int *)arg);
case SOUND_MIXER_SYNTH:
val = gus_wave_volume | (gus_wave_volume << 8);
break;
default:
return -EINVAL;
}
} else
return -EINVAL;
default:
return -EINVAL;
}
}
return __put_user(val, (int *)arg);
}
static struct mixer_operations gus_mixer_operations =
......
......@@ -123,7 +123,7 @@ static int ics2101_mixer_ioctl(int dev, unsigned int cmd, caddr_t arg)
if (((cmd >> 8) & 0xff) == 'M') {
if (_SIOC_DIR(cmd) & _SIOC_WRITE) {
if (__get_user(val, (int *)arg))
if (get_user(val, (int *)arg))
return -EFAULT;
switch (cmd & 0xff) {
case SOUND_MIXER_RECSRC:
......@@ -152,7 +152,7 @@ static int ics2101_mixer_ioctl(int dev, unsigned int cmd, caddr_t arg)
default:
return -EINVAL;
}
return __put_user(val, (int *)arg);
return put_user(val, (int *)arg);
} else {
switch (cmd & 0xff) {
/*
......@@ -200,7 +200,7 @@ static int ics2101_mixer_ioctl(int dev, unsigned int cmd, caddr_t arg)
default:
return -EINVAL;
}
return __put_user(val, (int *)arg);
return put_user(val, (int *)arg);
}
}
return -EINVAL;
......
......@@ -27,9 +27,6 @@ ifndef TOPDIR
TOPDIR=/usr/src/linux
endif
.c.o:
$(CC) $(CFLAGS) -c $<
lowlevel.o: $(OBJS)
$(LD) -r -o lowlevel.o $(OBJS)
......
......@@ -50,7 +50,7 @@ extern int sound_open_dma(int chn, char *deviceID);
extern void sound_free_dma(int chn);
extern void sound_close_dma(int chn);
extern void reporgram_timer(void);
extern void reprogram_timer(void);
#define RUNTIME_DMA_ALLOC
#define USE_AUTOINIT_DMA
......
......@@ -220,7 +220,7 @@ static int pas_mixer_ioctl(int dev, unsigned int cmd, caddr_t arg)
DEB(printk("pas2_mixer.c: int pas_mixer_ioctl(unsigned int cmd = %X, unsigned int arg = %X)\n", cmd, arg));
if (cmd == SOUND_MIXER_PRIVATE1) { /* Set loudness bit */
if (__get_user(level, (int *)arg))
if (get_user(level, (int *)arg))
return -EFAULT;
if (level == -1) /* Return current settings */
level = (mode_control & 0x04);
......@@ -231,10 +231,10 @@ static int pas_mixer_ioctl(int dev, unsigned int cmd, caddr_t arg)
set_mode(mode_control);
}
level = !!level;
return __put_user(level, (int *)arg);
return put_user(level, (int *)arg);
}
if (cmd == SOUND_MIXER_PRIVATE2) { /* Set enhance bit */
if (__get_user(level, (int *)arg))
if (get_user(level, (int *)arg))
return -EFAULT;
if (level == -1) { /* Return current settings */
if (!(mode_control & 0x03))
......@@ -254,10 +254,10 @@ static int pas_mixer_ioctl(int dev, unsigned int cmd, caddr_t arg)
i = (i + 1) * 20;
level = i;
}
return __put_user(level, (int *)arg);
return put_user(level, (int *)arg);
}
if (cmd == SOUND_MIXER_PRIVATE3) { /* Set mute bit */
if (__get_user(level, (int *)arg))
if (get_user(level, (int *)arg))
return -EFAULT;
if (level == -1) /* Return current settings */
level = !(pas_read(0x0B8A) & 0x20);
......@@ -269,10 +269,10 @@ static int pas_mixer_ioctl(int dev, unsigned int cmd, caddr_t arg)
level = !(pas_read(0x0B8A) & 0x20);
}
return __put_user(level, (int *)arg);
return put_user(level, (int *)arg);
}
if (((cmd >> 8) & 0xff) == 'M') {
if (__get_user(v, (int *)arg))
if (get_user(v, (int *)arg))
return -EFAULT;
if (_SIOC_DIR(cmd) & _SIOC_WRITE) {
v = pas_mixer_set(cmd & 0xff, v);
......@@ -303,7 +303,7 @@ static int pas_mixer_ioctl(int dev, unsigned int cmd, caddr_t arg)
break;
}
}
return __put_user(v, (int *)arg);
return put_user(v, (int *)arg);
}
return -EINVAL;
}
......
......@@ -293,14 +293,14 @@ static int sb_mixer_ioctl(int dev, unsigned int cmd, caddr_t arg)
* Use ioctl(fd, SOUND_MIXER_PRIVATE1, &mode) to turn AGC off (0) or on (1).
*/
if (cmd == SOUND_MIXER_PRIVATE1 && devc->model == MDL_SB16) {
if (__get_user(val, (int *)arg))
if (get_user(val, (int *)arg))
return -EFAULT;
sb_setmixer(devc, 0x43, (~val) & 0x01);
return 0;
}
if (((cmd >> 8) & 0xff) == 'M') {
if (_SIOC_DIR(cmd) & _SIOC_WRITE) {
if (__get_user(val, (int *)arg))
if (get_user(val, (int *)arg))
return -EFAULT;
switch (cmd & 0xff) {
case SOUND_MIXER_RECSRC:
......@@ -338,7 +338,7 @@ static int sb_mixer_ioctl(int dev, unsigned int cmd, caddr_t arg)
ret = sb_mixer_get(devc, cmd & 0xff);
break;
}
return __put_user(ret, (int *)arg);
return put_user(ret, (int *)arg);
} else
return -EINVAL;
}
......
......@@ -12,10 +12,8 @@ O_OBJS := dir.o file.o inode.o ioctl.o mmap.o ncplib_kernel.o sock.o
M_OBJS := $(O_TARGET)
# If you want debugging output, please uncomment the following line
# EXTRA_CFLAGS += -DDEBUG_NCP=1
include $(TOPDIR)/Rules.make
CFLAGS_ncplib_kernel.o := -finline-functions
ncplib_kernel.o: ncplib_kernel.c ncplib_kernel.h
$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -finline-functions -c -o $@ $<
include $(TOPDIR)/Rules.make
......@@ -132,6 +132,42 @@ static struct dentry * proc_follow_link(struct dentry *dentry,
return result;
}
/*
* This pretty-prints the pathname of a dentry,
* clarifying sockets etc.
*/
static int do_proc_readlink(struct dentry *dentry, char * buffer, int buflen)
{
struct inode * inode;
char * tmp = (char*)__get_free_page(GFP_KERNEL), *path, *pattern;
int len;
/* Check for special dentries.. */
pattern = NULL;
inode = dentry->d_inode;
if (inode && dentry->d_parent == dentry) {
if (inode->i_sock)
pattern = "socket:[%lu]";
if (inode->i_pipe)
pattern = "pipe:[%lu]";
}
if (pattern) {
len = sprintf(tmp, pattern, inode->i_ino);
path = tmp;
} else {
path = d_path(dentry, tmp, PAGE_SIZE);
len = tmp + PAGE_SIZE - path;
}
if (len < buflen)
buflen = len;
dput(dentry);
copy_to_user(buffer, path, buflen);
free_page((unsigned long)tmp);
return buflen;
}
static int proc_readlink(struct dentry * dentry, char * buffer, int buflen)
{
int error;
......@@ -141,18 +177,7 @@ static int proc_readlink(struct dentry * dentry, char * buffer, int buflen)
if (!IS_ERR(dentry)) {
error = -ENOENT;
if (dentry) {
char * tmp = (char*)__get_free_page(GFP_KERNEL), *path;
int len;
path = d_path(dentry, tmp, PAGE_SIZE);
len = tmp + PAGE_SIZE - path;
if (len < buflen)
buflen = len;
dput(dentry);
copy_to_user(buffer, path, buflen);
free_page((unsigned long)tmp);
error = buflen;
error = do_proc_readlink(dentry, buffer, buflen);
}
}
return error;
......
......@@ -4,7 +4,7 @@
* Copyright (C) 1992 David Giller, rafetmad@oxy.edu
* 1994, 1995 Eberhard Moenkeberg, emoenke@gwdg.de
* 1996 David van Leeuwen, david@tm.tno.nl
* 1997 Erik Andersen, andersee@debian.org
* 1997, 1998 Erik Andersen, andersee@debian.org
*/
#ifndef _LINUX_CDROM_H
......@@ -417,4 +417,4 @@ extern int register_cdrom(struct cdrom_device_info *cdi);
extern int unregister_cdrom(struct cdrom_device_info *cdi);
#endif /* End of kernel only stuff */
#endif _LINUX_CDROM_H
#endif /* _LINUX_CDROM_H */
......@@ -3,28 +3,4 @@
#include <linux/autoconf.h>
/*
* Defines for what uname() should return
*/
#ifndef UTS_SYSNAME
#define UTS_SYSNAME "Linux"
#endif
#ifndef UTS_MACHINE
#define UTS_MACHINE "unknown"
#endif
#ifndef UTS_NODENAME
#define UTS_NODENAME "(none)" /* set by sethostname() */
#endif
#ifndef UTS_DOMAINNAME
#define UTS_DOMAINNAME "(none)" /* set by setdomainname() */
#endif
/*
* The definitions for UTS_RELEASE and UTS_VERSION are now defined
* in linux/version.h, and should only be used by linux/version.c
*/
#endif
......@@ -266,6 +266,7 @@ static inline int buffer_protected(struct buffer_head * bh)
#include <linux/ufs_fs_i.h>
#include <linux/romfs_fs_i.h>
#include <linux/smb_fs_i.h>
#include <linux/hfs_fs_i.h>
/*
* Attribute flags. These should be or-ed together to figure out what
......@@ -366,6 +367,7 @@ struct inode {
struct ufs_inode_info ufs_i;
struct romfs_inode_info romfs_i;
struct smb_inode_info smbfs_i;
struct hfs_inode_info hfs_i;
struct socket socket_i;
void *generic_ip;
} u;
......@@ -503,6 +505,7 @@ extern int fasync_helper(struct file *, int, struct fasync_struct **);
#include <linux/ufs_fs_sb.h>
#include <linux/romfs_fs_sb.h>
#include <linux/smb_fs_sb.h>
#include <linux/hfs_fs_sb.h>
struct super_block {
kdev_t s_dev;
......@@ -538,6 +541,7 @@ struct super_block {
struct ufs_sb_info ufs_sb;
struct romfs_sb_info romfs_sb;
struct smb_sb_info smbfs_sb;
struct hfs_sb_info hfs_sb;
void *generic_sbp;
} u;
};
......
......@@ -208,35 +208,12 @@ struct hfs_cap_info {
#ifdef __KERNEL__
#include <linux/version.h>
#if defined(CONFIG_HFS_FS) || defined(CONFIG_HFS_FS_MODULE)
#if (LINUX_VERSION_CODE < 0x020001)
#error "Linux kernel version 2.0.1 or newer is required."
#endif
#if (LINUX_VERSION_CODE < 0x020100) && !defined(__alpha__)
typedef int hfs_rwret_t;
typedef int hfs_rwarg_t;
#else
typedef ssize_t hfs_rwret_t;
typedef size_t hfs_rwarg_t;
#endif
#if (LINUX_VERSION_CODE < 0x020104)
# define copy_to_user memcpy_tofs
# define copy_from_user memcpy_fromfs
#endif
#if (LINUX_VERSION_CODE < 0x020106)
# include <asm/segment.h>
#else
# include <asm/uaccess.h>
#endif
#if (LINUX_VERSION_CODE < 0x020105)
extern inline void clear_user(char *addr, off_t count)
{ while (count--) { put_user(0, addr++); } }
#endif
#include <asm/uaccess.h>
/* Some forward declarations */
struct hfs_fork;
......@@ -328,18 +305,8 @@ extern int hfs_mac2eight(char *, const struct hfs_name *);
extern int hfs_mac2alpha(char *, const struct hfs_name *);
extern int hfs_mac2triv(char *, const struct hfs_name *);
#ifdef MODULE /* The kernel may or may not know about HFS */
extern __inline__ struct hfs_inode_info *HFS_I(struct inode *inode) {
return (struct hfs_inode_info *)(&inode->u);
}
extern __inline__ struct hfs_sb_info *HFS_SB(struct super_block *super) {
return (struct hfs_sb_info *)(&super->u);
}
#else
# define HFS_I(X) (&((X)->u.hfs_i))
# define HFS_SB(X) (&((X)->u.hfs_sb))
#endif
#define HFS_I(X) (&((X)->u.hfs_i))
#define HFS_SB(X) (&((X)->u.hfs_sb))
extern __inline__ void hfs_nameout(struct inode *dir, struct hfs_name *out,
const char *in, int len) {
......@@ -388,6 +355,8 @@ static __inline__ void hfs_drop_special(const struct hfs_name *name,
}
}
}
#endif
#endif /* __KERNEL__ */
#endif
#ifndef _LINUX_UTS_H
#define _LINUX_UTS_H
/*
* Defines for what uname() should return
*/
#ifndef UTS_SYSNAME
#define UTS_SYSNAME "Linux"
#endif
#ifndef UTS_MACHINE
#define UTS_MACHINE "unknown"
#endif
#ifndef UTS_NODENAME
#define UTS_NODENAME "(none)" /* set by sethostname() */
#endif
#ifndef UTS_DOMAINNAME
#define UTS_DOMAINNAME "(none)" /* set by setdomainname() */
#endif
#endif
......@@ -6,15 +6,11 @@
* May be freely distributed as part of Linux.
*/
#include <linux/config.h>
#include <linux/uts.h>
#include <linux/utsname.h>
#include <linux/version.h>
#include <linux/compile.h>
/* make the "checkconfig" script happy: we really need to include config.h */
#ifdef CONFIG_BOGUS
#endif
#define version(a) Version_ ## a
#define version_string(a) version(a)
......
......@@ -21,7 +21,6 @@ ifeq ($(CONFIG_MODULES),y)
OX_OBJS += ksyms.o
endif
include $(TOPDIR)/Rules.make
CFLAGS_sched.o := $(PROFILING) -fno-omit-frame-pointer
sched.o: sched.c
$(CC) $(CFLAGS) $(PROFILING) -fno-omit-frame-pointer -c $<
include $(TOPDIR)/Rules.make
......@@ -25,15 +25,15 @@ tkparse: tkparse.o tkcond.o tkgen.o
${HOSTCC} -o tkparse tkparse.o tkcond.o tkgen.o
tkparse.o: tkparse.c tkparse.h
$(HOSTCC) $(HOSTCFLAGS) -c -o tkparse.o tkparse.c
tkcond.o: tkcond.c tkparse.h
$(HOSTCC) $(HOSTCFLAGS) -c -o tkcond.o tkcond.c
tkgen.o: tkgen.c tkparse.h
$(HOSTCC) $(HOSTCFLAGS) -c -o tkgen.o tkgen.c
tkparse.o tkcond.o tkgen.o:
$(HOSTCC) $(HOSTCFLAGS) -c -o $@ $(@:.o=.c)
clean:
rm -f *~ kconfig.tk *.o tkparse
rm -f *~ kconfig.tk *.o tkparse mkdep split-include
include $(TOPDIR)/Rules.make
......@@ -31,6 +31,11 @@
# 081297 Pavel Machek (pavel@atrey.karlin.mff.cuni.cz) - better error
# handling
#
# 131197 Michael Chastain (mec@shout.net) - output all lines for a
# choice list, not just the selected one. This makes the output
# the same as Configure output, which is important for smart config
# dependencies.
#
# 101297 Michael Chastain (mec@shout.net) - remove sound driver cruft.
#
# 221297 Michael Chastain (mec@shout.net) - make define_bool actually
......@@ -1051,11 +1056,19 @@ save_configuration () {
: ${current:=$default}
#
# Then extract the actual option from the list of choices.
# Output all choices (to be compatible with other configs).
#
current=${choices#*$current} ; set $current
define_bool "$1" "y"
set -- $choices
while [ -n "$2" ]
do
if eval [ "$1" = "$current" ]
then
define_bool "$2" "y"
else
define_bool "$2" "n"
fi
shift ; shift
done
}
function mainmenu_name () {
......
#! /usr/bin/perl
#
# checkconfig: find uses of CONFIG_* names without matching definitions.
use integer;
foreach $file (@ARGV)
{
# Open this file.
open(FILE, $file) || die "Can't open $file: $!\n";
# Initialize variables.
my $fInComment = 0;
my $fUseConfig = 0;
my $iLinuxConfig = 0;
my %configList = ();
LINE: while ( <FILE> )
{
# Strip comments.
$fInComment && (s+^.*?\*/+ +o ? ($fInComment = 0) : next);
m+/\*+o && (s+/\*.*?\*/+ +go, (s+/\*.*$+ +o && ($fInComment = 1)));
# Pick up definitions.
if ( m/^#/o )
{
$iLinuxConfig = $. if m/^#\s*include\s+<linux\/config\.h>/o;
$configList{uc $1} = 1 if m/^#\s*include\s+<config\/(\S*)\.h>/o;
$configList{$1} = 1 if m/^#\s*define\s+CONFIG_(\w*)/o;
$configList{$1} = 1 if m/^#\s*undef\s+CONFIG_(\w*)/o;
}
# Look for usages.
next unless m/CONFIG_/o;
WORD: while ( m/\bCONFIG_(\w*)/og )
{
$fUseConfig = 1;
last LINE if $iLinuxConfig;
next WORD if exists $configList{$1};
print "$file: $.: need CONFIG_$1.\n";
$configList{$1} = 0;
}
}
# Report superfluous includes.
if ( $iLinuxConfig && ! $fUseConfig )
{ print "$file: $iLinuxConfig: <linux/config.h> not needed.\n"; }
close(FILE);
}
# This is an awk script which does dependencies. We do NOT want it to
# recursively follow #include directives.
#
# The HPATH environment variable should be set to indicate where to look
# for include files. The -I in front of the path is optional.
#
# Surely there is a more elegant way to see if a file exists. Anyone know
# what it is?
#
function fileExists(f, TMP, dummy, result) {
if(result=FILEHASH[f]) {
if(result=="Yes") {
return "Yes"
} else {return ""}
}
ERRNO = getline dummy < f
if(ERRNO >= 0) {
close(f)
return FILEHASH[f]="Yes"
} else {
FILEHASH[f]="No"
return ""
}
}
function endfile(f) {
if (hasconfig && !needsconfig) {
printf "%s doesn't need config\n",f > "/dev/stderr"
}
if (hasdep) {
print cmd
}
}
BEGIN{
hasdep=0
hasconfig=0
needsconfig=0
incomment=0
if(!(TOPDIR=ENVIRON["TOPDIR"])) {
print "Environment variable TOPDIR is not set"
exit 1
}
split(ENVIRON["HPATH"],parray," ")
for(path in parray) {
sub("^-I","",parray[path])
sub("[/ ]*$","",parray[path])
}
}
# eliminate comments
{
# remove all comments fully contained on a single line
gsub("\\/\\*.*\\*\\/", "")
if (incomment) {
if ($0 ~ /\*\//) {
incomment = 0;
gsub(".*\\*\\/", "")
} else {
next
}
} else {
# start of multi-line comment
if ($0 ~ /\/\*/)
{
incomment = 1;
sub("\\/\\*.*", "")
} else if ($0 ~ /\*\//) {
incomment = 0;
sub(".*\\*\\/", "")
}
}
}
/^[ ]*#[ ]*if.*[^A-Za-z_]CONFIG_/ {
needsconfig=1
if (!hasconfig) {
printf "%s needs config but has not included config file\n",FILENAME > "/dev/stderr"
# only say it once per file..
hasconfig = 1
}
}
/^[ ]*#[ ]*include[ ]*[<"][^ ]*[>"]/{
found=0
if(LASTFILE!=FILENAME) {
endfile(LASTFILE)
hasdep=0
hasconfig=0
needsconfig=0
incomment=0
cmd=""
LASTFILE=FILENAME
depname=FILENAME
relpath=FILENAME
sub("\\.c$",".o: ",depname)
sub("\\.S$",".o: ",depname)
if (depname==FILENAME) {
cmd="\n\t@touch "depname
}
sub("\\.h$",".h: ",depname)
if(relpath ~ "^\\." ) {
sub("[^/]*$","", relpath)
relpath=relpath"/"
sub("//","/", relpath)
} else {
relpath=""
}
}
fname=$0
sub("^#[ ]*include[ ]*[<\"]","",fname)
sub("[>\"].*","",fname)
if (fname=="linux/config.h") {
hasconfig=1
}
rfname=relpath""fname
if(fileExists(rfname)) {
found=1
if (!hasdep) {
printf "%s", depname
}
hasdep=1
printf " \\\n %s", rfname
if(fname ~ "^\\." ) {
fnd=0;
for(i in ARGV) {
if(ARGV[i]==rfname) {
fnd=1
}
}
if(fnd==0) {
ARGV[ARGC]=rfname
++ARGC
}
}
} else {
for(path in parray) {
if(fileExists(parray[path]"/"fname)) {
shortp=parray[path]
found=1
if (!hasdep) {
printf "%s", depname
}
hasdep=1
printf " \\\n %s", parray[path]"/"fname
}
}
}
}
END{
endfile(FILENAME)
}
......@@ -228,10 +228,10 @@ proc write_comment { file1 file2 text } {
proc write_tristate { file1 file2 varname variable dep } {
if { $variable == 0 } \
then { puts $file1 "# $varname is not set"; \
puts $file2 "#undef $varname"} \
puts $file2 "#undef $varname"} \
elseif { $variable == 2 || ($dep == 2 && $variable == 1) } \
then { puts $file1 "$varname=m"; \
puts $file2 "#undef $varname"; \
puts $file2 "#undef $varname"; \
puts $file2 "#define ${varname}_MODULE 1" } \
elseif { $variable == 1 && $dep != 2 } \
then { puts $file1 "$varname=y"; \
......@@ -244,7 +244,7 @@ proc write_tristate { file1 file2 varname variable dep } {
proc write_int { file1 file2 varname variable dep } {
if { $dep == 0 } \
then { puts $file1 "# $varname is not set"; \
puts $file2 "#undef $varname"} \
puts $file2 "#undef $varname"} \
else {
puts $file1 "$varname=$variable"; \
puts $file2 "#define $varname $variable"; \
......@@ -254,7 +254,7 @@ proc write_int { file1 file2 varname variable dep } {
proc write_hex { file1 file2 varname variable dep } {
if { $dep == 0 } \
then { puts $file1 "# $varname is not set"; \
puts $file2 "#undef $varname"} \
puts $file2 "#undef $varname"} \
else {
puts $file1 "$varname=$variable"; \
puts $file2 "#define $varname 0x$variable"; \
......@@ -264,7 +264,7 @@ proc write_hex { file1 file2 varname variable dep } {
proc write_string { file1 file2 varname variable dep } {
if { $dep == 0 } \
then { puts $file1 "# $varname is not set"; \
puts $file2 "#undef $varname"} \
puts $file2 "#undef $varname"} \
else {
puts $file1 "$varname=\"$variable\""; \
puts $file2 "#define $varname \"$variable\""; \
......
#!/bin/sh
#
# This script looks to see if a directory contains .h files
#
for dir in $@; do
for hfile in $dir/*.h; do
if [ -f $hfile ]; then echo $dir; fi
break
done
done
exit 0
This diff is collapsed.
/*
* split-include.c
*
* Copyright abandoned, Michael Chastain, <mailto:mec@shout.net>.
* This is a C version of syncdep.pl by Werner Almesberger.
*
* This program takes autoconf.h as input and outputs a directory full
* of one-line include files, merging onto the old values.
*
* Think of the configuration options as key-value pairs. Then there
* are five cases:
*
* key old value new value action
*
* KEY-1 VALUE-1 VALUE-1 leave file alone
* KEY-2 VALUE-2A VALUE-2B write VALUE-2B into file
* KEY-3 - VALUE-3 write VALUE-3 into file
* KEY-4 VALUE-4 - write an empty file
* KEY-5 (empty) - leave old empty file alone
*/
#include <sys/stat.h>
#include <sys/types.h>
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#define ERROR_EXIT(strExit) \
{ \
const int errnoSave = errno; \
fprintf(stderr, "%s: ", str_my_name); \
errno = errnoSave; \
perror((strExit)); \
exit(1); \
}
int main(int argc, const char * argv [])
{
const char * str_my_name;
const char * str_file_autoconf;
const char * str_dir_config;
FILE * fp_config;
FILE * fp_target;
FILE * fp_find;
int buffer_size;
char * line;
char * old_line;
char * list_target;
char * ptarget;
struct stat stat_buf;
/* Check arg count. */
if (argc != 3)
{
fprintf(stderr, "%s: wrong number of arguments.\n", argv[0]);
exit(1);
}
str_my_name = argv[0];
str_file_autoconf = argv[1];
str_dir_config = argv[2];
/* Find a buffer size. */
if (stat(str_file_autoconf, &stat_buf) != 0)
ERROR_EXIT(str_file_autoconf);
buffer_size = 2 * stat_buf.st_size + 4096;
/* Allocate buffers. */
if ( (line = malloc(buffer_size)) == NULL
|| (old_line = malloc(buffer_size)) == NULL
|| (list_target = malloc(buffer_size)) == NULL )
ERROR_EXIT(str_file_autoconf);
/* Open autoconfig file. */
if ((fp_config = fopen(str_file_autoconf, "r")) == NULL)
ERROR_EXIT(str_file_autoconf);
/* Make output directory if needed. */
if (stat(str_dir_config, &stat_buf) != 0)
{
if (mkdir(str_dir_config, 0755) != 0)
ERROR_EXIT(str_dir_config);
}
/* Change to output directory. */
if (chdir(str_dir_config) != 0)
ERROR_EXIT(str_dir_config);
/* Put initial separator into target list. */
ptarget = list_target;
*ptarget++ = '\n';
/* Read config lines. */
while (fgets(line, buffer_size, fp_config))
{
const char * str_config;
int is_same;
int itarget;
if (line[0] != '#')
continue;
if ((str_config = strstr(line, "CONFIG_")) == NULL)
continue;
/* Make the output file name. */
str_config += sizeof("CONFIG_") - 1;
for (itarget = 0; !isspace(str_config[itarget]); itarget++)
{
char c = str_config[itarget];
if (isupper(c)) c = tolower(c);
if (c == '_') c = '/';
ptarget[itarget] = c;
}
ptarget[itarget++] = '.';
ptarget[itarget++] = 'h';
ptarget[itarget++] = '\0';
/* Check for existing file. */
is_same = 0;
if ((fp_target = fopen(ptarget, "r")) != NULL)
{
fgets(old_line, buffer_size, fp_target);
if (fclose(fp_target) != 0)
ERROR_EXIT(ptarget);
if (!strcmp(line, old_line))
is_same = 1;
}
if (!is_same)
{
/* Auto-create directories. */
int islash;
for (islash = 0; islash < itarget; islash++)
{
if (ptarget[islash] == '/')
{
ptarget[islash] = '\0';
if (stat(ptarget, &stat_buf) != 0
&& mkdir(ptarget, 0755) != 0)
ERROR_EXIT( ptarget );
ptarget[islash] = '/';
}
}
/* Write the file. */
if ((fp_target = fopen(ptarget, "w" )) == NULL)
ERROR_EXIT(ptarget);
fputs(line, fp_target);
if (ferror(fp_target) || fclose(fp_target) != 0)
ERROR_EXIT(ptarget);
}
/* Update target list */
ptarget += itarget;
*(ptarget-1) = '\n';
}
/*
* Close autoconfig file.
* Terminate the target list.
*/
if (fclose(fp_config) != 0)
ERROR_EXIT(str_file_autoconf);
*ptarget = '\0';
/*
* Fix up existing files which have no new value.
* This is Case 4 and Case 5.
*
* I re-read the tree and filter it against list_target.
* This is crude. But it avoids data copies. Also, list_target
* is compact and contiguous, so it easily fits into cache.
*
* Notice that list_target contains strings separated by \n,
* with a \n before the first string and after the last.
* fgets gives the incoming names a terminating \n.
* So by having an initial \n, strstr will find exact matches.
*/
fp_find = popen("find * -type f -print", "r");
if (fp_find == 0)
ERROR_EXIT( "find" );
line[0] = '\n';
while (fgets(line+1, buffer_size, fp_find))
{
if (strstr(list_target, line) == NULL)
{
/*
* This is an old file with no CONFIG_* flag in autoconf.h.
*/
/* First strip the \n. */
line[strlen(line)-1] = '\0';
/* Grab size. */
if (stat(line+1, &stat_buf) != 0)
ERROR_EXIT(line);
/* If file is not empty, make it empty and give it a fresh date. */
if (stat_buf.st_size != 0)
{
if ((fp_target = fopen(line+1, "w")) == NULL)
ERROR_EXIT(line);
if (fclose(fp_target) != 0)
ERROR_EXIT(line);
}
}
}
if (pclose(fp_find) != 0)
ERROR_EXIT("find");
return 0;
}
......@@ -53,6 +53,14 @@
* 1997 12 08
* Michael Chastain - Remove sound driver special cases.
*
* 1997 11 15
* Michael Chastain - For choice buttons, write values for all options,
* not just the single chosen one. This is compatible
* with 'make config' and 'make oldconfig', and is
* needed so smart-config dependencies work if the
* user switches from one configuration method to
* another.
*
* TO DO:
* - clean up - there are useless ifdef's everywhere.
* - better comments throughout - C code generating tcl is really cryptic.
......@@ -1034,9 +1042,10 @@ void dump_tk_script(struct kconfig *scfg)
cfg1 != NULL && cfg1->tok == tok_choice;
cfg1 = cfg1->next)
{
printf("\tif { $%s == \"%s\" } then { write_tristate $cfg $autocfg %s 1 $notmod }\n",
printf("\tif { $%s == \"%s\" } then { write_tristate $cfg $autocfg %s 1 $notmod } else { write_tristate $cfg $autocfg %s 0 $notmod }\n",
cfg->optionname,
cfg1->label,
cfg1->optionname,
cfg1->optionname);
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment