Re: [PATCH 1/2] platform/x86: intel_cht_int33fe: Register battery fuel gauge only for Yoga Book

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Feb 9, 2019 at 12:00 PM Yauhen Kharuzhy <jekhor@xxxxxxxxx> wrote:

Thanks for the patch, my comments below.

> Lenovo Yoga Book has INT33FE definition in the ACPI DSDT but doesn't
> have USB TypeC connector and muxer (it uses micro USB)

Can you provide a link to acpidump and output of
grep -H . /sys/bus/acpi/devices/*/status

> Add I2C device definition for BQ27542 battery fuel gauge used in this
> notebook and register only it.

I would like to hear Hans' opinion about all this.

>  #include <linux/platform_device.h>
>  #include <linux/regulator/consumer.h>
>  #include <linux/slab.h>
> +#include <linux/dmi.h>

Please, keep it sorted.

>  struct cht_int33fe_data {
> -       struct i2c_client *max17047;
> +       struct i2c_client *battery_fg;

>  static int cht_int33fe_probe(struct platform_device *pdev)
>  {
>         struct device *dev = &pdev->dev;
> @@ -97,6 +115,7 @@ static int cht_int33fe_probe(struct platform_device *pdev)
>         acpi_status status;
>         int fusb302_irq;
>         int ret;
> +       const char *product_name;

Keep it in reversed tree order (longer lines earlier).

> +       data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
> +       if (!data)
> +               return -ENOMEM;
> +
> +       /* Lenovo Yoga Book has INT33FE device in DSDT table but this device
> +        * doesn't have FUSB302, max17047 and pi3usb30532 definitions but has
> +        * a bq27542 battery gauge.
> +        */

This makes me wondering if the proper solution is to bail out and use
fuel gauge directly.

Btw, comment style should have /* line w/o text.

> +       product_name = dmi_get_system_info(DMI_PRODUCT_NAME);
> +       if (dmi_check_system(yogabook_ids)) {

I guess one call to *_match() should be enough.

> +               dev_info(dev, "Lenovo Yoga Book detected, register only "
> +                               "BQ27542 battery Fuel Gauge for it\n");

Don't split lines like this.

> +       }
> +
> +

One blank line is enough.

> -       i2c_unregister_device(data->pi3usb30532);
> -       i2c_unregister_device(data->fusb302);

> +       if (data->pi3usb30532)
> +               i2c_unregister_device(data->pi3usb30532);
> +
> +       if (data->fusb302)
> +               i2c_unregister_device(data->fusb302);

Why? What's wrong with the current state?

-- 
With Best Regards,
Andy Shevchenko



[Index of Archives]     [Linux Kernel Development]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux