Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp6142833rwp; Mon, 17 Jul 2023 16:01:33 -0700 (PDT) X-Google-Smtp-Source: APBJJlF6VTpb7Aeo4h93sVvGpa2q0Rm/g4z5GEWq+jx/C+AMIV6eGAaIj2OIJhx9U2oYyy54EH8z X-Received: by 2002:a17:907:16a5:b0:98e:48cc:4cbf with SMTP id hc37-20020a17090716a500b0098e48cc4cbfmr12741139ejc.26.1689634893090; Mon, 17 Jul 2023 16:01:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689634893; cv=none; d=google.com; s=arc-20160816; b=yU3lPvuE4WBgJ++O9tAdYiJ+GQTsiiUa6NE+XogHXEKTKTuT8vPvgD8r/GDWCug3dH Xoq/AmqH51VK59NjGxgt0MOSztlOTISj4HSPiLl8lk3KufNJhQQRoms6uSF2sl+yLspj LyITn3UpdGtI641voqFMqwEw9MNxULe87ZXnOltZgh8m3+S5myqKpacaBlX9oR3AhH0o bLI4Us1T4wJoH/eC6egnf6Pildb8HBuWDwORDjS8qvMdEOVJzFELW+dhEKTUPje+Wxak yCrgtBtJ8ViJffxMHD9pFl+VEG+v1shy48SH+pPhP8z+21jzGm0h5YQ9QiEiBZIO8EVW CPQQ== 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=0ZFSpPeABBzG5XwaWyUoAc/E/gXj2NoOgUk68JvYyRY=; fh=h793OaUni30alKFb4D+hGQdzb3dwmJ62PCcOI4idbnU=; b=Lu4FOjznSGyaCPoJW6TyXwmlbI/yfV/XTB+5NscQXsK5pkBbgVkVpOI03wJMa9etAA 6TPsfdyU/5rk0ccraiqPdFAvvW70ZFl8SsBVmoYW/UwdnZwYY5+Cx7S0nw+yXUbv4TsN /qiqGw6X4qMSnkkluOBPGmF8UGmxN36TnAhfct1Nnh9tc4O2L9ew9/gIYj1USv1NqVVI uFM9p0t1ZWYhxBFKmZA1KnjxP9psn7VH9HkLfQbgl7WBEzsUu49wKYM+OlxBiHrVBiXs TW54PMqAIkBXQkL3VUtnWTjy/ONXlThM9Lm7EaSMy0/+JuZfmpkUeUyN8WWeKfdRkAIE IBvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=WP6VAqBt; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z19-20020a170906945300b0098df1cbe2b1si251005ejx.925.2023.07.17.16.01.08; Mon, 17 Jul 2023 16:01:33 -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=WP6VAqBt; 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 S230338AbjGQWZt (ORCPT + 99 others); Mon, 17 Jul 2023 18:25:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230313AbjGQWZs (ORCPT ); Mon, 17 Jul 2023 18:25:48 -0400 Received: from mail-ot1-x333.google.com (mail-ot1-x333.google.com [IPv6:2607:f8b0:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2592B1; Mon, 17 Jul 2023 15:25:43 -0700 (PDT) Received: by mail-ot1-x333.google.com with SMTP id 46e09a7af769-6b9defb366eso578262a34.2; Mon, 17 Jul 2023 15:25:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689632743; x=1692224743; 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=0ZFSpPeABBzG5XwaWyUoAc/E/gXj2NoOgUk68JvYyRY=; b=WP6VAqBtcBpW6Hrw19ysTmnUuDGdUskCQXcX2Qz1ytlSCUFXustKh+YQhs5ydL6Rju 002hnHCV039FxxmavVVUosZ+fwVk+Fg2z/3ys8FRkdmkFJN20xuaO8MzUDLO+vE9lTZD e0jCvKGeweqlABLKO2GzHnk2RkoBZtVbCnpYDJ2VC2MQF2y9r15lCdVoIG5dAOECktNz MZqtfArNw+NE0tenCexfRL5aUDdoUsakEH/olq/Up7xx0DXpNp5dTgA01VITUfHagnHy a80FAp8gVRO3OF2G6qh8b+Tjsrn2ID+3nuiCZ9GuUblrEyoui49LMLKVhTrky+QwZ+SC UNSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689632743; x=1692224743; 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=0ZFSpPeABBzG5XwaWyUoAc/E/gXj2NoOgUk68JvYyRY=; b=U5VWleMYCl+L0+saaDTJ1zzsBIN32Vd6+JCQUklpjb0OWrrqpchviWb0MTQo++Bnaz hOmM7bI4mTR4XMipm7zrjqDT/E81c/25FTd1aFCXBSmKtdhhRosYbjDPzip4h0njjutc ml4oV5MUKz4/jxJLexIWpk6/uVrQ1Vx/VY6E6wX0diXRkip9Dz7pT1PUFZw7NHfjFuq0 3/2g45QbkyihirqGFU1brGFvyfQkSwmwqE52/b2uwTobSiwkQaXhm1QY6yg13GR+pKUN aW5/i7lNPMRvzyK2t+B1TDsEXU51sL2xu1ru0ubzPeKHudRMa2Vc1wuxVgaUcOiRCx8S ep1g== X-Gm-Message-State: ABy/qLa5BeWyprFuuwhllx4sTHDGMVoXoZnb/LWxVziYtaQjM0e02+g/ AqGt7Lr9L75YLHKXOMOXkVhZaJ2kAgk= X-Received: by 2002:a05:6870:c8aa:b0:1ad:2e18:7090 with SMTP id er42-20020a056870c8aa00b001ad2e187090mr13026815oab.32.1689632743205; Mon, 17 Jul 2023 15:25:43 -0700 (PDT) Received: from smeagol.fibertel.com.ar ([201.235.4.68]) by smtp.gmail.com with ESMTPSA id a7-20020a056870374700b001ba72480f2fsm385553oak.43.2023.07.17.15.25.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Jul 2023 15:25:42 -0700 (PDT) From: =?UTF-8?q?Joaqu=C3=ADn=20Ignacio=20Aramend=C3=ADa?= To: linux@roeck-us.net Cc: =?UTF-8?q?Joaqu=C3=ADn=20Ignacio=20Aramend=C3=ADa?= , linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org Subject: [PATCH v2 2/2] hwmon: (oxp-sensors) Move board detection to the init function Date: Mon, 17 Jul 2023 19:25:16 -0300 Message-ID: <20230717222526.229984-3-samsagax@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230717222526.229984-1-samsagax@gmail.com> References: <20230717222526.229984-1-samsagax@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Move detection logic to the start of init() function so we won't instantiate the driver if the board is not compatible. Signed-off-by: Joaquín Ignacio Aramendía --- drivers/hwmon/oxp-sensors.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/drivers/hwmon/oxp-sensors.c b/drivers/hwmon/oxp-sensors.c index 1e1cc67bcdea..ea9602063eab 100644 --- a/drivers/hwmon/oxp-sensors.c +++ b/drivers/hwmon/oxp-sensors.c @@ -434,23 +434,9 @@ static const struct hwmon_chip_info oxp_ec_chip_info = { /* 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; - /* - * 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 +455,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); -- 2.41.0