1
0

firewire: core: use macro expression for not-registered state of BUS_MANAGER_ID

The value of BUS_MANAGER_ID register has 0x3f when no node_id is
registered. Current implementation uses hard-coded numeric literal but
in the case the macro expression is preferable since it is easy to
distinguish the state from node ID mask.

This commit applies the idea.

Link: https://lore.kernel.org/r/20250913105737.778038-3-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
This commit is contained in:
Takashi Sakamoto
2025-09-13 19:57:37 +09:00
parent 91bf158f8c
commit 2ba08d1bad
2 changed files with 11 additions and 4 deletions

View File

@@ -327,7 +327,7 @@ static void bm_work(struct work_struct *work)
* next generation.
*/
__be32 data[2] = {
cpu_to_be32(0x3f),
cpu_to_be32(BUS_MANAGER_ID_NOT_REGISTERED),
cpu_to_be32(local_id),
};
struct fw_device *irm_device = fw_node_get_device(card->irm_node);
@@ -372,10 +372,14 @@ static void bm_work(struct work_struct *work)
if (rcode == RCODE_COMPLETE) {
int bm_id = be32_to_cpu(data[0]);
if (generation == card->generation)
card->bm_node_id = bm_id == 0x3f ? local_id : 0xffc0 | bm_id;
if (generation == card->generation) {
if (bm_id != BUS_MANAGER_ID_NOT_REGISTERED)
card->bm_node_id = 0xffc0 & bm_id;
else
card->bm_node_id = local_id;
}
if (bm_id != 0x3f) {
if (bm_id != BUS_MANAGER_ID_NOT_REGISTERED) {
spin_unlock_irq(&card->lock);
// Somebody else is BM. Only act as IRM.

View File

@@ -170,6 +170,9 @@ static inline void fw_iso_context_init_work(struct fw_iso_context *ctx, work_fun
/* -topology */
// The initial value of BUS_MANAGER_ID register, to express nothing registered.
#define BUS_MANAGER_ID_NOT_REGISTERED 0x3f
enum {
FW_NODE_CREATED,
FW_NODE_UPDATED,