Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: sfp: improve poll interval handling

The poll interval is a fixed value, so we don't need a static variable
for it. The change also allows to use standard macro
module_platform_driver, avoiding some boilerplate code.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Link: https://patch.msgid.link/b8079f96-6865-431c-a908-a0b9e9bd5379@gmail.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

authored by

Heiner Kallweit and committed by
Paolo Abeni
9ebef94c df7dcf5e

+11 -18
+11 -18
drivers/net/phy/sfp.c
··· 220 220 */ 221 221 #define SFP_EEPROM_BLOCK_SIZE 16 222 222 223 + #define SFP_POLL_INTERVAL msecs_to_jiffies(100) 224 + 223 225 struct sff_data { 224 226 unsigned int gpios; 225 227 bool (*module_supported)(const struct sfp_eeprom_id *id); ··· 299 297 struct dentry *debugfs_dir; 300 298 #endif 301 299 }; 300 + 301 + static void sfp_schedule_poll(struct sfp *sfp) 302 + { 303 + mod_delayed_work(system_percpu_wq, &sfp->poll, SFP_POLL_INTERVAL); 304 + } 302 305 303 306 static bool sff_module_supported(const struct sfp_eeprom_id *id) 304 307 { ··· 592 585 593 586 return NULL; 594 587 } 595 - 596 - static unsigned long poll_jiffies; 597 588 598 589 static unsigned int sfp_gpio_get_state(struct sfp *sfp) 599 590 { ··· 915 910 916 911 if (sfp->state_soft_mask & (SFP_F_LOS | SFP_F_TX_FAULT) && 917 912 !sfp->need_poll) 918 - mod_delayed_work(system_percpu_wq, &sfp->poll, poll_jiffies); 913 + sfp_schedule_poll(sfp); 919 914 mutex_unlock(&sfp->st_mutex); 920 915 } 921 916 ··· 3012 3007 // it's unimportant if we race while reading this. 3013 3008 if (sfp->state_soft_mask & (SFP_F_LOS | SFP_F_TX_FAULT) || 3014 3009 sfp->need_poll) 3015 - mod_delayed_work(system_percpu_wq, &sfp->poll, poll_jiffies); 3010 + sfp_schedule_poll(sfp); 3016 3011 } 3017 3012 3018 3013 static struct sfp *sfp_alloc(struct device *dev) ··· 3182 3177 } 3183 3178 3184 3179 if (sfp->need_poll) 3185 - mod_delayed_work(system_percpu_wq, &sfp->poll, poll_jiffies); 3180 + sfp_schedule_poll(sfp); 3186 3181 3187 3182 /* We could have an issue in cases no Tx disable pin is available or 3188 3183 * wired as modules using a laser as their light source will continue to ··· 3249 3244 }, 3250 3245 }; 3251 3246 3252 - static int sfp_init(void) 3253 - { 3254 - poll_jiffies = msecs_to_jiffies(100); 3255 - 3256 - return platform_driver_register(&sfp_driver); 3257 - } 3258 - module_init(sfp_init); 3259 - 3260 - static void sfp_exit(void) 3261 - { 3262 - platform_driver_unregister(&sfp_driver); 3263 - } 3264 - module_exit(sfp_exit); 3247 + module_platform_driver(sfp_driver); 3265 3248 3266 3249 MODULE_ALIAS("platform:sfp"); 3267 3250 MODULE_AUTHOR("Russell King");