summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorenami <enami@NetBSD.org>1997-10-01 01:18:38 +0000
committerenami <enami@NetBSD.org>1997-10-01 01:18:38 +0000
commitd7d845c3d2c14ed5772b861d3587b2893db7e412 (patch)
treea48223b2648bdb5aa92fdf4e12cd01c145c3ca10 /sys
parentbaef0c4d436847168173a87fd0811e4fa0bbc666 (diff)
Cosmetic changes to keep coding style consistency in this directory;
- Indent with tab of width 8. - Use four column to indent continuation line. - Fold long line if possible. - Use return (xx) instead of return xx. - Compare pointer against NULL instead of testing like boolean. - Delete whitespace at the end of line. - Delete whitespace in front of function call operator. - Delete whitespace after cast. - Dereference a pointer to function explicitly. - Add an empty line after local variable declaration. - Use NULL instead of (char *)0. - Dont use block for single statement.
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/scsipi/atapi_base.c28
-rw-r--r--sys/dev/scsipi/atapi_cd.h160
-rw-r--r--sys/dev/scsipi/atapiconf.c84
-rw-r--r--sys/dev/scsipi/atapiconf.h76
-rw-r--r--sys/dev/scsipi/cd.c340
-rw-r--r--sys/dev/scsipi/cd_atapi.c45
-rw-r--r--sys/dev/scsipi/cd_scsi.c38
-rw-r--r--sys/dev/scsipi/ch.c50
-rw-r--r--sys/dev/scsipi/files.scsipi32
-rw-r--r--sys/dev/scsipi/if_se.c191
-rw-r--r--sys/dev/scsipi/scsi_all.h30
-rw-r--r--sys/dev/scsipi/scsi_base.c189
-rw-r--r--sys/dev/scsipi/scsi_cd.h4
-rw-r--r--sys/dev/scsipi/scsi_disk.h8
-rw-r--r--sys/dev/scsipi/scsi_tape.h28
-rw-r--r--sys/dev/scsipi/scsiconf.c76
-rw-r--r--sys/dev/scsipi/scsiconf.h23
-rw-r--r--sys/dev/scsipi/scsipi_all.h96
-rw-r--r--sys/dev/scsipi/scsipi_base.c121
-rw-r--r--sys/dev/scsipi/scsipi_base.h8
-rw-r--r--sys/dev/scsipi/scsipi_cd.h25
-rw-r--r--sys/dev/scsipi/scsipi_disk.h8
-rw-r--r--sys/dev/scsipi/scsipi_ioctl.c86
-rw-r--r--sys/dev/scsipi/scsipiconf.c5
-rw-r--r--sys/dev/scsipi/scsipiconf.h55
-rw-r--r--sys/dev/scsipi/sd.c133
-rw-r--r--sys/dev/scsipi/ss.c4
-rw-r--r--sys/dev/scsipi/ss_mustek.c24
-rw-r--r--sys/dev/scsipi/ss_scanjet.c29
-rw-r--r--sys/dev/scsipi/st.c289
-rw-r--r--sys/dev/scsipi/uk.c25
31 files changed, 1161 insertions, 1149 deletions
diff --git a/sys/dev/scsipi/atapi_base.c b/sys/dev/scsipi/atapi_base.c
index b67c4d4bd21..4b1eb233140 100644
--- a/sys/dev/scsipi/atapi_base.c
+++ b/sys/dev/scsipi/atapi_base.c
@@ -1,4 +1,4 @@
-/* $NetBSD: atapi_base.c,v 1.2 1997/08/27 11:26:13 bouyer Exp $ */
+/* $NetBSD: atapi_base.c,v 1.3 1997/10/01 01:18:38 enami Exp $ */
/*
* Copyright (c) 1994, 1995, 1997 Charles M. Hannum. All rights reserved.
@@ -56,7 +56,7 @@
*
* THIS IS THE DEFAULT ERROR HANDLER
*/
-int
+int
atapi_interpret_sense(xs)
struct scsipi_xfer *xs;
{
@@ -75,7 +75,7 @@ atapi_interpret_sense(xs)
("calling private err_handler()\n"));
error = (*sc_link->device->err_handler) (xs);
if (error != -1)
- return error; /* error >= 0 better ? */
+ return (error); /* error >= 0 better ? */
}
/* otherwise use the default */
switch (key) {
@@ -90,9 +90,9 @@ atapi_interpret_sense(xs)
if ((sc_link->flags & SDEV_REMOVABLE) != 0)
sc_link->flags &= ~SDEV_MEDIA_LOADED;
if ((xs->flags & SCSI_IGNORE_NOT_READY) != 0)
- return 0;
+ return (0);
if ((xs->flags & SCSI_SILENT) != 0)
- return EIO;
+ return (EIO);
msg = "not ready";
error = EIO;
break;
@@ -106,9 +106,9 @@ atapi_interpret_sense(xs)
break;
case 0x5: /* ILLEGAL REQUEST */
if ((xs->flags & SCSI_IGNORE_ILLEGAL_REQUEST) != 0)
- return 0;
+ return (0);
if ((xs->flags & SCSI_SILENT) != 0)
- return EIO;
+ return (EIO);
msg = "illegal request";
error = EINVAL;
break;
@@ -118,9 +118,9 @@ atapi_interpret_sense(xs)
if ((xs->flags & SCSI_IGNORE_MEDIA_CHANGE) != 0 ||
/* XXX Should reupload any transient state. */
(sc_link->flags & SDEV_REMOVABLE) == 0)
- return ERESTART;
+ return (ERESTART);
if ((xs->flags & SCSI_SILENT) != 0)
- return EIO;
+ return (EIO);
msg = "unit attention";
error = EIO;
break;
@@ -163,7 +163,7 @@ atapi_interpret_sense(xs)
}
}
- return error;
+ return (error);
}
@@ -193,7 +193,7 @@ atapi_print_addr(sc_link)
* long the data is supposed to be. If we have a buf
* to associate with the transfer, we need that too.
*/
-int
+int
atapi_scsipi_cmd(sc_link, scsipi_cmd, cmdlen, data_addr, datalen,
retries, timeout, bp, flags)
struct scsipi_link *sc_link;
@@ -218,17 +218,17 @@ atapi_scsipi_cmd(sc_link, scsipi_cmd, cmdlen, data_addr, datalen,
if ((xs = scsipi_make_xs(sc_link, scsipi_cmd, cmdlen, data_addr,
datalen, retries, timeout, bp, flags)) == NULL)
- return ENOMEM;
+ return (ENOMEM);
xs->cmdlen = (sc_link->scsipi_atapi.cap & ACAP_LEN) ? 16 : 12;
if ((error = scsipi_execute_xs(xs)) == EJUSTRETURN)
- return 0;
+ return (0);
/*
* we have finished with the xfer stuct, free it and
* check if anyone else needs to be started up.
*/
scsipi_free_xs(xs, flags);
- return error;
+ return (error);
}
diff --git a/sys/dev/scsipi/atapi_cd.h b/sys/dev/scsipi/atapi_cd.h
index 42e1a51e16a..a4ae6c434ba 100644
--- a/sys/dev/scsipi/atapi_cd.h
+++ b/sys/dev/scsipi/atapi_cd.h
@@ -1,4 +1,4 @@
-/* $NetBSD: atapi_cd.h,v 1.2 1997/08/27 11:26:14 bouyer Exp $ */
+/* $NetBSD: atapi_cd.h,v 1.3 1997/10/01 01:18:40 enami Exp $ */
/*
* Copyright (c) 1996 Manuel Bouyer. All rights reserved.
@@ -29,7 +29,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#define ATAPI_MODE_SELECT 0x55
+#define ATAPI_MODE_SELECT 0x55
struct atapi_mode_select {
u_int8_t opcode;
u_int8_t byte2;
@@ -41,9 +41,9 @@ struct atapi_mode_select {
u_int8_t unused2[7];
};
-#define ATAPI_MODE_SENSE 0x5a
+#define ATAPI_MODE_SENSE 0x5a
struct atapi_mode_sense {
- u_int8_t opcode;
+ u_int8_t opcode;
u_int8_t byte2;
u_int8_t page;
u_int8_t reserved1[4];
@@ -52,94 +52,96 @@ struct atapi_mode_sense {
};
struct atapi_cap_page {
- /* Capabilities page */
- u_int8_t page_code;
- u_int8_t param_len;
- u_int8_t reserved2[2];
+ /* Capabilities page */
+ u_int8_t page_code;
+ u_int8_t param_len;
+ u_int8_t reserved2[2];
u_int8_t cap1;
-#define AUDIO_PLAY 0x01
-#define AUDIO_PLAY 0x01 /* audio play supported */
-#define AV_COMPOSITE /* composite audio/video supported */
+#define AUDIO_PLAY 0x01
+#define AUDIO_PLAY 0x01 /* audio play supported */
+#define AV_COMPOSITE /* composite audio/video supported */
#define DA_PORT1 /* digital audio on port 1 */
#define DA_PORT2 /* digital audio on port 2 */
#define M2F1 /* mode 2 form 1 (XA) read */
#define M2F2 /* mode 2 form 2 format */
-#define CD_MULTISESSION /* multi-session photo-CD */
- u_int8_t cap2;
-#define CD_DA 0x01 /* audio-CD read supported */
-#define CD_DA_STREAM 0x02 /* CD-DA streaming */
-#define RW_SUB 0x04 /* combined R-W subchannels */
-#define RW_SUB_CORR 0x08 /* R-W subchannel data corrected */
-#define C2_ERRP 0x10 /* C2 error pointers supported */
-#define ISRC 0x20 /* can return the ISRC */
-#define UPC 0x40 /* can return the catalog number UPC */
+#define CD_MULTISESSION /* multi-session photo-CD */
+ u_int8_t cap2;
+#define CD_DA 0x01 /* audio-CD read supported */
+#define CD_DA_STREAM 0x02 /* CD-DA streaming */
+#define RW_SUB 0x04 /* combined R-W subchannels */
+#define RW_SUB_CORR 0x08 /* R-W subchannel data corrected */
+#define C2_ERRP 0x10 /* C2 error pointers supported */
+#define ISRC 0x20 /* can return the ISRC */
+#define UPC 0x40 /* can return the catalog number UPC */
u_int8_t m_status;
-#define CANLOCK 0x01 /* could be locked */
-#define LOCK_STATE 0x02 /* current lock state */
-#define PREVENT_JUMP 0x04 /* prevent jumper installed */
-#define CANEJECT 0x08 /* can eject */
-#define MECH_MASK 0xe0 /* loading mechanism type */
-#define MECH_CADDY 0x00
-#define MECH_TRAY 0x20
-#define MECH_POPUP 0x40
-#define MECH_CHANGER_INDIV 0x80
-#define MECH_CHANGER_CARTRIDGE 0xa0
+#define CANLOCK 0x01 /* could be locked */
+#define LOCK_STATE 0x02 /* current lock state */
+#define PREVENT_JUMP 0x04 /* prevent jumper installed */
+#define CANEJECT 0x08 /* can eject */
+#define MECH_MASK 0xe0 /* loading mechanism type */
+#define MECH_CADDY 0x00
+#define MECH_TRAY 0x20
+#define MECH_POPUP 0x40
+#define MECH_CHANGER_INDIV 0x80
+#define MECH_CHANGER_CARTRIDGE 0xa0
u_int8_t cap3;
-#define SEPARATE_VOL 0x01 /* independent volume of channels */
-#define SEPARATE_MUTE 0x02 /* independent mute of channels */
-#define SUPP_DISK_PRESENT 0x04 /* changer can report contents of slots */
-#define SSS 0x08 /* software slot selection */
- u_int8_t max_speed[2]; /* max raw data rate in bytes/1000 */
- u_int8_t max_vol_levels[2]; /* number of discrete volume levels */
- u_int8_t buf_size[2]; /* internal buffer size in bytes/1024 */
- u_int8_t cur_speed[2]; /* current data rate in bytes/1000 */
- /* Digital drive output format description (optional?) */
- u_int8_t reserved3;
+#define SEPARATE_VOL 0x01 /* independent volume of channels */
+#define SEPARATE_MUTE 0x02 /* independent mute of channels */
+#define SUPP_DISK_PRESENT 0x04 /* changer can report contents of slots */
+#define SSS 0x08 /* software slot selection */
+ u_int8_t max_speed[2]; /* max raw data rate in bytes/1000 */
+ u_int8_t max_vol_levels[2]; /* number of discrete volume levels */
+ u_int8_t buf_size[2]; /* internal buffer size in bytes/1024 */
+ u_int8_t cur_speed[2]; /* current data rate in bytes/1000 */
+ /* Digital drive output format description (optional?) */
+ u_int8_t reserved3;
u_int8_t dig_output; /* Digital drive output format description */
- u_int8_t reserved4[2];
+ u_int8_t reserved4[2];
};
-
struct atapi_cdrom_page {
- u_int8_t page;
- u_int8_t length;
- u_int8_t reserved2;
- u_int8_t inact_mult;
- u_int8_t spm[2];
- u_int8_t fps[2];
+ u_int8_t page;
+ u_int8_t length;
+ u_int8_t reserved2;
+ u_int8_t inact_mult;
+ u_int8_t spm[2];
+ u_int8_t fps[2];
};
struct atapi_mode_data {
- struct mode_header {
- u_int8_t length[2];
- u_int8_t medium;
-#define MDT_UNKNOWN 0x00
-#define MDT_DATA_120 0x01
-#define MDT_AUDIO_120 0x02
-#define MDT_COMB_120 0x03
-#define MDT_PHOTO_120 0x04
-#define MDT_DATA_80 0x05
-#define MDT_AUDIO_80 0x06
-#define MDT_COMB_80 0x07
-#define MDT_PHOTO_80 0x08
-#define MDT_NO_DISC 0x70
-#define MDT_DOOR_OPEN 0x71
-#define MDT_FMT_ERROR 0x72
- u_int8_t reserved[5];
- } header;
-#define ATAPI_CDROM_PAGE 0x0d
-#define ATAPI_AUDIO_PAGE 0x0e
-#define ATAPI_AUDIO_PAGE_MASK 0x4e
-#define ATAPI_CAP_PAGE 0x2a
- union {
- u_int8_t page_code;
- struct atapi_cdrom_page cdrom;
- struct atapi_cap_page cap;
- struct cd_audio_page audio;
- } page;
+ struct mode_header {
+ u_int8_t length[2];
+ u_int8_t medium;
+#define MDT_UNKNOWN 0x00
+#define MDT_DATA_120 0x01
+#define MDT_AUDIO_120 0x02
+#define MDT_COMB_120 0x03
+#define MDT_PHOTO_120 0x04
+#define MDT_DATA_80 0x05
+#define MDT_AUDIO_80 0x06
+#define MDT_COMB_80 0x07
+#define MDT_PHOTO_80 0x08
+#define MDT_NO_DISC 0x70
+#define MDT_DOOR_OPEN 0x71
+#define MDT_FMT_ERROR 0x72
+ u_int8_t reserved[5];
+ } header;
+#define ATAPI_CDROM_PAGE 0x0d
+#define ATAPI_AUDIO_PAGE 0x0e
+#define ATAPI_AUDIO_PAGE_MASK 0x4e
+#define ATAPI_CAP_PAGE 0x2a
+ union {
+ u_int8_t page_code;
+ struct atapi_cdrom_page cdrom;
+ struct atapi_cap_page cap;
+ struct cd_audio_page audio;
+ } page;
};
-
-#define AUDIOPAGESIZE sizeof(struct cd_audio_page)+sizeof(struct mode_header)
-#define CDROMPAGESIZE sizeof(struct atapi_cdrom_page)+sizeof(struct mode_header)
-#define CAPPAGESIZE sizeof(struct atapi_cap_page)+sizeof(struct mode_header)
+
+#define AUDIOPAGESIZE \
+ sizeof(struct cd_audio_page)+sizeof(struct mode_header)
+#define CDROMPAGESIZE \
+ sizeof(struct atapi_cdrom_page)+sizeof(struct mode_header)
+#define CAPPAGESIZE \
+ sizeof(struct atapi_cap_page)+sizeof(struct mode_header)
diff --git a/sys/dev/scsipi/atapiconf.c b/sys/dev/scsipi/atapiconf.c
index ad8751a2edc..33cff157fee 100644
--- a/sys/dev/scsipi/atapiconf.c
+++ b/sys/dev/scsipi/atapiconf.c
@@ -1,4 +1,4 @@
-/* $NetBSD: atapiconf.c,v 1.3 1997/08/28 14:02:31 bouyer Exp $ */
+/* $NetBSD: atapiconf.c,v 1.4 1997/10/01 01:18:41 enami Exp $ */
/*
* Copyright (c) 1996 Manuel Bouyer. All rights reserved.
@@ -35,20 +35,21 @@
#include <sys/malloc.h>
#include <sys/device.h>
#include <sys/buf.h>
-#include <sys/proc.h>
+#include <sys/proc.h>
#include <dev/scsipi/scsipi_all.h>
#include <dev/scsipi/scsi_all.h>
#include <dev/scsipi/scsipiconf.h>
#include <dev/scsipi/atapiconf.h>
+
#include "locators.h"
#define SILENT_PRINTF(flags,string) if (!(flags & A_SILENT)) printf string
struct atapibus_softc {
struct device sc_dev;
- struct scsipi_link *adapter_link; /* proto supplied by adapter */
- struct scsipi_link **sc_link; /* dynamically allocated */
+ struct scsipi_link *adapter_link; /* proto supplied by adapter */
+ struct scsipi_link **sc_link; /* dynamically allocated */
};
#ifdef __BROKEN_INDIRECT_CONFIG
@@ -76,19 +77,19 @@ int atapibusprint __P((void *, const char *));
struct scsi_quirk_inquiry_pattern atapi_quirk_patterns[] = {
{{T_CDROM, T_REMOV,
- "GCD-R580B", "", "1.00"}, ADEV_LITTLETOC},
+ "GCD-R580B", "", "1.00"}, ADEV_LITTLETOC},
{{T_CDROM, T_REMOV,
- "SANYO CRD-256P", "", "1.02"}, ADEV_NOCAPACITY},
+ "SANYO CRD-256P", "", "1.02"}, ADEV_NOCAPACITY},
{{T_CDROM, T_REMOV,
- "SANYO CRD-254P", "", "1.02"}, ADEV_NOCAPACITY},
+ "SANYO CRD-254P", "", "1.02"}, ADEV_NOCAPACITY},
{{T_CDROM, T_REMOV,
- "UJDCD8730", "", "1.14"}, ADEV_NODOORLOCK},
+ "UJDCD8730", "", "1.14"}, ADEV_NODOORLOCK},
{{T_CDROM, T_REMOV,
- "ALPS ELECTRIC CO.,LTD. DC544C", "", "SW03D"}, ADEV_NOTUR},
+ "ALPS ELECTRIC CO.,LTD. DC544C", "", "SW03D"}, ADEV_NOTUR},
{{T_CDROM, T_REMOV,
- "NEC CD-ROM DRIVE:273", "", "4.21"}, ADEV_NOTUR},
+ "NEC CD-ROM DRIVE:273", "", "4.21"}, ADEV_NOTUR},
{{T_CDROM, T_REMOV,
- "MATSHITA CR-574", "", "1.06"}, ADEV_NOCAPACITY},
+ "MATSHITA CR-574", "", "1.06"}, ADEV_NOCAPACITY},
};
int
@@ -107,10 +108,10 @@ atapibusmatch(parent, cf, aux)
struct scsipi_link *sc_link = aux;
if (sc_link == NULL)
- return 0;
+ return (0);
if (sc_link->type != BUS_ATAPI)
- return 0;
- return 1;
+ return (0);
+ return (1);
}
int
@@ -131,37 +132,32 @@ atapibussubmatch(parent, cf, aux)
struct scsipi_link *sc_link = sa->sa_sc_link;
if (cf->cf_loc[ATAPIBUSCF_DRIVE] != ATAPIBUSCF_DRIVE_DEFAULT &&
- cf->cf_loc[ATAPIBUSCF_DRIVE] != sc_link->scsipi_atapi.drive)
- return 0;
+ cf->cf_loc[ATAPIBUSCF_DRIVE] != sc_link->scsipi_atapi.drive)
+ return (0);
return ((*cf->cf_attach->ca_match)(parent, cf, aux));
}
-
#if 0
void
atapi_fixquirk(sc_link)
- struct scsipi_link *ad_link;
+ struct scsipi_link *ad_link;
{
- struct atapi_identify *id = &ad_link->id;
- struct atapi_quirk_inquiry_pattern *quirk;
-
-
- /*
- * Clean up the model name, serial and
- * revision numbers.
- */
- btrim(id->model, sizeof(id->model));
- btrim(id->serial_number, sizeof(id->serial_number));
- btrim(id->firmware_revision, sizeof(id->firmware_revision));
-
+ struct atapi_identify *id = &ad_link->id;
+ struct atapi_quirk_inquiry_pattern *quirk;
+
+ /*
+ * Clean up the model name, serial and revision numbers.
+ */
+ btrim(id->model, sizeof(id->model));
+ btrim(id->serial_number, sizeof(id->serial_number));
+ btrim(id->firmware_revision, sizeof(id->firmware_revision));
}
#endif
-
void
atapibusattach(parent, self, aux)
- struct device *parent, *self;
- void *aux;
+ struct device *parent, *self;
+ void *aux;
{
struct atapibus_softc *ab = (struct atapibus_softc *)self;
struct scsipi_link *sc_link_proto = aux;
@@ -176,7 +172,7 @@ atapibusattach(parent, self, aux)
ab->adapter_link = sc_link_proto;
- nbytes = 2 * sizeof(struct scsipi_link **);
+ nbytes = 2 * sizeof(struct scsipi_link **);
ab->sc_link = (struct scsipi_link **)malloc(nbytes, M_DEVBUF,
M_NOWAIT);
if (ab->sc_link == NULL)
@@ -185,30 +181,30 @@ atapibusattach(parent, self, aux)
atapi_probe_bus(ab->sc_dev.dv_unit, -1);
}
-int
+int
atapi_probe_bus(bus, target)
-int bus, target;
+ int bus, target;
{
int maxtarget, mintarget;
struct atapibus_softc *atapi;
+
if (bus < 0 || bus >= atapibus_cd.cd_ndevs)
- return ENXIO;
+ return (ENXIO);
atapi = atapibus_cd.cd_devs[bus];
- if (!atapi)
- return ENXIO;
+ if (atapi == NULL)
+ return (ENXIO);
if (target == -1) {
maxtarget = 1;
mintarget = 0;
} else {
if (target < 0 || target > 1)
- return ENXIO;
+ return (ENXIO);
maxtarget = mintarget = target;
}
- for (target = mintarget; target <= maxtarget; target++) {
+ for (target = mintarget; target <= maxtarget; target++)
atapi_probedev(atapi, target);
- }
- return 0;
+ return (0);
}
void
@@ -291,7 +287,7 @@ atapi_probedev(atapi, target)
finger = (struct scsi_quirk_inquiry_pattern *)scsipi_inqmatch(
&sa.sa_inqbuf, (caddr_t)atapi_quirk_patterns,
sizeof(atapi_quirk_patterns) /
- sizeof(atapi_quirk_patterns[0]),
+ sizeof(atapi_quirk_patterns[0]),
sizeof(atapi_quirk_patterns[0]), &priority);
if (priority != 0)
sc_link->quirks |= finger->quirks;
diff --git a/sys/dev/scsipi/atapiconf.h b/sys/dev/scsipi/atapiconf.h
index 5225292d82b..03232b67d90 100644
--- a/sys/dev/scsipi/atapiconf.h
+++ b/sys/dev/scsipi/atapiconf.h
@@ -1,4 +1,4 @@
-/* $NetBSD: atapiconf.h,v 1.2 1997/08/27 11:26:17 bouyer Exp $ */
+/* $NetBSD: atapiconf.h,v 1.3 1997/10/01 01:18:42 enami Exp $ */
/*
* Copyright (c) 1996 Manuel Bouyer. All rights reserved.
@@ -40,7 +40,7 @@
#undef ATAPI_DEBUG_WDC
struct atapi_identify {
- struct config_s {
+ struct config_s {
u_int8_t cmd_drq_rem;
#define ATAPI_PACKET_SIZE_MASK 0x03
#define ATAPI_PACKET_SIZE_12 0x00
@@ -67,23 +67,23 @@ struct atapi_identify {
/* 0x00 and 0x01 are ATA */
#define ATAPI_GC_PROTO_TYPE_ATAPI 0x80
#define ATAPI_GC_PROTO_TYPE_RESERVED 0xc0
- } config; /* general configuration */
-
- u_int8_t cylinders[2];
- u_int8_t reserved1[2];
- u_int8_t heads[2];
- u_int8_t unf_bytes_per_track[2];
- u_int8_t unf_bytes_per_sector[2];
- u_int8_t sectors_per_track[2];
- u_int8_t reserved2[6];
- char serial_number[20];
- u_int8_t buffer_type[2];
- u_int8_t buffer_size[2];
- u_int8_t ECC_bytes_available[2];
- char firmware_revision[8];
- char model[40];
- u_int8_t sector_count[2];
- u_int8_t double_word[2]; /* == 0 for CD-ROMs */
+ } config; /* general configuration */
+
+ u_int8_t cylinders[2];
+ u_int8_t reserved1[2];
+ u_int8_t heads[2];
+ u_int8_t unf_bytes_per_track[2];
+ u_int8_t unf_bytes_per_sector[2];
+ u_int8_t sectors_per_track[2];
+ u_int8_t reserved2[6];
+ char serial_number[20];
+ u_int8_t buffer_type[2];
+ u_int8_t buffer_size[2];
+ u_int8_t ECC_bytes_available[2];
+ char firmware_revision[8];
+ char model[40];
+ u_int8_t sector_count[2];
+ u_int8_t double_word[2]; /* == 0 for CD-ROMs */
struct capabilities_s {
u_int8_t vendor;
@@ -94,40 +94,40 @@ struct atapi_identify {
#define ATAPI_IORDY 0x08 /* IORDY supported */
} capabilities;
- u_int8_t reserved3[2];
- u_int8_t PIO_cycle_timing[2];
- u_int8_t DMA_cycle_timing[2];
- u_int8_t validity[2]; /* of words 54-58, 64-70 in this table */
+ u_int8_t reserved3[2];
+ u_int8_t PIO_cycle_timing[2];
+ u_int8_t DMA_cycle_timing[2];
+ u_int8_t validity[2]; /* of words 54-58, 64-70 in this table */
#define ATAPI_VALID_FIRST 0x0 /* == 1 => words 54-58 are valid */
#define ATAPI_VALID_SECOND 0x1 /* == 1 => words 64-70 are valid */
- u_int8_t current_chs[6]; /* cylinder/head/sector */
- u_int8_t current_capacity[4];
- u_int8_t reserved4[2];
- u_int8_t user_addressable_sectors[4];
- u_int8_t singleword_DMA_mode[2];
+ u_int8_t current_chs[6]; /* cylinder/head/sector */
+ u_int8_t current_capacity[4];
+ u_int8_t reserved4[2];
+ u_int8_t user_addressable_sectors[4];
+ u_int8_t singleword_DMA_mode[2];
#define ATAPI_SW_DMA_MODE_AVAIL 0x00ff /* Mode 0 is supported */
#define ATAPI_SW_DMA_MODE_ACTIVE 0xff00 /* which mode is active */
- u_int8_t multiword_DMA_mode[2];
+ u_int8_t multiword_DMA_mode[2];
#define ATAPI_MW_DMA_MODE_AVAIL 0x00ff /* Mode 0 is supported */
#define ATAPI_MW_DMA_MODE_ACTIVE 0xff00 /* which mode is active */
- u_int8_t enhanced_PIO_mode[2];
+ u_int8_t enhanced_PIO_mode[2];
#define ATAPI_ENHANCED_PIO_AVAIL 0x0001 /* PIO Mode 3 is supported */
- u_int8_t blind_PIO_minimum_cycles[2];
- u_int8_t mw_dma_tct[2]; /* multi-word DMA transfer cycle time */
- u_int8_t min_PIO_tct_no_flow_control[2];
- u_int8_t min_PIO_tct_with_flow_control[2];
- u_int8_t reserved5[4];
- u_int8_t reserved6[114];
- u_int8_t vendor[64]; /* vendor unique */
- u_int8_t reserved7[192];
+ u_int8_t blind_PIO_minimum_cycles[2];
+ u_int8_t mw_dma_tct[2]; /* multi-word DMA transfer cycle time */
+ u_int8_t min_PIO_tct_no_flow_control[2];
+ u_int8_t min_PIO_tct_with_flow_control[2];
+ u_int8_t reserved5[4];
+ u_int8_t reserved6[114];
+ u_int8_t vendor[64]; /* vendor unique */
+ u_int8_t reserved7[192];
};
struct atapibus_attach_args {
diff --git a/sys/dev/scsipi/cd.c b/sys/dev/scsipi/cd.c
index c98e76663a1..01816d98f4f 100644
--- a/sys/dev/scsipi/cd.c
+++ b/sys/dev/scsipi/cd.c
@@ -1,4 +1,4 @@
-/* $NetBSD: cd.c,v 1.102 1997/09/09 09:07:43 bouyer Exp $ */
+/* $NetBSD: cd.c,v 1.103 1997/10/01 01:18:44 enami Exp $ */
/*
* Copyright (c) 1994, 1995, 1997 Charles M. Hannum. All rights reserved.
@@ -66,27 +66,30 @@
#include <dev/scsipi/scsipi_all.h>
#include <dev/scsipi/scsipi_cd.h>
-#include <dev/scsipi/scsipi_disk.h> /* rw_big and start_stop come from there */
+#include <dev/scsipi/scsipi_disk.h> /* rw_big and start_stop come */
+ /* from there */
#include <dev/scsipi/scsi_disk.h> /* rw comes from there */
#include <dev/scsipi/scsipiconf.h>
#include <dev/scsipi/cd_link.h>
-#include "cd.h" /* NCD_SCSI and NCD_ATAPI come from here */
+
+#include "cd.h" /* NCD_SCSI and NCD_ATAPI come */
+ /* from here */
#define CDUNIT(z) DISKUNIT(z)
#define CDPART(z) DISKPART(z)
#define MAKECDDEV(maj, unit, part) MAKEDISKDEV(maj, unit, part)
-#define MAXTRACK 99
-#define CD_BLOCK_OFFSET 150
-#define CD_FRAMES 75
-#define CD_SECS 60
+#define MAXTRACK 99
+#define CD_BLOCK_OFFSET 150
+#define CD_FRAMES 75
+#define CD_SECS 60
struct cd_toc {
- struct ioc_toc_header header;
- struct cd_toc_entry entries[MAXTRACK+1]; /* One extra for the leadout */
+ struct ioc_toc_header header;
+ struct cd_toc_entry entries[MAXTRACK+1]; /* One extra for the */
+ /* leadout */
};
-
int cdlock __P((struct cd_softc *));
void cdunlock __P((struct cd_softc *));
void cdstart __P((void *));
@@ -94,18 +97,18 @@ void cdminphys __P((struct buf *));
void cdgetdisklabel __P((struct cd_softc *));
void cddone __P((struct scsipi_xfer *));
u_long cd_size __P((struct cd_softc *, int));
-void lba2msf __P((u_long, u_char*, u_char*, u_char*));
-u_long msf2lba __P((u_char, u_char, u_char));
-int cd_play __P((struct cd_softc *, int, int ));
-int cd_play_tracks __P((struct cd_softc *, int, int, int, int ));
-int cd_play_msf __P((struct cd_softc *, int, int, int, int, int, int ));
+void lba2msf __P((u_long, u_char *, u_char *, u_char *));
+u_long msf2lba __P((u_char, u_char, u_char));
+int cd_play __P((struct cd_softc *, int, int));
+int cd_play_tracks __P((struct cd_softc *, int, int, int, int));
+int cd_play_msf __P((struct cd_softc *, int, int, int, int, int, int));
int cd_pause __P((struct cd_softc *, int));
int cd_reset __P((struct cd_softc *));
int cd_read_subchannel __P((struct cd_softc *, int, int, int,
- struct cd_sub_channel_info *, int ));
-int cd_read_toc __P((struct cd_softc *, int, int, void *, int ));
+ struct cd_sub_channel_info *, int));
+int cd_read_toc __P((struct cd_softc *, int, int, void *, int));
int cd_get_parms __P((struct cd_softc *, int));
-int cd_load_toc __P((struct cd_softc *, struct cd_toc *));
+int cd_load_toc __P((struct cd_softc *, struct cd_toc *));
struct cfdriver cd_cd = {
NULL, "cd", DV_DISK
@@ -153,7 +156,7 @@ cdattach(parent, cd, sc_link, ops)
#if !defined(i386)
dk_establish(&cd->sc_dk, &cd->sc_dev); /* XXX */
#endif
-
+
printf("\n");
}
@@ -172,10 +175,10 @@ cdlock(cd)
while ((cd->flags & CDF_LOCKED) != 0) {
cd->flags |= CDF_WANTED;
if ((error = tsleep(cd, PRIBIO | PCATCH, "cdlck", 0)) != 0)
- return error;
+ return (error);
}
cd->flags |= CDF_LOCKED;
- return 0;
+ return (0);
}
/*
@@ -209,10 +212,10 @@ cdopen(dev, flag, fmt, p)
unit = CDUNIT(dev);
if (unit >= cd_cd.cd_ndevs)
- return ENXIO;
+ return (ENXIO);
cd = cd_cd.cd_devs[unit];
- if (!cd)
- return ENXIO;
+ if (cd == NULL)
+ return (ENXIO);
sc_link = cd->sc_link;
@@ -221,7 +224,7 @@ cdopen(dev, flag, fmt, p)
cd_cd.cd_ndevs, CDPART(dev)));
if ((error = cdlock(cd)) != 0)
- return error;
+ return (error);
if (cd->sc_dk.dk_openmask != 0) {
/*
@@ -235,20 +238,19 @@ cdopen(dev, flag, fmt, p)
} else {
/* Check that it is still responding and ok. */
error = scsipi_test_unit_ready(sc_link,
- SCSI_IGNORE_ILLEGAL_REQUEST |
- SCSI_IGNORE_MEDIA_CHANGE |
- SCSI_IGNORE_NOT_READY);
+ SCSI_IGNORE_ILLEGAL_REQUEST | SCSI_IGNORE_MEDIA_CHANGE |
+ SCSI_IGNORE_NOT_READY);
SC_DEBUG(sc_link, SDEV_DB1,
- ("cdopen: scsipi_test_unit_ready, error=%d\n", error));
+ ("cdopen: scsipi_test_unit_ready, error=%d\n", error));
if (error)
goto bad3;
/* Start the pack spinning if necessary. */
error = scsipi_start(sc_link, SSS_START,
- SCSI_IGNORE_ILLEGAL_REQUEST |
- SCSI_IGNORE_MEDIA_CHANGE | SCSI_SILENT);
+ SCSI_IGNORE_ILLEGAL_REQUEST | SCSI_IGNORE_MEDIA_CHANGE |
+ SCSI_SILENT);
SC_DEBUG(sc_link, SDEV_DB1,
- ("cdopen: scsipi_start, error=%d\n", error));
+ ("cdopen: scsipi_start, error=%d\n", error));
if (error)
goto bad3;
@@ -256,10 +258,9 @@ cdopen(dev, flag, fmt, p)
/* Lock the pack in. */
error = scsipi_prevent(sc_link, PR_PREVENT,
- SCSI_IGNORE_ILLEGAL_REQUEST |
- SCSI_IGNORE_MEDIA_CHANGE);
+ SCSI_IGNORE_ILLEGAL_REQUEST | SCSI_IGNORE_MEDIA_CHANGE);
SC_DEBUG(sc_link, SDEV_DB1,
- ("cdopen: scsipi_prevent, error=%d\n", error));
+ ("cdopen: scsipi_prevent, error=%d\n", error));
if (error)
goto bad;
@@ -284,7 +285,7 @@ cdopen(dev, flag, fmt, p)
/* Check that the partition exists. */
if (part != RAW_PART &&
(part >= cd->sc_dk.dk_label->d_npartitions ||
- cd->sc_dk.dk_label->d_partitions[part].p_fstype == FS_UNUSED)) {
+ cd->sc_dk.dk_label->d_partitions[part].p_fstype == FS_UNUSED)) {
error = ENXIO;
goto bad;
}
@@ -298,11 +299,12 @@ cdopen(dev, flag, fmt, p)
cd->sc_dk.dk_bopenmask |= (1 << part);
break;
}
- cd->sc_dk.dk_openmask = cd->sc_dk.dk_copenmask | cd->sc_dk.dk_bopenmask;
+ cd->sc_dk.dk_openmask =
+ cd->sc_dk.dk_copenmask | cd->sc_dk.dk_bopenmask;
SC_DEBUG(sc_link, SDEV_DB3, ("open complete\n"));
cdunlock(cd);
- return 0;
+ return (0);
bad2:
sc_link->flags &= ~SDEV_MEDIA_LOADED;
@@ -316,7 +318,7 @@ bad:
bad3:
cdunlock(cd);
- return error;
+ return (error);
}
/*
@@ -334,7 +336,7 @@ cdclose(dev, flag, fmt, p)
int error;
if ((error = cdlock(cd)) != 0)
- return error;
+ return (error);
switch (fmt) {
case S_IFCHR:
@@ -344,7 +346,8 @@ cdclose(dev, flag, fmt, p)
cd->sc_dk.dk_bopenmask &= ~(1 << part);
break;
}
- cd->sc_dk.dk_openmask = cd->sc_dk.dk_copenmask | cd->sc_dk.dk_bopenmask;
+ cd->sc_dk.dk_openmask =
+ cd->sc_dk.dk_copenmask | cd->sc_dk.dk_bopenmask;
if (cd->sc_dk.dk_openmask == 0) {
/* XXXX Must wait for I/O to complete! */
@@ -355,7 +358,7 @@ cdclose(dev, flag, fmt, p)
}
cdunlock(cd);
- return 0;
+ return (0);
}
/*
@@ -451,6 +454,7 @@ cdstart(v)
{
register struct cd_softc *cd = v;
register struct scsipi_link *sc_link = cd->sc_link;
+ struct disklabel *lp = cd->sc_dk.dk_label;
struct buf *bp = 0;
struct buf *dp;
struct scsipi_rw_big cmd_big;
@@ -504,13 +508,12 @@ cdstart(v)
* First, translate the block to absolute and put it in terms
* of the logical blocksize of the device.
*/
- blkno =
- bp->b_blkno / (cd->sc_dk.dk_label->d_secsize / DEV_BSIZE);
+ blkno = bp->b_blkno / (lp->d_secsize / DEV_BSIZE);
if (CDPART(bp->b_dev) != RAW_PART) {
- p = &cd->sc_dk.dk_label->d_partitions[CDPART(bp->b_dev)];
- blkno += p->p_offset;
+ p = &lp->d_partitions[CDPART(bp->b_dev)];
+ blkno += p->p_offset;
}
- nblks = howmany(bp->b_bcount, cd->sc_dk.dk_label->d_secsize);
+ nblks = howmany(bp->b_bcount, lp->d_secsize);
#if NCD_SCSI > 0
/*
@@ -622,27 +625,29 @@ cdwrite(dev, uio, ioflag)
/*
* conversion between minute-seconde-frame and logical block adress
* adresses format
- */
+ */
void
lba2msf (lba, m, s, f)
- u_long lba;
- u_char *m, *s, *f;
+ u_long lba;
+ u_char *m, *s, *f;
{
- u_long tmp;
- tmp = lba + CD_BLOCK_OFFSET; /* offset of first logical frame */
- tmp &= 0xffffff; /* negative lbas use only 24 bits */
- *m = tmp / (CD_SECS * CD_FRAMES);
- tmp %= (CD_SECS * CD_FRAMES);
- *s = tmp / CD_FRAMES;
- *f = tmp % CD_FRAMES;
-}
+ u_long tmp;
+
+ tmp = lba + CD_BLOCK_OFFSET; /* offset of first logical frame */
+ tmp &= 0xffffff; /* negative lbas use only 24 bits */
+ *m = tmp / (CD_SECS * CD_FRAMES);
+ tmp %= (CD_SECS * CD_FRAMES);
+ *s = tmp / CD_FRAMES;
+ *f = tmp % CD_FRAMES;
+}
u_long
msf2lba (m, s, f)
- u_char m, s, f;
-{
- return (((m * CD_SECS) + s) * CD_FRAMES + f) - CD_BLOCK_OFFSET;
-}
+ u_char m, s, f;
+{
+
+ return ((((m * CD_SECS) + s) * CD_FRAMES + f) - CD_BLOCK_OFFSET);
+}
/*
@@ -666,26 +671,26 @@ cdioctl(dev, cmd, addr, flag, p)
* If the device is not valid.. abandon ship
*/
if ((cd->sc_link->flags & SDEV_MEDIA_LOADED) == 0)
- return EIO;
+ return (EIO);
switch (cmd) {
case DIOCGDINFO:
*(struct disklabel *)addr = *(cd->sc_dk.dk_label);
- return 0;
+ return (0);
case DIOCGPART:
((struct partinfo *)addr)->disklab = cd->sc_dk.dk_label;
((struct partinfo *)addr)->part =
&cd->sc_dk.dk_label->d_partitions[CDPART(dev)];
- return 0;
+ return (0);
case DIOCWDINFO:
case DIOCSDINFO:
if ((flag & FWRITE) == 0)
- return EBADF;
+ return (EBADF);
if ((error = cdlock(cd)) != 0)
- return error;
+ return (error);
cd->flags |= CDF_LABELLING;
error = setdisklabel(cd->sc_dk.dk_label,
@@ -697,57 +702,56 @@ cdioctl(dev, cmd, addr, flag, p)
cd->flags &= ~CDF_LABELLING;
cdunlock(cd);
- return error;
+ return (error);
case DIOCWLABEL:
- return EBADF;
+ return (EBADF);
case CDIOCPLAYTRACKS: {
struct ioc_play_track *args = (struct ioc_play_track *)addr;
if ((error = (*cd->sc_ops->cdo_set_pa_immed)(cd)) != 0)
- return error;
- return cd_play_tracks(cd, args->start_track,
- args->start_index, args->end_track,
- args->end_index);
+ return (error);
+ return (cd_play_tracks(cd, args->start_track,
+ args->start_index, args->end_track, args->end_index));
}
case CDIOCPLAYMSF: {
struct ioc_play_msf *args = (struct ioc_play_msf *)addr;
if ((error = (*cd->sc_ops->cdo_set_pa_immed)(cd)) != 0)
- return error;
- return cd_play_msf(cd, args->start_m, args->start_s,
- args->start_f, args->end_m, args->end_s,
- args->end_f);
+ return (error);
+ return (cd_play_msf(cd, args->start_m, args->start_s,
+ args->start_f, args->end_m, args->end_s, args->end_f));
}
case CDIOCPLAYBLOCKS: {
struct ioc_play_blocks *args = (struct ioc_play_blocks *)addr;
if ((error = (*cd->sc_ops->cdo_set_pa_immed)(cd)) != 0)
- return error;
- return cd_play(cd, args->blk, args->len);
+ return (error);
+ return (cd_play(cd, args->blk, args->len));
}
case CDIOCREADSUBCHANNEL: {
- struct ioc_read_subchannel *args
- = (struct ioc_read_subchannel *)addr;
+ struct ioc_read_subchannel *args =
+ (struct ioc_read_subchannel *)addr;
struct cd_sub_channel_info data;
int len = args->data_len;
+
if (len > sizeof(data) ||
len < sizeof(struct cd_sub_channel_header))
- return EINVAL;
+ return (EINVAL);
error = cd_read_subchannel(cd, args->address_format,
- args->data_format, args->track,
- &data, len);
+ args->data_format, args->track, &data, len);
if (error)
- return error;
+ return (error);
len = min(len, _2btol(data.header.data_len) +
sizeof(struct cd_sub_channel_header));
- return copyout(&data, args->data, len);
+ return (copyout(&data, args->data, len));
}
case CDIOREADTOCHEADER: {
struct ioc_toc_header th;
+
if ((error = cd_read_toc(cd, 0, 0, &th, sizeof(th))) != 0)
- return error;
+ return (error);
if (cd->sc_link->quirks & ADEV_LITTLETOC) {
#if BYTE_ORDER == BIG_ENDIAN
bswap((u_int8_t *)&th.len, sizeof(th.len));
@@ -755,13 +759,14 @@ cdioctl(dev, cmd, addr, flag, p)
} else
th.len = ntohs(th.len);
bcopy(&th, addr, sizeof(th));
- return 0;
+ return (0);
}
case CDIOREADTOCENTRYS: {
struct cd_toc toc;
struct ioc_read_toc_entry *te =
- (struct ioc_read_toc_entry *)addr;
+ (struct ioc_read_toc_entry *)addr;
struct ioc_toc_header *th;
+ struct cd_toc_entry *cte;
int len = te->data_len;
int ntracks;
@@ -769,24 +774,24 @@ cdioctl(dev, cmd, addr, flag, p)
if (len > sizeof(toc.entries) ||
len < sizeof(struct cd_toc_entry))
- return EINVAL;
- error = cd_read_toc(cd, te->address_format,
- te->starting_track, &toc,
- len + sizeof(struct ioc_toc_header));
+ return (EINVAL);
+ error = cd_read_toc(cd, te->address_format, te->starting_track,
+ &toc, len + sizeof(struct ioc_toc_header));
if (error)
- return error;
+ return (error);
if (te->address_format == CD_LBA_FORMAT)
- for (ntracks = th->ending_track - th->starting_track + 1;
- ntracks >= 0; ntracks--) {
- toc.entries[ntracks].addr_type = CD_LBA_FORMAT;
+ for (ntracks =
+ th->ending_track - th->starting_track + 1;
+ ntracks >= 0; ntracks--) {
+ cte = &toc.entries[ntracks];
+ cte->addr_type = CD_LBA_FORMAT;
if (cd->sc_link->quirks & ADEV_LITTLETOC) {
#if BYTE_ORDER == BIG_ENDIAN
- bswap((u_int8_t*)&toc.entries[ntracks].addr,
- sizeof(toc.entries[ntracks].addr));
+ bswap((u_int8_t*)&cte->addr,
+ sizeof(cte->addr));
#endif
} else
- toc.entries[ntracks].addr.lba =
- ntohl(toc.entries[ntracks].addr.lba);
+ cte->addr.lba = ntohl(cte->addr.lba);
}
if (cd->sc_link->quirks & ADEV_LITTLETOC) {
#if BYTE_ORDER == BIG_ENDIAN
@@ -795,15 +800,14 @@ cdioctl(dev, cmd, addr, flag, p)
} else
th->len = ntohs(th->len);
len = min(len, th->len - (sizeof(th->starting_track) +
- sizeof(th->ending_track)));
- return copyout(toc.entries, te->data, len);
+ sizeof(th->ending_track)));
+ return (copyout(toc.entries, te->data, len));
}
case CDIOCSETPATCH: {
struct ioc_patch *arg = (struct ioc_patch *)addr;
return ((*cd->sc_ops->cdo_setchan)(cd, arg->patch[0],
arg->patch[1], arg->patch[2], arg->patch[3]));
-
}
case CDIOCGETVOL: {
struct ioc_vol *arg = (struct ioc_vol *)addr;
@@ -837,36 +841,36 @@ cdioctl(dev, cmd, addr, flag, p)
RIGHT_CHANNEL, MUTE_CHANNEL, MUTE_CHANNEL));
case CDIOCRESUME:
- return cd_pause(cd, PA_RESUME);
+ return (cd_pause(cd, PA_RESUME));
case CDIOCPAUSE:
- return cd_pause(cd, PA_PAUSE);
+ return (cd_pause(cd, PA_PAUSE));
case CDIOCSTART:
- return scsipi_start(cd->sc_link, SSS_START, 0);
+ return (scsipi_start(cd->sc_link, SSS_START, 0));
case CDIOCSTOP:
- return scsipi_start(cd->sc_link, SSS_STOP, 0);
+ return (scsipi_start(cd->sc_link, SSS_STOP, 0));
case CDIOCEJECT: /* FALLTHROUGH */
case DIOCEJECT:
- return scsipi_start(cd->sc_link, SSS_STOP|SSS_LOEJ, 0);
+ return (scsipi_start(cd->sc_link, SSS_STOP|SSS_LOEJ, 0));
case CDIOCALLOW:
- return scsipi_prevent(cd->sc_link, PR_ALLOW, 0);
+ return (scsipi_prevent(cd->sc_link, PR_ALLOW, 0));
case CDIOCPREVENT:
- return scsipi_prevent(cd->sc_link, PR_PREVENT, 0);
+ return (scsipi_prevent(cd->sc_link, PR_PREVENT, 0));
case DIOCLOCK:
- return scsipi_prevent(cd->sc_link,
- (*(int *)addr) ? PR_PREVENT : PR_ALLOW, 0);
+ return (scsipi_prevent(cd->sc_link,
+ (*(int *)addr) ? PR_PREVENT : PR_ALLOW, 0));
case CDIOCSETDEBUG:
cd->sc_link->flags |= (SDEV_DB1 | SDEV_DB2);
- return 0;
+ return (0);
case CDIOCCLRDEBUG:
cd->sc_link->flags &= ~(SDEV_DB1 | SDEV_DB2);
- return 0;
+ return (0);
case CDIOCRESET:
- return cd_reset(cd);
+ return (cd_reset(cd));
default:
if (CDPART(dev) != RAW_PART)
- return ENOTTY;
- return scsipi_do_ioctl(cd->sc_link, dev, cmd, addr, flag, p);
+ return (ENOTTY);
+ return (scsipi_do_ioctl(cd->sc_link, dev, cmd, addr, flag, p));
}
#ifdef DIAGNOSTIC
@@ -939,7 +943,7 @@ cd_size(cd, flags)
*/
cd->params.blksize = 2048;
cd->params.disksize = 400000;
- return 400000;
+ return (400000);
}
/*
@@ -953,11 +957,11 @@ cd_size(cd, flags)
* If the command works, interpret the result as a 4 byte
* number of blocks and a blocksize
*/
- if (cd->sc_link->scsipi_cmd(cd->sc_link,
- (struct scsipi_generic *)&scsipi_cmd,
- sizeof(scsipi_cmd), (u_char *)&rdcap, sizeof(rdcap), CDRETRIES,
- 20000, NULL, flags | SCSI_DATA_IN) != 0)
- return 0;
+ if ((*cd->sc_link->scsipi_cmd)(cd->sc_link,
+ (struct scsipi_generic *)&scsipi_cmd, sizeof(scsipi_cmd),
+ (u_char *)&rdcap, sizeof(rdcap), CDRETRIES, 20000, NULL,
+ flags | SCSI_DATA_IN) != 0)
+ return (0);
blksize = _4btol(rdcap.length);
if ((blksize < 512) || ((blksize & 511) != 0))
@@ -970,7 +974,7 @@ cd_size(cd, flags)
cd->params.disksize = size;
SC_DEBUG(cd->sc_link, SDEV_DB2, ("cd_sise: %d %ld\n", blksize, size));
- return size;
+ return (size);
}
/*
@@ -987,9 +991,9 @@ cd_play(cd, blkno, nblks)
scsipi_cmd.opcode = PLAY;
_lto4b(blkno, scsipi_cmd.blk_addr);
_lto2b(nblks, scsipi_cmd.xfer_len);
- return cd->sc_link->scsipi_cmd(cd->sc_link,
- (struct scsipi_generic *)&scsipi_cmd,
- sizeof(scsipi_cmd), 0, 0, CDRETRIES, 200000, NULL, 0);
+ return ((*cd->sc_link->scsipi_cmd)(cd->sc_link,
+ (struct scsipi_generic *)&scsipi_cmd, sizeof(scsipi_cmd),
+ 0, 0, CDRETRIES, 200000, NULL, 0));
}
/*
@@ -1004,12 +1008,12 @@ cd_play_tracks(cd, strack, sindex, etrack, eindex)
int error;
if (!etrack)
- return EIO;
+ return (EIO);
if (strack > etrack)
- return EINVAL;
+ return (EINVAL);
if ((error = cd_load_toc(cd, &toc)) != 0)
- return error;
+ return (error);
if (++etrack > (toc.header.ending_track+1))
etrack = toc.header.ending_track+1;
@@ -1017,14 +1021,14 @@ cd_play_tracks(cd, strack, sindex, etrack, eindex)
strack -= toc.header.starting_track;
etrack -= toc.header.starting_track;
if (strack < 0)
- return EINVAL;
-
- return cd_play_msf(cd, toc.entries[strack].addr.msf.minute,
- toc.entries[strack].addr.msf.second,
- toc.entries[strack].addr.msf.frame,
- toc.entries[etrack].addr.msf.minute,
- toc.entries[etrack].addr.msf.second,
- toc.entries[etrack].addr.msf.frame);
+ return (EINVAL);
+
+ return (cd_play_msf(cd, toc.entries[strack].addr.msf.minute,
+ toc.entries[strack].addr.msf.second,
+ toc.entries[strack].addr.msf.frame,
+ toc.entries[etrack].addr.msf.minute,
+ toc.entries[etrack].addr.msf.second,
+ toc.entries[etrack].addr.msf.frame));
}
/*
@@ -1045,9 +1049,9 @@ cd_play_msf(cd, startm, starts, startf, endm, ends, endf)
scsipi_cmd.end_m = endm;
scsipi_cmd.end_s = ends;
scsipi_cmd.end_f = endf;
- return cd->sc_link->scsipi_cmd(cd->sc_link,
- (struct scsipi_generic *)&scsipi_cmd,
- sizeof(scsipi_cmd), 0, 0, CDRETRIES, 2000, NULL, 0);
+ return ((*cd->sc_link->scsipi_cmd)(cd->sc_link,
+ (struct scsipi_generic *)&scsipi_cmd, sizeof(scsipi_cmd),
+ 0, 0, CDRETRIES, 2000, NULL, 0));
}
/*
@@ -1063,9 +1067,9 @@ cd_pause(cd, go)
bzero(&scsipi_cmd, sizeof(scsipi_cmd));
scsipi_cmd.opcode = PAUSE;
scsipi_cmd.resume = go & 0xff;
- return cd->sc_link->scsipi_cmd(cd->sc_link,
- (struct scsipi_generic *)&scsipi_cmd,
- sizeof(scsipi_cmd), 0, 0, CDRETRIES, 2000, NULL, 0);
+ return ((*cd->sc_link->scsipi_cmd)(cd->sc_link,
+ (struct scsipi_generic *)&scsipi_cmd, sizeof(scsipi_cmd),
+ 0, 0, CDRETRIES, 2000, NULL, 0));
}
/*
@@ -1076,8 +1080,8 @@ cd_reset(cd)
struct cd_softc *cd;
{
- return cd->sc_link->scsipi_cmd(cd->sc_link, 0, 0, 0, 0, CDRETRIES, 2000, NULL,
- SCSI_RESET);
+ return ((*cd->sc_link->scsipi_cmd)(cd->sc_link, 0, 0, 0, 0,
+ CDRETRIES, 2000, NULL, SCSI_RESET));
}
/*
@@ -1099,10 +1103,10 @@ cd_read_subchannel(cd, mode, format, track, data, len)
scsipi_cmd.subchan_format = format;
scsipi_cmd.track = track;
_lto2b(len, scsipi_cmd.data_len);
- return cd->sc_link->scsipi_cmd(cd->sc_link,
- (struct scsipi_generic *)&scsipi_cmd,
+ return ((*cd->sc_link->scsipi_cmd)(cd->sc_link,
+ (struct scsipi_generic *)&scsipi_cmd,
sizeof(struct scsipi_read_subchannel), (u_char *)data, len,
- CDRETRIES, 5000, NULL, SCSI_DATA_IN|SCSI_SILENT);
+ CDRETRIES, 5000, NULL, SCSI_DATA_IN|SCSI_SILENT));
}
/*
@@ -1118,36 +1122,40 @@ cd_read_toc(cd, mode, start, data, len)
int ntoc;
bzero(&scsipi_cmd, sizeof(scsipi_cmd));
- /*if (len!=sizeof(struct ioc_toc_header))
- * ntoc=((len)-sizeof(struct ioc_toc_header))/sizeof(struct cd_toc_entry);
- * else */
+#if 0
+ if (len != sizeof(struct ioc_toc_header))
+ ntoc = ((len) - sizeof(struct ioc_toc_header)) /
+ sizeof(struct cd_toc_entry);
+ else
+#endif
ntoc = len;
scsipi_cmd.opcode = READ_TOC;
if (mode == CD_MSF_FORMAT)
scsipi_cmd.byte2 |= CD_MSF;
scsipi_cmd.from_track = start;
_lto2b(ntoc, scsipi_cmd.data_len);
- return cd->sc_link->scsipi_cmd(cd->sc_link,
- (struct scsipi_generic *)&scsipi_cmd,
+ return ((*cd->sc_link->scsipi_cmd)(cd->sc_link,
+ (struct scsipi_generic *)&scsipi_cmd,
sizeof(struct scsipi_read_toc), (u_char *)data, len, CDRETRIES,
- 5000, NULL, SCSI_DATA_IN);
+ 5000, NULL, SCSI_DATA_IN));
}
-int
+int
cd_load_toc(cd, toc)
- struct cd_softc *cd;
+ struct cd_softc *cd;
struct cd_toc *toc;
{
int ntracks, len, error;
if ((error = cd_read_toc(cd, 0, 0, toc, sizeof(toc->header))) != 0)
- return error;
+ return (error);
ntracks = toc->header.ending_track - toc->header.starting_track + 1;
- len = (ntracks+1)*sizeof(struct cd_toc_entry) + sizeof(toc->header);
+ len = (ntracks + 1) * sizeof(struct cd_toc_entry) +
+ sizeof(toc->header);
if ((error = cd_read_toc(cd, CD_MSF_FORMAT, 0, toc, len)) != 0)
- return error;
- return 0;
+ return (error);
+ return (0);
}
/*
@@ -1165,8 +1173,8 @@ cd_get_parms(cd, flags)
* is <= disk_size
*/
if (cd_size(cd, flags) == 0)
- return ENXIO;
- return 0;
+ return (ENXIO);
+ return (0);
}
int
@@ -1175,7 +1183,7 @@ cdsize(dev)
{
/* CD-ROMs are read-only. */
- return -1;
+ return (-1);
}
int
@@ -1187,5 +1195,5 @@ cddump(dev, blkno, va, size)
{
/* Not implemented. */
- return ENXIO;
+ return (ENXIO);
}
diff --git a/sys/dev/scsipi/cd_atapi.c b/sys/dev/scsipi/cd_atapi.c
index e38ae2ae1cd..87364f835f6 100644
--- a/sys/dev/scsipi/cd_atapi.c
+++ b/sys/dev/scsipi/cd_atapi.c
@@ -1,4 +1,4 @@
-/* $NetBSD: cd_atapi.c,v 1.2 1997/08/27 11:26:21 bouyer Exp $ */
+/* $NetBSD: cd_atapi.c,v 1.3 1997/10/01 01:18:46 enami Exp $ */
/*
* Copyright (c) 1997 Manuel Bouyer. All rights reserved.
@@ -115,11 +115,11 @@ cd_atapibus_match(parent, match, aux)
int priority;
if (sa->sa_sc_link->type != BUS_ATAPI)
- return 0;
+ return (0);
(void)scsipi_inqmatch(&sa->sa_inqbuf,
(caddr_t)cd_atapibus_patterns,
- sizeof(cd_atapibus_patterns)/sizeof(cd_atapibus_patterns[0]),
+ sizeof(cd_atapibus_patterns) / sizeof(cd_atapibus_patterns[0]),
sizeof(cd_atapibus_patterns[0]), &priority);
return (priority);
}
@@ -158,13 +158,12 @@ cd_atapibus_get_mode(cd, data, page, len, flags)
scsipi_cmd.page = page;
_lto2b(len, scsipi_cmd.length);
error = cd->sc_link->scsipi_cmd(cd->sc_link,
- (struct scsipi_generic *)&scsipi_cmd,
- sizeof(scsipi_cmd), (u_char *)data, sizeof(*data), CDRETRIES,
- 20000, NULL, SCSI_DATA_IN);
+ (struct scsipi_generic *)&scsipi_cmd, sizeof(scsipi_cmd),
+ (u_char *)data, sizeof(*data), CDRETRIES, 20000, NULL,
+ SCSI_DATA_IN);
SC_DEBUG(cd->sc_link, SDEV_DB2, ("cd_atapibus_get_mode: error=%d\n",
error));
- return error;
-
+ return (error);
}
int
@@ -183,12 +182,12 @@ cd_atapibus_set_mode(cd, data, len)
scsipi_cmd.page = data->page.page_code;
_lto2b(len, scsipi_cmd.length);
error = cd->sc_link->scsipi_cmd(cd->sc_link,
- (struct scsipi_generic *)&scsipi_cmd,
- sizeof(scsipi_cmd), (u_char *)data, sizeof(*data), CDRETRIES,
- 20000, NULL, SCSI_DATA_OUT);
+ (struct scsipi_generic *)&scsipi_cmd, sizeof(scsipi_cmd),
+ (u_char *)data, sizeof(*data), CDRETRIES, 20000, NULL,
+ SCSI_DATA_OUT);
SC_DEBUG(cd->sc_link, SDEV_DB2, ("cd_atapibus_set_mode: error=%d\n",
error));
- return error;
+ return (error);
}
int
@@ -201,12 +200,12 @@ cd_atapibus_setchan(cd, p0, p1, p2, p3)
if ((error = cd_atapibus_get_mode(cd, &data, ATAPI_AUDIO_PAGE,
AUDIOPAGESIZE, 0)) != 0)
- return error;
+ return (error);
data.page.audio.port[LEFT_PORT].channels = p0;
data.page.audio.port[RIGHT_PORT].channels = p1;
data.page.audio.port[2].channels = p2;
data.page.audio.port[3].channels = p3;
- return cd_atapibus_set_mode(cd, &data, AUDIOPAGESIZE);
+ return (cd_atapibus_set_mode(cd, &data, AUDIOPAGESIZE));
}
int
@@ -219,12 +218,12 @@ cd_atapibus_getvol(cd, arg)
if ((error = cd_atapibus_get_mode(cd, &data, ATAPI_AUDIO_PAGE,
AUDIOPAGESIZE, 0)) != 0)
- return error;
+ return (error);
arg->vol[0] = data.page.audio.port[0].volume;
arg->vol[1] = data.page.audio.port[1].volume;
arg->vol[2] = data.page.audio.port[2].volume;
arg->vol[3] = data.page.audio.port[3].volume;
- return 0;
+ return (0);
}
int
@@ -237,21 +236,21 @@ cd_atapibus_setvol(cd, arg)
if ((error = cd_atapibus_get_mode(cd, &data, ATAPI_AUDIO_PAGE,
AUDIOPAGESIZE, 0)) != 0)
- return error;
+ return (error);
if ((error = cd_atapibus_get_mode(cd, &mask, ATAPI_AUDIO_PAGE_MASK,
AUDIOPAGESIZE, 0)) != 0)
- return error;
+ return (error);
data.page.audio.port[0].volume = arg->vol[0] &
- mask.page.audio.port[0].volume;
+ mask.page.audio.port[0].volume;
data.page.audio.port[1].volume = arg->vol[1] &
- mask.page.audio.port[1].volume;
+ mask.page.audio.port[1].volume;
data.page.audio.port[2].volume = arg->vol[2] &
- mask.page.audio.port[2].volume;
+ mask.page.audio.port[2].volume;
data.page.audio.port[3].volume = arg->vol[3] &
- mask.page.audio.port[3].volume;
+ mask.page.audio.port[3].volume;
- return cd_atapibus_set_mode(cd, &data, AUDIOPAGESIZE);
+ return (cd_atapibus_set_mode(cd, &data, AUDIOPAGESIZE));
}
int
diff --git a/sys/dev/scsipi/cd_scsi.c b/sys/dev/scsipi/cd_scsi.c
index ed03cbf7272..9c82444cb5d 100644
--- a/sys/dev/scsipi/cd_scsi.c
+++ b/sys/dev/scsipi/cd_scsi.c
@@ -1,4 +1,4 @@
-/* $NetBSD: cd_scsi.c,v 1.3 1997/09/05 16:45:25 bouyer Exp $ */
+/* $NetBSD: cd_scsi.c,v 1.4 1997/10/01 01:18:48 enami Exp $ */
/*
* Copyright (c) 1994, 1995, 1997 Charles M. Hannum. All rights reserved.
@@ -116,11 +116,11 @@ cd_scsibus_match(parent, match, aux)
int priority;
if (sa->sa_sc_link->type != BUS_SCSI)
- return 0;
+ return (0);
(void)scsipi_inqmatch(&sa->sa_inqbuf,
(caddr_t)cd_scsibus_patterns,
- sizeof(cd_scsibus_patterns)/sizeof(cd_scsibus_patterns[0]),
+ sizeof(cd_scsibus_patterns) / sizeof(cd_scsibus_patterns[0]),
sizeof(cd_scsibus_patterns[0]), &priority);
return (priority);
}
@@ -168,10 +168,10 @@ cd_scsibus_get_mode(cd, data, page)
scsipi_cmd.opcode = SCSI_MODE_SENSE;
scsipi_cmd.page = page;
scsipi_cmd.length = sizeof(*data) & 0xff;
- return cd->sc_link->scsipi_cmd(cd->sc_link,
- (struct scsipi_generic *)&scsipi_cmd,
- sizeof(scsipi_cmd), (u_char *)data, sizeof(*data), CDRETRIES, 20000,
- NULL, SCSI_DATA_IN);
+ return ((*cd->sc_link->scsipi_cmd)(cd->sc_link,
+ (struct scsipi_generic *)&scsipi_cmd, sizeof(scsipi_cmd),
+ (u_char *)data, sizeof(*data), CDRETRIES, 20000, NULL,
+ SCSI_DATA_IN));
}
/*
@@ -189,10 +189,10 @@ cd_scsibus_set_mode(cd, data)
scsipi_cmd.byte2 |= SMS_PF;
scsipi_cmd.length = sizeof(*data) & 0xff;
data->header.data_length = 0;
- return cd->sc_link->scsipi_cmd(cd->sc_link,
- (struct scsipi_generic *)&scsipi_cmd,
- sizeof(scsipi_cmd), (u_char *)data, sizeof(*data), CDRETRIES, 20000,
- NULL, SCSI_DATA_OUT);
+ return ((*cd->sc_link->scsipi_cmd)(cd->sc_link,
+ (struct scsipi_generic *)&scsipi_cmd, sizeof(scsipi_cmd),
+ (u_char *)data, sizeof(*data), CDRETRIES, 20000, NULL,
+ SCSI_DATA_OUT));
}
int
@@ -203,10 +203,10 @@ cd_scsibus_set_pa_immed(cd)
int error;
if ((error = cd_scsibus_get_mode(cd, &data, SCSI_AUDIO_PAGE)) != 0)
- return error;
+ return (error);
data.page.audio.flags &= ~CD_PA_SOTC;
data.page.audio.flags |= CD_PA_IMMED;
- return cd_scsibus_set_mode(cd, &data);
+ return (cd_scsibus_set_mode(cd, &data));
}
int
@@ -218,12 +218,12 @@ cd_scsibus_setchan(cd, p0, p1, p2, p3)
int error;
if ((error = cd_scsibus_get_mode(cd, &data, SCSI_AUDIO_PAGE)) != 0)
- return error;
+ return (error);
data.page.audio.port[LEFT_PORT].channels = p0;
data.page.audio.port[RIGHT_PORT].channels = p1;
data.page.audio.port[2].channels = p2;
data.page.audio.port[3].channels = p3;
- return cd_scsibus_set_mode(cd, &data);
+ return (cd_scsibus_set_mode(cd, &data));
}
int
@@ -236,12 +236,12 @@ cd_scsibus_getvol(cd, arg)
int error;
if ((error = cd_scsibus_get_mode(cd, &data, SCSI_AUDIO_PAGE)) != 0)
- return error;
+ return (error);
arg->vol[LEFT_PORT] = data.page.audio.port[LEFT_PORT].volume;
arg->vol[RIGHT_PORT] = data.page.audio.port[RIGHT_PORT].volume;
arg->vol[2] = data.page.audio.port[2].volume;
arg->vol[3] = data.page.audio.port[3].volume;
- return 0;
+ return (0);
}
int
@@ -253,12 +253,12 @@ cd_scsibus_setvol(cd, arg)
int error;
if ((error = cd_scsibus_get_mode(cd, &data, SCSI_AUDIO_PAGE)) != 0)
- return error;
+ return (error);
data.page.audio.port[LEFT_PORT].channels = CHANNEL_0;
data.page.audio.port[LEFT_PORT].volume = arg->vol[LEFT_PORT];
data.page.audio.port[RIGHT_PORT].channels = CHANNEL_1;
data.page.audio.port[RIGHT_PORT].volume = arg->vol[RIGHT_PORT];
data.page.audio.port[2].volume = arg->vol[2];
data.page.audio.port[3].volume = arg->vol[3];
- return cd_scsibus_set_mode(cd, &data);
+ return (cd_scsibus_set_mode(cd, &data));
}
diff --git a/sys/dev/scsipi/ch.c b/sys/dev/scsipi/ch.c
index 60f6caedd54..34e3a31b62e 100644
--- a/sys/dev/scsipi/ch.c
+++ b/sys/dev/scsipi/ch.c
@@ -1,4 +1,4 @@
-/* $NetBSD: ch.c,v 1.28 1997/09/29 17:32:31 mjacob Exp $ */
+/* $NetBSD: ch.c,v 1.29 1997/10/01 01:18:50 enami Exp $ */
/*
* Copyright (c) 1996, 1997 Jason R. Thorpe <thorpej@and.com>
@@ -126,7 +126,8 @@ int ch_ielem __P((struct ch_softc *));
int ch_usergetelemstatus __P((struct ch_softc *, int, u_int8_t *));
int ch_getelemstatus __P((struct ch_softc *, int, int, caddr_t, size_t));
int ch_get_params __P((struct ch_softc *, int));
-void ch_get_quirks __P((struct ch_softc *, struct scsipi_inquiry_pattern *));
+void ch_get_quirks __P((struct ch_softc *,
+ struct scsipi_inquiry_pattern *));
/*
* SCSI changer quirks.
@@ -156,7 +157,7 @@ chmatch(parent, match, aux)
int priority;
(void)scsipi_inqmatch(&sa->sa_inqbuf,
- (caddr_t)ch_patterns, sizeof(ch_patterns)/sizeof(ch_patterns[0]),
+ (caddr_t)ch_patterns, sizeof(ch_patterns) / sizeof(ch_patterns[0]),
sizeof(ch_patterns[0]), &priority);
return (priority);
@@ -407,8 +408,9 @@ ch_move(sc, cm)
/*
* Send command to changer.
*/
- return (sc->sc_link->scsipi_cmd(sc->sc_link, (struct scsipi_generic *)&cmd,
- sizeof(cmd), NULL, 0, CHRETRIES, 100000, NULL, 0));
+ return ((*sc->sc_link->scsipi_cmd)(sc->sc_link,
+ (struct scsipi_generic *)&cmd, sizeof(cmd), NULL, 0, CHRETRIES,
+ 100000, NULL, 0));
}
int
@@ -463,8 +465,9 @@ ch_exchange(sc, ce)
/*
* Send command to changer.
*/
- return (sc->sc_link->scsipi_cmd(sc->sc_link, (struct scsipi_generic *)&cmd,
- sizeof(cmd), NULL, 0, CHRETRIES, 100000, NULL, 0));
+ return ((*sc->sc_link->scsipi_cmd)(sc->sc_link,
+ (struct scsipi_generic *)&cmd, sizeof(cmd), NULL, 0, CHRETRIES,
+ 100000, NULL, 0));
}
int
@@ -501,8 +504,9 @@ ch_position(sc, cp)
/*
* Send command to changer.
*/
- return (sc->sc_link->scsipi_cmd(sc->sc_link, (struct scsipi_generic *)&cmd,
- sizeof(cmd), NULL, 0, CHRETRIES, 100000, NULL, 0));
+ return ((*sc->sc_link->scsipi_cmd)(sc->sc_link,
+ (struct scsipi_generic *)&cmd, sizeof(cmd), NULL, 0, CHRETRIES,
+ 100000, NULL, 0));
}
/*
@@ -614,8 +618,9 @@ ch_getelemstatus(sc, first, count, data, datalen)
/*
* Send command to changer.
*/
- return (sc->sc_link->scsipi_cmd(sc->sc_link, (struct scsipi_generic *)&cmd,
- sizeof(cmd), (u_char *)data, datalen, CHRETRIES, 100000, NULL, 0));
+ return ((*sc->sc_link->scsipi_cmd)(sc->sc_link,
+ (struct scsipi_generic *)&cmd, sizeof(cmd),
+ (u_char *)data, datalen, CHRETRIES, 100000, NULL, 0));
}
@@ -634,9 +639,9 @@ ch_ielem(sc)
/*
* Send command to changer.
*/
- return (sc->sc_link->scsipi_cmd(sc->sc_link,
- (struct scsipi_generic *)&cmd, sizeof(cmd),
- NULL, 0, CHRETRIES, 100000, NULL, 0));
+ return ((*sc->sc_link->scsipi_cmd)(sc->sc_link,
+ (struct scsipi_generic *)&cmd, sizeof(cmd),
+ NULL, 0, CHRETRIES, 100000, NULL, 0));
}
/*
@@ -669,9 +674,10 @@ ch_get_params(sc, scsiflags)
cmd.byte2 |= 0x08; /* disable block descriptors */
cmd.page = 0x1d;
cmd.length = (sizeof(sense_data) & 0xff);
- error = sc->sc_link->scsipi_cmd(sc->sc_link, (struct scsipi_generic *)&cmd,
- sizeof(cmd), (u_char *)&sense_data, sizeof(sense_data), CHRETRIES,
- 6000, NULL, scsiflags | SCSI_DATA_IN);
+ error = (*sc->sc_link->scsipi_cmd)(sc->sc_link,
+ (struct scsipi_generic *)&cmd, sizeof(cmd), (u_char *)&sense_data,
+ sizeof(sense_data), CHRETRIES, 6000, NULL,
+ scsiflags | SCSI_DATA_IN);
if (error) {
printf("%s: could not sense element address page\n",
sc->sc_dev.dv_xname);
@@ -701,9 +707,10 @@ ch_get_params(sc, scsiflags)
cmd.byte2 = 0x08; /* disable block descriptors */
cmd.page = 0x1f;
cmd.length = (sizeof(sense_data) & 0xff);
- error = sc->sc_link->scsipi_cmd(sc->sc_link, (struct scsipi_generic *)&cmd,
- sizeof(cmd), (u_char *)&sense_data, sizeof(sense_data), CHRETRIES,
- 6000, NULL, scsiflags | SCSI_DATA_IN);
+ error = (*sc->sc_link->scsipi_cmd)(sc->sc_link,
+ (struct scsipi_generic *)&cmd, sizeof(cmd), (u_char *)&sense_data,
+ sizeof(sense_data), CHRETRIES, 6000, NULL,
+ scsiflags | SCSI_DATA_IN);
if (error) {
printf("%s: could not sense capabilities page\n",
sc->sc_dev.dv_xname);
@@ -737,7 +744,6 @@ ch_get_quirks(sc, inqbuf)
(caddr_t)chquirks,
sizeof(chquirks) / sizeof(chquirks[0]),
sizeof(chquirks[0]), &priority);
- if (priority != 0) {
+ if (priority != 0)
sc->sc_settledelay = match->cq_settledelay;
- }
}
diff --git a/sys/dev/scsipi/files.scsipi b/sys/dev/scsipi/files.scsipi
index 1b6dd554b77..4b971793b69 100644
--- a/sys/dev/scsipi/files.scsipi
+++ b/sys/dev/scsipi/files.scsipi
@@ -1,4 +1,4 @@
-# $NetBSD: files.scsipi,v 1.10 1997/09/13 08:51:15 enami Exp $
+# $NetBSD: files.scsipi,v 1.11 1997/10/01 01:18:51 enami Exp $
#
# Config file and device description for machine-independent SCSI code.
# Included by ports that need it. Ports that use it must provide
@@ -6,53 +6,53 @@
defopt SCSIVERBOSE
-file dev/scsipi/scsipiconf.c scsi | atapi
-file dev/scsipi/scsipi_base.c scsi | atapi
-file dev/scsipi/scsipi_ioctl.c scsi | atapi
+file dev/scsipi/scsipiconf.c scsi | atapi
+file dev/scsipi/scsipi_base.c scsi | atapi
+file dev/scsipi/scsipi_ioctl.c scsi | atapi
file dev/scsipi/scsi_base.c scsi
file dev/scsipi/atapi_base.c atapi
device scsibus {target = -1, lun = -1}
attach scsibus at scsi
-file dev/scsipi/scsiconf.c scsibus needs-flag
+file dev/scsipi/scsiconf.c scsibus needs-flag
-device atapibus {drive = -1}
-attach atapibus at atapi
-file dev/scsipi/atapiconf.c atapibus needs-flag
+device atapibus {drive = -1}
+attach atapibus at atapi
+file dev/scsipi/atapiconf.c atapibus needs-flag
device cd: disk
attach cd at scsibus with cd_scsibus
attach cd at atapibus with cd_atapibus
file dev/scsipi/cd_scsi.c cd_scsibus
file dev/scsipi/cd_atapi.c cd_atapibus
-file dev/scsipi/cd.c cd | cd_scsibus | cd_atapibus needs-flag
+file dev/scsipi/cd.c cd | cd_scsibus | cd_atapibus needs-flag
device ch: disk
attach ch at scsibus
-file dev/scsipi/ch.c ch needs-flag
+file dev/scsipi/ch.c ch needs-flag
device se: ifnet, ether, arp
attach se at scsibus
-file dev/scsipi/if_se.c se needs-flag
+file dev/scsipi/if_se.c se needs-flag
device sd: disk
attach sd at scsibus
-file dev/scsipi/sd.c sd needs-flag
+file dev/scsipi/sd.c sd needs-flag
device st: tape
attach st at scsibus
-file dev/scsipi/st.c st needs-flag
+file dev/scsipi/st.c st needs-flag
device ss: tape
attach ss at scsibus
-file dev/scsipi/ss.c ss needs-flag
+file dev/scsipi/ss.c ss needs-flag
file dev/scsipi/ss_mustek.c ss
file dev/scsipi/ss_scanjet.c ss
device su: disk
attach su at scsibus
-file dev/scsipi/su.c su needs-flag
+file dev/scsipi/su.c su needs-flag
device uk: disk
attach uk at scsibus
-file dev/scsipi/uk.c uk needs-flag
+file dev/scsipi/uk.c uk needs-flag
diff --git a/sys/dev/scsipi/if_se.c b/sys/dev/scsipi/if_se.c
index 541db3f1202..a15c04ab87b 100644
--- a/sys/dev/scsipi/if_se.c
+++ b/sys/dev/scsipi/if_se.c
@@ -1,4 +1,4 @@
-/* $NetBSD: if_se.c,v 1.9 1997/08/27 11:26:29 bouyer Exp $ */
+/* $NetBSD: if_se.c,v 1.10 1997/10/01 01:18:53 enami Exp $ */
/*
* Copyright (c) 1997 Ian W. Dall <ian.dall@dsto.defence.gov.au>
@@ -208,10 +208,10 @@ static int sc_set_all_multi __P((struct se_softc *, int));
#endif
static void se_stop __P((struct se_softc *));
static __inline int se_scsipi_cmd __P((struct scsipi_link *sc_link,
- struct scsipi_generic *scsipi_cmd,
- int cmdlen, u_char *data_addr, int datalen,
- int retries, int timeout, struct buf *bp,
- int flags));
+ struct scsipi_generic *scsipi_cmd,
+ int cmdlen, u_char *data_addr, int datalen,
+ int retries, int timeout, struct buf *bp,
+ int flags));
static void se_delayed_ifstart __P((void *));
static int se_set_mode(struct se_softc *, int, int);
@@ -271,7 +271,7 @@ sematch(parent, match, aux)
int priority;
(void)scsipi_inqmatch(&sa->sa_inqbuf,
- (caddr_t)se_patterns, sizeof(se_patterns)/sizeof(se_patterns[0]),
+ (caddr_t)se_patterns, sizeof(se_patterns) / sizeof(se_patterns[0]),
sizeof(se_patterns[0]), &priority);
return (priority);
}
@@ -356,10 +356,11 @@ se_scsipi_cmd(sc_link, scsipi_cmd, cmdlen, data_addr, datalen,
{
int error;
int s = splbio();
- error = sc_link->scsipi_cmd(sc_link, scsipi_cmd, cmdlen, data_addr, datalen,
- retries, timeout, bp, flags);
+
+ error = (*sc_link->scsipi_cmd)(sc_link, scsipi_cmd, cmdlen, data_addr,
+ datalen, retries, timeout, bp, flags);
splx(s);
- return error;
+ return (error);
}
/* Start routine for calling from scsi sub system */
@@ -370,6 +371,7 @@ sestart(v)
struct se_softc *sc = (struct se_softc *) v;
struct ifnet *ifp = &sc->sc_ethercom.ec_if;
int s = splnet();
+
se_ifstart(ifp);
(void) splx(s);
}
@@ -380,6 +382,7 @@ se_delayed_ifstart(v)
{
struct ifnet *ifp = v;
int s = splnet();
+
ifp->if_flags &= ~IFF_OACTIVE;
se_ifstart(ifp);
splx(s);
@@ -434,7 +437,7 @@ se_ifstart(ifp)
#ifdef SEDEBUG
if (sc->sc_debug)
printf("se: packet size %d (%d) < %d\n", len,
- cp - (u_char *)sc->sc_tbuf, SEMINSIZE);
+ cp - (u_char *)sc->sc_tbuf, SEMINSIZE);
#endif
bzero(cp, SEMINSIZE - len);
len = SEMINSIZE;
@@ -446,12 +449,12 @@ se_ifstart(ifp)
/* Send command to device. */
error = se_scsipi_cmd(sc->sc_link,
- (struct scsipi_generic *)&send_cmd, sizeof(send_cmd),
- sc->sc_tbuf, len, SERETRIES,
- SETIMEOUT, NULL, SCSI_NOSLEEP|SCSI_DATA_OUT);
+ (struct scsipi_generic *)&send_cmd, sizeof(send_cmd),
+ sc->sc_tbuf, len, SERETRIES,
+ SETIMEOUT, NULL, SCSI_NOSLEEP|SCSI_DATA_OUT);
if (error) {
printf("%s: not queued, error %d\n",
- sc->sc_dev.dv_xname, error);
+ sc->sc_dev.dv_xname, error);
ifp->if_oerrors++;
ifp->if_flags &= ~IFF_OACTIVE;
} else
@@ -503,7 +506,8 @@ sedone(xs)
if(n > 0) {
#ifdef SEDEBUG
if (sc->sc_debug)
- printf("sedone: received %d packets \n", n);
+ printf("sedone: received %d packets\n",
+ n);
#endif
if(ifp->if_snd.ifq_head)
/* Output is
@@ -522,7 +526,7 @@ sedone(xs)
}
splx(s);
}
-
+
static void
se_recv(v)
void *v;
@@ -535,10 +539,9 @@ se_recv(v)
PROTOCMD(ctron_ether_recv, recv_cmd);
error = se_scsipi_cmd(sc->sc_link,
- (struct scsipi_generic *)&recv_cmd,
- sizeof(recv_cmd),
- sc->sc_rbuf, RBUF_LEN, SERETRIES,
- SETIMEOUT, NULL, SCSI_NOSLEEP|SCSI_DATA_IN);
+ (struct scsipi_generic *)&recv_cmd, sizeof(recv_cmd),
+ sc->sc_rbuf, RBUF_LEN, SERETRIES, SETIMEOUT, NULL,
+ SCSI_NOSLEEP|SCSI_DATA_IN);
if (error)
timeout(se_recv, (void *)sc, se_poll);
}
@@ -574,7 +577,7 @@ se_get(sc, data, totlen)
MGET(m, M_DONTWAIT, MT_DATA);
if (m == 0) {
m_freem(top);
- return 0;
+ return (0);
}
len = MLEN;
}
@@ -583,7 +586,7 @@ se_get(sc, data, totlen)
if ((m->m_flags & M_EXT) == 0) {
m_free(m);
m_freem(top);
- return 0;
+ return (0);
}
len = MCLBYTES;
}
@@ -640,9 +643,8 @@ se_read(sc, data, datalen)
m = se_get(sc, data, len - ETHER_CRC);
if (m == 0) {
#ifdef SEDEBUG
- if (sc->sc_debug) {
+ if (sc->sc_debug)
printf("se_read: se_get returned null\n");
- }
#endif
ifp->if_ierrors++;
goto next_packet;
@@ -687,7 +689,7 @@ se_read(sc, data, datalen)
datalen -= len;
n++;
}
- return n;
+ return (n);
}
@@ -707,7 +709,7 @@ static int
se_reset(sc)
struct se_softc *sc;
{
- int error = 0;
+ int error;
int s = splnet();
#if 0
/* Maybe we don't *really* want to reset the entire bus
@@ -720,7 +722,7 @@ se_reset(sc)
#endif
error = se_init(sc);
splx(s);
- return error;
+ return (error);
}
static int
@@ -728,7 +730,7 @@ se_add_proto(sc, proto)
struct se_softc *sc;
int proto;
{
- int error = 0;
+ int error;
struct scsi_ctron_ether_generic add_proto_cmd;
u_int8_t data[2];
_lto2b(proto, data);
@@ -740,13 +742,9 @@ se_add_proto(sc, proto)
PROTOCMD(ctron_ether_add_proto, add_proto_cmd);
_lto2b(sizeof(data), add_proto_cmd.length);
error = se_scsipi_cmd(sc->sc_link,
- (struct scsipi_generic *) &add_proto_cmd,
- sizeof(add_proto_cmd),
- data,
- sizeof(data),
- SERETRIES, SETIMEOUT, NULL,
- SCSI_DATA_OUT);
- return error;
+ (struct scsipi_generic *) &add_proto_cmd, sizeof(add_proto_cmd),
+ data, sizeof(data), SERETRIES, SETIMEOUT, NULL, SCSI_DATA_OUT);
+ return (error);
}
static int
@@ -754,20 +752,17 @@ se_get_addr(sc, myaddr)
struct se_softc *sc;
u_int8_t *myaddr;
{
- int error = 0;
+ int error;
struct scsi_ctron_ether_generic get_addr_cmd;
PROTOCMD(ctron_ether_get_addr, get_addr_cmd);
_lto2b(ETHER_ADDR_LEN, get_addr_cmd.length);
error = se_scsipi_cmd(sc->sc_link,
- (struct scsipi_generic *) &get_addr_cmd,
- sizeof(get_addr_cmd),
- myaddr, ETHER_ADDR_LEN,
- SERETRIES, SETIMEOUT, NULL,
- SCSI_DATA_IN);
+ (struct scsipi_generic *) &get_addr_cmd, sizeof(get_addr_cmd),
+ myaddr, ETHER_ADDR_LEN, SERETRIES, SETIMEOUT, NULL, SCSI_DATA_IN);
printf("%s: ethernet address %s\n", sc->sc_dev.dv_xname,
ether_sprintf(myaddr));
- return error;
+ return (error);
}
@@ -776,19 +771,15 @@ se_set_media(sc, type)
struct se_softc *sc;
int type;
{
- int error = 0;
+ int error;
struct scsi_ctron_ether_generic set_media_cmd;
PROTOCMD(ctron_ether_set_media, set_media_cmd);
set_media_cmd.byte3 = type;
error = se_scsipi_cmd(sc->sc_link,
- (struct scsipi_generic *) &set_media_cmd,
- sizeof(set_media_cmd),
- 0,
- 0,
- SERETRIES, SETIMEOUT, NULL,
- 0);
- return error;
+ (struct scsipi_generic *) &set_media_cmd, sizeof(set_media_cmd),
+ 0, 0, SERETRIES, SETIMEOUT, NULL, 0);
+ return (error);
}
static int
@@ -797,20 +788,16 @@ se_set_mode(sc, len, mode)
int len;
int mode;
{
- int error = 0;
+ int error;
struct scsi_ctron_ether_set_mode set_mode_cmd;
PROTOCMD(ctron_ether_set_mode, set_mode_cmd);
set_mode_cmd.mode = mode;
_lto2b(len, set_mode_cmd.length);
error = se_scsipi_cmd(sc->sc_link,
- (struct scsipi_generic *) &set_mode_cmd,
- sizeof(set_mode_cmd),
- 0,
- 0,
- SERETRIES, SETIMEOUT, NULL,
- 0);
- return error;
+ (struct scsipi_generic *) &set_mode_cmd, sizeof(set_mode_cmd),
+ 0, 0, SERETRIES, SETIMEOUT, NULL, 0);
+ return (error);
}
@@ -829,38 +816,35 @@ se_init(sc)
else
#endif
error = se_set_mode(sc, ETHERMTU + sizeof(struct ether_header),
- 0);
+ 0);
if (error != 0)
- return error;
+ return (error);
PROTOCMD(ctron_ether_set_addr, set_addr_cmd);
_lto2b(ETHER_ADDR_LEN, set_addr_cmd.length);
error = se_scsipi_cmd(sc->sc_link,
- (struct scsipi_generic *) &set_addr_cmd,
- sizeof(set_addr_cmd),
- LLADDR(ifp->if_sadl), ETHER_ADDR_LEN,
- SERETRIES, SETIMEOUT, NULL,
- SCSI_DATA_OUT);
- if (error != 0) {
- return error;
- }
+ (struct scsipi_generic *) &set_addr_cmd, sizeof(set_addr_cmd),
+ LLADDR(ifp->if_sadl), ETHER_ADDR_LEN, SERETRIES, SETIMEOUT, NULL,
+ SCSI_DATA_OUT);
+ if (error != 0)
+ return (error);
if ((sc->protos & PROTO_IP) &&
(error = se_add_proto(sc, ETHERTYPE_IP)) != 0)
- return error;
+ return (error);
if ((sc->protos & PROTO_ARP) &&
(error = se_add_proto(sc, ETHERTYPE_ARP)) != 0)
- return error;
+ return (error);
if ((sc->protos & PROTO_REVARP) &&
(error = se_add_proto(sc, ETHERTYPE_REVARP)) != 0)
- return error;
+ return (error);
#ifdef NETATALK
if ((sc->protos & PROTO_AT) &&
(error = se_add_proto(sc, ETHERTYPE_AT)) != 0)
- return error;
+ return (error);
if ((sc->protos & PROTO_AARP) &&
(error = se_add_proto(sc, ETHERTYPE_AARP)) != 0)
- return error;
+ return (error);
#endif
if ((ifp->if_flags & (IFF_RUNNING|IFF_UP)) == IFF_UP) {
@@ -869,7 +853,7 @@ se_init(sc)
ifp->if_flags &= ~IFF_OACTIVE;
se_ifstart(ifp);
}
- return error;
+ return (error);
}
static int
@@ -887,13 +871,9 @@ se_set_multi(sc, addr)
PROTOCMD(ctron_ether_set_multi, set_multi_cmd);
_lto2b(sizeof(addr), set_multi_cmd.length);
error = se_scsipi_cmd(sc->sc_link,
- (struct scsipi_generic *) &set_multi_cmd,
- sizeof(set_multi_cmd),
- addr,
- sizeof(addr),
- SERETRIES, SETIMEOUT, NULL,
- SCSI_DATA_OUT);
- return error;
+ (struct scsipi_generic *) &set_multi_cmd, sizeof(set_multi_cmd),
+ addr, sizeof(addr), SERETRIES, SETIMEOUT, NULL, SCSI_DATA_OUT);
+ return (error);
}
static int
@@ -911,13 +891,10 @@ se_remove_multi(sc, addr)
PROTOCMD(ctron_ether_remove_multi, remove_multi_cmd);
_lto2b(sizeof(addr), remove_multi_cmd.length);
error = se_scsipi_cmd(sc->sc_link,
- (struct scsipi_generic *) &remove_multi_cmd,
- sizeof(remove_multi_cmd),
- addr,
- sizeof(addr),
- SERETRIES, SETIMEOUT, NULL,
- SCSI_DATA_OUT);
- return error;
+ (struct scsipi_generic *) &remove_multi_cmd,
+ sizeof(remove_multi_cmd),
+ addr, sizeof(addr), SERETRIES, SETIMEOUT, NULL, SCSI_DATA_OUT);
+ return (error);
}
#if 0 /* not used --thorpej */
@@ -931,6 +908,7 @@ sc_set_all_multi(sc, set)
struct ethercom *ac = &sc->sc_ethercom;
struct ether_multi *enm;
struct ether_multistep step;
+
ETHER_FIRST_MULTI(step, ac, enm);
while (enm != NULL) {
if (ETHER_CMP(enm->enm_addrlo, enm->enm_addrhi)) {
@@ -947,16 +925,17 @@ sc_set_all_multi(sc, set)
* typically not possible. The only real alternative
* is to go into promicuous mode and filter by hand.
*/
- return ENODEV;
+ return (ENODEV);
}
addr = enm->enm_addrlo;
- if ((error = set? se_set_multi(sc, addr): se_remove_multi(sc, addr)) != 0)
- return error;
+ if ((error = set ? se_set_multi(sc, addr) :
+ se_remove_multi(sc, addr)) != 0)
+ return (error);
ETHER_NEXT_MULTI(step, enm);
}
- return error;
+ return (error);
}
#endif /* not used */
@@ -964,6 +943,7 @@ static void
se_stop(sc)
struct se_softc *sc;
{
+
/* Don't schedule any reads */
untimeout(se_recv, sc);
@@ -993,7 +973,7 @@ se_ioctl(ifp, cmd, data)
ifp->if_flags |= IFF_UP;
if ((error = se_set_media(sc, CMEDIA_AUTOSENSE) != 0))
- return error;
+ return (error);
switch (ifa->ifa_addr->sa_family) {
#ifdef INET
@@ -1076,18 +1056,16 @@ se_ioctl(ifp, cmd, data)
break;
case SIOCADDMULTI:
- if (ether_addmulti(ifr, &sc->sc_ethercom) == ENETRESET) {
+ if (ether_addmulti(ifr, &sc->sc_ethercom) == ENETRESET)
error = se_set_multi(sc, ifr->ifr_addr.sa_data);
- } else {
+ else
error = 0;
- }
break;
case SIOCDELMULTI:
- if (ether_delmulti(ifr, &sc->sc_ethercom) == ENETRESET) {
+ if (ether_delmulti(ifr, &sc->sc_ethercom) == ENETRESET)
error = se_remove_multi(sc, ifr->ifr_addr.sa_data);
- } else {
+ else
error = 0;
- }
break;
default:
@@ -1116,20 +1094,21 @@ seopen(dev, flag, fmt, p)
unit = SEUNIT(dev);
if (unit >= se_cd.cd_ndevs)
- return ENXIO;
+ return (ENXIO);
sc = se_cd.cd_devs[unit];
- if (!sc)
- return ENXIO;
+ if (sc == NULL)
+ return (ENXIO);
sc_link = sc->sc_link;
SC_DEBUG(sc_link, SDEV_DB1,
- ("scopen: dev=0x%x (unit %d (of %d))\n", dev, unit, se_cd.cd_ndevs));
+ ("scopen: dev=0x%x (unit %d (of %d))\n", dev, unit,
+ se_cd.cd_ndevs));
sc_link->flags |= SDEV_OPEN;
SC_DEBUG(sc_link, SDEV_DB3, ("open complete\n"));
- return 0;
+ return (0);
}
/*
@@ -1147,7 +1126,7 @@ seclose(dev, flag, fmt, p)
SC_DEBUG(sc->sc_link, SDEV_DB1, ("closing\n"));
sc->sc_link->flags &= ~SDEV_OPEN;
- return 0;
+ return (0);
}
/*
@@ -1164,5 +1143,5 @@ seioctl(dev, cmd, addr, flag, p)
{
register struct se_softc *sc = se_cd.cd_devs[SEUNIT(dev)];
- return scsipi_do_ioctl(sc->sc_link, dev, cmd, addr, flag, p);
+ return (scsipi_do_ioctl(sc->sc_link, dev, cmd, addr, flag, p));
}
diff --git a/sys/dev/scsipi/scsi_all.h b/sys/dev/scsipi/scsi_all.h
index eca76da0a68..6455232fd16 100644
--- a/sys/dev/scsipi/scsi_all.h
+++ b/sys/dev/scsipi/scsi_all.h
@@ -1,4 +1,4 @@
-/* $NetBSD: scsi_all.h,v 1.11 1997/08/27 11:26:30 bouyer Exp $ */
+/* $NetBSD: scsi_all.h,v 1.12 1997/10/01 01:18:54 enami Exp $ */
/*
* SCSI-specific insterface description.
@@ -10,7 +10,7 @@
*
* TRW Financial Systems, in accordance with their agreement with Carnegie
* Mellon University, makes this software available to CMU to distribute
- * or use in any manner that they see fit as long as this message is kept with
+ * or use in any manner that they see fit as long as this message is kept with
* the software. For this reason TFS also grants any other persons or
* organisations permission to use or modify this software.
*
@@ -22,7 +22,7 @@
*/
#ifndef _SCSI_SCSI_ALL_H
-#define _SCSI_SCSI_ALL_H 1
+#define _SCSI_SCSI_ALL_H 1
/*
* SCSI command format
@@ -31,9 +31,9 @@
/*
* Define dome bits that are in ALL (or a lot of) scsi commands
*/
-#define SCSI_CTL_LINK 0x01
-#define SCSI_CTL_FLAG 0x02
-#define SCSI_CTL_VENDOR 0xC0
+#define SCSI_CTL_LINK 0x01
+#define SCSI_CTL_FLAG 0x02
+#define SCSI_CTL_VENDOR 0xC0
/*
@@ -67,7 +67,7 @@ struct scsi_send_diag {
u_int8_t control;
};
-#define SCSI_MODE_SENSE 0x1a
+#define SCSI_MODE_SENSE 0x1a
struct scsi_mode_sense {
u_int8_t opcode;
u_int8_t byte2;
@@ -94,7 +94,7 @@ struct scsi_mode_sense_big {
u_int8_t control;
};
-#define SCSI_MODE_SELECT 0x15
+#define SCSI_MODE_SELECT 0x15
struct scsi_mode_select {
u_int8_t opcode;
u_int8_t byte2;
@@ -114,7 +114,7 @@ struct scsi_mode_select_big {
u_int8_t control;
};
-#define SCSI_RESERVE 0x16
+#define SCSI_RESERVE 0x16
struct scsi_reserve {
u_int8_t opcode;
u_int8_t byte2;
@@ -123,7 +123,7 @@ struct scsi_reserve {
u_int8_t control;
};
-#define SCSI_RELEASE 0x17
+#define SCSI_RELEASE 0x17
struct scsi_release {
u_int8_t opcode;
u_int8_t byte2;
@@ -142,8 +142,8 @@ struct scsi_changedef {
u_int8_t datalen;
u_int8_t control;
};
-#define SC_SCSI_1 0x01
-#define SC_SCSI_2 0x03
+#define SC_SCSI_1 0x01
+#define SC_SCSI_2 0x03
struct scsi_blk_desc {
u_int8_t density;
@@ -173,8 +173,8 @@ struct scsi_mode_header_big {
*/
#define SCSI_OK 0x00
#define SCSI_CHECK 0x02
-#define SCSI_BUSY 0x08
-#define SCSI_INTERM 0x10
-#define SCSI_QUEUE_FULL 0x28
+#define SCSI_BUSY 0x08
+#define SCSI_INTERM 0x10
+#define SCSI_QUEUE_FULL 0x28
#endif /* _SCSI_SCSI_ALL_H */
diff --git a/sys/dev/scsipi/scsi_base.c b/sys/dev/scsipi/scsi_base.c
index 665b93d0d80..22aa9cf7063 100644
--- a/sys/dev/scsipi/scsi_base.c
+++ b/sys/dev/scsipi/scsi_base.c
@@ -1,4 +1,4 @@
-/* $NetBSD: scsi_base.c,v 1.49 1997/09/13 08:51:16 enami Exp $ */
+/* $NetBSD: scsi_base.c,v 1.50 1997/10/01 01:18:56 enami Exp $ */
/*
* Copyright (c) 1994, 1995, 1997 Charles M. Hannum. All rights reserved.
@@ -53,13 +53,14 @@
#include <dev/scsipi/scsipi_base.h>
#ifdef SCSIVERBOSE
-char *scsi_decode_sense __P((void *, int));
+static void asc2ascii __P((unsigned char, unsigned char, char *));
+char *scsi_decode_sense __P((void *, int));
#endif
/*
* Do a scsi operation, asking a device to run as SCSI-II if it can.
*/
-int
+int
scsi_change_def(sc_link, flags)
struct scsipi_link *sc_link;
int flags;
@@ -70,8 +71,9 @@ scsi_change_def(sc_link, flags)
scsipi_cmd.opcode = SCSI_CHANGE_DEFINITION;
scsipi_cmd.how = SC_SCSI_2;
- return sc_link->scsipi_cmd(sc_link, (struct scsipi_generic *) &scsipi_cmd,
- sizeof(scsipi_cmd), 0, 0, 2, 100000, NULL, flags);
+ return ((*sc_link->scsipi_cmd)(sc_link,
+ (struct scsipi_generic *) &scsipi_cmd, sizeof(scsipi_cmd),
+ 0, 0, 2, 100000, NULL, flags));
}
/*
@@ -80,7 +82,7 @@ scsi_change_def(sc_link, flags)
* long the data is supposed to be. If we have a buf
* to associate with the transfer, we need that too.
*/
-int
+int
scsi_scsipi_cmd(sc_link, scsipi_cmd, cmdlen, data_addr, datalen,
retries, timeout, bp, flags)
struct scsipi_link *sc_link;
@@ -103,19 +105,19 @@ scsi_scsipi_cmd(sc_link, scsipi_cmd, cmdlen, data_addr, datalen,
panic("scsi_scsipi_cmd: buffer without nosleep");
#endif
- if ((xs = scsipi_make_xs(sc_link, scsipi_cmd, cmdlen, data_addr, datalen,
- retries, timeout, bp, flags)) == NULL)
- return ENOMEM;
+ if ((xs = scsipi_make_xs(sc_link, scsipi_cmd, cmdlen, data_addr,
+ datalen, retries, timeout, bp, flags)) == NULL)
+ return (ENOMEM);
if ((error = scsipi_execute_xs(xs)) == EJUSTRETURN)
- return 0;
+ return (0);
/*
* we have finished with the xfer stuct, free it and
* check if anyone else needs to be started up.
*/
scsipi_free_xs(xs, flags);
- return error;
+ return (error);
}
/*
@@ -124,7 +126,7 @@ scsi_scsipi_cmd(sc_link, scsipi_cmd, cmdlen, data_addr, datalen,
*
* THIS IS THE DEFAULT ERROR HANDLER FOR SCSI DEVICES
*/
-int
+int
scsi_interpret_sense(xs)
struct scsipi_xfer *xs;
{
@@ -177,15 +179,17 @@ scsi_interpret_sense(xs)
* it wants us to continue with normal error processing.
*/
if (sc_link->device->err_handler) {
- SC_DEBUG(sc_link, SDEV_DB2, ("calling private err_handler()\n"));
- error = (*sc_link->device->err_handler) (xs);
+ SC_DEBUG(sc_link, SDEV_DB2,
+ ("calling private err_handler()\n"));
+ error = (*sc_link->device->err_handler)(xs);
if (error != -1)
- return error; /* error >= 0 better ? */
+ return (error); /* error >= 0 better ? */
}
/* otherwise use the default */
switch (sense->error_code & SSD_ERRCODE) {
/*
- * If it's code 70, use the extended stuff and interpret the key
+ * If it's code 70, use the extended stuff and
+ * interpret the key
*/
case 0x71: /* delayed error */
sc_link->sc_print_addr(sc_link);
@@ -211,16 +215,16 @@ scsi_interpret_sense(xs)
if ((sc_link->flags & SDEV_REMOVABLE) != 0)
sc_link->flags &= ~SDEV_MEDIA_LOADED;
if ((xs->flags & SCSI_IGNORE_NOT_READY) != 0)
- return 0;
+ return (0);
if ((xs->flags & SCSI_SILENT) != 0)
- return EIO;
+ return (EIO);
error = EIO;
break;
case 0x5: /* ILLEGAL REQUEST */
if ((xs->flags & SCSI_IGNORE_ILLEGAL_REQUEST) != 0)
- return 0;
+ return (0);
if ((xs->flags & SCSI_SILENT) != 0)
- return EIO;
+ return (EIO);
error = EINVAL;
break;
case 0x6: /* UNIT ATTENTION */
@@ -229,9 +233,9 @@ scsi_interpret_sense(xs)
if ((xs->flags & SCSI_IGNORE_MEDIA_CHANGE) != 0 ||
/* XXX Should reupload any transient state. */
(sc_link->flags & SDEV_REMOVABLE) == 0)
- return ERESTART;
+ return (ERESTART);
if ((xs->flags & SCSI_SILENT) != 0)
- return EIO;
+ return (EIO);
error = EIO;
break;
case 0x7: /* DATA PROTECT */
@@ -266,13 +270,13 @@ scsi_interpret_sense(xs)
break;
case 0x8: /* BLANK CHECK */
printf(", requested size: %d (decimal)",
- info);
+ info);
break;
case 0xb:
if (xs->retries)
printf(", retrying");
printf(", cmd 0x%x, info 0x%x",
- xs->cmd->opcode, info);
+ xs->cmd->opcode, info);
break;
default:
printf(", info = %d (decimal)", info);
@@ -282,28 +286,28 @@ scsi_interpret_sense(xs)
int n;
printf(", data =");
for (n = 0; n < sense->extra_len; n++)
- printf(" %02x", sense->cmd_spec_info[n]);
+ printf(" %02x",
+ sense->cmd_spec_info[n]);
}
printf("\n");
}
#endif
- return error;
+ return (error);
/*
* Not code 70, just report it
*/
default:
sc_link->sc_print_addr(sc_link);
- printf("error code %d",
- sense->error_code & SSD_ERRCODE);
+ printf("error code %d", sense->error_code & SSD_ERRCODE);
if ((sense->error_code & SSD_ERRCODE_VALID) != 0) {
struct scsipi_sense_data_unextended *usense =
- (struct scsipi_sense_data_unextended *)sense;
+ (struct scsipi_sense_data_unextended *)sense;
printf(" at block no. %d (decimal)",
- _3btol(usense->block));
+ _3btol(usense->block));
}
printf("\n");
- return EIO;
+ return (EIO);
}
}
@@ -321,10 +325,10 @@ scsi_print_addr(sc_link)
{
printf("%s(%s:%d:%d): ",
- sc_link->device_softc ?
- ((struct device *)sc_link->device_softc)->dv_xname : "probe",
- ((struct device *)sc_link->adapter_softc)->dv_xname,
- sc_link->scsipi_scsi.target, sc_link->scsipi_scsi.lun);
+ sc_link->device_softc ?
+ ((struct device *)sc_link->device_softc)->dv_xname : "probe",
+ ((struct device *)sc_link->adapter_softc)->dv_xname,
+ sc_link->scsipi_scsi.target, sc_link->scsipi_scsi.lun);
}
#ifdef SCSIVERBOSE
@@ -540,34 +544,33 @@ static const struct {
{ 0x61, 0x01, "Unable To Acquire Video" },
{ 0x61, 0x02, "Out Of Focus" },
{ 0x62, 0x00, "Scan Head Positioning Error" },
-{ 0x63, 0x00, "End Of User Area Encountered On This Track" },
+{ 0x63, 0x00, "End Of User Area Encountered On This Track" },
{ 0x64, 0x00, "Illegal Mode For This Track" },
-{ 0x00, 0x00, (char *) 0 }
-};
+{ 0x00, 0x00, NULL }
+};
static inline void
-asc2ascii(unsigned char asc, unsigned char ascq, char *result)
+asc2ascii(asc, ascq, result)
+ unsigned char asc, ascq;
+ char *result;
{
register int i = 0;
-
- while (adesc[i].description != (char *) 0) {
- if (adesc[i].asc == asc && adesc[i].ascq == ascq) {
+
+ while (adesc[i].description != NULL) {
+ if (adesc[i].asc == asc && adesc[i].ascq == ascq)
break;
- }
i++;
}
- if (adesc[i].description == (char *) 0) {
- if (asc == 0x40 && ascq != 0) {
- (void) sprintf(result,
- "Diagnostic Failure on Component 0x%02x",
- ascq & 0xff);
- } else {
- (void) sprintf(result, "ASC 0x%02x ASCQ 0x%02x",
- asc & 0xff, ascq & 0xff);
- }
- } else {
- (void) strcpy(result, adesc[i].description);
- }
+ if (adesc[i].description == NULL) {
+ if (asc == 0x40 && ascq != 0)
+ (void)sprintf(result,
+ "Diagnostic Failure on Component 0x%02x",
+ ascq & 0xff);
+ else
+ (void)sprintf(result, "ASC 0x%02x ASCQ 0x%02x",
+ asc & 0xff, ascq & 0xff);
+ } else
+ (void)strcpy(result, adesc[i].description);
}
void
@@ -603,9 +606,8 @@ scsi_print_sense(xs, verbosity)
printf("%c EOM Detected", pad);
pad = ',';
}
- if (s[2] & SSD_ILI) {
+ if (s[2] & SSD_ILI)
printf("%c Incorrect Length Indicator Set", pad);
- }
}
/*
@@ -615,9 +617,8 @@ scsi_print_sense(xs, verbosity)
* 32 bit integer.
*/
info = _4btol(&s[3]);
- if (info) {
+ if (info)
printf("\n INFO FIELD: %d", info);
- }
/*
* Now we check additional length to see whether there is
@@ -630,25 +631,21 @@ scsi_print_sense(xs, verbosity)
return;
}
info = _4btol(&s[8]);
- if (info) {
+ if (info)
printf("\n COMMAND INFO: %d (0x%x)", info, info);
- }
/*
* Decode ASC && ASCQ info, plus FRU, plus the rest...
*/
sbs = scsi_decode_sense(s, 1);
- if (sbs) {
+ if (sbs)
printf("\n ASC/ASCQ: %s", sbs);
- }
- if (s[14] != 0) {
+ if (s[14] != 0)
printf("\n FRU CODE: 0x%x\n", s[14] & 0xff);
- }
sbs = scsi_decode_sense(s, 3);
- if (sbs) {
+ if (sbs)
printf("\n SKSV: %s", sbs);
- }
printf("\n");
if (verbosity == 0) {
printf("\n");
@@ -665,15 +662,13 @@ scsi_print_sense(xs, verbosity)
* nonzero data. If we have some, go back and print the lot,
* otherwise we're done.
*/
- if (sbs) {
+ if (sbs)
i = 18;
- } else {
+ else
i = 15;
- }
- for (j = i; j < sizeof (xs->sense); j++) {
+ for (j = i; j < sizeof (xs->sense); j++)
if (s[j])
break;
- }
if (j == sizeof (xs->sense))
return;
@@ -702,7 +697,9 @@ scsi_print_sense(xs, verbosity)
}
char *
-scsi_decode_sense(void *sinfo, int flag)
+scsi_decode_sense(sinfo, flag)
+ void *sinfo;
+ int flag;
{
unsigned char *snsbuf;
unsigned char skey;
@@ -711,13 +708,12 @@ scsi_decode_sense(void *sinfo, int flag)
skey = 0;
snsbuf = (unsigned char *) sinfo;
- if (flag == 0 || flag == 2 || flag == 3) {
+ if (flag == 0 || flag == 2 || flag == 3)
skey = snsbuf[2] & 0xf;
- }
- if (flag == 0) { /* Sense Key Only */
+ if (flag == 0) { /* Sense Key Only */
(void) strcpy(rqsbuf, sense_keys[skey]);
return (rqsbuf);
- } else if (flag == 1) { /* ASC/ASCQ Only */
+ } else if (flag == 1) { /* ASC/ASCQ Only */
asc2ascii(snsbuf[12], snsbuf[13], rqsbuf);
return (rqsbuf);
} else if (flag == 2) { /* Sense Key && ASC/ASCQ */
@@ -725,40 +721,39 @@ scsi_decode_sense(void *sinfo, int flag)
asc2ascii(snsbuf[12], snsbuf[13], localbuf);
(void) sprintf(rqsbuf, "%s, %s", sense_keys[skey], localbuf);
return (rqsbuf);
- } else if (flag == 3 && snsbuf[7] >= 9 && (snsbuf[15] & 0x80)) {
+ } else if (flag == 3 && snsbuf[7] >= 9 && (snsbuf[15] & 0x80)) {
/*
* SKSV Data
*/
switch (skey) {
- case 0x5: /* Illegal Request */
- if (snsbuf[15] & 0x8) {
- (void) sprintf(rqsbuf,
- "Error in %s, Offset %d, bit %d",
- (snsbuf[15] & 0x40)? "CDB" : "Parameters",
- (snsbuf[16] & 0xff) << 8 |
- (snsbuf[17] & 0xff), snsbuf[15] & 0xf);
- } else {
- (void) sprintf(rqsbuf,
- "Error in %s, Offset %d",
- (snsbuf[15] & 0x40)? "CDB" : "Parameters",
- (snsbuf[16] & 0xff) << 8 |
- (snsbuf[17] & 0xff));
- }
+ case 0x5: /* Illegal Request */
+ if (snsbuf[15] & 0x8)
+ (void)sprintf(rqsbuf,
+ "Error in %s, Offset %d, bit %d",
+ (snsbuf[15] & 0x40)? "CDB" : "Parameters",
+ (snsbuf[16] & 0xff) << 8 |
+ (snsbuf[17] & 0xff), snsbuf[15] & 0xf);
+ else
+ (void)sprintf(rqsbuf,
+ "Error in %s, Offset %d",
+ (snsbuf[15] & 0x40)? "CDB" : "Parameters",
+ (snsbuf[16] & 0xff) << 8 |
+ (snsbuf[17] & 0xff));
return (rqsbuf);
case 0x1:
case 0x3:
case 0x4:
- (void) sprintf(rqsbuf, "Actual Retry Count: %d",
- (snsbuf[16] & 0xff) << 8 | (snsbuf[17] & 0xff));
+ (void)sprintf(rqsbuf, "Actual Retry Count: %d",
+ (snsbuf[16] & 0xff) << 8 | (snsbuf[17] & 0xff));
return (rqsbuf);
case 0x2:
- (void) sprintf(rqsbuf, "Progress Indicator: %d",
- (snsbuf[16] & 0xff) << 8 | (snsbuf[17] & 0xff));
+ (void)sprintf(rqsbuf, "Progress Indicator: %d",
+ (snsbuf[16] & 0xff) << 8 | (snsbuf[17] & 0xff));
return (rqsbuf);
default:
break;
}
}
- return ((char *) 0);
+ return (NULL);
}
#endif
diff --git a/sys/dev/scsipi/scsi_cd.h b/sys/dev/scsipi/scsi_cd.h
index 3942ae5e464..f68ef2895df 100644
--- a/sys/dev/scsipi/scsi_cd.h
+++ b/sys/dev/scsipi/scsi_cd.h
@@ -1,4 +1,4 @@
-/* $NetBSD: scsi_cd.h,v 1.7 1997/08/27 11:26:34 bouyer Exp $ */
+/* $NetBSD: scsi_cd.h,v 1.8 1997/10/01 01:18:58 enami Exp $ */
/*
* Written by Julian Elischer (julian@tfs.com)
@@ -6,7 +6,7 @@
*
* TRW Financial Systems, in accordance with their agreement with Carnegie
* Mellon University, makes this software available to CMU to distribute
- * or use in any manner that they see fit as long as this message is kept with
+ * or use in any manner that they see fit as long as this message is kept with
* the software. For this reason TFS also grants any other persons or
* organisations permission to use or modify this software.
*
diff --git a/sys/dev/scsipi/scsi_disk.h b/sys/dev/scsipi/scsi_disk.h
index e44e32878e4..70d950f9322 100644
--- a/sys/dev/scsipi/scsi_disk.h
+++ b/sys/dev/scsipi/scsi_disk.h
@@ -1,4 +1,4 @@
-/* $NetBSD: scsi_disk.h,v 1.11 1997/08/27 11:26:41 bouyer Exp $ */
+/* $NetBSD: scsi_disk.h,v 1.12 1997/10/01 01:19:00 enami Exp $ */
/*
* SCSI-specific interface description
@@ -13,7 +13,7 @@
* Grenoble, FRANCE
*
* All Rights Reserved
- *
+ *
* Permission to use, copy, modify, and distribute this software and
* its documentation for any purpose and without fee is hereby granted,
* provided that the above copyright notice appears in all copies and
@@ -22,7 +22,7 @@
* Foundation not be used in advertising or publicity pertaining to
* distribution of the software without specific, written prior
* permission.
- *
+ *
* OSF DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
* IN NO EVENT SHALL OSF BE LIABLE FOR ANY SPECIAL, INDIRECT, OR
@@ -38,7 +38,7 @@
*
* TRW Financial Systems, in accordance with their agreement with Carnegie
* Mellon University, makes this software available to CMU to distribute
- * or use in any manner that they see fit as long as this message is kept with
+ * or use in any manner that they see fit as long as this message is kept with
* the software. For this reason TFS also grants any other persons or
* organisations permission to use or modify this software.
*
diff --git a/sys/dev/scsipi/scsi_tape.h b/sys/dev/scsipi/scsi_tape.h
index d474ca0627a..fd55a659fb7 100644
--- a/sys/dev/scsipi/scsi_tape.h
+++ b/sys/dev/scsipi/scsi_tape.h
@@ -1,4 +1,4 @@
-/* $NetBSD: scsi_tape.h,v 1.11 1997/09/29 19:29:02 mjacob Exp $ */
+/* $NetBSD: scsi_tape.h,v 1.12 1997/10/01 01:19:01 enami Exp $ */
/*
* Copyright (c) 1994 Charles Hannum. All rights reserved.
@@ -35,7 +35,7 @@
*
* TRW Financial Systems, in accordance with their agreement with Carnegie
* Mellon University, makes this software available to CMU to distribute
- * or use in any manner that they see fit as long as this message is kept with
+ * or use in any manner that they see fit as long as this message is kept with
* the software. For this reason TFS also grants any other persons or
* organisations permission to use or modify this software.
*
@@ -130,8 +130,8 @@ struct scsi_block_limits {
struct scsi_block_limits_data {
u_int8_t reserved;
- u_int8_t max_length[3]; /* Most significant */
- u_int8_t min_length[2]; /* Most significant */
+ u_int8_t max_length[3]; /* Most significant */
+ u_int8_t min_length[2]; /* Most significant */
};
/* See SCSI-II spec 9.3.3.1 */
@@ -168,21 +168,21 @@ struct scsi_tape_dev_conf_page {
/* from SCSI-3: SSC-Rev10 (6/97) */
struct scsi_tape_dev_compression_page {
- u_int8_t pagecode; /* 0xf */
- u_int8_t pagelength; /* 0xe */
- u_int8_t dce_dcc;
+ u_int8_t pagecode; /* 0x0f */
+ u_int8_t pagelength; /* 0x0e */
+ u_int8_t dce_dcc;
#define DCP_DCE 0x80 /* enable compression */
#define DCP_DCC 0x40 /* compression capable */
- u_int8_t dde_red;
+ u_int8_t dde_red;
#define DCP_DDE 0x80 /* enable decompression */
/* There's a lot of gup about bits 5,6 for reporting exceptions */
/* in transitions between compressed and uncompressed data- but */
/* mostly we want the default (0), which is to report a MEDIUM */
/* ERROR when a read transitions into data that can't be de- */
/* compressed */
- u_int8_t comp_alg[4]; /* compression algorithm */
- u_int8_t decomp_alg[4]; /* de-"" */
- u_int8_t reserved[4];
+ u_int8_t comp_alg[4]; /* compression algorithm */
+ u_int8_t decomp_alg[4]; /* de-"" */
+ u_int8_t reserved[4];
};
/* defines for the device specific byte in the mode select/sense header */
@@ -207,9 +207,9 @@ struct block_desc_cipher {
#define READ_POSITION 0x34
struct scsi_tape_read_position {
- u_int8_t opcode; /* READ_POSITION */
- u_int8_t byte1; /* set LSB to read hardware block pos */
- u_int8_t reserved[8];
+ u_int8_t opcode; /* READ_POSITION */
+ u_int8_t byte1; /* set LSB to read hardware block pos */
+ u_int8_t reserved[8];
};
#define LOCATE 0x2B
diff --git a/sys/dev/scsipi/scsiconf.c b/sys/dev/scsipi/scsiconf.c
index 10eff59eb92..15d3d1b9ee8 100644
--- a/sys/dev/scsipi/scsiconf.c
+++ b/sys/dev/scsipi/scsiconf.c
@@ -1,4 +1,4 @@
-/* $NetBSD: scsiconf.c,v 1.91 1997/09/29 11:00:36 bouyer Exp $ */
+/* $NetBSD: scsiconf.c,v 1.92 1997/10/01 01:19:03 enami Exp $ */
/*
* Copyright (c) 1994 Charles Hannum. All rights reserved.
@@ -55,6 +55,7 @@
#include <dev/scsipi/scsi_all.h>
#include <dev/scsipi/scsipi_all.h>
#include <dev/scsipi/scsiconf.h>
+
#include "locators.h"
#if 0
@@ -151,10 +152,10 @@ scsibusmatch(parent, cf, aux)
* in a special way, so that it's not printed.
*/
channel = (l->scsipi_scsi.channel != SCSI_CHANNEL_ONLY_ONE) ?
- l->scsipi_scsi.channel : 0;
+ l->scsipi_scsi.channel : 0;
if (cf->cf_loc[SCSICF_CHANNEL] != channel &&
- cf->cf_loc[SCSICF_CHANNEL] != SCSICF_CHANNEL_DEFAULT)
+ cf->cf_loc[SCSICF_CHANNEL] != SCSICF_CHANNEL_DEFAULT)
return (0);
return (1);
@@ -185,14 +186,14 @@ scsibusattach(parent, self, aux)
nbytes = sb->sc_maxtarget * sizeof(struct scsipi_link **);
sb->sc_link = (struct scsipi_link ***)malloc(nbytes, M_DEVBUF,
- M_NOWAIT);
+ M_NOWAIT);
if (sb->sc_link == NULL)
panic("scsibusattach: can't allocate target links");
nbytes = 8 * sizeof(struct scsipi_link *);
for (i = 0; i <= sb->sc_maxtarget; i++) {
sb->sc_link[i] = (struct scsipi_link **)malloc(nbytes,
- M_DEVBUF, M_NOWAIT);
+ M_DEVBUF, M_NOWAIT);
if (sb->sc_link[i] == NULL)
panic("scsibusattach: can't allocate lun links");
bzero(sb->sc_link[i], nbytes);
@@ -200,7 +201,7 @@ scsibusattach(parent, self, aux)
#if defined(SCSI_DELAY) && SCSI_DELAY > 2
printf("%s: waiting for scsi devices to settle\n",
- sb->sc_dev.dv_xname);
+ sb->sc_dev.dv_xname);
#else /* SCSI_DELAY > 2 */
#undef SCSI_DELAY
#define SCSI_DELAY 2
@@ -231,11 +232,11 @@ scsibussubmatch(parent, cf, aux)
struct scsipi_link *sc_link = sa->sa_sc_link;
if (cf->cf_loc[SCSIBUSCF_TARGET] != SCSIBUSCF_TARGET_DEFAULT &&
- cf->cf_loc[SCSIBUSCF_TARGET] != sc_link->scsipi_scsi.target)
- return 0;
+ cf->cf_loc[SCSIBUSCF_TARGET] != sc_link->scsipi_scsi.target)
+ return (0);
if (cf->cf_loc[SCSIBUSCF_LUN] != SCSIBUSCF_LUN_DEFAULT &&
- cf->cf_loc[SCSIBUSCF_LUN] != sc_link->scsipi_scsi.lun)
- return 0;
+ cf->cf_loc[SCSIBUSCF_LUN] != sc_link->scsipi_scsi.lun)
+ return (0);
return ((*cf->cf_attach->ca_match)(parent, cf, aux));
}
@@ -253,10 +254,9 @@ scsi_probe_busses(bus, target, lun)
for (bus = 0; bus < scsibus_cd.cd_ndevs; bus++)
if (scsibus_cd.cd_devs[bus])
scsi_probe_bus(bus, target, lun);
- return 0;
- } else {
- return scsi_probe_bus(bus, target, lun);
- }
+ return (0);
+ } else
+ return (scsi_probe_bus(bus, target, lun));
}
/*
@@ -272,10 +272,10 @@ scsi_probe_bus(bus, target, lun)
u_int8_t scsi_addr;
if (bus < 0 || bus >= scsibus_cd.cd_ndevs)
- return ENXIO;
+ return (ENXIO);
scsi = scsibus_cd.cd_devs[bus];
- if (!scsi)
- return ENXIO;
+ if (scsi == NULL)
+ return (ENXIO);
scsi_addr = scsi->adapter_link->scsipi_scsi.adapter_target;
@@ -284,7 +284,7 @@ scsi_probe_bus(bus, target, lun)
mintarget = 0;
} else {
if (target < 0 || target > scsi->sc_maxtarget)
- return EINVAL;
+ return (EINVAL);
maxtarget = mintarget = target;
}
@@ -293,7 +293,7 @@ scsi_probe_bus(bus, target, lun)
minlun = 0;
} else {
if (lun < 0 || lun > 7)
- return EINVAL;
+ return (EINVAL);
maxlun = minlun = lun;
}
@@ -310,7 +310,7 @@ scsi_probe_bus(bus, target, lun)
/* otherwise something says we should look further */
}
}
- return 0;
+ return (0);
}
/*
@@ -367,18 +367,17 @@ scsibusprint(aux, pnp)
dtype = "vendor-unique";
break;
}
- if (dtype == 0) {
+ if (dtype == 0)
dtype = scsipi_dtype(type);
- }
scsipi_strvis(vendor, inqbuf->vendor, 8);
scsipi_strvis(product, inqbuf->product, 16);
scsipi_strvis(revision, inqbuf->revision, 4);
printf(" targ %d lun %d: <%s, %s, %s> SCSI%d %d/%s %s%s",
- target, lun, vendor, product, revision,
- sa->scsipi_info.scsi_version & SID_ANSII, type, dtype,
- inqbuf->removable ? "removable" : "fixed", qtype);
+ target, lun, vendor, product, revision,
+ sa->scsipi_info.scsi_version & SID_ANSII, type, dtype,
+ inqbuf->removable ? "removable" : "fixed", qtype);
return (UNCONF);
}
@@ -430,8 +429,8 @@ struct scsi_quirk_inquiry_pattern scsi_quirk_patterns[] = {
"TEXEL ", "CD-ROM DM-XX24 K", "1.10"}, SDEV_NOLUNS},
{{T_CDROM, T_REMOV,
"TOSHIBA ", "XM-4101TASUNSLCD", "1755"}, SDEV_NOLUNS},
- {{T_CDROM, T_REMOV,
- "ShinaKen", "CD-ROM DM-3x1S", "1.04"}, SDEV_NOLUNS},
+ {{T_CDROM, T_REMOV,
+ "ShinaKen", "CD-ROM DM-3x1S", "1.04"}, SDEV_NOLUNS},
{{T_DIRECT, T_FIXED,
"MICROP ", "1588-15MBSUN0669", ""}, SDEV_AUTOSAVE},
{{T_OPTICAL, T_REMOV,
@@ -574,7 +573,7 @@ scsi_probedev(scsi, target, lun)
struct cfdata *cf;
/* Skip this slot if it is already attached. */
- if (scsi->sc_link[target][lun])
+ if (scsi->sc_link[target][lun] != NULL)
return;
sc_link = malloc(sizeof(*sc_link), M_DEVBUF, M_NOWAIT);
@@ -592,7 +591,8 @@ scsi_probedev(scsi, target, lun)
#endif /* SCSIDEBUG */
(void) scsipi_test_unit_ready(sc_link,
- SCSI_AUTOCONF | SCSI_IGNORE_ILLEGAL_REQUEST | SCSI_IGNORE_NOT_READY | SCSI_IGNORE_MEDIA_CHANGE);
+ SCSI_AUTOCONF | SCSI_IGNORE_ILLEGAL_REQUEST |
+ SCSI_IGNORE_NOT_READY | SCSI_IGNORE_MEDIA_CHANGE);
#ifdef SCSI_2_DEF
/* some devices need to be told to go to SCSI2 */
@@ -616,20 +616,20 @@ scsi_probedev(scsi, target, lun)
sa.sa_sc_link = sc_link;
sa.sa_inqbuf.type = inqbuf.device;
sa.sa_inqbuf.removable = inqbuf.dev_qual2 & SID_REMOVABLE ?
- T_REMOV : T_FIXED;
+ T_REMOV : T_FIXED;
sa.sa_inqbuf.vendor = inqbuf.vendor;
sa.sa_inqbuf.product = inqbuf.product;
sa.sa_inqbuf.revision = inqbuf.revision;
sa.scsipi_info.scsi_version = inqbuf.version;
- finger = (struct scsi_quirk_inquiry_pattern *)scsipi_inqmatch(&sa.sa_inqbuf,
- (caddr_t)scsi_quirk_patterns,
- sizeof(scsi_quirk_patterns)/sizeof(scsi_quirk_patterns[0]),
- sizeof(scsi_quirk_patterns[0]), &priority);
+ finger = (struct scsi_quirk_inquiry_pattern *)scsipi_inqmatch(
+ &sa.sa_inqbuf, (caddr_t)scsi_quirk_patterns,
+ sizeof(scsi_quirk_patterns)/sizeof(scsi_quirk_patterns[0]),
+ sizeof(scsi_quirk_patterns[0]), &priority);
if (priority != 0)
sc_link->quirks |= finger->quirks;
if ((inqbuf.version & SID_ANSII) == 0 &&
- (sc_link->quirks & SDEV_FORCELUNS) == 0)
+ (sc_link->quirks & SDEV_FORCELUNS) == 0)
sc_link->quirks |= SDEV_NOLUNS;
sc_link->scsipi_scsi.scsi_version = inqbuf.version;
@@ -661,7 +661,7 @@ scsi_probedev(scsi, target, lun)
default:
break;
}
- if (checkdtype) {
+ if (checkdtype)
switch (inqbuf.device & SID_TYPE) {
case T_DIRECT:
case T_SEQUENTIAL:
@@ -678,9 +678,9 @@ scsi_probedev(scsi, target, lun)
case T_NODEVICE:
goto bad;
}
- }
- if ((cf = config_search(scsibussubmatch, (struct device *)scsi, &sa)) != 0) {
+ if ((cf = config_search(scsibussubmatch, (struct device *)scsi,
+ &sa)) != NULL) {
scsi->sc_link[target][lun] = sc_link;
config_attach((struct device *)scsi, cf, &sa, scsibusprint);
} else {
diff --git a/sys/dev/scsipi/scsiconf.h b/sys/dev/scsipi/scsiconf.h
index d7467207b47..40713ad5ddd 100644
--- a/sys/dev/scsipi/scsiconf.h
+++ b/sys/dev/scsipi/scsiconf.h
@@ -1,4 +1,4 @@
-/* $NetBSD: scsiconf.h,v 1.38 1997/08/27 11:26:47 bouyer Exp $ */
+/* $NetBSD: scsiconf.h,v 1.39 1997/10/01 01:19:04 enami Exp $ */
/*
* Copyright (c) 1993, 1994, 1995 Charles Hannum. All rights reserved.
@@ -68,7 +68,7 @@ int scsiprint __P((void *, const char *));
*/
struct scsibus_softc {
struct device sc_dev;
- struct scsipi_link *adapter_link; /* prototype supplied by adapter */
+ struct scsipi_link *adapter_link; /* prototype supplied by adapter */
struct scsipi_link ***sc_link; /* dynamically allocated */
int sc_maxtarget;
u_int8_t moreluns;
@@ -78,18 +78,15 @@ struct scsibus_softc {
#define SCSI_OP_RESET 0x0002
#define SCSI_OP_BDINFO 0x0003
-int scsi_change_def __P((struct scsipi_link *, int));
-void scsi_print_addr __P((struct scsipi_link *));
-int scsi_interpret_sense __P((struct scsipi_xfer *));
+int scsi_change_def __P((struct scsipi_link *, int));
+int scsi_interpret_sense __P((struct scsipi_xfer *));
+void scsi_print_addr __P((struct scsipi_link *));
#ifdef SCSIVERBOSE
-void scsi_print_sense __P((struct scsipi_xfer *, int));
+void scsi_print_sense __P((struct scsipi_xfer *, int));
#endif
-
-int scsi_scsipi_cmd __P((struct scsipi_link *, struct scsipi_generic *,
- int cmdlen, u_char *data_addr,
- int datalen, int retries,
- int timeout, struct buf *bp,
- int flags));
-int scsi_probe_busses __P((int, int, int));
+int scsi_probe_busses __P((int, int, int));
+int scsi_scsipi_cmd __P((struct scsipi_link *, struct scsipi_generic *,
+ int cmdlen, u_char *data_addr, int datalen, int retries,
+ int timeout, struct buf *bp, int flags));
#endif /* SCSI_SCSICONF_H */
diff --git a/sys/dev/scsipi/scsipi_all.h b/sys/dev/scsipi/scsipi_all.h
index c7227c9d705..720bbf7649a 100644
--- a/sys/dev/scsipi/scsipi_all.h
+++ b/sys/dev/scsipi/scsipi_all.h
@@ -1,4 +1,4 @@
-/* $NetBSD: scsipi_all.h,v 1.2 1997/08/27 11:26:49 bouyer Exp $ */
+/* $NetBSD: scsipi_all.h,v 1.3 1997/10/01 01:19:05 enami Exp $ */
/*
* SCSI and SCSI-like general interface description
@@ -10,7 +10,7 @@
*
* TRW Financial Systems, in accordance with their agreement with Carnegie
* Mellon University, makes this software available to CMU to distribute
- * or use in any manner that they see fit as long as this message is kept with
+ * or use in any manner that they see fit as long as this message is kept with
* the software. For this reason TFS also grants any other persons or
* organisations permission to use or modify this software.
*
@@ -22,7 +22,7 @@
*/
#ifndef _SCSI_PI_ALL_H
-#define _SCSI_PI_ALL_H 1
+#define _SCSI_PI_ALL_H 1
/*
* SCSI-like command format and opcode
@@ -36,7 +36,7 @@ struct scsipi_test_unit_ready {
u_int8_t control;
};
-#define REQUEST_SENSE 0x03
+#define REQUEST_SENSE 0x03
struct scsipi_sense {
u_int8_t opcode;
u_int8_t byte2;
@@ -45,7 +45,7 @@ struct scsipi_sense {
u_int8_t control;
};
-#define INQUIRY 0x12
+#define INQUIRY 0x12
struct scsipi_inquiry {
u_int8_t opcode;
u_int8_t byte2;
@@ -54,7 +54,7 @@ struct scsipi_inquiry {
u_int8_t control;
};
-#define PREVENT_ALLOW 0x1e
+#define PREVENT_ALLOW 0x1e
struct scsipi_prevent {
u_int8_t opcode;
u_int8_t byte2;
@@ -63,54 +63,54 @@ struct scsipi_prevent {
u_int8_t control;
};
#define PR_PREVENT 0x01
-#define PR_ALLOW 0x00
+#define PR_ALLOW 0x00
/*
* inquiry and sense data format
*/
struct scsipi_sense_data {
-/* 1*/ u_int8_t error_code;
-#define SSD_ERRCODE 0x7F
-#define SSD_ERRCODE_VALID 0x80
-/* 2*/ u_int8_t segment;
-/* 3*/ u_int8_t flags;
-#define SSD_KEY 0x0F
-#define SSD_ILI 0x20
-#define SSD_EOM 0x40
-#define SSD_FILEMARK 0x80
-/* 7*/ u_int8_t info[4];
-/* 8*/ u_int8_t extra_len;
-/*12*/ u_int8_t cmd_spec_info[4];
-/*13*/ u_int8_t add_sense_code;
-/*14*/ u_int8_t add_sense_code_qual;
-/*15*/ u_int8_t fru;
-/*16*/ u_int8_t sense_key_spec_1;
-#define SSD_SCS_VALID 0x80
-/*17*/ u_int8_t sense_key_spec_2;
-/*18*/ u_int8_t sense_key_spec_3;
-/*32*/ u_int8_t extra_bytes[14];
+/* 1*/ u_int8_t error_code;
+#define SSD_ERRCODE 0x7F
+#define SSD_ERRCODE_VALID 0x80
+/* 2*/ u_int8_t segment;
+/* 3*/ u_int8_t flags;
+#define SSD_KEY 0x0F
+#define SSD_ILI 0x20
+#define SSD_EOM 0x40
+#define SSD_FILEMARK 0x80
+/* 7*/ u_int8_t info[4];
+/* 8*/ u_int8_t extra_len;
+/*12*/ u_int8_t cmd_spec_info[4];
+/*13*/ u_int8_t add_sense_code;
+/*14*/ u_int8_t add_sense_code_qual;
+/*15*/ u_int8_t fru;
+/*16*/ u_int8_t sense_key_spec_1;
+#define SSD_SCS_VALID 0x80
+/*17*/ u_int8_t sense_key_spec_2;
+/*18*/ u_int8_t sense_key_spec_3;
+/*32*/ u_int8_t extra_bytes[14];
};
struct scsipi_sense_data_unextended {
-/* 1*/ u_int8_t error_code;
-/* 4*/ u_int8_t block[3];
-};
-
-#define T_DIRECT 0
-#define T_SEQUENTIAL 1
-#define T_PRINTER 2
-#define T_PROCESSOR 3
-#define T_WORM 4
-#define T_CDROM 5
-#define T_SCANNER 6
-#define T_OPTICAL 7
-#define T_NODEVICE 0x1F
-
-#define T_CHANGER 8
-#define T_COMM 9
-
-#define T_REMOV 1
+/* 1*/ u_int8_t error_code;
+/* 4*/ u_int8_t block[3];
+};
+
+#define T_DIRECT 0
+#define T_SEQUENTIAL 1
+#define T_PRINTER 2
+#define T_PROCESSOR 3
+#define T_WORM 4
+#define T_CDROM 5
+#define T_SCANNER 6
+#define T_OPTICAL 7
+#define T_NODEVICE 0x1F
+
+#define T_CHANGER 8
+#define T_COMM 9
+
+#define T_REMOV 1
#define T_FIXED 0
/*
@@ -131,9 +131,9 @@ struct scsipi_inquiry_data {
#define SID_QUAL2 0x7F
#define SID_REMOVABLE 0x80
u_int8_t version;
-#define SID_ANSII 0x07
-#define SID_ECMA 0x38
-#define SID_ISO 0xC0
+#define SID_ANSII 0x07
+#define SID_ECMA 0x38
+#define SID_ISO 0xC0
u_int8_t response_format;
u_int8_t additional_length;
u_int8_t unused[2];
diff --git a/sys/dev/scsipi/scsipi_base.c b/sys/dev/scsipi/scsipi_base.c
index 3b799acae98..f1f10792d8b 100644
--- a/sys/dev/scsipi/scsipi_base.c
+++ b/sys/dev/scsipi/scsipi_base.c
@@ -1,4 +1,4 @@
-/* $NetBSD: scsipi_base.c,v 1.2 1997/08/27 11:26:50 bouyer Exp $ */
+/* $NetBSD: scsipi_base.c,v 1.3 1997/10/01 01:19:07 enami Exp $ */
/*
* Copyright (c) 1994, 1995, 1997 Charles M. Hannum. All rights reserved.
@@ -51,11 +51,11 @@
#include <dev/scsipi/scsipi_base.h>
struct xs_free_list xs_free_list;
-int sc_err1 __P((struct scsipi_xfer *, int));
+int sc_err1 __P((struct scsipi_xfer *, int));
/*
* Get a scsipi transfer structure for the caller. Charge the structure
- * to the device that is referenced by the sc_link structure. If the
+ * to the device that is referenced by the sc_link structure. If the
* sc_link structure has no 'credits' then the device already has the
* maximum number or outstanding operations under way. In this stage,
* wait on the structure so that when one is freed, we are awoken again
@@ -78,10 +78,10 @@ scsipi_get_xs(sc_link, flags)
SC_DEBUG(sc_link, SDEV_DB3, ("sleeping\n"));
if ((flags & SCSI_NOSLEEP) != 0) {
splx(s);
- return 0;
+ return (0);
}
sc_link->flags |= SDEV_WAITING;
- (void) tsleep(sc_link, PRIBIO, "getxs", 0);
+ (void)tsleep(sc_link, PRIBIO, "getxs", 0);
}
sc_link->openings--;
if ((xs = xs_free_list.lh_first) != NULL) {
@@ -92,18 +92,21 @@ scsipi_get_xs(sc_link, flags)
SC_DEBUG(sc_link, SDEV_DB3, ("making\n"));
xs = malloc(sizeof(*xs), M_DEVBUF,
((flags & SCSI_NOSLEEP) != 0 ? M_NOWAIT : M_WAITOK));
- if (!xs) {
+ if (xs == NULL) {
sc_link->sc_print_addr(sc_link);
printf("cannot allocate scsipi xs\n");
- return 0;
+ return (0);
}
}
SC_DEBUG(sc_link, SDEV_DB3, ("returning\n"));
- /* zero's out the command, as ATAPI may use longer commands than SCSI */
+ /*
+ * zero's out the command, as ATAPI may use longer commands
+ * than SCSI
+ */
bzero(&xs->cmdstore, sizeof(xs->cmdstore));
xs->flags = INUSE | flags;
- return xs;
+ return (xs);
}
/*
@@ -111,7 +114,7 @@ scsipi_get_xs(sc_link, flags)
* return the struct to the free pool and credit the device with it
* If another process is waiting for an xs, do a wakeup, let it proceed
*/
-void
+void
scsipi_free_xs(xs, flags)
struct scsipi_xfer *xs;
int flags;
@@ -129,8 +132,9 @@ scsipi_free_xs(xs, flags)
wakeup(sc_link);
} else {
if (sc_link->device->start) {
- SC_DEBUG(sc_link, SDEV_DB2, ("calling private start()\n"));
- (*(sc_link->device->start)) (sc_link->device_softc);
+ SC_DEBUG(sc_link, SDEV_DB2,
+ ("calling private start()\n"));
+ (*(sc_link->device->start))(sc_link->device_softc);
}
}
}
@@ -158,20 +162,20 @@ scsipi_size(sc_link, flags)
* number of blocks
*/
if (sc_link->scsipi_cmd(sc_link, (struct scsipi_generic *)&scsipi_cmd,
- sizeof(scsipi_cmd), (u_char *)&rdcap, sizeof(rdcap),
- 2, 20000, NULL, flags | SCSI_DATA_IN) != 0) {
+ sizeof(scsipi_cmd), (u_char *)&rdcap, sizeof(rdcap),
+ 2, 20000, NULL, flags | SCSI_DATA_IN) != 0) {
sc_link->sc_print_addr(sc_link);
printf("could not get size\n");
- return 0;
+ return (0);
}
- return _4btol(rdcap.addr) + 1;
+ return (_4btol(rdcap.addr) + 1);
}
/*
* Get scsipi driver to send a "are you ready?" command
*/
-int
+int
scsipi_test_unit_ready(sc_link, flags)
struct scsipi_link *sc_link;
int flags;
@@ -180,13 +184,14 @@ scsipi_test_unit_ready(sc_link, flags)
/* some ATAPI drives don't support TEST_UNIT_READY. Sigh */
if (sc_link->quirks & ADEV_NOTUR)
- return 0;
+ return (0);
bzero(&scsipi_cmd, sizeof(scsipi_cmd));
scsipi_cmd.opcode = TEST_UNIT_READY;
- return sc_link->scsipi_cmd(sc_link, (struct scsipi_generic *) &scsipi_cmd,
- sizeof(scsipi_cmd), 0, 0, 2, 10000, NULL, flags);
+ return ((*sc_link->scsipi_cmd)(sc_link,
+ (struct scsipi_generic *)&scsipi_cmd, sizeof(scsipi_cmd),
+ 0, 0, 2, 10000, NULL, flags));
}
/*
@@ -196,7 +201,7 @@ scsipi_test_unit_ready(sc_link, flags)
* that some atapi CDROM may not implement it, althouh it marked as mandatory
* in the atapi specs.
*/
-int
+int
scsipi_inquire(sc_link, inqbuf, flags)
struct scsipi_link *sc_link;
struct scsipi_inquiry_data *inqbuf;
@@ -208,16 +213,16 @@ scsipi_inquire(sc_link, inqbuf, flags)
scsipi_cmd.opcode = INQUIRY;
scsipi_cmd.length = sizeof(struct scsipi_inquiry_data);
- return sc_link->scsipi_cmd(sc_link, (struct scsipi_generic *) &scsipi_cmd,
- sizeof(scsipi_cmd), (u_char *) inqbuf,
- sizeof(struct scsipi_inquiry_data), 2, 10000, NULL,
- SCSI_DATA_IN | flags);
+ return ((*sc_link->scsipi_cmd)(sc_link,
+ (struct scsipi_generic *) &scsipi_cmd, sizeof(scsipi_cmd),
+ (u_char *) inqbuf, sizeof(struct scsipi_inquiry_data),
+ 2, 10000, NULL, SCSI_DATA_IN | flags));
}
/*
* Prevent or allow the user to remove the media
*/
-int
+int
scsipi_prevent(sc_link, type, flags)
struct scsipi_link *sc_link;
int type, flags;
@@ -225,19 +230,20 @@ scsipi_prevent(sc_link, type, flags)
struct scsipi_prevent scsipi_cmd;
if (sc_link->quirks & ADEV_NODOORLOCK)
- return 0;
+ return (0);
bzero(&scsipi_cmd, sizeof(scsipi_cmd));
scsipi_cmd.opcode = PREVENT_ALLOW;
scsipi_cmd.how = type;
- return sc_link->scsipi_cmd(sc_link, (struct scsipi_generic *) &scsipi_cmd,
- sizeof(scsipi_cmd), 0, 0, 2, 5000, NULL, flags);
+ return ((*sc_link->scsipi_cmd)(sc_link,
+ (struct scsipi_generic *) &scsipi_cmd, sizeof(scsipi_cmd),
+ 0, 0, 2, 5000, NULL, flags));
}
/*
* Get scsipi driver to send a "start up" command
*/
-int
+int
scsipi_start(sc_link, type, flags)
struct scsipi_link *sc_link;
int type, flags;
@@ -248,15 +254,16 @@ scsipi_start(sc_link, type, flags)
scsipi_cmd.opcode = START_STOP;
scsipi_cmd.byte2 = 0x00;
scsipi_cmd.how = type;
- return sc_link->scsipi_cmd(sc_link, (struct scsipi_generic *) &scsipi_cmd,
- sizeof(scsipi_cmd), 0, 0, 2,
- type == SSS_START ? 30000 : 10000, NULL, flags);
+ return ((*sc_link->scsipi_cmd)(sc_link,
+ (struct scsipi_generic *) &scsipi_cmd, sizeof(scsipi_cmd),
+ 0, 0, 2, type == SSS_START ? 30000 : 10000, NULL, flags));
}
/*
- * This routine is called by the scsipi interrupt when the transfer is complete.
+ * This routine is called by the scsipi interrupt when the transfer is
+ * complete.
*/
-void
+void
scsipi_done(xs)
struct scsipi_xfer *xs;
{
@@ -271,10 +278,11 @@ scsipi_done(xs)
#endif /* SCSIDEBUG */
/*
- * If it's a user level request, bypass all usual completion processing,
- * let the user work it out.. We take reponsibility for freeing the
- * xs when the user returns. (and restarting the device's queue).
- */
+ * If it's a user level request, bypass all usual completion
+ * processing, let the user work it out.. We take
+ * reponsibility for freeing the xs when the user returns.
+ * (and restarting the device's queue).
+ */
if ((xs->flags & SCSI_USER) != 0) {
SC_DEBUG(sc_link, SDEV_DB3, ("calling user done()\n"));
scsipi_user_done(xs); /* to take a copy of the sense etc. */
@@ -301,8 +309,8 @@ scsipi_done(xs)
*/
retry:
error = sc_err1(xs, 1);
- if (error == ERESTART) {
- switch ((*(sc_link->adapter->scsipi_cmd)) (xs)) {
+ if (error == ERESTART)
+ switch ((*(sc_link->adapter->scsipi_cmd))(xs)) {
case SUCCESSFULLY_QUEUED:
return;
@@ -311,7 +319,6 @@ retry:
case COMPLETE:
goto retry;
}
- }
bp = xs->bp;
if (bp) {
@@ -354,12 +361,12 @@ retry:
* Do the transfer. If we are polling we will return:
* COMPLETE, Was poll, and scsipi_done has been called
* TRY_AGAIN_LATER, Adapter short resources, try again
- *
+ *
* if under full steam (interrupts) it will return:
* SUCCESSFULLY_QUEUED, will do a wakeup when complete
* TRY_AGAIN_LATER, (as for polling)
* After the wakeup, we must still check if it succeeded
- *
+ *
* If we have a SCSI_NOSLEEP (typically because we have a buf)
* we just return. All the error proccessing and the buffer
* code both expect us to return straight to them, so as soon
@@ -372,10 +379,10 @@ retry:
printf("\n");
}
#endif
- switch ((*(xs->sc_link->adapter->scsipi_cmd)) (xs)) {
+ switch ((*(xs->sc_link->adapter->scsipi_cmd))(xs)) {
case SUCCESSFULLY_QUEUED:
if ((xs->flags & (SCSI_NOSLEEP | SCSI_POLL)) == SCSI_NOSLEEP)
- return EJUSTRETURN;
+ return (EJUSTRETURN);
#ifdef DIAGNOSTIC
if (xs->flags & SCSI_NOSLEEP)
panic("scsipi_execute_xs: NOSLEEP and POLL");
@@ -386,11 +393,11 @@ retry:
splx(s);
case COMPLETE: /* Polling command completed ok */
if (xs->bp)
- return EJUSTRETURN;
+ return (EJUSTRETURN);
doit:
SC_DEBUG(xs->sc_link, SDEV_DB3, ("back in cmd()\n"));
if ((error = sc_err1(xs, 0)) != ERESTART)
- return error;
+ return (error);
goto retry;
case TRY_AGAIN_LATER: /* adapter resource shortage */
@@ -404,10 +411,10 @@ retry:
#ifdef DIAGNOSTIC
panic("scsipi_execute_xs: impossible");
#endif
- return EINVAL;
+ return (EINVAL);
}
-int
+int
sc_err1(xs, async)
struct scsipi_xfer *xs;
int async;
@@ -429,7 +436,8 @@ sc_err1(xs, async)
break;
case XS_SENSE:
- if ((error = xs->sc_link->scsipi_interpret_sense(xs)) == ERESTART)
+ if ((error = (*xs->sc_link->scsipi_interpret_sense)(xs)) ==
+ ERESTART)
goto retry;
SC_DEBUG(xs->sc_link, SDEV_DB3,
("scsipi_interpret_sense returned %d\n", error));
@@ -453,7 +461,7 @@ sc_err1(xs, async)
if (xs->retries--) {
xs->error = XS_NOERROR;
xs->flags &= ~ITSDONE;
- return ERESTART;
+ return (ERESTART);
}
case XS_DRIVER_STUFFUP:
lose:
@@ -466,13 +474,13 @@ sc_err1(xs, async)
break;
default:
- xs->sc_link->sc_print_addr(xs->sc_link);
+ (*xs->sc_link->sc_print_addr)(xs->sc_link);
printf("unknown error category from scsipi driver\n");
error = EIO;
break;
}
- return error;
+ return (error);
}
#ifdef SCSIDEBUG
@@ -483,6 +491,7 @@ void
show_scsipi_xs(xs)
struct scsipi_xfer *xs;
{
+
printf("xs(%p): ", xs);
printf("flg(0x%x)", xs->flags);
printf("sc_link(%p)", xs->sc_link);
@@ -503,9 +512,9 @@ show_scsipi_cmd(xs)
struct scsipi_xfer *xs;
{
u_char *b = (u_char *) xs->cmd;
- int i = 0;
+ int i = 0;
- xs->sc_link->sc_print_addr(xs->sc_link);
+ (*xs->sc_link->sc_print_addr)(xs->sc_link);
printf("command: ");
if ((xs->flags & SCSI_RESET) == 0) {
diff --git a/sys/dev/scsipi/scsipi_base.h b/sys/dev/scsipi/scsipi_base.h
index 4e5bbaff340..ab759415508 100644
--- a/sys/dev/scsipi/scsipi_base.h
+++ b/sys/dev/scsipi/scsipi_base.h
@@ -1,4 +1,4 @@
-/* $NetBSD: scsipi_base.h,v 1.3 1997/09/19 23:53:33 cgd Exp $ */
+/* $NetBSD: scsipi_base.h,v 1.4 1997/10/01 01:19:08 enami Exp $ */
/*
* Copyright (c) 1994, 1995, 1997 Charles M. Hannum. All rights reserved.
@@ -63,7 +63,7 @@ scsipi_make_xs(sc_link, scsipi_cmd, cmdlen, data_addr, datalen,
struct scsipi_xfer *xs;
if ((xs = scsipi_get_xs(sc_link, flags)) == NULL)
- return NULL;
+ return (NULL);
/*
* Fill out the scsipi_xfer structure. We don't know whose context
@@ -85,10 +85,10 @@ scsipi_make_xs(sc_link, scsipi_cmd, cmdlen, data_addr, datalen,
*/
if ((sc_link->type == BUS_SCSI) &&
- ((sc_link->scsipi_scsi.scsi_version & SID_ANSII) <= 2))
+ ((sc_link->scsipi_scsi.scsi_version & SID_ANSII) <= 2))
xs->cmd->bytes[0] |=
((sc_link->scsipi_scsi.lun << SCSI_CMD_LUN_SHIFT) &
SCSI_CMD_LUN_MASK);
- return xs;
+ return (xs);
}
diff --git a/sys/dev/scsipi/scsipi_cd.h b/sys/dev/scsipi/scsipi_cd.h
index 36804c815d3..3f9af3f26ed 100644
--- a/sys/dev/scsipi/scsipi_cd.h
+++ b/sys/dev/scsipi/scsipi_cd.h
@@ -1,4 +1,4 @@
-/* $NetBSD: scsipi_cd.h,v 1.2 1997/08/27 11:26:53 bouyer Exp $ */
+/* $NetBSD: scsipi_cd.h,v 1.3 1997/10/01 01:19:09 enami Exp $ */
/*
* Written by Julian Elischer (julian@tfs.com)
@@ -6,7 +6,7 @@
*
* TRW Financial Systems, in accordance with their agreement with Carnegie
* Mellon University, makes this software available to CMU to distribute
- * or use in any manner that they see fit as long as this message is kept with
+ * or use in any manner that they see fit as long as this message is kept with
* the software. For this reason TFS also grants any other persons or
* organisations permission to use or modify this software.
*
@@ -115,34 +115,33 @@ struct scsipi_read_cd_cap_data {
/* mod pages common to scsi and atapi */
struct cd_audio_page {
u_int8_t page_code;
-#define CD_PAGE_CODE 0x3F
-#define AUDIO_PAGE 0x0e
-#define CD_PAGE_PS 0x80
+#define CD_PAGE_CODE 0x3F
+#define AUDIO_PAGE 0x0e
+#define CD_PAGE_PS 0x80
u_int8_t param_len;
u_int8_t flags;
#define CD_PA_SOTC 0x02
#define CD_PA_IMMED 0x04
u_int8_t unused[2];
u_int8_t format_lba; /* valid only for SCSI CDs */
-#define CD_PA_FORMAT_LBA 0x0F
+#define CD_PA_FORMAT_LBA 0x0F
#define CD_PA_APR_VALID 0x80
u_int8_t lb_per_sec[2];
- struct port_control {
- u_int8_t channels;
+ struct port_control {
+ u_int8_t channels;
#define CHANNEL 0x0F
#define CHANNEL_0 1
#define CHANNEL_1 2
#define CHANNEL_2 4
#define CHANNEL_3 8
-#define LEFT_CHANNEL CHANNEL_0
-#define RIGHT_CHANNEL CHANNEL_1
-#define MUTE_CHANNEL 0x0
-#define BOTH_CHANNEL LEFT_CHANNEL | RIGHT_CHANNEL
+#define LEFT_CHANNEL CHANNEL_0
+#define RIGHT_CHANNEL CHANNEL_1
+#define MUTE_CHANNEL 0x0
+#define BOTH_CHANNEL LEFT_CHANNEL | RIGHT_CHANNEL
u_int8_t volume;
} port[4];
#define LEFT_PORT 0
#define RIGHT_PORT 1
};
-
#endif /* _SCSI_PI_CD_H */
diff --git a/sys/dev/scsipi/scsipi_disk.h b/sys/dev/scsipi/scsipi_disk.h
index df60857a30a..2dbc1f85aaa 100644
--- a/sys/dev/scsipi/scsipi_disk.h
+++ b/sys/dev/scsipi/scsipi_disk.h
@@ -1,4 +1,4 @@
-/* $NetBSD: scsipi_disk.h,v 1.2 1997/08/27 11:26:55 bouyer Exp $ */
+/* $NetBSD: scsipi_disk.h,v 1.3 1997/10/01 01:19:10 enami Exp $ */
/*
* SCSI and SCSI-like interfaces description
@@ -13,7 +13,7 @@
* Grenoble, FRANCE
*
* All Rights Reserved
- *
+ *
* Permission to use, copy, modify, and distribute this software and
* its documentation for any purpose and without fee is hereby granted,
* provided that the above copyright notice appears in all copies and
@@ -22,7 +22,7 @@
* Foundation not be used in advertising or publicity pertaining to
* distribution of the software without specific, written prior
* permission.
- *
+ *
* OSF DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
* IN NO EVENT SHALL OSF BE LIABLE FOR ANY SPECIAL, INDIRECT, OR
@@ -38,7 +38,7 @@
*
* TRW Financial Systems, in accordance with their agreement with Carnegie
* Mellon University, makes this software available to CMU to distribute
- * or use in any manner that they see fit as long as this message is kept with
+ * or use in any manner that they see fit as long as this message is kept with
* the software. For this reason TFS also grants any other persons or
* organisations permission to use or modify this software.
*
diff --git a/sys/dev/scsipi/scsipi_ioctl.c b/sys/dev/scsipi/scsipi_ioctl.c
index 1cbe6d512e4..f9d26528f4e 100644
--- a/sys/dev/scsipi/scsipi_ioctl.c
+++ b/sys/dev/scsipi/scsipi_ioctl.c
@@ -1,4 +1,4 @@
-/* $NetBSD: scsipi_ioctl.c,v 1.26 1997/09/19 00:59:49 enami Exp $ */
+/* $NetBSD: scsipi_ioctl.c,v 1.27 1997/10/01 01:19:12 enami Exp $ */
/*
* Copyright (c) 1994 Charles Hannum. All rights reserved.
@@ -29,11 +29,11 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-/*
+/*
* Contributed by HD Associates (hd@world.std.com).
* Copyright (c) 1992, 1993 HD Associates
*
- * Berkeley style copyright.
+ * Berkeley style copyright.
*/
#include <sys/types.h>
@@ -51,6 +51,7 @@
#include <dev/scsipi/scsipiconf.h>
#include <dev/scsipi/scsiconf.h>
#include <sys/scsiio.h>
+
#include "scsibus.h"
#include "atapibus.h"
@@ -65,10 +66,10 @@ struct scsi_ioctl {
LIST_HEAD(, scsi_ioctl) si_head;
-struct scsi_ioctl *si_get __P((void));
-void si_free __P((struct scsi_ioctl *));
-struct scsi_ioctl *si_find __P((struct buf *));
-void scsistrategy __P((struct buf *));
+struct scsi_ioctl *si_find __P((struct buf *));
+void si_free __P((struct scsi_ioctl *));
+struct scsi_ioctl *si_get __P((void));
+void scsistrategy __P((struct buf *));
struct scsi_ioctl *
si_get()
@@ -129,13 +130,13 @@ scsipi_user_done(xs)
struct scsipi_link *sc_link;
bp = xs->bp;
- if (!bp) { /* ALL user requests must have a buf */
+ if (bp == NULL) { /* ALL user requests must have a buf */
xs->sc_link->sc_print_addr(xs->sc_link);
printf("User command with no buf\n");
return;
}
si = si_find(bp);
- if (!si) {
+ if (si == NULL) {
xs->sc_link->sc_print_addr(xs->sc_link);
printf("User command with no ioctl\n");
return;
@@ -149,12 +150,14 @@ scsipi_user_done(xs)
switch (xs->error) {
case XS_NOERROR:
SC_DEBUG(sc_link, SDEV_DB3, ("no error\n"));
- screq->datalen_used = xs->datalen - xs->resid; /* probably rubbish */
+ screq->datalen_used =
+ xs->datalen - xs->resid; /* probably rubbish */
screq->retsts = SCCMD_OK;
break;
case XS_SENSE:
SC_DEBUG(sc_link, SDEV_DB3, ("have sense\n"));
- screq->senselen_used = min(sizeof(xs->sense.scsi_sense), SENSEBUFLEN);
+ screq->senselen_used = min(sizeof(xs->sense.scsi_sense),
+ SENSEBUFLEN);
bcopy(&xs->sense.scsi_sense, screq->sense, screq->senselen);
screq->retsts = SCCMD_SENSE;
break;
@@ -184,7 +187,7 @@ scsipi_user_done(xs)
/* Pseudo strategy function
* Called by scsipi_do_ioctl() via physio/physstrat if there is to
* be data transfered, and directly if there is no data transfer.
- *
+ *
* Should I reorganize this so it returns to physio instead
* of sleeping in scsiio_scsipi_cmd? Is there any advantage, other
* than avoiding the probable duplicate wakeup in iodone? [PD]
@@ -208,7 +211,7 @@ scsistrategy(bp)
int s;
si = si_find(bp);
- if (!si) {
+ if (si == NULL) {
printf("user_strat: No ioctl\n");
error = EINVAL;
goto bad;
@@ -248,8 +251,9 @@ scsistrategy(bp)
if (screq->flags & SCCMD_ESCAPE)
flags |= SCSI_ESCAPE;
- error = sc_link->scsipi_cmd(sc_link, (struct scsipi_generic *)screq->cmd,
- screq->cmdlen, (u_char *)bp->b_data, screq->datalen,
+ error = (*sc_link->scsipi_cmd)(sc_link,
+ (struct scsipi_generic *)screq->cmd, screq->cmdlen,
+ (u_char *)bp->b_data, screq->datalen,
0, /* user must do the retries *//* ignored */
screq->timeout, bp, flags | SCSI_USER | SCSI_NOSLEEP);
@@ -299,14 +303,14 @@ scsipi_do_ioctl(sc_link, dev, cmd, addr, flag, p)
case SCIOCCOMMAND:
if ((((scsireq_t *)addr)->flags & SCCMD_READ) == 0 &&
(flag & FWRITE) == 0)
- return EBADF;
+ return (EBADF);
break;
default:
if ((flag & FWRITE) == 0)
- return EBADF;
+ return (EBADF);
}
- switch(cmd) {
+ switch (cmd) {
case SCIOCCOMMAND: {
scsireq_t *screq = (scsireq_t *)addr;
struct scsi_ioctl *si;
@@ -324,7 +328,7 @@ scsipi_do_ioctl(sc_link, dev, cmd, addr, flag, p)
si->si_uio.uio_resid = len;
si->si_uio.uio_offset = 0;
si->si_uio.uio_segflg = UIO_USERSPACE;
- si->si_uio.uio_rw =
+ si->si_uio.uio_rw =
(screq->flags & SCCMD_READ) ? UIO_READ : UIO_WRITE;
si->si_uio.uio_procp = p;
error = physio(scsistrategy, &si->si_bp, dev,
@@ -342,7 +346,7 @@ scsipi_do_ioctl(sc_link, dev, cmd, addr, flag, p)
}
*screq = si->si_screq;
si_free(si);
- return error;
+ return (error);
}
case SCIOCDEBUG: {
int level = *((int *)addr);
@@ -357,16 +361,15 @@ scsipi_do_ioctl(sc_link, dev, cmd, addr, flag, p)
sc_link->flags |= SDEV_DB3;
if (level & 8)
sc_link->flags |= SDEV_DB4;
- return 0;
+ return (0);
}
#if NSCSIBUS > 0
case SCIOCREPROBE: {
struct scsi_addr *sca = (struct scsi_addr *)addr;
- if (sca->type != TYPE_SCSI) {
- return ENODEV;
- }
- return scsi_probe_busses(sca->addr.scsi.scbus, sca->addr.scsi.target,
- sca->addr.scsi.lun);
+ if (sca->type != TYPE_SCSI)
+ return (ENODEV);
+ return (scsi_probe_busses(sca->addr.scsi.scbus,
+ sca->addr.scsi.target, sca->addr.scsi.lun));
}
#if defined(COMPAT_12) || defined(COMPAT_FREEBSD)
/* SCIOCREPROBE before ATAPI staff merge */
@@ -379,39 +382,42 @@ scsipi_do_ioctl(sc_link, dev, cmd, addr, flag, p)
#endif
case SCIOCRECONFIG:
case SCIOCDECONFIG:
- return EINVAL;
+ return (EINVAL);
case SCIOCIDENTIFY: {
struct scsi_addr *sca = (struct scsi_addr *)addr;
- if (sc_link->type == BUS_SCSI) {
+
+ switch (sc_link->type) {
+ case BUS_SCSI:
sca->type = TYPE_SCSI;
sca->addr.scsi.scbus = sc_link->scsipi_scsi.scsibus;
sca->addr.scsi.target = sc_link->scsipi_scsi.target;
sca->addr.scsi.lun = sc_link->scsipi_scsi.lun;
- return 0;
- }
- if (sc_link->type == BUS_ATAPI) {
+ return (0);
+ case BUS_ATAPI:
sca->type = TYPE_ATAPI;
sca->addr.atapi.atbus = sc_link->scsipi_atapi.atapibus;
sca->addr.atapi.drive = sc_link->scsipi_atapi.drive;
- return 0;
+ return (0);
}
- return ENXIO;
+ return (ENXIO);
}
#if defined(COMPAT_12) || defined(COMPAT_FREEBSD)
/* SCIOCIDENTIFY before ATAPI staff merge */
case OSCIOCIDENTIFY: {
struct oscsi_addr *sca = (struct oscsi_addr *)addr;
- if (sc_link->type != BUS_SCSI)
- return (ENODEV);
- sca->scbus = sc_link->scsipi_scsi.scsibus;
- sca->target = sc_link->scsipi_scsi.target;
- sca->lun = sc_link->scsipi_scsi.lun;
- return (0);
+ switch (sc_link->type) {
+ case BUS_SCSI:
+ sca->scbus = sc_link->scsipi_scsi.scsibus;
+ sca->target = sc_link->scsipi_scsi.target;
+ sca->lun = sc_link->scsipi_scsi.lun;
+ return (0);
+ }
+ return (ENODEV);
}
#endif
default:
- return ENOTTY;
+ return (ENOTTY);
}
#ifdef DIAGNOSTIC
diff --git a/sys/dev/scsipi/scsipiconf.c b/sys/dev/scsipi/scsipiconf.c
index 65a4016dd19..605c012bbb2 100644
--- a/sys/dev/scsipi/scsipiconf.c
+++ b/sys/dev/scsipi/scsipiconf.c
@@ -1,4 +1,4 @@
-/* $NetBSD: scsipiconf.c,v 1.2 1997/08/27 11:26:58 bouyer Exp $ */
+/* $NetBSD: scsipiconf.c,v 1.3 1997/10/01 01:19:13 enami Exp $ */
/*
* Copyright (c) 1994 Charles Hannum. All rights reserved.
@@ -114,6 +114,7 @@ scsipi_dtype(type)
int type;
{
char *dtype;
+
switch (type) {
case T_DIRECT:
dtype = "direct";
@@ -151,7 +152,7 @@ scsipi_dtype(type)
dtype = "unknown";
break;
}
- return dtype;
+ return (dtype);
}
void
diff --git a/sys/dev/scsipi/scsipiconf.h b/sys/dev/scsipi/scsipiconf.h
index 465029cb458..a5209258650 100644
--- a/sys/dev/scsipi/scsipiconf.h
+++ b/sys/dev/scsipi/scsipiconf.h
@@ -1,4 +1,4 @@
-/* $NetBSD: scsipiconf.h,v 1.2 1997/08/27 11:27:00 bouyer Exp $ */
+/* $NetBSD: scsipiconf.h,v 1.3 1997/10/01 01:19:14 enami Exp $ */
/*
* Copyright (c) 1993, 1994, 1995 Charles Hannum. All rights reserved.
@@ -59,17 +59,17 @@ typedef int boolean;
* The following documentation tries to describe the relationship between the
* various structures defined in this file:
*
- * each adapter type has a scsipi_adapter struct. This describes the adapter and
- * identifies routines that can be called to use the adapter.
+ * each adapter type has a scsipi_adapter struct. This describes the adapter
+ * and identifies routines that can be called to use the adapter.
* each device type has a scsipi_device struct. This describes the device and
* identifies routines that can be called to use the device.
- * each existing device position (scsibus + target + lun or atapibus + drive)
+ * each existing device position (scsibus + target + lun or atapibus + drive)
* can be described by a scsipi_link struct.
* Only scsipi positions that actually have devices, have a scsipi_link
* structure assigned. so in effect each device has scsipi_link struct.
* The scsipi_link structure contains information identifying both the
- * device driver and the adapter driver for that position on that scsipi bus,
- * and can be said to 'link' the two.
+ * device driver and the adapter driver for that position on that scsipi
+ * bus, and can be said to 'link' the two.
* each individual scsipi bus has an array that points to all the scsipi_link
* structs associated with that scsipi bus. Slots with no device have
* a NULL pointer.
@@ -121,16 +121,16 @@ struct scsipi_device {
void (*done) __P((struct scsipi_xfer *));
};
-/*
+/*
* These entrypoints are called by the high-end drivers to get services from
- * whatever low-end drivers they are attached to each adapter type has one of
- * these statically allocated.
+ * whatever low-end drivers they are attached to each adapter type has one of
+ * these statically allocated.
*/
struct scsipi_adapter {
- int (*scsipi_cmd) __P((struct scsipi_xfer *));
+ int (*scsipi_cmd) __P((struct scsipi_xfer *));
void (*scsipi_minphys) __P((struct buf *));
int (*open_target_lu) __P((void));
- int (*close_target_lu) __P((void));
+ int (*close_target_lu) __P((void));
};
/*
@@ -144,9 +144,9 @@ struct scsipi_adapter {
*/
struct scsipi_link {
- u_int8_t type; /* device type, i.e. SCSI, ATAPI, ... */
-#define BUS_SCSI 0
-#define BUS_ATAPI 1
+ u_int8_t type; /* device type, i.e. SCSI, ATAPI, ...*/
+#define BUS_SCSI 0
+#define BUS_ATAPI 1
u_int8_t openings; /* available operations */
u_int8_t active; /* operations in progress */
u_int8_t flags; /* flags that all devices have */
@@ -164,8 +164,8 @@ struct scsipi_link {
#define SDEV_NOMODESENSE 0x0010 /* removable media/optical drives */
#define SDEV_NOSTARTUNIT 0x0020 /* do not issue start unit requests
in sd.c */
-#define ADEV_CDROM 0x0100 /* device is a CD-ROM */
-#define ADEV_LITTLETOC 0x0200 /* Audio TOC uses wrong byte order */
+#define ADEV_CDROM 0x0100 /* device is a CD-ROM */
+#define ADEV_LITTLETOC 0x0200 /* Audio TOC uses wrong byte order */
#define ADEV_NOCAPACITY 0x0400 /* no READ_CD_CAPACITY command */
#define ADEV_NOTUR 0x0800 /* no TEST_UNIT_READY command */
#define ADEV_NODOORLOCK 0x1000 /* device can't look door */
@@ -173,12 +173,12 @@ struct scsipi_link {
struct scsipi_device *device; /* device entry points etc. */
void *device_softc; /* needed for call to foo_start */
- struct scsipi_adapter *adapter; /* adapter entry points etc. */
+ struct scsipi_adapter *adapter;/* adapter entry points etc. */
void *adapter_softc; /* needed for call to foo_scsipi_cmd */
union { /* needed for call to foo_scsipi_cmd */
struct scsi_link {
- int channel; /* channel, i.e. bus # on controller */
-
+ int channel; /* channel, i.e. bus # on controller */
+
u_int8_t scsi_version; /* SCSI-I, SCSI-II, etc. */
u_int8_t scsibus; /* the Nth scsibus */
u_int8_t target; /* targ of this dev */
@@ -198,16 +198,14 @@ struct scsipi_link {
u_int8_t atapibus;
u_int8_t cap; /* drive capability */
#define ACAP_DRQ_MPROC 0x0000 /* microprocessor DRQ */
-#define ACAP_DRQ_INTR 0x0100 /* interrupt DRQ */
+#define ACAP_DRQ_INTR 0x0100 /* interrupt DRQ */
#define ACAP_DRQ_ACCEL 0x0200 /* accelerated DRQ */
#define ACAP_LEN 0x0400 /* 16 bit commands */
} scsipi_atapi;
} _scsipi_link;
int (*scsipi_cmd) __P((struct scsipi_link *, struct scsipi_generic *,
- int cmdlen, u_char *data_addr,
- int datalen, int retries,
- int timeout, struct buf *bp,
- int flags));
+ int cmdlen, u_char *data_addr, int datalen, int retries,
+ int timeout, struct buf *bp, int flags));
int (*scsipi_interpret_sense) __P((struct scsipi_xfer *));
void (*sc_print_addr) __P((struct scsipi_link *sc_link));
};
@@ -232,7 +230,8 @@ struct scsipi_xfer {
int datalen; /* data len (blank if uio) */
int resid; /* how much buffer was not touched */
int error; /* an error value */
- struct buf *bp; /* If we need to associate with a buf */
+ struct buf *bp; /* If we need to associate with */
+ /* a buf */
union {
struct scsipi_sense_data scsi_sense; /* 32 bytes */
u_int32_t atapi_sense;
@@ -296,12 +295,12 @@ struct scsipi_inquiry_pattern {
struct scsipibus_attach_args {
struct scsipi_link *sa_sc_link;
struct scsipi_inquiry_pattern sa_inqbuf;
- union { /* bus-type specific infos */
- u_int8_t scsi_version; /* SCSI version */
+ union { /* bus-type specific infos */
+ u_int8_t scsi_version; /* SCSI version */
} scsipi_info;
};
-/*
+/*
* this describes a quirk entry
*/
diff --git a/sys/dev/scsipi/sd.c b/sys/dev/scsipi/sd.c
index 099511beb4d..e762e3ebb21 100644
--- a/sys/dev/scsipi/sd.c
+++ b/sys/dev/scsipi/sd.c
@@ -1,4 +1,4 @@
-/* $NetBSD: sd.c,v 1.117 1997/09/20 18:56:30 mjacob Exp $ */
+/* $NetBSD: sd.c,v 1.118 1997/10/01 01:19:17 enami Exp $ */
/*
* Copyright (c) 1994, 1995, 1997 Charles M. Hannum. All rights reserved.
@@ -169,7 +169,7 @@ sdmatch(parent, match, aux)
int priority;
(void)scsipi_inqmatch(&sa->sa_inqbuf,
- (caddr_t)sd_patterns, sizeof(sd_patterns)/sizeof(sd_patterns[0]),
+ (caddr_t)sd_patterns, sizeof(sd_patterns) / sizeof(sd_patterns[0]),
sizeof(sd_patterns[0]), &priority);
return (priority);
}
@@ -228,8 +228,8 @@ sdattach(parent, self, aux)
if ((sd->sc_link->quirks & SDEV_NOSTARTUNIT) == 0) {
error = scsipi_start(sd->sc_link, SSS_START,
- SCSI_AUTOCONF | SCSI_IGNORE_ILLEGAL_REQUEST |
- SCSI_IGNORE_MEDIA_CHANGE | SCSI_SILENT);
+ SCSI_AUTOCONF | SCSI_IGNORE_ILLEGAL_REQUEST |
+ SCSI_IGNORE_MEDIA_CHANGE | SCSI_SILENT);
} else
error = 0;
@@ -256,10 +256,10 @@ sdlock(sd)
while ((sd->flags & SDF_LOCKED) != 0) {
sd->flags |= SDF_WANTED;
if ((error = tsleep(sd, PRIBIO | PCATCH, "sdlck", 0)) != 0)
- return error;
+ return (error);
}
sd->flags |= SDF_LOCKED;
- return 0;
+ return (0);
}
/*
@@ -293,10 +293,10 @@ sdopen(dev, flag, fmt, p)
unit = SDUNIT(dev);
if (unit >= sd_cd.cd_ndevs)
- return ENXIO;
+ return (ENXIO);
sd = sd_cd.cd_devs[unit];
if (sd == NULL)
- return ENXIO;
+ return (ENXIO);
sc_link = sd->sc_link;
@@ -305,7 +305,7 @@ sdopen(dev, flag, fmt, p)
sd_cd.cd_ndevs, SDPART(dev)));
if ((error = sdlock(sd)) != 0)
- return error;
+ return (error);
if (sd->sc_dk.dk_openmask != 0) {
/*
@@ -319,18 +319,16 @@ sdopen(dev, flag, fmt, p)
} else {
/* Check that it is still responding and ok. */
error = scsipi_test_unit_ready(sc_link,
- SCSI_IGNORE_ILLEGAL_REQUEST |
- SCSI_IGNORE_MEDIA_CHANGE |
- SCSI_IGNORE_NOT_READY);
+ SCSI_IGNORE_ILLEGAL_REQUEST | SCSI_IGNORE_MEDIA_CHANGE |
+ SCSI_IGNORE_NOT_READY);
if (error)
goto bad3;
/* Start the pack spinning if necessary. */
if ((sc_link->quirks & SDEV_NOSTARTUNIT) == 0) {
error = scsipi_start(sc_link, SSS_START,
- SCSI_IGNORE_ILLEGAL_REQUEST |
- SCSI_IGNORE_MEDIA_CHANGE |
- SCSI_SILENT);
+ SCSI_IGNORE_ILLEGAL_REQUEST |
+ SCSI_IGNORE_MEDIA_CHANGE | SCSI_SILENT);
if (error)
goto bad3;
}
@@ -339,8 +337,7 @@ sdopen(dev, flag, fmt, p)
/* Lock the pack in. */
error = scsipi_prevent(sc_link, PR_PREVENT,
- SCSI_IGNORE_ILLEGAL_REQUEST |
- SCSI_IGNORE_MEDIA_CHANGE);
+ SCSI_IGNORE_ILLEGAL_REQUEST | SCSI_IGNORE_MEDIA_CHANGE);
if (error)
goto bad;
@@ -379,11 +376,12 @@ sdopen(dev, flag, fmt, p)
sd->sc_dk.dk_bopenmask |= (1 << part);
break;
}
- sd->sc_dk.dk_openmask = sd->sc_dk.dk_copenmask | sd->sc_dk.dk_bopenmask;
+ sd->sc_dk.dk_openmask =
+ sd->sc_dk.dk_copenmask | sd->sc_dk.dk_bopenmask;
SC_DEBUG(sc_link, SDEV_DB3, ("open complete\n"));
sdunlock(sd);
- return 0;
+ return (0);
bad2:
sc_link->flags &= ~SDEV_MEDIA_LOADED;
@@ -397,7 +395,7 @@ bad:
bad3:
sdunlock(sd);
- return error;
+ return (error);
}
/*
@@ -415,7 +413,7 @@ sdclose(dev, flag, fmt, p)
int error;
if ((error = sdlock(sd)) != 0)
- return error;
+ return (error);
switch (fmt) {
case S_IFCHR:
@@ -425,7 +423,8 @@ sdclose(dev, flag, fmt, p)
sd->sc_dk.dk_bopenmask &= ~(1 << part);
break;
}
- sd->sc_dk.dk_openmask = sd->sc_dk.dk_copenmask | sd->sc_dk.dk_bopenmask;
+ sd->sc_dk.dk_openmask =
+ sd->sc_dk.dk_copenmask | sd->sc_dk.dk_bopenmask;
if (sd->sc_dk.dk_openmask == 0) {
/* XXXX Must wait for I/O to complete! */
@@ -436,7 +435,7 @@ sdclose(dev, flag, fmt, p)
}
sdunlock(sd);
- return 0;
+ return (0);
}
/*
@@ -531,6 +530,7 @@ sdstart(v)
{
register struct sd_softc *sd = v;
register struct scsipi_link *sc_link = sd->sc_link;
+ struct disklabel *lp = sd->sc_dk.dk_label;
struct buf *bp = 0;
struct buf *dp;
struct scsipi_rw_big cmd_big;
@@ -582,13 +582,12 @@ sdstart(v)
* First, translate the block to absolute and put it in terms
* of the logical blocksize of the device.
*/
- blkno =
- bp->b_blkno / (sd->sc_dk.dk_label->d_secsize / DEV_BSIZE);
+ blkno = bp->b_blkno / (lp->d_secsize / DEV_BSIZE);
if (SDPART(bp->b_dev) != RAW_PART) {
- p = &sd->sc_dk.dk_label->d_partitions[SDPART(bp->b_dev)];
- blkno += p->p_offset;
+ p = &lp->d_partitions[SDPART(bp->b_dev)];
+ blkno += p->p_offset;
}
- nblks = howmany(bp->b_bcount, sd->sc_dk.dk_label->d_secsize);
+ nblks = howmany(bp->b_bcount, lp->d_secsize);
/*
* Fill out the scsi command. If the transfer will
@@ -626,7 +625,7 @@ sdstart(v)
* Call the routine that chats with the adapter.
* Note: we cannot sleep as we may be an interrupt
*/
- error = sc_link->scsipi_cmd(sc_link, cmdp, cmdlen,
+ error = (*sc_link->scsipi_cmd)(sc_link, cmdp, cmdlen,
(u_char *)bp->b_data, bp->b_bcount,
SDRETRIES, 60000, bp, SCSI_NOSLEEP |
((bp->b_flags & B_READ) ? SCSI_DATA_IN : SCSI_DATA_OUT));
@@ -715,26 +714,26 @@ sdioctl(dev, cmd, addr, flag, p)
* If the device is not valid.. abandon ship
*/
if ((sd->sc_link->flags & SDEV_MEDIA_LOADED) == 0)
- return EIO;
+ return (EIO);
switch (cmd) {
case DIOCGDINFO:
*(struct disklabel *)addr = *(sd->sc_dk.dk_label);
- return 0;
+ return (0);
case DIOCGPART:
((struct partinfo *)addr)->disklab = sd->sc_dk.dk_label;
((struct partinfo *)addr)->part =
&sd->sc_dk.dk_label->d_partitions[SDPART(dev)];
- return 0;
+ return (0);
case DIOCWDINFO:
case DIOCSDINFO:
if ((flag & FWRITE) == 0)
- return EBADF;
+ return (EBADF);
if ((error = sdlock(sd)) != 0)
- return error;
+ return (error);
sd->flags |= SDF_LABELLING;
error = setdisklabel(sd->sc_dk.dk_label,
@@ -749,20 +748,20 @@ sdioctl(dev, cmd, addr, flag, p)
sd->flags &= ~SDF_LABELLING;
sdunlock(sd);
- return error;
+ return (error);
case DIOCWLABEL:
if ((flag & FWRITE) == 0)
- return EBADF;
+ return (EBADF);
if (*(int *)addr)
sd->flags |= SDF_WLABEL;
else
sd->flags &= ~SDF_WLABEL;
- return 0;
+ return (0);
case DIOCLOCK:
- return scsipi_prevent(sd->sc_link,
- (*(int *)addr) ? PR_PREVENT : PR_ALLOW, 0);
+ return (scsipi_prevent(sd->sc_link,
+ (*(int *)addr) ? PR_PREVENT : PR_ALLOW, 0));
case DIOCEJECT:
return ((sd->sc_link->flags & SDEV_REMOVABLE) == 0 ? ENOTTY :
@@ -770,8 +769,8 @@ sdioctl(dev, cmd, addr, flag, p)
default:
if (SDPART(dev) != RAW_PART)
- return ENOTTY;
- return scsipi_do_ioctl(sd->sc_link, dev, cmd, addr, flag, p);
+ return (ENOTTY);
+ return (scsipi_do_ioctl(sd->sc_link, dev, cmd, addr, flag, p));
}
#ifdef DIAGNOSTIC
@@ -827,7 +826,7 @@ sdgetdisklabel(sd)
* Call the generic disklabel extraction routine
*/
errstring = readdisklabel(MAKESDDEV(0, sd->sc_dev.dv_unit, RAW_PART),
- sdstrategy, lp, sd->sc_dk.dk_cpulabel);
+ sdstrategy, lp, sd->sc_dk.dk_cpulabel);
if (errstring) {
printf("%s: %s\n", sd->sc_dev.dv_xname, errstring);
return;
@@ -852,10 +851,10 @@ sd_reassign_blocks(sd, blkno)
_lto2b(sizeof(rbdata.defect_descriptor[0]), rbdata.length);
_lto4b(blkno, rbdata.defect_descriptor[0].dlbaddr);
- return sd->sc_link->scsipi_cmd(sd->sc_link,
- (struct scsipi_generic *)&scsipi_cmd,
- sizeof(scsipi_cmd), (u_char *)&rbdata, sizeof(rbdata), SDRETRIES,
- 5000, NULL, SCSI_DATA_OUT);
+ return ((*sd->sc_link->scsipi_cmd)(sd->sc_link,
+ (struct scsipi_generic *)&scsipi_cmd, sizeof(scsipi_cmd),
+ (u_char *)&rbdata, sizeof(rbdata), SDRETRIES, 5000, NULL,
+ SCSI_DATA_OUT));
}
@@ -883,10 +882,10 @@ sd_mode_sense(sd, scsipi_sense, page, flags)
* If the command worked, use the results to fill out
* the parameter structure
*/
- return sd->sc_link->scsipi_cmd(sd->sc_link,
- (struct scsipi_generic *)&scsipi_cmd,
- sizeof(scsipi_cmd), (u_char *)scsipi_sense, sizeof(*scsipi_sense),
- SDRETRIES, 6000, NULL, flags | SCSI_DATA_IN | SCSI_SILENT);
+ return ((*sd->sc_link->scsipi_cmd)(sd->sc_link,
+ (struct scsipi_generic *)&scsipi_cmd, sizeof(scsipi_cmd),
+ (u_char *)scsipi_sense, sizeof(*scsipi_sense),
+ SDRETRIES, 6000, NULL, flags | SCSI_DATA_IN | SCSI_SILENT));
}
int
@@ -906,7 +905,7 @@ sd_get_optparms(sd, flags, dp)
dp->blksize = 512;
if ((sectors = scsipi_size(sd->sc_link, flags)) == 0)
- return 1;
+ return (1);
/* XXX
* It is better to get the following params from the
@@ -920,11 +919,11 @@ sd_get_optparms(sd, flags, dp)
scsipi_cmd.length = sizeof(struct scsi_mode_header) +
sizeof(struct scsi_blk_desc);
- if ((error = sd->sc_link->scsipi_cmd(sd->sc_link,
+ if ((error = (*sd->sc_link->scsipi_cmd)(sd->sc_link,
(struct scsipi_generic *)&scsipi_cmd, sizeof(scsipi_cmd),
(u_char *)&scsipi_sense, sizeof(scsipi_sense), SDRETRIES,
6000, NULL, flags | SCSI_DATA_IN)) != 0)
- return error;
+ return (error);
dp->blksize = _3btol(scsipi_sense.blk_desc.blklen);
if (dp->blksize == 0)
@@ -938,7 +937,7 @@ sd_get_optparms(sd, flags, dp)
dp->cyls = sectors / (dp->heads * dp->sectors);
dp->disksize = sectors;
- return 0;
+ return (0);
}
/*
@@ -959,7 +958,7 @@ sd_get_parms(sd, flags)
if (sd->type == T_OPTICAL) {
if ((error = sd_get_optparms(sd, flags, dp)) != 0)
sd->sc_link->flags &= ~SDEV_MEDIA_LOADED;
- return error;
+ return (error);
}
if ((error = sd_mode_sense(sd, &scsipi_sense, page = 4, flags)) == 0) {
@@ -992,7 +991,7 @@ sd_get_parms(sd, flags)
sectors /= (dp->heads * dp->cyls);
dp->sectors = sectors; /* XXX dubious on SCSI */
- return 0;
+ return (0);
}
if ((error = sd_mode_sense(sd, &scsipi_sense, page = 5, flags)) == 0) {
@@ -1007,7 +1006,7 @@ sd_get_parms(sd, flags)
if (dp->blksize == 0)
dp->blksize = 512;
- return 0;
+ return (0);
}
fake_it:
@@ -1031,7 +1030,7 @@ fake_it:
dp->cyls = sectors / (64 * 32);
dp->blksize = 512;
dp->disksize = sectors;
- return 0;
+ return (0);
}
int
@@ -1094,7 +1093,7 @@ sddump(dev, blkno, va, size)
/* Check if recursive dump; if so, punt. */
if (sddoingadump)
- return EFAULT;
+ return (EFAULT);
/* Mark as active early. */
sddoingadump = 1;
@@ -1104,7 +1103,7 @@ sddump(dev, blkno, va, size)
/* Check for acceptable drive number. */
if (unit >= sd_cd.cd_ndevs || (sd = sd_cd.cd_devs[unit]) == NULL)
- return ENXIO;
+ return (ENXIO);
/*
* XXX Can't do this check, since the media might have been
@@ -1114,14 +1113,14 @@ sddump(dev, blkno, va, size)
#if 0
/* Make sure it was initialized. */
if ((sd->sc_link->flags & SDEV_MEDIA_LOADED) != SDEV_MEDIA_LOADED)
- return ENXIO;
+ return (ENXIO);
#endif
/* Convert to disk sectors. Request must be a multiple of size. */
lp = sd->sc_dk.dk_label;
sectorsize = lp->d_secsize;
if ((size % sectorsize) != 0)
- return EFAULT;
+ return (EFAULT);
totwrt = size / sectorsize;
blkno = dbtob(blkno) / sectorsize; /* blkno in DEV_BSIZE units */
@@ -1130,7 +1129,7 @@ sddump(dev, blkno, va, size)
/* Check transfer bounds against partition size. */
if ((blkno < 0) || ((blkno + totwrt) > nsects))
- return EINVAL;
+ return (EINVAL);
/* Offset block number to start of partition. */
blkno += sectoff;
@@ -1169,9 +1168,9 @@ sddump(dev, blkno, va, size)
/*
* Pass all this info to the scsi driver.
*/
- retval = (*(sd->sc_link->adapter->scsipi_cmd)) (xs);
+ retval = (*sd->sc_link->adapter->scsipi_cmd)(xs);
if (retval != COMPLETE)
- return ENXIO;
+ return (ENXIO);
#else /* SD_DUMP_NOT_TRUSTED */
/* Let's just talk about this first... */
printf("sd%d: dump addr 0x%x, blk %d\n", unit, va, blkno);
@@ -1184,7 +1183,7 @@ sddump(dev, blkno, va, size)
va += sectorsize * nwrt;
}
sddoingadump = 0;
- return 0;
+ return (0);
}
#else /* __BDEVSW_DUMP_NEW_TYPE */
int
@@ -1196,6 +1195,6 @@ sddump(dev, blkno, va, size)
{
/* Not implemented. */
- return ENXIO;
+ return (ENXIO);
}
#endif /* __BDEVSW_DUMP_NEW_TYPE */
diff --git a/sys/dev/scsipi/ss.c b/sys/dev/scsipi/ss.c
index 4deb38d8c67..423cd2ebf11 100644
--- a/sys/dev/scsipi/ss.c
+++ b/sys/dev/scsipi/ss.c
@@ -1,4 +1,4 @@
-/* $NetBSD: ss.c,v 1.16 1997/08/27 11:27:04 bouyer Exp $ */
+/* $NetBSD: ss.c,v 1.17 1997/10/01 01:19:18 enami Exp $ */
/*
* Copyright (c) 1995 Kenneth Stailey. All rights reserved.
@@ -117,7 +117,7 @@ ssmatch(parent, match, aux)
int priority;
(void)scsipi_inqmatch(&sa->sa_inqbuf,
- (caddr_t)ss_patterns, sizeof(ss_patterns)/sizeof(ss_patterns[0]),
+ (caddr_t)ss_patterns, sizeof(ss_patterns) / sizeof(ss_patterns[0]),
sizeof(ss_patterns[0]), &priority);
return (priority);
}
diff --git a/sys/dev/scsipi/ss_mustek.c b/sys/dev/scsipi/ss_mustek.c
index 4b4bf4563e1..78870b31255 100644
--- a/sys/dev/scsipi/ss_mustek.c
+++ b/sys/dev/scsipi/ss_mustek.c
@@ -1,4 +1,4 @@
-/* $NetBSD: ss_mustek.c,v 1.7 1997/08/27 11:27:06 bouyer Exp $ */
+/* $NetBSD: ss_mustek.c,v 1.8 1997/10/01 01:19:20 enami Exp $ */
/*
* Copyright (c) 1995 Joachim Koenig-Baltes. All rights reserved.
@@ -326,7 +326,8 @@ mustek_trigger_scanner(ss)
/* send the set window command to the scanner */
SC_DEBUG(sc_link, SDEV_DB1, ("mustek_set_parms: set_window\n"));
- error = sc_link->scsipi_cmd(sc_link, (struct scsipi_generic *) &window_cmd,
+ error = (*sc_link->scsipi_cmd)(sc_link,
+ (struct scsipi_generic *) &window_cmd,
sizeof(window_cmd), (u_char *) &window_data, sizeof(window_data),
MUSTEK_RETRIES, 5000, NULL, SCSI_DATA_OUT);
if (error)
@@ -365,7 +366,8 @@ mustek_trigger_scanner(ss)
SC_DEBUG(sc_link, SDEV_DB1, ("mustek_trigger_scanner: mode_select\n"));
/* send the command to the scanner */
- error = sc_link->scsipi_cmd(sc_link, (struct scsipi_generic *) &mode_cmd,
+ error = (*sc_link->scsipi_cmd)(sc_link,
+ (struct scsipi_generic *) &mode_cmd,
sizeof(mode_cmd), (u_char *) &mode_data, sizeof(mode_data),
MUSTEK_RETRIES, 5000, NULL, SCSI_DATA_OUT);
if (error)
@@ -402,7 +404,8 @@ mustek_trigger_scanner(ss)
/* send the command to the scanner */
SC_DEBUG(sc_link, SDEV_DB1, ("mustek_trigger_scanner: start_scan\n"));
- error = sc_link->scsipi_cmd(sc_link, (struct scsipi_generic *) &start_scan_cmd,
+ error = (*sc_link->scsipi_cmd)(sc_link,
+ (struct scsipi_generic *) &start_scan_cmd,
sizeof(start_scan_cmd), NULL, 0,
MUSTEK_RETRIES, 5000, NULL, 0);
if (error)
@@ -445,7 +448,8 @@ mustek_rewind_scanner(ss)
/* send the command to the scanner */
SC_DEBUG(sc_link, SDEV_DB1,
("mustek_rewind_scanner: stop_scan\n"));
- error = sc_link->scsipi_cmd(sc_link, (struct scsipi_generic *) &cmd,
+ error = (*sc_link->scsipi_cmd)(sc_link,
+ (struct scsipi_generic *) &cmd,
sizeof(cmd), NULL, 0, MUSTEK_RETRIES, 5000, NULL, 0);
if (error)
return (error);
@@ -483,7 +487,8 @@ mustek_read(ss, bp)
/*
* go ask the adapter to do all this for us
*/
- if (sc_link->scsipi_cmd(sc_link, (struct scsipi_generic *) &cmd, sizeof(cmd),
+ if ((*sc_link->scsipi_cmd)(sc_link,
+ (struct scsipi_generic *) &cmd, sizeof(cmd),
(u_char *) bp->b_data, bp->b_bcount, MUSTEK_RETRIES, 10000, bp,
SCSI_NOSLEEP | SCSI_DATA_IN) != SUCCESSFULLY_QUEUED)
printf("%s: not queued\n", ss->sc_dev.dv_xname);
@@ -518,8 +523,9 @@ mustek_get_status(ss, timeout, update)
while (1) {
SC_DEBUG(sc_link, SDEV_DB1, ("mustek_get_status: stat_cmd\n"));
- error = sc_link->scsipi_cmd(sc_link, (struct scsipi_generic *) &cmd,
- sizeof(cmd), (u_char *) &data, sizeof(data), MUSTEK_RETRIES,
+ error = (*sc_link->scsipi_cmd)(sc_link,
+ (struct scsipi_generic *) &cmd, sizeof(cmd),
+ (u_char *) &data, sizeof(data), MUSTEK_RETRIES,
5000, NULL, SCSI_DATA_IN);
if (error)
return (error);
@@ -597,6 +603,6 @@ mustek_compute_sizes(ss)
ss->sio.scan_lines =
(ss->sio.scan_height * ss->sio.scan_y_resolution) / 1200;
- ss->sio.scan_window_size = ss->sio.scan_lines *
+ ss->sio.scan_window_size = ss->sio.scan_lines *
((ss->sio.scan_pixels_per_line * ss->sio.scan_bits_per_pixel) / 8);
}
diff --git a/sys/dev/scsipi/ss_scanjet.c b/sys/dev/scsipi/ss_scanjet.c
index d4ccaee7a96..450b4695347 100644
--- a/sys/dev/scsipi/ss_scanjet.c
+++ b/sys/dev/scsipi/ss_scanjet.c
@@ -1,4 +1,4 @@
-/* $NetBSD: ss_scanjet.c,v 1.12 1997/08/27 11:27:10 bouyer Exp $ */
+/* $NetBSD: ss_scanjet.c,v 1.13 1997/10/01 01:19:22 enami Exp $ */
/*
* Copyright (c) 1995 Kenneth Stailey. All rights reserved.
@@ -280,7 +280,8 @@ scanjet_read(ss, bp)
/*
* go ask the adapter to do all this for us
*/
- if (sc_link->scsipi_cmd(sc_link, (struct scsipi_generic *) &cmd, sizeof(cmd),
+ if ((*sc_link->scsipi_cmd)(sc_link,
+ (struct scsipi_generic *) &cmd, sizeof(cmd),
(u_char *) bp->b_data, bp->b_bcount, SCANJET_RETRIES, 100000, bp,
SCSI_NOSLEEP | SCSI_DATA_IN) != SUCCESSFULLY_QUEUED)
printf("%s: not queued\n", ss->sc_dev.dv_xname);
@@ -309,7 +310,8 @@ scanjet_ctl_write(ss, buf, size, flags)
bzero(&cmd, sizeof(cmd));
cmd.opcode = WRITE;
_lto3b(size, cmd.len);
- return (ss->sc_link->scsipi_cmd(ss->sc_link, (struct scsipi_generic *) &cmd,
+ return ((*ss->sc_link->scsipi_cmd)(ss->sc_link,
+ (struct scsipi_generic *) &cmd,
sizeof(cmd), (u_char *) buf, size, 0, 100000, NULL,
flags | SCSI_DATA_OUT));
}
@@ -330,7 +332,8 @@ scanjet_ctl_read(ss, buf, size, flags)
bzero(&cmd, sizeof(cmd));
cmd.opcode = READ;
_lto3b(size, cmd.len);
- return (ss->sc_link->scsipi_cmd(ss->sc_link, (struct scsipi_generic *) &cmd,
+ return ((*ss->sc_link->scsipi_cmd)(ss->sc_link,
+ (struct scsipi_generic *) &cmd,
sizeof(cmd), (u_char *) buf, size, 0, 100000, NULL,
flags | SCSI_DATA_IN));
}
@@ -339,15 +342,15 @@ scanjet_ctl_read(ss, buf, size, flags)
#ifdef SCANJETDEBUG
static void show_es(char *es)
{
- char *p = es;
- while (*p) {
- if (*p == '\033')
- printf("[Esc]");
- else
- printf("%c", *p);
- ++p;
- }
- printf("\n");
+ char *p = es;
+ while (*p) {
+ if (*p == '\033')
+ printf("[Esc]");
+ else
+ printf("%c", *p);
+ ++p;
+ }
+ printf("\n");
}
#endif
diff --git a/sys/dev/scsipi/st.c b/sys/dev/scsipi/st.c
index 9b1ca68ee95..99c02162fb1 100644
--- a/sys/dev/scsipi/st.c
+++ b/sys/dev/scsipi/st.c
@@ -1,4 +1,4 @@
-/* $NetBSD: st.c,v 1.75 1997/09/29 19:33:03 mjacob Exp $ */
+/* $NetBSD: st.c,v 1.76 1997/10/01 01:19:24 enami Exp $ */
/*
* Copyright (c) 1994 Charles Hannum. All rights reserved.
@@ -82,7 +82,7 @@
#define STMODE(z) ( minor(z) & 0x03)
#define STDSTY(z) ((minor(z) >> 2) & 0x03)
#define STUNIT(z) ((minor(z) >> 4) )
-#define CTLMODE 3
+#define CTLMODE 3
/*
* Maximum density code known.
@@ -232,24 +232,24 @@ struct st_quirk_inquiry_pattern st_quirk_patterns[] = {
struct st_softc {
struct device sc_dev;
-/*--------------------present operating parameters, flags etc.----------------*/
- int flags; /* see below */
- u_int quirks; /* quirks for the open mode */
- int blksize; /* blksize we are using */
- u_int8_t density; /* present density */
- u_int page_0_size; /* size of page 0 data */
+/*--------------------present operating parameters, flags etc.---------------*/
+ int flags; /* see below */
+ u_int quirks; /* quirks for the open mode */
+ int blksize; /* blksize we are using */
+ u_int8_t density; /* present density */
+ u_int page_0_size; /* size of page 0 data */
u_int last_dsty; /* last density opened */
-/*--------------------device/scsi parameters----------------------------------*/
- struct scsipi_link *sc_link; /* our link to the adpter etc. */
-/*--------------------parameters reported by the device ----------------------*/
+/*--------------------device/scsi parameters---------------------------------*/
+ struct scsipi_link *sc_link; /* our link to the adpter etc. */
+/*--------------------parameters reported by the device ---------------------*/
int blkmin; /* min blk size */
int blkmax; /* max blk size */
- struct quirkdata *quirkdata; /* if we have a rogue entry */
-/*--------------------parameters reported by the device for this media--------*/
+ struct quirkdata *quirkdata; /* if we have a rogue entry */
+/*--------------------parameters reported by the device for this media-------*/
u_long numblks; /* nominal blocks capacity */
int media_blksize; /* 0 if not ST_FIXEDBLOCKS */
u_int8_t media_density; /* this is what it said when asked */
-/*--------------------quirks for the whole drive------------------------------*/
+/*--------------------quirks for the whole drive-----------------------------*/
u_int drive_quirks; /* quirks of this drive */
/*--------------------How we should set up when opening each minor device----*/
struct modes modes[4]; /* plus more for each mode */
@@ -258,12 +258,13 @@ struct st_softc {
#define DENSITY_SET_BY_QUIRK 0x02
#define BLKSIZE_SET_BY_USER 0x04
#define BLKSIZE_SET_BY_QUIRK 0x08
-/*--------------------storage for sense data returned by the drive------------*/
+/*--------------------storage for sense data returned by the drive-----------*/
u_char sense_data[MAX_PAGE_0_SIZE]; /*
* additional sense data needed
* for mode sense/select.
*/
- struct buf buf_queue; /* the queue of pending IO operations */
+ struct buf buf_queue; /* the queue of pending IO */
+ /* operations */
};
@@ -274,7 +275,7 @@ int stmatch __P((struct device *, struct cfdata *, void *));
#endif
void stattach __P((struct device *, struct device *, void *));
void st_identify_drive __P((struct st_softc *,
- struct scsipi_inquiry_pattern *));
+ struct scsipi_inquiry_pattern *));
void st_loadquirks __P((struct st_softc *));
int st_mount_tape __P((dev_t, int));
void st_unmount __P((struct st_softc *, boolean));
@@ -317,7 +318,7 @@ struct scsipi_device st_switch = {
#define ST_FIXEDBLOCKS 0x0008
#define ST_AT_FILEMARK 0x0010
#define ST_EIO_PENDING 0x0020 /* we couldn't report it then (had data) */
-#define ST_NEW_MOUNT 0x0040 /* still need to decide mode */
+#define ST_NEW_MOUNT 0x0040 /* still need to decide mode */
#define ST_READONLY 0x0080 /* st_mode_sense says write protected */
#define ST_FM_WRITTEN 0x0100 /*
* EOF file mark written -- used with
@@ -330,8 +331,8 @@ struct scsipi_device st_switch = {
#define ST_DONTBUFFER 0x1000 /* Disable buffering/caching */
#define ST_PER_ACTION (ST_AT_FILEMARK | ST_EIO_PENDING | ST_BLANK_READ)
-#define ST_PER_MOUNT (ST_INFO_VALID | ST_BLOCK_SET | ST_WRITTEN | \
- ST_FIXEDBLOCKS | ST_READONLY | ST_FM_WRITTEN | \
+#define ST_PER_MOUNT (ST_INFO_VALID | ST_BLOCK_SET | ST_WRITTEN | \
+ ST_FIXEDBLOCKS | ST_READONLY | ST_FM_WRITTEN | \
ST_2FM_AT_EOD | ST_PER_ACTION)
struct scsipi_inquiry_pattern st_patterns[] = {
@@ -431,7 +432,7 @@ st_identify_drive(st, inqbuf)
finger = (struct st_quirk_inquiry_pattern *)scsipi_inqmatch(inqbuf,
(caddr_t)st_quirk_patterns,
- sizeof(st_quirk_patterns)/sizeof(st_quirk_patterns[0]),
+ sizeof(st_quirk_patterns) / sizeof(st_quirk_patterns[0]),
sizeof(st_quirk_patterns[0]), &priority);
if (priority != 0) {
st->quirkdata = &finger->quirkdata;
@@ -478,7 +479,7 @@ st_loadquirks(st)
/*
* open the device.
*/
-int
+int
stopen(dev, flags, mode, p)
dev_t dev;
int flags;
@@ -493,10 +494,10 @@ stopen(dev, flags, mode, p)
unit = STUNIT(dev);
if (unit >= st_cd.cd_ndevs)
- return ENXIO;
+ return (ENXIO);
st = st_cd.cd_devs[unit];
- if (!st)
- return ENXIO;
+ if (st == NULL)
+ return (ENXIO);
stmode = STMODE(dev);
dsty = STDSTY(dev);
@@ -510,16 +511,14 @@ stopen(dev, flags, mode, p)
*/
if (sc_link->flags & SDEV_OPEN) {
printf("%s: already open\n", st->sc_dev.dv_xname);
- return EBUSY;
+ return (EBUSY);
}
/*
* Catch any unit attention errors.
*/
- error = scsipi_test_unit_ready(sc_link,
- SCSI_IGNORE_MEDIA_CHANGE |
- (stmode == CTLMODE ?
- SCSI_IGNORE_NOT_READY : 0));
+ error = scsipi_test_unit_ready(sc_link, SCSI_IGNORE_MEDIA_CHANGE |
+ (stmode == CTLMODE ? SCSI_IGNORE_NOT_READY : 0));
if (error)
goto bad;
@@ -531,7 +530,7 @@ stopen(dev, flags, mode, p)
* This mode does NOT ALLOW I/O, only ioctls
*/
if (stmode == CTLMODE)
- return 0;
+ return (0);
/*
* if it's a different mode, or if the media has been
@@ -559,19 +558,19 @@ stopen(dev, flags, mode, p)
st->flags |= ST_WRITTEN;
SC_DEBUG(sc_link, SDEV_DB2, ("open complete\n"));
- return 0;
+ return (0);
bad:
st_unmount(st, NOEJECT);
sc_link->flags &= ~SDEV_OPEN;
- return error;
+ return (error);
}
/*
* close the device.. only called if we are the LAST
* occurence of an open device
*/
-int
+int
stclose(dev, flags, mode, p)
dev_t dev;
int flags;
@@ -599,7 +598,7 @@ stclose(dev, flags, mode, p)
}
st->sc_link->flags &= ~SDEV_OPEN;
- return 0;
+ return (0);
}
/*
@@ -625,7 +624,7 @@ st_mount_tape(dev, flags)
sc_link = st->sc_link;
if (st->flags & ST_MOUNTED)
- return 0;
+ return (0);
SC_DEBUG(sc_link, SDEV_DB1, ("mounting\n "));
st->flags |= ST_NEW_MOUNT;
@@ -635,7 +634,7 @@ st_mount_tape(dev, flags)
* to do a 'load' instruction. (We assume it is new.)
*/
if ((error = st_load(st, LD_LOAD, 0)) != 0)
- return error;
+ return (error);
/*
* Throw another dummy instruction to catch
* 'Unit attention' errors. Some drives appear to give
@@ -650,13 +649,13 @@ st_mount_tape(dev, flags)
*/
if (st->quirks & ST_Q_SENSE_HELP)
if ((error = st_touch_tape(st)) != 0)
- return error;
+ return (error);
/*
* Load the physical device parameters
* loads: blkmin, blkmax
*/
if ((error = st_read_block_limits(st, 0)) != 0)
- return error;
+ return (error);
/*
* Load the media dependent parameters
* includes: media_blksize,media_density,numblks
@@ -664,7 +663,7 @@ st_mount_tape(dev, flags)
* If not you may need the "quirk" above.
*/
if ((error = st_mode_sense(st, 0)) != 0)
- return error;
+ return (error);
/*
* If we have gained a permanent density from somewhere,
* then use it in preference to the one supplied by
@@ -680,17 +679,18 @@ st_mount_tape(dev, flags)
* default by the driver.
*/
st->flags &= ~ST_FIXEDBLOCKS;
- if (st->modeflags[dsty] & (BLKSIZE_SET_BY_QUIRK | BLKSIZE_SET_BY_USER)) {
+ if (st->modeflags[dsty] &
+ (BLKSIZE_SET_BY_QUIRK | BLKSIZE_SET_BY_USER)) {
st->blksize = st->modes[dsty].blksize;
if (st->blksize)
st->flags |= ST_FIXEDBLOCKS;
} else {
if ((error = st_decide_mode(st, FALSE)) != 0)
- return error;
+ return (error);
}
if ((error = st_mode_select(st, 0)) != 0) {
printf("%s: cannot set selected mode\n", st->sc_dev.dv_xname);
- return error;
+ return (error);
}
scsipi_prevent(sc_link, PR_PREVENT,
SCSI_IGNORE_ILLEGAL_REQUEST | SCSI_IGNORE_NOT_READY);
@@ -698,7 +698,7 @@ st_mount_tape(dev, flags)
st->flags |= ST_MOUNTED;
sc_link->flags |= SDEV_MEDIA_LOADED; /* move earlier? */
- return 0;
+ return (0);
}
/*
@@ -831,7 +831,7 @@ done:
default:
st->flags |= ST_2FM_AT_EOD;
}
- return 0;
+ return (0);
}
/*
@@ -870,7 +870,7 @@ ststrategy(bp)
* as are out-of-range requests on variable drives.
*/
else if (bp->b_bcount < st->blkmin ||
- (st->blkmax && bp->b_bcount > st->blkmax)) {
+ (st->blkmax && bp->b_bcount > st->blkmax)) {
printf("%s: bad request, must be between %d and %d\n",
st->sc_dev.dv_xname, st->blkmin, st->blkmax);
bp->b_error = EIO;
@@ -923,7 +923,7 @@ done:
* continues to be drained.
* ststart() is called at splbio
*/
-void
+void
ststart(v)
void *v;
{
@@ -1041,9 +1041,10 @@ ststart(v)
/*
* go ask the adapter to do all this for us
*/
- if (sc_link->scsipi_cmd(sc_link, (struct scsipi_generic *) &cmd,
- sizeof(cmd), (u_char *) bp->b_data, bp->b_bcount, 0,
- 100000, bp, flags | SCSI_NOSLEEP))
+ if ((*sc_link->scsipi_cmd)(sc_link,
+ (struct scsipi_generic *)&cmd, sizeof(cmd),
+ (u_char *)bp->b_data, bp->b_bcount,
+ 0, 100000, bp, flags | SCSI_NOSLEEP))
printf("%s: not queued\n", st->sc_dev.dv_xname);
} /* go back and see if we can cram more work in.. */
}
@@ -1057,7 +1058,7 @@ stread(dev, uio, iomode)
struct st_softc *st = st_cd.cd_devs[STUNIT(dev)];
return (physio(ststrategy, NULL, dev, B_READ,
- st->sc_link->adapter->scsipi_minphys, uio));
+ st->sc_link->adapter->scsipi_minphys, uio));
}
int
@@ -1069,7 +1070,7 @@ stwrite(dev, uio, iomode)
struct st_softc *st = st_cd.cd_devs[STUNIT(dev)];
return (physio(ststrategy, NULL, dev, B_WRITE,
- st->sc_link->adapter->scsipi_minphys, uio));
+ st->sc_link->adapter->scsipi_minphys, uio));
}
/*
@@ -1126,7 +1127,8 @@ stioctl(dev, cmd, arg, flag, p)
case MTIOCTOP: {
SC_DEBUG(st->sc_link, SDEV_DB1,
- ("[ioctl: op=0x%x count=0x%x]\n", mt->mt_op, mt->mt_count));
+ ("[ioctl: op=0x%x count=0x%x]\n", mt->mt_op,
+ mt->mt_count));
/* compat: in U*x it is a short */
number = mt->mt_count;
@@ -1184,9 +1186,9 @@ stioctl(dev, cmd, arg, flag, p)
break;
}
#endif
- if (number == 0) {
+ if (number == 0)
st->flags &= ~ST_FIXEDBLOCKS;
- } else {
+ else {
if ((st->blkmin || st->blkmax) &&
(number < st->blkmin ||
number > st->blkmax)) {
@@ -1238,12 +1240,13 @@ stioctl(dev, cmd, arg, flag, p)
default:
if (STMODE(dev) == CTLMODE)
- error = scsipi_do_ioctl(st->sc_link, dev, cmd, arg, flag, p);
+ error = scsipi_do_ioctl(st->sc_link, dev, cmd, arg,
+ flag, p);
else
error = ENOTTY;
break;
}
- return error;
+ return (error);
/*-----------------------------*/
try_new_value:
/*
@@ -1258,7 +1261,7 @@ try_new_value:
st->flags |= ST_FIXEDBLOCKS;
else
st->flags &= ~ST_FIXEDBLOCKS;
- return error;
+ return (error);
}
/*
* As the drive liked it, if we are setting a new default,
@@ -1280,7 +1283,7 @@ try_new_value:
break;
}
}
- return 0;
+ return (0);
}
/*
@@ -1299,7 +1302,7 @@ st_read(st, buf, size, flags)
* If it's a null transfer, return immediatly
*/
if (size == 0)
- return 0;
+ return (0);
bzero(&cmd, sizeof(cmd));
cmd.opcode = READ;
if (st->flags & ST_FIXEDBLOCKS) {
@@ -1308,9 +1311,9 @@ st_read(st, buf, size, flags)
cmd.len);
} else
_lto3b(size, cmd.len);
- return st->sc_link->scsipi_cmd(st->sc_link, (struct scsipi_generic *) &cmd,
- sizeof(cmd), (u_char *) buf, size, 0, 100000, NULL,
- flags | SCSI_DATA_IN);
+ return ((*st->sc_link->scsipi_cmd)(st->sc_link,
+ (struct scsipi_generic *)&cmd, sizeof(cmd),
+ (u_char *)buf, size, 0, 100000, NULL, flags | SCSI_DATA_IN));
}
/*
@@ -1330,7 +1333,7 @@ st_read_block_limits(st, flags)
* First check if we have it all loaded
*/
if ((sc_link->flags & SDEV_MEDIA_LOADED))
- return 0;
+ return (0);
/*
* do a 'Read Block Limits'
@@ -1341,19 +1344,18 @@ st_read_block_limits(st, flags)
/*
* do the command, update the global values
*/
- error = sc_link->scsipi_cmd(sc_link, (struct scsipi_generic *) &cmd,
- sizeof(cmd), (u_char *) &block_limits,
- sizeof(block_limits), ST_RETRIES, 5000,
- NULL, flags | SCSI_DATA_IN);
+ error = (*sc_link->scsipi_cmd)(sc_link, (struct scsipi_generic *)&cmd,
+ sizeof(cmd), (u_char *)&block_limits, sizeof(block_limits),
+ ST_RETRIES, 5000, NULL, flags | SCSI_DATA_IN);
if (error)
- return error;
+ return (error);
st->blkmin = _2btol(block_limits.min_length);
st->blkmax = _3btol(block_limits.max_length);
SC_DEBUG(sc_link, SDEV_DB3,
("(%d <= blksize <= %d)\n", st->blkmin, st->blkmax));
- return 0;
+ return (0);
}
/*
@@ -1396,12 +1398,11 @@ st_mode_sense(st, flags)
* or if we need it as a template for the mode select
* store it away.
*/
- error = sc_link->scsipi_cmd(sc_link, (struct scsipi_generic *) &cmd,
- sizeof(cmd), (u_char *) &scsipi_sense,
- scsipi_sense_len, ST_RETRIES, 5000, NULL,
- flags | SCSI_DATA_IN);
+ error = (*sc_link->scsipi_cmd)(sc_link, (struct scsipi_generic *)&cmd,
+ sizeof(cmd), (u_char *)&scsipi_sense, scsipi_sense_len,
+ ST_RETRIES, 5000, NULL, flags | SCSI_DATA_IN);
if (error)
- return error;
+ return (error);
st->numblks = _3btol(scsipi_sense.blk_desc.nblocks);
st->media_blksize = _3btol(scsipi_sense.blk_desc.blklen);
@@ -1416,9 +1417,10 @@ st_mode_sense(st, flags)
("%sbuffered\n",
scsipi_sense.header.dev_spec & SMH_DSP_BUFF_MODE ? "" : "un"));
if (st->page_0_size)
- bcopy(scsipi_sense.sense_data, st->sense_data, st->page_0_size);
+ bcopy(scsipi_sense.sense_data, st->sense_data,
+ st->page_0_size);
sc_link->flags |= SDEV_MEDIA_LOADED;
- return 0;
+ return (0);
}
/*
@@ -1450,7 +1452,7 @@ st_mode_select(st, flags)
SC_DEBUG(sc_link, SDEV_DB3,
("not setting density 0x%x blksize 0x%x\n",
st->density, st->blksize));
- return 0;
+ return (0);
}
/*
@@ -1476,9 +1478,9 @@ st_mode_select(st, flags)
/*
* do the command
*/
- return sc_link->scsipi_cmd(sc_link, (struct scsipi_generic *) &cmd,
- sizeof(cmd), (u_char *) &scsi_select, scsi_select_len,
- ST_RETRIES, 5000, NULL, flags | SCSI_DATA_OUT);
+ return ((*sc_link->scsipi_cmd)(sc_link, (struct scsipi_generic *)&cmd,
+ sizeof(cmd), (u_char *)&scsi_select, scsi_select_len,
+ ST_RETRIES, 5000, NULL, flags | SCSI_DATA_OUT));
}
int
@@ -1492,22 +1494,22 @@ st_cmprss(st, onoff)
struct scsi_select {
struct scsi_mode_header header;
struct scsi_blk_desc blk_desc;
- u_char pdata[max(sizeof (struct scsi_tape_dev_conf_page),
- sizeof (struct scsi_tape_dev_compression_page))];
+ u_char pdata[max(sizeof(struct scsi_tape_dev_conf_page),
+ sizeof(struct scsi_tape_dev_compression_page))];
} scsi_pdata;
struct scsi_tape_dev_conf_page *ptr;
struct scsi_tape_dev_compression_page *cptr;
struct scsipi_link *sc_link = st->sc_link;
int error, ison, flags;
- scsi_dlen = sizeof (scsi_pdata);
+ scsi_dlen = sizeof(scsi_pdata);
bzero(&scsi_pdata, scsi_dlen);
/*
* Set up for a mode sense.
* Do DATA COMPRESSION page first.
*/
- bzero(&scmd, sizeof (scmd));
+ bzero(&scmd, sizeof(scmd));
scmd.opcode = SCSI_MODE_SENSE;
scmd.page = SMS_PAGE_CTRL_CURRENT | 0xf;
scmd.length = scsi_dlen;
@@ -1518,23 +1520,23 @@ st_cmprss(st, onoff)
* Do the MODE SENSE command...
*/
again:
- error = sc_link->scsipi_cmd(sc_link, (struct scsipi_generic *) &scmd,
- sizeof(scmd), (u_char *) &scsi_pdata, scsi_dlen,
- ST_RETRIES, 5000, NULL, flags | SCSI_DATA_IN);
+ error = (*sc_link->scsipi_cmd)(sc_link,
+ (struct scsipi_generic *)&scmd, sizeof(scmd),
+ (u_char *)&scsi_pdata, scsi_dlen,
+ ST_RETRIES, 5000, NULL, flags | SCSI_DATA_IN);
if (error) {
if (scmd.byte2 != SMS_DBD) {
scmd.byte2 = SMS_DBD;
goto again;
}
- return error;
+ return (error);
}
- if (scsi_pdata.header.blk_desc_len) {
+ if (scsi_pdata.header.blk_desc_len)
ptr = (struct scsi_tape_dev_conf_page *) scsi_pdata.pdata;
- } else {
+ else
ptr = (struct scsi_tape_dev_conf_page *) &scsi_pdata.blk_desc;
- }
if ((scmd.page & SMS_PAGE_CODE) == 0xf) {
cptr = (struct scsi_tape_dev_compression_page *) ptr;
@@ -1552,7 +1554,7 @@ again:
ptr->sel_comp_alg = 0;
ptr->pagecode &= ~0x80;
}
- onoff = (onoff)? 1 : 0;
+ onoff = onoff ? 1 : 0;
/*
* There might be a virtue in actually doing the MODE SELECTS,
* but let's not clog the bus over it.
@@ -1583,10 +1585,11 @@ again:
}
/*
- * do the command
+ * Do the command
*/
- error = sc_link->scsipi_cmd(sc_link, (struct scsipi_generic *) &mcmd,
- sizeof(mcmd), (u_char *) &scsi_pdata, scsi_dlen,
+ error = (*sc_link->scsipi_cmd)(sc_link,
+ (struct scsipi_generic *)&mcmd, sizeof(mcmd),
+ (u_char *)&scsi_pdata, scsi_dlen,
ST_RETRIES, 5000, NULL, flags | SCSI_DATA_OUT);
if (error && (scmd.page & SMS_PAGE_CODE) == 0xf) {
@@ -1624,8 +1627,9 @@ st_erase(st, full, flags)
* XXX We always do this asynchronously, for now. How long should
* we wait if we want to (eventually) to it synchronously?
*/
- return (st->sc_link->scsipi_cmd(st->sc_link, (struct scsipi_generic *)&cmd,
- sizeof(cmd), 0, 0, ST_RETRIES, 5000, NULL, flags));
+ return ((*st->sc_link->scsipi_cmd)(st->sc_link,
+ (struct scsipi_generic *)&cmd, sizeof(cmd),
+ 0, 0, ST_RETRIES, 5000, NULL, flags));
}
/*
@@ -1646,7 +1650,7 @@ st_space(st, number, what, flags)
if (st->flags & ST_PER_ACTION) {
if (number > 0) {
st->flags &= ~ST_PER_ACTION;
- return EIO;
+ return (EIO);
} else if (number < 0) {
if (st->flags & ST_AT_FILEMARK) {
/*
@@ -1655,13 +1659,13 @@ st_space(st, number, what, flags)
* right file mark count.
*/
error = st_space(st, 0, SP_FILEMARKS,
- flags);
+ flags);
if (error)
- return error;
+ return (error);
}
if (st->flags & ST_BLANK_READ) {
st->flags &= ~ST_BLANK_READ;
- return EIO;
+ return (EIO);
}
st->flags &= ~ST_EIO_PENDING;
}
@@ -1672,7 +1676,7 @@ st_space(st, number, what, flags)
if (number > 0) {
/* pretend we just discovered the error */
st->flags &= ~ST_EIO_PENDING;
- return EIO;
+ return (EIO);
} else if (number < 0) {
/* back away from the error */
st->flags &= ~ST_EIO_PENDING;
@@ -1692,22 +1696,23 @@ st_space(st, number, what, flags)
if (st->flags & ST_EIO_PENDING) {
/* pretend we just discovered the error */
st->flags &= ~ST_EIO_PENDING;
- return EIO;
+ return (EIO);
}
if (st->flags & ST_AT_FILEMARK)
st->flags &= ~ST_AT_FILEMARK;
break;
}
if (number == 0)
- return 0;
+ return (0);
bzero(&cmd, sizeof(cmd));
cmd.opcode = SPACE;
cmd.byte2 = what;
_lto3b(number, cmd.number);
- return st->sc_link->scsipi_cmd(st->sc_link, (struct scsipi_generic *) &cmd,
- sizeof(cmd), 0, 0, 0, 900000, NULL, flags);
+ return ((*st->sc_link->scsipi_cmd)(st->sc_link,
+ (struct scsipi_generic *)&cmd, sizeof(cmd),
+ 0, 0, 0, 900000, NULL, flags));
}
/*
@@ -1726,7 +1731,7 @@ st_write_filemarks(st, number, flags)
* Don't try.
*/
if (number < 0)
- return EINVAL;
+ return (EINVAL);
switch (number) {
case 0: /* really a command to sync the drive's buffers */
break;
@@ -1745,8 +1750,9 @@ st_write_filemarks(st, number, flags)
cmd.opcode = WRITE_FILEMARKS;
_lto3b(number, cmd.number);
- return st->sc_link->scsipi_cmd(st->sc_link, (struct scsipi_generic *) &cmd,
- sizeof(cmd), 0, 0, 0, 100000, NULL, flags);
+ return ((*st->sc_link->scsipi_cmd)(st->sc_link,
+ (struct scsipi_generic *)&cmd, sizeof(cmd),
+ 0, 0, 0, 100000, NULL, flags));
}
/*
@@ -1769,7 +1775,7 @@ st_check_eod(st, position, nmarks, flags)
switch (st->flags & (ST_WRITTEN | ST_FM_WRITTEN | ST_2FM_AT_EOD)) {
default:
*nmarks = 0;
- return 0;
+ return (0);
case ST_WRITTEN:
case ST_WRITTEN | ST_FM_WRITTEN | ST_2FM_AT_EOD:
*nmarks = 1;
@@ -1780,7 +1786,7 @@ st_check_eod(st, position, nmarks, flags)
error = st_write_filemarks(st, *nmarks, flags);
if (position && !error)
error = st_space(st, -*nmarks, SP_FILEMARKS, flags);
- return error;
+ return (error);
}
/*
@@ -1800,17 +1806,18 @@ st_load(st, type, flags)
error = st_check_eod(st, FALSE, &nmarks, flags);
if (error)
- return error;
+ return (error);
}
if (st->quirks & ST_Q_IGNORE_LOADS)
- return 0;
+ return (0);
bzero(&cmd, sizeof(cmd));
cmd.opcode = LOAD;
cmd.how = type;
- return st->sc_link->scsipi_cmd(st->sc_link, (struct scsipi_generic *) &cmd,
- sizeof(cmd), 0, 0, ST_RETRIES, 300000, NULL, flags);
+ return ((*st->sc_link->scsipi_cmd)(st->sc_link,
+ (struct scsipi_generic *)&cmd, sizeof(cmd),
+ 0, 0, ST_RETRIES, 300000, NULL, flags));
}
/*
@@ -1828,16 +1835,16 @@ st_rewind(st, immediate, flags)
error = st_check_eod(st, FALSE, &nmarks, flags);
if (error)
- return error;
+ return (error);
st->flags &= ~ST_PER_ACTION;
bzero(&cmd, sizeof(cmd));
cmd.opcode = REWIND;
cmd.byte2 = immediate;
- return st->sc_link->scsipi_cmd(st->sc_link, (struct scsipi_generic *) &cmd,
- sizeof(cmd), 0, 0, ST_RETRIES, immediate ? 5000 : 300000, NULL,
- flags);
+ return ((*st->sc_link->scsipi_cmd)(st->sc_link,
+ (struct scsipi_generic *)&cmd, sizeof(cmd),
+ 0, 0, ST_RETRIES, immediate ? 5000 : 300000, NULL, flags));
}
int
@@ -1857,21 +1864,21 @@ st_rdpos(st, hard, blkptr)
if (error)
return (error);
- bzero(&cmd, sizeof (cmd));
- bzero(&posdata, sizeof (posdata));
+ bzero(&cmd, sizeof(cmd));
+ bzero(&posdata, sizeof(posdata));
cmd.opcode = READ_POSITION;
if (hard)
cmd.byte1 = 1;
error = st->sc_link->scsipi_cmd(st->sc_link,
- (struct scsipi_generic *) &cmd, sizeof (cmd), (u_char *) &posdata,
- sizeof (posdata), ST_RETRIES, 30000, NULL, SCSI_DATA_IN);
+ (struct scsipi_generic *)&cmd, sizeof(cmd), (u_char *)&posdata,
+ sizeof(posdata), ST_RETRIES, 30000, NULL, SCSI_DATA_IN);
if (error == 0) {
#if 0
printf("posdata:");
- for (hard = 0; hard < sizeof (posdata); hard++)
+ for (hard = 0; hard < sizeof(posdata); hard++)
printf("%02x ", posdata[hard] & 0xff);
printf("\n");
#endif
@@ -1900,13 +1907,13 @@ st_setpos(st, hard, blkptr)
if (error)
return (error);
- bzero(&cmd, sizeof (cmd));
+ bzero(&cmd, sizeof(cmd));
cmd.opcode = LOCATE;
if (hard)
cmd.bytes[0] = 1 << 2;
_lto4b(*blkptr, &cmd.bytes[2]);
- error = st->sc_link->scsipi_cmd(st->sc_link, &cmd, sizeof (cmd), NULL,
- 0, ST_RETRIES, 5000, NULL, 0);
+ error = (*st->sc_link->scsipi_cmd)(st->sc_link, &cmd, sizeof(cmd),
+ NULL, 0, ST_RETRIES, 5000, NULL, 0);
/*
* XXX: Note file && block number position now unknown (if
* XXX: these things ever start being maintained in this driver)
@@ -1939,7 +1946,7 @@ st_interpret_sense(xs)
else
info = xs->datalen; /* bad choice if fixed blocks */
if ((sense->error_code & SSD_ERRCODE) != 0x70)
- return -1; /* let the generic code handle it */
+ return (-1); /* let the generic code handle it */
#ifdef SCSIVERBOSE
else if ((xs->flags & SCSI_SILENT) == 0)
scsi_print_sense(xs, 0); /* tell folks what happened */
@@ -1981,21 +1988,21 @@ st_interpret_sense(xs)
*/
if (xs->resid >= xs->datalen) {
if (st->flags & ST_EIO_PENDING)
- return EIO;
+ return (EIO);
if (st->flags & ST_AT_FILEMARK) {
if (bp)
bp->b_resid = xs->resid;
- return 0;
+ return (0);
}
}
} else { /* must be variable mode */
xs->resid = xs->datalen; /* to be sure */
if (sense->flags & SSD_EOM)
- return EIO;
+ return (EIO);
if (sense->flags & SSD_FILEMARK) {
if (bp)
bp->b_resid = bp->b_bcount;
- return 0;
+ return (0);
}
if (sense->flags & SSD_ILI) {
if (info < 0) {
@@ -2006,7 +2013,7 @@ st_interpret_sense(xs)
printf("%s: %d-byte record too big\n",
st->sc_dev.dv_xname,
xs->datalen - info);
- return EIO;
+ return (EIO);
}
xs->resid = info;
if (bp)
@@ -2033,10 +2040,10 @@ st_interpret_sense(xs)
bp->b_resid = xs->resid;
/* return an EOF */
}
- return 0;
+ return (0);
}
}
- return -1; /* let the default/generic handler handle it */
+ return (-1); /* let the default/generic handler handle it */
}
/*
@@ -2064,8 +2071,8 @@ st_touch_tape(st)
int error;
buf = malloc(1024, M_TEMP, M_NOWAIT);
- if (!buf)
- return ENOMEM;
+ if (buf == NULL)
+ return (ENOMEM);
if ((error = st_mode_sense(st, 0)) != 0)
goto bad;
@@ -2086,12 +2093,12 @@ st_touch_tape(st)
st_read(st, buf, readsize, SCSI_SILENT); /* XXX */
if ((error = st_rewind(st, 0, 0)) != 0) {
bad: free(buf, M_TEMP);
- return error;
+ return (error);
}
} while (readsize != 1 && readsize > st->blksize);
free(buf, M_TEMP);
- return 0;
+ return (0);
}
int
@@ -2103,5 +2110,5 @@ stdump(dev, blkno, va, size)
{
/* Not implemented. */
- return ENXIO;
+ return (ENXIO);
}
diff --git a/sys/dev/scsipi/uk.c b/sys/dev/scsipi/uk.c
index aab0184f370..dcf624bce9c 100644
--- a/sys/dev/scsipi/uk.c
+++ b/sys/dev/scsipi/uk.c
@@ -1,4 +1,4 @@
-/* $NetBSD: uk.c,v 1.19 1997/08/27 11:27:18 bouyer Exp $ */
+/* $NetBSD: uk.c,v 1.20 1997/10/01 01:19:26 enami Exp $ */
/*
* Copyright (c) 1994 Charles Hannum. All rights reserved.
@@ -29,7 +29,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-/*
+/*
* Dummy driver for a device we can't identify.
* Originally by Julian Elischer (julian@tfs.com)
*/
@@ -93,7 +93,7 @@ ukmatch(parent, match, aux)
void *aux;
{
- return 1;
+ return (1);
}
/*
@@ -138,28 +138,29 @@ ukopen(dev, flag, fmt, p)
unit = UKUNIT(dev);
if (unit >= uk_cd.cd_ndevs)
- return ENXIO;
+ return (ENXIO);
uk = uk_cd.cd_devs[unit];
- if (!uk)
- return ENXIO;
-
+ if (uk == NULL)
+ return (ENXIO);
+
sc_link = uk->sc_link;
SC_DEBUG(sc_link, SDEV_DB1,
- ("ukopen: dev=0x%x (unit %d (of %d))\n", dev, unit, uk_cd.cd_ndevs));
+ ("ukopen: dev=0x%x (unit %d (of %d))\n", dev, unit,
+ uk_cd.cd_ndevs));
/*
* Only allow one at a time
*/
if (sc_link->flags & SDEV_OPEN) {
printf("%s: already open\n", uk->sc_dev.dv_xname);
- return EBUSY;
+ return (EBUSY);
}
sc_link->flags |= SDEV_OPEN;
SC_DEBUG(sc_link, SDEV_DB3, ("open complete\n"));
- return 0;
+ return (0);
}
/*
@@ -177,7 +178,7 @@ ukclose(dev, flag, fmt, p)
SC_DEBUG(uk->sc_link, SDEV_DB1, ("closing\n"));
uk->sc_link->flags &= ~SDEV_OPEN;
- return 0;
+ return (0);
}
/*
@@ -194,5 +195,5 @@ ukioctl(dev, cmd, addr, flag, p)
{
register struct uk_softc *uk = uk_cd.cd_devs[UKUNIT(dev)];
- return scsipi_do_ioctl(uk->sc_link, dev, cmd, addr, flag, p);
+ return (scsipi_do_ioctl(uk->sc_link, dev, cmd, addr, flag, p));
}