Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp677409yba; Thu, 18 Apr 2019 07:50:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqz57ZjlNjtzxJGnfcitwEhvaJeK+HPFB3tQC4UDNgR1Eai1sPpCN2ypHXKmHoOKVugl+DeU X-Received: by 2002:a65:60ca:: with SMTP id r10mr11606313pgv.64.1555599037597; Thu, 18 Apr 2019 07:50:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555599037; cv=none; d=google.com; s=arc-20160816; b=uX1DN1bWjgTXUYruPluO4SJAar3dIsQgb0da39O0N5kZvZADalhVdlsI13AGgMq16s AIN0ashEA7AU+DaEmUmKfyKFaFZZyWGwCknQ6imqPAZlb6p+J7zfTQdJ4VM1apgiSepO o9BOXNcAr1jq33db75zTLgnx+4Mrnxfuy0E7YphFgwJkmvF1wcWjQPdnH7qa74v7VnZe LLCibQKv4mpBU42D3paSZoL5hjkP450ZPyl3fHmWvJ+/x81CQ3H8RO+lr5cnzmubNFoR VYWtxiATLYlYLFaz+cC+qOJ8L4h4xdF8ARZg/XMQ+nPoVcV3xuy+0yAS39HLZfpNvk4p Skkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=tMajJ/NkvVCmYCkUQvaYn1q1jPHB5vfdN8Fvern/BXc=; b=vG708bKTRXdK8YmBNvfWD7c78OhVQM1Kpd+bojlaIdwJazkbdYsqRaBr+CdbLHrBH5 nKt3mAv1y1fcrlJc3y60OMv/d7sUfss3LXFR8Ohd7hjbmoDFeN8aTbVIvAL1eK63WfMY 739qVIxq1KsP/izbjSwdYzypwsWwQeKZptnSvV8jSV/iFcR9Nuo1nBhzR+op4XHk6xJh 9sExiwGLd8DOaw8y2xDuvEjXImxqB3u36ThEHnuXZl1p/5dLyim28I47wtyYdUqcs+Cw U2+JAy3JC/EbqTMHqLsZSbV8C/rMH0A3DVSF0A/yZ3U3Ad0CYwHF64/V1sgwu39nnlDg ASTA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y16si2197254plr.431.2019.04.18.07.50.22; Thu, 18 Apr 2019 07:50:37 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389544AbfDROrz (ORCPT + 99 others); Thu, 18 Apr 2019 10:47:55 -0400 Received: from shell.v3.sk ([90.176.6.54]:48053 "EHLO shell.v3.sk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389464AbfDROrh (ORCPT ); Thu, 18 Apr 2019 10:47:37 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.v3.sk (Postfix) with ESMTP id EFA561027BC; Thu, 18 Apr 2019 16:47:33 +0200 (CEST) Received: from shell.v3.sk ([127.0.0.1]) by localhost (zimbra.v3.sk [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id K--TdcROK2jY; Thu, 18 Apr 2019 16:47:19 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by zimbra.v3.sk (Postfix) with ESMTP id 416781027A8; Thu, 18 Apr 2019 16:47:09 +0200 (CEST) X-Virus-Scanned: amavisd-new at zimbra.v3.sk Received: from shell.v3.sk ([127.0.0.1]) by localhost (zimbra.v3.sk [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id NHJD_dvIXovh; Thu, 18 Apr 2019 16:47:05 +0200 (CEST) Received: from belphegor.brq.redhat.com (nat-pool-brq-t.redhat.com [213.175.37.10]) by zimbra.v3.sk (Postfix) with ESMTPSA id D116C1027BF; Thu, 18 Apr 2019 16:47:01 +0200 (CEST) From: Lubomir Rintel To: Sebastian Reichel Cc: Darren Hart , Rob Herring , Mark Rutland , x86@kernel.org, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Lubomir Rintel , Sebastian Reichel Subject: [PATCH v7 10/10] power: supply: olpc_battery: Have the framework register sysfs files for us Date: Thu, 18 Apr 2019 16:46:55 +0200 Message-Id: <20190418144655.18758-11-lkundrak@v3.sk> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190418144655.18758-1-lkundrak@v3.sk> References: <20190418144655.18758-1-lkundrak@v3.sk> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The power framework gained ability to register groups of sysfs attributes in commit cef8fe6a382c ("power: supply: core: add support for custom sysfs attributes"). Signed-off-by: Lubomir Rintel Suggested-by: Sebastian Reichel Reviewed-by: Sebastian Reichel --- Changes since v6: - Collect review tag from Sebastian Reichel Changes since v5: - Added this patch drivers/power/supply/olpc_battery.c | 64 ++++++++++++++++------------- 1 file changed, 35 insertions(+), 29 deletions(-) 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.21.0