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

Changeset 5f0fe4e9 in mainline


Ignore:
Timestamp:
2011-05-11T19:37:16Z (11 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master
Children:
c372e03
Parents:
cf002dbf
Message:

Mass storage (small) refactoring

Location:
uspace/drv/usbmast
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/usbmast/main.c

    rcf002dbf r5f0fe4e9  
    107107            (size_t) dev->pipes[BULK_OUT_EP].descriptor->max_packet_size);
    108108
    109         int lun_count = usb_massstor_get_max_lun(dev);
    110         /* Return value:
    111          * rc < 0 => device does not know this request, only single LUN
    112          *     could be present
    113          * rc >= 0 - the rc is the maximum LUN, thus count is +1
    114          */
    115         if (lun_count < 0) {
    116                 lun_count = 1;
    117         } else {
    118                 lun_count++;
    119         }
     109        size_t lun_count = usb_masstor_get_lun_count(dev);
    120110
    121111        usb_massstor_inquiry_result_t inquiry;
     
    127117        }
    128118
    129         usb_log_info("Mass storage `%s': `%s' by `%s' is %s (%s), %d LUN(s).\n",
     119        usb_log_info("Mass storage `%s': " \
     120            "`%s' by `%s' is %s (%s), %zu LUN(s).\n",
    130121            dev->ddf_dev->name,
    131122            inquiry.product_and_revision, inquiry.vendor_id,
  • uspace/drv/usbmast/mast.c

    rcf002dbf r5f0fe4e9  
    173173/** Get max LUN of a mass storage device.
    174174 *
     175 * @see usb_masstor_get_lun_count
     176 *
    175177 * @warning Error from this command does not necessarily indicate malfunction
    176178 * of the device. Device does not need to support this request.
     179 * You shall rather use usb_masstor_get_lun_count.
    177180 *
    178181 * @param dev Mass storage device.
     
    195198}
    196199
     200/** Get number of LUNs supported by mass storage device.
     201 *
     202 * @warning This function hides any error during the request
     203 * (typically that shall not be a problem).
     204 *
     205 * @param dev Mass storage device.
     206 * @return Number of LUNs.
     207 */
     208size_t usb_masstor_get_lun_count(usb_device_t *dev)
     209{
     210        int max_lun = usb_massstor_get_max_lun(dev);
     211        if (max_lun < 0) {
     212                max_lun = 1;
     213        } else {
     214                max_lun++;
     215        }
     216
     217        return (size_t) max_lun;
     218}
     219
    197220/**
    198221 * @}
  • uspace/drv/usbmast/mast.h

    rcf002dbf r5f0fe4e9  
    6262void usb_massstor_reset_recovery(usb_device_t *, size_t, size_t);
    6363int usb_massstor_get_max_lun(usb_device_t *);
     64size_t usb_masstor_get_lun_count(usb_device_t *);
    6465int usb_massstor_inquiry(usb_device_t *, size_t, size_t,
    6566    usb_massstor_inquiry_result_t *);
Note: See TracChangeset for help on using the changeset viewer.