> > This patch adds the jd_mutex to protect the jack detection control flow. > > And only the headset type could check the button status. > > What's the protection here for - as far as I can see the mutex is only taken in > the jack detection work function which should only ever have one copy running > at once by virtue of being a single work function? In the rt5645_sys_resume function, the driver calls rt5645_jack_detect_work function directly. It is possible that the work and rt5645_sys_resume both call rt5645_jack_detect_work function. Therefore, we need the mutex to protect.