Skip to content

Commit

Permalink
Merge pull request #1992 from ghaerr/cleanup
Browse files Browse the repository at this point in the history
[kernel] Small code cleanups
  • Loading branch information
ghaerr authored Sep 3, 2024
2 parents 2cd97c9 + cca7f27 commit bc2bdb5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 42 deletions.
7 changes: 4 additions & 3 deletions elks/fs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,9 @@ int do_umount(kdev_t dev)
int sys_umount(char *name)
{
struct inode *inode;
register struct inode *inodep;
struct inode *inodep;
struct file_operations *fops;
struct super_block *sb;
kdev_t dev;
int retval;

Expand All @@ -267,7 +269,7 @@ int sys_umount(char *name)
return -EACCES;
}
} else {
register struct super_block *sb = inodep->i_sb;
sb = inodep->i_sb;
if (!sb || inodep != sb->s_mounted) {
iput(inodep);
return -EINVAL;
Expand All @@ -282,7 +284,6 @@ int sys_umount(char *name)
return -ENXIO;
}
if (!(retval = do_umount(dev)) && dev != ROOT_DEV) {
register struct file_operations *fops;
fops = get_blkfops(MAJOR(dev));
if (fops && fops->release) fops->release(inodep, NULL);
}
Expand Down
41 changes: 3 additions & 38 deletions elks/init/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,36 +85,12 @@ static char * INITPROC root_dev_name(int dev);
static int INITPROC parse_options(void);
static void INITPROC finalize_options(void);
static char * INITPROC option(char *s);
#endif /* CONFIG_BOOTOPTS */

#endif

static void init_task(void);
static void INITPROC early_kernel_init(void);
static void INITPROC kernel_init(void);
static void INITPROC kernel_banner(seg_t start, seg_t end, seg_t init, seg_t extra);

#if TIMER_TEST
void testloop(unsigned timer)
{
unsigned long pticks;
unsigned int x = timer;
int i;
static unsigned long a[10];

#if 1
get_ptime();
for (i=0; i<10; i++)
a[i] = get_ptime();
for (i=0; i<10; i++)
printk("%ld,", a[i]);
printk("\n");
#endif
get_ptime();
while (x--) asm("nop");
pticks = get_ptime();
printk("ptime %u: %lk (%lu)\n", timer, pticks, pticks);
}
#endif
static void init_task(void);

/* this procedure called using temp stack then switched, no local vars allowed */
void start_kernel(void)
Expand All @@ -124,19 +100,11 @@ void start_kernel(void)
task = heap_alloc(max_tasks * sizeof(struct task_struct),
HEAP_TAG_TASK|HEAP_TAG_CLEAR);
if (!task) panic("No task mem");

sched_init(); /* set us (the current stack) to be idle task #0*/
setsp(&task->t_regs.ax); /* change to idle task stack */
kernel_init(); /* continue init running on idle task stack */

#if TIMER_TEST
/* run tests before 2nd process created for stability */
test_ptime_print();
testloop(30000);
testloop(3000);
testloop(300);
printk("\n");
#endif

/* fork and run procedure init_task() as task #1*/
kfork_proc(init_task);
wake_up_process(&task[1]);
Expand All @@ -146,9 +114,6 @@ void start_kernel(void)
* The idle task always runs with _gint_count == 1 (switched from user mode syscall)
*/
while (1) {
#if TIMER_TEST
test_ptime_idle_loop();
#endif
schedule();
#ifdef CONFIG_TIMER_INT0F
int0F(); /* simulate timer interrupt hooked on IRQ 7 */
Expand Down
2 changes: 1 addition & 1 deletion elks/kernel/sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ static void del_from_runqueue(register struct task_struct *p)
if (!p->next_run || !p->prev_run)
panic("SCHED(%d): task not on run-queue, state %d", p->pid, p->state);
if (p == &idle_task)
panic("SCHED: trying to sleep idle task");
panic("trying to sleep idle task");
#endif
(p->next_run->prev_run = p->prev_run)->next_run = p->next_run;
p->next_run = p->prev_run = NULL;
Expand Down

0 comments on commit bc2bdb5

Please sign in to comment.