From: Andy Shevchenko <andy.shevchenko@gmail.com>
To: Hans de Goede <hdegoede@redhat.com>
Cc: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
platform-driver-x86@vger.kernel.org
Subject: Re: [PATCH 4/5] platform/x86: x86-android-tablets: Add support for getting serdev-controller by PCI parent
Date: Mon, 11 Nov 2024 11:37:24 +0200 [thread overview]
Message-ID: <ZzHQVAVJvbiRohPh@smile.fi.intel.com> (raw)
In-Reply-To: <b8340169-5832-4aa2-8713-9639b7f7aec4@redhat.com>
On Sun, Nov 10, 2024 at 11:27:31PM +0100, Hans de Goede wrote:
> On 10-Nov-24 12:51 PM, Andy Shevchenko wrote:
> > On Sun, Nov 10, 2024 at 12:05 AM Hans de Goede <hdegoede@redhat.com> wrote:
...
> >> + if (dev_info->use_pci)
> >> + ctrl_dev = get_serdev_controller_by_pci_parent(info);
> >> + else
> >> + ctrl_dev = get_serdev_controller(info->ctrl_hid, info->ctrl_uid, 0,
> >> + info->ctrl_devname);
> >
> > I would expect that they both take info as an argument...
>
> The "old" get_serdev_controller() helper for getting the controller
> by ACPI HID + UID is also used outside of the x86-android-tablets code
> and struct x86_serdev_info is x86-android-tablets specific.
I see, thanks for elaborating this.
> >> if (IS_ERR(ctrl_dev))
> >> return PTR_ERR(ctrl_dev);
...
> >> struct x86_serdev_info {
> >> + /* For ACPI enumerated controllers */
> >> const char *ctrl_hid;
> >> const char *ctrl_uid;
> >> + /* For PCI enumerated controllers */
> >> + unsigned int ctrl_devfn;
> >> + /* Typically "serial0" */
> >> const char *ctrl_devname;
> >
> > Why not union as we have a type selector, i.e. use_pci ?
>
> A union would be possible. I simply did not think of that.
>
> Not sure if it is worth the trouble though, since it saves
> only 8 bytes on a struct which is currently used only 3
> times in the driver.
Saving bytes is not the main point, the main point is to make the code robust
against writing both fields and make things confusing. Along with that, union
gives a reader the clue that those fields are never used at the same time. So,
can you consider using union?
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2024-11-11 9:37 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-09 22:05 [PATCH 0/5] platform/x86: x86-android-tablets: Add Bluetooth support for Vexia EDU ATLA 10 Hans de Goede
2024-11-09 22:05 ` [PATCH 1/5] platform/x86: serdev_helpers: Add get_serdev_controller_from_parent() helper Hans de Goede
2024-11-09 22:05 ` [PATCH 2/5] platform/x86: x86-android-tablets: Add missing __init to get_i2c_adap_by_*() Hans de Goede
2024-11-09 22:05 ` [PATCH 3/5] platform/x86: x86-android-tablets: Change x86_instantiate_serdev() prototype Hans de Goede
2024-11-09 22:05 ` [PATCH 4/5] platform/x86: x86-android-tablets: Add support for getting serdev-controller by PCI parent Hans de Goede
2024-11-10 11:51 ` Andy Shevchenko
2024-11-10 22:27 ` Hans de Goede
2024-11-11 9:37 ` Andy Shevchenko [this message]
2024-11-11 9:53 ` Hans de Goede
2024-11-09 22:05 ` [PATCH 5/5] platform/x86: x86-android-tablets: Add Bluetooth support for Vexia EDU ATLA 10 Hans de Goede
2024-11-10 14:53 ` [PATCH 0/5] " Andy Shevchenko
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=ZzHQVAVJvbiRohPh@smile.fi.intel.com \
--to=andy.shevchenko@gmail.com \
--cc=hdegoede@redhat.com \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=platform-driver-x86@vger.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox