Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 6430ac6 in mainline


Ignore:
Timestamp:
2011-07-03T10:53:17Z (11 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master
Children:
71fa44c
Parents:
3f08fd2b
Message:

Refactor inquiry.c a little.

Location:
uspace/drv/bus/usb/usbmast
Files:
1 added
3 edited
1 moved

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/usbmast/Makefile

    r3f08fd2b r6430ac6  
    4545SOURCES = \
    4646        cmds.c \
    47         inquiry.c \
    4847        main.c \
    49         mast.c
     48        mast.c \
     49        scsi_ms.c
    5050
    5151include $(USPACE_PREFIX)/Makefile.common
  • uspace/drv/bus/usb/usbmast/main.c

    r3f08fd2b r6430ac6  
    4242#include "cmds.h"
    4343#include "mast.h"
     44#include "scsi_ms.h"
    4445
    4546#define NAME "usbmast"
     
    107108
    108109        usb_log_debug("Inquire...\n");
    109         usb_massstor_inquiry_result_t inquiry;
    110         rc = usb_massstor_inquiry(dev, &inquiry);
     110        usbmast_inquiry_data_t inquiry;
     111        rc = usbmast_inquiry(dev, &inquiry);
    111112        if (rc != EOK) {
    112113                usb_log_warning("Failed to inquire device `%s': %s.\n",
     
    121122            inquiry.vendor,
    122123            inquiry.revision,
    123             usb_str_masstor_scsi_peripheral_device_type(inquiry.device_type),
     124            usbmast_scsi_dev_type_str(inquiry.device_type),
    124125            inquiry.removable ? "removable" : "non-removable",
    125126            lun_count);
  • uspace/drv/bus/usb/usbmast/mast.h

    r3f08fd2b r6430ac6  
    4646#define BULK_OUT_EP 1
    4747
    48 /** Result of SCSI INQUIRY command.
    49  * This is already parsed structure, not the original buffer returned by
    50  * the device.
    51  */
    52 typedef struct {
    53         /** SCSI peripheral device type */
    54         unsigned device_type;
    55         /** Whether the device is removable */
    56         bool removable;
    57         /** Vendor ID string */
    58         char vendor[SCSI_INQ_VENDOR_STR_BUFSIZE];
    59         /** Product ID string */
    60         char product[SCSI_INQ_PRODUCT_STR_BUFSIZE];
    61         /** Revision string */
    62         char revision[SCSI_INQ_REVISION_STR_BUFSIZE];
    63 } usb_massstor_inquiry_result_t;
    64 
    6548int usb_massstor_data_in(usb_device_t *dev, uint32_t, uint8_t, void *,
    6649    size_t, void *, size_t, size_t *);
     
    6952int usb_massstor_get_max_lun(usb_device_t *);
    7053size_t usb_masstor_get_lun_count(usb_device_t *);
    71 int usb_massstor_inquiry(usb_device_t *, usb_massstor_inquiry_result_t *);
    72 const char *usb_str_masstor_scsi_peripheral_device_type(unsigned);
    7354
    7455#endif
  • uspace/drv/bus/usb/usbmast/scsi_ms.c

    r3f08fd2b r6430ac6  
    3232/**
    3333 * @file
    34  * Main routines of USB mass storage driver.
     34 * SCSI functions for USB mass storage driver.
    3535 */
    3636#include <bitops.h>
     
    4646#include "cmds.h"
    4747#include "mast.h"
     48#include "scsi_ms.h"
    4849
    4950/** Get string representation for SCSI peripheral device type.
    5051 *
    51  * @param type SCSI peripheral device type code.
    52  * @return String representation.
     52 * @param type          SCSI peripheral device type code.
     53 * @return              String representation.
    5354 */
    54 const char *usb_str_masstor_scsi_peripheral_device_type(unsigned type)
     55const char *usbmast_scsi_dev_type_str(unsigned type)
    5556{
    5657        return scsi_get_dev_type_str(type);
     
    5960/** Perform SCSI INQUIRY command on USB mass storage device.
    6061 *
    61  * @param dev USB device.
    62  * @param bulk_in_idx Index (in dev->pipes) of bulk in pipe.
    63  * @param bulk_out_idx Index of bulk out pipe.
     62 * @param dev           USB device.
    6463 * @param inquiry_result Where to store parsed inquiry result.
    65  * @return Error code.
     64 * @return              Error code.
    6665 */
    67 int usb_massstor_inquiry(usb_device_t *dev,
    68     usb_massstor_inquiry_result_t *inquiry_result)
     66int usbmast_inquiry(usb_device_t *dev, usbmast_inquiry_data_t *inq_res)
    6967{
    7068        scsi_std_inquiry_data_t inq_data;
     
    9896         */
    9997
    100         bzero(inquiry_result, sizeof(*inquiry_result));
     98        bzero(inq_res, sizeof(*inq_res));
    10199
    102         inquiry_result->device_type = BIT_RANGE_EXTRACT(uint8_t,
     100        inq_res->device_type = BIT_RANGE_EXTRACT(uint8_t,
    103101            inq_data.pqual_devtype, SCSI_PQDT_DEV_TYPE_h, SCSI_PQDT_DEV_TYPE_l);
    104102
    105         inquiry_result->removable = BIT_RANGE_EXTRACT(uint8_t,
     103        inq_res->removable = BIT_RANGE_EXTRACT(uint8_t,
    106104            inq_data.rmb, SCSI_RMB_RMB, SCSI_RMB_RMB);
    107105
    108         spascii_to_str(inquiry_result->vendor, SCSI_INQ_VENDOR_STR_BUFSIZE,
     106        spascii_to_str(inq_res->vendor, SCSI_INQ_VENDOR_STR_BUFSIZE,
    109107            inq_data.vendor, sizeof(inq_data.vendor));
    110108
    111         spascii_to_str(inquiry_result->product, SCSI_INQ_PRODUCT_STR_BUFSIZE,
     109        spascii_to_str(inq_res->product, SCSI_INQ_PRODUCT_STR_BUFSIZE,
    112110            inq_data.product, sizeof(inq_data.product));
    113111
    114         spascii_to_str(inquiry_result->revision, SCSI_INQ_REVISION_STR_BUFSIZE,
     112        spascii_to_str(inq_res->revision, SCSI_INQ_REVISION_STR_BUFSIZE,
    115113            inq_data.revision, sizeof(inq_data.revision));
    116114
Note: See TracChangeset for help on using the changeset viewer.