port-probe-cache: removed, no longer needed
The `MMDevice' acts as port probe cache for us now, directly storing all port probes of the same device.
This commit is contained in:
@@ -194,8 +194,6 @@ ModemManager_SOURCES = \
|
|||||||
mm-port-probe.c \
|
mm-port-probe.c \
|
||||||
mm-port-probe-at.h \
|
mm-port-probe-at.h \
|
||||||
mm-port-probe-at.c \
|
mm-port-probe-at.c \
|
||||||
mm-port-probe-cache.h \
|
|
||||||
mm-port-probe-cache.c \
|
|
||||||
mm-plugin.c \
|
mm-plugin.c \
|
||||||
mm-plugin.h
|
mm-plugin.h
|
||||||
|
|
||||||
|
@@ -32,7 +32,6 @@
|
|||||||
#include "mm-auth.h"
|
#include "mm-auth.h"
|
||||||
#include "mm-plugin.h"
|
#include "mm-plugin.h"
|
||||||
#include "mm-log.h"
|
#include "mm-log.h"
|
||||||
#include "mm-port-probe-cache.h"
|
|
||||||
|
|
||||||
static void initable_iface_init (GInitableIface *iface);
|
static void initable_iface_init (GInitableIface *iface);
|
||||||
|
|
||||||
@@ -325,9 +324,6 @@ device_removed (MMManager *self,
|
|||||||
|
|
||||||
g_return_if_fail (udev_device != NULL);
|
g_return_if_fail (udev_device != NULL);
|
||||||
|
|
||||||
/* Ensure cached port probe infos get removed when the port is gone */
|
|
||||||
mm_port_probe_cache_remove (udev_device);
|
|
||||||
|
|
||||||
if (!g_str_equal (g_udev_device_get_subsystem (udev_device), "usb")) {
|
if (!g_str_equal (g_udev_device_get_subsystem (udev_device), "usb")) {
|
||||||
/* Handle tty/net port removal */
|
/* Handle tty/net port removal */
|
||||||
device = find_device_by_port (self, udev_device);
|
device = find_device_by_port (self, udev_device);
|
||||||
@@ -717,8 +713,6 @@ finalize (GObject *object)
|
|||||||
|
|
||||||
g_hash_table_destroy (priv->devices);
|
g_hash_table_destroy (priv->devices);
|
||||||
|
|
||||||
mm_port_probe_cache_clear ();
|
|
||||||
|
|
||||||
if (priv->udev)
|
if (priv->udev)
|
||||||
g_object_unref (priv->udev);
|
g_object_unref (priv->udev);
|
||||||
|
|
||||||
|
@@ -30,7 +30,6 @@
|
|||||||
|
|
||||||
#include "mm-plugin.h"
|
#include "mm-plugin.h"
|
||||||
#include "mm-device.h"
|
#include "mm-device.h"
|
||||||
#include "mm-port-probe-cache.h"
|
|
||||||
#include "mm-at-serial-port.h"
|
#include "mm-at-serial-port.h"
|
||||||
#include "mm-qcdm-serial-port.h"
|
#include "mm-qcdm-serial-port.h"
|
||||||
#include "mm-serial-parsers.h"
|
#include "mm-serial-parsers.h"
|
||||||
@@ -573,8 +572,7 @@ mm_plugin_supports_port (MMPlugin *self,
|
|||||||
(GAsyncReadyCallback)port_probe_run_ready,
|
(GAsyncReadyCallback)port_probe_run_ready,
|
||||||
ctx);
|
ctx);
|
||||||
|
|
||||||
/* Keep track of the probe. Note that we got a new reference already
|
/* Keep track of the probe. Note that we got a new reference already */
|
||||||
* from the cache. */
|
|
||||||
g_hash_table_insert (priv->tasks,
|
g_hash_table_insert (priv->tasks,
|
||||||
g_strdup (key),
|
g_strdup (key),
|
||||||
probe);
|
probe);
|
||||||
|
@@ -1,87 +0,0 @@
|
|||||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
||||||
/*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details:
|
|
||||||
*
|
|
||||||
* Copyright (C) 2011 Aleksander Morgado <aleksander@gnu.org>
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <glib.h>
|
|
||||||
|
|
||||||
#include "mm-port-probe.h"
|
|
||||||
#include "mm-port-probe-cache.h"
|
|
||||||
|
|
||||||
/* Cache of port probing objects */
|
|
||||||
static GHashTable *cache;
|
|
||||||
|
|
||||||
static gchar *
|
|
||||||
get_key (GUdevDevice *port)
|
|
||||||
{
|
|
||||||
return g_strdup_printf ("%s%s",
|
|
||||||
g_udev_device_get_subsystem (port),
|
|
||||||
g_udev_device_get_name (port));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
probe_remove (MMPortProbe *probe)
|
|
||||||
{
|
|
||||||
mm_port_probe_run_cancel (probe);
|
|
||||||
g_object_unref (probe);
|
|
||||||
}
|
|
||||||
|
|
||||||
MMPortProbe *
|
|
||||||
mm_port_probe_cache_get (GUdevDevice *port,
|
|
||||||
const gchar *physdev_path,
|
|
||||||
const gchar *driver)
|
|
||||||
{
|
|
||||||
MMPortProbe *probe = NULL;
|
|
||||||
gchar *key;
|
|
||||||
|
|
||||||
key = get_key (port);
|
|
||||||
|
|
||||||
if (G_UNLIKELY (!cache)) {
|
|
||||||
cache = g_hash_table_new_full (g_str_hash,
|
|
||||||
g_str_equal,
|
|
||||||
g_free,
|
|
||||||
(GDestroyNotify)probe_remove);
|
|
||||||
} else {
|
|
||||||
probe = g_hash_table_lookup (cache, key);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!probe) {
|
|
||||||
probe = mm_port_probe_new (port, physdev_path, driver);
|
|
||||||
g_hash_table_insert (cache, key, probe);
|
|
||||||
} else
|
|
||||||
g_free (key);
|
|
||||||
|
|
||||||
return g_object_ref (probe);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
mm_port_probe_cache_remove (GUdevDevice *port)
|
|
||||||
{
|
|
||||||
gchar *key;
|
|
||||||
|
|
||||||
if (G_UNLIKELY (!cache))
|
|
||||||
return;
|
|
||||||
|
|
||||||
key = get_key (port);
|
|
||||||
g_hash_table_remove (cache, key);
|
|
||||||
g_free (key);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
mm_port_probe_cache_clear (void)
|
|
||||||
{
|
|
||||||
if (G_UNLIKELY (!cache))
|
|
||||||
return;
|
|
||||||
|
|
||||||
g_hash_table_remove_all (cache);
|
|
||||||
}
|
|
@@ -1,31 +0,0 @@
|
|||||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
||||||
/*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details:
|
|
||||||
*
|
|
||||||
* Copyright (C) 2011 Aleksander Morgado <aleksander@gnu.org>
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef MM_PORT_PROBE_CACHE_H
|
|
||||||
#define MM_PORT_PROBE_CACHE_H
|
|
||||||
|
|
||||||
#include <glib.h>
|
|
||||||
|
|
||||||
#include "mm-port-probe.h"
|
|
||||||
|
|
||||||
MMPortProbe *mm_port_probe_cache_get (GUdevDevice *port,
|
|
||||||
const gchar *physdev_path,
|
|
||||||
const gchar *driver);
|
|
||||||
|
|
||||||
void mm_port_probe_cache_remove (GUdevDevice *port);
|
|
||||||
|
|
||||||
void mm_port_probe_cache_clear (void);
|
|
||||||
|
|
||||||
#endif /* MM_PORT_PROBE_CACHE_H */
|
|
Reference in New Issue
Block a user