From patchwork Tue Oct 10 13:39:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 150790 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp209468vqb; Tue, 10 Oct 2023 06:42:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEDAuCaICNNIFeFAvjipMA9UfwCkGftkdgLzRpZZImwfGnzyJbWKKV0cmA23rUDueIkA/F+ X-Received: by 2002:a05:6a20:3c8b:b0:12c:b10d:693d with SMTP id b11-20020a056a203c8b00b0012cb10d693dmr18700227pzj.6.1696945373876; Tue, 10 Oct 2023 06:42:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696945373; cv=none; d=google.com; s=arc-20160816; b=Dg29sWllARlxI8lTtgPe2h+7PCBWOATsw7vE/ojP7ci0j1V0p8EuVEoLh57ov0KaSc zX69LxGV3TocNj67CFt5IMerTWuOM3g595z8YUqfsP0IOlSPnsYT0AD3uKKuUNcIy64P 18etEsXM27HhBqFLuKziAKKBNvJeNlOvMDA8/WYdTvM8A1ojhlZFfOQMYhDFl/DOoPWj YjO3tj+hCXREmZ8jFYDDQvfS9euoYto/32jZHRcA9VncNKKhceYzi/Guf2ayBSiYYm+S eWch6wo3ouQrJRhErjITi7w/MFcYA7jLNMIguYlRqox+Tx9VEPZPBjAWZzWwSItjH34U miaw== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=B6q3yCZxRjPeu5UBXWqb8gnANFSS6mZJHadFa8P0zUM=; fh=VQbRgMbEHbytg6bzwKsctoq9phP0vcfNS8axRc0TDN8=; b=NKj947xY3JPAITA3/w/AKhnoSHq8lblQ78PDeLzZlH8RgS72TcCqneZ9rbwYR9m1PL ss5cxYGFPuX+CXu9rzAODlWedMryNK8W+5R1zUkPugfAKWN4oFsoFJH3wgKmw6stXUJm np9CqK2iZ5fJZM7jDfJWSF4mLMsWy10AZt5sAB5z1uvsca8ATZv/p1KDCy7sDrHPg81B FVWiRvkow9ukI4RnTFnmqSmlj8TgfJMb4KfxIFrkYzh0VBRuLlRM9DsuWQo3/svEI2Nr WxV5AyOSzZGJeFr0eIMkK5mKDt11tYMFGdQtMnKUd5cW+vdYFWd/1z3M/X4K+gGPvkma a4FA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=P+lyTVQg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id be3-20020a656e43000000b0058555ea0a21si3283492pgb.571.2023.10.10.06.42.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Oct 2023 06:42:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=P+lyTVQg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id A7A9180736AE; Tue, 10 Oct 2023 06:42:51 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232511AbjJJNmN (ORCPT + 20 others); Tue, 10 Oct 2023 09:42:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232865AbjJJNk5 (ORCPT ); Tue, 10 Oct 2023 09:40:57 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 696AC10D1; Tue, 10 Oct 2023 06:39:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1696945184; x=1728481184; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=bweTMAw7Mh9T1bx7i565yAzoKLSObi9KIivLe8urTtA=; b=P+lyTVQgJ6n4xBnqupgrCp7tbHoHt9I31I6kL2v+7OufKh4gqcTWXAnm wXxetYz7iiA4ujkH58bF/KQi7vTDd4AXZXHk6a8Rgyh2rhIiShswHgOOR whU9mEDD2jgWO9HAXQd18zHr6pCGljcX9QRVlmijWCTLOtSyG6w0MfH52 lwiCfT4yxXpLG5g1HOrxjYPezNq9nJMvtCPxnLO5PgIluvuqWwjwf3sTe dWmOeMNiqtv5ucfIbJCwc2FIPeZBWaj0OR4ycO5qn1tY0H5/p0vBheHyc I//SA+phSIWswcGmDAbLhcPEKMRGHkLR9RneaPNHpAmyW9uRkLoBzxm7Z w==; X-IronPort-AV: E=McAfee;i="6600,9927,10859"; a="415410035" X-IronPort-AV: E=Sophos;i="6.03,212,1694761200"; d="scan'208";a="415410035" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Oct 2023 06:39:43 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10859"; a="1000701667" X-IronPort-AV: E=Sophos;i="6.03,212,1694761200"; d="scan'208";a="1000701667" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga006.fm.intel.com with ESMTP; 10 Oct 2023 06:39:42 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id B3ED735A; Tue, 10 Oct 2023 16:39:40 +0300 (EEST) From: Andy Shevchenko To: Hans de Goede , Andy Shevchenko , platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org Cc: =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Mark Gross Subject: [PATCH v4 1/1] platform/x86: xo15-ebook: Replace open coded acpi_match_acpi_device() Date: Tue, 10 Oct 2023 16:39:36 +0300 Message-Id: <20231010133936.3891996-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b MIME-Version: 1.0 X-Spam-Status: No, score=2.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Tue, 10 Oct 2023 06:42:51 -0700 (PDT) X-Spam-Level: ** X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779376192266083635 X-GMAIL-MSGID: 1779376192266083635 Replace open coded acpi_match_acpi_device() in ebook_switch_add(). Note, while it is a bit longer it is more robust in case more IDs will be added. Reviewed-by: Hans de Goede Signed-off-by: Andy Shevchenko --- v4: updated subject (Ilpo) v3: used proper API, added tag (Hans) v2: fixed compilation error drivers/platform/x86/xo15-ebook.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/platform/x86/xo15-ebook.c b/drivers/platform/x86/xo15-ebook.c index 391f7ea4431e..df2bf1c58523 100644 --- a/drivers/platform/x86/xo15-ebook.c +++ b/drivers/platform/x86/xo15-ebook.c @@ -81,9 +81,9 @@ static SIMPLE_DEV_PM_OPS(ebook_switch_pm, NULL, ebook_switch_resume); static int ebook_switch_add(struct acpi_device *device) { + const struct acpi_device_id *id; struct ebook_switch *button; struct input_dev *input; - const char *hid = acpi_device_hid(device); char *name, *class; int error; @@ -102,8 +102,9 @@ static int ebook_switch_add(struct acpi_device *device) name = acpi_device_name(device); class = acpi_device_class(device); - if (strcmp(hid, XO15_EBOOK_HID)) { - pr_err("Unsupported hid [%s]\n", hid); + id = acpi_match_acpi_device(ebook_device_ids, device); + if (!id) { + dev_err(&device->dev, "Unsupported hid\n"); error = -ENODEV; goto err_free_input; } @@ -111,7 +112,7 @@ static int ebook_switch_add(struct acpi_device *device) strcpy(name, XO15_EBOOK_DEVICE_NAME); sprintf(class, "%s/%s", XO15_EBOOK_CLASS, XO15_EBOOK_SUBCLASS); - snprintf(button->phys, sizeof(button->phys), "%s/button/input0", hid); + snprintf(button->phys, sizeof(button->phys), "%s/button/input0", id->id); input->name = name; input->phys = button->phys;