@@ -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
813813int __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
862862start_over :
@@ -933,26 +933,27 @@ static int serio_uevent(struct device *dev, struct kobj_uevent_env *env)
933933#ifdef CONFIG_PM
934934static 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
946946static 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 ;
0 commit comments