summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/modem.h2
-rw-r--r--src/modem.c16
2 files changed, 13 insertions, 5 deletions
diff --git a/include/modem.h b/include/modem.h
index 5f71fe74..8ca5f83b 100644
--- a/include/modem.h
+++ b/include/modem.h
@@ -41,7 +41,7 @@ const char *ofono_modem_get_path(struct ofono_modem *modem);
void ofono_modem_set_data(struct ofono_modem *modem, void *data);
void *ofono_modem_get_data(struct ofono_modem *modem);
-struct ofono_modem *ofono_modem_create(const char *node, const char *type);
+struct ofono_modem *ofono_modem_create(const char *type);
int ofono_modem_register(struct ofono_modem *modem);
void ofono_modem_remove(struct ofono_modem *modem);
diff --git a/src/modem.c b/src/modem.c
index 08738fd7..c892856c 100644
--- a/src/modem.c
+++ b/src/modem.c
@@ -38,6 +38,8 @@ static GSList *g_devinfo_drivers = NULL;
static GSList *g_driver_list = NULL;
static GSList *g_modem_list = NULL;
+static int next_modem_id = 0;
+
enum ofono_property_type {
OFONO_PROPERTY_TYPE_INVALID = 0,
OFONO_PROPERTY_TYPE_STRING,
@@ -1020,14 +1022,19 @@ int ofono_modem_get_integer(struct ofono_modem *modem, const char *key)
return value;
}
-struct ofono_modem *ofono_modem_create(const char *node, const char *type)
+struct ofono_modem *ofono_modem_create(const char *type)
{
struct ofono_modem *modem;
char path[128];
- DBG("%s, %s", node, type);
+ DBG("%s", type);
- if (strlen(node) > 16)
+ if (strlen(type) > 16)
+ return NULL;
+
+ snprintf(path, sizeof(path), "/%s%d", type, next_modem_id);
+
+ if (__ofono_dbus_valid_object_path(path) == FALSE)
return NULL;
modem = g_try_new0(struct ofono_modem, 1);
@@ -1035,7 +1042,6 @@ struct ofono_modem *ofono_modem_create(const char *node, const char *type)
if (modem == NULL)
return modem;
- snprintf(path, sizeof(path), "/%s", node);
modem->path = g_strdup(path);
modem->driver_type = g_strdup(type);
modem->properties = g_hash_table_new_full(g_str_hash, g_str_equal,
@@ -1043,6 +1049,8 @@ struct ofono_modem *ofono_modem_create(const char *node, const char *type)
g_modem_list = g_slist_prepend(g_modem_list, modem);
+ next_modem_id += 1;
+
return modem;
}