diff options
Diffstat (limited to 'sanei/sanei_scsi.c')
-rw-r--r-- | sanei/sanei_scsi.c | 76 |
1 files changed, 38 insertions, 38 deletions
diff --git a/sanei/sanei_scsi.c b/sanei/sanei_scsi.c index 2413d8f..ca3dbb0 100644 --- a/sanei/sanei_scsi.c +++ b/sanei/sanei_scsi.c @@ -252,11 +252,11 @@ static int unit_ready (int fd); #endif #if USE == SYSVR4_INTERFACE -# define MAX_DATA 56*1024 /* don't increase or kernel will dump - * tested with adsl, adsa and umax backend - * it depends on the lowend scsi - * drivers . But the most restriction - * is in the UNIXWARE KERNEL witch do +# define MAX_DATA 56*1024 /* don't increase or kernel will dump + * tested with adsl, adsa and umax backend + * it depends on the lowend scsi + * drivers . But the most restriction + * is in the UNIXWARE KERNEL witch do * not allow more then 64kB DMA transfers */ static char lastrcmd[16]; /* hold command block of last read command */ #endif @@ -875,7 +875,7 @@ sanei_scsi_open (const char *dev, int *fdp, int fd, i; #if USE == LINUX_INTERFACE static int first_time = 1; -#elif USE == MACOSX_INTERFACE +#elif USE == MACOSX_INTERFACE UInt8 *guid; int len; u_int d; @@ -909,7 +909,7 @@ sanei_scsi_open (const char *dev, int *fdp, With newer versions of the SG driver, check the available buffer size by opening all SG device files belonging to a scanner, issue the ioctl calls for setting and reading the reserved - buffer size, and take the smallest value. + buffer size, and take the smallest value. For older version of the SG driver, which don't support variable buffer size, try to read /proc/sys/kernel/sg-big-biff ; if @@ -958,7 +958,7 @@ sanei_scsi_open (const char *dev, int *fdp, if (sscanf (dev, "b%dt%dl%d", &bus, &target, &lun) != 3) { - DBG (1, "sanei_scsi_open: device name `%s´ is not valid: %s\n", + DBG (1, "sanei_scsi_open: device name `%s´ is not valid: %s\n", dev, strerror (errno)); return SANE_STATUS_INVAL; } @@ -1149,7 +1149,7 @@ sanei_scsi_open (const char *dev, int *fdp, } else { - DBG (1, "sanei_scsi_open: can't open device `%s´: %s\n", dev, + DBG (1, "sanei_scsi_open: can't open device `%s´: %s\n", dev, strerror (errno)); return SANE_STATUS_INVAL; } @@ -1163,7 +1163,7 @@ sanei_scsi_open (const char *dev, int *fdp, if (4 != sscanf (dev, "/dev/passthru0:%d,%d,%d,%d", &bus, &cnt, &id, &lun)) { - DBG (1, "sanei_scsi_open: device name `%s´ is not valid: %s\n", + DBG (1, "sanei_scsi_open: device name `%s´ is not valid: %s\n", dev, strerror (errno)); return SANE_STATUS_INVAL; } @@ -1222,21 +1222,21 @@ sanei_scsi_open (const char *dev, int *fdp, { char scsi_hca_name[20]; u_int hca = 0; - + if (sscanf (dev, "h%ub%ut%ul%u", &hca, &bus, &target, &lun) != 4) { DBG (1, "sanei_scsi_open: device name %s is not valid\n", dev); return SANE_STATUS_INVAL; } - + snprintf(scsi_hca_name, 19, "\\\\.\\Scsi%d:", hca); scsi_hca_name[19] = 0; - + fd = CreateFile(scsi_hca_name, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_FLAG_RANDOM_ACCESS, NULL ); - + if (fd == INVALID_HANDLE_VALUE) fd = -1; } #else @@ -1420,7 +1420,7 @@ sanei_scsi_open (const char *dev, int *fdp, else { /* we have a really old SG driver version, or we're not opening - an SG device file + an SG device file */ if (ioctl (fd, SG_GET_TIMEOUT, &ioctl_val) < 0) { @@ -2436,8 +2436,8 @@ issue (struct req *req) } #if 0 - /* Sometimes the Linux SCSI system reports bogus resid values. - Observed with lk 2.4.5, 2.4.13, aic7xxx and sym53c8xx drivers, + /* Sometimes the Linux SCSI system reports bogus resid values. + Observed with lk 2.4.5, 2.4.13, aic7xxx and sym53c8xx drivers, if command queueing is used. So we better issue only a warning */ if (status == SANE_STATUS_GOOD) @@ -2601,7 +2601,7 @@ issue (struct req *req) } static int /* Returns 1 if match with 'name' set, else 0 */ - + lx_scan_sg (int exclude_devnum, char *name, size_t name_len, int host, int channel, int id, int lun) { @@ -2636,7 +2636,7 @@ issue (struct req *req) } static int /* Returns 1 if match, else 0 */ - + lx_chk_devicename (int guess_devnum, char *name, size_t name_len, int host, int channel, int id, int lun) { @@ -2945,8 +2945,7 @@ sanei_scsi_find_devices (const char *findvendor, const char *findmodel, char *me = "sanei_scsi_find_devices"; char path[PATH_MAX]; char dev_name[128]; - struct dirent buf; - struct dirent *de; + struct dirent *buf; DIR *scsidevs; FILE *fp; char *ptr; @@ -2987,8 +2986,9 @@ sanei_scsi_find_devices (const char *findvendor, const char *findmodel, number = -1; for (;;) { - ret = readdir_r(scsidevs, &buf, &de); - if (ret != 0) + errno = 0; + buf = readdir (scsidevs); + if (errno != 0) { DBG (1, "%s: could not read directory %s: %s\n", me, SYSFS_SCSI_DEVICES, strerror(errno)); @@ -2996,14 +2996,14 @@ sanei_scsi_find_devices (const char *findvendor, const char *findmodel, break; } - if (de == NULL) + if (buf == NULL) break; - if (buf.d_name[0] == '.') + if (buf->d_name[0] == '.') continue; /* Extract bus, channel, id, lun from directory name b:c:i:l */ - ptr = buf.d_name; + ptr = buf->d_name; for (i = 0; i < 4; i++) { errno = 0; @@ -3028,7 +3028,7 @@ sanei_scsi_find_devices (const char *findvendor, const char *findmodel, if (*end && (*end != ':')) { - DBG (1, "%s: parse error on string %s (%d)\n", me, buf.d_name, i); + DBG (1, "%s: parse error on string %s (%d)\n", me, buf->d_name, i); i = 12; /* Skip */ break; @@ -3036,7 +3036,7 @@ sanei_scsi_find_devices (const char *findvendor, const char *findmodel, if (val > INT_MAX) { - DBG (1, "%s: integer value too large (%s)\n", me, buf.d_name); + DBG (1, "%s: integer value too large (%s)\n", me, buf->d_name); i = 12; /* Skip */ break; @@ -3059,11 +3059,11 @@ sanei_scsi_find_devices (const char *findvendor, const char *findmodel, for (i = 0; i < 3; i++) { ret = snprintf (path, PATH_MAX, "%s/%s/%s", - SYSFS_SCSI_DEVICES, buf.d_name, vmtfiles[i]); + SYSFS_SCSI_DEVICES, buf->d_name, vmtfiles[i]); if ((ret < 0) || (ret >= PATH_MAX)) { DBG (1, "%s: skipping %s/%s, PATH_MAX exceeded on %s\n", - me, SYSFS_SCSI_DEVICES, buf.d_name, vmtfiles[i]); + me, SYSFS_SCSI_DEVICES, buf->d_name, vmtfiles[i]); i = 12; /* Skip */ break; @@ -3179,7 +3179,7 @@ sanei_scsi_find_devices (const char *findvendor, const char *findmodel, scsireq_t hdr; int result; -/* xxx obsolete: +/* xxx obsolete: cdb_size = CDB_SIZE (*(u_char *) src); */ @@ -3201,7 +3201,7 @@ sanei_scsi_find_devices (const char *findvendor, const char *findmodel, /* The old variant: hdr.databuf = (char *) src + cdb_size; hdr.datalen = src_size; - xxxxxx huh? Shouldn´t the above line have been src_size - cdb_size) + xxxxxx huh? Shouldn´t the above line have been src_size - cdb_size) */ hdr.databuf = (char *) src; hdr.datalen = src_size; @@ -5013,7 +5013,7 @@ sanei_scsi_find_devices (const char *findvendor, const char *findmodel, #if USE == WIN32_INTERFACE SANE_Status -sanei_scsi_cmd2 (int fd, +sanei_scsi_cmd2 (int fd, const void *cmd, size_t cmd_size, const void *src, size_t src_size, void *dst, size_t * dst_size) @@ -5049,8 +5049,8 @@ sanei_scsi_cmd2 (int fd, pkt.sptd.DataBuffer = src; } else { - pkt.sptd.DataIn = SCSI_IOCTL_DATA_UNSPECIFIED; - } + pkt.sptd.DataIn = SCSI_IOCTL_DATA_UNSPECIFIED; + } pkt.sptd.TimeOutValue = sane_scsicmd_timeout; @@ -5081,7 +5081,7 @@ sanei_scsi_cmd2 (int fd, else { return SANE_STATUS_IO_ERROR; } - } + } else if (pkt.sptd.ScsiStatus != 0) { DBG (1, "sanei_scsi_cmd2: ScsiStatus is %d\n", pkt.sptd.ScsiStatus); @@ -5152,14 +5152,14 @@ sanei_scsi_find_devices (const char *findvendor, const char *findmodel, adapter = (PSCSI_ADAPTER_BUS_INFO)buffer; - for(i = 0; i < adapter->NumberOfBuses; i++) { + for(i = 0; i < adapter->NumberOfBuses; i++) { if (adapter->BusData[i].InquiryDataOffset == 0) { /* No device here */ continue; } - inquiry = (PSCSI_INQUIRY_DATA) (buffer + + inquiry = (PSCSI_INQUIRY_DATA) (buffer + adapter->BusData[i].InquiryDataOffset); while(1) { |