linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg KH <gregkh@suse.de>
To: linux-kernel@vger.kernel.org
Cc: kay.sievers@suse.de
Subject: [PATCH] INPUT: add MODALIAS to the event environment
Date: Fri, 13 Jan 2006 11:50:08 -0800	[thread overview]
Message-ID: <11371818084013@kroah.com> (raw)
In-Reply-To: <11371818082670@kroah.com>

[PATCH] INPUT: add MODALIAS to the event environment

input: add MODALIAS to the event environment

Signed-off-by: Kay Sievers <kay.sievers@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

---
commit bd37e5a951ad2123d3f51f59c407b5242946b6ba
tree 3a9b4875ee602d9495d4b3e1f202b20d644ae793
parent 67daf5f11f06b9b15f8320de1d237ccc2e74fe43
author Kay Sievers <kay.sievers@suse.de> Thu, 05 Jan 2006 13:19:55 +0100
committer Greg Kroah-Hartman <gregkh@suse.de> Fri, 13 Jan 2006 11:26:04 -0800

 drivers/input/input.c |   55 +++++++++++++++++++++++++++++++++----------------
 1 files changed, 37 insertions(+), 18 deletions(-)

diff --git a/drivers/input/input.c b/drivers/input/input.c
index fe33ff3..4fe3da3 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -528,40 +528,56 @@ INPUT_DEV_STRING_ATTR_SHOW(name);
 INPUT_DEV_STRING_ATTR_SHOW(phys);
 INPUT_DEV_STRING_ATTR_SHOW(uniq);
 
-static int print_modalias_bits(char *buf, char prefix, unsigned long *arr,
+static int print_modalias_bits(char *buf, int size, char prefix, unsigned long *arr,
 			       unsigned int min, unsigned int max)
 {
 	int len, i;
 
-	len = sprintf(buf, "%c", prefix);
+	len = snprintf(buf, size, "%c", prefix);
 	for (i = min; i < max; i++)
 		if (arr[LONG(i)] & BIT(i))
-			len += sprintf(buf+len, "%X,", i);
+			len += snprintf(buf + len, size - len, "%X,", i);
 	return len;
 }
 
-static ssize_t input_dev_show_modalias(struct class_device *dev, char *buf)
+static int print_modalias(char *buf, int size, struct input_dev *id)
 {
-	struct input_dev *id = to_input_dev(dev);
-	ssize_t len = 0;
+	int len;
 
-	len += sprintf(buf+len, "input:b%04Xv%04Xp%04Xe%04X-",
+	len = snprintf(buf, size, "input:b%04Xv%04Xp%04Xe%04X-",
 		       id->id.bustype,
 		       id->id.vendor,
 		       id->id.product,
 		       id->id.version);
 
-	len += print_modalias_bits(buf+len, 'e', id->evbit, 0, EV_MAX);
-	len += print_modalias_bits(buf+len, 'k', id->keybit,
+	len += print_modalias_bits(buf + len, size - len, 'e', id->evbit,
+				   0, EV_MAX);
+	len += print_modalias_bits(buf + len, size - len, 'k', id->keybit,
 				   KEY_MIN_INTERESTING, KEY_MAX);
-	len += print_modalias_bits(buf+len, 'r', id->relbit, 0, REL_MAX);
-	len += print_modalias_bits(buf+len, 'a', id->absbit, 0, ABS_MAX);
-	len += print_modalias_bits(buf+len, 'm', id->mscbit, 0, MSC_MAX);
-	len += print_modalias_bits(buf+len, 'l', id->ledbit, 0, LED_MAX);
-	len += print_modalias_bits(buf+len, 's', id->sndbit, 0, SND_MAX);
-	len += print_modalias_bits(buf+len, 'f', id->ffbit, 0, FF_MAX);
-	len += print_modalias_bits(buf+len, 'w', id->swbit, 0, SW_MAX);
-	len += sprintf(buf+len, "\n");
+	len += print_modalias_bits(buf + len, size - len, 'r', id->relbit,
+				   0, REL_MAX);
+	len += print_modalias_bits(buf + len, size - len, 'a', id->absbit,
+				   0, ABS_MAX);
+	len += print_modalias_bits(buf + len, size - len, 'm', id->mscbit,
+				   0, MSC_MAX);
+	len += print_modalias_bits(buf + len, size - len, 'l', id->ledbit,
+				   0, LED_MAX);
+	len += print_modalias_bits(buf + len, size - len, 's', id->sndbit,
+				   0, SND_MAX);
+	len += print_modalias_bits(buf + len, size - len, 'f', id->ffbit,
+				   0, FF_MAX);
+	len += print_modalias_bits(buf + len, size - len, 'w', id->swbit,
+				   0, SW_MAX);
+	return len;
+}
+
+static ssize_t input_dev_show_modalias(struct class_device *dev, char *buf)
+{
+	struct input_dev *id = to_input_dev(dev);
+	ssize_t len;
+
+	len = print_modalias(buf, PAGE_SIZE, id);
+	len += snprintf(buf + len, PAGE_SIZE-len, "\n");
 	return len;
 }
 static CLASS_DEVICE_ATTR(modalias, S_IRUGO, input_dev_show_modalias, NULL);
@@ -728,8 +744,11 @@ static int input_dev_uevent(struct class
 	if (test_bit(EV_SW, dev->evbit))
 		INPUT_ADD_HOTPLUG_BM_VAR("SW=", dev->swbit, SW_MAX);
 
-	envp[i] = NULL;
+	envp[i++] = buffer + len;
+	len += snprintf(buffer + len, buffer_size - len, "MODALIAS=");
+	len += print_modalias(buffer + len, buffer_size - len, dev) + 1;
 
+	envp[i] = NULL;
 	return 0;
 }
 


  reply	other threads:[~2006-01-13 19:53 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-01-13 19:46 [GIT PATCH] More Driver Core patches for 2.6.15 Greg KH
2006-01-13 19:50 ` [PATCH] Add bus_type probe, remove, shutdown methods Greg KH
2006-01-13 19:50   ` [PATCH] Add pci_bus_type probe and remove methods Greg KH
2006-01-13 19:50     ` Greg KH [this message]
2006-01-13 19:50       ` [PATCH] Add SA1111 bus_type probe/remove methods Greg KH
2006-01-13 19:50         ` [PATCH] Add locomo " Greg KH
2006-01-13 19:50           ` [PATCH] Add logic module " Greg KH
2006-01-13 19:50             ` [PATCH] Add tiocx " Greg KH
2006-01-13 19:50               ` [PATCH] Add ecard_bus_type probe/remove/shutdown methods Greg KH
2006-01-13 19:50                 ` [PATCH] Add of_platform_bus_type probe and remove methods Greg KH
2006-01-13 19:50                   ` [PATCH] Add ocp_bus_type " Greg KH
2006-01-13 19:50                     ` [PATCH] Add parisc_bus_type " Greg KH
2006-01-13 19:50                       ` [PATCH] Add sh_bus_type " Greg KH
2006-01-13 19:50                         ` [PATCH] Add gameport bus_type " Greg KH
2006-01-13 19:50                           ` [PATCH] Add vio_bus_type " Greg KH
2006-01-13 19:50                             ` [PATCH] Add serio bus_type " Greg KH
2006-01-13 19:50                               ` [PATCH] Add dio_bus_type " Greg KH
2006-01-13 19:50                                 ` [PATCH] Add i2c_bus_type " Greg KH
2006-01-13 19:50                                   ` [PATCH] Add pcmcia_bus_type " Greg KH
2006-01-13 19:50                                     ` [PATCH] Add MCP bus_type " Greg KH
2006-01-13 19:50                                       ` [PATCH] Add macio_bus_type " Greg KH
2006-01-13 19:50                                         ` [PATCH] Add mmc_bus_type " Greg KH
2006-01-13 19:50                                           ` [PATCH] Add pnp_bus_type " Greg KH
2006-01-13 19:50                                             ` [PATCH] Add usb_serial_bus_type " Greg KH
2006-01-13 19:50                                               ` [PATCH] Add ccwgroup_bus_type " Greg KH
2006-01-13 19:50                                                 ` [PATCH] Add superhyway_bus_type " Greg KH
2006-01-13 19:50                                                   ` [PATCH] Add ide_bus_type " Greg KH
2006-01-13 19:50                                                     ` [PATCH] Add zorro_bus_type " Greg KH
2006-01-13 19:50                                                       ` [PATCH] Add Pseudo LLD bus_type " Greg KH
2006-01-13 19:50                                                         ` [PATCH] Add rio_bus_type " Greg KH
2006-01-13 19:50                                                           ` [PATCH] platform-device-del typo fix Greg KH
2006-01-13 19:50                                                             ` [PATCH] Add bttv sub bus_type probe and remove methods Greg KH
2006-01-13 19:50                                                               ` [PATCH] Add {css,ccw}_bus_type probe, remove, shutdown methods Greg KH
2006-01-13 19:50                                                                 ` [PATCH] Remove usb gadget generic driver methods Greg KH
2006-01-13 19:50                                                                   ` [PATCH] device_shutdown can loop if the driver frees itself Greg KH
2006-01-13 20:06                                                     ` [PATCH] Add ide_bus_type probe and remove methods Bartlomiej Zolnierkiewicz
2006-01-14 19:57                                                       ` Russell King
2006-01-14 20:32                                                         ` Bartlomiej Zolnierkiewicz
2006-01-23  8:39                                                         ` Bartlomiej Zolnierkiewicz
2006-01-14  5:14       ` [PATCH] INPUT: add MODALIAS to the event environment Alexander E. Patrakov
2006-01-14 11:04         ` Kay Sievers
2006-01-14 13:15           ` Alexander E. Patrakov
2006-01-14 13:21             ` Kay Sievers
2006-01-14 13:42               ` Alexander E. Patrakov
2006-01-14 14:11                 ` Kay Sievers
2006-01-14 14:50                   ` Alexander E. Patrakov
2006-01-23  6:00             ` Dmitry Torokhov

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=11371818084013@kroah.com \
    --to=gregkh@suse.de \
    --cc=greg@kroah.com \
    --cc=kay.sievers@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    /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).