aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/mouse/psmouse.h
diff options
context:
space:
mode:
authorDmitry Torokhov <dtor_core@ameritech.net>2005-09-04 02:40:20 -0400
committerDmitry Torokhov <dtor_core@ameritech.net>2005-09-04 02:40:20 -0400
commitcfe9e88866fe892f4f71bf132c64ec8bd5256e5e (patch)
treec1da19c8a2b1f9f1a32597554660747fe0aa5132 /drivers/input/mouse/psmouse.h
parent15c42e5a1f0bccb69508059b8ae0720840068b8e (diff)
Input: rework psmouse attributes to reduce module size
Rearrange attribute code to use generic show and set handlers instead of replicating them for every attribute; switch to using attribute_group instead of creating all attributes manually. All this saves about 4K. Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/input/mouse/psmouse.h')
-rw-r--r--drivers/input/mouse/psmouse.h51
1 files changed, 32 insertions, 19 deletions
diff --git a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h
index e312a6b41681..45d2bd774f00 100644
--- a/drivers/input/mouse/psmouse.h
+++ b/drivers/input/mouse/psmouse.h
@@ -86,24 +86,37 @@ int psmouse_sliced_command(struct psmouse *psmouse, unsigned char command);
86int psmouse_reset(struct psmouse *psmouse); 86int psmouse_reset(struct psmouse *psmouse);
87void psmouse_set_resolution(struct psmouse *psmouse, unsigned int resolution); 87void psmouse_set_resolution(struct psmouse *psmouse, unsigned int resolution);
88 88
89ssize_t psmouse_attr_show_helper(struct device *dev, char *buf, 89
90 ssize_t (*handler)(struct psmouse *, char *)); 90struct psmouse_attribute {
91ssize_t psmouse_attr_set_helper(struct device *dev, const char *buf, size_t count, 91 struct device_attribute dattr;
92 ssize_t (*handler)(struct psmouse *, const char *, size_t)); 92 void *data;
93 93 ssize_t (*show)(struct psmouse *psmouse, void *data, char *buf);
94#define PSMOUSE_DEFINE_ATTR(_name) \ 94 ssize_t (*set)(struct psmouse *psmouse, void *data,
95static ssize_t psmouse_attr_show_##_name(struct psmouse *, char *); \ 95 const char *buf, size_t count);
96static ssize_t psmouse_attr_set_##_name(struct psmouse *, const char *, size_t);\ 96};
97static ssize_t psmouse_do_show_##_name(struct device *d, struct device_attribute *attr, char *b) \ 97#define to_psmouse_attr(a) container_of((a), struct psmouse_attribute, dattr)
98{ \ 98
99 return psmouse_attr_show_helper(d, b, psmouse_attr_show_##_name); \ 99ssize_t psmouse_attr_show_helper(struct device *dev, struct device_attribute *attr,
100} \ 100 char *buf);
101static ssize_t psmouse_do_set_##_name(struct device *d, struct device_attribute *attr, const char *b, size_t s)\ 101ssize_t psmouse_attr_set_helper(struct device *dev, struct device_attribute *attr,
102{ \ 102 const char *buf, size_t count);
103 return psmouse_attr_set_helper(d, b, s, psmouse_attr_set_##_name); \ 103
104} \ 104#define PSMOUSE_DEFINE_ATTR(_name, _mode, _data, _show, _set) \
105static struct device_attribute psmouse_attr_##_name = \ 105static ssize_t _show(struct psmouse *, void *data, char *); \
106 __ATTR(_name, S_IWUSR | S_IRUGO, \ 106static ssize_t _set(struct psmouse *, void *data, const char *, size_t); \
107 psmouse_do_show_##_name, psmouse_do_set_##_name); 107static struct psmouse_attribute psmouse_attr_##_name = { \
108 .dattr = { \
109 .attr = { \
110 .name = __stringify(_name), \
111 .mode = _mode, \
112 .owner = THIS_MODULE, \
113 }, \
114 .show = psmouse_attr_show_helper, \
115 .store = psmouse_attr_set_helper, \
116 }, \
117 .data = _data, \
118 .show = _show, \
119 .set = _set, \
120}
108 121
109#endif /* _PSMOUSE_H */ 122#endif /* _PSMOUSE_H */