linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ivo van Doorn <ivdoorn@gmail.com>
To: "John W. Linville" <linville@tuxdriver.com>
Cc: rt2400-devel@lists.sourceforge.net, linux-wireless@vger.kernel.org
Subject: [PATCH 12/21] rt2x00: Input-polldev requires input device
Date: Sat, 27 Oct 2007 13:40:25 +0200	[thread overview]
Message-ID: <200710271340.25324.IvDoorn@gmail.com> (raw)
In-Reply-To: <200710271334.34192.IvDoorn@gmail.com>

input-polldev requires a correctly allocated
and initialized input device to be set for the
input_polled_dev->input field.
Failure to do that will prevent correct polling
of the device.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
---
 drivers/net/wireless/rt2x00/rt2x00rfkill.c |   35 ++++++++++++++++++++++++---
 1 files changed, 31 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/rt2x00/rt2x00rfkill.c b/drivers/net/wireless/rt2x00/rt2x00rfkill.c
index a0f8b8e..db513f1 100644
--- a/drivers/net/wireless/rt2x00/rt2x00rfkill.c
+++ b/drivers/net/wireless/rt2x00/rt2x00rfkill.c
@@ -68,8 +68,10 @@ static void rt2x00rfkill_poll(struct input_polled_dev *poll_dev)
 	struct rt2x00_dev *rt2x00dev = poll_dev->private;
 	int state = rt2x00dev->ops->lib->rfkill_poll(rt2x00dev);
 
-	if (rt2x00dev->rfkill->state != state)
+	if (rt2x00dev->rfkill->state != state) {
 		input_report_key(poll_dev->input, KEY_WLAN, 1);
+		input_report_key(poll_dev->input, KEY_WLAN, 0);
+	}
 }
 
 int rt2x00rfkill_register(struct rt2x00_dev *rt2x00dev)
@@ -114,7 +116,7 @@ int rt2x00rfkill_allocate(struct rt2x00_dev *rt2x00dev)
 	rt2x00dev->rfkill = rfkill_allocate(device, RFKILL_TYPE_WLAN);
 	if (!rt2x00dev->rfkill) {
 		ERROR(rt2x00dev, "Failed to allocate rfkill handler.\n");
-		return -ENOMEM;
+		goto exit;
 	}
 
 	rt2x00dev->rfkill->name = rt2x00dev->ops->name;
@@ -125,15 +127,39 @@ int rt2x00rfkill_allocate(struct rt2x00_dev *rt2x00dev)
 	rt2x00dev->poll_dev = input_allocate_polled_device();
 	if (!rt2x00dev->poll_dev) {
 		ERROR(rt2x00dev, "Failed to allocate polled device.\n");
-		rfkill_free(rt2x00dev->rfkill);
-		return -ENOMEM;
+		goto exit_free_rfkill;
 	}
 
 	rt2x00dev->poll_dev->private = rt2x00dev;
 	rt2x00dev->poll_dev->poll = rt2x00rfkill_poll;
 	rt2x00dev->poll_dev->poll_interval = RFKILL_POLL_INTERVAL;
 
+	rt2x00dev->poll_dev->input = input_allocate_device();
+	if (!rt2x00dev->poll_dev->input) {
+		ERROR(rt2x00dev, "Failed to allocate input device.\n");
+		goto exit_free_polldev;
+	}
+
+	rt2x00dev->poll_dev->input->name = rt2x00dev->ops->name;
+	rt2x00dev->poll_dev->input->phys = wiphy_name(rt2x00dev->hw->wiphy);
+	rt2x00dev->poll_dev->input->id.bustype = BUS_HOST;
+	rt2x00dev->poll_dev->input->id.vendor = 0x1814;
+	rt2x00dev->poll_dev->input->id.product = rt2x00dev->chip.rt;
+	rt2x00dev->poll_dev->input->id.version = rt2x00dev->chip.rev;
+	rt2x00dev->poll_dev->input->dev.parent = device;
+	rt2x00dev->poll_dev->input->evbit[0] = BIT(EV_KEY);
+	set_bit(KEY_WLAN, rt2x00dev->poll_dev->input->keybit);
+
 	return 0;
+
+exit_free_polldev:
+	input_free_polled_device(rt2x00dev->poll_dev);
+
+exit_free_rfkill:
+	rfkill_free(rt2x00dev->rfkill);
+
+exit:
+	return -ENOMEM;
 }
 
 void rt2x00rfkill_free(struct rt2x00_dev *rt2x00dev)
@@ -141,6 +167,7 @@ void rt2x00rfkill_free(struct rt2x00_dev *rt2x00dev)
 	if (!test_bit(CONFIG_SUPPORT_HW_BUTTON, &rt2x00dev->flags))
 		return;
 
+	input_free_device(rt2x00dev->poll_dev->input);
 	input_free_polled_device(rt2x00dev->poll_dev);
 	rfkill_free(rt2x00dev->rfkill);
 }
-- 
1.5.3.4


  parent reply	other threads:[~2007-10-27 11:25 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-27 11:34 Please pull 'upstream' branch of rt2x00 Ivo van Doorn
2007-10-27 11:35 ` [PATCH 1/21] rt2x00: Move quality statistics into seperate structure Ivo van Doorn
2007-10-27 11:35 ` [PATCH 2/21] rt2x00: Use enum defines Ivo van Doorn
2007-10-27 11:36 ` [PATCH 3/21] rt2x00: Correctly translate mac80211 antenna setup to rt2x00 Ivo van Doorn
2007-10-27 11:36 ` [PATCH 4/21] rt2x00: SW diversity should default to antenna B Ivo van Doorn
2007-10-27 11:37 ` [PATCH 5/21] rt2x00: Remove rt2x00_clear_link Ivo van Doorn
2007-10-27 11:37 ` [PATCH 6/21] rt2x00: Implement SW diversity Ivo van Doorn
2007-10-27 11:38 ` [PATCH 7/21] rt2x00: Cleanup if-statements Ivo van Doorn
2007-10-27 11:38 ` [PATCH 8/21] rt2x00: Fix antenna selection Ivo van Doorn
2007-10-27 11:39 ` [PATCH 9/21] rt2x00: Release rt2x00 2.0.11 Ivo van Doorn
2007-10-27 11:39 ` [PATCH 10/21] rt2x00: Disable RX when switching antenna Ivo van Doorn
2007-10-27 11:39 ` [PATCH 11/21] rt2x00: Split rt61/rt73 antenna selection into RX and TX antenna Ivo van Doorn
2007-10-27 11:40 ` Ivo van Doorn [this message]
2007-10-27 11:40 ` [PATCH 13/21] rt2x00: Detect initial rfkill state on register Ivo van Doorn
2007-10-27 11:41 ` [PATCH 14/21] rt2x00: Unconstify rt2x00dev Ivo van Doorn
2007-10-27 11:41 ` [PATCH 15/21] rt2x00: Rework rt61 antenna selection Ivo van Doorn
2007-10-27 11:42 ` [PATCH 16/21] rt2x00: Remove unused variables Ivo van Doorn
2007-10-27 11:42 ` [PATCH 17/21] rt2x00: Rework rt73 antenna selection Ivo van Doorn
2007-10-27 11:43 ` [PATCH 18/21] rt2x00: Remove data_desc structure Ivo van Doorn
2007-10-27 11:43 ` [PATCH 19/21] rt2x00: Place mutex around USB register access Ivo van Doorn
2007-10-27 11:43 ` [PATCH 20/21] rt2x00: Correctly set ACK bit in tx descriptors Ivo van Doorn
2007-10-27 11:44 ` [PATCH 21/21] rt2x00: Release rt2x00 2.0.12 Ivo van Doorn
2007-10-27 12:47 ` [Rt2400-devel] Please pull 'upstream' branch of rt2x00 John W. Linville
2007-10-27 14:45   ` Ivo van Doorn
2007-10-27 16:19     ` Ivo van Doorn

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=200710271340.25324.IvDoorn@gmail.com \
    --to=ivdoorn@gmail.com \
    --cc=linux-wireless@vger.kernel.org \
    --cc=linville@tuxdriver.com \
    --cc=rt2400-devel@lists.sourceforge.net \
    /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).