Commit ad5ceb33 authored by Sven Schnelle's avatar Sven Schnelle Committed by Vasily Gorbik

s390/stp: unify stp_work_mutex and clock_sync_mutex

No need to have two mutexes, and while at it rename it to
stp_mutex.
Signed-off-by: default avatarSven Schnelle <svens@linux.ibm.com>
Reviewed-by: default avatarAlexander Egorenkov <egorenar@linux.ibm.com>
Signed-off-by: default avatarVasily Gorbik <gor@linux.ibm.com>
parent 4fb53dde
...@@ -296,7 +296,7 @@ void __init time_init(void) ...@@ -296,7 +296,7 @@ void __init time_init(void)
} }
static DEFINE_PER_CPU(atomic_t, clock_sync_word); static DEFINE_PER_CPU(atomic_t, clock_sync_word);
static DEFINE_MUTEX(clock_sync_mutex); static DEFINE_MUTEX(stp_mutex);
static unsigned long clock_sync_flags; static unsigned long clock_sync_flags;
#define CLOCK_SYNC_HAS_STP 0 #define CLOCK_SYNC_HAS_STP 0
...@@ -445,7 +445,6 @@ static struct stp_sstpi stp_info; ...@@ -445,7 +445,6 @@ static struct stp_sstpi stp_info;
static void *stp_page; static void *stp_page;
static void stp_work_fn(struct work_struct *work); static void stp_work_fn(struct work_struct *work);
static DEFINE_MUTEX(stp_work_mutex);
static DECLARE_WORK(stp_work, stp_work_fn); static DECLARE_WORK(stp_work, stp_work_fn);
static struct timer_list stp_timer; static struct timer_list stp_timer;
...@@ -683,7 +682,7 @@ static void stp_work_fn(struct work_struct *work) ...@@ -683,7 +682,7 @@ static void stp_work_fn(struct work_struct *work)
int rc; int rc;
/* prevent multiple execution. */ /* prevent multiple execution. */
mutex_lock(&stp_work_mutex); mutex_lock(&stp_mutex);
if (!stp_online) { if (!stp_online) {
chsc_sstpc(stp_page, STP_OP_CTRL, 0x0000, NULL); chsc_sstpc(stp_page, STP_OP_CTRL, 0x0000, NULL);
...@@ -718,7 +717,7 @@ static void stp_work_fn(struct work_struct *work) ...@@ -718,7 +717,7 @@ static void stp_work_fn(struct work_struct *work)
stp_check_leap(); stp_check_leap();
out_unlock: out_unlock:
mutex_unlock(&stp_work_mutex); mutex_unlock(&stp_mutex);
} }
/* /*
...@@ -735,11 +734,11 @@ static ssize_t ctn_id_show(struct device *dev, ...@@ -735,11 +734,11 @@ static ssize_t ctn_id_show(struct device *dev,
{ {
ssize_t ret = -ENODATA; ssize_t ret = -ENODATA;
mutex_lock(&stp_work_mutex); mutex_lock(&stp_mutex);
if (stpinfo_valid()) if (stpinfo_valid())
ret = sprintf(buf, "%016llx\n", ret = sprintf(buf, "%016llx\n",
*(unsigned long long *) stp_info.ctnid); *(unsigned long long *) stp_info.ctnid);
mutex_unlock(&stp_work_mutex); mutex_unlock(&stp_mutex);
return ret; return ret;
} }
...@@ -751,10 +750,10 @@ static ssize_t ctn_type_show(struct device *dev, ...@@ -751,10 +750,10 @@ static ssize_t ctn_type_show(struct device *dev,
{ {
ssize_t ret = -ENODATA; ssize_t ret = -ENODATA;
mutex_lock(&stp_work_mutex); mutex_lock(&stp_mutex);
if (stpinfo_valid()) if (stpinfo_valid())
ret = sprintf(buf, "%i\n", stp_info.ctn); ret = sprintf(buf, "%i\n", stp_info.ctn);
mutex_unlock(&stp_work_mutex); mutex_unlock(&stp_mutex);
return ret; return ret;
} }
...@@ -766,10 +765,10 @@ static ssize_t dst_offset_show(struct device *dev, ...@@ -766,10 +765,10 @@ static ssize_t dst_offset_show(struct device *dev,
{ {
ssize_t ret = -ENODATA; ssize_t ret = -ENODATA;
mutex_lock(&stp_work_mutex); mutex_lock(&stp_mutex);
if (stpinfo_valid() && (stp_info.vbits & 0x2000)) if (stpinfo_valid() && (stp_info.vbits & 0x2000))
ret = sprintf(buf, "%i\n", (int)(s16) stp_info.dsto); ret = sprintf(buf, "%i\n", (int)(s16) stp_info.dsto);
mutex_unlock(&stp_work_mutex); mutex_unlock(&stp_mutex);
return ret; return ret;
} }
...@@ -781,10 +780,10 @@ static ssize_t leap_seconds_show(struct device *dev, ...@@ -781,10 +780,10 @@ static ssize_t leap_seconds_show(struct device *dev,
{ {
ssize_t ret = -ENODATA; ssize_t ret = -ENODATA;
mutex_lock(&stp_work_mutex); mutex_lock(&stp_mutex);
if (stpinfo_valid() && (stp_info.vbits & 0x8000)) if (stpinfo_valid() && (stp_info.vbits & 0x8000))
ret = sprintf(buf, "%i\n", (int)(s16) stp_info.leaps); ret = sprintf(buf, "%i\n", (int)(s16) stp_info.leaps);
mutex_unlock(&stp_work_mutex); mutex_unlock(&stp_mutex);
return ret; return ret;
} }
...@@ -797,14 +796,14 @@ static ssize_t leap_seconds_scheduled_show(struct device *dev, ...@@ -797,14 +796,14 @@ static ssize_t leap_seconds_scheduled_show(struct device *dev,
struct stp_stzi stzi; struct stp_stzi stzi;
ssize_t ret; ssize_t ret;
mutex_lock(&stp_work_mutex); mutex_lock(&stp_mutex);
if (!stpinfo_valid() || !(stp_info.vbits & 0x8000) || !stp_info.lu) { if (!stpinfo_valid() || !(stp_info.vbits & 0x8000) || !stp_info.lu) {
mutex_unlock(&stp_work_mutex); mutex_unlock(&stp_mutex);
return -ENODATA; return -ENODATA;
} }
ret = chsc_stzi(stp_page, &stzi, sizeof(stzi)); ret = chsc_stzi(stp_page, &stzi, sizeof(stzi));
mutex_unlock(&stp_work_mutex); mutex_unlock(&stp_mutex);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -824,10 +823,10 @@ static ssize_t stratum_show(struct device *dev, ...@@ -824,10 +823,10 @@ static ssize_t stratum_show(struct device *dev,
{ {
ssize_t ret = -ENODATA; ssize_t ret = -ENODATA;
mutex_lock(&stp_work_mutex); mutex_lock(&stp_mutex);
if (stpinfo_valid()) if (stpinfo_valid())
ret = sprintf(buf, "%i\n", (int)(s16) stp_info.stratum); ret = sprintf(buf, "%i\n", (int)(s16) stp_info.stratum);
mutex_unlock(&stp_work_mutex); mutex_unlock(&stp_mutex);
return ret; return ret;
} }
...@@ -839,10 +838,10 @@ static ssize_t time_offset_show(struct device *dev, ...@@ -839,10 +838,10 @@ static ssize_t time_offset_show(struct device *dev,
{ {
ssize_t ret = -ENODATA; ssize_t ret = -ENODATA;
mutex_lock(&stp_work_mutex); mutex_lock(&stp_mutex);
if (stpinfo_valid() && (stp_info.vbits & 0x0800)) if (stpinfo_valid() && (stp_info.vbits & 0x0800))
ret = sprintf(buf, "%i\n", (int) stp_info.tto); ret = sprintf(buf, "%i\n", (int) stp_info.tto);
mutex_unlock(&stp_work_mutex); mutex_unlock(&stp_mutex);
return ret; return ret;
} }
...@@ -854,10 +853,10 @@ static ssize_t time_zone_offset_show(struct device *dev, ...@@ -854,10 +853,10 @@ static ssize_t time_zone_offset_show(struct device *dev,
{ {
ssize_t ret = -ENODATA; ssize_t ret = -ENODATA;
mutex_lock(&stp_work_mutex); mutex_lock(&stp_mutex);
if (stpinfo_valid() && (stp_info.vbits & 0x4000)) if (stpinfo_valid() && (stp_info.vbits & 0x4000))
ret = sprintf(buf, "%i\n", (int)(s16) stp_info.tzo); ret = sprintf(buf, "%i\n", (int)(s16) stp_info.tzo);
mutex_unlock(&stp_work_mutex); mutex_unlock(&stp_mutex);
return ret; return ret;
} }
...@@ -869,10 +868,10 @@ static ssize_t timing_mode_show(struct device *dev, ...@@ -869,10 +868,10 @@ static ssize_t timing_mode_show(struct device *dev,
{ {
ssize_t ret = -ENODATA; ssize_t ret = -ENODATA;
mutex_lock(&stp_work_mutex); mutex_lock(&stp_mutex);
if (stpinfo_valid()) if (stpinfo_valid())
ret = sprintf(buf, "%i\n", stp_info.tmd); ret = sprintf(buf, "%i\n", stp_info.tmd);
mutex_unlock(&stp_work_mutex); mutex_unlock(&stp_mutex);
return ret; return ret;
} }
...@@ -884,10 +883,10 @@ static ssize_t timing_state_show(struct device *dev, ...@@ -884,10 +883,10 @@ static ssize_t timing_state_show(struct device *dev,
{ {
ssize_t ret = -ENODATA; ssize_t ret = -ENODATA;
mutex_lock(&stp_work_mutex); mutex_lock(&stp_mutex);
if (stpinfo_valid()) if (stpinfo_valid())
ret = sprintf(buf, "%i\n", stp_info.tst); ret = sprintf(buf, "%i\n", stp_info.tst);
mutex_unlock(&stp_work_mutex); mutex_unlock(&stp_mutex);
return ret; return ret;
} }
...@@ -911,14 +910,14 @@ static ssize_t online_store(struct device *dev, ...@@ -911,14 +910,14 @@ static ssize_t online_store(struct device *dev,
return -EINVAL; return -EINVAL;
if (!test_bit(CLOCK_SYNC_HAS_STP, &clock_sync_flags)) if (!test_bit(CLOCK_SYNC_HAS_STP, &clock_sync_flags))
return -EOPNOTSUPP; return -EOPNOTSUPP;
mutex_lock(&clock_sync_mutex); mutex_lock(&stp_mutex);
stp_online = value; stp_online = value;
if (stp_online) if (stp_online)
set_bit(CLOCK_SYNC_STP, &clock_sync_flags); set_bit(CLOCK_SYNC_STP, &clock_sync_flags);
else else
clear_bit(CLOCK_SYNC_STP, &clock_sync_flags); clear_bit(CLOCK_SYNC_STP, &clock_sync_flags);
queue_work(time_sync_wq, &stp_work); queue_work(time_sync_wq, &stp_work);
mutex_unlock(&clock_sync_mutex); mutex_unlock(&stp_mutex);
return count; return count;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment