Skip to content

Commit 7705d54

Browse files
committed
Input: psmouse - do not carry DMI data around
DMI tables use considerable amount of memory. Mark them as __initconst so they will be discarded once module is loaded. Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
1 parent f72a28a commit 7705d54

File tree

5 files changed

+38
-13
lines changed

5 files changed

+38
-13
lines changed

drivers/input/mouse/lifebook.c

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,13 @@ struct lifebook_data {
2525
char phys[32];
2626
};
2727

28+
static bool lifebook_present;
29+
2830
static const char *desired_serio_phys;
2931

30-
static int lifebook_set_serio_phys(const struct dmi_system_id *d)
32+
static int lifebook_limit_serio3(const struct dmi_system_id *d)
3133
{
32-
desired_serio_phys = d->driver_data;
34+
desired_serio_phys = "isa0060/serio3";
3335
return 0;
3436
}
3537

@@ -41,7 +43,8 @@ static int lifebook_set_6byte_proto(const struct dmi_system_id *d)
4143
return 0;
4244
}
4345

44-
static const struct dmi_system_id lifebook_dmi_table[] = {
46+
static const struct dmi_system_id __initconst lifebook_dmi_table[] = {
47+
#if defined(CONFIG_DMI) && defined(CONFIG_X86)
4548
{
4649
.ident = "FLORA-ie 55mi",
4750
.matches = {
@@ -83,8 +86,7 @@ static const struct dmi_system_id lifebook_dmi_table[] = {
8386
.matches = {
8487
DMI_MATCH(DMI_PRODUCT_NAME, "CF-18"),
8588
},
86-
.callback = lifebook_set_serio_phys,
87-
.driver_data = "isa0060/serio3",
89+
.callback = lifebook_limit_serio3,
8890
},
8991
{
9092
.ident = "Panasonic CF-28",
@@ -116,8 +118,14 @@ static const struct dmi_system_id lifebook_dmi_table[] = {
116118
},
117119
},
118120
{ }
121+
#endif
119122
};
120123

124+
void __init lifebook_module_init(void)
125+
{
126+
lifebook_present = dmi_check_system(lifebook_dmi_table);
127+
}
128+
121129
static psmouse_ret_t lifebook_process_byte(struct psmouse *psmouse)
122130
{
123131
struct lifebook_data *priv = psmouse->private;
@@ -243,7 +251,7 @@ static void lifebook_disconnect(struct psmouse *psmouse)
243251

244252
int lifebook_detect(struct psmouse *psmouse, bool set_properties)
245253
{
246-
if (!dmi_check_system(lifebook_dmi_table))
254+
if (!lifebook_present)
247255
return -1;
248256

249257
if (desired_serio_phys &&

drivers/input/mouse/lifebook.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,13 @@
1212
#define _LIFEBOOK_H
1313

1414
#ifdef CONFIG_MOUSE_PS2_LIFEBOOK
15+
void lifebook_module_init(void);
1516
int lifebook_detect(struct psmouse *psmouse, bool set_properties);
1617
int lifebook_init(struct psmouse *psmouse);
1718
#else
19+
inline void lifebook_module_init(void)
20+
{
21+
}
1822
inline int lifebook_detect(struct psmouse *psmouse, bool set_properties)
1923
{
2024
return -ENOSYS;

drivers/input/mouse/psmouse-base.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1696,6 +1696,9 @@ static int __init psmouse_init(void)
16961696
{
16971697
int err;
16981698

1699+
lifebook_module_init();
1700+
synaptics_module_init();
1701+
16991702
kpsmoused_wq = create_singlethread_workqueue("kpsmoused");
17001703
if (!kpsmoused_wq) {
17011704
printk(KERN_ERR "psmouse: failed to create kpsmoused workqueue\n");

drivers/input/mouse/synaptics.c

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
*/
2525

2626
#include <linux/module.h>
27+
#include <linux/dmi.h>
2728
#include <linux/input.h>
2829
#include <linux/serio.h>
2930
#include <linux/libps2.h>
@@ -629,9 +630,10 @@ static int synaptics_reconnect(struct psmouse *psmouse)
629630
return 0;
630631
}
631632

632-
#if defined(__i386__)
633-
#include <linux/dmi.h>
634-
static const struct dmi_system_id toshiba_dmi_table[] = {
633+
static bool impaired_toshiba_kbc;
634+
635+
static const struct dmi_system_id __initconst toshiba_dmi_table[] = {
636+
#if defined(CONFIG_DMI) && defined(CONFIG_X86)
635637
{
636638
.ident = "Toshiba Satellite",
637639
.matches = {
@@ -664,8 +666,13 @@ static const struct dmi_system_id toshiba_dmi_table[] = {
664666

665667
},
666668
{ }
667-
};
668669
#endif
670+
};
671+
672+
void __init synaptics_module_init(void)
673+
{
674+
impaired_toshiba_kbc = dmi_check_system(toshiba_dmi_table);
675+
}
669676

670677
int synaptics_init(struct psmouse *psmouse)
671678
{
@@ -718,18 +725,16 @@ int synaptics_init(struct psmouse *psmouse)
718725
if (SYN_CAP_PASS_THROUGH(priv->capabilities))
719726
synaptics_pt_create(psmouse);
720727

721-
#if defined(__i386__)
722728
/*
723729
* Toshiba's KBC seems to have trouble handling data from
724730
* Synaptics as full rate, switch to lower rate which is roughly
725731
* thye same as rate of standard PS/2 mouse.
726732
*/
727-
if (psmouse->rate >= 80 && dmi_check_system(toshiba_dmi_table)) {
733+
if (psmouse->rate >= 80 && impaired_toshiba_kbc) {
728734
printk(KERN_INFO "synaptics: Toshiba %s detected, limiting rate to 40pps.\n",
729735
dmi_get_system_info(DMI_PRODUCT_NAME));
730736
psmouse->rate = 40;
731737
}
732-
#endif
733738

734739
return 0;
735740

@@ -740,6 +745,10 @@ int synaptics_init(struct psmouse *psmouse)
740745

741746
#else /* CONFIG_MOUSE_PS2_SYNAPTICS */
742747

748+
void __init synaptics_module_init(void)
749+
{
750+
}
751+
743752
int synaptics_init(struct psmouse *psmouse)
744753
{
745754
return -ENOSYS;

drivers/input/mouse/synaptics.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ struct synaptics_data {
105105
int scroll;
106106
};
107107

108+
void synaptics_module_init(void);
108109
int synaptics_detect(struct psmouse *psmouse, bool set_properties);
109110
int synaptics_init(struct psmouse *psmouse);
110111
void synaptics_reset(struct psmouse *psmouse);

0 commit comments

Comments
 (0)