From: Marcel Holtmann Date: Sat, 30 Jan 2010 15:44:13 +0000 (-0800) Subject: Add support for using old CAIF subsystem with character devices X-Git-Tag: 0.17~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=16f477653dd82fbfcc30d599bf74984e2404a1f4;p=platform%2Fupstream%2Fofono.git Add support for using old CAIF subsystem with character devices --- diff --git a/plugins/modemconf.c b/plugins/modemconf.c index aedaad0..cf0ee8b 100644 --- a/plugins/modemconf.c +++ b/plugins/modemconf.c @@ -121,6 +121,7 @@ static struct { { "phonesim", set_address }, { "atgen", set_device }, { "g1", set_device }, + { "ste", set_device }, { "calypso", set_device }, { "palmpre", set_device }, { NULL } diff --git a/plugins/ste.c b/plugins/ste.c index 34550c8..5605b76 100644 --- a/plugins/ste.c +++ b/plugins/ste.c @@ -25,6 +25,8 @@ #endif #include +#include +#include #include #include #include @@ -110,29 +112,42 @@ static int ste_enable(struct ofono_modem *modem) struct ste_data *data = ofono_modem_get_data(modem); GIOChannel *channel; GAtSyntax *syntax; - int fd, err; - struct sockaddr_caif addr; + const char *device; + int fd; DBG("%p", modem); - /* Create a CAIF socket for AT Service */ - fd = socket(AF_CAIF, SOCK_SEQPACKET, CAIFPROTO_AT); - if (fd < 0) { - ofono_error("Failed to create CAIF socket for AT"); - return -EIO; + device = ofono_modem_get_string(modem, "Device"); + if (!device) { + struct sockaddr_caif addr; + int err; + + /* Create a CAIF socket for AT Service */ + fd = socket(AF_CAIF, SOCK_SEQPACKET, CAIFPROTO_AT); + if (fd < 0) { + ofono_error("Failed to create CAIF socket for AT"); + return -EIO; + } + + memset(&addr, 0, sizeof(addr)); + addr.family = AF_CAIF; + addr.u.at.type = CAIF_ATTYPE_PLAIN; + + /* Connect to the AT Service at the modem */ + err = connect(fd, (struct sockaddr *) &addr, sizeof(addr)); + if (err < 0) { + ofono_error("Failed to connect CAIF socket for AT"); + close(fd); + return err; + } + } else { + fd = open(device, O_RDWR); + if (fd < 0) { + ofono_error("Failed to open device %s", device); + return -EIO; + } } - memset(&addr, 0, sizeof(addr)); - addr.family = AF_CAIF; - addr.u.at.type = CAIF_ATTYPE_PLAIN; - - /* Connect to the AT Service at the modem */ - err = connect(fd, (struct sockaddr *) &addr, sizeof(addr)); - if (err < 0) { - ofono_error("Failed to connect CAIF socket for AT"); - close(fd); - return err; - } channel = g_io_channel_unix_new(fd); if (!channel) { close(fd);