Fixed inconsistent behavior, removed unnecesary while loop

This commit is contained in:
notsomeidiot123 2026-06-27 15:00:46 -04:00
parent 047a057e9b
commit f437724cb1
1 changed files with 8 additions and 6 deletions

View File

@ -4,6 +4,7 @@
#include "../system/vfs.h"
#include "../shared/string.h"
#include "../shared/memory.h"
#include "../drivers/serial.h"
#define MODULE_NAME "PCI"
char *classes[][20] = {
@ -79,20 +80,21 @@ void pci_make_file(uint32_t class, uint8_t bus, uint8_t slot, uint8_t func){
char cpy[256];
vfile_t *file = 0;
uint8_t tries = 0;
while(file == 0){
// while(file == 0){
itoa(tries++, num, 10);
strcpy(str, cpy);
strcpy(num, cpy + strlen(cpy));
file = fcreate(cpy, 0);
// file->read = pci_read_file;
// file->write = pci_write_file;
if(file == 0) break;
file->fileops = &pci_fileops;
if(tries >= 254){
mlog(MODULE_NAME, "Failed to make PCI file for device!\n", MLOG_PRINT);
// if(file == 0) break;
if(!file){
mlog(MODULE_NAME, "Failed to make file for PCI device!\n", MLOG_PRINT);
return;
}
}
// printf("ASSERT file == null: %d\n", file == 0);
file->fileops = &pci_fileops;
// }
file->id = (uint32_t)slot | ((uint32_t)func << 8) | ((uint32_t)bus << 16);
}