samsung: port plugin to the refactored probing logic
This commit is contained in:
@@ -28,59 +28,25 @@
|
||||
#include "mm-broadband-modem-samsung.h"
|
||||
#include "mm-log.h"
|
||||
|
||||
G_DEFINE_TYPE (MMPluginSamsung, mm_plugin_samsung, MM_TYPE_PLUGIN_BASE)
|
||||
G_DEFINE_TYPE (MMPluginSamsung, mm_plugin_samsung, MM_TYPE_PLUGIN)
|
||||
|
||||
int mm_plugin_major_version = MM_PLUGIN_MAJOR_VERSION;
|
||||
int mm_plugin_minor_version = MM_PLUGIN_MINOR_VERSION;
|
||||
|
||||
static MMBaseModem *
|
||||
grab_port (MMPluginBase *base,
|
||||
MMBaseModem *existing,
|
||||
MMPortProbe *probe,
|
||||
GError **error)
|
||||
create_modem (MMPlugin *self,
|
||||
const gchar *sysfs_path,
|
||||
const gchar *driver,
|
||||
guint16 vendor,
|
||||
guint16 product,
|
||||
GList *probes,
|
||||
GError **error)
|
||||
{
|
||||
MMBaseModem *modem = NULL;
|
||||
const gchar *name, *subsys, *driver;
|
||||
guint16 vendor = 0, product = 0;
|
||||
|
||||
mm_dbg(" existing %p", existing);
|
||||
/* The Samsung plugin uses AT and net ports */
|
||||
if (!mm_port_probe_is_at (probe) &&
|
||||
!g_str_equal (mm_port_probe_get_port_subsys (probe), "net")) {
|
||||
g_set_error (error, 0, 0, "Ignoring non-AT/net port");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
subsys = mm_port_probe_get_port_subsys (probe);
|
||||
name = mm_port_probe_get_port_name (probe);
|
||||
driver = mm_port_probe_get_port_driver (probe);
|
||||
mm_dbg("subsys %s name %s driver %s", subsys, name, driver);
|
||||
|
||||
/* Try to get Product IDs from udev. */
|
||||
mm_plugin_base_get_device_ids (base, subsys, name, &vendor, &product);
|
||||
mm_dbg("vendor 0x%04x product 0x%04x", vendor, product);
|
||||
|
||||
/* If this is the first port being grabbed, create a new modem object */
|
||||
if (!existing)
|
||||
modem = MM_BASE_MODEM (mm_broadband_modem_samsung_new (mm_port_probe_get_port_physdev (probe),
|
||||
driver,
|
||||
mm_plugin_get_name (MM_PLUGIN (base)),
|
||||
vendor,
|
||||
product));
|
||||
|
||||
if (!mm_base_modem_grab_port (existing ? existing : modem,
|
||||
subsys,
|
||||
name,
|
||||
mm_port_probe_get_port_type (probe),
|
||||
MM_AT_PORT_FLAG_NONE,
|
||||
error)) {
|
||||
mm_dbg("mm_base_modem_grab_port failed; releasing");
|
||||
if (modem)
|
||||
g_object_unref (modem);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return existing ? existing : modem;
|
||||
return MM_BASE_MODEM (mm_broadband_modem_samsung_new (sysfs_path,
|
||||
driver,
|
||||
mm_plugin_get_name (self),
|
||||
vendor,
|
||||
product));
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
@@ -94,10 +60,10 @@ mm_plugin_create (void)
|
||||
{ 0, 0 } };
|
||||
return MM_PLUGIN (
|
||||
g_object_new (MM_TYPE_PLUGIN_SAMSUNG,
|
||||
MM_PLUGIN_BASE_NAME, "Samsung",
|
||||
MM_PLUGIN_BASE_ALLOWED_SUBSYSTEMS, subsystems,
|
||||
MM_PLUGIN_BASE_ALLOWED_PRODUCT_IDS, products,
|
||||
MM_PLUGIN_BASE_ALLOWED_AT, TRUE,
|
||||
MM_PLUGIN_NAME, "Samsung",
|
||||
MM_PLUGIN_ALLOWED_SUBSYSTEMS, subsystems,
|
||||
MM_PLUGIN_ALLOWED_PRODUCT_IDS, products,
|
||||
MM_PLUGIN_ALLOWED_AT, TRUE,
|
||||
NULL));
|
||||
}
|
||||
|
||||
@@ -109,7 +75,7 @@ mm_plugin_samsung_init (MMPluginSamsung *self)
|
||||
static void
|
||||
mm_plugin_samsung_class_init (MMPluginSamsungClass *klass)
|
||||
{
|
||||
MMPluginBaseClass *pb_class = MM_PLUGIN_BASE_CLASS (klass);
|
||||
MMPluginClass *plugin_class = MM_PLUGIN_CLASS (klass);
|
||||
|
||||
pb_class->grab_port = grab_port;
|
||||
plugin_class->create_modem = create_modem;
|
||||
}
|
||||
|
@@ -23,7 +23,7 @@
|
||||
#ifndef MM_PLUGIN_SAMSUNG_H
|
||||
#define MM_PLUGIN_SAMSUNG_H
|
||||
|
||||
#include "mm-plugin-base.h"
|
||||
#include "mm-plugin.h"
|
||||
|
||||
#define MM_TYPE_PLUGIN_SAMSUNG (mm_plugin_samsung_get_type ())
|
||||
#define MM_PLUGIN_SAMSUNG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_PLUGIN_SAMSUNG, MMPluginSamsung))
|
||||
@@ -33,11 +33,11 @@
|
||||
#define MM_PLUGIN_SAMSUNG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_PLUGIN_SAMSUNG, MMPluginSamsungClass))
|
||||
|
||||
typedef struct {
|
||||
MMPluginBase parent;
|
||||
MMPlugin parent;
|
||||
} MMPluginSamsung;
|
||||
|
||||
typedef struct {
|
||||
MMPluginBaseClass parent;
|
||||
MMPluginClass parent;
|
||||
} MMPluginSamsungClass;
|
||||
|
||||
GType mm_plugin_samsung_get_type (void);
|
||||
|
Reference in New Issue
Block a user