mirror of git://git.sysmocom.de/ofono
Get rid of node argument in ofono_modem_create
This commit is contained in:
parent
03a0fde2f4
commit
7a95c41fab
|
@ -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_set_data(struct ofono_modem *modem, void *data);
|
||||||
void *ofono_modem_get_data(struct ofono_modem *modem);
|
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);
|
int ofono_modem_register(struct ofono_modem *modem);
|
||||||
void ofono_modem_remove(struct ofono_modem *modem);
|
void ofono_modem_remove(struct ofono_modem *modem);
|
||||||
|
|
||||||
|
|
16
src/modem.c
16
src/modem.c
|
@ -38,6 +38,8 @@ static GSList *g_devinfo_drivers = NULL;
|
||||||
static GSList *g_driver_list = NULL;
|
static GSList *g_driver_list = NULL;
|
||||||
static GSList *g_modem_list = NULL;
|
static GSList *g_modem_list = NULL;
|
||||||
|
|
||||||
|
static int next_modem_id = 0;
|
||||||
|
|
||||||
enum ofono_property_type {
|
enum ofono_property_type {
|
||||||
OFONO_PROPERTY_TYPE_INVALID = 0,
|
OFONO_PROPERTY_TYPE_INVALID = 0,
|
||||||
OFONO_PROPERTY_TYPE_STRING,
|
OFONO_PROPERTY_TYPE_STRING,
|
||||||
|
@ -1020,14 +1022,19 @@ int ofono_modem_get_integer(struct ofono_modem *modem, const char *key)
|
||||||
return value;
|
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;
|
struct ofono_modem *modem;
|
||||||
char path[128];
|
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;
|
return NULL;
|
||||||
|
|
||||||
modem = g_try_new0(struct ofono_modem, 1);
|
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)
|
if (modem == NULL)
|
||||||
return modem;
|
return modem;
|
||||||
|
|
||||||
snprintf(path, sizeof(path), "/%s", node);
|
|
||||||
modem->path = g_strdup(path);
|
modem->path = g_strdup(path);
|
||||||
modem->driver_type = g_strdup(type);
|
modem->driver_type = g_strdup(type);
|
||||||
modem->properties = g_hash_table_new_full(g_str_hash, g_str_equal,
|
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);
|
g_modem_list = g_slist_prepend(g_modem_list, modem);
|
||||||
|
|
||||||
|
next_modem_id += 1;
|
||||||
|
|
||||||
return modem;
|
return modem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue