Re: [RFC/PATCH] Per-device parameter support (13/16)

From: Rusty Russell (rusty_at_rustcorp.com.au)
Date: 10/25/04

  • Next message: Jeff Garzik: "Re: Concerns about our pci_{save,restore}_state()"
    To: Tejun Heo <tj@home-tj.org>
    Date:	Mon, 25 Oct 2004 16:08:10 +1000
    
    

    On Sat, 2004-10-23 at 13:31 +0900, Tejun Heo wrote:
    > +/* For some reason, gcc aligns structures which contain other
    > + structures to 32-byte boundary even when __alignof__() the strucure
    > + is smaller than that. As we're gonna assemble paramset array
    > + manually, we need to set alignment explicitly. Also, we put all
    > + paramset array elements into .data.1 to avoid intervening variables
    > + of different types (kparam_string, kparam_array for now). */

    You need __attribute__((aligned(sizeof(void *))): see moduleparam.h.
    The padding between structures is arch-dependent (x86-64 found out the
    hard way when we changed kernel_param previously). Not sure why you're
    using a separate section here anyway.

    > +/* Bit flag */
    > +#define __DEVICE_PARAM_FLAG(Name, Field, Flag, Dfl, Inv, Perm, Desc) \
    > + param_check_uint(__devparam_data(Name), \
    > + &(((__devparam_type *)0)->Field)); \
    > + static struct kparam_flag __devparam_data(__param_flag_##Name) \
    > + __devparam_extra_section = { 0, Flag, Inv }; \
    > + __DEVICE_PARAM_CALL_RANGED(Name, param_set_flag, param_get_flag,\
    > + &__devparam_data(__param_flag_##Name), \
    > + sizeof(struct kparam_flag), 1, 0, Dfl, 0, Perm, Desc, \
    > + offsetof(struct kparam_flag, pflags), \
    > + offsetof(__devparam_type, Field), -1, -1)
    > +
    > +#define DEVICE_PARAM_FLAG(Name, Field, Flag, Dfl, Perm, Desc) \
    > + __DEVICE_PARAM_FLAG(Name, Field, Flag, Dfl, 0, Perm, Desc)

    Haven't read closely, but why is FLAG special?

    I think your macros might be better off always having the range, which
    would reduce the number of functions.. I like including the description
    in the macros: that's an improvement.

    I always disliked the _NAMED versions (if it's a good name for users,
    it's usually a good name for the variable and vice versa), but you might
    want to consider always having it if that's the common case.

    Cheers,
    Rusty.

    -- 
    A bad analogy is like a leaky screwdriver -- Richard Braakman
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at  http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at  http://www.tux.org/lkml/
    

  • Next message: Jeff Garzik: "Re: Concerns about our pci_{save,restore}_state()"

    Relevant Pages

    • Re: [PATCH] mask ADT: new mask.h file [2/22]
      ... > or so macros are less commonly used. ... burden of using existing infrastructure. ... I don't even want to learn 28 bitops primitives. ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • Re: [PATCH] fix: macros to detect existance of unlocked_ioctl and compat_ioctl
      ... >> I disagree since the alternative is so ugly. ... > documented times. ... HAVE_FOO macros, then the presence of the macros is the least of our ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • Re: [PATCH 2.4] jffs2 aligment problems
      ... >> kernel. ... Emulating unaligned accesses with traps (even even the architecture ... On architectures where it doesn't matter, the macros just do the access, ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • Re: [PATCH linux-2.6-block:post-2.6.15 09/10] blk: add FUA support to IDE
      ... Tejun Heo wrote: ... > window where wrong barrier requests can hit the drive. ... have similar race window. ... To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/ ...
      (Linux-Kernel)
    • Re: [RFC/PATCH] Per-device parameter support (4/16)
      ... On Sat, 2004-10-23 at 13:25 +0900, Tejun Heo wrote: ... > They appear as boolean parameter to the outside, and bitwise OR the ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)