Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp374257lqs; Thu, 13 Jun 2024 12:31:47 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWVWeKygiOkdu4lVawov2aZRXO025O9T9VJYKDF3bHlga2uETy9b29mcgUIq4RH04socVfkiRzyRioL0AlKYL6UIRugV2Dm1YTTiAcecQ== X-Google-Smtp-Source: AGHT+IFitW5O6i0IwEp9J9AIcShE97QQQvUvzlWIuSlhh8v4m+1P6t+a5HqJaICsblux51QsOnR2 X-Received: by 2002:a17:906:3786:b0:a63:49d3:e1c5 with SMTP id a640c23a62f3a-a6f60de1c35mr53787666b.64.1718307106858; Thu, 13 Jun 2024 12:31:46 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718307106; cv=pass; d=google.com; s=arc-20160816; b=i6XhgYskvrK+K3PXbwPgqSXtCSuIgZ4rLcyl38l9tmwQaRJkc/f/yPQewcw2aiEojV nR4wiaoJoddLgOrynsdVYcDOAGq1R6ornoiahpgd33Kpx5rvA2xHAMghZWv/W486e1de lq6UFQShmSlEUUFGfF8KVgJuCHo151sBD2BwFKUDf9QO9boJHeEU4xbaHISQwY6CZoDe DtjDB+bT9MO5h3QFuibweYIRQ5xae1deyxezhoCPgJnK04GaFXkjTlKAskQSbVuS9m5T I74FLRscVyo1oTKQrSm/PdKS8yRjDrLCY9d5i2OLJN2sJqTiFVsyRZ9yv7JJmjTPmwnm zaWg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=b8ywdsPotGzzVtHV0omXufcErHr0wfq8huYkzn344tY=; fh=TUzXlHjdfDAQiUCYky71LNNyOC7uEIwI1yKxg+ZueZ0=; b=LW1QAVi64GF7J6ZRrPwQQomYnEjoD24Gf3kB2puwdu0wav8LIl8y6LKiRnERslufNk WLfxVZ2mgX0KbT8B9LMFtAxbnXwxpbMTez02XfenMSGG2yPClX7d4I/KPlGSnXTLytnj yb+EKzQZT7xuAl/7CDOeaIaxEHCWTn/7Z0I2Hjgu7V0fBZl1wOaJMFyftoL5cI5Wtc4i PIAa8BS+WzQYxM37U36NDTcDbMPxDntuM0PuY2vJvgIutqwkW8b9zbSGk0uaHcezPjYO VYhD8oBzrNx30GiAL266ArsPxGF9PJurdLBQdvCJajx9tOv16phHSLJcFs6ULS9BAAZm movg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fm6LvKOq; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-213926-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-213926-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a640c23a62f3a-a6f56dd6d1csi93651966b.363.2024.06.13.12.31.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jun 2024 12:31:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-213926-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fm6LvKOq; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-213926-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-213926-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 1EFD51F22656 for ; Thu, 13 Jun 2024 19:31:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0024614B965; Thu, 13 Jun 2024 19:31:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="fm6LvKOq" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 23D2A1EA87; Thu, 13 Jun 2024 19:31:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718307096; cv=none; b=CK/6hGJQybOzDQ5txNXJ4B9o7pmB/pXoQ0raEiKMC5rakHIjcEeoWWFA1Y+/Zy9DOf2T1EmC9rBqD2NNFQrzjxDujea44zvsFzo9DVJH1sNVqLZ1D8VpFv0v46FG8o/GmYoBQb1K7AL/GQhzZOOVqtJ77NZOYoyy90qIj07FgEI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718307096; c=relaxed/simple; bh=Msrty0CWghk7EgHSD1Enom1a+uVe/GJvqQt78XwijVc=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=TH4sX8MWCO3BJJ8vr5dyMkkRtuzCElVfd2+enHi8a45B2xRBiLRPZJ9MkGRWxSe9lUzEoRvzaUrr1iRvBRxDfZ4G5qhbSzQTXZxco9vDk1oLw9+FamZUs1Bs6o4A+SdEdPgW9xkww52t3HO4Rq0PiVrcv36jyAe5M4FmXLl2M9A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fm6LvKOq; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id B8B88C3277B; Thu, 13 Jun 2024 19:31:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718307095; bh=Msrty0CWghk7EgHSD1Enom1a+uVe/GJvqQt78XwijVc=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=fm6LvKOq8LnCkBKudRaefpRrC9T/XZx9lMSs+kmy3GilS6OOTjYz0bbmhro7CPW+z JIJOSCprtyehKRXBJif3Je62s5h884wbeaMM+rh64Z+XdWxbwHFaVojIngZ1oMp6Bc UiGSrmploDvU1bCi0dAsnnZIY269KCwJy5LlKlhxlZobY4Zc2Y2k75m+obusE1zBEE 50tnPmceVKM/u1IJmK/TMLwUDiN45ZvidKgUQ3wYtkW4LDBrT982XxT3dBKj04EjAm 3Ngmnh+M0MOJT4KrPdubtUZMLdd0aFs7XdYYIfKsFJjWZ6S9PKLO0OcFAohEvNOzvk jOogEuJ6APleQ== Received: by mail-oo1-f44.google.com with SMTP id 006d021491bc7-5bad97708efso76639eaf.1; Thu, 13 Jun 2024 12:31:35 -0700 (PDT) X-Forwarded-Encrypted: i=1; AJvYcCXqhMFnW2/iSDSXVG1dTV42Ew566CqkYl+5FeugrTXvzrK/t9wbTG/CCyTgwF9w+PRkw7jqeajqTqgWOUBKGQJmyqYRsXCotXzBhHyUE3Xzk+FWdIE29uqC9twL3u84uB6bunAXn4o9Tw== X-Gm-Message-State: AOJu0YzjOcWyA86xrLC+4/oKiwKQYtvGiR0NbwfT9Fw9VGYauGIN4JaX nWR1A8hueh/8OHtxoKp1M1wT40Wox+XD7H6mi8Q3BZ9v4iaHuITgg3yrJJc6a09+liSpipf32r0 4yepfPRl8/ELd6FDfbVo7q2sHMgo= X-Received: by 2002:a05:6820:287:b0:5ba:ca8a:6598 with SMTP id 006d021491bc7-5bdad9f3131mr667709eaf.0.1718307095066; Thu, 13 Jun 2024 12:31:35 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240609-acpi-sbs-sysfs-group-v1-1-7f0bf95523e7@weissschuh.net> In-Reply-To: <20240609-acpi-sbs-sysfs-group-v1-1-7f0bf95523e7@weissschuh.net> From: "Rafael J. Wysocki" Date: Thu, 13 Jun 2024 21:31:23 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] ACPI: SBS: manage alarm sysfs attribute through psy core To: =?UTF-8?Q?Thomas_Wei=C3=9Fschuh?= Cc: "Rafael J. Wysocki" , Len Brown , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sun, Jun 9, 2024 at 1:13=E2=80=AFPM Thomas Wei=C3=9Fschuh wrote: > > Let the power supply core register the attribute. > This ensures that the attribute is created before the device is > announced to userspace, avoiding a race condition. > > Signed-off-by: Thomas Wei=C3=9Fschuh > --- > Only compile-tested. > > This is the SBS equivalent of > "ACPI: battery: create alarm sysfs attribute atomically" [0] > > [0] https://lore.kernel.org/lkml/20240609-acpi-battery-cleanup-v1-5-34451= 7bdca73@weisss > --- > drivers/acpi/sbs.c | 23 ++++++++++++----------- > 1 file changed, 12 insertions(+), 11 deletions(-) > > diff --git a/drivers/acpi/sbs.c b/drivers/acpi/sbs.c > index dc8164b182dc..442c5905d43b 100644 > --- a/drivers/acpi/sbs.c > +++ b/drivers/acpi/sbs.c > @@ -77,7 +77,6 @@ struct acpi_battery { > u16 spec; > u8 id; > u8 present:1; > - u8 have_sysfs_alarm:1; > }; > > #define to_acpi_battery(x) power_supply_get_drvdata(x) > @@ -462,12 +461,18 @@ static ssize_t acpi_battery_alarm_store(struct devi= ce *dev, > return count; > } > > -static const struct device_attribute alarm_attr =3D { > +static struct device_attribute alarm_attr =3D { > .attr =3D {.name =3D "alarm", .mode =3D 0644}, > .show =3D acpi_battery_alarm_show, > .store =3D acpi_battery_alarm_store, > }; > > +static struct attribute *acpi_battery_attrs[] =3D { > + &alarm_attr.attr, > + NULL > +}; > +ATTRIBUTE_GROUPS(acpi_battery); > + > /* ---------------------------------------------------------------------= ----- > Driver Interface > ---------------------------------------------------------------------= ----- */ > @@ -518,7 +523,10 @@ static int acpi_battery_read(struct acpi_battery *ba= ttery) > static int acpi_battery_add(struct acpi_sbs *sbs, int id) > { > struct acpi_battery *battery =3D &sbs->battery[id]; > - struct power_supply_config psy_cfg =3D { .drv_data =3D battery, }= ; > + struct power_supply_config psy_cfg =3D { > + .drv_data =3D battery, > + .attr_grp =3D acpi_battery_groups, > + }; > int result; > > battery->id =3D id; > @@ -548,10 +556,6 @@ static int acpi_battery_add(struct acpi_sbs *sbs, in= t id) > goto end; > } > > - result =3D device_create_file(&battery->bat->dev, &alarm_attr); > - if (result) > - goto end; > - battery->have_sysfs_alarm =3D 1; > end: > pr_info("%s [%s]: Battery Slot [%s] (battery %s)\n", > ACPI_SBS_DEVICE_NAME, acpi_device_bid(sbs->device), > @@ -563,11 +567,8 @@ static void acpi_battery_remove(struct acpi_sbs *sbs= , int id) > { > struct acpi_battery *battery =3D &sbs->battery[id]; > > - if (battery->bat) { > - if (battery->have_sysfs_alarm) > - device_remove_file(&battery->bat->dev, &alarm_att= r); > + if (battery->bat) > power_supply_unregister(battery->bat); > - } > } > > static int acpi_charger_add(struct acpi_sbs *sbs) > > --- Applied as 6.11 material, thanks!