Re: [patch 20/28] posix-timers: Make posix-cpu-timers functionsstatic

From: Thomas Gleixner
Date: Tue Feb 01 2011 - 16:34:17 EST


On Tue, 1 Feb 2011, John Stultz wrote:

> On Tue, 2011-02-01 at 13:52 +0000, Thomas Gleixner wrote:
> > plain text document attachment
> > (posix-timer-make-posix-cpu-timer-functions-static.patch)
> > All functions are accessed via clock_posix_cpu now. So make them static.
> >
> > Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
> > Cc: John Stultz <john.stultz@xxxxxxxxxx>
> > Cc: Richard Cochran <richard.cochran@xxxxxxxxxx>
>
> This patch seems to have more then just making functions static in it.
>
> > @@ -1481,68 +1483,67 @@ static int do_cpu_nanosleep(const clocki
> > return error;
> > }
> >
> > -int posix_cpu_nsleep(const clockid_t which_clock, int flags,
> > - struct timespec *rqtp, struct timespec __user *rmtp)
> > +static long posix_cpu_nsleep_restart(struct restart_block *restart_block)
> > {
> > - struct restart_block *restart_block =
> > - &current_thread_info()->restart_block;
> > + clockid_t which_clock = restart_block->nanosleep.index;
> > + struct timespec t;
> > struct itimerspec it;
> > int error;
> >
> > - /*
> > - * Diagnose required errors first.
> > - */
> > - if (CPUCLOCK_PERTHREAD(which_clock) &&
> > - (CPUCLOCK_PID(which_clock) == 0 ||
> > - CPUCLOCK_PID(which_clock) == current->pid))
> > - return -EINVAL;
> > + t = ns_to_timespec(restart_block->nanosleep.expires);
> >
> > - error = do_cpu_nanosleep(which_clock, flags, rqtp, &it);
> > + error = do_cpu_nanosleep(which_clock, TIMER_ABSTIME, &t, &it);
> >
> > if (error == -ERESTART_RESTARTBLOCK) {
> > -
> > - if (flags & TIMER_ABSTIME)
> > - return -ERESTARTNOHAND;
> > + struct timespec __user *rmtp = restart_block->nanosleep.rmtp;
> > /*
> > * Report back to the user the time still remaining.
> > */
> > if (rmtp && copy_to_user(rmtp, &it.it_value, sizeof *rmtp))
> > return -EFAULT;
> >
> > - restart_block->fn = posix_cpu_nsleep_restart;
> > - restart_block->nanosleep.index = which_clock;
> > - restart_block->nanosleep.rmtp = rmtp;
> > - restart_block->nanosleep.expires = timespec_to_ns(rqtp);
> > + restart_block->nanosleep.expires = timespec_to_ns(&t);
> > }
> > return error;
> > +
> > }
> >
> > -long posix_cpu_nsleep_restart(struct restart_block *restart_block)
> > +static int posix_cpu_nsleep(const clockid_t which_clock, int flags,
> > + struct timespec *rqtp, struct timespec __user *rmtp)
> > {
> > - clockid_t which_clock = restart_block->nanosleep.index;
> > - struct timespec t;
> > + struct restart_block *restart_block =
> > + &current_thread_info()->restart_block;
> > struct itimerspec it;
> > int error;
> >
> > - t = ns_to_timespec(restart_block->nanosleep.expires);
> > + /*
> > + * Diagnose required errors first.
> > + */
> > + if (CPUCLOCK_PERTHREAD(which_clock) &&
> > + (CPUCLOCK_PID(which_clock) == 0 ||
> > + CPUCLOCK_PID(which_clock) == current->pid))
> > + return -EINVAL;
> >
> > - error = do_cpu_nanosleep(which_clock, TIMER_ABSTIME, &t, &it);
> > + error = do_cpu_nanosleep(which_clock, flags, rqtp, &it);
> >
> > if (error == -ERESTART_RESTARTBLOCK) {
> > - struct timespec __user *rmtp = restart_block->nanosleep.rmtp;
> > +
> > + if (flags & TIMER_ABSTIME)
> > + return -ERESTARTNOHAND;
> > /*
> > * Report back to the user the time still remaining.
> > */
> > if (rmtp && copy_to_user(rmtp, &it.it_value, sizeof *rmtp))
> > return -EFAULT;
> >
> > - restart_block->nanosleep.expires = timespec_to_ns(&t);
> > + restart_block->fn = posix_cpu_nsleep_restart;
> > + restart_block->nanosleep.index = which_clock;
> > + restart_block->nanosleep.rmtp = rmtp;
> > + restart_block->nanosleep.expires = timespec_to_ns(rqtp);
> > }
> > return error;
> > -
> > }
>
> Maybe split that out?

I just moved the restart function above nanosleep to avoid the forward
declaration, but patch deciced to make it more complex. I'll stick
with the forward declaration.

Thanks,

tglx
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/