From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Gerd Hoffmann <kraxel@redhat.com>
Subject: [Qemu-devel] [PATCH 5/5] qdev: add watchdog capability
Date: Mon, 31 Aug 2009 12:27:39 +0200 [thread overview]
Message-ID: <1251714459-2467-6-git-send-email-kraxel@redhat.com> (raw)
In-Reply-To: <1251714459-2467-1-git-send-email-kraxel@redhat.com>
This patch add watchdog capability and tags the two watchdog drivers.
It also kill the private register functions and driver list in
watchdog.c, instead the qdev driver list and the watchdog capability
bit is used.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/qdev.c | 2 +-
hw/qdev.h | 3 +++
hw/watchdog.c | 53 +++++++++++++++++++++++++++++------------------------
hw/watchdog.h | 11 -----------
hw/wdt_i6300esb.c | 8 ++------
hw/wdt_ib700.c | 8 ++------
6 files changed, 37 insertions(+), 48 deletions(-)
diff --git a/hw/qdev.c b/hw/qdev.c
index b6a1a1d..a26bd46 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -33,7 +33,7 @@
/* This is a nasty hack to allow passing a NULL bus to qdev_create. */
static BusState *main_system_bus;
-static DeviceInfo *device_info_list;
+DeviceInfo *device_info_list;
static BusState *qbus_find_recursive(BusState *bus, const char *name,
const BusInfo *info);
diff --git a/hw/qdev.h b/hw/qdev.h
index 2df6ad3..d443534 100644
--- a/hw/qdev.h
+++ b/hw/qdev.h
@@ -106,11 +106,13 @@ enum DeviceCapBits {
DEV_CAP_BIT_AUDIO = 0,
DEV_CAP_BIT_ETHERNET = 1,
DEV_CAP_BIT_DISPLAY = 2,
+ DEV_CAP_BIT_WATCHDOG = 3,
};
#define DEV_CAP_AUDIO (1 << DEV_CAP_BIT_AUDIO)
#define DEV_CAP_ETHERNET (1 << DEV_CAP_BIT_ETHERNET)
#define DEV_CAP_DISPLAY (1 << DEV_CAP_BIT_DISPLAY)
+#define DEV_CAP_WATCHDOG (1 << DEV_CAP_BIT_WATCHDOG)
struct DeviceInfo {
const char *name;
@@ -126,6 +128,7 @@ struct DeviceInfo {
BusInfo *bus_info;
struct DeviceInfo *next;
};
+extern DeviceInfo *device_info_list;
void qdev_register(DeviceInfo *info);
diff --git a/hw/watchdog.c b/hw/watchdog.c
index adba872..5c6bb8a 100644
--- a/hw/watchdog.c
+++ b/hw/watchdog.c
@@ -24,6 +24,7 @@
#include "qemu-config.h"
#include "sys-queue.h"
#include "sysemu.h"
+#include "qdev.h"
#include "hw/watchdog.h"
/* Possible values for action parameter. */
@@ -35,47 +36,51 @@
#define WDT_NONE 6 /* Do nothing. */
static int watchdog_action = WDT_RESET;
-static LIST_HEAD(watchdog_list, WatchdogTimerModel) watchdog_list;
-
-void watchdog_add_model(WatchdogTimerModel *model)
-{
- LIST_INSERT_HEAD(&watchdog_list, model, entry);
-}
/* Returns:
* 0 = continue
* 1 = exit program with error
* 2 = exit program without error
*/
+
+static void print_watchdog_list(FILE *fp)
+{
+ DeviceInfo *info;
+
+ for (info = device_info_list; info != NULL; info = info->next) {
+ if (!(info->caps & DEV_CAP_WATCHDOG))
+ continue;
+ fprintf(fp, " %-10s %s (%s)\n", info->name, info->desc, info->bus_info->name);
+ }
+}
+
int select_watchdog(const char *p)
{
- WatchdogTimerModel *model;
+ DeviceInfo *info;
QemuOpts *opts;
/* -watchdog ? lists available devices and exits cleanly. */
if (strcmp(p, "?") == 0) {
- LIST_FOREACH(model, &watchdog_list, entry) {
- fprintf(stderr, "\t%s\t%s\n",
- model->wdt_name, model->wdt_description);
- }
+ print_watchdog_list(stderr);
return 2;
}
- LIST_FOREACH(model, &watchdog_list, entry) {
- if (strcasecmp(model->wdt_name, p) == 0) {
- /* add the device */
- opts = qemu_opts_create(&qemu_device_opts, NULL, 0);
- qemu_opt_set(opts, "driver", p);
- return 0;
- }
+ for (info = device_info_list; info != NULL; info = info->next) {
+ if (!(info->caps & DEV_CAP_WATCHDOG))
+ continue;
+ if (strcmp(p, info->name) == 0)
+ break;
}
-
- fprintf(stderr, "Unknown -watchdog device. Supported devices are:\n");
- LIST_FOREACH(model, &watchdog_list, entry) {
- fprintf(stderr, "\t%s\t%s\n",
- model->wdt_name, model->wdt_description);
+ if (info == NULL) {
+ fprintf(stderr, "Unknown -watchdog device. Supported devices are:\n");
+ print_watchdog_list(stderr);
+ return 1;
}
- return 1;
+
+ /* add the device */
+ opts = qemu_opts_create(&qemu_device_opts, NULL, 0);
+ qemu_opt_set(opts, "driver", p);
+ return 0;
}
int select_watchdog_action(const char *p)
diff --git a/hw/watchdog.h b/hw/watchdog.h
index 8c54fa4..2c042af 100644
--- a/hw/watchdog.h
+++ b/hw/watchdog.h
@@ -22,20 +22,9 @@
#ifndef QEMU_WATCHDOG_H
#define QEMU_WATCHDOG_H
-struct WatchdogTimerModel {
- LIST_ENTRY(WatchdogTimerModel) entry;
-
- /* Short name of the device - used to select it on the command line. */
- const char *wdt_name;
- /* Longer description (eg. manufacturer and full model number). */
- const char *wdt_description;
-};
-typedef struct WatchdogTimerModel WatchdogTimerModel;
-
/* in hw/watchdog.c */
extern int select_watchdog(const char *p);
extern int select_watchdog_action(const char *action);
-extern void watchdog_add_model(WatchdogTimerModel *model);
extern void watchdog_perform_action(void);
#endif /* QEMU_WATCHDOG_H */
diff --git a/hw/wdt_i6300esb.c b/hw/wdt_i6300esb.c
index 6927d43..1b46cbf 100644
--- a/hw/wdt_i6300esb.c
+++ b/hw/wdt_i6300esb.c
@@ -446,14 +446,11 @@ static int i6300esb_init(PCIDevice *dev)
return 0;
}
-static WatchdogTimerModel model = {
- .wdt_name = "i6300esb",
- .wdt_description = "Intel 6300ESB",
-};
-
static PCIDeviceInfo i6300esb_info = {
.qdev.name = "i6300esb",
+ .qdev.desc = "Intel 6300ESB",
.qdev.size = sizeof(I6300State),
+ .qdev.caps = DEV_CAP_WATCHDOG,
.config_read = i6300esb_config_read,
.config_write = i6300esb_config_write,
.init = i6300esb_init,
@@ -461,7 +458,6 @@ static PCIDeviceInfo i6300esb_info = {
static void i6300esb_register_devices(void)
{
- watchdog_add_model(&model);
pci_qdev_register(&i6300esb_info);
}
diff --git a/hw/wdt_ib700.c b/hw/wdt_ib700.c
index e0ee65a..c1570a4 100644
--- a/hw/wdt_ib700.c
+++ b/hw/wdt_ib700.c
@@ -98,20 +98,16 @@ static int wdt_ib700_init(ISADevice *dev)
return 0;
}
-static WatchdogTimerModel model = {
- .wdt_name = "ib700",
- .wdt_description = "iBASE 700",
-};
-
static ISADeviceInfo wdt_ib700_info = {
.qdev.name = "ib700",
+ .qdev.desc = "iBASE 700",
.qdev.size = sizeof(ISADevice),
+ .qdev.caps = DEV_CAP_WATCHDOG,
.init = wdt_ib700_init,
};
static void wdt_ib700_register_devices(void)
{
- watchdog_add_model(&model);
isa_qdev_register(&wdt_ib700_info);
}
--
1.6.2.5
next prev parent reply other threads:[~2009-08-31 10:27 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-31 10:27 [Qemu-devel] [PATCH 0/5] qdev: device capabilities Gerd Hoffmann
2009-08-31 10:27 ` [Qemu-devel] [PATCH 1/5] " Gerd Hoffmann
2009-08-31 10:27 ` [Qemu-devel] [PATCH 2/5] qdev: add audio capability Gerd Hoffmann
2009-08-31 10:27 ` [Qemu-devel] [PATCH 3/5] qdev: add ethernet capability Gerd Hoffmann
2009-08-31 10:27 ` [Qemu-devel] [PATCH 4/5] qdev: add display capability Gerd Hoffmann
2009-08-31 10:27 ` Gerd Hoffmann [this message]
2009-09-04 15:08 ` [Qemu-devel] [PATCH 0/5] qdev: device capabilities Anthony Liguori
2009-09-04 15:16 ` Gerd Hoffmann
2009-09-05 13:39 ` Anthony Liguori
2009-09-07 10:47 ` Gerd Hoffmann
2009-09-07 20:36 ` Anthony Liguori
2009-09-08 6:52 ` Gerd Hoffmann
2009-09-10 16:30 ` Markus Armbruster
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1251714459-2467-6-git-send-email-kraxel@redhat.com \
--to=kraxel@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).