drivers/ioexpander: minor initialize and styling fixes

Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
This commit is contained in:
Petro Karashchenko 2022-02-17 23:14:52 +02:00 committed by Xiang Xiao
parent 61fa5d70f5
commit 27d75e7552
4 changed files with 113 additions and 95 deletions

View File

@ -124,11 +124,13 @@ static int ioe_dummy_multireadpin(FAR struct ioexpander_dev_s *dev,
FAR uint8_t *pins, FAR bool *values, FAR uint8_t *pins, FAR bool *values,
int count); int count);
#endif #endif
#ifdef CONFIG_IOEXPANDER_INT_ENABLE
static FAR void *ioe_dummy_attach(FAR struct ioexpander_dev_s *dev, static FAR void *ioe_dummy_attach(FAR struct ioexpander_dev_s *dev,
ioe_pinset_t pinset, ioe_pinset_t pinset,
ioe_callback_t callback, FAR void *arg); ioe_callback_t callback, FAR void *arg);
static int ioe_dummy_detach(FAR struct ioexpander_dev_s *dev, static int ioe_dummy_detach(FAR struct ioexpander_dev_s *dev,
FAR void *handle); FAR void *handle);
#endif
static ioe_pinset_t ioe_dummy_int_update(FAR struct ioe_dummy_dev_s *priv); static ioe_pinset_t ioe_dummy_int_update(FAR struct ioe_dummy_dev_s *priv);
static void ioe_dummy_interrupt_work(void *arg); static void ioe_dummy_interrupt_work(void *arg);
@ -152,14 +154,16 @@ static const struct ioexpander_ops_s g_ioe_dummy_ops =
ioe_dummy_option, ioe_dummy_option,
ioe_dummy_writepin, ioe_dummy_writepin,
ioe_dummy_readpin, ioe_dummy_readpin,
ioe_dummy_readpin, ioe_dummy_readpin
#ifdef CONFIG_IOEXPANDER_MULTIPIN #ifdef CONFIG_IOEXPANDER_MULTIPIN
ioe_dummy_multiwritepin, , ioe_dummy_multiwritepin
ioe_dummy_multireadpin, , ioe_dummy_multireadpin
ioe_dummy_multireadpin, , ioe_dummy_multireadpin
#endif
#ifdef CONFIG_IOEXPANDER_INT_ENABLE
, ioe_dummy_attach
, ioe_dummy_detach
#endif #endif
ioe_dummy_attach,
ioe_dummy_detach
}; };
/**************************************************************************** /****************************************************************************
@ -545,6 +549,7 @@ static int ioe_dummy_multireadpin(FAR struct ioexpander_dev_s *dev,
* *
****************************************************************************/ ****************************************************************************/
#ifdef CONFIG_IOEXPANDER_INT_ENABLE
static FAR void *ioe_dummy_attach(FAR struct ioexpander_dev_s *dev, static FAR void *ioe_dummy_attach(FAR struct ioexpander_dev_s *dev,
ioe_pinset_t pinset, ioe_pinset_t pinset,
ioe_callback_t callback, FAR void *arg) ioe_callback_t callback, FAR void *arg)
@ -576,6 +581,7 @@ static FAR void *ioe_dummy_attach(FAR struct ioexpander_dev_s *dev,
return handle; return handle;
} }
#endif
/**************************************************************************** /****************************************************************************
* Name: ioe_dummy_detach * Name: ioe_dummy_detach
@ -592,6 +598,7 @@ static FAR void *ioe_dummy_attach(FAR struct ioexpander_dev_s *dev,
* *
****************************************************************************/ ****************************************************************************/
#ifdef CONFIG_IOEXPANDER_INT_ENABLE
static int ioe_dummy_detach(FAR struct ioexpander_dev_s *dev, static int ioe_dummy_detach(FAR struct ioexpander_dev_s *dev,
FAR void *handle) FAR void *handle)
{ {
@ -611,6 +618,7 @@ static int ioe_dummy_detach(FAR struct ioexpander_dev_s *dev,
cb->cbarg = NULL; cb->cbarg = NULL;
return OK; return OK;
} }
#endif
/**************************************************************************** /****************************************************************************
* Name: ioe_dummy_int_update * Name: ioe_dummy_int_update

View File

@ -212,10 +212,15 @@ static const struct ioexpander_ops_s g_ioe_rpmsg_ops =
ioe_rpmsg_option, ioe_rpmsg_option,
ioe_rpmsg_writepin, ioe_rpmsg_writepin,
ioe_rpmsg_readpin, ioe_rpmsg_readpin,
ioe_rpmsg_readpin, ioe_rpmsg_readpin
#ifdef CONFIG_IOEXPANDER_MULTIPIN
, NULL
, NULL
, NULL
#endif
#ifdef CONFIG_IOEXPANDER_INT_ENABLE #ifdef CONFIG_IOEXPANDER_INT_ENABLE
ioe_rpmsg_attach, , ioe_rpmsg_attach
ioe_rpmsg_detach, , ioe_rpmsg_detach
#endif #endif
}; };
@ -288,31 +293,27 @@ static int ioe_rpmsg_sendrecv(FAR struct rpmsg_endpoint *ept,
static int ioe_rpmsg_direction(FAR struct ioexpander_dev_s *dev, uint8_t pin, static int ioe_rpmsg_direction(FAR struct ioexpander_dev_s *dev, uint8_t pin,
int dir) int dir)
{ {
FAR struct ioe_rpmsg_client_s *priv = FAR struct ioe_rpmsg_client_s *priv = (struct ioe_rpmsg_client_s *)dev;
(struct ioe_rpmsg_client_s *)dev;
struct ioe_rpmsg_direction_s msg; struct ioe_rpmsg_direction_s msg;
msg.pin = pin; msg.pin = pin;
msg.val = dir; msg.val = dir;
return ioe_rpmsg_sendrecv(&priv->ept, IOE_RPMSG_DIRECTION, return ioe_rpmsg_sendrecv(&priv->ept, IOE_RPMSG_DIRECTION,
(struct ioe_rpmsg_header_s *)&msg, (struct ioe_rpmsg_header_s *)&msg, sizeof(msg));
sizeof(msg));
} }
static int ioe_rpmsg_readpin(FAR struct ioexpander_dev_s *dev, uint8_t pin, static int ioe_rpmsg_readpin(FAR struct ioexpander_dev_s *dev, uint8_t pin,
FAR bool *value) FAR bool *value)
{ {
FAR struct ioe_rpmsg_client_s *priv = FAR struct ioe_rpmsg_client_s *priv = (struct ioe_rpmsg_client_s *)dev;
(struct ioe_rpmsg_client_s *)dev;
struct ioe_rpmsg_readpin_s msg; struct ioe_rpmsg_readpin_s msg;
int ret; int ret;
msg.pin = pin; msg.pin = pin;
ret = ioe_rpmsg_sendrecv(&priv->ept, IOE_RPMSG_READPIN, ret = ioe_rpmsg_sendrecv(&priv->ept, IOE_RPMSG_READPIN,
(struct ioe_rpmsg_header_s *)&msg, (struct ioe_rpmsg_header_s *)&msg, sizeof(msg));
sizeof(msg));
if (ret >= 0) if (ret >= 0)
{ {
*value = ret; *value = ret;
@ -324,23 +325,20 @@ static int ioe_rpmsg_readpin(FAR struct ioexpander_dev_s *dev, uint8_t pin,
static int ioe_rpmsg_writepin(FAR struct ioexpander_dev_s *dev, uint8_t pin, static int ioe_rpmsg_writepin(FAR struct ioexpander_dev_s *dev, uint8_t pin,
bool value) bool value)
{ {
FAR struct ioe_rpmsg_client_s *priv = FAR struct ioe_rpmsg_client_s *priv = (struct ioe_rpmsg_client_s *)dev;
(struct ioe_rpmsg_client_s *)dev;
struct ioe_rpmsg_writepin_s msg; struct ioe_rpmsg_writepin_s msg;
msg.pin = pin; msg.pin = pin;
msg.val = value; msg.val = value;
return ioe_rpmsg_sendrecv(&priv->ept, IOE_RPMSG_WRITEPIN, return ioe_rpmsg_sendrecv(&priv->ept, IOE_RPMSG_WRITEPIN,
(struct ioe_rpmsg_header_s *)&msg, (struct ioe_rpmsg_header_s *)&msg, sizeof(msg));
sizeof(msg));
} }
static int ioe_rpmsg_option(FAR struct ioexpander_dev_s *dev, uint8_t pin, static int ioe_rpmsg_option(FAR struct ioexpander_dev_s *dev, uint8_t pin,
int opt, void *regval) int opt, void *regval)
{ {
FAR struct ioe_rpmsg_client_s *priv = FAR struct ioe_rpmsg_client_s *priv = (struct ioe_rpmsg_client_s *)dev;
(struct ioe_rpmsg_client_s *)dev;
struct ioe_rpmsg_option_s msg; struct ioe_rpmsg_option_s msg;
msg.pin = pin; msg.pin = pin;
@ -348,8 +346,7 @@ static int ioe_rpmsg_option(FAR struct ioexpander_dev_s *dev, uint8_t pin,
msg.val = (uintptr_t)regval; msg.val = (uintptr_t)regval;
return ioe_rpmsg_sendrecv(&priv->ept, IOE_RPMSG_OPTION, return ioe_rpmsg_sendrecv(&priv->ept, IOE_RPMSG_OPTION,
(struct ioe_rpmsg_header_s *)&msg, (struct ioe_rpmsg_header_s *)&msg, sizeof(msg));
sizeof(msg));
} }
#ifdef CONFIG_IOEXPANDER_INT_ENABLE #ifdef CONFIG_IOEXPANDER_INT_ENABLE
@ -358,8 +355,7 @@ static void *ioe_rpmsg_attach(FAR struct ioexpander_dev_s *dev,
ioe_callback_t callback, ioe_callback_t callback,
FAR void *arg) FAR void *arg)
{ {
FAR struct ioe_rpmsg_client_s *priv = FAR struct ioe_rpmsg_client_s *priv = (struct ioe_rpmsg_client_s *)dev;
(struct ioe_rpmsg_client_s *)dev;
struct ioe_rpmsg_attach_s msg; struct ioe_rpmsg_attach_s msg;
int ret; int ret;
@ -368,8 +364,7 @@ static void *ioe_rpmsg_attach(FAR struct ioexpander_dev_s *dev,
msg.cbarg = (uintptr_t)arg; msg.cbarg = (uintptr_t)arg;
ret = ioe_rpmsg_sendrecv(&priv->ept, IOE_RPMSG_ATTACH, ret = ioe_rpmsg_sendrecv(&priv->ept, IOE_RPMSG_ATTACH,
(struct ioe_rpmsg_header_s *)&msg, (struct ioe_rpmsg_header_s *)&msg, sizeof(msg));
sizeof(msg));
if (ret >= 0) if (ret >= 0)
{ {
return (FAR void *)(ret + 1); return (FAR void *)(ret + 1);
@ -381,15 +376,13 @@ static void *ioe_rpmsg_attach(FAR struct ioexpander_dev_s *dev,
static int ioe_rpmsg_detach(FAR struct ioexpander_dev_s *dev, static int ioe_rpmsg_detach(FAR struct ioexpander_dev_s *dev,
FAR void *handle) FAR void *handle)
{ {
FAR struct ioe_rpmsg_client_s *priv = FAR struct ioe_rpmsg_client_s *priv = (struct ioe_rpmsg_client_s *)dev;
(struct ioe_rpmsg_client_s *)dev;
struct ioe_rpmsg_detach_s msg; struct ioe_rpmsg_detach_s msg;
msg.cbidx = (uintptr_t)handle - 1; msg.cbidx = (uintptr_t)handle - 1;
return ioe_rpmsg_sendrecv(&priv->ept, IOE_RPMSG_DETACH, return ioe_rpmsg_sendrecv(&priv->ept, IOE_RPMSG_DETACH,
(struct ioe_rpmsg_header_s *)&msg, (struct ioe_rpmsg_header_s *)&msg, sizeof(msg));
sizeof(msg));
} }
#endif #endif
@ -400,8 +393,7 @@ static int ioe_rpmsg_direction_handler(FAR struct rpmsg_endpoint *ept,
FAR struct ioe_rpmsg_direction_s *msg = data; FAR struct ioe_rpmsg_direction_s *msg = data;
FAR struct ioe_rpmsg_server_s *priv = priv_; FAR struct ioe_rpmsg_server_s *priv = priv_;
msg->header.result = IOEXP_SETDIRECTION(priv->ioe, msg->header.result = IOEXP_SETDIRECTION(priv->ioe, msg->pin, msg->val);
msg->pin, msg->val);
return rpmsg_send(ept, msg, len); return rpmsg_send(ept, msg, len);
} }
@ -413,8 +405,7 @@ static int ioe_rpmsg_option_handler(FAR struct rpmsg_endpoint *ept,
FAR struct ioe_rpmsg_option_s *msg = data; FAR struct ioe_rpmsg_option_s *msg = data;
FAR struct ioe_rpmsg_server_s *priv = priv_; FAR struct ioe_rpmsg_server_s *priv = priv_;
msg->header.result = IOEXP_SETOPTION(priv->ioe, msg->header.result = IOEXP_SETOPTION(priv->ioe, msg->pin, msg->opt,
msg->pin, msg->opt,
(void *)(uintptr_t)msg->val); (void *)(uintptr_t)msg->val);
return rpmsg_send(ept, msg, len); return rpmsg_send(ept, msg, len);
@ -427,8 +418,7 @@ static int ioe_rpmsg_writepin_handler(FAR struct rpmsg_endpoint *ept,
FAR struct ioe_rpmsg_writepin_s *msg = data; FAR struct ioe_rpmsg_writepin_s *msg = data;
FAR struct ioe_rpmsg_server_s *priv = priv_; FAR struct ioe_rpmsg_server_s *priv = priv_;
msg->header.result = IOEXP_WRITEPIN(priv->ioe, msg->header.result = IOEXP_WRITEPIN(priv->ioe, msg->pin, msg->val);
msg->pin, msg->val);
return rpmsg_send(ept, msg, len); return rpmsg_send(ept, msg, len);
} }
@ -463,21 +453,19 @@ static void ioe_rpmsg_irqworker(FAR void *priv_)
msg.cbarg = cb->cbarg; msg.cbarg = cb->cbarg;
ioe_rpmsg_sendrecv(cb->ept, IOE_RPMSG_IRQ, ioe_rpmsg_sendrecv(cb->ept, IOE_RPMSG_IRQ,
(struct ioe_rpmsg_header_s *)&msg, (struct ioe_rpmsg_header_s *)&msg, sizeof(msg));
sizeof(msg));
cb->pendset = 0; cb->pendset = 0;
} }
static int ioe_rpmsg_irq_cb(FAR struct ioexpander_dev_s *dev, static int ioe_rpmsg_irq_cb(FAR struct ioexpander_dev_s *dev,
ioe_pinset_t pinset, FAR void *priv_) ioe_pinset_t pinset, FAR void *priv_)
{ {
FAR struct ioe_rpmsg_cb_s *cb = priv_; FAR struct ioe_rpmsg_cb_s *cb = priv_;
cb->pendset |= pinset; cb->pendset |= pinset;
work_queue(HPWORK, &cb->work, ioe_rpmsg_irqworker, work_queue(HPWORK, &cb->work, ioe_rpmsg_irqworker, cb, 0);
cb, 0);
return OK; return OK;
} }
@ -494,9 +482,8 @@ static int ioe_rpmsg_attach_handler(FAR struct rpmsg_endpoint *ept,
{ {
if (!priv->cb[i].handler) if (!priv->cb[i].handler)
{ {
priv->cb[i].handler = priv->cb[i].handler = IOEP_ATTACH(priv->ioe, msg->pinset,
IOEP_ATTACH(priv->ioe, msg->pinset, ioe_rpmsg_irq_cb, &priv->cb[i]);
ioe_rpmsg_irq_cb, &priv->cb[i]);
if (priv->cb[i].handler) if (priv->cb[i].handler)
{ {
@ -521,8 +508,7 @@ static int ioe_rpmsg_detach_handler(FAR struct rpmsg_endpoint *ept,
FAR struct ioe_rpmsg_detach_s *msg = data; FAR struct ioe_rpmsg_detach_s *msg = data;
FAR struct ioe_rpmsg_server_s *priv = priv_; FAR struct ioe_rpmsg_server_s *priv = priv_;
msg->header.result = IOEP_DETACH(priv->ioe, msg->header.result = IOEP_DETACH(priv->ioe, priv->cb[msg->cbidx].handler);
priv->cb[msg->cbidx].handler);
if (msg->header.result >= 0) if (msg->header.result >= 0)
{ {
@ -585,13 +571,11 @@ static void ioe_rpmsg_client_created(FAR struct rpmsg_device *rdev,
if (!strcmp(priv->cpuname, rpmsg_get_cpuname(rdev))) if (!strcmp(priv->cpuname, rpmsg_get_cpuname(rdev)))
{ {
char eptname[RPMSG_NAME_SIZE]; char eptname[RPMSG_NAME_SIZE];
snprintf(eptname, RPMSG_NAME_SIZE, IOE_RPMSG_EPT_FORMAT, snprintf(eptname, RPMSG_NAME_SIZE, IOE_RPMSG_EPT_FORMAT, priv->name);
priv->name);
priv->ept.priv = priv; priv->ept.priv = priv;
rpmsg_create_ept(&priv->ept, rdev, eptname, rpmsg_create_ept(&priv->ept, rdev, eptname, RPMSG_ADDR_ANY,
RPMSG_ADDR_ANY, RPMSG_ADDR_ANY, RPMSG_ADDR_ANY, ioe_rpmsg_ept_cb, NULL);
ioe_rpmsg_ept_cb, NULL);
nxsem_post(&priv->sem); nxsem_post(&priv->sem);
} }
@ -624,8 +608,7 @@ static void ioe_rpmsg_server_bind(FAR struct rpmsg_device *rdev,
FAR struct ioe_rpmsg_server_s *priv = priv_; FAR struct ioe_rpmsg_server_s *priv = priv_;
char eptname[RPMSG_NAME_SIZE]; char eptname[RPMSG_NAME_SIZE];
snprintf(eptname, RPMSG_NAME_SIZE, IOE_RPMSG_EPT_FORMAT, snprintf(eptname, RPMSG_NAME_SIZE, IOE_RPMSG_EPT_FORMAT, priv->name);
priv->name);
if (!strcmp(name, eptname)) if (!strcmp(name, eptname))
{ {
@ -639,10 +622,8 @@ static void ioe_rpmsg_server_bind(FAR struct rpmsg_device *rdev,
ept->priv = priv; ept->priv = priv;
rpmsg_create_ept(ept, rdev, name, rpmsg_create_ept(ept, rdev, name, RPMSG_ADDR_ANY, RPMSG_ADDR_ANY,
RPMSG_ADDR_ANY, RPMSG_ADDR_ANY, ioe_rpmsg_ept_cb, ioe_rpmsg_server_unbind);
ioe_rpmsg_ept_cb,
ioe_rpmsg_server_unbind);
} }
} }
@ -678,10 +659,7 @@ int ioe_rpmsg_server_initialize(FAR const char *name,
priv->name = name; priv->name = name;
priv->ioe = ioe; priv->ioe = ioe;
ret = rpmsg_register_callback(priv, ret = rpmsg_register_callback(priv, NULL, NULL, ioe_rpmsg_server_bind);
NULL,
NULL,
ioe_rpmsg_server_bind);
if (ret < 0) if (ret < 0)
{ {
kmm_free(priv); kmm_free(priv);
@ -699,8 +677,7 @@ int ioe_rpmsg_server_initialize(FAR const char *name,
****************************************************************************/ ****************************************************************************/
FAR struct ioexpander_dev_s * FAR struct ioexpander_dev_s *
ioe_rpmsg_client_initialize(FAR const char *cpuname, ioe_rpmsg_client_initialize(FAR const char *cpuname, FAR const char *name)
FAR const char *name)
{ {
FAR struct ioe_rpmsg_client_s *priv; FAR struct ioe_rpmsg_client_s *priv;
int ret; int ret;
@ -717,14 +694,12 @@ ioe_rpmsg_client_initialize(FAR const char *cpuname,
} }
priv->ioe.ops = &g_ioe_rpmsg_ops; priv->ioe.ops = &g_ioe_rpmsg_ops;
priv->cpuname = cpuname; priv->cpuname = cpuname;
priv->name = name; priv->name = name;
nxsem_init(&priv->sem, 0, 0); nxsem_init(&priv->sem, 0, 0);
ret = rpmsg_register_callback(priv, ret = rpmsg_register_callback(priv, ioe_rpmsg_client_created,
ioe_rpmsg_client_created, ioe_rpmsg_client_destroy, NULL);
ioe_rpmsg_client_destroy,
NULL);
if (ret < 0) if (ret < 0)
{ {
kmm_free(priv); kmm_free(priv);

View File

@ -81,30 +81,33 @@ struct skel_dev_s
static int skel_lock(FAR struct skel_dev_s *priv); static int skel_lock(FAR struct skel_dev_s *priv);
static int skel_direction(FAR struct ioexpander_dev_s *dev, uint8_t pin, static int skel_direction(FAR struct ioexpander_dev_s *dev, uint8_t pin,
int dir); int dir);
static int skel_option(FAR struct ioexpander_dev_s *dev, uint8_t pin, static int skel_option(FAR struct ioexpander_dev_s *dev, uint8_t pin,
int opt, void *val); int opt, void *val);
static int skel_writepin(FAR struct ioexpander_dev_s *dev, uint8_t pin, static int skel_writepin(FAR struct ioexpander_dev_s *dev, uint8_t pin,
bool value); bool value);
static int skel_readpin(FAR struct ioexpander_dev_s *dev, uint8_t pin, static int skel_readpin(FAR struct ioexpander_dev_s *dev, uint8_t pin,
FAR bool *value); FAR bool *value);
static int skel_readbuf(FAR struct ioexpander_dev_s *dev, uint8_t pin, static int skel_readbuf(FAR struct ioexpander_dev_s *dev, uint8_t pin,
FAR bool *value); FAR bool *value);
#ifdef CONFIG_IOEXPANDER_MULTIPIN #ifdef CONFIG_IOEXPANDER_MULTIPIN
static int skel_multiwritepin(FAR struct ioexpander_dev_s *dev, static int skel_multiwritepin(FAR struct ioexpander_dev_s *dev,
FAR uint8_t *pins, FAR bool *values, int count); FAR uint8_t *pins, FAR bool *values,
int count);
static int skel_multireadpin(FAR struct ioexpander_dev_s *dev, static int skel_multireadpin(FAR struct ioexpander_dev_s *dev,
FAR uint8_t *pins, FAR bool *values, int count); FAR uint8_t *pins, FAR bool *values, int count);
static int skel_multireadbuf(FAR struct ioexpander_dev_s *dev, static int skel_multireadbuf(FAR struct ioexpander_dev_s *dev,
FAR uint8_t *pins, FAR bool *values, int count); FAR uint8_t *pins, FAR bool *values, int count);
#endif #endif
#ifdef CONFIG_IOEXPANDER_INT_ENABLE #ifdef CONFIG_IOEXPANDER_INT_ENABLE
static int skel_attach(FAR struct ioexpander_dev_s *dev, static int skel_attach(FAR struct ioexpander_dev_s *dev,
ioe_pinset_t pinset, ioe_callback_t callback); ioe_pinset_t pinset, ioe_callback_t callback);
#endif static int skel_detach(FAR struct ioexpander_dev_s *dev,
FAR void *handle);
static void skel_irqworker(void *arg); static void skel_irqworker(void *arg);
static void skel_interrupt(FAR void *arg); static void skel_interrupt(FAR void *arg);
#endif
/**************************************************************************** /****************************************************************************
* Private Data * Private Data
@ -134,6 +137,7 @@ static const struct ioexpander_ops_s g_skel_ops =
#endif #endif
#ifdef CONFIG_IOEXPANDER_INT_ENABLE #ifdef CONFIG_IOEXPANDER_INT_ENABLE
, skel_attach , skel_attach
, skel_detach
#endif #endif
}; };
@ -412,7 +416,7 @@ static int skel_getmultibits(FAR struct skel_dev_s *priv, FAR uint8_t *pins,
return -ENXIO; return -ENXIO;
} }
values[i] = ((pinset & (1 << pin) != 0); values[i] = ((pinset & (1 << pin)) != 0);
} }
return OK; return OK;
@ -438,8 +442,7 @@ static int skel_getmultibits(FAR struct skel_dev_s *priv, FAR uint8_t *pins,
#ifdef CONFIG_IOEXPANDER_MULTIPIN #ifdef CONFIG_IOEXPANDER_MULTIPIN
static int skel_multiwritepin(FAR struct ioexpander_dev_s *dev, static int skel_multiwritepin(FAR struct ioexpander_dev_s *dev,
FAR uint8_t *pins, FAR bool *values, FAR uint8_t *pins, FAR bool *values, int count)
int count)
{ {
FAR struct skel_dev_s *priv = (FAR struct skel_dev_s *)dev; FAR struct skel_dev_s *priv = (FAR struct skel_dev_s *)dev;
ioe_pinset_t pinset; ioe_pinset_t pinset;
@ -506,8 +509,7 @@ static int skel_multiwritepin(FAR struct ioexpander_dev_s *dev,
#ifdef CONFIG_IOEXPANDER_MULTIPIN #ifdef CONFIG_IOEXPANDER_MULTIPIN
static int skel_multireadpin(FAR struct ioexpander_dev_s *dev, static int skel_multireadpin(FAR struct ioexpander_dev_s *dev,
FAR uint8_t *pins, FAR bool *values, FAR uint8_t *pins, FAR bool *values, int count)
int count)
{ {
FAR struct skel_dev_s *priv = (FAR struct skel_dev_s *)dev; FAR struct skel_dev_s *priv = (FAR struct skel_dev_s *)dev;
int ret; int ret;
@ -549,8 +551,7 @@ static int skel_multireadpin(FAR struct ioexpander_dev_s *dev,
#ifdef CONFIG_IOEXPANDER_MULTIPIN #ifdef CONFIG_IOEXPANDER_MULTIPIN
static int skel_multireadbuf(FAR struct ioexpander_dev_s *dev, static int skel_multireadbuf(FAR struct ioexpander_dev_s *dev,
FAR uint8_t *pins, FAR bool *values, FAR uint8_t *pins, FAR bool *values, int count)
int count)
{ {
FAR struct skel_dev_s *priv = (FAR struct skel_dev_s *)dev; FAR struct skel_dev_s *priv = (FAR struct skel_dev_s *)dev;
int ret; int ret;
@ -590,7 +591,7 @@ static int skel_multireadbuf(FAR struct ioexpander_dev_s *dev,
* *
****************************************************************************/ ****************************************************************************/
#ifdef CONFIG_skeleton_INT_ENABLE #ifdef CONFIG_IOEXPANDER_INT_ENABLE
static int skel_attach(FAR struct ioexpander_dev_s *dev, ioe_pinset_t pinset, static int skel_attach(FAR struct ioexpander_dev_s *dev, ioe_pinset_t pinset,
ioe_callback_t callback) ioe_callback_t callback)
{ {
@ -630,6 +631,41 @@ static int skel_attach(FAR struct ioexpander_dev_s *dev, ioe_pinset_t pinset,
} }
#endif #endif
/****************************************************************************
* Name: skel_detach_detach
*
* Description:
* Detach and disable a pin interrupt callback function.
*
* Input Parameters:
* dev - Device-specific state data
* handle - The non-NULL opaque value return by skel_attach_attch()
*
* Returned Value:
* 0 on success, else a negative error code
*
****************************************************************************/
#ifdef CONFIG_IOEXPANDER_INT_ENABLE
static int skel_detach(FAR struct ioexpander_dev_s *dev, FAR void *handle)
{
FAR struct skel_dev_s *priv = (FAR struct skel_dev_s *)dev;
FAR struct skel_callback_s *cb =
(FAR struct skel_callback_s *)handle;
DEBUGASSERT(priv != NULL && cb != NULL);
DEBUGASSERT((uintptr_t)cb >= (uintptr_t)&priv->cb[0] &&
(uintptr_t)cb <=
(uintptr_t)&priv->cb[CONFIG_SKELETON_INT_NCALLBACKS - 1]);
UNUSED(priv);
cb->pinset = 0;
cb->cbfunc = NULL;
cb->cbarg = NULL;
return OK;
}
#endif
/**************************************************************************** /****************************************************************************
* Name: skel_irqworker * Name: skel_irqworker
* *
@ -639,7 +675,7 @@ static int skel_attach(FAR struct ioexpander_dev_s *dev, ioe_pinset_t pinset,
* *
****************************************************************************/ ****************************************************************************/
#ifdef CONFIG_skeleton_INT_ENABLE #ifdef CONFIG_IOEXPANDER_INT_ENABLE
static void skel_irqworker(void *arg) static void skel_irqworker(void *arg)
{ {
FAR struct skel_dev_s *priv = (FAR struct skel_dev_s *)arg; FAR struct skel_dev_s *priv = (FAR struct skel_dev_s *)arg;
@ -697,7 +733,7 @@ static void skel_irqworker(void *arg)
* *
****************************************************************************/ ****************************************************************************/
#ifdef CONFIG_skeleton_INT_ENABLE #ifdef CONFIG_IOEXPANDER_INT_ENABLE
static void skel_interrupt(FAR void *arg) static void skel_interrupt(FAR void *arg)
{ {
FAR struct skel_dev_s *priv = (FAR struct skel_dev_s *)arg; FAR struct skel_dev_s *priv = (FAR struct skel_dev_s *)arg;
@ -778,7 +814,7 @@ FAR struct ioexpander_dev_s *skel_initialize(void)
priv->dev.ops = &g_skel_ops; priv->dev.ops = &g_skel_ops;
#ifdef CONFIG_skeleton_INT_ENABLE #ifdef CONFIG_IOEXPANDER_INT_ENABLE
/* Attach the I/O expander interrupt handler and enable interrupts */ /* Attach the I/O expander interrupt handler and enable interrupts */
#warning Missing logic #warning Missing logic

View File

@ -335,8 +335,7 @@ struct ioexpander_ops_s
CODE FAR void *(*ioe_attach)(FAR struct ioexpander_dev_s *dev, CODE FAR void *(*ioe_attach)(FAR struct ioexpander_dev_s *dev,
ioe_pinset_t pinset, ioe_pinset_t pinset,
ioe_callback_t callback, FAR void *arg); ioe_callback_t callback, FAR void *arg);
CODE int (*ioe_detach)(FAR struct ioexpander_dev_s *dev, CODE int (*ioe_detach)(FAR struct ioexpander_dev_s *dev, FAR void *handle);
FAR void *handle);
#endif #endif
}; };