[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <ZT_TENjSBRpwMw90@black.fi.intel.com>
Date: Mon, 30 Oct 2023 18:00:16 +0200
From: Raag Jadav <raag.jadav@...el.com>
To: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Cc: "Rafael J. Wysocki" <rafael@...nel.org>,
Mika Westerberg <mika.westerberg@...ux.intel.com>,
len.brown@...el.com, linux-acpi@...r.kernel.org,
linux-kernel@...r.kernel.org,
mallikarjunappa.sangannavar@...el.com, bala.senthil@...el.com
Subject: Re: [PATCH v2] ACPI: LPSS: use acpi_dev_uid_match() for matching _UID
On Mon, Oct 30, 2023 at 12:12:27PM +0200, Andy Shevchenko wrote:
> 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.
My initial thought was to have separate functions per type, but then
I realized it would become an unnecessary inconvenience to maintain
one per type. Having it inline with _Generic would make it relatively
easier, but I'll leave it to the maintainers to decide.
> P.S.
> All to me it seems way too overengineered w/o any potential prospective user.
I found a couple of acpi_dev_uid_to_integer() usages which could be
simplified with this implementation, but let's see how everyone feels
about this.
Thanks for the comments,
Raag
Powered by blists - more mailing lists