In order to remove the exit call in the get_ip_perm function the
function needs to return a value indicating success or failure. This
patch adds such return value and make all callers check for it.
Signed-off-by: Niklas Söderlund <niso(a)kth.se>
---
atahpt.c | 3 ++-
drkaiser.c | 3 ++-
gfxnvidia.c | 3 ++-
hwaccess.c | 17 +++++++++++------
internal.c | 4 +++-
nic3com.c | 3 ++-
nicintel.c | 3 ++-
nicintel_spi.c | 3 ++-
nicnatsemi.c | 3 ++-
nicrealtek.c | 3 ++-
ogp_spi.c | 3 ++-
programmer.h | 2 +-
rayer_spi.c | 3 ++-
satamv.c | 3 ++-
satasii.c | 3 ++-
15 files changed, 39 insertions(+), 20 deletions(-)
diff --git a/atahpt.c b/atahpt.c
index 4234f6d..b692b88 100644
--- a/atahpt.c
+++ b/atahpt.c
@@ -67,7 +67,8 @@ int atahpt_init(void)
{
uint32_t reg32;
- get_io_perms();
+ if (get_io_perms())
+ return 1;
io_base_addr = pcidev_init(PCI_BASE_ADDRESS_4, ata_hpt);
diff --git a/drkaiser.c b/drkaiser.c
index 362db57..d4b6120 100644
--- a/drkaiser.c
+++ b/drkaiser.c
@@ -67,7 +67,8 @@ int drkaiser_init(void)
{
uint32_t addr;
- get_io_perms();
+ if (get_io_perms())
+ return 1;
addr = pcidev_init(PCI_BASE_ADDRESS_2, drkaiser_pcidev);
diff --git a/gfxnvidia.c b/gfxnvidia.c
index b8750b3..457172d 100644
--- a/gfxnvidia.c
+++ b/gfxnvidia.c
@@ -91,7 +91,8 @@ int gfxnvidia_init(void)
{
uint32_t reg32;
- get_io_perms();
+ if (get_io_perms())
+ return 1;
io_base_addr = pcidev_init(PCI_BASE_ADDRESS_0, gfx_nvidia);
diff --git a/hwaccess.c b/hwaccess.c
index 571edd7..b54fbdf 100644
--- a/hwaccess.c
+++ b/hwaccess.c
@@ -44,11 +44,11 @@ static inline void sync_primitive(void)
int io_fd;
#endif
-void get_io_perms(void)
+int get_io_perms(void)
{
#if defined(__DJGPP__) || defined(__LIBPAYLOAD__)
/* We have full permissions by default. */
- return;
+ return 0;
#else
#if defined (__sun) && (defined(__i386) || defined(__amd64))
if (sysi86(SI86V86, V86SC_IOPL, PS_IOPL) != 0) {
@@ -64,8 +64,10 @@ void get_io_perms(void)
"and reboot, or reboot into \n");
msg_perr("single user mode.\n");
#endif
- exit(1);
+ return 1;
}
+
+ return 0;
#endif
}
@@ -88,8 +90,9 @@ static inline void sync_primitive(void)
}
/* PCI port I/O is not yet implemented on PowerPC. */
-void get_io_perms(void)
+int get_io_perms(void)
{
+ return 0;
}
/* PCI port I/O is not yet implemented on PowerPC. */
@@ -107,8 +110,9 @@ static inline void sync_primitive(void)
}
/* PCI port I/O is not yet implemented on MIPS. */
-void get_io_perms(void)
+int get_io_perms(void)
{
+ return 0;
}
/* PCI port I/O is not yet implemented on MIPS. */
@@ -122,8 +126,9 @@ static inline void sync_primitive(void)
{
}
-void get_io_perms(void)
+int get_io_perms(void)
{
+ return 0;
}
void release_io_perms(void)
diff --git a/internal.c b/internal.c
index 75e526b..ec7cba1 100644
--- a/internal.c
+++ b/internal.c
@@ -225,7 +225,9 @@ int internal_init(void)
}
free(arg);
- get_io_perms();
+ if (get_io_perms())
+ return 1;
+
if (register_shutdown(internal_shutdown, NULL))
return 1;
diff --git a/nic3com.c b/nic3com.c
index 473c7b1..4df720f 100644
--- a/nic3com.c
+++ b/nic3com.c
@@ -87,7 +87,8 @@ static int nic3com_shutdown(void *data)
int nic3com_init(void)
{
- get_io_perms();
+ if (get_io_perms())
+ return 1;
io_base_addr = pcidev_init(PCI_BASE_ADDRESS_0, nics_3com);
diff --git a/nicintel.c b/nicintel.c
index 0415f46..f2d4529 100644
--- a/nicintel.c
+++ b/nicintel.c
@@ -74,7 +74,8 @@ int nicintel_init(void)
/* Needed only for PCI accesses on some platforms.
* FIXME: Refactor that into get_mem_perms/get_io_perms/get_pci_perms?
*/
- get_io_perms();
+ if (get_io_perms())
+ return 1;
/* No need to check for errors, pcidev_init() will not return in case
* of errors.
diff --git a/nicintel_spi.c b/nicintel_spi.c
index 4ff8554..7eb3af3 100644
--- a/nicintel_spi.c
+++ b/nicintel_spi.c
@@ -167,7 +167,8 @@ int nicintel_spi_init(void)
{
uint32_t tmp;
- get_io_perms();
+ if (get_io_perms())
+ return 1;
io_base_addr = pcidev_init(PCI_BASE_ADDRESS_0, nics_intel_spi);
diff --git a/nicnatsemi.c b/nicnatsemi.c
index eb2a7f8..c39637a 100644
--- a/nicnatsemi.c
+++ b/nicnatsemi.c
@@ -59,7 +59,8 @@ static int nicnatsemi_shutdown(void *data)
int nicnatsemi_init(void)
{
- get_io_perms();
+ if (get_io_perms())
+ return 1;
io_base_addr = pcidev_init(PCI_BASE_ADDRESS_0, nics_natsemi);
diff --git a/nicrealtek.c b/nicrealtek.c
index 32aa434..f808e06 100644
--- a/nicrealtek.c
+++ b/nicrealtek.c
@@ -61,7 +61,8 @@ static int nicrealtek_shutdown(void *data)
int nicrealtek_init(void)
{
- get_io_perms();
+ if (get_io_perms())
+ return 1;
io_base_addr = pcidev_init(PCI_BASE_ADDRESS_0, nics_realtek);
diff --git a/ogp_spi.c b/ogp_spi.c
index 812420c..8502847 100644
--- a/ogp_spi.c
+++ b/ogp_spi.c
@@ -128,7 +128,8 @@ int ogp_spi_init(void)
return 1;
}
- get_io_perms();
+ if (get_io_perms())
+ return 1;
io_base_addr = pcidev_init(PCI_BASE_ADDRESS_0, ogp_spi);
diff --git a/programmer.h b/programmer.h
index d60fc5d..47be768 100644
--- a/programmer.h
+++ b/programmer.h
@@ -300,7 +300,7 @@ struct pci_dev *pci_dev_find(uint16_t vendor, uint16_t device);
struct pci_dev *pci_card_find(uint16_t vendor, uint16_t device,
uint16_t card_vendor, uint16_t card_device);
#endif
-void get_io_perms(void);
+int get_io_perms(void);
void release_io_perms(void);
#if CONFIG_INTERNAL == 1
extern int is_laptop;
diff --git a/rayer_spi.c b/rayer_spi.c
index 0011bc0..62f0e12 100644
--- a/rayer_spi.c
+++ b/rayer_spi.c
@@ -167,7 +167,8 @@ int rayer_spi_init(void)
rayer_miso_bit = 4;
}
- get_io_perms();
+ if (get_io_perms())
+ return 1;
/* Get the initial value before writing to any line. */
lpt_outbyte = INB(lpt_iobase);
diff --git a/satamv.c b/satamv.c
index e39385b..0b83a14 100644
--- a/satamv.c
+++ b/satamv.c
@@ -85,7 +85,8 @@ int satamv_init(void)
uintptr_t addr;
uint32_t tmp;
- get_io_perms();
+ if (get_io_perms())
+ return 1;
/* BAR0 has all internal registers memory mapped. */
/* No need to check for errors, pcidev_init() will not return in case
diff --git a/satasii.c b/satasii.c
index 387c605..75378be 100644
--- a/satasii.c
+++ b/satasii.c
@@ -70,7 +70,8 @@ int satasii_init(void)
uint32_t addr;
uint16_t reg_offset;
- get_io_perms();
+ if (get_io_perms())
+ return 1;
pcidev_init(PCI_BASE_ADDRESS_0, satas_sii);
--
1.7.11.1