void j1939_ecu_unmap_all(struct j1939_priv *priv)
{ int i;
write_lock_bh(&priv->lock); for (i = 0; i < ARRAY_SIZE(priv->ents); i++) if (priv->ents[i].ecu)
j1939_ecu_unmap_locked(priv->ents[i].ecu);
write_unlock_bh(&priv->lock);
}
void j1939_ecu_timer_start(struct j1939_ecu *ecu)
{ /* The ECU is held here and released in the * j1939_ecu_timer_handler() or j1939_ecu_timer_cancel().
*/
j1939_ecu_get(ecu);
/* Schedule timer in 250 msec to commit address change. */
hrtimer_start(&ecu->ac_timer, ms_to_ktime(250),
HRTIMER_MODE_REL_SOFT);
}
void j1939_ecu_timer_cancel(struct j1939_ecu *ecu)
{ if (hrtimer_cancel(&ecu->ac_timer))
j1939_ecu_put(ecu);
}
read_lock_bh(&priv->lock);
ecu = j1939_ecu_find_by_name_locked(priv, name); if (ecu && j1939_ecu_is_mapped_locked(ecu)) /* ecu's SA is registered */
addr = ecu->addr;
read_unlock_bh(&priv->lock);
return addr;
}
/* TX addr/name accounting * Transport protocol needs to know if a SA is local or not * These functions originate from userspace manipulating sockets, * so locking is straigforward
*/
int j1939_local_ecu_get(struct j1939_priv *priv, name_t name, u8 sa)
{ struct j1939_ecu *ecu; int err = 0;
write_lock_bh(&priv->lock);
if (j1939_address_is_unicast(sa))
priv->ents[sa].nusers++;
if (!name) goto done;
ecu = j1939_ecu_get_by_name_locked(priv, name); if (!ecu)
ecu = j1939_ecu_create_locked(priv, name);
err = PTR_ERR_OR_ZERO(ecu); if (err) { if (j1939_address_is_unicast(sa))
priv->ents[sa].nusers--; goto done;
}
ecu->nusers++; /* TODO: do we care if ecu->addr != sa? */ if (j1939_ecu_is_mapped_locked(ecu)) /* ecu's sa is active already */
priv->ents[ecu->addr].nusers++;
if (j1939_address_is_unicast(sa))
priv->ents[sa].nusers--;
if (!name) goto done;
ecu = j1939_ecu_find_by_name_locked(priv, name); if (WARN_ON_ONCE(!ecu)) goto done;
ecu->nusers--; /* TODO: do we care if ecu->addr != sa? */ if (j1939_ecu_is_mapped_locked(ecu)) /* ecu's sa is active already */
priv->ents[ecu->addr].nusers--;
j1939_ecu_put(ecu);
done:
write_unlock_bh(&priv->lock);
}
Messung V0.5
¤ Dauer der Verarbeitung: 0.10 Sekunden
(vorverarbeitet)
¤
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.