Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp1205754rdh; Fri, 27 Oct 2023 07:36:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH9AhjIFvCXjciAAO6UBeJWz8FKTMl4iGFQxJbstwNcH/PiFNV9RvYVnj7+K9ir/y7ag6Ql X-Received: by 2002:a81:e20c:0:b0:59b:5d6b:5110 with SMTP id p12-20020a81e20c000000b0059b5d6b5110mr3159591ywl.21.1698417391259; Fri, 27 Oct 2023 07:36:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698417391; cv=none; d=google.com; s=arc-20160816; b=DMK/vJ4x9tvlVlQGzk2wLepBy6BKgT3qHw8T74uDucM1pnzb3zkpb8XORn2MxxCrJD JZxOjZmWy3QTkcC1sURGlK9Ow/Wwc6RLNrR1ibWAZ3Ro0oywoewDDXvSn8R+6UVS6/Ov Izk0gS3eSt7Fh2uXYIy2ETWAn0BYKdsi+lbKUQO0ZSOO8jyPSQfpLxQxhz6kkUkx6rzv GBYtvvCsM2B0pHQspyU5xjQn7TocWt94FE0gyg89QdjvRQNQiKSLLWQ9dSaW4teEr44m V6URzRNIRzWmDYI51d3YFFTQaVzGYDLSEFCP1ezk5PBWtHjURBhnm2s+M5W9wyksRZug tyBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=5264VXvxOPpkHHZcdf1TcQk8KkAmttgEQOun6seB2MQ=; fh=+RY31rx+TuoUAw6X/AukJ92USaJukncsQC4RlnBSqB0=; b=igsLCUxT7zw9RxbBNhbajEV6uMspmFleYFkIpdJLSYDIsXwVobegpJQPSbbVwAYXeO S9sgqS1rnSE+ivEwYOKLeRpc4q1+bvFZHA0YNFxj0JM68LowQf4l9Jb3RP5lcTOcIyf6 TDWEHvZ39ArB7iCR+34YtQ+/y3xd5LjDz/x3cE9A+6lVcIUm6RRVzKyqfffSwNETEpd6 Xc1KOlS6z9YGkX3qsNLayexJZokDPt2aMECLd0dpqqc7/AHYaiOJf/Aamwm16rJexzIB cVQy4bGzvS55PpP6sV0fHHEIfYhcXVCwiawQc7CyObhSAxbFBGfQK+ny0p3I0MAqK+rC fCDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=U2RZ8Ske; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id r206-20020a819ad7000000b005afd42d792dsi1757357ywg.513.2023.10.27.07.36.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Oct 2023 07:36:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=U2RZ8Ske; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (Postfix) with ESMTP id 3D4748348D8D; Fri, 27 Oct 2023 07:36:25 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346106AbjJ0Ofw (ORCPT + 99 others); Fri, 27 Oct 2023 10:35:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44592 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346136AbjJ0Ofu (ORCPT ); Fri, 27 Oct 2023 10:35:50 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D05801B3; Fri, 27 Oct 2023 07:35:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1698417348; x=1729953348; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=fH8jf7Ty5A/dlTOoUqTjFRJ6N8Oq7tW+7xDYH8Bdocg=; b=U2RZ8Skep3/EDTDaM/5/jWxhjkwHB9qTz3F55qSlK32ApUNsiWr63olH 7CSeT6fahBwwxjGzfg8vmOUjeYoYxbhSMZ1LGHPXXLXKBiUEtecPkZj1u /KZT8Pzc/oUX8542cRqkeMltHzoHsgLqq5AQWDgjhjGCTHPoST1nFWGkQ wOEDBIkJB9mFRjQD4FA2j4yyWtPBTVPY7m/CZjLaqfc0um+6UsMg8UiSD 0Es+UeTzRr18CtoZQALbAZs0WCB4QZiAEq+D4AAn72uxNWKOTIk4/R/UQ Ebf1cTJQn0XulF065ZbBSyyGzB38BpyBQqhzlkbvL5SBs7gMAQMatPFsf Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10876"; a="367127575" X-IronPort-AV: E=Sophos;i="6.03,256,1694761200"; d="scan'208";a="367127575" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Oct 2023 07:35:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10876"; a="709428757" X-IronPort-AV: E=Sophos;i="6.03,256,1694761200"; d="scan'208";a="709428757" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga003.jf.intel.com with ESMTP; 27 Oct 2023 07:35:42 -0700 Received: by black.fi.intel.com (Postfix, from userid 1001) id 72E65263; Fri, 27 Oct 2023 17:28:56 +0300 (EEST) Date: Fri, 27 Oct 2023 17:28:56 +0300 From: Mika Westerberg To: Raag Jadav Cc: rafael@kernel.org, len.brown@intel.com, andriy.shevchenko@linux.intel.com, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, mallikarjunappa.sangannavar@intel.com, bala.senthil@intel.com Subject: Re: [PATCH v2] ACPI: LPSS: use acpi_dev_uid_match() for matching _UID Message-ID: <20231027142856.GL3208943@black.fi.intel.com> References: <20231026083335.12551-1-raag.jadav@intel.com> <20231027081855.GK3208943@black.fi.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.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 (howler.vger.email [0.0.0.0]); Fri, 27 Oct 2023 07:36:25 -0700 (PDT) On Fri, Oct 27, 2023 at 05:17:12PM +0300, Raag Jadav wrote: > On Fri, Oct 27, 2023 at 01:12:02PM +0300, Raag Jadav wrote: > > On Fri, Oct 27, 2023 at 11:18:55AM +0300, Mika Westerberg wrote: > > > On Thu, Oct 26, 2023 at 02:03:35PM +0530, Raag Jadav wrote: > > > > Now that we have a standard ACPI helper, we can use acpi_dev_uid_match() > > > > for matching _UID as per the original logic before commit 2a036e489eb1 > > > > ("ACPI: LPSS: Refactor _UID handling to use acpi_dev_uid_to_integer()"), > > > > instead of treating it as an integer. > > > > > > > > Signed-off-by: Raag Jadav > > > > Acked-by: Mika Westerberg > > > > > > The change still looks good to me, however I wonder if we could maybe > > > improve acpi_dev_uid_match() to support both data types possible for > > > _UID? This of course is separate patch (unless there are objections). > > > > > > There is the _Generic() thing and I think that can be used to make > > > > > > acpi_dev_uid_match() > > > > > > which takes either u64 (or maybe even unsigned int) or const char * and > > > based on that picks the correct implementation. Not sure if that's > > > possible, did not check but it would allow us to use one function > > > everywhere instead of acpi_dev_uid_to_integer() and > > > acpi_dev_uid_match(). > > > > The way I see it, acpi_dev_uid_to_integer() is useful when drivers want to > > parse _UID and store it in their private data, so that it is available for > > making various decisions throughout the lifetime of the driver, as opposed > > to acpi_dev_uid_match() which is more useful for oneshot comparisons in my > > opinion. > > > > So I'm a bit conflicted about merging them into a single helper, unless > > ofcourse there is a way to serve both purposes. > > Or perhaps something like, > > bool acpi_dev_uid_match(struct acpi_device *adev, const void *uid2, enum uid_type type) > { > u64 uid1_d, uid2_d; > > if (type == UID_TYPE_STR) { > char *uid2_s = (char *)uid2; > if (!(uid2_s && !kstrtou64(uid2_s, 0, &uid2_d))) > return false; > } else if (type == UID_TYPE_INT) { > u64 *uid2_p; > uid2_p = (u64 *)uid2; > uid2_d = *uid2_p; > } else { > return false; > } > > if (!acpi_dev_uid_to_integer(adev, &uid1_d) && uid1_d == uid2_d) > return true; > else > return false; > } > > Although this looks unnecessarily hideous. Indeed, but using the _Generic() you should be able to have a single acpi_dev_uid_match() to work for either type so: acpi_dev_uid_match(adev, "1") and acpi_dev_uid_match(adev, 1) would both work with type checkings etc. Not sure if this is worth the trouble though.