Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9c6c273a authored by Kees Cook's avatar Kees Cook Committed by Thomas Gleixner
Browse files

timer: Remove init_timer_on_stack() in favor of timer_setup_on_stack()



Remove uses of init_timer_on_stack() with open-coded function and data
assignments that could be expressed using timer_setup_on_stack(). Several
were removed from the stack entirely since there was a one-to-one mapping
of parent structure to timer, those are switched to using timer_setup()
instead. All related callbacks were adjusted to use from_timer().

Signed-off-by: default avatarKees Cook <keescook@chromium.org>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Cc: linux-mips@linux-mips.org
Cc: Petr Mladek <pmladek@suse.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Sebastian Reichel <sre@kernel.org>
Cc: Kalle Valo <kvalo@qca.qualcomm.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: Wim Van Sebroeck <wim@iguana.be>
Cc: linux1394-devel@lists.sourceforge.net
Cc: Chris Metcalf <cmetcalf@mellanox.com>
Cc: linux-s390@vger.kernel.org
Cc: linux-wireless@vger.kernel.org
Cc: "James E.J. Bottomley" <jejb@linux.vnet.ibm.com>
Cc: linux-scsi@vger.kernel.org
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Ursula Braun <ubraun@linux.vnet.ibm.com>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Harish Patil <harish.patil@cavium.com>
Cc: Stephen Boyd <sboyd@codeaurora.org>
Cc: Michael Reed <mdr@sgi.com>
Cc: Manish Chopra <manish.chopra@cavium.com>
Cc: Len Brown <len.brown@intel.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: linux-pm@vger.kernel.org
Cc: Lai Jiangshan <jiangshanlai@gmail.com>
Cc: Tejun Heo <tj@kernel.org>
Cc: Julian Wiedmann <jwi@linux.vnet.ibm.com>
Cc: John Stultz <john.stultz@linaro.org>
Cc: Mark Gross <mark.gross@intel.com>
Cc: linux-watchdog@vger.kernel.org
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Stefan Richter <stefanr@s5r6.in-berlin.de>
Cc: Guenter Roeck <linux@roeck-us.net>
Cc: netdev@vger.kernel.org
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: linuxppc-dev@lists.ozlabs.org
Cc: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
Link: https://lkml.kernel.org/r/1507159627-127660-4-git-send-email-keescook@chromium.org
parent 1d1fe902
Loading
Loading
Loading
Loading
+3 −5
Original line number Diff line number Diff line
@@ -478,9 +478,9 @@ struct dpm_watchdog {
 * There's not much we can do here to recover so panic() to
 * capture a crash-dump in pstore.
 */
static void dpm_watchdog_handler(unsigned long data)
static void dpm_watchdog_handler(struct timer_list *t)
{
	struct dpm_watchdog *wd = (void *)data;
	struct dpm_watchdog *wd = from_timer(wd, t, timer);

	dev_emerg(wd->dev, "**** DPM device timeout ****\n");
	show_stack(wd->tsk, NULL);
@@ -500,11 +500,9 @@ static void dpm_watchdog_set(struct dpm_watchdog *wd, struct device *dev)
	wd->dev = dev;
	wd->tsk = current;

	init_timer_on_stack(timer);
	timer_setup_on_stack(timer, dpm_watchdog_handler, 0);
	/* use same timeout value for both suspend and resume */
	timer->expires = jiffies + HZ * CONFIG_DPM_WATCHDOG_TIMEOUT;
	timer->function = dpm_watchdog_handler;
	timer->data = (unsigned long)wd;
	add_timer(timer);
}

+5 −5
Original line number Diff line number Diff line
@@ -137,9 +137,9 @@ int fw_cancel_transaction(struct fw_card *card,
}
EXPORT_SYMBOL(fw_cancel_transaction);

static void split_transaction_timeout_callback(unsigned long data)
static void split_transaction_timeout_callback(struct timer_list *timer)
{
	struct fw_transaction *t = (struct fw_transaction *)data;
	struct fw_transaction *t = from_timer(t, timer, split_timeout_timer);
	struct fw_card *card = t->card;
	unsigned long flags;

@@ -373,8 +373,8 @@ void fw_send_request(struct fw_card *card, struct fw_transaction *t, int tcode,
	t->tlabel = tlabel;
	t->card = card;
	t->is_split_transaction = false;
	setup_timer(&t->split_timeout_timer,
		    split_transaction_timeout_callback, (unsigned long)t);
	timer_setup(&t->split_timeout_timer,
		    split_transaction_timeout_callback, 0);
	t->callback = callback;
	t->callback_data = callback_data;

@@ -423,7 +423,7 @@ int fw_run_transaction(struct fw_card *card, int tcode, int destination_id,
	struct transaction_callback_data d;
	struct fw_transaction t;

	init_timer_on_stack(&t.split_timeout_timer);
	timer_setup_on_stack(&t.split_timeout_timer, NULL, 0);
	init_completion(&d.done);
	d.payload = payload;
	fw_send_request(card, &t, tcode, destination_id, generation, speed,
+7 −14
Original line number Diff line number Diff line
@@ -44,10 +44,11 @@ static void parport_ieee1284_wakeup (struct parport *port)
	up (&port->physport->ieee1284.irq);
}

static struct parport *port_from_cookie[PARPORT_MAX];
static void timeout_waiting_on_port (unsigned long cookie)
static void timeout_waiting_on_port (struct timer_list *t)
{
	parport_ieee1284_wakeup (port_from_cookie[cookie % PARPORT_MAX]);
	struct parport *port = from_timer(port, t, timer);

	parport_ieee1284_wakeup (port);
}

/**
@@ -69,27 +70,19 @@ static void timeout_waiting_on_port (unsigned long cookie)
int parport_wait_event (struct parport *port, signed long timeout)
{
	int ret;
	struct timer_list timer;

	if (!port->physport->cad->timeout)
		/* Zero timeout is special, and we can't down() the
		   semaphore. */
		return 1;

	init_timer_on_stack(&timer);
	timer.expires = jiffies + timeout;
	timer.function = timeout_waiting_on_port;
	port_from_cookie[port->number % PARPORT_MAX] = port;
	timer.data = port->number;

	add_timer (&timer);
	timer_setup(&port->timer, timeout_waiting_on_port, 0);
	mod_timer(&port->timer, jiffies + timeout);
	ret = down_interruptible (&port->physport->ieee1284.irq);
	if (!del_timer_sync(&timer) && !ret)
	if (!del_timer_sync(&port->timer) && !ret)
		/* Timed out. */
		ret = 1;

	destroy_timer_on_stack(&timer);

	return ret;
}

+1 −0
Original line number Diff line number Diff line
@@ -128,6 +128,7 @@ struct tape_request {
	int options;			/* options for execution. */
	int retries;			/* retry counter for error recovery. */
	int rescnt;			/* residual count from devstat. */
	struct timer_list timer;	/* timer for std_assign_timeout(). */

	/* Callback for delivering final status. */
	void (*callback)(struct tape_request *, void *);
+6 −12
Original line number Diff line number Diff line
@@ -32,14 +32,12 @@
 * tape_std_assign
 */
static void
tape_std_assign_timeout(unsigned long data)
tape_std_assign_timeout(struct timer_list *t)
{
	struct tape_request *	request;
	struct tape_device *	device;
	struct tape_request *	request = from_timer(request, t, timer);
	struct tape_device *	device = request->device;
	int rc;

	request = (struct tape_request *) data;
	device = request->device;
	BUG_ON(!device);

	DBF_EVENT(3, "%08x: Assignment timeout. Device busy.\n",
@@ -70,16 +68,12 @@ tape_std_assign(struct tape_device *device)
	 * to another host (actually this shouldn't happen but it does).
	 * So we set up a timeout for this call.
	 */
	init_timer_on_stack(&timeout);
	timeout.function = tape_std_assign_timeout;
	timeout.data     = (unsigned long) request;
	timeout.expires  = jiffies + 2 * HZ;
	add_timer(&timeout);
	timer_setup(&request->timer, tape_std_assign_timeout, 0);
	mod_timer(&timeout, jiffies + 2 * HZ);

	rc = tape_do_io_interruptible(device, request);

	del_timer_sync(&timeout);
	destroy_timer_on_stack(&timeout);
	del_timer_sync(&request->timer);

	if (rc != 0) {
		DBF_EVENT(3, "%08x: assign failed - device might be busy\n",
Loading