Search Linux Wireless

Re: [PATCH 5/5] staging: wilc1000: use id value as argument

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> Real ID value means the value mapped to an alive NIC handler.

Who is mapping it?  It's all within the driver so it is not "real"
unless there external requirements.

> And when the driver transmits and receives some data frame with chipset,
> the ID is used to distinguish the data frame's owner. Just like the driver,
> chipset uses the appointed identifier. the data frame always includes the
> identifier.

Yes.  But it uses whatever we give it, otherwise it will break when we
change this.

> You know, current driver is using 32bit pointer address as the identifier.
> So, this patch converts the address value to integer value. As mentioned
> earlier, '0' value is the reserved value to terminate an alive NIC handler
> and inform it to chipset.

Ah... I see now.  In the original code we used pointers and NULL meant
disconnect.  Now we are using integers but we still want zero to be
disconnect.  Fine, just make the array one pointer larger, it's not
worth the extra headache (the first version had off by one bugs, and the
second version still had an off by one bug even after I pointed them out
in the first version), just to save 8 bytes:

/* Zero is not used, because a zero ID means disconnect */
static tstrWILC_WFIDrv *wfidrv_list[NUM_CONCURRENT_IFC + 1];

static int add_handler_in_list(tstrWILC_WFIDrv *handler)
{
	int i;

	for (i = 1; i < ARRAY_SIZE(wfidrv_list); i++) {
		if (!wfidrv_list[i]) {
			wfidrv_list[i] = handler;
			return 0;
		}
	}

	return -ENOBUFS;
}

static int remove_handler_in_list(tstrWILC_WFIDrv *handler)
{
	int i;

	for (i = 1; i < ARRAY_SIZE(wfidrv_list); i++) {
		if (wfidrv_list[i] == handler) {
			wfidrv_list[i] = NULL;
			return 0;
		}
	}

	return -EINVAL;
}

static int get_id_from_handler(tstrWILC_WFIDrv *handler)
{
	int i;

	if (!handler)
		return 0;

	for (i = 1; i < ARRAY_SIZE(wfidrv_list); i++) {
		if (wfidrv_list[i] == handler)
			return i;
	}

	return 0;
}

static tstrWILC_WFIDrv *get_handler_from_id(int id)
{
	if (id <= 0 || id >= ARRAY_SIZE(wfidrv_list))
		return NULL;

	return wfidrv_list[id];
}

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Wireless Personal Area Network]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Hiking]     [MIPS Linux]     [ARM Linux]     [Linux RAID]

  Powered by Linux