Move static usbsn into serdev structure, remove serno access function
This commit is contained in:
parent
8d8157bf8b
commit
0a883973a2
|
@ -1569,9 +1569,9 @@ int jtag3_open_common(PROGRAMMER *pgm, const char *port) {
|
||||||
pmsg_notice("found CMSIS-DAP compliant device, using EDBG protocol\n");
|
pmsg_notice("found CMSIS-DAP compliant device, using EDBG protocol\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get USB serial number function if function pointer is present
|
// Copy over pointer to USB serial number function
|
||||||
if (serial_serno)
|
if (serdev && serdev->usbsn)
|
||||||
pgm->usbsn = serial_serno();
|
pgm->usbsn = serdev->usbsn;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* drain any extraneous input
|
* drain any extraneous input
|
||||||
|
|
|
@ -649,7 +649,6 @@ union pinfo
|
||||||
struct serial_device {
|
struct serial_device {
|
||||||
// open should return -1 on error, other values on success
|
// open should return -1 on error, other values on success
|
||||||
int (*open)(const char *port, union pinfo pinfo, union filedescriptor *fd);
|
int (*open)(const char *port, union pinfo pinfo, union filedescriptor *fd);
|
||||||
const char *(*serno)();
|
|
||||||
int (*setparams)(const union filedescriptor *fd, long baud, unsigned long cflags);
|
int (*setparams)(const union filedescriptor *fd, long baud, unsigned long cflags);
|
||||||
void (*close)(union filedescriptor *fd);
|
void (*close)(union filedescriptor *fd);
|
||||||
|
|
||||||
|
@ -659,6 +658,7 @@ struct serial_device {
|
||||||
|
|
||||||
int (*set_dtr_rts)(const union filedescriptor *fd, int is_on);
|
int (*set_dtr_rts)(const union filedescriptor *fd, int is_on);
|
||||||
|
|
||||||
|
const char *usbsn;
|
||||||
int flags;
|
int flags;
|
||||||
#define SERDEV_FL_NONE 0x0000 /* no flags */
|
#define SERDEV_FL_NONE 0x0000 /* no flags */
|
||||||
#define SERDEV_FL_CANSETSPEED 0x0001 /* device can change speed */
|
#define SERDEV_FL_CANSETSPEED 0x0001 /* device can change speed */
|
||||||
|
@ -672,7 +672,6 @@ extern struct serial_device avrdoper_serdev;
|
||||||
extern struct serial_device usbhid_serdev;
|
extern struct serial_device usbhid_serdev;
|
||||||
|
|
||||||
#define serial_open (serdev->open)
|
#define serial_open (serdev->open)
|
||||||
#define serial_serno (serdev->serno)
|
|
||||||
#define serial_setparams (serdev->setparams)
|
#define serial_setparams (serdev->setparams)
|
||||||
#define serial_close (serdev->close)
|
#define serial_close (serdev->close)
|
||||||
#define serial_send (serdev->send)
|
#define serial_send (serdev->send)
|
||||||
|
|
|
@ -1578,9 +1578,9 @@ static int stk500v2_open(PROGRAMMER *pgm, const char *port) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get USB serial number function if function pointer is present
|
// Copy over pointer to USB serial number function
|
||||||
if (serial_serno)
|
if (serdev && serdev->usbsn)
|
||||||
pgm->usbsn = serial_serno();
|
pgm->usbsn = serdev->usbsn;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* drain any extraneous input
|
* drain any extraneous input
|
||||||
|
|
|
@ -42,12 +42,6 @@
|
||||||
|
|
||||||
#include "usbdevs.h"
|
#include "usbdevs.h"
|
||||||
|
|
||||||
static const char *usbsn = "";
|
|
||||||
|
|
||||||
const char *usbhid_get_serno() {
|
|
||||||
return usbsn;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The "baud" parameter is meaningless for USB devices, so we reuse it
|
* The "baud" parameter is meaningless for USB devices, so we reuse it
|
||||||
* to pass the desired USB device ID.
|
* to pass the desired USB device ID.
|
||||||
|
@ -142,7 +136,8 @@ static int usbhid_open(const char *port, union pinfo pinfo, union filedescriptor
|
||||||
if (n) {
|
if (n) {
|
||||||
char *cn = cfg_malloc(__func__, n);
|
char *cn = cfg_malloc(__func__, n);
|
||||||
if (wcstombs(cn, sn, n) != (size_t) -1)
|
if (wcstombs(cn, sn, n) != (size_t) -1)
|
||||||
usbsn = cache_string(cn);
|
if(serdev)
|
||||||
|
serdev->usbsn = cache_string(cn);
|
||||||
free(cn);
|
free(cn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -319,7 +314,6 @@ static int usbhid_drain(const union filedescriptor *fd, int display) {
|
||||||
*/
|
*/
|
||||||
struct serial_device usbhid_serdev = {
|
struct serial_device usbhid_serdev = {
|
||||||
.open = usbhid_open,
|
.open = usbhid_open,
|
||||||
.serno = usbhid_get_serno,
|
|
||||||
.close = usbhid_close,
|
.close = usbhid_close,
|
||||||
.send = usbhid_send,
|
.send = usbhid_send,
|
||||||
.recv = usbhid_recv,
|
.recv = usbhid_recv,
|
||||||
|
|
|
@ -58,12 +58,6 @@ static int buflen = -1, bufptr;
|
||||||
|
|
||||||
static int usb_interface;
|
static int usb_interface;
|
||||||
|
|
||||||
static const char *usbsn = "";
|
|
||||||
|
|
||||||
const char *usbdev_get_serno() {
|
|
||||||
return usbsn;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The "baud" parameter is meaningless for USB devices, so we reuse it
|
* The "baud" parameter is meaningless for USB devices, so we reuse it
|
||||||
* to pass the desired USB device ID.
|
* to pass the desired USB device ID.
|
||||||
|
@ -144,7 +138,8 @@ static int usbdev_open(const char *port, union pinfo pinfo, union filedescriptor
|
||||||
else
|
else
|
||||||
strcpy(string, "[unknown]");
|
strcpy(string, "[unknown]");
|
||||||
}
|
}
|
||||||
usbsn = cache_string(string);
|
if(serdev)
|
||||||
|
serdev->usbsn = cache_string(string);
|
||||||
if (usb_get_string_simple(udev,
|
if (usb_get_string_simple(udev,
|
||||||
dev->descriptor.iProduct,
|
dev->descriptor.iProduct,
|
||||||
product, sizeof(product)) < 0)
|
product, sizeof(product)) < 0)
|
||||||
|
@ -582,7 +577,6 @@ static int usbdev_drain(const union filedescriptor *fd, int display)
|
||||||
struct serial_device usb_serdev =
|
struct serial_device usb_serdev =
|
||||||
{
|
{
|
||||||
.open = usbdev_open,
|
.open = usbdev_open,
|
||||||
.serno = usbdev_get_serno,
|
|
||||||
.close = usbdev_close,
|
.close = usbdev_close,
|
||||||
.send = usbdev_send,
|
.send = usbdev_send,
|
||||||
.recv = usbdev_recv,
|
.recv = usbdev_recv,
|
||||||
|
@ -596,7 +590,6 @@ struct serial_device usb_serdev =
|
||||||
struct serial_device usb_serdev_frame =
|
struct serial_device usb_serdev_frame =
|
||||||
{
|
{
|
||||||
.open = usbdev_open,
|
.open = usbdev_open,
|
||||||
.serno = usbdev_get_serno,
|
|
||||||
.close = usbdev_close,
|
.close = usbdev_close,
|
||||||
.send = usbdev_send,
|
.send = usbdev_send,
|
||||||
.recv = usbdev_recv_frame,
|
.recv = usbdev_recv_frame,
|
||||||
|
|
Loading…
Reference in New Issue