mirror of
https://git.proxmox.com/git/fwupd
synced 2025-05-30 14:51:04 +00:00
59 lines
1.3 KiB
C
59 lines
1.3 KiB
C
/*
|
|
* Copyright (C) 2018 Richard Hughes <richard@hughsie.com>
|
|
*
|
|
* SPDX-License-Identifier: LGPL-2.1+
|
|
*/
|
|
|
|
#include "config.h"
|
|
|
|
#include "fu-plugin.h"
|
|
#include "fu-plugin-vfuncs.h"
|
|
|
|
#include "fu-nvme-device.h"
|
|
|
|
gboolean
|
|
fu_plugin_udev_device_added (FuPlugin *plugin, GUdevDevice *udev_device, GError **error)
|
|
{
|
|
g_autoptr(FuNvmeDevice) dev = NULL;
|
|
g_autoptr(FuDeviceLocker) locker = NULL;
|
|
|
|
/* interesting device? */
|
|
if (g_strcmp0 (g_udev_device_get_subsystem (udev_device), "nvme") != 0)
|
|
return TRUE;
|
|
|
|
dev = fu_nvme_device_new (udev_device);
|
|
locker = fu_device_locker_new (dev, error);
|
|
if (locker == NULL)
|
|
return FALSE;
|
|
fu_plugin_device_add (plugin, FU_DEVICE (dev));
|
|
return TRUE;
|
|
}
|
|
|
|
void
|
|
fu_plugin_init (FuPlugin *plugin)
|
|
{
|
|
fu_plugin_add_udev_subsystem (plugin, "nvme");
|
|
}
|
|
|
|
gboolean
|
|
fu_plugin_update (FuPlugin *plugin,
|
|
FuDevice *device,
|
|
GBytes *blob_fw,
|
|
FwupdInstallFlags flags,
|
|
GError **error)
|
|
{
|
|
g_autoptr(FuDeviceLocker) locker = NULL;
|
|
if ((flags & FWUPD_INSTALL_FLAG_FORCE) == 0) {
|
|
g_set_error_literal (error,
|
|
G_IO_ERROR,
|
|
G_IO_ERROR_NOT_SUPPORTED,
|
|
"writing NVMe firmware is untested, "
|
|
"use --force to override");
|
|
return FALSE;
|
|
}
|
|
locker = fu_device_locker_new (device, error);
|
|
if (locker == NULL)
|
|
return FALSE;
|
|
return fu_device_write_firmware (device, blob_fw, error);
|
|
}
|