LKML Archive on lore.kernel.org help / color / mirror / Atom feed
From: Tobias Schramm <t.schramm@manjaro.org> To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>, Tobias Schramm <t.schramm@manjaro.org> Cc: Sebastian Reichel <sre@kernel.org>, Rob Herring <robh+dt@kernel.org>, Mark Rutland <mark.rutland@arm.com>, Daniel Thompson <daniel.thompson@linaro.org>, Maxime Ripard <mripard@kernel.org>, Sam Ravnborg <sam@ravnborg.org>, Heiko Stuebner <heiko.stuebner@theobroma-systems.com>, Stephan Gerhold <stephan@gerhold.net>, Mark Brown <broonie@kernel.org>, Mauro Carvalho Chehab <mchehab+samsung@kernel.org>, "David S. Miller" <davem@davemloft.net>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Jonathan Cameron <Jonathan.Cameron@huawei.com>, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v4 3/3] power: supply: add CellWise cw2015 fuel gauge driver Date: Sun, 15 Mar 2020 12:00:35 +0100 [thread overview] Message-ID: <fd75f94b-8e08-97da-a396-6df61c6fd89f@manjaro.org> (raw) In-Reply-To: <20200313091124.GP1922688@smile.fi.intel.com> Hi Andy, thanks for your feedback. Please find my comments inline. > >> + dev_err(cw_bat->dev, >> + "Failed to upload battery info\n"); > > Indentation of the second line. > I've seen quite a few different indentation styles used in kernel source. Personally I'd indent like this: dev_warn(cw_bat->dev, "some long error message"); However coding-style.rst specifies that spaces are never to be used for indentation. May I assume they are ok for alignment though? > And I'm thinking that we may refactor this function. So, > > length = ..._count_u8(...); > if (length < 0) { > dev_warn(...); > } else if (length != ...) { > dev_err(...); > ... > } else { > ... > } > > > >> + if (length != CW2015_SIZE_BATINFO) { >> + dev_err(cw_bat->dev, "battery-profile must be %d bytes", >> + CW2015_SIZE_BATINFO); >> + return -EINVAL; >> + } >> + >> + cw_bat->bat_profile = devm_kzalloc(dev, length, GFP_KERNEL); >> + if (!cw_bat->bat_profile) { >> + dev_err(cw_bat->dev, >> + "Failed to allocate memory for battery config info"); >> + return -ENOMEM; >> + } >> + >> + ret = device_property_read_u8_array(dev, >> + "cellwise,battery-profile", >> + cw_bat->bat_profile, >> + length); >> + if (ret) >> + return ret; >> + } else { >> + dev_warn(cw_bat->dev, >> + "No battery-profile found, rolling with current flash contents"); >> + } >> + > > ...and here... > >> + cw_bat->poll_interval_ms = CW2015_DEFAULT_POLL_INTERVAL_MS; >> + ret = device_property_read_u32(dev, "cellwise,monitor-interval-ms", &value); >> + if (ret >= 0) { >> + dev_dbg(cw_bat->dev, "Overriding default monitor-interval with %u ms", >> + value); >> + cw_bat->poll_interval_ms = value; >> + } > > ret = device_property_read_u32(dev, "cellwise,monitor-interval-ms", &cw_bat->poll_interval_ms); > if (ret) { > dev_dbg(cw_bat->dev, "Use default\n"); > cw_bat->poll_interval_ms = CW2015_DEFAULT_POLL_INTERVAL_MS; > } > > What do you think? > Looks good to me. I'll use it just like that. > >> + int ret; >> + struct cw_battery *cw_bat; > >> + struct power_supply_config psy_cfg = { }; > > Don't you need 0 here? > Yeah, that would be better. Think empty initializers are a GNU extension. Best Regards, Tobias
next prev parent reply other threads:[~2020-03-15 11:00 UTC|newest] Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-03-12 22:24 [PATCH v4 0/3] Add support for CellWise cw2015 fuel gauge Tobias Schramm 2020-03-12 22:24 ` [PATCH v4 1/3] dt-bindings: Document cellwise vendor-prefix Tobias Schramm 2020-03-12 22:24 ` [PATCH v4 2/3] dt-bindings: power: supply: add cw2015_battery bindings Tobias Schramm 2020-03-12 22:24 ` [PATCH v4 3/3] power: supply: add CellWise cw2015 fuel gauge driver Tobias Schramm 2020-03-13 9:11 ` Andy Shevchenko 2020-03-15 11:00 ` Tobias Schramm [this message] 2020-03-15 11:16 ` Sam Ravnborg
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=fd75f94b-8e08-97da-a396-6df61c6fd89f@manjaro.org \ --to=t.schramm@manjaro.org \ --cc=Jonathan.Cameron@huawei.com \ --cc=andriy.shevchenko@linux.intel.com \ --cc=broonie@kernel.org \ --cc=daniel.thompson@linaro.org \ --cc=davem@davemloft.net \ --cc=devicetree@vger.kernel.org \ --cc=gregkh@linuxfoundation.org \ --cc=heiko.stuebner@theobroma-systems.com \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-pm@vger.kernel.org \ --cc=mark.rutland@arm.com \ --cc=mchehab+samsung@kernel.org \ --cc=mripard@kernel.org \ --cc=robh+dt@kernel.org \ --cc=sam@ravnborg.org \ --cc=sre@kernel.org \ --cc=stephan@gerhold.net \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).