linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] misc: habanalabs: avoid HWMON dependency
@ 2019-03-04 20:04 Arnd Bergmann
  2019-03-04 20:21 ` Oded Gabbay
  0 siblings, 1 reply; 3+ messages in thread
From: Arnd Bergmann @ 2019-03-04 20:04 UTC (permalink / raw)
  To: Oded Gabbay, Arnd Bergmann, Greg Kroah-Hartman
  Cc: Mike Rapoport, linux-kernel

When CONFIG_HWMON is disabled, we currently get a link error for this driver:

ERROR: "hwmon_device_unregister" [drivers/misc/habanalabs/habanalabs.ko] undefined!
ERROR: "hwmon_device_register_with_info" [drivers/misc/habanalabs/habanalabs.ko] undefined!

As the hardware monitoring is not a required part of the functionality,
make it possible to compile without HWMON by ignoring all that functionality
depending on the configuration.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/misc/habanalabs/hwmon.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/misc/habanalabs/hwmon.c b/drivers/misc/habanalabs/hwmon.c
index 77facd25c4a2..933746639831 100644
--- a/drivers/misc/habanalabs/hwmon.c
+++ b/drivers/misc/habanalabs/hwmon.c
@@ -423,7 +423,7 @@ int hl_hwmon_init(struct hl_device *hdev)
 	struct device *dev = hdev->pdev ? &hdev->pdev->dev : hdev->dev;
 	int rc;
 
-	if ((hdev->hwmon_initialized) || !(hdev->fw_loading))
+	if (!IS_ENABLED(CONFIG_HWMON) || (hdev->hwmon_initialized) || !(hdev->fw_loading))
 		return 0;
 
 	if (hdev->hl_chip_info->info) {
@@ -451,7 +451,7 @@ int hl_hwmon_init(struct hl_device *hdev)
 
 void hl_hwmon_fini(struct hl_device *hdev)
 {
-	if (!hdev->hwmon_initialized)
+	if (!IS_ENABLED(CONFIG_HWMON) || !hdev->hwmon_initialized)
 		return;
 
 	hwmon_device_unregister(hdev->hwmon_dev);
-- 
2.20.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] misc: habanalabs: avoid HWMON dependency
  2019-03-04 20:04 [PATCH] misc: habanalabs: avoid HWMON dependency Arnd Bergmann
@ 2019-03-04 20:21 ` Oded Gabbay
  2019-03-04 21:12   ` Arnd Bergmann
  0 siblings, 1 reply; 3+ messages in thread
From: Oded Gabbay @ 2019-03-04 20:21 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Greg Kroah-Hartman, Mike Rapoport, Linux-Kernel@Vger. Kernel. Org

On Mon, Mar 4, 2019 at 10:04 PM Arnd Bergmann <arnd@arndb.de> wrote:
>
> When CONFIG_HWMON is disabled, we currently get a link error for this driver:
>
> ERROR: "hwmon_device_unregister" [drivers/misc/habanalabs/habanalabs.ko] undefined!
> ERROR: "hwmon_device_register_with_info" [drivers/misc/habanalabs/habanalabs.ko] undefined!
>
> As the hardware monitoring is not a required part of the functionality,
> make it possible to compile without HWMON by ignoring all that functionality
> depending on the configuration.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  drivers/misc/habanalabs/hwmon.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/misc/habanalabs/hwmon.c b/drivers/misc/habanalabs/hwmon.c
> index 77facd25c4a2..933746639831 100644
> --- a/drivers/misc/habanalabs/hwmon.c
> +++ b/drivers/misc/habanalabs/hwmon.c
> @@ -423,7 +423,7 @@ int hl_hwmon_init(struct hl_device *hdev)
>         struct device *dev = hdev->pdev ? &hdev->pdev->dev : hdev->dev;
>         int rc;
>
> -       if ((hdev->hwmon_initialized) || !(hdev->fw_loading))
> +       if (!IS_ENABLED(CONFIG_HWMON) || (hdev->hwmon_initialized) || !(hdev->fw_loading))
>                 return 0;
>
>         if (hdev->hl_chip_info->info) {
> @@ -451,7 +451,7 @@ int hl_hwmon_init(struct hl_device *hdev)
>
>  void hl_hwmon_fini(struct hl_device *hdev)
>  {
> -       if (!hdev->hwmon_initialized)
> +       if (!IS_ENABLED(CONFIG_HWMON) || !hdev->hwmon_initialized)
>                 return;
>
>         hwmon_device_unregister(hdev->hwmon_dev);
> --
> 2.20.0
>

Hi Arnd,
I sent a patch to gkh to fix this last week (and he merged that into
his tree), but I took a different approach of selecting HWMON in
kconfig (with an added depends on of HAS_IOMEM to prevent dependency
breakage).
I don't really want the driver to load without HWMON support. I took
the example from AMD's amdgpu driver which does the same thing.

Thanks,
Oded

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] misc: habanalabs: avoid HWMON dependency
  2019-03-04 20:21 ` Oded Gabbay
@ 2019-03-04 21:12   ` Arnd Bergmann
  0 siblings, 0 replies; 3+ messages in thread
From: Arnd Bergmann @ 2019-03-04 21:12 UTC (permalink / raw)
  To: Oded Gabbay
  Cc: Greg Kroah-Hartman, Mike Rapoport, Linux-Kernel@Vger. Kernel. Org

On Mon, Mar 4, 2019 at 9:21 PM Oded Gabbay <oded.gabbay@gmail.com> wrote:
>
> On Mon, Mar 4, 2019 at 10:04 PM Arnd Bergmann <arnd@arndb.de> wrote:
> >
> > When CONFIG_HWMON is disabled, we currently get a link error for this driver:
> >
> > ERROR: "hwmon_device_unregister" [drivers/misc/habanalabs/habanalabs.ko] undefined!
> > ERROR: "hwmon_device_register_with_info" [drivers/misc/habanalabs/habanalabs.ko] undefined!
> >
> > As the hardware monitoring is not a required part of the functionality,
> > make it possible to compile without HWMON by ignoring all that functionality
> > depending on the configuration.

> Hi Arnd,
> I sent a patch to gkh to fix this last week (and he merged that into
> his tree), but I took a different approach of selecting HWMON in
> kconfig (with an added depends on of HAS_IOMEM to prevent dependency
> breakage).
> I don't really want the driver to load without HWMON support. I took
> the example from AMD's amdgpu driver which does the same thing.

Ok, that's fine, I see your fix now.

I tried to avoid doing this in Kconfig, as we already have a mix of 'depends on
HWMON' and 'select HWMON', which sooner or later is likely to cause
circular dependencies. Since you don't have any 'depends on' statements
so far, it's not a problem for you though.

      Arnd

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-03-04 21:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-04 20:04 [PATCH] misc: habanalabs: avoid HWMON dependency Arnd Bergmann
2019-03-04 20:21 ` Oded Gabbay
2019-03-04 21:12   ` Arnd Bergmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).