aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/mouse
diff options
context:
space:
mode:
authorAndres Salomon <dilinger@debian.org>2008-09-16 12:30:34 -0400
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2008-09-21 18:28:47 -0400
commit68d482214bb0eaac138ace329e72390d6c8d44ff (patch)
tree905c8b976b8b0829b8b49072af04c0025f2627a3 /drivers/input/mouse
parent8bf020ee9650899a45295d0c3a0744d4d1bf2801 (diff)
Input: psmouse - tweak PSMOUSE_DEFINE_ATTR to support raw set callbacks
We want to support attr->set callbacks that may need psmouse->state to not be updated, or may want to manually deal w/ enabling and disabling the device. To do that, we create __PSMOUSE_DEFINE_ATTR which enables us to set a 'protect' argument specifying whether or not the set callback should be protected with psmouse_disable and state setting. Signed-off-by: Andres Salomon <dilinger@debian.org> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/input/mouse')
-rw-r--r--drivers/input/mouse/psmouse-base.c30
-rw-r--r--drivers/input/mouse/psmouse.h7
2 files changed, 23 insertions, 14 deletions
diff --git a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c
index 3c76f6f9c835..a0671e57dd8b 100644
--- a/drivers/input/mouse/psmouse-base.c
+++ b/drivers/input/mouse/psmouse-base.c
@@ -1401,25 +1401,29 @@ ssize_t psmouse_attr_set_helper(struct device *dev, struct device_attribute *dev
1401 1401
1402 psmouse = serio_get_drvdata(serio); 1402 psmouse = serio_get_drvdata(serio);
1403 1403
1404 if (psmouse->state == PSMOUSE_IGNORE) { 1404 if (attr->protect) {
1405 retval = -ENODEV; 1405 if (psmouse->state == PSMOUSE_IGNORE) {
1406 goto out_unlock; 1406 retval = -ENODEV;
1407 } 1407 goto out_unlock;
1408 }
1408 1409
1409 if (serio->parent && serio->id.type == SERIO_PS_PSTHRU) { 1410 if (serio->parent && serio->id.type == SERIO_PS_PSTHRU) {
1410 parent = serio_get_drvdata(serio->parent); 1411 parent = serio_get_drvdata(serio->parent);
1411 psmouse_deactivate(parent); 1412 psmouse_deactivate(parent);
1412 } 1413 }
1413 1414
1414 psmouse_deactivate(psmouse); 1415 psmouse_deactivate(psmouse);
1416 }
1415 1417
1416 retval = attr->set(psmouse, attr->data, buf, count); 1418 retval = attr->set(psmouse, attr->data, buf, count);
1417 1419
1418 if (retval != -ENODEV) 1420 if (attr->protect) {
1419 psmouse_activate(psmouse); 1421 if (retval != -ENODEV)
1422 psmouse_activate(psmouse);
1420 1423
1421 if (parent) 1424 if (parent)
1422 psmouse_activate(parent); 1425 psmouse_activate(parent);
1426 }
1423 1427
1424 out_unlock: 1428 out_unlock:
1425 mutex_unlock(&psmouse_mutex); 1429 mutex_unlock(&psmouse_mutex);
diff --git a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h
index 48e0112fb264..0f13c1b499ab 100644
--- a/drivers/input/mouse/psmouse.h
+++ b/drivers/input/mouse/psmouse.h
@@ -106,6 +106,7 @@ struct psmouse_attribute {
106 ssize_t (*show)(struct psmouse *psmouse, void *data, char *buf); 106 ssize_t (*show)(struct psmouse *psmouse, void *data, char *buf);
107 ssize_t (*set)(struct psmouse *psmouse, void *data, 107 ssize_t (*set)(struct psmouse *psmouse, void *data,
108 const char *buf, size_t count); 108 const char *buf, size_t count);
109 int protect;
109}; 110};
110#define to_psmouse_attr(a) container_of((a), struct psmouse_attribute, dattr) 111#define to_psmouse_attr(a) container_of((a), struct psmouse_attribute, dattr)
111 112
@@ -114,7 +115,7 @@ ssize_t psmouse_attr_show_helper(struct device *dev, struct device_attribute *at
114ssize_t psmouse_attr_set_helper(struct device *dev, struct device_attribute *attr, 115ssize_t psmouse_attr_set_helper(struct device *dev, struct device_attribute *attr,
115 const char *buf, size_t count); 116 const char *buf, size_t count);
116 117
117#define PSMOUSE_DEFINE_ATTR(_name, _mode, _data, _show, _set) \ 118#define __PSMOUSE_DEFINE_ATTR(_name, _mode, _data, _show, _set, _protect) \
118static ssize_t _show(struct psmouse *, void *data, char *); \ 119static ssize_t _show(struct psmouse *, void *data, char *); \
119static ssize_t _set(struct psmouse *, void *data, const char *, size_t); \ 120static ssize_t _set(struct psmouse *, void *data, const char *, size_t); \
120static struct psmouse_attribute psmouse_attr_##_name = { \ 121static struct psmouse_attribute psmouse_attr_##_name = { \
@@ -129,6 +130,10 @@ static struct psmouse_attribute psmouse_attr_##_name = { \
129 .data = _data, \ 130 .data = _data, \
130 .show = _show, \ 131 .show = _show, \
131 .set = _set, \ 132 .set = _set, \
133 .protect = _protect, \
132} 134}
133 135
136#define PSMOUSE_DEFINE_ATTR(_name, _mode, _data, _show, _set) \
137 __PSMOUSE_DEFINE_ATTR(_name, _mode, _data, _show, _set, 1)
138
134#endif /* _PSMOUSE_H */ 139#endif /* _PSMOUSE_H */