From patchwork Tue Jan 4 23:03:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 12703906 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 99705C433F5 for ; Tue, 4 Jan 2022 23:03:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235731AbiADXDh (ORCPT ); Tue, 4 Jan 2022 18:03:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235651AbiADXDg (ORCPT ); Tue, 4 Jan 2022 18:03:36 -0500 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F3548C061761 for ; Tue, 4 Jan 2022 15:03:35 -0800 (PST) Received: by mail-wm1-x32d.google.com with SMTP id j140-20020a1c2392000000b003399ae48f58so626178wmj.5 for ; Tue, 04 Jan 2022 15:03:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:content-language:to:cc:from :subject:content-transfer-encoding; bh=YnlOWDgjlMB4rFNWbCTyi5cSZMFsXGAB6TZsI/YdqCk=; b=clzvY5RRW6gMAQ8mJr4Cl/33PlAnapvDAyreT4+opYtxJi3lVggDAbqchheZVxc0BB QlbkGIGo5mquIDv2XgAvfEmZHqSUANJcUI1wCkOhILeDZPX5q+eOkZXQtFGITRoHV2Ti Z9gX5i2cDhjI39797aPotpd1ZbttsUaSBrtsWGyVBkO60smSoGvNhYCXPwknQ7qgSnsT YkclEIfT6l9nhOX8rGqQqmuni2/E3JOexYsFktjdWO7fHRIKO7QWjZO0HSMD9Tkwwez/ rOzJwUGskYr8/fM0MkEpj8fmKgHpllMQGkZ0qqhwnzu0jsbDomqky1R604kZZQwqeOkX FCkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent :content-language:to:cc:from:subject:content-transfer-encoding; bh=YnlOWDgjlMB4rFNWbCTyi5cSZMFsXGAB6TZsI/YdqCk=; b=lhnhPwBPvZvsiaqR4uxTX0gCrY1vAucxeKhVc8dNf190AeYGJ7qh5NmK/Sg3OwS15f Hiob+huXn/IqlEW/+2aGG7ZKgdbwtaEjaRv3wDI8rfFj3hBFw5MJwkXwprLP3B1PEyaq 1rvGlBjDAM2ElqLFzuNhCPt4114qmX2ZUtwr6m+2M1UQvXbejl1th6rJ3OS6F4r0tKLj fP2fiZn3OhrnIOtrcEn45mCD6v2OS3U3RDVUz/ipcye7+bNLvgUmKcOxgZfRfgpmsQ5R 2V2A2dh6DdLIZzf7LZHL9F0EAPqTVJPqNo3xgkC2Y9oOV68c0SkiLx0RFqCO+BIWN1Nm /Thw== X-Gm-Message-State: AOAM5310ElSJlZ7XA77YijRc4VnyRnynC/xLJQvrRgznOUQJNOQFMGri PM8k4oMYcX9hYK4vLDNQMio= X-Google-Smtp-Source: ABdhPJxnEifo5VIFZa6qO1chEpu7UXfsS5b+WVvgpkm5jNGxr/RgHbEj2Rm0vcbGA0nQN0VOCtk/Pw== X-Received: by 2002:a1c:9a88:: with SMTP id c130mr456286wme.98.1641337414582; Tue, 04 Jan 2022 15:03:34 -0800 (PST) Received: from ?IPV6:2003:ea:8f2f:5b00:f9ee:e9e3:d08e:f6e9? (p200300ea8f2f5b00f9eee9e3d08ef6e9.dip0.t-ipconnect.de. [2003:ea:8f2f:5b00:f9ee:e9e3:d08e:f6e9]) by smtp.googlemail.com with ESMTPSA id g18sm39554455wrv.42.2022.01.04.15.03.31 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 04 Jan 2022 15:03:34 -0800 (PST) Message-ID: <52cedbd4-7db2-7d81-f6c6-e6f6b7436545@gmail.com> Date: Wed, 5 Jan 2022 00:03:25 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.4.1 Content-Language: en-US To: Sebastian Reichel , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= , Hans de Goede Cc: Linux PM From: Heiner Kallweit Subject: Warning since "power: supply: add charge_behaviour attributes" Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Since 1b0b6cc8030d ("power: supply: add charge_behaviour attributes") I get the following warning: power_supply_init_attrs: Property 37 skipped because it is missing from power_supply_attrs Seems the patch misses the following: Didn't this show up when testing before submitting the patch? diff --git a/drivers/power/supply/power_supply_sysfs.c b/drivers/power/supply/power_supply_sysfs.c index 2cfce2b2e..ef5109102 100644 --- a/drivers/power/supply/power_supply_sysfs.c +++ b/drivers/power/supply/power_supply_sysfs.c @@ -179,6 +179,7 @@ static struct power_supply_attr power_supply_attrs[] = { POWER_SUPPLY_ATTR(CHARGE_CONTROL_LIMIT_MAX), POWER_SUPPLY_ATTR(CHARGE_CONTROL_START_THRESHOLD), POWER_SUPPLY_ATTR(CHARGE_CONTROL_END_THRESHOLD), + POWER_SUPPLY_ENUM_ATTR(CHARGE_BEHAVIOUR), POWER_SUPPLY_ATTR(INPUT_CURRENT_LIMIT), POWER_SUPPLY_ATTR(INPUT_VOLTAGE_LIMIT), POWER_SUPPLY_ATTR(INPUT_POWER_LIMIT), From patchwork Wed Jan 5 06:42:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 12704108 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AE1DFC433F5 for ; Wed, 5 Jan 2022 06:42:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234825AbiAEGm4 (ORCPT ); Wed, 5 Jan 2022 01:42:56 -0500 Received: from todd.t-8ch.de ([159.69.126.157]:41247 "EHLO todd.t-8ch.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231960AbiAEGmz (ORCPT ); Wed, 5 Jan 2022 01:42:55 -0500 From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=weissschuh.net; s=mail; t=1641364971; bh=Dq3BHuCbeArfebh5gWrRObPgO7rpTfM1CntbrUioOgY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M3LGG4logHlSDHooFM9bvmBY4Yg4NkGRxZKbfsjKpWRvg4qvHvSX+s14V3/wjCnZS HP/T9UKPaXkInSnovq7Un1X7JqUwV2AGrP4ioGdpoDmsdUfpLB4vszycblHgSuaDFf Xxmyx1uiCvP5wLili+KHE2St5wIU6vrdNMe/0Nl0= To: Heiner Kallweit , Sebastian Reichel , Hans de Goede Cc: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] power: supply: validate size of power_supply_attrs at compiletime Date: Wed, 5 Jan 2022 07:42:39 +0100 Message-Id: <20220105064239.2689-2-linux@weissschuh.net> X-Mailer: git-send-email 2.34.1 In-Reply-To: <52cedbd4-7db2-7d81-f6c6-e6f6b7436545@gmail.com> References: <52cedbd4-7db2-7d81-f6c6-e6f6b7436545@gmail.com> MIME-Version: 1.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1641364918; l=1340; s=20211113; h=from:subject; bh=Dq3BHuCbeArfebh5gWrRObPgO7rpTfM1CntbrUioOgY=; b=iPHtX2pwqf8rgip2aL0uLNjIsBufKsFp4xuH7kdLPtpddXf1fDdOMxWUJkqdGPdqZupejU0IKW3/ HXw4KbdVCRihWNbMp61HmSQDqgeLI5RUVN97DzxZDIpE48d+E7d2 X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=9LP6KM4vD/8CwHW7nouRBhWLyQLcK1MkP6aTZbzUlj4= Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org For each member of enum power_supply_property a matching entry in power_supply_attrs is needed. Add a basic test at compiletime to validate this in addition to the existing runtime testing. Signed-off-by: Thomas Weißschuh --- drivers/power/supply/power_supply_sysfs.c | 2 ++ include/linux/power_supply.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/drivers/power/supply/power_supply_sysfs.c b/drivers/power/supply/power_supply_sysfs.c index 491ffec7bf47..2565052a7a8c 100644 --- a/drivers/power/supply/power_supply_sysfs.c +++ b/drivers/power/supply/power_supply_sysfs.c @@ -403,6 +403,8 @@ void power_supply_init_attrs(struct device_type *dev_type) { int i; + BUILD_BUG_ON(ARRAY_SIZE(power_supply_attrs) != __POWER_SUPPLY_PROP_CNT); + dev_type->groups = power_supply_attr_groups; for (i = 0; i < ARRAY_SIZE(power_supply_attrs); i++) { diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h index 71f0379c2af8..60853f26e25f 100644 --- a/include/linux/power_supply.h +++ b/include/linux/power_supply.h @@ -172,6 +172,8 @@ enum power_supply_property { POWER_SUPPLY_PROP_MODEL_NAME, POWER_SUPPLY_PROP_MANUFACTURER, POWER_SUPPLY_PROP_SERIAL_NUMBER, + + __POWER_SUPPLY_PROP_CNT }; enum power_supply_type {