Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[smscusb] Move non-inline register access functions to smscusb.c
Signed-off-by: Michael Brown <mcb30@ipxe.org>
  • Loading branch information
mcb30 committed Jul 10, 2017
1 parent 6a258d8 commit 340f033
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 49 deletions.
57 changes: 57 additions & 0 deletions src/drivers/net/smscusb.c
Expand Up @@ -42,6 +42,63 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
static struct profiler smscusb_intr_profiler __profiler =
{ .name = "smscusb.intr" };

/******************************************************************************
*
* Register access
*
******************************************************************************
*/

/**
* Write register (without byte-swapping)
*
* @v smscusb Smscusb device
* @v address Register address
* @v value Register value
* @ret rc Return status code
*/
int smscusb_raw_writel ( struct smscusb_device *smscusb, unsigned int address,
uint32_t value ) {
int rc;

/* Write register */
DBGCIO ( smscusb, "SMSCUSB %p [%03x] <= %08x\n",
smscusb, address, le32_to_cpu ( value ) );
if ( ( rc = usb_control ( smscusb->usb, SMSCUSB_REGISTER_WRITE, 0,
address, &value, sizeof ( value ) ) ) != 0 ) {
DBGC ( smscusb, "SMSCUSB %p could not write %03x: %s\n",
smscusb, address, strerror ( rc ) );
return rc;
}

return 0;
}

/**
* Read register (without byte-swapping)
*
* @v smscusb SMSC USB device
* @v address Register address
* @ret value Register value
* @ret rc Return status code
*/
int smscusb_raw_readl ( struct smscusb_device *smscusb, unsigned int address,
uint32_t *value ) {
int rc;

/* Read register */
if ( ( rc = usb_control ( smscusb->usb, SMSCUSB_REGISTER_READ, 0,
address, value, sizeof ( *value ) ) ) != 0 ) {
DBGC ( smscusb, "SMSCUSB %p could not read %03x: %s\n",
smscusb, address, strerror ( rc ) );
return rc;
}
DBGCIO ( smscusb, "SMSCUSB %p [%03x] => %08x\n",
smscusb, address, le32_to_cpu ( *value ) );

return 0;
}

/******************************************************************************
*
* EEPROM access
Expand Down
53 changes: 4 additions & 49 deletions src/drivers/net/smscusb.h
Expand Up @@ -170,30 +170,10 @@ struct smscusb_device {
uint32_t int_sts;
};

/**
* Write register (without byte-swapping)
*
* @v smscusb Smscusb device
* @v address Register address
* @v value Register value
* @ret rc Return status code
*/
static int smscusb_raw_writel ( struct smscusb_device *smscusb,
unsigned int address, uint32_t value ) {
int rc;

/* Write register */
DBGCIO ( smscusb, "SMSCUSB %p [%03x] <= %08x\n",
smscusb, address, le32_to_cpu ( value ) );
if ( ( rc = usb_control ( smscusb->usb, SMSCUSB_REGISTER_WRITE, 0,
address, &value, sizeof ( value ) ) ) != 0 ) {
DBGC ( smscusb, "SMSCUSB %p could not write %03x: %s\n",
smscusb, address, strerror ( rc ) );
return rc;
}

return 0;
}
extern int smscusb_raw_writel ( struct smscusb_device *smscusb,
unsigned int address, uint32_t value );
extern int smscusb_raw_readl ( struct smscusb_device *smscusb,
unsigned int address, uint32_t *value );

/**
* Write register
Expand All @@ -216,31 +196,6 @@ smscusb_writel ( struct smscusb_device *smscusb, unsigned int address,
return 0;
}

/**
* Read register (without byte-swapping)
*
* @v smscusb SMSC USB device
* @v address Register address
* @ret value Register value
* @ret rc Return status code
*/
static int smscusb_raw_readl ( struct smscusb_device *smscusb,
unsigned int address, uint32_t *value ) {
int rc;

/* Read register */
if ( ( rc = usb_control ( smscusb->usb, SMSCUSB_REGISTER_READ, 0,
address, value, sizeof ( *value ) ) ) != 0 ) {
DBGC ( smscusb, "SMSCUSB %p could not read %03x: %s\n",
smscusb, address, strerror ( rc ) );
return rc;
}
DBGCIO ( smscusb, "SMSCUSB %p [%03x] => %08x\n",
smscusb, address, le32_to_cpu ( *value ) );

return 0;
}

/**
* Read register
*
Expand Down

0 comments on commit 340f033

Please sign in to comment.