lkml.org 
[lkml]   [2012]   [Oct]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 02/10] drivers/mfd/sta2x11-mfd: add regmap support
On Mon, Oct 22, 2012 at 04:50:33PM +0200, ciminaghi@gnudd.com wrote:

> +static bool sta2x11_sctl_writeable_reg(struct device *dev, unsigned int reg)
> +{
> + return !__reg_within_range(reg, SCTL_SCPCIECSBRST, SCTL_SCRSTSTA);
> +}

This and most of your other readable/writable things look like a
framework feature waiting to be written - something data driven which
takes a table of register ranges and goes and does the
__reg_within_range() check on them. Seems like it'd be really useful
for devices like this.

> +static bool sta2x11_apb_soc_regs_writeable_reg(struct device *dev,
> + unsigned int reg)
> +{
> + if (!sta2x11_apb_soc_regs_readable_reg(dev, reg))
> + return false;
> + return (!__reg_within_range(reg, PCIE_PM_STATUS_0_PORT_0_4,
> + PCIE_PM_STATUS_7_0_EP4) &&
> + reg != PCIE_COMMON_CLOCK_CONFIG_0_4_0 &&
> + !__reg_within_range(reg, PCIE_SoC_INT_ROUTER_STATUS0_REG,
> + PCIE_SoC_INT_ROUTER_STATUS3_REG) &&
> + reg != SYSTEM_CONFIG_STATUS_REG &&
> + reg != COMPENSATION_REG1);

For this I'd write a switch statement with the range checks in the
default: case. Actually you could just use the GCC switch range
feature:

case PCIE_PM_STATUS_0_PORT_0_4..PCIE_PM_STATUS_7_0_EP4:

Either of these would increase readability.

but generally

Reviewed-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
[unhandled content-type:application/pgp-signature]
\
 
 \ /
  Last update: 2012-10-23 20:01    [W:0.126 / U:0.060 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site