Re: [PATCH (resend)] mailbox: Add Altera mailbox driver
From: Ley Foon Tan
Date: Mon Dec 15 2014 - 21:00:54 EST
On Mon, Dec 15, 2014 at 10:22 PM, Dinh Nguyen <dinh.linux@xxxxxxxxx> wrote:
>
>
> On 12/15/14, 12:22 AM, Ley Foon Tan wrote:
>> On Fri, Dec 12, 2014 at 10:38 PM, Dinh Nguyen <dinh.linux@xxxxxxxxx> wrote:
>>
>>>> +
>>>> +#include <linux/kernel.h>
>>>> +#include <linux/module.h>
>>>> +#include <linux/device.h>
>>>> +#include <linux/platform_device.h>
>>>> +#include <linux/interrupt.h>
>>>> +#include <linux/io.h>
>>>> +#include <linux/of.h>
>>>> +#include <linux/mailbox_controller.h>
>>>
>>> Alphabetize the headers.
>> Okay.
>>
>>
>>>> +static int altera_mbox_startup_sender(struct mbox_chan *chan)
>>>> +{
>>>> + int ret;
>>>> + struct altera_mbox *mbox = to_altera_mbox(chan);
>>>> +
>>>> + if (mbox->intr_mode) {
>>>> + ret = request_irq(mbox->irq, altera_mbox_tx_interrupt, 0,
>>>
>>> Use devm_request_irq, since you didn't have and don't need use free_irq
>>> in the shutdown function.
>> We want to free_irq when it shutdown. That means nobody requests for
>> that mailbox (or channel) and request_irq() again if someone requests
>> for a mailbox.
>>
>
> But you didn't have any free_irq in the shutdown function. Use
> devm_request_irq here, so you don't have to add them.
Hi Dinh
free_irq() is in altera_mbox_shutdown(). This function will be called
when user free/release the mailbox (channel).
But, devm_free_irq() only will be called when unload the module.
+static void altera_mbox_shutdown(struct mbox_chan *chan)
+{
+ struct altera_mbox *mbox = to_altera_mbox(chan);
+
+ if (WARN_ON(!mbox))
+ return;
+
+ if (mbox->intr_mode) {
+ /* Unmask all interrupt masks */
+ __raw_writel(~0, mbox->mbox_base + MAILBOX_INTMASK_REG);
+ free_irq(mbox->irq, chan);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/