Re: [PATCH 1/2] Staging: comedi: introduce outl_1564_* and inl_1564_* helper functions in hwdrv_apci1564.c

From: Dan Carpenter
Date: Sat Mar 01 2014 - 07:46:29 EST


On Sat, Mar 01, 2014 at 04:28:27AM -0600, Chase Southwood wrote:
> This patch introduces a handful of outl and inl helper functions with the
> ultimate goal of improving code readability and allowing several lines
> which violate the character limit to be shortened in a sane way.
>
> Cc: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
> Signed-off-by: Chase Southwood <chase.southwood@xxxxxxxxx>
> ---
> This patchset serves as a replacement to my previous cleanup patchset for
> hwdrv_apci1564.c
>
> Dan,
> After spending a little bit more time with this and trying out different
> ways of cleaning this up, I decided that making helper functions for all
> of the most common register sets would look the best, but I haven't made
> a helper for a few of the least common inl/outl calls because if I did,
> the sheer number of helper functions would get quite ridiculous.
> Let me know if you think my selections of what to make into helper
> functions seems appropriate.
>

Yeah. You're right... It's kind of a lot of helper functions.

I wonder if we could just do something like:

static void outl_amcc(struct addi_private *devpriv, unsigned int cmd,
unsigned int reg)
{
outl(cmd, devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP + reg);
}

And then change APCI1564_DIGITAL_IP_INTERRUPT_MODE1 to be:

#define APCI1564_DIGITAL_IP_INTERRUPT_MODE1 (0x4 + 0x4)

The only problem with that would be i_APCI1564_Reset(). Is
i_APCI1564_Reset() buggy? Ian or Hartley might know. Take a look at
other comedi drivers as well to see what they do.

regards,
dan carpenter

--
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/