X-Git-Url: https://jxself.org/git/?p=linux-libre-firmware.git;a=blobdiff_plain;f=atusb%2Fsernum.c;fp=atusb%2Fsernum.c;h=41e434c75eeb0b725ccb27ca574e1780562d4c5f;hp=0000000000000000000000000000000000000000;hb=dd4bc9ff49b9a7075e579fdd62fd930d27a9a7df;hpb=c164bf7f87f9081fee7e1a186dd7a87a9a020b9e diff --git a/atusb/sernum.c b/atusb/sernum.c new file mode 100644 index 0000000..41e434c --- /dev/null +++ b/atusb/sernum.c @@ -0,0 +1,47 @@ +/* + * fw/sernum.c - ATUSB serial number + * + * Written 2008-2011, 2013 by Werner Almesberger + * Copyright 2008-2011, 2013 Werner Almesberger + * + * This program is free software; you can redistribute it and/or modify + * 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. + */ + + +#include +#include + +#include "usb.h" + +#include "board.h" +#include "sernum.h" + + +static const uint8_t string_descriptor_0[] = { + 4, /* blength */ + USB_DT_STRING, /* bDescriptorType */ + LE(USB_LANGID_ENGLISH_US) /* wLANGID[0] */ +}; + + +bool sernum_get_descr(uint8_t type, uint8_t index, const uint8_t **reply, + uint8_t *size) +{ + if (type != USB_DT_STRING) + return 0; + switch (index) { + case 0: + *reply = string_descriptor_0; + *size = sizeof(string_descriptor_0); + return 1; + case 1: + *reply = board_sernum; + *size = sizeof(board_sernum); + return 1; + default: + return 0; + } +}