struct gpio_latch_priv { struct gpio_chip gc; struct gpio_descs *clk_gpios; struct gpio_descs *latched_gpios; int n_latched_gpios; unsignedint setup_duration_ns; unsignedint clock_duration_ns; unsignedlong *shadow; /* * Depending on whether any of the underlying GPIOs may sleep we either * use a mutex or a spinlock to protect our shadow map.
*/ union { struct mutex mutex; /* protects @shadow */
spinlock_t spinlock; /* protects @shadow */
};
};
staticint gpio_latch_set_unlocked(struct gpio_latch_priv *priv, int (*set)(struct gpio_desc *desc, int value), unsignedint offset, bool val)
{ int latch = offset / priv->n_latched_gpios, i, ret;
assign_bit(offset, priv->shadow, val);
for (i = 0; i < priv->n_latched_gpios; i++) {
ret = set(priv->latched_gpios->desc[i],
test_bit(latch * priv->n_latched_gpios + i,
priv->shadow)); if (ret) return ret;
}
staticbool gpio_latch_can_sleep(struct gpio_latch_priv *priv, unsignedint n_latches)
{ int i;
for (i = 0; i < n_latches; i++) if (gpiod_cansleep(priv->clk_gpios->desc[i])) returntrue;
for (i = 0; i < priv->n_latched_gpios; i++) if (gpiod_cansleep(priv->latched_gpios->desc[i])) returntrue;
returnfalse;
}
/* * Some value which is still acceptable to delay in atomic context. * If we need to go higher we might have to switch to usleep_range(), * but that cannot ne used in atomic context and the driver would have * to be adjusted to support that.
*/ #define DURATION_NS_MAX 5000
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.