From: Dmitry Torokhov <dtor_core@ameritech.net>
To: Vojtech Pavlik <vojtech@suse.cz>
Cc: linux-kernel@vger.kernel.org
Subject: [patch 01/24] uinput: formatting, cleanup
Date: Mon, 25 Jul 2005 00:34:50 -0500 [thread overview]
Message-ID: <20050725054530.674379000.dtor_core@ameritech.net> (raw)
In-Reply-To: 20050725053449.483098000.dtor_core@ameritech.net
[-- Attachment #1: uinput-cleanup.patch --]
[-- Type: text/plain, Size: 7452 bytes --]
Input: clean up uinput driver (formatting, extra braces)
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
---
drivers/input/misc/uinput.c | 81 +++++++++++++++++++-------------------------
1 files changed, 35 insertions(+), 46 deletions(-)
Index: work/drivers/input/misc/uinput.c
===================================================================
--- work.orig/drivers/input/misc/uinput.c
+++ work/drivers/input/misc/uinput.c
@@ -36,16 +36,6 @@
#include <linux/miscdevice.h>
#include <linux/uinput.h>
-static int uinput_dev_open(struct input_dev *dev)
-{
- return 0;
-}
-
-static void uinput_dev_close(struct input_dev *dev)
-{
-
-}
-
static int uinput_dev_event(struct input_dev *dev, unsigned int type, unsigned int code, int value)
{
struct uinput_device *udev;
@@ -68,17 +58,20 @@ static int uinput_request_alloc_id(struc
/* Atomically allocate an ID for the given request. Returns 0 on success. */
struct uinput_device *udev = dev->private;
int id;
+ int err = -1;
down(&udev->requests_sem);
- for (id=0; id<UINPUT_NUM_REQUESTS; id++)
+
+ for (id = 0; id < UINPUT_NUM_REQUESTS; id++)
if (!udev->requests[id]) {
udev->requests[id] = request;
request->id = id;
- up(&udev->requests_sem);
- return 0;
+ err = 0;
+ break;
}
+
up(&udev->requests_sem);
- return -1;
+ return err;
}
static struct uinput_request* uinput_request_find(struct uinput_device *udev, int id)
@@ -101,7 +94,7 @@ static void uinput_request_init(struct i
/* Allocate an ID. If none are available right away, wait. */
request->retval = wait_event_interruptible(udev->requests_waitq,
- !uinput_request_alloc_id(dev, request));
+ !uinput_request_alloc_id(dev, request));
}
static void uinput_request_submit(struct input_dev *dev, struct uinput_request *request)
@@ -159,32 +152,30 @@ static int uinput_create_device(struct u
return -EINVAL;
}
- udev->dev->open = uinput_dev_open;
- udev->dev->close = uinput_dev_close;
udev->dev->event = uinput_dev_event;
udev->dev->upload_effect = uinput_dev_upload_effect;
udev->dev->erase_effect = uinput_dev_erase_effect;
udev->dev->private = udev;
- init_waitqueue_head(&(udev->waitq));
+ init_waitqueue_head(&udev->waitq);
input_register_device(udev->dev);
- set_bit(UIST_CREATED, &(udev->state));
+ set_bit(UIST_CREATED, &udev->state);
return 0;
}
static int uinput_destroy_device(struct uinput_device *udev)
{
- if (!test_bit(UIST_CREATED, &(udev->state))) {
+ if (!test_bit(UIST_CREATED, &udev->state)) {
printk(KERN_WARNING "%s: create the device first\n", UINPUT_NAME);
return -EINVAL;
}
input_unregister_device(udev->dev);
- clear_bit(UIST_CREATED, &(udev->state));
+ clear_bit(UIST_CREATED, &udev->state);
return 0;
}
@@ -253,15 +244,15 @@ static int uinput_alloc_device(struct fi
struct uinput_user_dev *user_dev;
struct input_dev *dev;
struct uinput_device *udev;
- int size,
- retval;
+ int size;
+ int retval;
retval = count;
udev = file->private_data;
dev = udev->dev;
- user_dev = kmalloc(sizeof(*user_dev), GFP_KERNEL);
+ user_dev = kmalloc(sizeof(struct uinput_user_dev), GFP_KERNEL);
if (!user_dev) {
retval = -ENOMEM;
goto exit;
@@ -272,7 +263,7 @@ static int uinput_alloc_device(struct fi
goto exit;
}
- if (NULL != dev->name)
+ if (dev->name)
kfree(dev->name);
size = strnlen(user_dev->name, UINPUT_MAX_NAME_SIZE) + 1;
@@ -314,14 +305,13 @@ static ssize_t uinput_write(struct file
{
struct uinput_device *udev = file->private_data;
- if (test_bit(UIST_CREATED, &(udev->state))) {
+ if (test_bit(UIST_CREATED, &udev->state)) {
struct input_event ev;
if (copy_from_user(&ev, buffer, sizeof(struct input_event)))
return -EFAULT;
input_event(udev->dev, ev.type, ev.code, ev.value);
- }
- else
+ } else
count = uinput_alloc_device(file, buffer, count);
return count;
@@ -332,26 +322,24 @@ static ssize_t uinput_read(struct file *
struct uinput_device *udev = file->private_data;
int retval = 0;
- if (!test_bit(UIST_CREATED, &(udev->state)))
+ if (!test_bit(UIST_CREATED, &udev->state))
return -ENODEV;
- if ((udev->head == udev->tail) && (file->f_flags & O_NONBLOCK))
+ if (udev->head == udev->tail && (file->f_flags & O_NONBLOCK))
return -EAGAIN;
retval = wait_event_interruptible(udev->waitq,
- (udev->head != udev->tail) ||
- !test_bit(UIST_CREATED, &(udev->state)));
-
+ udev->head != udev->tail || !test_bit(UIST_CREATED, &udev->state));
if (retval)
return retval;
- if (!test_bit(UIST_CREATED, &(udev->state)))
+ if (!test_bit(UIST_CREATED, &udev->state))
return -ENODEV;
while ((udev->head != udev->tail) &&
(retval + sizeof(struct input_event) <= count)) {
- if (copy_to_user(buffer + retval, &(udev->buff[udev->tail]),
- sizeof(struct input_event))) return -EFAULT;
+ if (copy_to_user(buffer + retval, &udev->buff[udev->tail], sizeof(struct input_event)))
+ return -EFAULT;
udev->tail = (udev->tail + 1) % UINPUT_BUFFER_SIZE;
retval += sizeof(struct input_event);
}
@@ -373,12 +361,12 @@ static unsigned int uinput_poll(struct f
static int uinput_burn_device(struct uinput_device *udev)
{
- if (test_bit(UIST_CREATED, &(udev->state)))
+ if (test_bit(UIST_CREATED, &udev->state))
uinput_destroy_device(udev);
- if (NULL != udev->dev->name)
+ if (udev->dev->name)
kfree(udev->dev->name);
- if (NULL != udev->dev->phys)
+ if (udev->dev->phys)
kfree(udev->dev->phys);
kfree(udev->dev);
@@ -389,7 +377,8 @@ static int uinput_burn_device(struct uin
static int uinput_close(struct inode *inode, struct file *file)
{
- return uinput_burn_device(file->private_data);
+ uinput_burn_device(file->private_data);
+ return 0;
}
static int uinput_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
@@ -415,7 +404,7 @@ static int uinput_ioctl(struct inode *in
case UI_SET_SNDBIT:
case UI_SET_FFBIT:
case UI_SET_PHYS:
- if (test_bit(UIST_CREATED, &(udev->state)))
+ if (test_bit(UIST_CREATED, &udev->state))
return -EINVAL;
}
@@ -511,7 +500,7 @@ static int uinput_ioctl(struct inode *in
udev->dev->phys = NULL;
break;
}
- udev->dev->phys[length-1] = '\0';
+ udev->dev->phys[length - 1] = '\0';
break;
case UI_BEGIN_FF_UPLOAD:
@@ -520,7 +509,7 @@ static int uinput_ioctl(struct inode *in
break;
}
req = uinput_request_find(udev, ff_up.request_id);
- if (!(req && req->code==UI_FF_UPLOAD && req->u.effect)) {
+ if (!(req && req->code == UI_FF_UPLOAD && req->u.effect)) {
retval = -EINVAL;
break;
}
@@ -538,7 +527,7 @@ static int uinput_ioctl(struct inode *in
break;
}
req = uinput_request_find(udev, ff_erase.request_id);
- if (!(req && req->code==UI_FF_ERASE)) {
+ if (!(req && req->code == UI_FF_ERASE)) {
retval = -EINVAL;
break;
}
@@ -556,7 +545,7 @@ static int uinput_ioctl(struct inode *in
break;
}
req = uinput_request_find(udev, ff_up.request_id);
- if (!(req && req->code==UI_FF_UPLOAD && req->u.effect)) {
+ if (!(req && req->code == UI_FF_UPLOAD && req->u.effect)) {
retval = -EINVAL;
break;
}
@@ -572,7 +561,7 @@ static int uinput_ioctl(struct inode *in
break;
}
req = uinput_request_find(udev, ff_erase.request_id);
- if (!(req && req->code==UI_FF_ERASE)) {
+ if (!(req && req->code == UI_FF_ERASE)) {
retval = -EINVAL;
break;
}
next prev parent reply other threads:[~2005-07-25 6:46 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-07-25 5:34 [patch 00/24] Input patches for 2.6.13 Dmitry Torokhov
2005-07-25 5:34 ` Dmitry Torokhov [this message]
2005-07-25 5:34 ` [patch 02/24] uinput: use completions Dmitry Torokhov
2005-07-25 5:34 ` [patch 03/24] serio: add modalias Dmitry Torokhov
2005-07-25 5:34 ` [patch 04/24] Acecad: small cleanup Dmitry Torokhov
2005-07-25 5:34 ` [patch 05/24] Add usb_to_input_id Dmitry Torokhov
2005-07-25 5:34 ` [patch 06/24] sonypi: make sure input_work is not running when unloading Dmitry Torokhov
2005-07-25 5:34 ` [patch 07/24] input: rearrange procfs code Dmitry Torokhov
2005-07-25 5:34 ` [patch 08/24] input: make name, phys and uniq const char Dmitry Torokhov
2005-07-25 5:34 ` [patch 09/24] input.c section fix Dmitry Torokhov
2005-07-25 5:34 ` [patch 10/24] serio_raw: link misc device and serio port Dmitry Torokhov
2005-07-25 5:35 ` [patch 11/24] serio_raw - fix Kconfig help Dmitry Torokhov
2005-07-25 5:35 ` [patch 12/24] i8042 - add Alienware Sentia to NOMUX blacklist Dmitry Torokhov
2005-07-25 5:35 ` [patch 13/24] i8042 - add Fujitsu T3010 " Dmitry Torokhov
2005-07-25 5:35 ` [patch 14/24] synaptics - limit rate on Toshiba Dynabooks Dmitry Torokhov
2005-07-25 5:35 ` [patch 15/24] ALPS: Fix resume for DualPoints Dmitry Torokhov
2005-07-25 5:35 ` [patch 16/24] ALPS: fix enabling tapping mode Dmitry Torokhov
2005-07-25 5:35 ` [patch 17/24] HID: Add a quirk for Aashima gamepad Dmitry Torokhov
2005-07-25 5:35 ` [patch 18/24] joydev - remove MSECS macro Dmitry Torokhov
2005-07-25 5:35 ` [patch 19/24] elo - fix help in Kconfig Dmitry Torokhov
2005-07-25 5:35 ` [patch 20/24] HID - only report events coming from interrupts to hiddev Dmitry Torokhov
2005-07-25 5:35 ` [patch 21/24] psmouse: wheel mice always have middle button Dmitry Torokhov
2005-07-25 5:35 ` [patch 22/24] i8042 - dont use negation in i8042_command() Dmitry Torokhov
2005-07-25 5:35 ` [patch 23/24] Input - check keycodesize when adjusting keymaps Dmitry Torokhov
2005-07-25 5:35 ` [patch 24/24] Synaptics - fix setting packet size on passthrough port 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=20050725054530.674379000.dtor_core@ameritech.net \
--to=dtor_core@ameritech.net \
--cc=linux-kernel@vger.kernel.org \
--cc=vojtech@suse.cz \
/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