[Previous] [Contents] [Next]

Caution: This version of this document is no longer maintained. For the latest documentation, see http://www.qnx.com/developers/docs.

iopower_getmodes()

Get the power modes supported by a power managed device

Synopsis:

#include <sys/pm.h>
int iopower_getmodes(int filedes, 
                     pm_power_mode_t *modes, 
                     int nmodes);

Arguments:

filedes
A file descriptor to the device special file.
mode
Pointer to where the list of modes are returned.
nmodes
The number of modes to be returned.

Library:

libpm

Description:


Note:

The iopower_getmodes() function replaces pm_get_modes() that has been deprecated.


The iopower_getmodes() function is used to get a list of the power modes supported by a power managed device.

Returns:

The number of modes supported by the device, or -1 (errno is set).

Errors:

EBADF
filedes is not a valid file descriptor.
EFAULT
A fault occurred accesing modes.
ENOSYS
The device specified by filedes doesn't implement power management.

Examples:

#include <sys/pm.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <alloca.h>

int
main(void)
{
  int   fd;
  int   i;
  int   nmode;
        pm_power_mode_t *modes;

  fd = open("/dev/device", O_RDONLY);
  if (fd == -1) {
  perror("open");
  return EXIT_FAILURE;
  }

  nmode = iopower_getmodes(fd, 0, 0);
  if (nmode < 0) {
  perror("iopower_getmodes");
  return EXIT_FAILURE;
  }
  printf("Device supports %d modes:", nmode);

  modes = alloca(nmode * sizeof(*modes));
  if (modes == 0) {
     perror("alloca");
     return EXIT_FAILURE;
  }

  nmode = iopower_getmodes(fd, modes, nmode);
  if (nmode < 0) {
     perror("iopower_getmodes");
     return EXIT_FAILURE;
     }
  
  for (i = 0; i < nmode; i++) {
  printf("%d: mode=0x%x\n", i, modes[i]);
  }
  
  return EXIT_SUCCESS;
}

Classification:

Neutrino

Safety:
Cancellation point Yes
Interrupt handler No
Signal handler Yes
Thread Yes

See also:

pm_power_mode_t, iopower_getattr(), iopower_setmode(), iopower_modeattr()


[Previous] [Contents] [Next]