public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: tip-bot for Christoph Hellwig <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: hch@lst.de, hpa@zytor.com, mike.travis@hpe.com, sivanich@hpe.com,
	mingo@kernel.org, tglx@linutronix.de,
	linux-kernel@vger.kernel.org
Subject: [tip:timers/core] posix-timers: Make posix_clocks immutable
Date: Fri, 26 May 2017 05:40:27 -0700	[thread overview]
Message-ID: <tip-d346807445883732d530a62ebadb69af2f017e28@git.kernel.org> (raw)
In-Reply-To: <20170526090311.3377-3-hch@lst.de>

Commit-ID:  d346807445883732d530a62ebadb69af2f017e28
Gitweb:     http://git.kernel.org/tip/d346807445883732d530a62ebadb69af2f017e28
Author:     Christoph Hellwig <hch@lst.de>
AuthorDate: Fri, 26 May 2017 12:03:11 +0300
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Fri, 26 May 2017 14:35:06 +0200

posix-timers: Make posix_clocks immutable

There are no more modular users providing a posix clock. The register
function is now pointless so the posix clock array can be initialized
statically at compile time and the array including the various k_clock
structs can be marked 'const'.

Inspired by changes in the Grsecurity patch set, but done proper.

[ tglx: Massaged changelog and fixed the POSIX_TIMER=n case ]

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Mike Travis <mike.travis@hpe.com>
Cc: Dimitri Sivanich <sivanich@hpe.com>
Link: http://lkml.kernel.org/r/20170526090311.3377-3-hch@lst.de
---
 kernel/time/alarmtimer.c | 64 ++++++++++++++++++++++++------------------------
 1 file changed, 32 insertions(+), 32 deletions(-)

diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
index 7b5b7bf..4f4cc35 100644
--- a/kernel/time/alarmtimer.c
+++ b/kernel/time/alarmtimer.c
@@ -307,38 +307,6 @@ static int alarmtimer_resume(struct device *dev)
 }
 #endif
 
-static void alarmtimer_freezerset(ktime_t absexp, enum alarmtimer_type type)
-{
-	struct alarm_base *base;
-	unsigned long flags;
-	ktime_t delta;
-
-	switch(type) {
-	case ALARM_REALTIME:
-		base = &alarm_bases[ALARM_REALTIME];
-		type = ALARM_REALTIME_FREEZER;
-		break;
-	case ALARM_BOOTTIME:
-		base = &alarm_bases[ALARM_BOOTTIME];
-		type = ALARM_BOOTTIME_FREEZER;
-		break;
-	default:
-		WARN_ONCE(1, "Invalid alarm type: %d\n", type);
-		return;
-	}
-
-	delta = ktime_sub(absexp, base->gettime());
-
-	spin_lock_irqsave(&freezer_delta_lock, flags);
-	if (!freezer_delta || (delta < freezer_delta)) {
-		freezer_delta = delta;
-		freezer_expires = absexp;
-		freezer_alarmtype = type;
-	}
-	spin_unlock_irqrestore(&freezer_delta_lock, flags);
-}
-
-
 /**
  * alarm_init - Initialize an alarm structure
  * @alarm: ptr to alarm to be initialized
@@ -489,6 +457,38 @@ u64 alarm_forward_now(struct alarm *alarm, ktime_t interval)
 EXPORT_SYMBOL_GPL(alarm_forward_now);
 
 #ifdef CONFIG_POSIX_TIMERS
+
+static void alarmtimer_freezerset(ktime_t absexp, enum alarmtimer_type type)
+{
+	struct alarm_base *base;
+	unsigned long flags;
+	ktime_t delta;
+
+	switch(type) {
+	case ALARM_REALTIME:
+		base = &alarm_bases[ALARM_REALTIME];
+		type = ALARM_REALTIME_FREEZER;
+		break;
+	case ALARM_BOOTTIME:
+		base = &alarm_bases[ALARM_BOOTTIME];
+		type = ALARM_BOOTTIME_FREEZER;
+		break;
+	default:
+		WARN_ONCE(1, "Invalid alarm type: %d\n", type);
+		return;
+	}
+
+	delta = ktime_sub(absexp, base->gettime());
+
+	spin_lock_irqsave(&freezer_delta_lock, flags);
+	if (!freezer_delta || (delta < freezer_delta)) {
+		freezer_delta = delta;
+		freezer_expires = absexp;
+		freezer_alarmtype = type;
+	}
+	spin_unlock_irqrestore(&freezer_delta_lock, flags);
+}
+
 /**
  * clock2alarm - helper that converts from clockid to alarmtypes
  * @clockid: clockid.

  parent reply	other threads:[~2017-05-26 12:41 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-26  9:03 constify struct k_clock Christoph Hellwig
2017-05-26  9:03 ` [PATCH 1/2] remove the SGI SN2 mmtimer driver Christoph Hellwig
2017-05-26 10:58   ` [tip:timers/core] mmtimer: Remove " tip-bot for Christoph Hellwig
2017-05-26 14:43     ` Joe Perches
2017-05-26  9:03 ` [PATCH 2/2] kernel: mark all struct k_clock instances const Christoph Hellwig
2017-05-26  9:35   ` Joe Perches
2017-05-26 10:32     ` Thomas Gleixner
2017-05-26 16:09       ` Joe Perches
2017-05-26 10:58   ` [tip:timers/core] posix-timers: Make posix_clocks immutable tip-bot for Christoph Hellwig
2017-05-26 12:39   ` tip-bot for Christoph Hellwig
2017-05-26 12:40   ` tip-bot for Christoph Hellwig [this message]
2017-05-27  7:52   ` tip-bot for Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=tip-d346807445883732d530a62ebadb69af2f017e28@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=hch@lst.de \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mike.travis@hpe.com \
    --cc=mingo@kernel.org \
    --cc=sivanich@hpe.com \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox