lkml.org 
[lkml]   [2010]   [Jan]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH 04/36] x86/pci: add cap_resource


    On Wed, 20 Jan 2010, Yinghai Lu wrote:
    >
    > -v2: hpa said we should compare with (resource_size_t)~0

    Hmm. Some of these look dubious.

    > diff --git a/arch/x86/pci/bus_numa.c b/arch/x86/pci/bus_numa.c
    > index f939d60..b267919 100644
    > --- a/arch/x86/pci/bus_numa.c
    > +++ b/arch/x86/pci/bus_numa.c
    > @@ -60,6 +60,9 @@ void __devinit update_res(struct pci_root_info *info, size_t start,
    > if (start > end)
    > return;
    >
    > + if (start == (resource_size_t)~0)
    > + return;

    Here, 'start' isn't a resource_size_t. It's a regular size_t. And if
    resource_size_t is u64, and size_t is u32, this test can never be true.

    Maybe that is intentional, but if looks odd/wrong. Needs a comment if
    right, needs fixing if wrong.

    > +static inline resource_size_t cap_resource(u64 val)
    > +{
    > + if (val > (resource_size_t)~0)
    > + return (resource_size_t)~0;
    > + else
    > + return val;
    > +}
    > #endif

    And this just looks odd. I'd suggest just doing

    #define MAX_RESOURCE ((resource_size_t)~0)

    static inline resource_size_t cap_resource(u64 val)
    {
    if (val > MAX_RESOURCE)
    val = MAX_RESOURCE;
    return val;
    }

    instead, which looks a whole lot more natural. No?

    Linus


    \
     
     \ /
      Last update: 2010-01-21 16:53    [W:0.021 / U:0.688 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site