Skip to content

Commit

Permalink
Input: wacom - do not allocate wacom_wac separately
Browse files Browse the repository at this point in the history
There is no reason for allocating struct wacom_wac separately from
struct wacom since both have the same lifetime rules and are not
shared. Also make 'open' field a boolean.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
  • Loading branch information
Dmitry Torokhov committed Apr 14, 2010
1 parent 4492eff commit 51269fe
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions drivers/input/tablet/wacom.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ struct wacom {
struct usb_device *usbdev;
struct usb_interface *intf;
struct urb *irq;
struct wacom_wac *wacom_wac;
struct wacom_wac wacom_wac;
struct mutex lock;
unsigned int open:1;
bool open;
char phys[32];
};

Expand Down
21 changes: 9 additions & 12 deletions drivers/input/tablet/wacom_sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
* (at your option) any later version.
*/

#include "wacom.h"
#include "wacom_wac.h"
#include "wacom.h"

/* defines to get HID report descriptor */
#define HID_DEVICET_HID (USB_TYPE_CLASS | 0x01)
Expand Down Expand Up @@ -99,7 +99,7 @@ static void wacom_sys_irq(struct urb *urb)
wcombo.wacom = wacom;
wcombo.urb = urb;

if (wacom_wac_irq(wacom->wacom_wac, (void *)&wcombo))
if (wacom_wac_irq(&wacom->wacom_wac, (void *)&wcombo))
input_sync(get_input_dev(&wcombo));

exit:
Expand Down Expand Up @@ -168,7 +168,7 @@ static int wacom_open(struct input_dev *dev)
return -EIO;
}

wacom->open = 1;
wacom->open = true;
wacom->intf->needs_remote_wakeup = 1;

mutex_unlock(&wacom->lock);
Expand All @@ -181,7 +181,7 @@ static void wacom_close(struct input_dev *dev)

mutex_lock(&wacom->lock);
usb_kill_urb(wacom->irq);
wacom->open = 0;
wacom->open = false;
wacom->intf->needs_remote_wakeup = 0;
mutex_unlock(&wacom->lock);
}
Expand Down Expand Up @@ -617,13 +617,13 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i
return -EINVAL;

wacom = kzalloc(sizeof(struct wacom), GFP_KERNEL);
wacom_wac = kzalloc(sizeof(struct wacom_wac), GFP_KERNEL);
input_dev = input_allocate_device();
if (!wacom || !input_dev || !wacom_wac) {
if (!wacom || !input_dev) {
error = -ENOMEM;
goto fail1;
}

wacom_wac = &wacom->wacom_wac;
wacom_wac->features = *((struct wacom_features *)id->driver_info);
features = &wacom_wac->features;
if (features->pktlen > WACOM_PKGLEN_MAX) {
Expand Down Expand Up @@ -682,7 +682,6 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i
}

input_dev->name = wacom_wac->name;
wacom->wacom_wac = wacom_wac;

input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOUCH);
Expand Down Expand Up @@ -716,7 +715,6 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i
fail2: usb_buffer_free(dev, WACOM_PKGLEN_MAX, wacom_wac->data, wacom->data_dma);
fail1: input_free_device(input_dev);
kfree(wacom);
kfree(wacom_wac);
return error;
}

Expand All @@ -730,9 +728,8 @@ static void wacom_disconnect(struct usb_interface *intf)
input_unregister_device(wacom->dev);
usb_free_urb(wacom->irq);
usb_buffer_free(interface_to_usbdev(intf), WACOM_PKGLEN_MAX,
wacom->wacom_wac->data, wacom->data_dma);
wacom_remove_shared_data(wacom->wacom_wac);
kfree(wacom->wacom_wac);
wacom->wacom_wac.data, wacom->data_dma);
wacom_remove_shared_data(&wacom->wacom_wac);
kfree(wacom);
}

Expand All @@ -750,7 +747,7 @@ static int wacom_suspend(struct usb_interface *intf, pm_message_t message)
static int wacom_resume(struct usb_interface *intf)
{
struct wacom *wacom = usb_get_intfdata(intf);
struct wacom_features *features = &wacom->wacom_wac->features;
struct wacom_features *features = &wacom->wacom_wac.features;
int rv;

mutex_lock(&wacom->lock);
Expand Down
3 changes: 2 additions & 1 deletion drivers/input/tablet/wacom_wac.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*/
#include "wacom.h"

#include "wacom_wac.h"
#include "wacom.h"

static int wacom_penpartner_irq(struct wacom_wac *wacom, void *wcombo)
{
Expand Down
2 changes: 2 additions & 0 deletions drivers/input/tablet/wacom_wac.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#ifndef WACOM_WAC_H
#define WACOM_WAC_H

#include <linux/types.h>

/* maximum packet length for USB devices */
#define WACOM_PKGLEN_MAX 32

Expand Down

0 comments on commit 51269fe

Please sign in to comment.