From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964947AbdKBXTi (ORCPT ); Thu, 2 Nov 2017 19:19:38 -0400 Received: from mail-pg0-f65.google.com ([74.125.83.65]:50405 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964913AbdKBXTh (ORCPT ); Thu, 2 Nov 2017 19:19:37 -0400 X-Google-Smtp-Source: ABhQp+S6/bGEpc0Kffpffaby3QQvgkc4SSHtLH5cfPgpko3gmhuV4m4mfYJ6EJsRFMMod2Wzc2zYKQ== Date: Thu, 2 Nov 2017 16:19:34 -0700 From: Kees Cook To: Jassi Brar Cc: Ley Foon Tan , Jassi Brar , nios2-dev@lists.rocketboards.org, linux-kernel@vger.kernel.org Subject: [PATCH] mailbox: Convert timers to use timer_setup() Message-ID: <20171102231934.GA100586@beast> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In preparation for unconditionally passing the struct timer_list pointer to all timer callbacks, switch to using the new timer_setup() and from_timer() to pass the timer pointer explicitly. Cc: Ley Foon Tan Cc: Jassi Brar Cc: nios2-dev@lists.rocketboards.org Signed-off-by: Kees Cook --- FYI, this requires -rc3's timer_setup() API. If that's not available, I can carry this in the timers tree with you Ack/Review. Thanks! --- drivers/mailbox/mailbox-altera.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/mailbox/mailbox-altera.c b/drivers/mailbox/mailbox-altera.c index bb682c926b0a..bcb29df9549e 100644 --- a/drivers/mailbox/mailbox-altera.c +++ b/drivers/mailbox/mailbox-altera.c @@ -57,6 +57,7 @@ struct altera_mbox { /* If the controller supports only RX polling mode */ struct timer_list rxpoll_timer; + struct mbox_chan *chan; }; static struct altera_mbox *mbox_chan_to_altera_mbox(struct mbox_chan *chan) @@ -138,12 +139,11 @@ static void altera_mbox_rx_data(struct mbox_chan *chan) } } -static void altera_mbox_poll_rx(unsigned long data) +static void altera_mbox_poll_rx(struct timer_list *t) { - struct mbox_chan *chan = (struct mbox_chan *)data; - struct altera_mbox *mbox = mbox_chan_to_altera_mbox(chan); + struct altera_mbox *mbox = from_timer(mbox, t, rxpoll_timer); - altera_mbox_rx_data(chan); + altera_mbox_rx_data(mbox->chan); mod_timer(&mbox->rxpoll_timer, jiffies + msecs_to_jiffies(MBOX_POLLING_MS)); @@ -206,8 +206,8 @@ static int altera_mbox_startup_receiver(struct mbox_chan *chan) polling: /* Setup polling timer */ - setup_timer(&mbox->rxpoll_timer, altera_mbox_poll_rx, - (unsigned long)chan); + mbox->chan = chan; + timer_setup(&mbox->rxpoll_timer, altera_mbox_poll_rx, 0); mod_timer(&mbox->rxpoll_timer, jiffies + msecs_to_jiffies(MBOX_POLLING_MS)); -- 2.7.4 -- Kees Cook Pixel Security