aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2011-03-27 15:26:55 -0500
committerDan Williams <dcbw@redhat.com>2011-03-27 15:26:55 -0500
commit9d1c02f55399d2959e25b5f56d60f52a0d8c9545 (patch)
treecb401d01ca58c5efb61069ab3972db1a70cb7238
parent35b3e348e66842f02e065b0ccb9c8ef1fd1abb99 (diff)
samsung: clean up modem detection
Use standard vendor/device id detection mechanisms and handle the net port like other net ports are handled, by just claiming it. Also reject CDMA modems for now.
-rwxr-xr-xplugins/mm-plugin-samsung.c77
1 files changed, 34 insertions, 43 deletions
diff --git a/plugins/mm-plugin-samsung.c b/plugins/mm-plugin-samsung.c
index 5b551c52..73292bf8 100755
--- a/plugins/mm-plugin-samsung.c
+++ b/plugins/mm-plugin-samsung.c
@@ -11,8 +11,8 @@
* GNU General Public License for more details:
*
* Copyright (C) 2008 - 2009 Novell, Inc.
- * Copyright (C) 2009 Red Hat, Inc.
- * Copyright 2011 by Samsung Electronics, Inc.,
+ * Copyright (C) 2009 - 2011 Red Hat, Inc.
+ * Copyright (c) 2011 Samsung Electronics, Inc.,
*/
#include <string.h>
@@ -36,6 +36,13 @@ mm_plugin_create (void)
NULL));
}
+/*****************************************************************************/
+
+#define CAP_CDMA (MM_PLUGIN_BASE_PORT_CAP_IS707_A | \
+ MM_PLUGIN_BASE_PORT_CAP_IS707_P | \
+ MM_PLUGIN_BASE_PORT_CAP_IS856 | \
+ MM_PLUGIN_BASE_PORT_CAP_IS856_A)
+
static guint32
get_level_for_capabilities (guint32 capabilities)
{
@@ -59,56 +66,33 @@ supports_port (MMPluginBase *base,
MMPluginBaseSupportsTask *task)
{
GUdevDevice *port;
- const char *tmp;
- guint32 level;
+ const char *subsys, *name;
+ guint16 vendor = 0, product = 0;
- /* Can't do anything with non-serial ports */
port = mm_plugin_base_supports_task_get_port (task);
- if(!g_str_has_prefix(g_udev_device_get_subsystem(port), "tty"))
- {
- if(g_str_has_prefix(g_udev_device_get_name(port), "usb"))
- {
- goto done;
- }
- else
- {
- return MM_PLUGIN_SUPPORTS_PORT_UNSUPPORTED;
- }
- }
- else
- {
- tmp = g_udev_device_get_property (port, "ID_BUS");
-
- if(g_strcmp0(tmp, "usb"))
- return MM_PLUGIN_SUPPORTS_PORT_UNSUPPORTED;
-
- tmp = g_udev_device_get_property (port, "ID_VENDOR_ID");
-
- if (g_strcmp0(tmp, "04e8") && g_strcmp0(tmp, "1983"))
- {
- return MM_PLUGIN_SUPPORTS_PORT_UNSUPPORTED;
- }
- }
+ subsys = g_udev_device_get_subsystem (port);
+ g_assert (subsys);
+ name = g_udev_device_get_name (port);
+ g_assert (name);
-done:
+ if (!mm_plugin_base_get_device_ids (base, subsys, name, &vendor, &product))
+ return MM_PLUGIN_SUPPORTS_PORT_UNSUPPORTED;
- if (g_str_has_prefix(g_udev_device_get_name (port), "usb")) {
- level = get_level_for_capabilities (1);
- if (level) {
- mm_plugin_base_supports_task_complete (task, 10);
- return MM_PLUGIN_SUPPORTS_PORT_IN_PROGRESS;
- }
+ /* Vendor ID check */
+ if (vendor != 0x04e8 && vendor != 0x1983)
return MM_PLUGIN_SUPPORTS_PORT_UNSUPPORTED;
- }
- mm_plugin_base_supports_task_set_custom_init_command (task, "+CFUN=1", 10, 4, FALSE, NULL, NULL);
+ /* The ethernet ports are obviously supported and don't need probing */
+ if (!strcmp (subsys, "net")) {
+ mm_plugin_base_supports_task_complete (task, 10);
+ return MM_PLUGIN_SUPPORTS_PORT_IN_PROGRESS;
+ }
/* Otherwise kick off a probe */
if (mm_plugin_base_probe_port (base, task, NULL))
- {
return MM_PLUGIN_SUPPORTS_PORT_IN_PROGRESS;
- }
+
return MM_PLUGIN_SUPPORTS_PORT_UNSUPPORTED;
}
@@ -120,6 +104,7 @@ grab_port (MMPluginBase *base,
{
GUdevDevice *port = NULL;
MMModem *modem = NULL;
+ guint32 caps;
const char *name, *subsys, *sysfs_path;
port = mm_plugin_base_supports_task_get_port (task);
@@ -128,11 +113,17 @@ grab_port (MMPluginBase *base,
subsys = g_udev_device_get_subsystem (port);
name = g_udev_device_get_name (port);
+ caps = mm_plugin_base_supports_task_get_probed_capabilities (task);
+ if (caps & CAP_CDMA) {
+ g_set_error (error, 0, 0, "Only GSM modems are currently supported by this plugin.");
+ return NULL;
+ }
+
sysfs_path = mm_plugin_base_supports_task_get_physdev_path (task);
if (!existing) {
modem = mm_modem_samsung_gsm_new (sysfs_path,
- mm_plugin_base_supports_task_get_driver (task),
- mm_plugin_get_name (MM_PLUGIN (base)));
+ mm_plugin_base_supports_task_get_driver (task),
+ mm_plugin_get_name (MM_PLUGIN (base)));
if (modem) {
if (!mm_modem_grab_port (modem, subsys, name, MM_PORT_TYPE_UNKNOWN, NULL, error)) {