Fix build error when sys/io.h is not available

This commit is contained in:
Richard Hughes 2021-10-06 16:50:24 +01:00
parent 46c90f11a4
commit bc43adf020
2 changed files with 12 additions and 1 deletions

View File

@ -314,6 +314,9 @@ endif
if cc.has_header('sys/socket.h') if cc.has_header('sys/socket.h')
conf.set('HAVE_SOCKET_H', '1') conf.set('HAVE_SOCKET_H', '1')
endif endif
if cc.has_header('sys/io.h')
conf.set('HAVE_IO_H', '1')
endif
if cc.has_header('linux/ethtool.h') if cc.has_header('linux/ethtool.h')
conf.set('HAVE_ETHTOOL_H', '1') conf.set('HAVE_ETHTOOL_H', '1')
endif endif

View File

@ -5,10 +5,13 @@
*/ */
#include "config.h" #include "config.h"
#ifdef HAVE_IO_H
#include <sys/io.h> #include <sys/io.h>
#endif
#include "fu-flashrom-cmos.h" #include "fu-flashrom-cmos.h"
#ifdef HAVE_IO_H
static gboolean static gboolean
fu_flashrom_cmos_write(guint8 addr, guint8 val) fu_flashrom_cmos_write(guint8 addr, guint8 val)
{ {
@ -29,10 +32,12 @@ fu_flashrom_cmos_write(guint8 addr, guint8 val)
/* Check the read value against the written */ /* Check the read value against the written */
return (tmp == val); return (tmp == val);
} }
#endif
gboolean gboolean
fu_flashrom_cmos_reset(GError **error) fu_flashrom_cmos_reset(GError **error)
{ {
#ifdef HAVE_IO_H
/* Call ioperm() to grant us access to ports 0x70 and 0x71 */ /* Call ioperm() to grant us access to ports 0x70 and 0x71 */
if (ioperm(RTC_BASE_PORT, 2, TRUE) < 0) { if (ioperm(RTC_BASE_PORT, 2, TRUE) < 0) {
g_set_error_literal(error, g_set_error_literal(error,
@ -50,6 +55,9 @@ fu_flashrom_cmos_reset(GError **error)
} }
/* success */ /* success */
return TRUE; return TRUE;
#else
g_set_error_literal(error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, "no <sys/io.h> support");
return FALSE;
#endif
} }