wvk86
wvk86

Reputation: 11

How do I get a list of ACPI devices on a Linux Kernel Driver?

I am developing a Linux Kernel Driver. Part of the requirement is to get a list of ACPI devices on the system and iterate through. While the following code worked for user-mode, it does not get compiled on kernel.

#include <dirent.h>
#include <stdio.h>

int main(void)
{
   DIR           * d;
   struct dirent * dir;
   d = opendir("/sys/bus/acpi/devices");

   if (d)
   {
      while ((dir = readdir(d)) != NULL)
      {
         printf("%s\n", dir->d_name);
      }

      closedir(d);
   }

   return 0;
}

Is there a similar function that is available in kernel for me to get list of ACPI devices?

Upvotes: 1

Views: 3584

Answers (1)

Hercules dd
Hercules dd

Reputation: 225

The code that you have written in using linux userspace header files and functions which are not used in kernel. Linux kernel has its own way of dealing with devices.

In kernel : The ACPI implementation enumerates devices behind busses (platform, SPI and I2C), creates the physical devices and binds them to their ACPI handle in the ACPI namespace. Read full kernel text here.

Upvotes: 1

Related Questions