All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andy.shevchenko@gmail.com>
To: Mika Westerberg <mika.westerberg@linux.intel.com>
Cc: Hans de Goede <hdegoede@redhat.com>,
	Mark Gross <markgross@kernel.org>,
	Andy Shevchenko <andy@infradead.org>,
	Platform Driver <platform-driver-x86@vger.kernel.org>
Subject: Re: [PATCH v2 1/2] platform/x86: Add x86-acpi-irq-helpers.h
Date: Wed, 22 Dec 2021 14:49:56 +0200	[thread overview]
Message-ID: <CAHp75VcP1Ca1Y0tB0MeKmjxbCGO5puiQuNJmv0K4U1ase+XQvQ@mail.gmail.com> (raw)
In-Reply-To: <YcMd7dn+RCVrKOlj@lahna>

On Wed, Dec 22, 2021 at 2:47 PM Mika Westerberg
<mika.westerberg@linux.intel.com> wrote:
> On Tue, Dec 21, 2021 at 07:58:26PM +0100, Hans de Goede wrote:
> > On 12/21/21 16:27, Andy Shevchenko wrote:
> > > On Tue, Dec 21, 2021 at 5:13 PM Hans de Goede <hdegoede@redhat.com> wrote:
> > >>
> > >> Add helper code to get Linux IRQ numbers given a description of the IRQ
> > >> source (either IOAPIC index, or GPIO chip name + pin-number).
> > >>
> > >> This is intended to be used to lookup Linux IRQ numbers in cases where the
> > >> ACPI description for a device somehow lacks this info. This is only meant
> > >> for use on x86 ACPI platforms.
> > >>
> > >> This code is big/complex enough to warrant sharing, but too small to live
> > >> in its own module, therefor x86_acpi_irq_helper_get() is defined as
> > >> a static inline helper function.
> > >
> > > ...
> > >
> > >> +/* For gpio_get_desc which is EXPORT_SYMBOL_GPL() */
> > >
> > > gpio_get_desc()
> >
> > Fixed in my local version.
> >
> > > and honestly I don't like this kind of includes (yes,
> > > I know sometimes it's the best compromise).
> > >
> > >> +#include "../../gpio/gpiolib.h"
> > >
> > > ...
> > >
> > >> +               /* Like acpi_dev_gpio_irq_get(), but without parsing ACPI resources */
> > >> +               chip = gpiochip_find(data->gpio_chip, x86_acpi_irq_helper_gpiochip_find);
> > >> +               if (!chip)
> > >> +                       return -EPROBE_DEFER;
> > >> +
> > >> +               gpiod = gpiochip_get_desc(chip, data->index);
> > >> +               if (IS_ERR(gpiod)) {
> > >> +                       ret = PTR_ERR(gpiod);
> > >> +                       pr_err("error %d getting GPIO %s %d\n", ret,
> > >> +                              data->gpio_chip, data->index);
> > >> +                       return ret;
> > >> +               }
> > >> +
> > >> +               irq = gpiod_to_irq(gpiod);
> > >> +               if (irq < 0) {
> > >> +                       pr_err("error %d getting IRQ %s %d\n", irq,
> > >> +                              data->gpio_chip, data->index);
> > >> +                       return irq;
> > >> +               }
> > >> +
> > >> +               irq_type = acpi_dev_get_irq_type(data->trigger, data->polarity);
> > >> +               if (irq_type != IRQ_TYPE_NONE && irq_type != irq_get_trigger_type(irq))
> > >> +                       irq_set_irq_type(irq, irq_type);
> > >> +
> > >> +               return irq;
> > >
> > > I'm wondering why it can't be a part of the GPIO ACPI library?
> >
> > Interesting suggestion, but this really is only intended for the
> > special case when the DSDT is missing this info. I'm a bit worried
> > that having this available as a generic helper may lead to it
> > getting used too much. But I guess we can just put a comment on it
> > explaining that normally its use should be avoided.
> >
> > I've added Mika to the Cc, Mika, what do you think about adding this
> > as a new helper to the GPIO ACPI library ?
>
> Preferably no :-) Reason is that even if we add comment to the function
> you don't remember it after two weeks so the next patch adding another
> user will not be noticed by reviewers (unless tha name of the function
> clearly says it is a quirk/workaround).

Oh, we have a solution for this already, it's called an export
namespace. We may export symbols in its own namespace and any user
must to import it. It will show immediately who is trying to do "bad
things". Code duplication makes kernel bigger and harder to maintain.
Imagine if there is an issue or refactoring happening in one copy of
the code and missed in the other. How long would it take to discover
that and fix it?

-- 
With Best Regards,
Andy Shevchenko

  reply	other threads:[~2021-12-22 12:51 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-21 15:12 [PATCH v2 1/2] platform/x86: Add x86-acpi-irq-helpers.h Hans de Goede
2021-12-21 15:12 ` [PATCH v2 2/2] platform/x86: x86-android-tablets: New driver for x86 Android tablets Hans de Goede
2021-12-21 15:39   ` Andy Shevchenko
2021-12-21 19:05     ` Hans de Goede
2021-12-21 19:12       ` Hans de Goede
2021-12-21 15:27 ` [PATCH v2 1/2] platform/x86: Add x86-acpi-irq-helpers.h Andy Shevchenko
2021-12-21 18:58   ` Hans de Goede
2021-12-22 12:45     ` Mika Westerberg
2021-12-22 12:49       ` Andy Shevchenko [this message]
2021-12-23 17:26       ` Hans de Goede

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=CAHp75VcP1Ca1Y0tB0MeKmjxbCGO5puiQuNJmv0K4U1ase+XQvQ@mail.gmail.com \
    --to=andy.shevchenko@gmail.com \
    --cc=andy@infradead.org \
    --cc=hdegoede@redhat.com \
    --cc=markgross@kernel.org \
    --cc=mika.westerberg@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 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.