@@ -220,6 +220,8 @@ static const enum gpiod_flags gpio_flags[] = {
220220 */
221221#define SFP_EEPROM_BLOCK_SIZE 16
222222
223+ #define SFP_POLL_INTERVAL msecs_to_jiffies(100)
224+
223225struct sff_data {
224226 unsigned int gpios ;
225227 bool (* module_supported )(const struct sfp_eeprom_id * id );
@@ -298,6 +300,11 @@ struct sfp {
298300#endif
299301};
300302
303+ static void sfp_schedule_poll (struct sfp * sfp )
304+ {
305+ mod_delayed_work (system_percpu_wq , & sfp -> poll , SFP_POLL_INTERVAL );
306+ }
307+
301308static bool sff_module_supported (const struct sfp_eeprom_id * id )
302309{
303310 return id -> base .phys_id == SFF8024_ID_SFF_8472 &&
@@ -586,8 +593,6 @@ static const struct sfp_quirk *sfp_lookup_quirk(const struct sfp_eeprom_id *id)
586593 return NULL ;
587594}
588595
589- static unsigned long poll_jiffies ;
590-
591596static unsigned int sfp_gpio_get_state (struct sfp * sfp )
592597{
593598 unsigned int i , state , v ;
@@ -910,7 +915,7 @@ static void sfp_soft_start_poll(struct sfp *sfp)
910915
911916 if (sfp -> state_soft_mask & (SFP_F_LOS | SFP_F_TX_FAULT ) &&
912917 !sfp -> need_poll )
913- mod_delayed_work ( system_percpu_wq , & sfp -> poll , poll_jiffies );
918+ sfp_schedule_poll ( sfp );
914919 mutex_unlock (& sfp -> st_mutex );
915920}
916921
@@ -3007,7 +3012,7 @@ static void sfp_poll(struct work_struct *work)
30073012 // it's unimportant if we race while reading this.
30083013 if (sfp -> state_soft_mask & (SFP_F_LOS | SFP_F_TX_FAULT ) ||
30093014 sfp -> need_poll )
3010- mod_delayed_work ( system_percpu_wq , & sfp -> poll , poll_jiffies );
3015+ sfp_schedule_poll ( sfp );
30113016}
30123017
30133018static struct sfp * sfp_alloc (struct device * dev )
@@ -3177,7 +3182,7 @@ static int sfp_probe(struct platform_device *pdev)
31773182 }
31783183
31793184 if (sfp -> need_poll )
3180- mod_delayed_work ( system_percpu_wq , & sfp -> poll , poll_jiffies );
3185+ sfp_schedule_poll ( sfp );
31813186
31823187 /* We could have an issue in cases no Tx disable pin is available or
31833188 * wired as modules using a laser as their light source will continue to
@@ -3244,19 +3249,7 @@ static struct platform_driver sfp_driver = {
32443249 },
32453250};
32463251
3247- static int sfp_init (void )
3248- {
3249- poll_jiffies = msecs_to_jiffies (100 );
3250-
3251- return platform_driver_register (& sfp_driver );
3252- }
3253- module_init (sfp_init );
3254-
3255- static void sfp_exit (void )
3256- {
3257- platform_driver_unregister (& sfp_driver );
3258- }
3259- module_exit (sfp_exit );
3252+ module_platform_driver (sfp_driver );
32603253
32613254MODULE_ALIAS ("platform:sfp" );
32623255MODULE_AUTHOR ("Russell King" );
0 commit comments