Changeset 20235a3 in mainline for uspace/srv/hid/kbd/port/chardev.c


Ignore:
Timestamp:
2010-09-02T20:55:28Z (14 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0c39b96
Parents:
0c61955 (diff), 3249673 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/hid/kbd/port/chardev.c

    r0c61955 r20235a3  
    4141#include <kbd.h>
    4242#include <vfs/vfs.h>
     43#include <sys/stat.h>
    4344#include <fcntl.h>
    4445#include <errno.h>
     
    5051#define NAME "kbd"
    5152
     53/** List of devices to try connecting to. */
     54static const char *in_devs[] = {
     55        "/dev/char/ps2a",
     56        "/dev/char/s3c24ser"
     57};
     58
     59static const int num_devs = sizeof(in_devs) / sizeof(in_devs[0]);
     60
    5261int kbd_port_init(void)
    5362{
    54         const char *input = "/dev/char/ps2a";
    5563        int input_fd;
     64        int i;
    5665
    57         printf(NAME ": open %s\n", input);
     66        input_fd = -1;
     67        for (i = 0; i < num_devs; i++) {
     68                struct stat s;
    5869
    59         input_fd = open(input, O_RDONLY);
     70                if (stat(in_devs[i], &s) == EOK)
     71                        break;
     72        }
     73
     74        if (i >= num_devs) {
     75                printf(NAME ": Could not find any suitable input device.\n");
     76                return -1;
     77        }
     78
     79        input_fd = open(in_devs[i], O_RDONLY);
    6080        if (input_fd < 0) {
    61                 printf(NAME ": Failed opening %s (%d)\n", input, input_fd);
    62                 return false;
     81                printf(NAME ": failed opening device %s (%d).\n", in_devs[i],
     82                    input_fd);
     83                return -1;
    6384        }
    6485
    6586        dev_phone = fd_phone(input_fd);
    6687        if (dev_phone < 0) {
    67                 printf(NAME ": Failed to connect to device\n");
    68                 return false;
     88                printf(NAME ": Failed connecting to device\n");
     89                return -1;
    6990        }
    7091
     
    7394        if (ipc_connect_to_me(dev_phone, 0, 0, 0, &phonehash) != 0) {
    7495                printf(NAME ": Failed to create callback from device\n");
    75                 return false;
     96                return -1;
    7697        }
    7798
Note: See TracChangeset for help on using the changeset viewer.