linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Johnny Kim <johnny.kim@atmel.com>
Cc: devel@driverdev.osuosl.org, rachel.kim@atmel.com,
	chris.park@atmel.com, gregkh@linuxfoundation.org,
	linux-wireless@vger.kernel.org, jude.lee@atmel.com,
	Tony Cho <tony.cho@atmel.com>,
	leo.kim@atmel.com
Subject: Re: [PATCH 5/5] staging: wilc1000: use id value as argument
Date: Wed, 19 Aug 2015 13:05:09 +0300	[thread overview]
Message-ID: <20150819100509.GK5610@mwanda> (raw)
In-Reply-To: <55D43738.7000008@atmel.com>


> 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];
}


  reply	other threads:[~2015-08-19 10:04 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-13  4:41 [PATCH 0/5] staging: wilc1000: 64bit build patch Tony Cho
2015-08-13  4:41 ` [PATCH 1/5] staging: wilc1000: replace WILC_WFIDrvHandle by tstrWILC_WFIDrv Tony Cho
2015-08-13  4:41 ` [PATCH 2/5] staging: wilc1000: change void pointer type to real type Tony Cho
2015-08-14  6:26   ` Sudip Mukherjee
2015-08-15  2:01     ` Greg KH
2015-08-13  4:41 ` [PATCH 3/5] staging: wilc1000: clarify the argument type Tony Cho
2015-08-13  4:41 ` [PATCH 4/5] staging: wilc1000: use the real data type Tony Cho
2015-08-15  2:04   ` Greg KH
2015-08-13  4:41 ` [PATCH 5/5] staging: wilc1000: use id value as argument Tony Cho
2015-08-13 14:49   ` Dan Carpenter
2015-08-18  3:10     ` Johnny Kim
2015-08-18  9:12       ` Dan Carpenter
2015-08-19  7:58         ` Johnny Kim
2015-08-19 10:05           ` Dan Carpenter [this message]
  -- strict thread matches above, loose matches on Subject: below --
2015-08-10  5:58 [PATCH 0/5] 64 bit build patch Tony Cho
2015-08-10  5:58 ` [PATCH 5/5] staging: wilc1000: use id value as argument Tony Cho
2015-08-10  6:47   ` Julian Calaby
2015-08-10  7:53     ` Johnny Kim
2015-08-10 10:44   ` Dan Carpenter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150819100509.GK5610@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=chris.park@atmel.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=johnny.kim@atmel.com \
    --cc=jude.lee@atmel.com \
    --cc=leo.kim@atmel.com \
    --cc=linux-wireless@vger.kernel.org \
    --cc=rachel.kim@atmel.com \
    --cc=tony.cho@atmel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).