From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Raag Jadav <raag.jadav@intel.com>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>,
Mika Westerberg <mika.westerberg@linux.intel.com>,
len.brown@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
Date: Mon, 30 Oct 2023 12:12:27 +0200 [thread overview]
Message-ID: <ZT+BiykmKepdAA8K@smile.fi.intel.com> (raw)
In-Reply-To: <ZTzNBAPe0ToFUqIw@black.fi.intel.com>
On Sat, Oct 28, 2023 at 11:58:12AM +0300, Raag Jadav wrote:
> On Fri, Oct 27, 2023 at 07:40:38PM +0200, Rafael J. Wysocki wrote:
...
> We'd probably end up with an oops trying to strcmp into a random address
> without knowing its type, so I think Mika's would be a better approach.
>
> #define acpi_dev_uid_match(adev, uid2) \
> ({ \
> const char *uid1 = acpi_device_uid(adev); \
> u64 __uid1; \
> \
> _Generic(uid2, \
> int: uid1 && !kstrtou64(uid1, 0, &__uid1) && (typeof(uid2))__uid1 == uid2, \
> const char *: uid1 && uid2 && !strcmp(uid1, (const char *)uid2), \
> default: false); \
> \
> })
>
> This one I atleast got to compile, but I'm not very well versed with _Generic,
> so this could definitely use some comments.
If you go this way, make _Generic() use simple in the macro with a help of two
additional functions (per type). Also you need to take care about uid2 type to
be _any_ unsigned integer. Or if you want to complicate things, then you need
to distinguish signed and unsigned cases.
P.S.
All to me it seems way too overengineered w/o any potential prospective user.
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2023-10-30 10:12 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-26 8:33 [PATCH v2] ACPI: LPSS: use acpi_dev_uid_match() for matching _UID Raag Jadav
2023-10-27 8:18 ` Mika Westerberg
2023-10-27 10:11 ` Raag Jadav
2023-10-27 14:17 ` Raag Jadav
2023-10-27 14:28 ` Mika Westerberg
2023-10-27 16:51 ` Raag Jadav
2023-10-27 17:19 ` Rafael J. Wysocki
2023-10-27 17:40 ` Rafael J. Wysocki
2023-10-28 8:58 ` Raag Jadav
2023-10-30 10:12 ` Andy Shevchenko [this message]
2023-10-30 16:00 ` Raag Jadav
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZT+BiykmKepdAA8K@smile.fi.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=bala.senthil@intel.com \
--cc=len.brown@intel.com \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mallikarjunappa.sangannavar@intel.com \
--cc=mika.westerberg@linux.intel.com \
--cc=raag.jadav@intel.com \
--cc=rafael@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.