[uaccess] Remove trivial uses of userptr_t

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown
2025-04-24 01:30:50 +01:00
parent 945df9b429
commit e8ffe2cd64
34 changed files with 69 additions and 86 deletions

View File

@@ -23,6 +23,7 @@
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#include <string.h>
#include <ipxe/uaccess.h>
#include <ipxe/settings.h>
@@ -47,12 +48,12 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
* @ret len Length of setting data, or negative error
*/
static int vram_fetch ( void *data, size_t len ) {
userptr_t vram = phys_to_virt ( VRAM_BASE );
const void *vram = phys_to_virt ( VRAM_BASE );
/* Copy video RAM */
if ( len > VRAM_LEN )
len = VRAM_LEN;
copy_from_user ( data, vram, 0, len );
memcpy ( data, vram, len );
return VRAM_LEN;
}

View File

@@ -54,7 +54,7 @@ const char *pxe_cmdline;
* @ret rc Return status code
*/
static int pxe_exec ( struct image *image ) {
userptr_t buffer = real_to_virt ( 0, 0x7c00 );
void *buffer = real_to_virt ( 0, 0x7c00 );
struct net_device *netdev;
int rc;

View File

@@ -87,7 +87,7 @@ real_to_virt ( unsigned int segment, unsigned int offset ) {
static inline __always_inline void
copy_to_real ( unsigned int dest_seg, unsigned int dest_off,
void *src, size_t n ) {
copy_to_user ( real_to_virt ( dest_seg, dest_off ), 0, src, n );
memcpy ( real_to_virt ( dest_seg, dest_off ), src, n );
}
/**
@@ -101,7 +101,7 @@ copy_to_real ( unsigned int dest_seg, unsigned int dest_off,
static inline __always_inline void
copy_from_real ( void *dest, unsigned int src_seg,
unsigned int src_off, size_t n ) {
copy_from_user ( dest, real_to_virt ( src_seg, src_off ), 0, n );
memcpy ( dest, real_to_virt ( src_seg, src_off ), n );
}
/**

View File

@@ -33,7 +33,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#include <stdint.h>
#include <string.h>
#include <stdlib.h>
#include <ipxe/uaccess.h>
#include <ipxe/dhcp.h>
#include <ipxe/fakedhcp.h>
#include <ipxe/device.h>
@@ -184,7 +183,7 @@ pxenv_get_cached_info ( struct s_PXENV_GET_CACHED_INFO *get_cached_info ) {
union pxe_cached_info *info;
unsigned int idx;
size_t len;
userptr_t buffer;
void *buffer;
DBGC ( &pxe_netdev, "PXENV_GET_CACHED_INFO %s to %04x:%04x+%x",
pxenv_get_cached_info_name ( get_cached_info->PacketType ),
@@ -245,7 +244,7 @@ pxenv_get_cached_info ( struct s_PXENV_GET_CACHED_INFO *get_cached_info ) {
DBGC ( &pxe_netdev, " buffer may be too short" );
buffer = real_to_virt ( get_cached_info->Buffer.segment,
get_cached_info->Buffer.offset );
copy_to_user ( buffer, 0, info, len );
memcpy ( buffer, info, len );
get_cached_info->BufferSize = len;
}

View File

@@ -33,7 +33,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#include <stdio.h>
#include <errno.h>
#include <byteswap.h>
#include <ipxe/uaccess.h>
#include <ipxe/in.h>
#include <ipxe/tftp.h>
#include <ipxe/iobuf.h>
@@ -49,7 +48,7 @@ struct pxe_tftp_connection {
/** Data transfer interface */
struct interface xfer;
/** Data buffer */
userptr_t buffer;
void *buffer;
/** Size of data buffer */
size_t size;
/** Starting offset of data buffer */
@@ -121,9 +120,8 @@ static int pxe_tftp_xfer_deliver ( struct pxe_tftp_connection *pxe_tftp,
( pxe_tftp->start + pxe_tftp->size ) );
rc = -ENOBUFS;
} else {
copy_to_user ( pxe_tftp->buffer,
( pxe_tftp->offset - pxe_tftp->start ),
iobuf->data, len );
memcpy ( ( pxe_tftp->buffer + pxe_tftp->offset -
pxe_tftp->start ), iobuf->data, len );
}
/* Calculate new buffer position */
@@ -385,7 +383,7 @@ static PXENV_EXIT_t pxenv_tftp_read ( struct s_PXENV_TFTP_READ *tftp_read ) {
while ( ( ( rc = pxe_tftp.rc ) == -EINPROGRESS ) &&
( pxe_tftp.offset == pxe_tftp.start ) )
step();
pxe_tftp.buffer = UNULL;
pxe_tftp.buffer = NULL;
tftp_read->BufferSize = ( pxe_tftp.offset - pxe_tftp.start );
tftp_read->PacketNumber = ++pxe_tftp.blkidx;
@@ -496,7 +494,7 @@ PXENV_EXIT_t pxenv_tftp_read_file ( struct s_PXENV_TFTP_READ_FILE
pxe_tftp.size = tftp_read_file->BufferSize;
while ( ( rc = pxe_tftp.rc ) == -EINPROGRESS )
step();
pxe_tftp.buffer = UNULL;
pxe_tftp.buffer = NULL;
tftp_read_file->BufferSize = pxe_tftp.max_offset;
/* Close TFTP file */

View File

@@ -9,7 +9,6 @@
#include <ipxe/iobuf.h>
#include <ipxe/xfer.h>
#include <ipxe/udp.h>
#include <ipxe/uaccess.h>
#include <ipxe/process.h>
#include <ipxe/netdevice.h>
#include <ipxe/malloc.h>
@@ -296,7 +295,7 @@ pxenv_udp_write ( struct s_PXENV_UDP_WRITE *pxenv_udp_write ) {
};
size_t len;
struct io_buffer *iobuf;
userptr_t buffer;
const void *buffer;
int rc;
DBG ( "PXENV_UDP_WRITE" );
@@ -330,7 +329,7 @@ pxenv_udp_write ( struct s_PXENV_UDP_WRITE *pxenv_udp_write ) {
}
buffer = real_to_virt ( pxenv_udp_write->buffer.segment,
pxenv_udp_write->buffer.offset );
copy_from_user ( iob_put ( iobuf, len ), buffer, 0, len );
memcpy ( iob_put ( iobuf, len ), buffer, len );
DBG ( " %04x:%04x+%x %d->%s:%d\n", pxenv_udp_write->buffer.segment,
pxenv_udp_write->buffer.offset, pxenv_udp_write->buffer_size,
@@ -400,7 +399,7 @@ static PXENV_EXIT_t pxenv_udp_read ( struct s_PXENV_UDP_READ *pxenv_udp_read ) {
struct pxe_udp_pseudo_header *pshdr;
uint16_t d_port_wanted = pxenv_udp_read->d_port;
uint16_t d_port;
userptr_t buffer;
void *buffer;
size_t len;
/* Try receiving a packet, if the queue is empty */
@@ -443,7 +442,7 @@ static PXENV_EXIT_t pxenv_udp_read ( struct s_PXENV_UDP_READ *pxenv_udp_read ) {
len = iob_len ( iobuf );
if ( len > pxenv_udp_read->buffer_size )
len = pxenv_udp_read->buffer_size;
copy_to_user ( buffer, 0, iobuf->data, len );
memcpy ( buffer, iobuf->data, len );
pxenv_udp_read->buffer_size = len;
/* Fill in source/dest information */

View File

@@ -198,7 +198,7 @@ static int cachedhcp_apply ( struct cached_dhcp_packet *cache,
* @ret rc Return status code
*/
int cachedhcp_record ( struct cached_dhcp_packet *cache, unsigned int vlan,
userptr_t data, size_t max_len ) {
const void *data, size_t max_len ) {
struct dhcp_packet *dhcppkt;
struct dhcp_packet *tmp;
struct dhcphdr *dhcphdr;
@@ -216,7 +216,7 @@ int cachedhcp_record ( struct cached_dhcp_packet *cache, unsigned int vlan,
return -ENOMEM;
}
dhcphdr = ( ( ( void * ) dhcppkt ) + sizeof ( *dhcppkt ) );
copy_from_user ( dhcphdr, data, 0, max_len );
memcpy ( dhcphdr, data, max_len );
dhcppkt_init ( dhcppkt, dhcphdr, max_len );
/* Shrink packet to required length. If reallocation fails,

View File

@@ -136,7 +136,7 @@ static void * dma_op_umalloc ( struct dma_device *dma,
struct dma_operations *op = dma->op;
if ( ! op )
return UNULL;
return NULL;
return op->umalloc ( dma, map, len, align );
}

View File

@@ -1037,7 +1037,7 @@ static int fdt_urealloc ( struct fdt *fdt, size_t len ) {
assert ( len >= fdt->used );
/* Attempt reallocation */
new = urealloc ( virt_to_user ( fdt->raw ), len );
new = urealloc ( fdt->raw, len );
if ( ! new ) {
DBGC ( fdt, "FDT could not reallocate from +%#04zx to "
"+%#04zx\n", fdt->len, len );
@@ -1129,7 +1129,7 @@ int fdt_create ( struct fdt_header **hdr, const char *cmdline ) {
return 0;
err_bootargs:
ufree ( virt_to_user ( fdt.raw ) );
ufree ( fdt.raw );
err_alloc:
err_image:
return rc;
@@ -1143,7 +1143,7 @@ int fdt_create ( struct fdt_header **hdr, const char *cmdline ) {
void fdt_remove ( struct fdt_header *hdr ) {
/* Free modifiable copy */
ufree ( virt_to_user ( hdr ) );
ufree ( hdr );
}
/* Drag in objects via fdt_describe() */

View File

@@ -2119,7 +2119,7 @@ static void arbel_stop_firmware ( struct arbel *arbel ) {
DBGC ( arbel, "Arbel %p FATAL could not stop firmware: %s\n",
arbel, strerror ( rc ) );
/* Leak memory and return; at least we avoid corruption */
arbel->firmware_area = UNULL;
arbel->firmware_area = NULL;
return;
}
}

View File

@@ -10,7 +10,6 @@
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#include <stdint.h>
#include <ipxe/uaccess.h>
#include <ipxe/ib_packet.h>
#include "mlx_bitops.h"
#include "MT25218_PRM.h"
@@ -492,7 +491,7 @@ struct arbel {
* final teardown, in order to avoid memory map changes at
* runtime.
*/
userptr_t firmware_area;
void *firmware_area;
/** ICM size */
size_t icm_len;
/** ICM AUX size */
@@ -503,7 +502,7 @@ struct arbel {
* final teardown, in order to avoid memory map changes at
* runtime.
*/
userptr_t icm;
void *icm;
/** Offset within ICM of doorbell records */
size_t db_rec_offset;
/** Doorbell records */

View File

@@ -52,7 +52,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
struct golan_page {
struct list_head list;
userptr_t addr;
void *addr;
};
static void golan_free_fw_areas ( struct golan *golan ) {
@@ -61,7 +61,7 @@ static void golan_free_fw_areas ( struct golan *golan ) {
for (i = 0; i < GOLAN_FW_AREAS_NUM; i++) {
if ( golan->fw_areas[i].area ) {
ufree ( golan->fw_areas[i].area );
golan->fw_areas[i].area = UNULL;
golan->fw_areas[i].area = NULL;
}
}
}
@@ -75,7 +75,7 @@ static int golan_init_fw_areas ( struct golan *golan ) {
}
for (i = 0; i < GOLAN_FW_AREAS_NUM; i++)
golan->fw_areas[i].area = UNULL;
golan->fw_areas[i].area = NULL;
return rc;
@@ -448,12 +448,12 @@ static inline int golan_provide_pages ( struct golan *golan , uint32_t pages
int size_ibox = 0;
int size_obox = 0;
int rc = 0;
userptr_t next_page_addr = UNULL;
void *next_page_addr = NULL;
DBGC(golan, "%s\n", __FUNCTION__);
if ( ! fw_area->area ) {
fw_area->area = umalloc ( GOLAN_PAGE_SIZE * pages );
if ( fw_area->area == UNULL ) {
if ( fw_area->area == NULL ) {
rc = -ENOMEM;
DBGC (golan ,"Failed to allocated %d pages \n",pages);
goto err_golan_alloc_fw_area;
@@ -467,7 +467,7 @@ static inline int golan_provide_pages ( struct golan *golan , uint32_t pages
unsigned i, j;
struct golan_cmd_layout *cmd;
struct golan_manage_pages_inbox *in;
userptr_t addr = 0;
void *addr = NULL;
mailbox = GET_INBOX(golan, MEM_MBOX);
size_ibox = sizeof(struct golan_manage_pages_inbox) + (pas_num * GOLAN_PAS_SIZE);

View File

@@ -121,7 +121,7 @@ struct golan_firmware_area {
* final teardown, in order to avoid memory map changes at
* runtime.
*/
userptr_t area;
void *area;
};
/* Queue Pair */
#define GOLAN_SEND_WQE_BB_SIZE 64

View File

@@ -2422,7 +2422,7 @@ static void hermon_stop_firmware ( struct hermon *hermon ) {
DBGC ( hermon, "Hermon %p FATAL could not stop firmware: %s\n",
hermon, strerror ( rc ) );
/* Leak memory and return; at least we avoid corruption */
hermon->firmware_area = UNULL;
hermon->firmware_area = NULL;
return;
}
}

View File

@@ -10,7 +10,6 @@
FILE_LICENCE ( GPL2_OR_LATER );
#include <stdint.h>
#include <ipxe/uaccess.h>
#include <ipxe/ib_packet.h>
#include <ipxe/bofm.h>
#include <ipxe/nvsvpd.h>
@@ -887,7 +886,7 @@ struct hermon {
* final teardown, in order to avoid memory map changes at
* runtime.
*/
userptr_t firmware_area;
void *firmware_area;
/** ICM map */
struct hermon_icm_map icm_map[HERMON_ICM_NUM_REGIONS];
/** ICM size */
@@ -900,7 +899,7 @@ struct hermon {
* final teardown, in order to avoid memory map changes at
* runtime.
*/
userptr_t icm;
void *icm;
/** Event queue */
struct hermon_event_queue eq;

View File

@@ -177,7 +177,7 @@ struct nii_nic {
size_t mtu;
/** Hardware transmit/receive buffer */
userptr_t buffer;
void *buffer;
/** Hardware transmit/receive buffer length */
size_t buffer_len;

View File

@@ -622,7 +622,7 @@ static int netvsc_buffer_copy ( struct vmbus_xfer_pages *pages, void *data,
return -ERANGE;
/* Copy data from buffer */
copy_from_user ( data, buffer->data, offset, len );
memcpy ( data, ( buffer->data + offset ), len );
return 0;
}

View File

@@ -305,7 +305,7 @@ struct netvsc_buffer {
/** Buffer length */
size_t len;
/** Buffer */
userptr_t data;
void *data;
/** GPADL ID */
unsigned int gpadl;
};

View File

@@ -11,7 +11,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#include <assert.h>
#include <ipxe/pci.h>
#include <ipxe/uaccess.h>
#include <ipxe/usb.h>
/** Minimum alignment required for data structures
@@ -1054,7 +1053,7 @@ struct xhci_scratchpad {
/** Number of page-sized scratchpad buffers */
unsigned int count;
/** Scratchpad buffer area */
userptr_t buffer;
void *buffer;
/** Buffer DMA mapping */
struct dma_mapping buffer_map;
/** Scratchpad array */

View File

@@ -57,7 +57,7 @@ struct errortab segment_errors[] __errortab = {
* @v memsz Size of the segment
* @ret rc Return status code
*/
int prep_segment ( userptr_t segment, size_t filesz, size_t memsz ) {
int prep_segment ( void *segment, size_t filesz, size_t memsz ) {
struct memory_map memmap;
physaddr_t start = virt_to_phys ( segment );
physaddr_t mid = ( start + filesz );

View File

@@ -10,7 +10,6 @@
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#include <stddef.h>
#include <ipxe/uaccess.h>
struct net_device;
struct cached_dhcp_packet;
@@ -20,7 +19,7 @@ extern struct cached_dhcp_packet cached_proxydhcp;
extern struct cached_dhcp_packet cached_pxebs;
extern int cachedhcp_record ( struct cached_dhcp_packet *cache,
unsigned int vlan, userptr_t data,
unsigned int vlan, const void *data,
size_t max_len );
extern void cachedhcp_recycle ( struct net_device *netdev );

View File

@@ -9,8 +9,6 @@
FILE_LICENCE ( GPL2_OR_LATER );
#include <ipxe/uaccess.h>
extern int linux_sysfs_read ( const char *filename, userptr_t *data );
extern int linux_sysfs_read ( const char *filename, void **data );
#endif /* _IPXE_LINUX_SYSFS_H */

View File

@@ -10,8 +10,7 @@
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#include <stdint.h>
#include <ipxe/uaccess.h>
extern size_t largest_memblock ( userptr_t *start );
extern size_t largest_memblock ( void **start );
#endif /* _IPXE_MEMBLOCK_H */

View File

@@ -10,8 +10,8 @@
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#include <ipxe/uaccess.h>
#include <stdint.h>
extern int prep_segment ( userptr_t segment, size_t filesz, size_t memsz );
extern int prep_segment ( void *segment, size_t filesz, size_t memsz );
#endif /* _IPXE_SEGMENT_H */

View File

@@ -13,7 +13,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#include <ipxe/uuid.h>
#include <ipxe/device.h>
#include <ipxe/tables.h>
#include <ipxe/uaccess.h>
#include <ipxe/iobuf.h>
#include <ipxe/hyperv.h>
@@ -634,7 +633,7 @@ vmbus_gpadl_is_obsolete ( unsigned int gpadl ) {
return ( gpadl <= vmbus_obsolete_gpadl );
}
extern int vmbus_establish_gpadl ( struct vmbus_device *vmdev, userptr_t data,
extern int vmbus_establish_gpadl ( struct vmbus_device *vmdev, void *data,
size_t len );
extern int vmbus_gpadl_teardown ( struct vmbus_device *vmdev,
unsigned int gpadl );

View File

@@ -110,8 +110,7 @@ static int efi_block_rw ( struct san_device *sandev, uint64_t lba,
}
/* Read from / write to block device */
if ( ( rc = sandev_rw ( sandev, lba, count,
virt_to_user ( data ) ) ) != 0 ) {
if ( ( rc = sandev_rw ( sandev, lba, count, data ) ) != 0 ) {
DBGC ( sandev->drive, "EFIBLK %#02x I/O failed: %s\n",
sandev->drive, strerror ( rc ) );
return rc;

View File

@@ -284,8 +284,7 @@ static int efi_bofm_start ( struct efi_device *efidev ) {
efi_handle_name ( device ) );
DBGC2_HD ( device, bofmtab2, bofmtab2->Parameters.Length );
}
bofmrc = bofm ( virt_to_user ( bofmtab2 ? bofmtab2 : bofmtab ),
&efipci.pci );
bofmrc = bofm ( ( bofmtab2 ? bofmtab2 : bofmtab ), &efipci.pci );
DBGC ( device, "EFIBOFM %s status %08x\n",
efi_handle_name ( device ), bofmrc );
DBGC2 ( device, "EFIBOFM %s version 1 after processing:\n",

View File

@@ -72,8 +72,7 @@ int efi_cachedhcp_record ( EFI_HANDLE device,
/* Record DHCPACK, if present */
if ( mode->DhcpAckReceived &&
( ( rc = cachedhcp_record ( &cached_dhcpack, vlan,
virt_to_user ( &mode->DhcpAck ),
( ( rc = cachedhcp_record ( &cached_dhcpack, vlan, &mode->DhcpAck,
sizeof ( mode->DhcpAck ) ) ) != 0 ) ) {
DBGC ( device, "EFI %s could not record DHCPACK: %s\n",
efi_handle_name ( device ), strerror ( rc ) );
@@ -83,7 +82,7 @@ int efi_cachedhcp_record ( EFI_HANDLE device,
/* Record ProxyDHCPOFFER, if present */
if ( mode->ProxyOfferReceived &&
( ( rc = cachedhcp_record ( &cached_proxydhcp, vlan,
virt_to_user ( &mode->ProxyOffer ),
&mode->ProxyOffer,
sizeof ( mode->ProxyOffer ) ) ) != 0)){
DBGC ( device, "EFI %s could not record ProxyDHCPOFFER: %s\n",
efi_handle_name ( device ), strerror ( rc ) );
@@ -92,9 +91,8 @@ int efi_cachedhcp_record ( EFI_HANDLE device,
/* Record PxeBSACK, if present */
if ( mode->PxeReplyReceived &&
( ( rc = cachedhcp_record ( &cached_pxebs, vlan,
virt_to_user ( &mode->PxeReply ),
sizeof ( mode->PxeReply ) ) ) != 0)){
( ( rc = cachedhcp_record ( &cached_pxebs, vlan, &mode->PxeReply,
sizeof ( mode->PxeReply ) ) ) != 0 )){
DBGC ( device, "EFI %s could not record PXEBSACK: %s\n",
efi_handle_name ( device ), strerror ( rc ) );
return rc;

View File

@@ -177,12 +177,12 @@ static size_t efi_file_len ( struct efi_file *file ) {
* Read chunk of EFI file
*
* @v reader EFI file reader
* @v data Input data, or UNULL to zero-fill
* @v data Input data, or NULL to zero-fill
* @v len Length of input data
* @ret len Length of output data
*/
static size_t efi_file_read_chunk ( struct efi_file_reader *reader,
userptr_t data, size_t len ) {
const void *data, size_t len ) {
struct efi_file *file = reader->file;
size_t offset;
@@ -203,7 +203,7 @@ static size_t efi_file_read_chunk ( struct efi_file_reader *reader,
/* Copy or zero output data */
if ( data ) {
copy_from_user ( reader->data, data, offset, len );
memcpy ( reader->data, ( data + offset ), len );
} else {
memset ( reader->data, 0, len );
}
@@ -262,7 +262,7 @@ static size_t efi_file_read_initrd ( struct efi_file_reader *reader ) {
efi_file_name ( file ), reader->pos,
( reader->pos + pad_len ) );
}
len += efi_file_read_chunk ( reader, UNULL, pad_len );
len += efi_file_read_chunk ( reader, NULL, pad_len );
/* Read CPIO header(s), if applicable */
name = cpio_name ( image );
@@ -274,13 +274,10 @@ static size_t efi_file_read_initrd ( struct efi_file_reader *reader ) {
efi_file_name ( file ), reader->pos,
( reader->pos + cpio_len + pad_len ),
image->name );
len += efi_file_read_chunk ( reader,
virt_to_user ( &cpio ),
len += efi_file_read_chunk ( reader, &cpio,
sizeof ( cpio ) );
len += efi_file_read_chunk ( reader,
virt_to_user ( name ),
name_len );
len += efi_file_read_chunk ( reader, UNULL, pad_len );
len += efi_file_read_chunk ( reader, name, name_len );
len += efi_file_read_chunk ( reader, NULL, pad_len );
}
/* Read file data */

View File

@@ -273,7 +273,7 @@ static int vmbus_negotiate_version ( struct hv_hypervisor *hv ) {
* @v len Length of data buffer
* @ret gpadl GPADL ID, or negative error
*/
int vmbus_establish_gpadl ( struct vmbus_device *vmdev, userptr_t data,
int vmbus_establish_gpadl ( struct vmbus_device *vmdev, void *data,
size_t len ) {
struct hv_hypervisor *hv = vmdev->hv;
struct vmbus *vmbus = hv->vmbus;
@@ -442,7 +442,7 @@ int vmbus_open ( struct vmbus_device *vmdev,
memset ( ring, 0, len );
/* Establish GPADL for ring buffer */
gpadl = vmbus_establish_gpadl ( vmdev, virt_to_user ( ring ), len );
gpadl = vmbus_establish_gpadl ( vmdev, ring, len );
if ( gpadl < 0 ) {
rc = gpadl;
goto err_establish;

View File

@@ -21,6 +21,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <ipxe/linux_api.h>
#include <ipxe/linux_sysfs.h>

View File

@@ -19,6 +19,7 @@
FILE_LICENCE ( GPL2_OR_LATER );
#include <string.h>
#include <errno.h>
#include <ipxe/linux_api.h>
#include <ipxe/linux_sysfs.h>

View File

@@ -42,8 +42,8 @@ FILE_LICENCE ( GPL2_OR_LATER );
* @v data Data to fill in
* @ret len Length read, or negative error
*/
int linux_sysfs_read ( const char *filename, userptr_t *data ) {
userptr_t tmp;
int linux_sysfs_read ( const char *filename, void **data ) {
void *tmp;
ssize_t read;
size_t len;
int fd;
@@ -59,7 +59,7 @@ int linux_sysfs_read ( const char *filename, userptr_t *data ) {
}
/* Read file */
for ( *data = UNULL, len = 0 ; ; len += read ) {
for ( *data = NULL, len = 0 ; ; len += read ) {
/* (Re)allocate space */
tmp = urealloc ( *data, ( len + LINUX_SYSFS_BLKSIZE ) );

View File

@@ -26,7 +26,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <ipxe/uaccess.h>
#include <ipxe/init.h>
#include <ipxe/pci.h>
#include <ipxe/ethernet.h>
@@ -111,7 +110,7 @@ void bofm_test ( struct pci_device *pci ) {
printf ( "BOFMTEST performing harvest\n" );
bofmtab_harvest.en.busdevfn = pci->busdevfn;
DBG_HDA ( 0, &bofmtab_harvest, sizeof ( bofmtab_harvest ) );
bofmrc = bofm ( virt_to_user ( &bofmtab_harvest ), pci );
bofmrc = bofm ( &bofmtab_harvest, pci );
printf ( "BOFMTEST harvest result %08x\n", bofmrc );
if ( bofmtab_harvest.en.options & BOFM_EN_HVST ) {
printf ( "BOFMTEST harvested MAC address %s\n",
@@ -125,7 +124,7 @@ void bofm_test ( struct pci_device *pci ) {
printf ( "BOFMTEST performing update\n" );
bofmtab_update.en.busdevfn = pci->busdevfn;
DBG_HDA ( 0, &bofmtab_update, sizeof ( bofmtab_update ) );
bofmrc = bofm ( virt_to_user ( &bofmtab_update ), pci );
bofmrc = bofm ( &bofmtab_update, pci );
printf ( "BOFMTEST update result %08x\n", bofmrc );
if ( bofmtab_update.en.options & BOFM_EN_CSM_SUCCESS ) {
printf ( "BOFMTEST updated MAC address to %s\n",