On Sat, Feb 19, 2011 at 23:10, Bill Gatliff wrote:
> +static inline void pwmc_writel(const struct atmel_pwmc *p, unsigned offset, 
> u32 val)
> +static inline u32 pwmc_readl(const struct atmel_pwmc *p, unsigned offset)
> +static inline void pwmc_chan_writel(const struct pwm_device *p,
> +                                   u32 offset, u32 val)
> +static inline u32 pwmc_chan_readl(const struct pwm_device *p, u32 offset)
> +static inline int __atmel_pwmc_is_on(struct pwm_device *p)
> +static inline void __atmel_pwmc_stop(struct pwm_device *p)
> +static inline void __atmel_pwmc_start(struct pwm_device *p)
> +static inline int __atmel_pwmc_config_polarity(struct pwm_device *p,
> +                                             struct pwm_config *c)
> +static inline int __atmel_pwmc_config_duty_ticks(struct pwm_device *p,
> +                                               struct pwm_config *c)
> +static inline int __atmel_pwmc_config_period_ticks(struct pwm_device *p,
> +                                                 struct pwm_config *c)

seems like a lot of unnecessary inlines.  while the first two might
make sense since they're really just redirecting to the read/write i/o
api, the rest are quite a bit bigger.

> +static inline int __atmel_pwmc_config_polarity(struct pwm_device *p,
> +                                             struct pwm_config *c)
> +static inline int __atmel_pwmc_config_duty_ticks(struct pwm_device *p,
> +                                               struct pwm_config *c)
> +static inline int __atmel_pwmc_config_period_ticks(struct pwm_device *p,
> +                                                 struct pwm_config *c)

these funcs always return 0 and the callers never check the return
value, so i guess these should return void instead

> +static int atmel_pwmc_stop_sync(struct pwm_device *p)
> +{
> +       struct atmel_pwmc *ap = pwm_get_drvdata(p);
> +       int was_on = __atmel_pwmc_is_on(p);
> +       int chan = p - &ap->p[0];
> +       int ret;
> +
> +       if (was_on) {
> +               do {
> +                       init_completion(&ap->complete);
> +                       set_bit(FLAG_STOP, &p->flags);
> +                       pwmc_writel(ap, PWMC_IER, BIT(chan));
> +
> +                       dev_dbg(p->dev, "waiting on stop_sync 
> completion...\n");
> +
> +                       ret = 
> wait_for_completion_interruptible(&ap->complete);
> +
> +                       dev_dbg(p->dev, "stop_sync complete (%d)\n", ret);
> +
> +                       if (ret)
> +                               return ret;
> +               } while (test_bit(FLAG_STOP, &p->flags));
> +       }
> +
> +       return was_on;
> +}

if you changed this to return immediately when !was_on, then you
wouldnt need to indent the entire block.

> +       ap->iobase = ioremap_nocache(r->start, r->end - r->start + 1);

isnt there a resource_size helper ?

> +       if (IS_ERR_OR_NULL(ap->iobase)) {
> +               ret = -ENODEV;
> +               goto err_ioremap;
> +       }

i dont think any of the io funcs return PTR_ERR.  they all return NULL
or a valid address.

> +       for (chan = 0; chan < NCHAN; chan++) {
> +               ap->p[chan].ops = &ap->ops;
> +               pwm_set_drvdata(&ap->p[chan], ap);
> +               ret = pwm_register(&ap->p[chan], &pdev->dev, chan);
> +               if (ret)
> +                       goto err_pwm_register;
> +       }
> +
> +err_pwm_register:
> +       for (chan = 0; chan < chan; chan++) {
> +               if (pwm_is_registered(&ap->p[chan]))
> +                       pwm_unregister(&ap->p[chan]);
> +       }

if you wanted to be tricky, you could just have the unwind not change
the value of "chan".
while (--chan > 0)
    pwm_unregister(&ap->p[chan]);

otherwise, the "chan < chan" test makes no sense in the for loop.

> +static int __devexit atmel_pwmc_remove(struct platform_device *pdev)
> +{
> +       struct atmel_pwmc *ap = platform_get_drvdata(pdev);
> +       int chan;
> +
> +       for (chan = 0; chan < NCHAN; chan++)
> +               if (pwm_is_registered(&ap->p[chan]))
> +                       pwm_unregister(&ap->p[chan]);

why do you test if it's registered ?  the probe function will abort if
any do not register properly.
-mike
--
To unsubscribe from this list: send the line "unsubscribe linux-embedded" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to