Re: [PATCH 3/4] Convert WM97xx driver to use platform_data

Mark Brown
2009-07-23T11:49:02Z

On Wed, Jul 22, 2009 at 01:04:16PM +0200, Marek Vasut wrote:

> diff --git a/drivers/input/touchscreen/wm97xx-core.c b/drivers/input/touchscreen/wm97xx-core.c
> index 252eb11..f944918 100644
> --- a/drivers/input/touchscreen/wm97xx-core.c
> +++ b/drivers/input/touchscreen/wm97xx-core.c
> @@ -561,6 +561,7 @@ static void wm97xx_ts_input_close(struct input_dev *idev)
> static int wm97xx_probe(struct device *dev)
> {
> struct wm97xx *wm;
> + struct wm97xx_pdata *pdata = dev->platform_data;
> int ret = 0, id = 0;
>
> wm = kzalloc(sizeof(struct wm97xx), GFP_KERNEL);

> +++ b/drivers/power/wm97xx_battery.c
> @@ -22,17 +22,19 @@
> #include <linux/spinlock.h>
> #include <linux/interrupt.h>
> #include <linux/gpio.h>
> -#include <linux/wm97xx_batt.h>
> +#include <linux/irq.h>

...

> +static irqreturn_t wm97xx_chrg_irq(int irq, void *data)
> +{
> + schedule_work(&bat_work);
> + return IRQ_HANDLED;
> +}
> +

> - if (pdata->charge_gpio >= 0 && gpio_is_valid(pdata->charge_gpio)) {
> + if (gpio_is_valid(pdata->charge_gpio)) {
> ret = gpio_request(pdata->charge_gpio, "BATT CHRG");
> if (ret)
> goto err;
> ret = gpio_direction_input(pdata->charge_gpio);
> if (ret)
> goto err2;
> + ret = request_irq(gpio_to_irq(pdata->charge_gpio),
> + wm97xx_chrg_irq, IRQF_DISABLED,
> + "AC Detect", 0);
> + if (ret)
> + goto err2;
> props++; /* POWER_SUPPLY_PROP_STATUS */

None of these hunks appear to be related to the change in where the
platform data is coming from and should be split out, as should all the
error handling code which follows.

> -void __init wm97xx_bat_set_pdata(struct wm97xx_batt_info *data)
> -{
> - pdata = data;
> -}
> -EXPORT_SYMBOL_GPL(wm97xx_bat_set_pdata);
> -

This change and the removal of the old structure should ideally be
included in the commit which converts all the users to avoid build
errors during bisection. I'd say it's OK to have the driver just print
a warning or something if someone boots the affected kernel during the
transition period.