Re: [NEW DRIVER V1 1/7] DA9058 MFD core and ADC driver

From: Mark Brown
Date: Thu Aug 02 2012 - 06:16:23 EST


On Thu, Aug 02, 2012 at 09:48:55AM +0100, Anthony Olech wrote:

> +#if 0
> + return regmap_bulk_read(da9058->regmap, reg, val, val_count);
> +#else
> + int ret = regmap_bulk_read(da9058->regmap, reg, val, val_count);
> + return ret;
> +#endif

This shouldn't be going into mainline...

> +/*
> + * if the PMIC is in automatic ADC consersion mode we have the choice
> + * of just getting the last (automatic) conversion or doing a manual
> + * conversion anyway.
> + *
> + * if the PMIC is not in automatic ADC consersion mode we have no choice
> + * we just have to ignore the requested mode and just do a manual
> + * ADC conversion.
> + */
> +static int da9058_automatic_adc_conversion(struct da9058 *da9058,
> + const int channel, int *value)

This ADC stuff should be an IIO driver now.

> + if (pdata->init_board_irq) {
> + ret = pdata->init_board_irq();
> + if (ret)

Why is this conditional? With irqdomains there's no real reason to not
allocate the IRQs even if you can't usefully use them and it helps make
the code simpler.

> + goto err4;

Named labesl are *much* better, it's vastly less painful if you need to
add new code.

> + da9058->reg_read = da9058_register_read;
> + da9058->reg_write = da9058_register_write;
> + da9058->reg_raw_read = da9058_register_raw_read;
> + da9058->reg_raw_write = da9058_register_raw_write;
> + da9058->reg_bulk_read = da9058_register_bulk_read;
> + da9058->reg_bulk_write = da9058_register_bulk_write;
> + da9058->reg_update_bits = da9058_register_update_bits;

These are always the same thing. Just have some inline functions in the
header if you find this useful, the vtable in the driver is just
replicating what regmap does and making things more complicated.

> +int da9058_to_virt_irq_num(struct da9058 *da9058, int irq)
> +{
> + return da9058->irq_base + irq;
> +}
> +EXPORT_SYMBOL_GPL(da9058_to_virt_irq_num);

This should be calling regmap_irq_get_virq() and a static inlinne in the
header.

> + dev_info(da9058->dev, "IRQ %d mapped to virtual array based at %d\n",
> + da9058->chip_irq, da9058->irq_base);

This sort of log message isn't terribly useful and isn't accurate with
irq domains.
--
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/