linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sebastian Reichel <sebastian.reichel@collabora.com>
To: Sebastian Reichel <sre@kernel.org>
Cc: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Pali Rohár" <pali.rohar@gmail.com>, "Milo Kim" <milo.kim@ti.com>,
	"Andreas Dannenberg" <dannenberg@ti.com>,
	"Krzysztof Kozlowski" <k.kozlowski@samsung.com>,
	"Hans de Goede" <hdegoede@redhat.com>,
	"Liam Breck" <kernel@networkimprov.net>,
	linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org,
	"Sebastian Reichel" <sebastian.reichel@collabora.com>
Subject: [PATCHv1 07/14] power: supply: bq24257: fix race-condition in sysfs registration
Date: Mon,  1 Oct 2018 00:03:42 +0200	[thread overview]
Message-ID: <20180930220349.10515-8-sebastian.reichel@collabora.com> (raw)
In-Reply-To: <20180930220349.10515-1-sebastian.reichel@collabora.com>

This registers custom sysfs properties using the native functionality
of the power-supply framework, which cleans up the code a bit and
fixes a race-condition. Before this patch the sysfs attributes were
not properly registered to udev.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
---
 drivers/power/supply/bq24257_charger.c | 15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)

diff --git a/drivers/power/supply/bq24257_charger.c b/drivers/power/supply/bq24257_charger.c
index 6fc31bdc639b..673c7d6ff1a7 100644
--- a/drivers/power/supply/bq24257_charger.c
+++ b/drivers/power/supply/bq24257_charger.c
@@ -845,7 +845,7 @@ static DEVICE_ATTR(high_impedance_enable, S_IWUSR | S_IRUGO,
 static DEVICE_ATTR(sysoff_enable, S_IWUSR | S_IRUGO,
 		   bq24257_sysfs_show_enable, bq24257_sysfs_set_enable);
 
-static struct attribute *bq24257_charger_attr[] = {
+static struct attribute *bq24257_charger_sysfs_attrs[] = {
 	&dev_attr_ovp_voltage.attr,
 	&dev_attr_in_dpm_voltage.attr,
 	&dev_attr_high_impedance_enable.attr,
@@ -853,14 +853,13 @@ static struct attribute *bq24257_charger_attr[] = {
 	NULL,
 };
 
-static const struct attribute_group bq24257_attr_group = {
-	.attrs = bq24257_charger_attr,
-};
+ATTRIBUTE_GROUPS(bq24257_charger_sysfs);
 
 static int bq24257_power_supply_init(struct bq24257_device *bq)
 {
 	struct power_supply_config psy_cfg = { .drv_data = bq, };
 
+	psy_cfg.attr_grp = bq24257_charger_sysfs_groups;
 	psy_cfg.supplied_to = bq24257_charger_supplied_to;
 	psy_cfg.num_supplicants = ARRAY_SIZE(bq24257_charger_supplied_to);
 
@@ -1084,12 +1083,6 @@ static int bq24257_probe(struct i2c_client *client,
 		return ret;
 	}
 
-	ret = sysfs_create_group(&bq->charger->dev.kobj, &bq24257_attr_group);
-	if (ret < 0) {
-		dev_err(dev, "Can't create sysfs entries\n");
-		return ret;
-	}
-
 	return 0;
 }
 
@@ -1100,8 +1093,6 @@ static int bq24257_remove(struct i2c_client *client)
 	if (bq->iilimit_autoset_enable)
 		cancel_delayed_work_sync(&bq->iilimit_setup_work);
 
-	sysfs_remove_group(&bq->charger->dev.kobj, &bq24257_attr_group);
-
 	bq24257_field_write(bq, F_RESET, 1); /* reset to defaults */
 
 	return 0;
-- 
2.19.0


  parent reply	other threads:[~2018-09-30 22:04 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-30 22:03 [PATCHv1 00/14] power: supply: Fix custom sysfs attribute registration Sebastian Reichel
2018-09-30 22:03 ` [PATCHv1 01/14] power: supply: core: add support for custom sysfs attributes Sebastian Reichel
2018-09-30 22:03 ` [PATCHv1 02/14] power: supply: bq2415x: fix race-condition in sysfs registration Sebastian Reichel
2018-09-30 22:03 ` [PATCHv1 03/14] power: supply: ds2780: " Sebastian Reichel
2018-09-30 22:03 ` [PATCHv1 04/14] power: supply: ds2781: " Sebastian Reichel
2018-09-30 22:03 ` [PATCHv1 05/14] power: supply: lp8788: " Sebastian Reichel
2018-09-30 22:03 ` [PATCHv1 06/14] power: supply: bq24190_charger: " Sebastian Reichel
2018-09-30 22:03 ` Sebastian Reichel [this message]
2018-09-30 22:03 ` [PATCHv1 08/14] power: supply: charger-manager: simplify generation of sysfs attribute group name Sebastian Reichel
2018-09-30 22:03 ` [PATCHv1 09/14] power: supply: charger-manager: fix race-condition in sysfs registration Sebastian Reichel
2018-09-30 22:03 ` [PATCHv1 10/14] power: supply: pcf50633: " Sebastian Reichel
2018-09-30 22:03 ` [PATCHv1 11/14] power: supply: ds2780: fix race-condition in bin attribute registration Sebastian Reichel
2018-09-30 22:03 ` [PATCHv1 12/14] power: supply: ds2781: " Sebastian Reichel
2018-09-30 22:03 ` [PATCHv1 13/14] power: supply: ds2780: switch to devm_power_supply_register Sebastian Reichel
2018-09-30 22:03 ` [PATCHv1 14/14] power: supply: ds2781: " Sebastian Reichel
2018-10-02 23:00 ` [PATCHv1 00/14] power: supply: Fix custom sysfs attribute registration Greg Kroah-Hartman

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=20180930220349.10515-8-sebastian.reichel@collabora.com \
    --to=sebastian.reichel@collabora.com \
    --cc=dannenberg@ti.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hdegoede@redhat.com \
    --cc=k.kozlowski@samsung.com \
    --cc=kernel@networkimprov.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=milo.kim@ti.com \
    --cc=pali.rohar@gmail.com \
    --cc=sre@kernel.org \
    /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: link
Be 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).