[PATCH] ucb1x00-ts: handle errors from input_register_device()
ucb1x00-ts: handle errors from input_register_device() Signed-off-by: Dmitry Torokhov <dtor@mail.ru> Cc: Russell King <rmk@arm.linux.org.uk> Cc: Pavel Machek <pavel@ucw.cz> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
parent
aa83aa40ed
commit
08c67d2a5d
1 changed files with 28 additions and 17 deletions
|
@ -58,6 +58,7 @@ static int adcsync;
|
||||||
static inline void ucb1x00_ts_evt_add(struct ucb1x00_ts *ts, u16 pressure, u16 x, u16 y)
|
static inline void ucb1x00_ts_evt_add(struct ucb1x00_ts *ts, u16 pressure, u16 x, u16 y)
|
||||||
{
|
{
|
||||||
struct input_dev *idev = ts->idev;
|
struct input_dev *idev = ts->idev;
|
||||||
|
|
||||||
input_report_abs(idev, ABS_X, x);
|
input_report_abs(idev, ABS_X, x);
|
||||||
input_report_abs(idev, ABS_Y, y);
|
input_report_abs(idev, ABS_Y, y);
|
||||||
input_report_abs(idev, ABS_PRESSURE, pressure);
|
input_report_abs(idev, ABS_PRESSURE, pressure);
|
||||||
|
@ -67,6 +68,7 @@ static inline void ucb1x00_ts_evt_add(struct ucb1x00_ts *ts, u16 pressure, u16 x
|
||||||
static inline void ucb1x00_ts_event_release(struct ucb1x00_ts *ts)
|
static inline void ucb1x00_ts_event_release(struct ucb1x00_ts *ts)
|
||||||
{
|
{
|
||||||
struct input_dev *idev = ts->idev;
|
struct input_dev *idev = ts->idev;
|
||||||
|
|
||||||
input_report_abs(idev, ABS_PRESSURE, 0);
|
input_report_abs(idev, ABS_PRESSURE, 0);
|
||||||
input_sync(idev);
|
input_sync(idev);
|
||||||
}
|
}
|
||||||
|
@ -189,6 +191,7 @@ static inline unsigned int ucb1x00_ts_read_yres(struct ucb1x00_ts *ts)
|
||||||
static inline int ucb1x00_ts_pen_down(struct ucb1x00_ts *ts)
|
static inline int ucb1x00_ts_pen_down(struct ucb1x00_ts *ts)
|
||||||
{
|
{
|
||||||
unsigned int val = ucb1x00_reg_read(ts->ucb, UCB_TS_CR);
|
unsigned int val = ucb1x00_reg_read(ts->ucb, UCB_TS_CR);
|
||||||
|
|
||||||
if (machine_is_collie())
|
if (machine_is_collie())
|
||||||
return (!(val & (UCB_TS_CR_TSPX_LOW)));
|
return (!(val & (UCB_TS_CR_TSPX_LOW)));
|
||||||
else
|
else
|
||||||
|
@ -291,6 +294,7 @@ static int ucb1x00_thread(void *_ts)
|
||||||
static void ucb1x00_ts_irq(int idx, void *id)
|
static void ucb1x00_ts_irq(int idx, void *id)
|
||||||
{
|
{
|
||||||
struct ucb1x00_ts *ts = id;
|
struct ucb1x00_ts *ts = id;
|
||||||
|
|
||||||
ucb1x00_disable_irq(ts->ucb, UCB_IRQ_TSPX, UCB_FALLING);
|
ucb1x00_disable_irq(ts->ucb, UCB_IRQ_TSPX, UCB_FALLING);
|
||||||
wake_up(&ts->irq_wait);
|
wake_up(&ts->irq_wait);
|
||||||
}
|
}
|
||||||
|
@ -372,36 +376,43 @@ static int ucb1x00_ts_resume(struct ucb1x00_dev *dev)
|
||||||
static int ucb1x00_ts_add(struct ucb1x00_dev *dev)
|
static int ucb1x00_ts_add(struct ucb1x00_dev *dev)
|
||||||
{
|
{
|
||||||
struct ucb1x00_ts *ts;
|
struct ucb1x00_ts *ts;
|
||||||
|
struct input_dev *idev;
|
||||||
|
int err;
|
||||||
|
|
||||||
ts = kzalloc(sizeof(struct ucb1x00_ts), GFP_KERNEL);
|
ts = kzalloc(sizeof(struct ucb1x00_ts), GFP_KERNEL);
|
||||||
if (!ts)
|
idev = input_allocate_device();
|
||||||
return -ENOMEM;
|
if (!ts || !idev) {
|
||||||
|
err = -ENOMEM;
|
||||||
ts->idev = input_allocate_device();
|
goto fail;
|
||||||
if (!ts->idev) {
|
|
||||||
kfree(ts);
|
|
||||||
return -ENOMEM;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ts->ucb = dev->ucb;
|
ts->ucb = dev->ucb;
|
||||||
|
ts->idev = idev;
|
||||||
ts->adcsync = adcsync ? UCB_SYNC : UCB_NOSYNC;
|
ts->adcsync = adcsync ? UCB_SYNC : UCB_NOSYNC;
|
||||||
|
|
||||||
ts->idev->private = ts;
|
idev->private = ts;
|
||||||
ts->idev->name = "Touchscreen panel";
|
idev->name = "Touchscreen panel";
|
||||||
ts->idev->id.product = ts->ucb->id;
|
idev->id.product = ts->ucb->id;
|
||||||
ts->idev->open = ucb1x00_ts_open;
|
idev->open = ucb1x00_ts_open;
|
||||||
ts->idev->close = ucb1x00_ts_close;
|
idev->close = ucb1x00_ts_close;
|
||||||
|
|
||||||
__set_bit(EV_ABS, ts->idev->evbit);
|
__set_bit(EV_ABS, idev->evbit);
|
||||||
__set_bit(ABS_X, ts->idev->absbit);
|
__set_bit(ABS_X, idev->absbit);
|
||||||
__set_bit(ABS_Y, ts->idev->absbit);
|
__set_bit(ABS_Y, idev->absbit);
|
||||||
__set_bit(ABS_PRESSURE, ts->idev->absbit);
|
__set_bit(ABS_PRESSURE, idev->absbit);
|
||||||
|
|
||||||
input_register_device(ts->idev);
|
err = input_register_device(idev);
|
||||||
|
if (err)
|
||||||
|
goto fail;
|
||||||
|
|
||||||
dev->priv = ts;
|
dev->priv = ts;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
fail:
|
||||||
|
input_free_device(idev);
|
||||||
|
kfree(ts);
|
||||||
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ucb1x00_ts_remove(struct ucb1x00_dev *dev)
|
static void ucb1x00_ts_remove(struct ucb1x00_dev *dev)
|
||||||
|
|
Loading…
Reference in a new issue