udev-util: add generic device_get_{vendor,model}_string() helpers

We chck the same props in various places, add a single implementation of
a call to inquire this.
This commit is contained in:
Lennart Poettering
2023-11-13 16:24:17 +01:00
parent 7e91c97aff
commit 3cc7a9fd25
7 changed files with 49 additions and 41 deletions
+5 -8
View File
@@ -11,11 +11,12 @@
#include "build.h"
#include "cgroup-util.h"
#include "conf-parser.h"
#include "devnum-util.h"
#include "device-util.h"
#include "devnum-util.h"
#include "main-func.h"
#include "path-util.h"
#include "pretty-print.h"
#include "udev-util.h"
#include "verbs.h"
static char *arg_target_solution = NULL;
@@ -248,14 +249,10 @@ static int query_solutions_for_path(const char *path) {
if (r < 0)
return log_error_errno(r, "Error looking up device: %m");
r = sd_device_get_property_value(device, "ID_MODEL_FROM_DATABASE", &model_name);
r = device_get_model_string(device, &model_name);
if (r == -ENOENT) {
log_device_debug(device, "Missing ID_MODEL_FROM_DATABASE property, trying ID_MODEL");
r = sd_device_get_property_value(device, "ID_MODEL", &model_name);
if (r == -ENOENT) {
log_device_info(device, "Device model not found");
return 0;
}
log_device_info(device, "Device model not found");
return 0;
}
if (r < 0)
return log_device_error_errno(device, r, "Model name for device %s is unknown", path);