Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp290763yba; Fri, 5 Apr 2019 06:50:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqxCROko5qFQoKcND/YTutY7evAANFo+Iq0GyCc6/XUojBBxGCONzN71j1MzJKJN1Mp3wK7y X-Received: by 2002:a63:3190:: with SMTP id x138mr11789649pgx.273.1554472225021; Fri, 05 Apr 2019 06:50:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554472225; cv=none; d=google.com; s=arc-20160816; b=WNU07vfZOYRj26IUCjsu0tvglP7NnFeE0OvCqaJmQqtMdAd4285OnWjxFDZRLg3XgI eiIcgynieaHdXsaB1h+2J/cHyWS2/lQfeX0/72pfukevaXZwfab908LWz6FDA/5BcRD9 3uxoAefUd7Aay423yJZqeJeRD9jqrN8opK37vY5J+eu2vE31h6ava5PbQDVkG0Fi/Mmi 9nhsyPPCgRx+3kwxOqtB2BtUH4rIaXUr0PMoespvdHc/uRmw3yTjCrMj5MBVMse3djR1 y+9QkqCfdCc7HDgoAF5IqpWslHeIxomHo4mF+sA0Llrz74GnJud3oLzo85W8wuzkqycF +7UA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=ePfVnsx3yedmIcce8hzbIlA3J0zPlm9VhP43Eg5suHo=; b=WOgSpkm80di99OOx6lVbJxnqjZEgdyIOdmnTZ1gUdaSbDm9V9knWyBHE9DxFqH3eMQ Dbbjylgt3Fu0mvgqilm72tNZPfrDDE8JBzW7YNx3SuGYIo2jxM+elFLOwXHRenV1ufyE DR5amEHdmzrfHOUHndkI3NQRwkZWGY1ZJg74pt0j7Q+/Er5H3p9pce+kmSSptdzz1T1d CSlPZ3mJYStw5AVfiA2GPLAyDU/VYblHOK0Mwaby7ODO+jXYRylHhKU4IhRgEdcTnpMf 8Ai1ZbfNt7YuJZ0BqmKpwtKtDaUkWroEiKjN844tE1kdlEx4v3yveU66h1R4uOiS0Bht ROvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=RZ4wKu+X; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v3si14681251pga.354.2019.04.05.06.50.10; Fri, 05 Apr 2019 06:50:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=RZ4wKu+X; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731066AbfDENte (ORCPT + 99 others); Fri, 5 Apr 2019 09:49:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:36994 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726027AbfDENte (ORCPT ); Fri, 5 Apr 2019 09:49:34 -0400 Received: from earth.universe (host-091-097-083-087.ewe-ip-backbone.de [91.97.83.87]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 554682186A; Fri, 5 Apr 2019 13:49:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554472172; bh=bUAg6EAurqjHSyc4YImb/XTHcFPiojfgfAa23OOiarI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=RZ4wKu+XAsyDH+lRmMqnm6r8SD+aIIJrwtzBcEsqpyNErHc+iR6AyoUy5vLzEfhNY O3n7TbZC/VohEkTUngSpnXPBT1kzDhjWZXpMdJYuQNhN0D0L4FtHKZWbu6TsMxbCsk Mn1OgJXCzxPEdipP9/P/fWnLdRMuIKP8EQY9BFPg= Received: by earth.universe (Postfix, from userid 1000) id 59FB23C08D5; Fri, 5 Apr 2019 15:49:30 +0200 (CEST) Date: Fri, 5 Apr 2019 15:49:30 +0200 From: Sebastian Reichel To: Lubomir Rintel Cc: Darren Hart , Rob Herring , Mark Rutland , x86@kernel.org, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 10/10] power: supply: olpc_battery: Have the framework register sysfs files for us Message-ID: <20190405134930.acntvwnep3ne6uol@earth.universe> References: <20190310162419.11861-1-lkundrak@v3.sk> <20190310162419.11861-11-lkundrak@v3.sk> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="unphcry5q6yu32bu" Content-Disposition: inline In-Reply-To: <20190310162419.11861-11-lkundrak@v3.sk> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --unphcry5q6yu32bu Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi, On Sun, Mar 10, 2019 at 05:24:19PM +0100, Lubomir Rintel wrote: > The power framework gained ability to register groups of sysfs > attributes in commit cef8fe6a382c ("power: supply: core: add support for > custom sysfs attributes"). >=20 > Signed-off-by: Lubomir Rintel > Suggested-by: Sebastian Reichel >=20 > --- Reviewed-by: Sebastian Reichel -- Sebastian > Changes since v5: > - Added this patch >=20 > drivers/power/supply/olpc_battery.c | 64 ++++++++++++++++------------- > 1 file changed, 35 insertions(+), 29 deletions(-) >=20 > diff --git a/drivers/power/supply/olpc_battery.c b/drivers/power/supply/o= lpc_battery.c > index 0d67158c13d6..c628d3a47e14 100644 > --- a/drivers/power/supply/olpc_battery.c > +++ b/drivers/power/supply/olpc_battery.c > @@ -551,7 +551,7 @@ static ssize_t olpc_bat_eeprom_read(struct file *filp= , struct kobject *kobj, > return count; > } > =20 > -static const struct bin_attribute olpc_bat_eeprom =3D { > +static struct bin_attribute olpc_bat_eeprom =3D { > .attr =3D { > .name =3D "eeprom", > .mode =3D S_IRUGO, > @@ -575,7 +575,7 @@ static ssize_t olpc_bat_error_read(struct device *dev, > return sprintf(buf, "%d\n", ec_byte); > } > =20 > -static const struct device_attribute olpc_bat_error =3D { > +static struct device_attribute olpc_bat_error =3D { > .attr =3D { > .name =3D "error", > .mode =3D S_IRUGO, > @@ -583,6 +583,27 @@ static const struct device_attribute olpc_bat_error = =3D { > .show =3D olpc_bat_error_read, > }; > =20 > +static struct attribute *olpc_bat_sysfs_attrs[] =3D { > + &olpc_bat_error.attr, > + NULL > +}; > + > +static struct bin_attribute *olpc_bat_sysfs_bin_attrs[] =3D { > + &olpc_bat_eeprom, > + NULL > +}; > + > +static const struct attribute_group olpc_bat_sysfs_group =3D { > + .attrs =3D olpc_bat_sysfs_attrs, > + .bin_attrs =3D olpc_bat_sysfs_bin_attrs, > + > +}; > + > +static const struct attribute_group *olpc_bat_sysfs_groups[] =3D { > + &olpc_bat_sysfs_group, > + NULL > +}; > + > /********************************************************************* > * Initialisation > *********************************************************************/ > @@ -615,7 +636,8 @@ static int olpc_battery_suspend(struct platform_devic= e *pdev, > =20 > static int olpc_battery_probe(struct platform_device *pdev) > { > - struct power_supply_config psy_cfg =3D {}; > + struct power_supply_config bat_psy_cfg =3D {}; > + struct power_supply_config ac_psy_cfg =3D {}; > struct olpc_battery_data *data; > uint8_t status; > uint8_t ecver; > @@ -654,10 +676,11 @@ static int olpc_battery_probe(struct platform_devic= e *pdev) > =20 > /* Ignore the status. It doesn't actually matter */ > =20 > - psy_cfg.of_node =3D pdev->dev.of_node; > - psy_cfg.drv_data =3D data; > + ac_psy_cfg.of_node =3D pdev->dev.of_node; > + ac_psy_cfg.drv_data =3D data; > =20 > - data->olpc_ac =3D devm_power_supply_register(&pdev->dev, &olpc_ac_desc,= &psy_cfg); > + data->olpc_ac =3D devm_power_supply_register(&pdev->dev, &olpc_ac_desc, > + &ac_psy_cfg); > if (IS_ERR(data->olpc_ac)) > return PTR_ERR(data->olpc_ac); > =20 > @@ -671,37 +694,21 @@ static int olpc_battery_probe(struct platform_devic= e *pdev) > olpc_bat_desc.num_properties =3D ARRAY_SIZE(olpc_xo1_bat_props); > } > =20 > - data->olpc_bat =3D devm_power_supply_register(&pdev->dev, &olpc_bat_des= c, &psy_cfg); > + bat_psy_cfg.of_node =3D pdev->dev.of_node; > + bat_psy_cfg.drv_data =3D data; > + bat_psy_cfg.attr_grp =3D olpc_bat_sysfs_groups; > + > + data->olpc_bat =3D devm_power_supply_register(&pdev->dev, &olpc_bat_des= c, > + &bat_psy_cfg); > if (IS_ERR(data->olpc_bat)) > return PTR_ERR(data->olpc_bat); > =20 > - ret =3D device_create_bin_file(&data->olpc_bat->dev, &olpc_bat_eeprom); > - if (ret) > - return ret; > - > - ret =3D device_create_file(&data->olpc_bat->dev, &olpc_bat_error); > - if (ret) > - goto error_failed; > - > if (olpc_ec_wakeup_available()) { > device_set_wakeup_capable(&data->olpc_ac->dev, true); > device_set_wakeup_capable(&data->olpc_bat->dev, true); > } > =20 > return 0; > - > -error_failed: > - device_remove_bin_file(&data->olpc_bat->dev, &olpc_bat_eeprom); > - return ret; > -} > - > -static int olpc_battery_remove(struct platform_device *pdev) > -{ > - struct olpc_battery_data *data =3D platform_get_drvdata(pdev); > - > - device_remove_file(&data->olpc_bat->dev, &olpc_bat_error); > - device_remove_bin_file(&data->olpc_bat->dev, &olpc_bat_eeprom); > - return 0; > } > =20 > static const struct of_device_id olpc_battery_ids[] =3D { > @@ -717,7 +724,6 @@ static struct platform_driver olpc_battery_driver =3D= { > .of_match_table =3D olpc_battery_ids, > }, > .probe =3D olpc_battery_probe, > - .remove =3D olpc_battery_remove, > .suspend =3D olpc_battery_suspend, > }; > =20 > --=20 > 2.20.1 >=20 --unphcry5q6yu32bu Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEE72YNB0Y/i3JqeVQT2O7X88g7+poFAlynXOoACgkQ2O7X88g7 +po67Q/+JS2eQ+iEKpeTffBWTUvRYiV+Fpj+B6N7E5rO1DOK5TnhWXyobmNpfz69 AaNMYf1e+c4w5555zZxRZ/itZesLirJmJ205XeUPWDpfr5y1mGNiCpDq+7BBSyRk 0pNitWKWjaae9gIPfXz1iOBz1s35HFquIM34OPqxRZ2TsuLyfeJ+OJgVKiaETTSe kJJ78Xe1F7rKNlXf0I6pkO+8FipBuTadlBXcn3sC90aFx5ewnGyCs5AhvnjYnIJV iJ+jeIS5c0EVeUMD9X7DEk4wPQGJEIHbUUx2DJ0hZkr26Nx1xCxYVWGltSBCVtfr woEv2A7d+GL9zIkznZz6FAuGPxT1WKM9F8lFlkiq+8bQ6vZpFmNtscVrvnIkue6N +v/EF9E2/zNfsP8e7dBo6DuVmBq255uMkL6IZlu5DiucpKWQhre3AjKC/RuZqq1w yavx/Ga81EvoKt2uCPJwgqAJSoYVlAaVog56Qa5Sa2HWmRPL7vPhGBi2TG56vtbU T7vmAKHW6yt88uHr7zgQ8EJULeGgmNJhJGaMrP5846Vp6cvwTk6YozNCrXQ4CShs avrpOBjJQ6iukLBEWDxozfBF1TM/2FRZUeDYadUuQVJuEBgHkUunb0WPmwMmQOMW Cl78VeVF5iLctfjEStiOPalgZhIvjWo5RGQyUP05Si8pABkvft4= =LZl8 -----END PGP SIGNATURE----- --unphcry5q6yu32bu--