- Sprinkle const
- Avoid variable shadowing. - Eliminate some caddr_t abuse.
This commit is contained in:
parent
efc217b18f
commit
3acb3fe622
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: atapi_base.c,v 1.24 2005/02/21 00:29:07 thorpej Exp $ */
|
||||
/* $NetBSD: atapi_base.c,v 1.25 2005/05/29 22:00:50 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998, 1999, 2004 The NetBSD Foundation, Inc.
|
||||
|
@ -38,7 +38,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: atapi_base.c,v 1.24 2005/02/21 00:29:07 thorpej Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: atapi_base.c,v 1.25 2005/05/29 22:00:50 christos Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
@ -66,7 +66,7 @@ atapi_interpret_sense(struct scsipi_xfer *xs)
|
|||
{
|
||||
struct scsipi_periph *periph = xs->xs_periph;
|
||||
int key, error;
|
||||
char *msg = NULL;
|
||||
const char *msg = NULL;
|
||||
|
||||
/*
|
||||
* If the device has it's own error handler, call it first.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: atapi_wdc.c,v 1.92 2005/02/27 00:27:48 perry Exp $ */
|
||||
/* $NetBSD: atapi_wdc.c,v 1.93 2005/05/29 22:00:50 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1998, 2001 Manuel Bouyer.
|
||||
|
@ -30,7 +30,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: atapi_wdc.c,v 1.92 2005/02/27 00:27:48 perry Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: atapi_wdc.c,v 1.93 2005/05/29 22:00:50 christos Exp $");
|
||||
|
||||
#ifndef ATADEBUG
|
||||
#define ATADEBUG
|
||||
|
@ -424,7 +424,7 @@ wdc_atapi_start(struct ata_channel *chp, struct ata_xfer *xfer)
|
|||
struct scsipi_xfer *sc_xfer = xfer->c_cmd;
|
||||
struct ata_drive_datas *drvp = &chp->ch_drive[xfer->c_drive];
|
||||
int wait_flags = (sc_xfer->xs_control & XS_CTL_POLL) ? AT_POLL : 0;
|
||||
char *errstring;
|
||||
const char *errstring;
|
||||
|
||||
ATADEBUG_PRINT(("wdc_atapi_start %s:%d:%d, scsi flags 0x%x \n",
|
||||
atac->atac_dev.dv_xname, chp->ch_channel, drvp->drive,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: atapiconf.c,v 1.66 2004/09/13 12:55:48 drochner Exp $ */
|
||||
/* $NetBSD: atapiconf.c,v 1.67 2005/05/29 22:00:50 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996, 2001 Manuel Bouyer. All rights reserved.
|
||||
|
@ -30,7 +30,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: atapiconf.c,v 1.66 2004/09/13 12:55:48 drochner Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: atapiconf.c,v 1.67 2005/05/29 22:00:50 christos Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
@ -255,12 +255,12 @@ atapi_probe_device(struct atapibus_softc *sc, int target,
|
|||
struct scsipi_periph *periph, struct scsipibus_attach_args *sa)
|
||||
{
|
||||
struct scsipi_channel *chan = sc->sc_channel;
|
||||
struct scsi_quirk_inquiry_pattern *finger;
|
||||
const struct scsi_quirk_inquiry_pattern *finger;
|
||||
struct cfdata *cf;
|
||||
int priority, quirks;
|
||||
|
||||
finger = (struct scsi_quirk_inquiry_pattern *)scsipi_inqmatch(
|
||||
&sa->sa_inqbuf, (caddr_t)atapi_quirk_patterns,
|
||||
finger = scsipi_inqmatch(
|
||||
&sa->sa_inqbuf, (const void *)atapi_quirk_patterns,
|
||||
sizeof(atapi_quirk_patterns) /
|
||||
sizeof(atapi_quirk_patterns[0]),
|
||||
sizeof(atapi_quirk_patterns[0]), &priority);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: cd.c,v 1.222 2005/04/25 17:52:30 drochner Exp $ */
|
||||
/* $NetBSD: cd.c,v 1.223 2005/05/29 22:00:50 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998, 2001, 2003, 2004 The NetBSD Foundation, Inc.
|
||||
|
@ -54,7 +54,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: cd.c,v 1.222 2005/04/25 17:52:30 drochner Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: cd.c,v 1.223 2005/05/29 22:00:50 christos Exp $");
|
||||
|
||||
#include "rnd.h"
|
||||
|
||||
|
@ -210,7 +210,7 @@ cdmatch(struct device *parent, struct cfdata *match, void *aux)
|
|||
int priority;
|
||||
|
||||
(void)scsipi_inqmatch(&sa->sa_inqbuf,
|
||||
(caddr_t)cd_patterns, sizeof(cd_patterns) / sizeof(cd_patterns[0]),
|
||||
cd_patterns, sizeof(cd_patterns) / sizeof(cd_patterns[0]),
|
||||
sizeof(cd_patterns[0]), &priority);
|
||||
|
||||
return (priority);
|
||||
|
@ -1021,7 +1021,7 @@ static void
|
|||
cdminphys(struct buf *bp)
|
||||
{
|
||||
struct cd_softc *cd = cd_cd.cd_devs[CDUNIT(bp->b_dev)];
|
||||
long max;
|
||||
long xmax;
|
||||
|
||||
/*
|
||||
* If the device is ancient, we want to make sure that
|
||||
|
@ -1035,10 +1035,10 @@ cdminphys(struct buf *bp)
|
|||
* in a 10-byte read/write actually means 0 blocks.
|
||||
*/
|
||||
if (cd->flags & CDF_ANCIENT) {
|
||||
max = cd->sc_dk.dk_label->d_secsize * 0xff;
|
||||
xmax = cd->sc_dk.dk_label->d_secsize * 0xff;
|
||||
|
||||
if (bp->b_bcount > max)
|
||||
bp->b_bcount = max;
|
||||
if (bp->b_bcount > xmax)
|
||||
bp->b_bcount = xmax;
|
||||
}
|
||||
|
||||
(*cd->sc_periph->periph_channel->chan_adapter->adapt_minphys)(bp);
|
||||
|
@ -1833,47 +1833,47 @@ static int
|
|||
dvd_auth(struct cd_softc *cd, dvd_authinfo *a)
|
||||
{
|
||||
struct scsipi_generic cmd;
|
||||
u_int8_t buf[20];
|
||||
u_int8_t bf[20];
|
||||
int error;
|
||||
|
||||
memset(cmd.bytes, 0, 15);
|
||||
memset(buf, 0, sizeof(buf));
|
||||
memset(bf, 0, sizeof(bf));
|
||||
|
||||
switch (a->type) {
|
||||
case DVD_LU_SEND_AGID:
|
||||
cmd.opcode = GPCMD_REPORT_KEY;
|
||||
cmd.bytes[8] = 8;
|
||||
cmd.bytes[9] = 0 | (0 << 6);
|
||||
error = scsipi_command(cd->sc_periph, &cmd, 12, buf, 8,
|
||||
error = scsipi_command(cd->sc_periph, &cmd, 12, bf, 8,
|
||||
CDRETRIES, 30000, NULL,
|
||||
XS_CTL_DATA_IN|XS_CTL_DATA_ONSTACK);
|
||||
if (error)
|
||||
return (error);
|
||||
a->lsa.agid = buf[7] >> 6;
|
||||
a->lsa.agid = bf[7] >> 6;
|
||||
return (0);
|
||||
|
||||
case DVD_LU_SEND_CHALLENGE:
|
||||
cmd.opcode = GPCMD_REPORT_KEY;
|
||||
cmd.bytes[8] = 16;
|
||||
cmd.bytes[9] = 1 | (a->lsc.agid << 6);
|
||||
error = scsipi_command(cd->sc_periph, &cmd, 12, buf, 16,
|
||||
error = scsipi_command(cd->sc_periph, &cmd, 12, bf, 16,
|
||||
CDRETRIES, 30000, NULL,
|
||||
XS_CTL_DATA_IN|XS_CTL_DATA_ONSTACK);
|
||||
if (error)
|
||||
return (error);
|
||||
dvd_copy_challenge(a->lsc.chal, &buf[4]);
|
||||
dvd_copy_challenge(a->lsc.chal, &bf[4]);
|
||||
return (0);
|
||||
|
||||
case DVD_LU_SEND_KEY1:
|
||||
cmd.opcode = GPCMD_REPORT_KEY;
|
||||
cmd.bytes[8] = 12;
|
||||
cmd.bytes[9] = 2 | (a->lsk.agid << 6);
|
||||
error = scsipi_command(cd->sc_periph, &cmd, 12, buf, 12,
|
||||
error = scsipi_command(cd->sc_periph, &cmd, 12, bf, 12,
|
||||
CDRETRIES, 30000, NULL,
|
||||
XS_CTL_DATA_IN|XS_CTL_DATA_ONSTACK);
|
||||
if (error)
|
||||
return (error);
|
||||
dvd_copy_key(a->lsk.key, &buf[4]);
|
||||
dvd_copy_key(a->lsk.key, &bf[4]);
|
||||
return (0);
|
||||
|
||||
case DVD_LU_SEND_TITLE_KEY:
|
||||
|
@ -1881,36 +1881,36 @@ dvd_auth(struct cd_softc *cd, dvd_authinfo *a)
|
|||
_lto4b(a->lstk.lba, &cmd.bytes[1]);
|
||||
cmd.bytes[8] = 12;
|
||||
cmd.bytes[9] = 4 | (a->lstk.agid << 6);
|
||||
error = scsipi_command(cd->sc_periph, &cmd, 12, buf, 12,
|
||||
error = scsipi_command(cd->sc_periph, &cmd, 12, bf, 12,
|
||||
CDRETRIES, 30000, NULL,
|
||||
XS_CTL_DATA_IN|XS_CTL_DATA_ONSTACK);
|
||||
if (error)
|
||||
return (error);
|
||||
a->lstk.cpm = (buf[4] >> 7) & 1;
|
||||
a->lstk.cp_sec = (buf[4] >> 6) & 1;
|
||||
a->lstk.cgms = (buf[4] >> 4) & 3;
|
||||
dvd_copy_key(a->lstk.title_key, &buf[5]);
|
||||
a->lstk.cpm = (bf[4] >> 7) & 1;
|
||||
a->lstk.cp_sec = (bf[4] >> 6) & 1;
|
||||
a->lstk.cgms = (bf[4] >> 4) & 3;
|
||||
dvd_copy_key(a->lstk.title_key, &bf[5]);
|
||||
return (0);
|
||||
|
||||
case DVD_LU_SEND_ASF:
|
||||
cmd.opcode = GPCMD_REPORT_KEY;
|
||||
cmd.bytes[8] = 8;
|
||||
cmd.bytes[9] = 5 | (a->lsasf.agid << 6);
|
||||
error = scsipi_command(cd->sc_periph, &cmd, 12, buf, 8,
|
||||
error = scsipi_command(cd->sc_periph, &cmd, 12, bf, 8,
|
||||
CDRETRIES, 30000, NULL,
|
||||
XS_CTL_DATA_IN|XS_CTL_DATA_ONSTACK);
|
||||
if (error)
|
||||
return (error);
|
||||
a->lsasf.asf = buf[7] & 1;
|
||||
a->lsasf.asf = bf[7] & 1;
|
||||
return (0);
|
||||
|
||||
case DVD_HOST_SEND_CHALLENGE:
|
||||
cmd.opcode = GPCMD_SEND_KEY;
|
||||
cmd.bytes[8] = 16;
|
||||
cmd.bytes[9] = 1 | (a->hsc.agid << 6);
|
||||
buf[1] = 14;
|
||||
dvd_copy_challenge(&buf[4], a->hsc.chal);
|
||||
error = scsipi_command(cd->sc_periph, &cmd, 12, buf, 16,
|
||||
bf[1] = 14;
|
||||
dvd_copy_challenge(&bf[4], a->hsc.chal);
|
||||
error = scsipi_command(cd->sc_periph, &cmd, 12, bf, 16,
|
||||
CDRETRIES, 30000, NULL,
|
||||
XS_CTL_DATA_OUT|XS_CTL_DATA_ONSTACK);
|
||||
if (error)
|
||||
|
@ -1922,9 +1922,9 @@ dvd_auth(struct cd_softc *cd, dvd_authinfo *a)
|
|||
cmd.opcode = GPCMD_SEND_KEY;
|
||||
cmd.bytes[8] = 12;
|
||||
cmd.bytes[9] = 3 | (a->hsk.agid << 6);
|
||||
buf[1] = 10;
|
||||
dvd_copy_key(&buf[4], a->hsk.key);
|
||||
error = scsipi_command(cd->sc_periph, &cmd, 12, buf, 12,
|
||||
bf[1] = 10;
|
||||
dvd_copy_key(&bf[4], a->hsk.key);
|
||||
error = scsipi_command(cd->sc_periph, &cmd, 12, bf, 12,
|
||||
CDRETRIES, 30000, NULL,
|
||||
XS_CTL_DATA_OUT|XS_CTL_DATA_ONSTACK);
|
||||
if (error) {
|
||||
|
@ -1937,7 +1937,7 @@ dvd_auth(struct cd_softc *cd, dvd_authinfo *a)
|
|||
case DVD_INVALIDATE_AGID:
|
||||
cmd.opcode = GPCMD_REPORT_KEY;
|
||||
cmd.bytes[9] = 0x3f | (a->lsa.agid << 6);
|
||||
error = scsipi_command(cd->sc_periph, &cmd, 12, buf, 16,
|
||||
error = scsipi_command(cd->sc_periph, &cmd, 12, bf, 16,
|
||||
CDRETRIES, 30000, NULL, 0);
|
||||
if (error)
|
||||
return (error);
|
||||
|
@ -1947,25 +1947,25 @@ dvd_auth(struct cd_softc *cd, dvd_authinfo *a)
|
|||
cmd.opcode = GPCMD_REPORT_KEY;
|
||||
cmd.bytes[8] = 8;
|
||||
cmd.bytes[9] = 8 | (0 << 6);
|
||||
error = scsipi_command(cd->sc_periph, &cmd, 12, buf, 8,
|
||||
error = scsipi_command(cd->sc_periph, &cmd, 12, bf, 8,
|
||||
CDRETRIES, 30000, NULL,
|
||||
XS_CTL_DATA_IN|XS_CTL_DATA_ONSTACK);
|
||||
if (error)
|
||||
return (error);
|
||||
a->lrpcs.type = (buf[4] >> 6) & 3;
|
||||
a->lrpcs.vra = (buf[4] >> 3) & 7;
|
||||
a->lrpcs.ucca = (buf[4]) & 7;
|
||||
a->lrpcs.region_mask = buf[5];
|
||||
a->lrpcs.rpc_scheme = buf[6];
|
||||
a->lrpcs.type = (bf[4] >> 6) & 3;
|
||||
a->lrpcs.vra = (bf[4] >> 3) & 7;
|
||||
a->lrpcs.ucca = (bf[4]) & 7;
|
||||
a->lrpcs.region_mask = bf[5];
|
||||
a->lrpcs.rpc_scheme = bf[6];
|
||||
return (0);
|
||||
|
||||
case DVD_HOST_SEND_RPC_STATE:
|
||||
cmd.opcode = GPCMD_SEND_KEY;
|
||||
cmd.bytes[8] = 8;
|
||||
cmd.bytes[9] = 6 | (0 << 6);
|
||||
buf[1] = 6;
|
||||
buf[4] = a->hrpcs.pdrc;
|
||||
error = scsipi_command(cd->sc_periph, &cmd, 12, buf, 8,
|
||||
bf[1] = 6;
|
||||
bf[4] = a->hrpcs.pdrc;
|
||||
error = scsipi_command(cd->sc_periph, &cmd, 12, bf, 8,
|
||||
CDRETRIES, 30000, NULL,
|
||||
XS_CTL_DATA_OUT|XS_CTL_DATA_ONSTACK);
|
||||
if (error)
|
||||
|
@ -1981,23 +1981,23 @@ static int
|
|||
dvd_read_physical(struct cd_softc *cd, dvd_struct *s)
|
||||
{
|
||||
struct scsipi_generic cmd;
|
||||
u_int8_t buf[4 + 4 * 20], *bufp;
|
||||
u_int8_t bf[4 + 4 * 20], *bufp;
|
||||
int error;
|
||||
struct dvd_layer *layer;
|
||||
int i;
|
||||
|
||||
memset(cmd.bytes, 0, 15);
|
||||
memset(buf, 0, sizeof(buf));
|
||||
memset(bf, 0, sizeof(bf));
|
||||
cmd.opcode = GPCMD_READ_DVD_STRUCTURE;
|
||||
cmd.bytes[6] = s->type;
|
||||
_lto2b(sizeof(buf), &cmd.bytes[7]);
|
||||
_lto2b(sizeof(bf), &cmd.bytes[7]);
|
||||
|
||||
cmd.bytes[5] = s->physical.layer_num;
|
||||
error = scsipi_command(cd->sc_periph, &cmd, 12, buf, sizeof(buf),
|
||||
error = scsipi_command(cd->sc_periph, &cmd, 12, bf, sizeof(bf),
|
||||
CDRETRIES, 30000, NULL, XS_CTL_DATA_IN|XS_CTL_DATA_ONSTACK);
|
||||
if (error)
|
||||
return (error);
|
||||
for (i = 0, bufp = &buf[4], layer = &s->physical.layer[0]; i < 4;
|
||||
for (i = 0, bufp = &bf[4], layer = &s->physical.layer[0]; i < 4;
|
||||
i++, bufp += 20, layer++) {
|
||||
memset(layer, 0, sizeof(*layer));
|
||||
layer->book_version = bufp[0] & 0xf;
|
||||
|
@ -2021,22 +2021,22 @@ static int
|
|||
dvd_read_copyright(struct cd_softc *cd, dvd_struct *s)
|
||||
{
|
||||
struct scsipi_generic cmd;
|
||||
u_int8_t buf[8];
|
||||
u_int8_t bf[8];
|
||||
int error;
|
||||
|
||||
memset(cmd.bytes, 0, 15);
|
||||
memset(buf, 0, sizeof(buf));
|
||||
memset(bf, 0, sizeof(bf));
|
||||
cmd.opcode = GPCMD_READ_DVD_STRUCTURE;
|
||||
cmd.bytes[6] = s->type;
|
||||
_lto2b(sizeof(buf), &cmd.bytes[7]);
|
||||
_lto2b(sizeof(bf), &cmd.bytes[7]);
|
||||
|
||||
cmd.bytes[5] = s->copyright.layer_num;
|
||||
error = scsipi_command(cd->sc_periph, &cmd, 12, buf, sizeof(buf),
|
||||
error = scsipi_command(cd->sc_periph, &cmd, 12, bf, sizeof(bf),
|
||||
CDRETRIES, 30000, NULL, XS_CTL_DATA_IN|XS_CTL_DATA_ONSTACK);
|
||||
if (error)
|
||||
return (error);
|
||||
s->copyright.cpst = buf[4];
|
||||
s->copyright.rmi = buf[5];
|
||||
s->copyright.cpst = bf[4];
|
||||
s->copyright.rmi = bf[5];
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
@ -2044,11 +2044,11 @@ static int
|
|||
dvd_read_disckey(struct cd_softc *cd, dvd_struct *s)
|
||||
{
|
||||
struct scsipi_generic cmd;
|
||||
u_int8_t *buf;
|
||||
u_int8_t *bf;
|
||||
int error;
|
||||
|
||||
buf = malloc(4 + 2048, M_TEMP, M_WAITOK|M_ZERO);
|
||||
if (buf == NULL)
|
||||
bf = malloc(4 + 2048, M_TEMP, M_WAITOK|M_ZERO);
|
||||
if (bf == NULL)
|
||||
return EIO;
|
||||
memset(cmd.bytes, 0, 15);
|
||||
cmd.opcode = GPCMD_READ_DVD_STRUCTURE;
|
||||
|
@ -2056,11 +2056,11 @@ dvd_read_disckey(struct cd_softc *cd, dvd_struct *s)
|
|||
_lto2b(4 + 2048, &cmd.bytes[7]);
|
||||
|
||||
cmd.bytes[9] = s->disckey.agid << 6;
|
||||
error = scsipi_command(cd->sc_periph, &cmd, 12, buf, 4 + 2048,
|
||||
error = scsipi_command(cd->sc_periph, &cmd, 12, bf, 4 + 2048,
|
||||
CDRETRIES, 30000, NULL, XS_CTL_DATA_IN|XS_CTL_DATA_ONSTACK);
|
||||
if (error == 0)
|
||||
memcpy(s->disckey.value, &buf[4], 2048);
|
||||
free(buf, M_TEMP);
|
||||
memcpy(s->disckey.value, &bf[4], 2048);
|
||||
free(bf, M_TEMP);
|
||||
return error;
|
||||
}
|
||||
|
||||
|
@ -2068,23 +2068,23 @@ static int
|
|||
dvd_read_bca(struct cd_softc *cd, dvd_struct *s)
|
||||
{
|
||||
struct scsipi_generic cmd;
|
||||
u_int8_t buf[4 + 188];
|
||||
u_int8_t bf[4 + 188];
|
||||
int error;
|
||||
|
||||
memset(cmd.bytes, 0, 15);
|
||||
memset(buf, 0, sizeof(buf));
|
||||
memset(bf, 0, sizeof(bf));
|
||||
cmd.opcode = GPCMD_READ_DVD_STRUCTURE;
|
||||
cmd.bytes[6] = s->type;
|
||||
_lto2b(sizeof(buf), &cmd.bytes[7]);
|
||||
_lto2b(sizeof(bf), &cmd.bytes[7]);
|
||||
|
||||
error = scsipi_command(cd->sc_periph, &cmd, 12, buf, sizeof(buf),
|
||||
error = scsipi_command(cd->sc_periph, &cmd, 12, bf, sizeof(bf),
|
||||
CDRETRIES, 30000, NULL, XS_CTL_DATA_IN|XS_CTL_DATA_ONSTACK);
|
||||
if (error)
|
||||
return (error);
|
||||
s->bca.len = _2btol(&buf[0]);
|
||||
s->bca.len = _2btol(&bf[0]);
|
||||
if (s->bca.len < 12 || s->bca.len > 188)
|
||||
return (EIO);
|
||||
memcpy(s->bca.value, &buf[4], s->bca.len);
|
||||
memcpy(s->bca.value, &bf[4], s->bca.len);
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
@ -2092,27 +2092,27 @@ static int
|
|||
dvd_read_manufact(struct cd_softc *cd, dvd_struct *s)
|
||||
{
|
||||
struct scsipi_generic cmd;
|
||||
u_int8_t *buf;
|
||||
u_int8_t *bf;
|
||||
int error;
|
||||
|
||||
buf = malloc(4 + 2048, M_TEMP, M_WAITOK|M_ZERO);
|
||||
if (buf == NULL)
|
||||
bf = malloc(4 + 2048, M_TEMP, M_WAITOK|M_ZERO);
|
||||
if (bf == NULL)
|
||||
return (EIO);
|
||||
memset(cmd.bytes, 0, 15);
|
||||
cmd.opcode = GPCMD_READ_DVD_STRUCTURE;
|
||||
cmd.bytes[6] = s->type;
|
||||
_lto2b(4 + 2048, &cmd.bytes[7]);
|
||||
|
||||
error = scsipi_command(cd->sc_periph, &cmd, 12, buf, 4 + 2048,
|
||||
error = scsipi_command(cd->sc_periph, &cmd, 12, bf, 4 + 2048,
|
||||
CDRETRIES, 30000, NULL, XS_CTL_DATA_IN|XS_CTL_DATA_ONSTACK);
|
||||
if (error == 0) {
|
||||
s->manufact.len = _2btol(&buf[0]);
|
||||
s->manufact.len = _2btol(&bf[0]);
|
||||
if (s->manufact.len >= 0 && s->manufact.len <= 2048)
|
||||
memcpy(s->manufact.value, &buf[4], s->manufact.len);
|
||||
memcpy(s->manufact.value, &bf[4], s->manufact.len);
|
||||
else
|
||||
error = EIO;
|
||||
}
|
||||
free(buf, M_TEMP);
|
||||
free(bf, M_TEMP);
|
||||
return error;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: scsipi_base.c,v 1.129 2005/04/04 11:26:50 yamt Exp $ */
|
||||
/* $NetBSD: scsipi_base.c,v 1.130 2005/05/29 22:00:50 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998, 1999, 2000, 2002, 2003, 2004 The NetBSD Foundation, Inc.
|
||||
|
@ -38,7 +38,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: scsipi_base.c,v 1.129 2005/04/04 11:26:50 yamt Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: scsipi_base.c,v 1.130 2005/05/29 22:00:50 christos Exp $");
|
||||
|
||||
#include "opt_scsi.h"
|
||||
|
||||
|
@ -989,7 +989,7 @@ scsipi_interpret_sense(struct scsipi_xfer *xs)
|
|||
default:
|
||||
#if defined(SCSIDEBUG) || defined(DEBUG)
|
||||
{
|
||||
static char *uc = "undecodable sense error";
|
||||
static const char *uc = "undecodable sense error";
|
||||
int i;
|
||||
u_int8_t *cptr = (u_int8_t *) sense;
|
||||
scsipi_printaddr(periph);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: scsipi_verbose.c,v 1.26 2005/02/21 00:29:07 thorpej Exp $ */
|
||||
/* $NetBSD: scsipi_verbose.c,v 1.27 2005/05/29 22:00:50 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
||||
|
@ -37,7 +37,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: scsipi_verbose.c,v 1.26 2005/02/21 00:29:07 thorpej Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: scsipi_verbose.c,v 1.27 2005/05/29 22:00:50 christos Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/time.h>
|
||||
|
@ -82,7 +82,7 @@ static const char *sense_keys[16] = {
|
|||
static const struct {
|
||||
unsigned char asc;
|
||||
unsigned char ascq;
|
||||
char *description;
|
||||
const char *description;
|
||||
} adesc[] = {
|
||||
{ 0x00, 0x00, "No Additional Sense Information" },
|
||||
{ 0x00, 0x01, "Filemark Detected" },
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: scsipiconf.c,v 1.31 2005/02/27 00:27:48 perry Exp $ */
|
||||
/* $NetBSD: scsipiconf.c,v 1.32 2005/05/29 22:00:50 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998, 1999, 2004 The NetBSD Foundation, Inc.
|
||||
|
@ -55,7 +55,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: scsipiconf.c,v 1.31 2005/02/27 00:27:48 perry Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: scsipiconf.c,v 1.32 2005/05/29 22:00:50 christos Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
@ -119,18 +119,19 @@ scsipi_alloc_periph(int malloc_flag)
|
|||
* Return a priority based on how much of the inquiry data matches
|
||||
* the patterns for the particular driver.
|
||||
*/
|
||||
caddr_t
|
||||
scsipi_inqmatch(struct scsipi_inquiry_pattern *inqbuf, caddr_t base,
|
||||
int nmatches, int matchsize, int *bestpriority)
|
||||
const void *
|
||||
scsipi_inqmatch(struct scsipi_inquiry_pattern *inqbuf, const void *base,
|
||||
size_t nmatches, size_t matchsize, int *bestpriority)
|
||||
{
|
||||
u_int8_t type;
|
||||
caddr_t bestmatch;
|
||||
const struct scsipi_inquiry_pattern *bestmatch;
|
||||
|
||||
/* Include the qualifier to catch vendor-unique types. */
|
||||
type = inqbuf->type;
|
||||
|
||||
for (*bestpriority = 0, bestmatch = 0; nmatches--; base += matchsize) {
|
||||
struct scsipi_inquiry_pattern *match = (void *)base;
|
||||
for (*bestpriority = 0, bestmatch = 0; nmatches--;
|
||||
base = (const char *)base + matchsize) {
|
||||
const struct scsipi_inquiry_pattern *match = base;
|
||||
int priority, len;
|
||||
|
||||
if (type != match->type)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: scsipiconf.h,v 1.98 2005/05/18 13:58:10 chs Exp $ */
|
||||
/* $NetBSD: scsipiconf.h,v 1.99 2005/05/29 22:00:50 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998, 1999, 2000, 2004 The NetBSD Foundation, Inc.
|
||||
|
@ -596,9 +596,9 @@ struct scsipi_xfer {
|
|||
struct scsipi_inquiry_pattern {
|
||||
u_int8_t type;
|
||||
boolean removable;
|
||||
char *vendor;
|
||||
char *product;
|
||||
char *revision;
|
||||
const char *vendor;
|
||||
const char *product;
|
||||
const char *revision;
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -633,8 +633,8 @@ void scsipi_init(void);
|
|||
int scsipi_command(struct scsipi_periph *, struct scsipi_generic *, int,
|
||||
u_char *, int, int, int, struct buf *, int);
|
||||
void scsipi_create_completion_thread(void *);
|
||||
caddr_t scsipi_inqmatch(struct scsipi_inquiry_pattern *, caddr_t,
|
||||
int, int, int *);
|
||||
const void *scsipi_inqmatch(struct scsipi_inquiry_pattern *, const void *,
|
||||
size_t, size_t, int *);
|
||||
const char *scsipi_dtype(int);
|
||||
void scsipi_strvis(u_char *, int, u_char *, int);
|
||||
int scsipi_execute_xs(struct scsipi_xfer *);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: sd.c,v 1.239 2005/04/25 17:35:26 drochner Exp $ */
|
||||
/* $NetBSD: sd.c,v 1.240 2005/05/29 22:00:50 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998, 2003, 2004 The NetBSD Foundation, Inc.
|
||||
|
@ -54,7 +54,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: sd.c,v 1.239 2005/04/25 17:35:26 drochner Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: sd.c,v 1.240 2005/05/29 22:00:50 christos Exp $");
|
||||
|
||||
#include "opt_scsi.h"
|
||||
#include "rnd.h"
|
||||
|
@ -200,7 +200,7 @@ sdmatch(struct device *parent, struct cfdata *match, void *aux)
|
|||
int priority;
|
||||
|
||||
(void)scsipi_inqmatch(&sa->sa_inqbuf,
|
||||
(caddr_t)sd_patterns, sizeof(sd_patterns) / sizeof(sd_patterns[0]),
|
||||
sd_patterns, sizeof(sd_patterns) / sizeof(sd_patterns[0]),
|
||||
sizeof(sd_patterns[0]), &priority);
|
||||
|
||||
return (priority);
|
||||
|
@ -950,7 +950,7 @@ static void
|
|||
sdminphys(struct buf *bp)
|
||||
{
|
||||
struct sd_softc *sd = sd_cd.cd_devs[SDUNIT(bp->b_dev)];
|
||||
long max;
|
||||
long xmax;
|
||||
|
||||
/*
|
||||
* If the device is ancient, we want to make sure that
|
||||
|
@ -966,10 +966,10 @@ sdminphys(struct buf *bp)
|
|||
if ((sd->flags & SDF_ANCIENT) &&
|
||||
((sd->sc_periph->periph_flags &
|
||||
(PERIPH_REMOVABLE | PERIPH_MEDIA_LOADED)) != PERIPH_REMOVABLE)) {
|
||||
max = sd->sc_dk.dk_label->d_secsize * 0xff;
|
||||
xmax = sd->sc_dk.dk_label->d_secsize * 0xff;
|
||||
|
||||
if (bp->b_bcount > max)
|
||||
bp->b_bcount = max;
|
||||
if (bp->b_bcount > xmax)
|
||||
bp->b_bcount = xmax;
|
||||
}
|
||||
|
||||
scsipi_adapter_minphys(sd->sc_periph->periph_channel, bp);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: st.c,v 1.180 2005/04/25 17:08:46 drochner Exp $ */
|
||||
/* $NetBSD: st.c,v 1.181 2005/05/29 22:00:50 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998, 2004 The NetBSD Foundation, Inc.
|
||||
|
@ -57,7 +57,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: st.c,v 1.180 2005/04/25 17:08:46 drochner Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: st.c,v 1.181 2005/05/29 22:00:50 christos Exp $");
|
||||
|
||||
#include "opt_scsi.h"
|
||||
|
||||
|
@ -481,11 +481,11 @@ stdetach(struct device *self, int flags)
|
|||
static void
|
||||
st_identify_drive(struct st_softc *st, struct scsipi_inquiry_pattern *inqbuf)
|
||||
{
|
||||
struct st_quirk_inquiry_pattern *finger;
|
||||
const struct st_quirk_inquiry_pattern *finger;
|
||||
int priority;
|
||||
|
||||
finger = (struct st_quirk_inquiry_pattern *)scsipi_inqmatch(inqbuf,
|
||||
(caddr_t)st_quirk_patterns,
|
||||
finger = scsipi_inqmatch(inqbuf,
|
||||
st_quirk_patterns,
|
||||
sizeof(st_quirk_patterns) / sizeof(st_quirk_patterns[0]),
|
||||
sizeof(st_quirk_patterns[0]), &priority);
|
||||
if (priority != 0) {
|
||||
|
@ -506,7 +506,7 @@ static void
|
|||
st_loadquirks(struct st_softc *st)
|
||||
{
|
||||
int i;
|
||||
struct modes *mode;
|
||||
const struct modes *mode;
|
||||
struct modes *mode2;
|
||||
|
||||
mode = st->quirkdata->modes;
|
||||
|
@ -1629,7 +1629,7 @@ try_new_value:
|
|||
* Do a synchronous read.
|
||||
*/
|
||||
static int
|
||||
st_read(struct st_softc *st, char *buf, int size, int flags)
|
||||
st_read(struct st_softc *st, char *bf, int size, int flags)
|
||||
{
|
||||
struct scsi_rw_tape cmd;
|
||||
|
||||
|
@ -1647,7 +1647,7 @@ st_read(struct st_softc *st, char *buf, int size, int flags)
|
|||
} else
|
||||
_lto3b(size, cmd.len);
|
||||
return (scsipi_command(st->sc_periph,
|
||||
(void *)&cmd, sizeof(cmd), (void *)buf, size, 0, ST_IO_TIME, NULL,
|
||||
(void *)&cmd, sizeof(cmd), (void *)bf, size, 0, ST_IO_TIME, NULL,
|
||||
flags | XS_CTL_DATA_IN));
|
||||
}
|
||||
|
||||
|
@ -2332,12 +2332,12 @@ st_interpret_sense(struct scsipi_xfer *xs)
|
|||
static int
|
||||
st_touch_tape(struct st_softc *st)
|
||||
{
|
||||
char *buf;
|
||||
char *bf;
|
||||
int readsize;
|
||||
int error;
|
||||
|
||||
buf = malloc(1024, M_TEMP, M_NOWAIT);
|
||||
if (buf == NULL)
|
||||
bf = malloc(1024, M_TEMP, M_NOWAIT);
|
||||
if (bf == NULL)
|
||||
return (ENOMEM);
|
||||
|
||||
if ((error = st->ops(st, ST_OPS_MODESENSE, 0)) != 0)
|
||||
|
@ -2375,14 +2375,14 @@ st_touch_tape(struct st_softc *st)
|
|||
st->blksize -= 512;
|
||||
continue;
|
||||
}
|
||||
st_read(st, buf, readsize, XS_CTL_SILENT); /* XXX */
|
||||
st_read(st, bf, readsize, XS_CTL_SILENT); /* XXX */
|
||||
if ((error = st_rewind(st, 0, 0)) != 0) {
|
||||
bad: free(buf, M_TEMP);
|
||||
bad: free(bf, M_TEMP);
|
||||
return (error);
|
||||
}
|
||||
} while (readsize != 1 && readsize > st->blksize);
|
||||
|
||||
free(buf, M_TEMP);
|
||||
free(bf, M_TEMP);
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: st_atapi.c,v 1.15 2005/02/27 00:27:48 perry Exp $ */
|
||||
/* $NetBSD: st_atapi.c,v 1.16 2005/05/29 22:00:50 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001 Manuel Bouyer.
|
||||
|
@ -31,7 +31,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: st_atapi.c,v 1.15 2005/02/27 00:27:48 perry Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: st_atapi.c,v 1.16 2005/05/29 22:00:50 christos Exp $");
|
||||
|
||||
#include "opt_scsi.h"
|
||||
#include "rnd.h"
|
||||
|
@ -71,7 +71,7 @@ st_atapibus_match(struct device *parent, struct cfdata *match, void *aux)
|
|||
return (0);
|
||||
|
||||
(void)scsipi_inqmatch(&sa->sa_inqbuf,
|
||||
(caddr_t)st_atapibus_patterns,
|
||||
st_atapibus_patterns,
|
||||
sizeof(st_atapibus_patterns)/sizeof(st_atapibus_patterns[0]),
|
||||
sizeof(st_atapibus_patterns[0]), &priority);
|
||||
return (priority);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: stvar.h,v 1.12 2005/02/01 00:19:34 reinoud Exp $ */
|
||||
/* $NetBSD: stvar.h,v 1.13 2005/05/29 22:00:50 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
||||
|
@ -127,7 +127,7 @@ struct st_softc {
|
|||
/*--------------------parameters reported by the device ---------------------*/
|
||||
int blkmin; /* min blk size */
|
||||
int blkmax; /* max blk size */
|
||||
struct quirkdata *quirkdata; /* if we have a rogue entry */
|
||||
const 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 */
|
||||
|
|
Loading…
Reference in New Issue