Skip to content

Commit 7e044e0

Browse files
committed
Input: serio - do not use deprecated dev.power.power_state
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
1 parent 6f660f1 commit 7e044e0

5 files changed

Lines changed: 39 additions & 33 deletions

File tree

‎drivers/input/gameport/gameport.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,7 @@ int __gameport_register_driver(struct gameport_driver *drv, struct module *owner
723723
* Temporarily disable automatic binding because probing
724724
* takes long time and we are better off doing it in kgameportd
725725
*/
726-
drv->ignore = 1;
726+
drv->ignore = true;
727727

728728
error = driver_register(&drv->driver);
729729
if (error) {
@@ -736,7 +736,7 @@ int __gameport_register_driver(struct gameport_driver *drv, struct module *owner
736736
/*
737737
* Reset ignore flag and let kgameportd bind the driver to free ports
738738
*/
739-
drv->ignore = 0;
739+
drv->ignore = false;
740740
error = gameport_queue_event(drv, NULL, GAMEPORT_ATTACH_DRIVER);
741741
if (error) {
742742
driver_unregister(&drv->driver);
@@ -753,7 +753,7 @@ void gameport_unregister_driver(struct gameport_driver *drv)
753753

754754
mutex_lock(&gameport_mutex);
755755

756-
drv->ignore = 1; /* so gameport_find_driver ignores it */
756+
drv->ignore = true; /* so gameport_find_driver ignores it */
757757
gameport_remove_pending_events(drv);
758758

759759
start_over:

‎drivers/input/serio/i8042.c‎

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
* the Free Software Foundation.
1111
*/
1212

13+
#include <linux/types.h>
1314
#include <linux/delay.h>
1415
#include <linux/module.h>
1516
#include <linux/interrupt.h>
@@ -921,6 +922,9 @@ static void i8042_dritek_enable(void)
921922
#endif
922923

923924
#ifdef CONFIG_PM
925+
926+
static bool i8042_suspended;
927+
924928
/*
925929
* Here we try to restore the original BIOS settings. We only want to
926930
* do that once, when we really suspend, not when we taking memory
@@ -930,11 +934,9 @@ static void i8042_dritek_enable(void)
930934

931935
static int i8042_suspend(struct platform_device *dev, pm_message_t state)
932936
{
933-
if (dev->dev.power.power_state.event != state.event) {
934-
if (state.event == PM_EVENT_SUSPEND)
935-
i8042_controller_reset();
936-
937-
dev->dev.power.power_state = state;
937+
if (!i8042_suspended && state.event == PM_EVENT_SUSPEND) {
938+
i8042_controller_reset();
939+
i8042_suspended = true;
938940
}
939941

940942
return 0;
@@ -952,7 +954,7 @@ static int i8042_resume(struct platform_device *dev)
952954
/*
953955
* Do not bother with restoring state if we haven't suspened yet
954956
*/
955-
if (dev->dev.power.power_state.event == PM_EVENT_ON)
957+
if (!i8042_suspended)
956958
return 0;
957959

958960
error = i8042_controller_check();
@@ -998,10 +1000,9 @@ static int i8042_resume(struct platform_device *dev)
9981000
if (i8042_ports[I8042_KBD_PORT_NO].serio)
9991001
i8042_enable_kbd_port();
10001002

1003+
i8042_suspended = false;
10011004
i8042_interrupt(0, NULL);
10021005

1003-
dev->dev.power.power_state = PMSG_ON;
1004-
10051006
return 0;
10061007
}
10071008
#endif /* CONFIG_PM */

‎drivers/input/serio/serio.c‎

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -495,9 +495,9 @@ static ssize_t serio_set_bind_mode(struct device *dev, struct device_attribute *
495495

496496
retval = count;
497497
if (!strncmp(buf, "manual", count)) {
498-
serio->manual_bind = 1;
498+
serio->manual_bind = true;
499499
} else if (!strncmp(buf, "auto", count)) {
500-
serio->manual_bind = 0;
500+
serio->manual_bind = false;
501501
} else {
502502
retval = -EINVAL;
503503
}
@@ -570,7 +570,7 @@ static void serio_add_port(struct serio *serio)
570570
"serio: device_add() failed for %s (%s), error: %d\n",
571571
serio->phys, serio->name, error);
572572
else {
573-
serio->registered = 1;
573+
serio->registered = true;
574574
error = sysfs_create_group(&serio->dev.kobj, &serio_id_attr_group);
575575
if (error)
576576
printk(KERN_ERR
@@ -606,7 +606,7 @@ static void serio_destroy_port(struct serio *serio)
606606
if (serio->registered) {
607607
sysfs_remove_group(&serio->dev.kobj, &serio_id_attr_group);
608608
device_del(&serio->dev);
609-
serio->registered = 0;
609+
serio->registered = false;
610610
}
611611

612612
list_del_init(&serio->node);
@@ -750,9 +750,9 @@ static ssize_t serio_driver_set_bind_mode(struct device_driver *drv, const char
750750

751751
retval = count;
752752
if (!strncmp(buf, "manual", count)) {
753-
serio_drv->manual_bind = 1;
753+
serio_drv->manual_bind = true;
754754
} else if (!strncmp(buf, "auto", count)) {
755-
serio_drv->manual_bind = 0;
755+
serio_drv->manual_bind = false;
756756
} else {
757757
retval = -EINVAL;
758758
}
@@ -812,7 +812,7 @@ static void serio_attach_driver(struct serio_driver *drv)
812812

813813
int __serio_register_driver(struct serio_driver *drv, struct module *owner, const char *mod_name)
814814
{
815-
int manual_bind = drv->manual_bind;
815+
bool manual_bind = drv->manual_bind;
816816
int error;
817817

818818
drv->driver.bus = &serio_bus;
@@ -823,7 +823,7 @@ int __serio_register_driver(struct serio_driver *drv, struct module *owner, cons
823823
* Temporarily disable automatic binding because probing
824824
* takes long time and we are better off doing it in kseriod
825825
*/
826-
drv->manual_bind = 1;
826+
drv->manual_bind = true;
827827

828828
error = driver_register(&drv->driver);
829829
if (error) {
@@ -838,7 +838,7 @@ int __serio_register_driver(struct serio_driver *drv, struct module *owner, cons
838838
* driver to free ports
839839
*/
840840
if (!manual_bind) {
841-
drv->manual_bind = 0;
841+
drv->manual_bind = false;
842842
error = serio_queue_event(drv, NULL, SERIO_ATTACH_DRIVER);
843843
if (error) {
844844
driver_unregister(&drv->driver);
@@ -856,7 +856,7 @@ void serio_unregister_driver(struct serio_driver *drv)
856856

857857
mutex_lock(&serio_mutex);
858858

859-
drv->manual_bind = 1; /* so serio_find_driver ignores it */
859+
drv->manual_bind = true; /* so serio_find_driver ignores it */
860860
serio_remove_pending_events(drv);
861861

862862
start_over:
@@ -933,26 +933,27 @@ static int serio_uevent(struct device *dev, struct kobj_uevent_env *env)
933933
#ifdef CONFIG_PM
934934
static int serio_suspend(struct device *dev, pm_message_t state)
935935
{
936-
if (dev->power.power_state.event != state.event) {
937-
if (state.event == PM_EVENT_SUSPEND)
938-
serio_cleanup(to_serio_port(dev));
936+
struct serio *serio = to_serio_port(dev);
939937

940-
dev->power.power_state = state;
938+
if (!serio->suspended && state.event == PM_EVENT_SUSPEND) {
939+
serio_cleanup(serio);
940+
serio->suspended = true;
941941
}
942942

943943
return 0;
944944
}
945945

946946
static int serio_resume(struct device *dev)
947947
{
948+
struct serio *serio = to_serio_port(dev);
949+
948950
/*
949951
* Driver reconnect can take a while, so better let kseriod
950952
* deal with it.
951953
*/
952-
if (dev->power.power_state.event != PM_EVENT_ON) {
953-
dev->power.power_state = PMSG_ON;
954-
serio_queue_event(to_serio_port(dev), NULL,
955-
SERIO_RECONNECT_PORT);
954+
if (serio->suspended) {
955+
serio->suspended = false;
956+
serio_queue_event(serio, NULL, SERIO_RECONNECT_PORT);
956957
}
957958

958959
return 0;

‎include/linux/gameport.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
#ifdef __KERNEL__
1313
#include <asm/io.h>
14+
#include <linux/types.h>
1415
#include <linux/list.h>
1516
#include <linux/mutex.h>
1617
#include <linux/device.h>
@@ -62,7 +63,7 @@ struct gameport_driver {
6263

6364
struct device_driver driver;
6465

65-
unsigned int ignore;
66+
bool ignore;
6667
};
6768
#define to_gameport_driver(d) container_of(d, struct gameport_driver, driver)
6869

‎include/linux/serio.h‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
#ifdef __KERNEL__
1717

18+
#include <linux/types.h>
1819
#include <linux/interrupt.h>
1920
#include <linux/list.h>
2021
#include <linux/spinlock.h>
@@ -28,7 +29,10 @@ struct serio {
2829
char name[32];
2930
char phys[32];
3031

31-
unsigned int manual_bind;
32+
bool manual_bind;
33+
bool registered; /* port has been fully registered with driver core */
34+
bool suspended; /* port is suspended */
35+
3236

3337
struct serio_device_id id;
3438

@@ -47,7 +51,6 @@ struct serio {
4751
struct mutex drv_mutex; /* protects serio->drv so attributes can pin driver */
4852

4953
struct device dev;
50-
unsigned int registered; /* port has been fully registered with driver core */
5154

5255
struct list_head node;
5356
};
@@ -58,7 +61,7 @@ struct serio_driver {
5861
char *description;
5962

6063
struct serio_device_id *id_table;
61-
unsigned int manual_bind;
64+
bool manual_bind;
6265

6366
void (*write_wakeup)(struct serio *);
6467
irqreturn_t (*interrupt)(struct serio *, unsigned char, unsigned int);

0 commit comments

Comments
 (0)