[PATCH] watchdog add settimeout ioctl
Tito
farmatito at tiscali.it
Tue Aug 5 13:37:57 UTC 2008
On Tuesday 05 August 2008 15:05:11 Darius wrote:
> Tito wrote:
> > On Tuesday 05 August 2008 13:18:06 Darius wrote:
> >> Hi All,
> >>
> >> this patch adds one more command line option for watchdog utility and
> >> small ioctl implementation for hardware WD timer setting. Now it is
> >> possible to set up userspace and hardware timers independently with
> >> different values.
> >>
> >> BR,
> >> Darius Augulis
> >
> > Hi,
> > maybe you can you use this little optimization.
> >
> > - if (ioctl(3, WDIOC_SETTIMEOUT, &htimer_duration) != 0){
> > - printf("error setting hardware timer!\n");
> > - if (ioctl(3, WDIOC_GETTIMEOUT, &htimer_duration) != 0)
> > - printf("ioctl not supported by device!\n");
> > - }
> > +bb_ioctl_or_warn(3, WDIOC_SETTIMEOUT, &htimer_duration);
> > +bb_ioctl_or_warn(3, WDIOC_GETTIMEOUT, &htimer_duration);
> >
> > This is untested. You should test what happens with htimer_duration
> > if one of the calls fails and if this could affect somehow the subsequent
>
> Ok, thanks. Attached new patch with this optimization.
> Tested in both cases when neither SETTIMEOUT nor GETTIMEOUT ioctls are not
> available in WD driver. Works ok.
>
> BR,
> Darius
Hi Darius,
Please remove the last argument as there is some preprocessor magic
in in libbb.h that will add it automagically depending on the setting
of f ENABLE_IOCTL_HEX2STR_ERROR
#if ENABLE_IOCTL_HEX2STR_ERROR
int bb_ioctl_or_warn(int fd, unsigned request, void *argp, const char *ioctl_name) FAST_FUNC;
int bb_xioctl(int fd, unsigned request, void *argp, const char *ioctl_name) FAST_FUNC;
#define ioctl_or_warn(fd,request,argp) bb_ioctl_or_warn(fd,request,argp,#request)
#define xioctl(fd,request,argp) bb_xioctl(fd,request,argp,#request)
#else
int bb_ioctl_or_warn(int fd, unsigned request, void *argp) FAST_FUNC;
int bb_xioctl(int fd, unsigned request, void *argp) FAST_FUNC;
#define ioctl_or_warn(fd,request,argp) bb_ioctl_or_warn(fd,request,argp)
#define xioctl(fd,request,argp) bb_xioctl(fd,request,argp)
#endif
+ bb_ioctl_or_warn(3, WDIOC_SETTIMEOUT, &htimer_duration, "error setting hardware timer");
+ bb_ioctl_or_warn(3, WDIOC_GETTIMEOUT, &htimer_duration, "error getting timer value");
so you should change the calls to:
+ ioctl_or_warn(3, WDIOC_SETTIMEOUT, &htimer_duration);
+ ioctl_or_warn(3, WDIOC_GETTIMEOUT, &htimer_duration);
They will print the following error message depending on ENABLE_IOCTL_HEX2STR_ERROR:
ioctl WDIOC_SETTIMEOUT failed
or
ioctl 0x0000 failed
if you want to use your custom error messages you can use:
ioctl_or_perror(int fd, unsigned request, void *argp, const char *fmt,...)
but this will increase size.
Sorry for the inconvenience as i mislead a bit you with my first
mail but i forgot about this magic stuff.
Ciao,
Tito
More information about the busybox
mailing list