[Top] [All Lists]

Re: [PATCH] OF: PCI: const usage needed by MIPS

To: John Crispin <>
Subject: Re: [PATCH] OF: PCI: const usage needed by MIPS
From: Bjorn Helgaas <>
Date: Thu, 3 May 2012 18:30:20 -0600
Cc: David Daney <>, Ralf Baechle <>, Grant Likely <>,,,
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed;; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding:x-system-of-record; bh=Y/Ftqp2+f0C33bWO5FyppNYLGW3qQdI+lguCiWNzNQ8=; b=WvIdsWIiYGPAVs28j/adO49txkSfOwjnEKxRrzL3JHXyh5K2Bpy+DO8N/EXopovbWk ZiT/JFpJa11Cezq/YviVhEzny0KDFO05CkpWbFSvfs2WFRj6X7wBWbYcp/mVuuP1PMDU Pohmk6ZP8RK+j33ltsFAxVrsuYRz1lhFGJ6ceIplZm3bU4NEN2YI2Hd2QdljVoMdUCOc jkbZp5/a+3dYGYgU7A/2xcMERnsy1EakEoeo1Zk/ndZm0Gkv1uAaLlSGqdxx1EQYOskx KceGw2A1+/5eBTg8Cut0L5aFXZfNh0A0qxfZTNTLMlA5NLvzlBCD98oDYjeVJ2htfzFa qLmw==
In-reply-to: <>
References: <> <> <>
On Tue, May 1, 2012 at 7:28 AM, John Crispin <> wrote:
> On 30/04/12 19:54, David Daney wrote:
>> On 04/30/2012 10:46 AM, John Crispin wrote:
>>> On MIPS we want to call of_irq_map_pci from inside
>>> arch/mips/include/asm/pci.h:extern int pcibios_map_irq(
>>>                 const struct pci_dev *dev, u8 slot, u8 pin);
>>> For this to work we need to change several functions to const usage.
>> I think there is a mismatch on this throughout the kernel.
>> Properly fixing it requires touching many more places than these.
>> Although I haven't tried it, I wouldn't be surprised if doing this
>> caused warnings to appear in non-MIPS code.
>> Ralf had a patch at one point that tried to make this consistent
>> tree-wide, but it is not yet applied.
>> David Daney
> Hi,
> Ok, lets see what Ralf has to say.
> I just tested the patch on x86 with OF enabled and drivers turned on
> that use the API. I did not see any errors appear.

I'm far from a const expert, but I think this should be safe.  Here's
my reasoning:

We're changing pci_swizzle_interrupt_pin() to take a pointer to a
constant struct pci_dev.  pci_swizzle_interrupt_pin() only reads the
struct pci_dev; it doesn't modify it.  It is legal to pass either
"struct pci_dev *" or "const struct pci_dev *" to a function expecting
"const struct pci_dev *"; the callee just won't be able to modify the
struct, even if the caller can.

Similar reasoning applies to of_irq_map_pci().

So I'm fine with this.  You sent it to Grant, so I'll assume he'll
merge it unless I hear otherwise.

Acked-by: Bjorn Helgaas <>

<Prev in Thread] Current Thread [Next in Thread>