mirror of
https://git.proxmox.com/git/fwupd
synced 2025-08-08 15:53:23 +00:00
libdfu: Add dfu_context_get_device_by_platform_id()
This lets us get the connection platform ID without exposing the GUsbDevice.
This commit is contained in:
parent
a45d00eb2c
commit
42ffdf7645
@ -509,6 +509,46 @@ dfu_context_get_device_by_vid_pid (DfuContext *context,
|
|||||||
return g_object_ref (device);
|
return g_object_ref (device);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* dfu_context_get_device_by_platform_id:
|
||||||
|
* @context: a #DfuContext
|
||||||
|
* @platform_id: a platform ID
|
||||||
|
* @error: a #GError, or %NULL
|
||||||
|
*
|
||||||
|
* Finds a device in the context with a specific platform ID.
|
||||||
|
*
|
||||||
|
* Return value: (transfer full): a #DfuDevice for success, or %NULL for an error
|
||||||
|
*
|
||||||
|
* Since: 0.5.4
|
||||||
|
**/
|
||||||
|
DfuDevice *
|
||||||
|
dfu_context_get_device_by_platform_id (DfuContext *context,
|
||||||
|
const gchar *platform_id,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
DfuContextPrivate *priv = GET_PRIVATE (context);
|
||||||
|
DfuContextItem *item;
|
||||||
|
guint i;
|
||||||
|
|
||||||
|
g_return_val_if_fail (DFU_IS_CONTEXT (context), FALSE);
|
||||||
|
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
||||||
|
|
||||||
|
/* search all devices */
|
||||||
|
for (i = 0; i < priv->devices->len; i++) {
|
||||||
|
item = g_ptr_array_index (priv->devices, i);
|
||||||
|
if (g_strcmp0 (dfu_device_get_platform_id (item->device),
|
||||||
|
platform_id) == 0) {
|
||||||
|
return g_object_ref (item->device);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
g_set_error (error,
|
||||||
|
DFU_ERROR,
|
||||||
|
DFU_ERROR_NOT_FOUND,
|
||||||
|
"no device matches for %s",
|
||||||
|
platform_id);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* dfu_context_get_device_default:
|
* dfu_context_get_device_default:
|
||||||
* @context: a #DfuContext
|
* @context: a #DfuContext
|
||||||
|
@ -65,6 +65,9 @@ DfuDevice *dfu_context_get_device_by_vid_pid (DfuContext *context,
|
|||||||
guint16 vid,
|
guint16 vid,
|
||||||
guint16 pid,
|
guint16 pid,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
DfuDevice *dfu_context_get_device_by_platform_id (DfuContext *context,
|
||||||
|
const gchar *platform_id,
|
||||||
|
GError **error);
|
||||||
DfuDevice *dfu_context_get_device_default (DfuContext *context,
|
DfuDevice *dfu_context_get_device_default (DfuContext *context,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
|
@ -731,6 +731,24 @@ dfu_device_get_target_by_alt_name (DfuDevice *device,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* dfu_device_get_platform_id:
|
||||||
|
* @device: a #DfuDevice
|
||||||
|
*
|
||||||
|
* Gets the platform ID which normally corresponds to the port in some way.
|
||||||
|
*
|
||||||
|
* Return value: string or %NULL
|
||||||
|
*
|
||||||
|
* Since: 0.5.4
|
||||||
|
**/
|
||||||
|
const gchar *
|
||||||
|
dfu_device_get_platform_id (DfuDevice *device)
|
||||||
|
{
|
||||||
|
DfuDevicePrivate *priv = GET_PRIVATE (device);
|
||||||
|
g_return_val_if_fail (DFU_IS_DEVICE (device), NULL);
|
||||||
|
return g_usb_device_get_platform_id (priv->dev);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* dfu_device_get_runtime_vid:
|
* dfu_device_get_runtime_vid:
|
||||||
* @device: a #DfuDevice
|
* @device: a #DfuDevice
|
||||||
|
@ -78,6 +78,7 @@ gboolean dfu_device_open (DfuDevice *device,
|
|||||||
GError **error);
|
GError **error);
|
||||||
gboolean dfu_device_close (DfuDevice *device,
|
gboolean dfu_device_close (DfuDevice *device,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
const gchar *dfu_device_get_platform_id (DfuDevice *device);
|
||||||
GPtrArray *dfu_device_get_targets (DfuDevice *device);
|
GPtrArray *dfu_device_get_targets (DfuDevice *device);
|
||||||
DfuTarget *dfu_device_get_target_by_alt_setting (DfuDevice *device,
|
DfuTarget *dfu_device_get_target_by_alt_setting (DfuDevice *device,
|
||||||
guint8 alt_setting,
|
guint8 alt_setting,
|
||||||
|
Loading…
Reference in New Issue
Block a user