option.c revision 181368a3b26329f77a93b06a5d2b285d4bf5f8e3
/*
* Modem mode switcher
*
* Copyright (C) 2008 Dan Williams <dcbw@redhat.com>
* Copyright (C) 2008 Peter Henn <support@option.com>
*
* Heavily based on the 'ozerocdoff' tool by Peter Henn.
*
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details:
*/
#include <usb.h>
#include "utils.h"
#include "option.h"
#define USB_ENDPOINT_XFER_BULK 2
#define USB_ENDPOINT_DIR_MASK 0x80
#define USB_DIR_OUT 0 /* to device */
struct usb_device *
{
struct usb_device *dev;
debug ("Found mass storage device:");
return dev;
}
}
}
}
return NULL;
}
static int
{
int i;
}
return 0;
}
return -1;
}
int
{
const char const rezero_cbw[] = {
0x55, 0x53, 0x42, 0x43, /* bulk command signature (LE) */
0x78, 0x56, 0x34, 0x12, /* bulk command host tag */
0x01, 0x00, 0x00, 0x00, /* bulk command data transfer length (LE) */
0x80, /* flags: direction data-in */
0x00, /* LUN */
0x06, /* SCSI command length */
0x01, /* SCSI command: REZERO */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* filler */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
char buffer[256];
/* Find the device's bulk in and out endpoints */
goto out;
}
if (ret != 0) {
goto out;
}
/* Let the mass storage device settle */
sleep (1);
/* Send the modeswitch command */
if (ret < 0)
return ret;
/* Some devices need to be read from */
out:
return ret;
}