Message ID | 20210406211653.182338-1-hdegoede@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [1/2] ACPI: utils: Add acpi_reduced_hardware() helper | expand |
On Tue, Apr 6, 2021 at 11:17 PM Hans de Goede <hdegoede@redhat.com> wrote: > > Add a getter for the acpi_gbl_reduced_hardware variable so that modules > can check if they are running on an ACPI reduced-hw platform or not. > > Signed-off-by: Hans de Goede <hdegoede@redhat.com> > --- > drivers/acpi/utils.c | 11 +++++++++++ > include/acpi/acpi_bus.h | 1 + > include/linux/acpi.h | 5 +++++ > 3 files changed, 17 insertions(+) > > diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c > index 682edd913b3b..4cb061d3169a 100644 > --- a/drivers/acpi/utils.c > +++ b/drivers/acpi/utils.c > @@ -872,6 +872,17 @@ acpi_dev_get_first_match_dev(const char *hid, const char *uid, s64 hrv) > } > EXPORT_SYMBOL(acpi_dev_get_first_match_dev); > > +/** > + * acpi_reduced_hardware - Return if this is an ACPI-reduced-hw machine > + * > + * Return true when running on an ACPI-reduced-hw machine, false otherwise. > + */ > +bool acpi_reduced_hardware(void) > +{ > + return acpi_gbl_reduced_hardware; > +} > +EXPORT_SYMBOL(acpi_reduced_hardware); EXPORT_SYMBOL_GPL()? > + > /* > * acpi_backlight= handling, this is done here rather then in video_detect.c > * because __setup cannot be used in modules. > diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h > index f28b097c658f..d631cb52283e 100644 > --- a/include/acpi/acpi_bus.h > +++ b/include/acpi/acpi_bus.h > @@ -78,6 +78,7 @@ acpi_evaluate_dsm_typed(acpi_handle handle, const guid_t *guid, u64 rev, > > bool acpi_dev_found(const char *hid); > bool acpi_dev_present(const char *hid, const char *uid, s64 hrv); > +bool acpi_reduced_hardware(void); > > #ifdef CONFIG_ACPI > > diff --git a/include/linux/acpi.h b/include/linux/acpi.h > index 3bdcfc4401b7..e2e6db8313c8 100644 > --- a/include/linux/acpi.h > +++ b/include/linux/acpi.h > @@ -748,6 +748,11 @@ acpi_dev_get_first_match_dev(const char *hid, const char *uid, s64 hrv) > return NULL; > } > > +static inline bool acpi_reduced_hardware(void) > +{ > + return false; > +} > + > static inline void acpi_dev_put(struct acpi_device *adev) {} > > static inline bool is_acpi_node(const struct fwnode_handle *fwnode) > -- > 2.30.2 >
Hi, On 4/7/21 7:13 PM, Rafael J. Wysocki wrote: > On Tue, Apr 6, 2021 at 11:17 PM Hans de Goede <hdegoede@redhat.com> wrote: >> >> Add a getter for the acpi_gbl_reduced_hardware variable so that modules >> can check if they are running on an ACPI reduced-hw platform or not. >> >> Signed-off-by: Hans de Goede <hdegoede@redhat.com> >> --- >> drivers/acpi/utils.c | 11 +++++++++++ >> include/acpi/acpi_bus.h | 1 + >> include/linux/acpi.h | 5 +++++ >> 3 files changed, 17 insertions(+) >> >> diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c >> index 682edd913b3b..4cb061d3169a 100644 >> --- a/drivers/acpi/utils.c >> +++ b/drivers/acpi/utils.c >> @@ -872,6 +872,17 @@ acpi_dev_get_first_match_dev(const char *hid, const char *uid, s64 hrv) >> } >> EXPORT_SYMBOL(acpi_dev_get_first_match_dev); >> >> +/** >> + * acpi_reduced_hardware - Return if this is an ACPI-reduced-hw machine >> + * >> + * Return true when running on an ACPI-reduced-hw machine, false otherwise. >> + */ >> +bool acpi_reduced_hardware(void) >> +{ >> + return acpi_gbl_reduced_hardware; >> +} >> +EXPORT_SYMBOL(acpi_reduced_hardware); > > EXPORT_SYMBOL_GPL()? Yes, that was my intention, no idea what happened here. Before I send a v2, do you have any remarks on patch 2/2 (which is actually the more interesting patch) ? Regards, Hans > >> + >> /* >> * acpi_backlight= handling, this is done here rather then in video_detect.c >> * because __setup cannot be used in modules. >> diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h >> index f28b097c658f..d631cb52283e 100644 >> --- a/include/acpi/acpi_bus.h >> +++ b/include/acpi/acpi_bus.h >> @@ -78,6 +78,7 @@ acpi_evaluate_dsm_typed(acpi_handle handle, const guid_t *guid, u64 rev, >> >> bool acpi_dev_found(const char *hid); >> bool acpi_dev_present(const char *hid, const char *uid, s64 hrv); >> +bool acpi_reduced_hardware(void); >> >> #ifdef CONFIG_ACPI >> >> diff --git a/include/linux/acpi.h b/include/linux/acpi.h >> index 3bdcfc4401b7..e2e6db8313c8 100644 >> --- a/include/linux/acpi.h >> +++ b/include/linux/acpi.h >> @@ -748,6 +748,11 @@ acpi_dev_get_first_match_dev(const char *hid, const char *uid, s64 hrv) >> return NULL; >> } >> >> +static inline bool acpi_reduced_hardware(void) >> +{ >> + return false; >> +} >> + >> static inline void acpi_dev_put(struct acpi_device *adev) {} >> >> static inline bool is_acpi_node(const struct fwnode_handle *fwnode) >> -- >> 2.30.2 >> >
On Wed, Apr 7, 2021 at 7:43 PM Hans de Goede <hdegoede@redhat.com> wrote: > > Hi, > > On 4/7/21 7:13 PM, Rafael J. Wysocki wrote: > > On Tue, Apr 6, 2021 at 11:17 PM Hans de Goede <hdegoede@redhat.com> wrote: > >> > >> Add a getter for the acpi_gbl_reduced_hardware variable so that modules > >> can check if they are running on an ACPI reduced-hw platform or not. > >> > >> Signed-off-by: Hans de Goede <hdegoede@redhat.com> > >> --- > >> drivers/acpi/utils.c | 11 +++++++++++ > >> include/acpi/acpi_bus.h | 1 + > >> include/linux/acpi.h | 5 +++++ > >> 3 files changed, 17 insertions(+) > >> > >> diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c > >> index 682edd913b3b..4cb061d3169a 100644 > >> --- a/drivers/acpi/utils.c > >> +++ b/drivers/acpi/utils.c > >> @@ -872,6 +872,17 @@ acpi_dev_get_first_match_dev(const char *hid, const char *uid, s64 hrv) > >> } > >> EXPORT_SYMBOL(acpi_dev_get_first_match_dev); > >> > >> +/** > >> + * acpi_reduced_hardware - Return if this is an ACPI-reduced-hw machine > >> + * > >> + * Return true when running on an ACPI-reduced-hw machine, false otherwise. > >> + */ > >> +bool acpi_reduced_hardware(void) > >> +{ > >> + return acpi_gbl_reduced_hardware; > >> +} > >> +EXPORT_SYMBOL(acpi_reduced_hardware); > > > > EXPORT_SYMBOL_GPL()? > > Yes, that was my intention, no idea what happened here. > > Before I send a v2, do you have any remarks on patch 2/2 (which is actually > the more interesting patch) ? I thought that basing that check on the ACPICA's global variable may be too coarse grained for some cases, but then I've decided to do it as is now and we'll see. No need to resend that one.
Hi, On 4/7/21 7:50 PM, Rafael J. Wysocki wrote: > On Wed, Apr 7, 2021 at 7:43 PM Hans de Goede <hdegoede@redhat.com> wrote: >> >> Hi, >> >> On 4/7/21 7:13 PM, Rafael J. Wysocki wrote: >>> On Tue, Apr 6, 2021 at 11:17 PM Hans de Goede <hdegoede@redhat.com> wrote: >>>> >>>> Add a getter for the acpi_gbl_reduced_hardware variable so that modules >>>> can check if they are running on an ACPI reduced-hw platform or not. >>>> >>>> Signed-off-by: Hans de Goede <hdegoede@redhat.com> >>>> --- >>>> drivers/acpi/utils.c | 11 +++++++++++ >>>> include/acpi/acpi_bus.h | 1 + >>>> include/linux/acpi.h | 5 +++++ >>>> 3 files changed, 17 insertions(+) >>>> >>>> diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c >>>> index 682edd913b3b..4cb061d3169a 100644 >>>> --- a/drivers/acpi/utils.c >>>> +++ b/drivers/acpi/utils.c >>>> @@ -872,6 +872,17 @@ acpi_dev_get_first_match_dev(const char *hid, const char *uid, s64 hrv) >>>> } >>>> EXPORT_SYMBOL(acpi_dev_get_first_match_dev); >>>> >>>> +/** >>>> + * acpi_reduced_hardware - Return if this is an ACPI-reduced-hw machine >>>> + * >>>> + * Return true when running on an ACPI-reduced-hw machine, false otherwise. >>>> + */ >>>> +bool acpi_reduced_hardware(void) >>>> +{ >>>> + return acpi_gbl_reduced_hardware; >>>> +} >>>> +EXPORT_SYMBOL(acpi_reduced_hardware); >>> >>> EXPORT_SYMBOL_GPL()? >> >> Yes, that was my intention, no idea what happened here. I just prepped and send out v2 and I think I know what happened, all the other functions in drivers/acpi/utils.c are EXPORT_SYMBOL, so I probably just copy-and-pasted this without too much thinking. It might be worthwhile to see if we should also mark some other functions as EXPORT_SYMBOL_GPL() here. >> Before I send a v2, do you have any remarks on patch 2/2 (which is actually >> the more interesting patch) ? > > I thought that basing that check on the ACPICA's global variable may > be too coarse grained for some cases, but then I've decided to do it > as is now and we'll see. Yes, the whole code for selecting which backlight driver to use is mostly heuristics, so "we'll see" indeed . With that said I'm pretty confident that this change should not cause problems. Platforms which actually set acpi_gbl_reduced_hardware=true seem to be quite rare. I'm actually only aware of Bay Trail-T based devices doing this. Regards, Hans
diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c index 682edd913b3b..4cb061d3169a 100644 --- a/drivers/acpi/utils.c +++ b/drivers/acpi/utils.c @@ -872,6 +872,17 @@ acpi_dev_get_first_match_dev(const char *hid, const char *uid, s64 hrv) } EXPORT_SYMBOL(acpi_dev_get_first_match_dev); +/** + * acpi_reduced_hardware - Return if this is an ACPI-reduced-hw machine + * + * Return true when running on an ACPI-reduced-hw machine, false otherwise. + */ +bool acpi_reduced_hardware(void) +{ + return acpi_gbl_reduced_hardware; +} +EXPORT_SYMBOL(acpi_reduced_hardware); + /* * acpi_backlight= handling, this is done here rather then in video_detect.c * because __setup cannot be used in modules. diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h index f28b097c658f..d631cb52283e 100644 --- a/include/acpi/acpi_bus.h +++ b/include/acpi/acpi_bus.h @@ -78,6 +78,7 @@ acpi_evaluate_dsm_typed(acpi_handle handle, const guid_t *guid, u64 rev, bool acpi_dev_found(const char *hid); bool acpi_dev_present(const char *hid, const char *uid, s64 hrv); +bool acpi_reduced_hardware(void); #ifdef CONFIG_ACPI diff --git a/include/linux/acpi.h b/include/linux/acpi.h index 3bdcfc4401b7..e2e6db8313c8 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -748,6 +748,11 @@ acpi_dev_get_first_match_dev(const char *hid, const char *uid, s64 hrv) return NULL; } +static inline bool acpi_reduced_hardware(void) +{ + return false; +} + static inline void acpi_dev_put(struct acpi_device *adev) {} static inline bool is_acpi_node(const struct fwnode_handle *fwnode)
Add a getter for the acpi_gbl_reduced_hardware variable so that modules can check if they are running on an ACPI reduced-hw platform or not. Signed-off-by: Hans de Goede <hdegoede@redhat.com> --- drivers/acpi/utils.c | 11 +++++++++++ include/acpi/acpi_bus.h | 1 + include/linux/acpi.h | 5 +++++ 3 files changed, 17 insertions(+)