Comment 21 for bug 1229658

Revision history for this message
Mohammad Merajul Islam Molla (meraj-enigma) wrote :

Hello Sanjay/Botao,

It looks like there is a problem in the code portion below -

while (read = getline(&line, &len, fgpio) != -1) {
  char *str;

  if (strstr(line, "gpio-")) {
   str = strtok(line, " ");
   sscanf(str, "gpio-%d", &gpio[num]);
   fprintf(fgpio_export, "%d", gpio[num]);
   num++;
  }

/sys/kernel/debug/gpio will have lines as below only if those gpio pins have already been exported by writing to /sys/class/gpio/export file -

 gpio-1 (sysfs ) in hi
 gpio-2 (sysfs ) in lo
 gpio-3 (sysfs ) in hi
 gpio-4 (sysfs ) in lo
 gpio-5 (sysfs ) in lo
 gpio-6 (sysfs ) in hi
 gpio-7 (sysfs ) in hi

I have attached a patch which fixes the problem. Now it dynamically determines maximum number of gpios on the platform and exports those via /sys/class/gpio/export file.

Please review/comment/test the patch attached.

*** NOTE: The earlier patch (mentioned above) is no longer necessary. This patch contains all the other fixes too.

Thanks,
-Meraj