-/* $OpenBSD: hibernate_machdep.c,v 1.39 2017/05/29 12:58:37 jmatthew Exp $ */
+/* $OpenBSD: hibernate_machdep.c,v 1.40 2018/02/10 05:11:06 jmatthew Exp $ */
/*
* Copyright (c) 2012 Mike Larkin <mlarkin@openbsd.org>
extern int sr_hibernate_io(dev_t dev, daddr_t blkno,
vaddr_t addr, size_t size, int op, void *page);
struct device *dv = disk_lookup(&sd_cd, DISKUNIT(dev));
-
+ struct {
+ const char *driver;
+ hibio_fn io_func;
+ } sd_io_funcs[] = {
#if NAHCI > 0
- if (dv && dv->dv_parent && dv->dv_parent->dv_parent &&
- strcmp(dv->dv_parent->dv_parent->dv_cfdata->cf_driver->cd_name,
- "ahci") == 0)
- return ahci_hibernate_io;
+ { "ahci", ahci_hibernate_io },
#endif
#if NNVME > 0
- if (dv && dv->dv_parent && dv->dv_parent->dv_parent &&
- strcmp(dv->dv_parent->dv_parent->dv_cfdata->cf_driver->cd_name,
- "nvme") == 0)
- return nvme_hibernate_io;
+ { "nvme", nvme_hibernate_io },
#endif
#if NSOFTRAID > 0
- if (dv && dv->dv_parent && dv->dv_parent->dv_parent &&
- strcmp(dv->dv_parent->dv_parent->dv_cfdata->cf_driver->cd_name,
- "softraid") == 0)
- return sr_hibernate_io;
- }
+ { "softraid", sr_hibernate_io },
#endif
+ };
+
+ if (dv && dv->dv_parent && dv->dv_parent->dv_parent) {
+ const char *driver = dv->dv_parent->dv_parent->dv_cfdata->
+ cf_driver->cd_name;
+ int i;
+
+ for (i = 0; i < nitems(sd_io_funcs); i++) {
+ if (strcmp(driver, sd_io_funcs[i].driver) == 0)
+ return sd_io_funcs[i].io_func;
+ }
+ }
+ }
#endif /* NSD > 0 */
return NULL;
}
-/* $OpenBSD: hibernate_machdep.c,v 1.49 2016/05/20 02:30:41 mlarkin Exp $ */
+/* $OpenBSD: hibernate_machdep.c,v 1.50 2018/02/10 05:11:06 jmatthew Exp $ */
/*
* Copyright (c) 2011 Mike Larkin <mlarkin@openbsd.org>
extern int sr_hibernate_io(dev_t dev, daddr_t blkno,
vaddr_t addr, size_t size, int op, void *page);
struct device *dv = disk_lookup(&sd_cd, DISKUNIT(dev));
-
+ struct {
+ const char *driver;
+ hibio_fn io_func;
+ } sd_io_funcs[] = {
#if NAHCI > 0
- if (dv && dv->dv_parent && dv->dv_parent->dv_parent &&
- strcmp(dv->dv_parent->dv_parent->dv_cfdata->cf_driver->cd_name,
- "ahci") == 0)
- return ahci_hibernate_io;
+ { "ahci", ahci_hibernate_io },
#endif
#if NSOFTRAID > 0
- if (dv && dv->dv_parent && dv->dv_parent->dv_parent &&
- strcmp(dv->dv_parent->dv_parent->dv_cfdata->cf_driver->cd_name,
- "softraid") == 0)
- return sr_hibernate_io;
- }
+ { "softraid", sr_hibernate_io },
#endif
+ };
+
+ if (dv && dv->dv_parent && dv->dv_parent->dv_parent) {
+ const char *driver = dv->dv_parent->dv_parent->dv_cfdata->
+ cf_driver->cd_name;
+ int i;
+
+ for (i = 0; i < nitems(sd_io_funcs); i++) {
+ if (strcmp(driver, sd_io_funcs[i].driver) == 0)
+ return sd_io_funcs[i].io_func;
+ }
+ }
+ }
#endif /* NSD > 0 */
return NULL;
}