From patchwork Mon Jul 17 12:40:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Joaqu=C3=ADn_Ignacio_Aramend=C3=ADa?= X-Patchwork-Id: 121290 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1102923vqt; Mon, 17 Jul 2023 06:13:34 -0700 (PDT) X-Google-Smtp-Source: APBJJlHxE/B4CS28+gooSVeatbg+6ViIg0fXCkjsjKCh1bssZmbslnmM6s/TsasoncIi6CcDj3oy X-Received: by 2002:a17:902:e88b:b0:1b8:72b2:fd3b with SMTP id w11-20020a170902e88b00b001b872b2fd3bmr12878427plg.54.1689599614369; Mon, 17 Jul 2023 06:13:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689599614; cv=none; d=google.com; s=arc-20160816; b=d0ZEl942acqa5TNciVMsawmf1HNQaoSswLNr4XcIfujzwbsZTd3NaZnZOwFjj/jtWr uJ02JHHR1taRIVmTTGGduS7SeFu/pXHsSJZycc6dW2C2DvZXfwm49ZhfWLbn/uVagyq4 MOocGeyTxcAWBF2wzfi6hNTHK5mXg5OAVmVQCmnTMNj0eQHxb/r09yPh0NvJWTHQ6wj/ WjNJ+YMkdbYsZKwZYU5zSj6OWRCGV2MY1UFLbQDxPDJOY+1NLPAtaTjl6V5Iw+0BBCNP /wmIP6Y2ii2786BU4bcG8wAwBQ3H1mzDekKnhqffNj6mZ8KF05Btd7+YlcVK+tAODcSG e5uQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=CST2V5HUJAp534l0pQswZcm6gl2QiyFZ0HpK2IOlhFU=; fh=h793OaUni30alKFb4D+hGQdzb3dwmJ62PCcOI4idbnU=; b=kPzQqr/4yWa+OG/08Yhyk2zAKzjZkV1FLcVPLqGaBqzWvUXdwas5XAL4DjDYik1GUm 9MmGVRj/F4wbVe6fpaVpHcIw/xMKOS4O0YBXmLYUe8n3Kt9XERR9VqxHmCwdUdNY3CUH CdRE3huUQAWbfKSRwepuduPN1qt3hC7YXthrykHCCeXIZih3sob3vJsWYle56i3KGKGz U5mUOUfZNP87JrD/NVeClKoP7MX6tH1k4EfkH8oerFrTPGPjhIm+E+HrH2+WZNoQMYJd lZHukNIavlmKzydYOebow8G4tjorkfddLK8IUDgsMheUOJ3TrtgLgH5HKhIspFINsa8k KqWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=ARJps01w; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p16-20020a170902e75000b001b9ed021929si11825870plf.225.2023.07.17.06.13.21; Mon, 17 Jul 2023 06:13:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=ARJps01w; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230057AbjGQMlR (ORCPT + 99 others); Mon, 17 Jul 2023 08:41:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230256AbjGQMkr (ORCPT ); Mon, 17 Jul 2023 08:40:47 -0400 Received: from mail-oa1-x2d.google.com (mail-oa1-x2d.google.com [IPv6:2001:4860:4864:20::2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C9A81B0; Mon, 17 Jul 2023 05:40:46 -0700 (PDT) Received: by mail-oa1-x2d.google.com with SMTP id 586e51a60fabf-1b03ec2015fso2956902fac.3; Mon, 17 Jul 2023 05:40:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689597645; x=1692189645; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=CST2V5HUJAp534l0pQswZcm6gl2QiyFZ0HpK2IOlhFU=; b=ARJps01w3DllVpl2+KbVZuXzWSgNsiVPaWlIpiXecckN56qqjVG3GAjYVmozjx8xEJ nnXYwf0m8+vhhRVAvS+Ewp86moeXHJA1l1cTnVAXt1xxAxcH83sHC+zJxgX6VrO3wv3e Wow53E/FWfEr/pnS9dTbPVloF4HM9FTmjzItR/j2JXZPZCAqzxYtacBZQcrIAxuYEPFt 15vHzavixeXjjM1XihRbuXrVACXlGbjvA97nA5eUxcsWP16vphon5duI2agJJT2JwANb ukFxKT9v4V9loswL6bOuvHyVVUvLby95IndKDzDyeU3kSqgwBwzASmA/I2f5hyT8c79Z FlFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689597645; x=1692189645; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CST2V5HUJAp534l0pQswZcm6gl2QiyFZ0HpK2IOlhFU=; b=X6MhSpH1oJCywytYaDY3tc6BCQmFuzHNUpPZSfGlyUy1OLF1B8iVNI1ka2Ct2AIo/u 1xxMAL2e468CrYDbJOQxu3yFmPLsbZO/IfaIqq2tINmb1ayIB1yZxeLWdX2+Ne+RliyM FZowJfLaDHVz+Ck7P3rdy6j0CoXFFkhQ3Z5yyFnvlOEYLV3ALrWyCn+muvSxaLLrIw0B s7ZXfC9GzAfHsaCvj7FI/+zt8FgyhKlkwMKIUfa7g2Np3rBQohqQVw3uoxRmvLuZ4Mlx 7E1ikNT6ahEFX4molmMcziHlyeteUiuJdNgYz8nuDCJvrEbGVL4XFRAzbdoV2D8dOkob tpRQ== X-Gm-Message-State: ABy/qLZ4ytNHjOlaxHNPWNq/ykNrNRO0YpCb7zg+ZKzfKBy5S5VG+9Jp VyZJ1OCIkxf9/f18hDoUH1k= X-Received: by 2002:a05:6870:5623:b0:1b3:738e:a341 with SMTP id m35-20020a056870562300b001b3738ea341mr11780347oao.46.1689597645617; Mon, 17 Jul 2023 05:40:45 -0700 (PDT) Received: from smeagol.fibertel.com.ar ([201.235.4.68]) by smtp.gmail.com with ESMTPSA id em30-20020a0568705b9e00b001b02a3426ddsm7032173oab.14.2023.07.17.05.40.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Jul 2023 05:40:45 -0700 (PDT) From: =?utf-8?q?Joaqu=C3=ADn_Ignacio_Aramend=C3=ADa?= To: linux@roeck-us.net Cc: =?utf-8?q?Joaqu=C3=ADn_Ignacio_Aramend=C3=ADa?= , linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org Subject: [PATCH 1/3] hwmon: (oxp-sensors) Move tt_toggle attribute to dev_groups Date: Mon, 17 Jul 2023 09:40:04 -0300 Message-ID: <20230717124013.38796-3-samsagax@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230717124013.38796-2-samsagax@gmail.com> References: <20230717124013.38796-2-samsagax@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771673604826637170 X-GMAIL-MSGID: 1771673604826637170 A driver should not be manually adding groups in its probe function (it will race with userspace), so replace the call to devm_device_add_groups() to use the platform dev_groups callback instead. This will allow for removal of the devm_device_add_groups() function. --- drivers/hwmon/oxp-sensors.c | 38 +++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/drivers/hwmon/oxp-sensors.c b/drivers/hwmon/oxp-sensors.c index e1a907cae820..1e1cc67bcdea 100644 --- a/drivers/hwmon/oxp-sensors.c +++ b/drivers/hwmon/oxp-sensors.c @@ -220,6 +220,20 @@ static int tt_toggle_disable(void) } /* Callbacks for turbo toggle attribute */ +static umode_t tt_toggle_is_visible(struct kobject *kobj, + struct attribute *attr, int n) +{ + switch (board) { + case aok_zoe_a1: + case oxp_mini_amd_a07: + case oxp_mini_amd_pro: + return attr->mode; + default: + break; + } + return 0; +} + static ssize_t tt_toggle_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) @@ -396,7 +410,15 @@ static struct attribute *oxp_ec_attrs[] = { NULL }; -ATTRIBUTE_GROUPS(oxp_ec); +static struct attribute_group oxp_ec_attribute_group = { + .is_visible = tt_toggle_is_visible, + .attrs = oxp_ec_attrs, +}; + +static const struct attribute_group *oxp_ec_groups[] = { + &oxp_ec_attribute_group, + NULL +}; static const struct hwmon_ops oxp_ec_hwmon_ops = { .is_visible = oxp_ec_hwmon_is_visible, @@ -415,7 +437,6 @@ static int oxp_platform_probe(struct platform_device *pdev) const struct dmi_system_id *dmi_entry; struct device *dev = &pdev->dev; struct device *hwdev; - int ret; /* * Have to check for AMD processor here because DMI strings are the @@ -430,18 +451,6 @@ static int oxp_platform_probe(struct platform_device *pdev) board = (enum oxp_board)(unsigned long)dmi_entry->driver_data; - switch (board) { - case aok_zoe_a1: - case oxp_mini_amd_a07: - case oxp_mini_amd_pro: - ret = devm_device_add_groups(dev, oxp_ec_groups); - if (ret) - return ret; - break; - default: - break; - } - hwdev = devm_hwmon_device_register_with_info(dev, "oxpec", NULL, &oxp_ec_chip_info, NULL); @@ -451,6 +460,7 @@ static int oxp_platform_probe(struct platform_device *pdev) static struct platform_driver oxp_platform_driver = { .driver = { .name = "oxp-platform", + .dev_groups = oxp_ec_groups, }, .probe = oxp_platform_probe, }; From patchwork Mon Jul 17 12:40:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Joaqu=C3=ADn_Ignacio_Aramend=C3=ADa?= X-Patchwork-Id: 121275 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1090755vqt; Mon, 17 Jul 2023 05:55:58 -0700 (PDT) X-Google-Smtp-Source: APBJJlG+Y7x0/7CgqtpnDZ0teMx2dW0GEiimOxnuzQkzatPeH6q3sP9U502yzW8bG+GrtUlDTk0O X-Received: by 2002:a05:6870:ac0c:b0:1aa:192e:9f35 with SMTP id kw12-20020a056870ac0c00b001aa192e9f35mr13735455oab.26.1689598558240; Mon, 17 Jul 2023 05:55:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689598558; cv=none; d=google.com; s=arc-20160816; b=eMMsNEXAXuyzXeuUJS6Mz177+n6jq7efuFjZ4CfkVHOHa0sMaBRdq6fW1ujimV6pZg R1JMmk1lW8erRHV6TOw6ZP+oY+GM7JkWzLID///WBNVeTDSMe+iC2P/kgMpuCFOKJMnU NVU/J7Q3faun9XJA+vhP+z4S3aGbn4fULzUFEZKvrzUZdFWJOKGPFTb4uwDkr4n/FUtO KpVUs7Jh7JF74979tDYHw6NZebA/qA3eiMOvKnkKuJ5kc5KpHACXUEglAR8CPh9FUI7B H8qA0pmECyyQW4mWuijuX/fl9Eqpp5uwc+p6nqBs088wu2PMAZ2+Gafk8SXKgMY8PBVY RO+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=NResrH/dwxJIXwvQtz2wBMlaGEhGmTQmAGoAye4iGiI=; fh=h793OaUni30alKFb4D+hGQdzb3dwmJ62PCcOI4idbnU=; b=dEsW5tRCsVdSVntmi5OX5badS7TGF8q/EMikrG7R5lu12P3Aay8ROTzx6A919olxoC SzbpT/14LpdSD7nYrY5nT7DBRIQMy4sm2pBtj27e6zfCa+yzNYXDKzfY2ouzlu1HptqH ttHtc+jHkdrCpvQyfp7r7clBn4GeTmH23Y80YUk2bYteutdYVoi9zblpp0ZPkvm481jf JgsoFrO4MLv9BPsV9cS0HdgXanrn8H2Gf/UhMBAkrxUWnK6KO0o2wolTrxEQQW23sw8I /OOQ/GquPmw5y1JubvnlIf8SnPVb4WOPyQ74moxbwhRX6jeNnv4wpAgRXvDJJPgySSnV wgHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=Nbd+0cMg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z66-20020a633345000000b0055ded4169a5si5976880pgz.576.2023.07.17.05.55.45; Mon, 17 Jul 2023 05:55:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=Nbd+0cMg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230443AbjGQMlU (ORCPT + 99 others); Mon, 17 Jul 2023 08:41:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55378 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231162AbjGQMkw (ORCPT ); Mon, 17 Jul 2023 08:40:52 -0400 Received: from mail-oa1-x30.google.com (mail-oa1-x30.google.com [IPv6:2001:4860:4864:20::30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8DEF6E56; Mon, 17 Jul 2023 05:40:50 -0700 (PDT) Received: by mail-oa1-x30.google.com with SMTP id 586e51a60fabf-1b06ea7e7beso3477792fac.0; Mon, 17 Jul 2023 05:40:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689597649; x=1692189649; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=NResrH/dwxJIXwvQtz2wBMlaGEhGmTQmAGoAye4iGiI=; b=Nbd+0cMgqaIZOZVN4VrsMWp34BzbhFFNwvhTlMuMffSsup3fWX8AV9ahT/1rQroW1I B3K60HBPRNne9Oqusn95f/yWJtpiDB+H3gzTnwMUmBIhe5voHUEmasN/PlXQcylCx5Xq usxV9PIFcu9cr0yH0X35ed0lNwxKBbBEvhNTfc61Hoj2MBXDeDrKk+nCmMSMvWOriNo4 XKA3CbVYTCY0/mxEBkRSKCkjlZ1H8Rtm8MOi2sak8gD7cuLHbPuGwtbomhs4iRvrEJ7W iXglIPogO0kT29aQrqgrWj+k/I1NhpIv3K9qgehqUKu+DvB7Nz80stXwejm3FGSoNYLP B/nA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689597649; x=1692189649; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NResrH/dwxJIXwvQtz2wBMlaGEhGmTQmAGoAye4iGiI=; b=Stm4WBNPlmxQ0+35cbI4RRGVM+/xmseCs9S2RNhdzFY2rPeoQoTNycx7IExrhjDL1X CRkhY9tyy7R5YEgpeJWedVbNJO15kZfsQF1ZQc5u18Yas+pS5FpuhCuP40ejbpf3JBWr ZjbKCgR5XVu/vILjr5WyZCM8rp5mxhu2WD/v7QDmIOcKPOnC/en3DKN1kOn9g/bHUW2C lvdGEi2MwigFZkcCZ9BdVNxp9BsEhMha9KIkRQFzAW/bnZIOfsV24wvGVJK1ll2RaWzV HGubB5y8nx05scR3js1G5IboxoV3g7kjq4HY62m/KsYnUQvhdnL+nOQ9B++pkuXCzl4g LqgA== X-Gm-Message-State: ABy/qLaTP/IxHKLCRHeUiZArjSTa2cBguiR54VFXpiBqSwgHpK+AMq8d qIXExoE/85Fks2BMxRnxZF0= X-Received: by 2002:a05:6871:b0c:b0:1b0:3433:7664 with SMTP id fq12-20020a0568710b0c00b001b034337664mr12647885oab.40.1689597649554; Mon, 17 Jul 2023 05:40:49 -0700 (PDT) Received: from smeagol.fibertel.com.ar ([201.235.4.68]) by smtp.gmail.com with ESMTPSA id em30-20020a0568705b9e00b001b02a3426ddsm7032173oab.14.2023.07.17.05.40.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Jul 2023 05:40:49 -0700 (PDT) From: =?utf-8?q?Joaqu=C3=ADn_Ignacio_Aramend=C3=ADa?= To: linux@roeck-us.net Cc: =?utf-8?q?Joaqu=C3=ADn_Ignacio_Aramend=C3=ADa?= , linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org Subject: [PATCH 2/3] hwmon: (oxp-sensors) Move board detection to the init function Date: Mon, 17 Jul 2023 09:40:05 -0300 Message-ID: <20230717124013.38796-4-samsagax@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230717124013.38796-2-samsagax@gmail.com> References: <20230717124013.38796-2-samsagax@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771672497250593466 X-GMAIL-MSGID: 1771672497250593466 This driver is not hotpluggable by nature so it makes more sense to detect the board on init() instead of on probe(). Move detection logic to the start of init() function so we won't instantiate the driver if the board is not compatible. --- drivers/hwmon/oxp-sensors.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/drivers/hwmon/oxp-sensors.c b/drivers/hwmon/oxp-sensors.c index 1e1cc67bcdea..c70d9355eeba 100644 --- a/drivers/hwmon/oxp-sensors.c +++ b/drivers/hwmon/oxp-sensors.c @@ -438,19 +438,6 @@ static int oxp_platform_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; struct device *hwdev; - /* - * Have to check for AMD processor here because DMI strings are the - * same between Intel and AMD boards, the only way to tell them apart - * is the CPU. - * Intel boards seem to have different EC registers and values to - * read/write. - */ - dmi_entry = dmi_first_match(dmi_table); - if (!dmi_entry || boot_cpu_data.x86_vendor != X86_VENDOR_AMD) - return -ENODEV; - - board = (enum oxp_board)(unsigned long)dmi_entry->driver_data; - hwdev = devm_hwmon_device_register_with_info(dev, "oxpec", NULL, &oxp_ec_chip_info, NULL); @@ -469,6 +456,21 @@ static struct platform_device *oxp_platform_device; static int __init oxp_platform_init(void) { + const struct dmi_system_id *dmi_entry; + + /* + * Have to check for AMD processor here because DMI strings are the + * same between Intel and AMD boards, the only way to tell them apart + * is the CPU. + * Intel boards seem to have different EC registers and values to + * read/write. + */ + dmi_entry = dmi_first_match(dmi_table); + if (!dmi_entry || boot_cpu_data.x86_vendor != X86_VENDOR_AMD) + return -ENODEV; + + board = (enum oxp_board)(unsigned long)dmi_entry->driver_data; + oxp_platform_device = platform_create_bundle(&oxp_platform_driver, oxp_platform_probe, NULL, 0, NULL, 0); From patchwork Mon Jul 17 12:40:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Joaqu=C3=ADn_Ignacio_Aramend=C3=ADa?= X-Patchwork-Id: 121351 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1139488vqt; Mon, 17 Jul 2023 07:15:28 -0700 (PDT) X-Google-Smtp-Source: APBJJlFA8IOW+sDXdRcz+wKU4bABv2yuBPUVjnIn80smxC8KEXv1PVmRJflZqsd3D11UAi/zZnfr X-Received: by 2002:a05:6e02:1aa5:b0:348:7177:5a8c with SMTP id l5-20020a056e021aa500b0034871775a8cmr9224227ilv.20.1689603328489; Mon, 17 Jul 2023 07:15:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689603328; cv=none; d=google.com; s=arc-20160816; b=HxNvb5rMohymLXLU/QtfrEO+NI+EFY5BrL/2vp7NufAlrE0ZLun/Dp+JL0FHTMwL79 QaQZDHORkPmgC41mC1H19kKkYXm5WnJ1NdAMmnXEFx5XDiZSVKcP6o8yfx2PO8VRbEZQ 6bGeJ7NuBRgrBPN80oqQMvE8tBzpHm4DCVt1CMLd84tlgacMBccbDqV+EnK1sJxF4JaC yF8Rdpp4LdmBLFUapMXFeNhmu3saIsvwL+Im128rM1j7qBHI+cyJSsVfR/XDx1CFaTru JyhF0qeAEZ2KQnknDDN4/4hh1V+n/mejySRPZJa939eFjLjDU5fjCmpzBJChDAUF/a50 6dYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=1245q7RdkHHn0geBQ7otTdkqOOaXep5soyGm2gOl4DI=; fh=h793OaUni30alKFb4D+hGQdzb3dwmJ62PCcOI4idbnU=; b=I82jcmgHHDehr88zwipzDMvhI2+1ca4ajNtan1G7S70C2/cJI9nGRGnxAiHIrbQ9e0 It0XU3wF4/bt+5husnxn1WwawGhliRwwA3mE5NibOUTaUVSwEOCUj8sFeaul+X1YByL4 mzax4bgn1Bqg9GDy6zr3vpC9hLrlYAQIT9VMhKfmRVppiTfpzWw4diuBeu6bTNjlw7JM KGh3PgBcMWPIdQED5yrqhHdAUwZgqDTU1RFKKsQvk1rYXWkgAovXi0SXAJSu3NgjZEap fg8mvt8eLZF2X9R9wBB6w3G1jcLa4qkj+dSakQRUdMTcAsd08xY7UwUvQ8AfgvecepoX Jjsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=HDshjTlg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n11-20020a17090ade8b00b00263b4a986cfsi5783318pjv.73.2023.07.17.07.15.14; Mon, 17 Jul 2023 07:15:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=HDshjTlg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231153AbjGQMlW (ORCPT + 99 others); Mon, 17 Jul 2023 08:41:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55382 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231261AbjGQMky (ORCPT ); Mon, 17 Jul 2023 08:40:54 -0400 Received: from mail-oa1-x2a.google.com (mail-oa1-x2a.google.com [IPv6:2001:4860:4864:20::2a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6DA1010D7; Mon, 17 Jul 2023 05:40:53 -0700 (PDT) Received: by mail-oa1-x2a.google.com with SMTP id 586e51a60fabf-1b38121a011so3336631fac.2; Mon, 17 Jul 2023 05:40:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689597652; x=1692189652; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1245q7RdkHHn0geBQ7otTdkqOOaXep5soyGm2gOl4DI=; b=HDshjTlgf6EKSidSjTNxj8gmqnCRUllPK4Z2XU4oL2qj6/CRoomQcBVNBvkvlkIDA1 7wiox/XvvUXb81+Sgijbi4ElgTbLvIwDZ1TcLGDSMrCAdlBkjPOfl/HD8G3mFy02ggzw 4hKScY0ARpfhAC/i8U+y8FZzZNjKox+wydJGKPGadaw86uHsVMegNlWvX6b67IsoVq+o l529n/WslD++ATVi24LRdcz1J0W2pbq7ENv1vcu3PBZY4263FFu+kzQtcb5ruvveFOVJ B5ko0N6Q3rOdj6LzwERMEYIhGCHILHufi6rsUVstVibVcX1ly9WsNZJODzeEo+JCt+kd p2MA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689597652; x=1692189652; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1245q7RdkHHn0geBQ7otTdkqOOaXep5soyGm2gOl4DI=; b=RO0o+1RyneFkTKj/REd/P4T+dvUdqueFCVhFrANJnDyLWnFiJyzU38XVvjzplkxdcj wzlghutufzh2IT97RgcNmm8JKWOvkJ3TiKz7LBSWA5adcVuTLSwCBOBVGTJ//+I5F2uV K+hY705sB3p33lAWGFGSwtUjyIMghgzlZ2BT9Px678OI+LUNWjyI4e1t0HlHa/QMH0nR 8k/rqKncvP+WrjrL71N+WN9O4IaI/z9RiAMCIrQejMrMe6nSmQwyTlqXb5Rbb8jUUbKT cJai/nr4RGFuMegtaGJkGYsvrYHv2DV1RvqR353v72+G2FTYdlYLHVBTrQaON3wlIdSn +aNQ== X-Gm-Message-State: ABy/qLacq60gaawlVe4zoQ7dQ2UGWuAU24uQ0kt1WcgY7f6v/QkHMCnb RHRmBxZbLKxo+i3wnU8/VZo= X-Received: by 2002:a05:6870:ac07:b0:1b0:7eac:70ae with SMTP id kw7-20020a056870ac0700b001b07eac70aemr12561509oab.33.1689597652728; Mon, 17 Jul 2023 05:40:52 -0700 (PDT) Received: from smeagol.fibertel.com.ar ([201.235.4.68]) by smtp.gmail.com with ESMTPSA id em30-20020a0568705b9e00b001b02a3426ddsm7032173oab.14.2023.07.17.05.40.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Jul 2023 05:40:52 -0700 (PDT) From: =?utf-8?q?Joaqu=C3=ADn_Ignacio_Aramend=C3=ADa?= To: linux@roeck-us.net Cc: =?utf-8?q?Joaqu=C3=ADn_Ignacio_Aramend=C3=ADa?= , linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org Subject: [PATCH 3/3] hwmon: (oxp-sensors) Refactor init() and remove probe() Date: Mon, 17 Jul 2023 09:40:06 -0300 Message-ID: <20230717124013.38796-5-samsagax@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230717124013.38796-2-samsagax@gmail.com> References: <20230717124013.38796-2-samsagax@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771677499309810688 X-GMAIL-MSGID: 1771677499309810688 Since the driver is not hotpluggable the probe() funtion is not used more than once. Move all attribute registration logic to the init() function. --- drivers/hwmon/oxp-sensors.c | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/drivers/hwmon/oxp-sensors.c b/drivers/hwmon/oxp-sensors.c index c70d9355eeba..39de49c8a392 100644 --- a/drivers/hwmon/oxp-sensors.c +++ b/drivers/hwmon/oxp-sensors.c @@ -431,32 +431,20 @@ static const struct hwmon_chip_info oxp_ec_chip_info = { .info = oxp_platform_sensors, }; -/* Initialization logic */ -static int oxp_platform_probe(struct platform_device *pdev) -{ - const struct dmi_system_id *dmi_entry; - struct device *dev = &pdev->dev; - struct device *hwdev; - - hwdev = devm_hwmon_device_register_with_info(dev, "oxpec", NULL, - &oxp_ec_chip_info, NULL); - - return PTR_ERR_OR_ZERO(hwdev); -} - static struct platform_driver oxp_platform_driver = { .driver = { .name = "oxp-platform", .dev_groups = oxp_ec_groups, }, - .probe = oxp_platform_probe, }; static struct platform_device *oxp_platform_device; +/* Initialization logic */ static int __init oxp_platform_init(void) { const struct dmi_system_id *dmi_entry; + struct device *hwdev; /* * Have to check for AMD processor here because DMI strings are the @@ -472,10 +460,21 @@ static int __init oxp_platform_init(void) board = (enum oxp_board)(unsigned long)dmi_entry->driver_data; oxp_platform_device = - platform_create_bundle(&oxp_platform_driver, - oxp_platform_probe, NULL, 0, NULL, 0); + platform_create_bundle(&oxp_platform_driver, NULL, NULL, 0, + NULL, 0); + if (IS_ERR(oxp_platform_device)) + return PTR_ERR(oxp_platform_device); - return PTR_ERR_OR_ZERO(oxp_platform_device); + hwdev = devm_hwmon_device_register_with_info(&oxp_platform_device->dev, + "oxpec", NULL, + &oxp_ec_chip_info, NULL); + if (IS_ERR(hwdev)) { + platform_device_unregister(oxp_platform_device); + platform_driver_unregister(&oxp_platform_driver); + return PTR_ERR(hwdev); + } + + return 0; } static void __exit oxp_platform_exit(void)