Commit ccac11ac authored by Jakob Bornecrantz's avatar Jakob Bornecrantz
Browse files

st/prober: Remove auto-wrapper

parent cc83b937
......@@ -10,7 +10,6 @@ include_directories(
set(PROBER_INCLUDES)
set(PROBER_SOURCE_FILES
p_auto_wrap.c
p_documentation.h
p_dump.c
p_prober.c
......
// Copyright 2019, Collabora, Ltd.
// SPDX-License-Identifier: BSL-1.0
/*!
* @file
* @brief Export a auto prober interface.
* @author Jakob Bornecrantz <jakob@collabora.com>
* @ingroup st_prober
*/
#include "xrt/xrt_compiler.h"
#include "xrt/xrt_prober.h"
#include "util/u_misc.h"
/*
*
* Structs and helprs.
*
*/
/*!
* Simple wrapper exposing the old interface.
*
* @ingroup st_prober
*/
struct prober_wrapper
{
struct xrt_auto_prober base;
struct xrt_prober *xp;
};
static inline struct prober_wrapper *
prober_wrapper(struct xrt_auto_prober *xap)
{
return (struct prober_wrapper *)xap;
}
/*
*
* Member functions.
*
*/
static struct xrt_device *
auto_probe(struct xrt_auto_prober *xap)
{
struct prober_wrapper *pw = prober_wrapper(xap);
struct xrt_device *xdev = NULL;
int ret;
ret = pw->xp->probe(pw->xp);
if (ret < 0) {
return NULL;
}
ret = pw->xp->select(pw->xp, &xdev, 1);
if (ret < 0) {
return NULL;
}
return xdev;
}
static void
destroy(struct xrt_auto_prober *xap)
{
struct prober_wrapper *pw = prober_wrapper(xap);
if (pw->xp != NULL) {
pw->xp->destroy(&pw->xp);
}
free(pw);
}
/*
*
* Exported function(s).
*
*/
struct xrt_auto_prober *
xrt_auto_prober_create()
{
struct prober_wrapper *pw = U_TYPED_CALLOC(struct prober_wrapper);
struct xrt_prober *xp = NULL;
int ret;
if (pw == NULL) {
return NULL;
}
ret = xrt_prober_create(&xp);
if (ret < 0) {
free(pw);
return NULL;
}
pw->base.lelo_dallas_autoprobe = auto_probe;
pw->base.destroy = destroy;
pw->xp = xp;
return &pw->base;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment