diff mbox series

misc: habanalabs: avoid HWMON dependency

Message ID 20190304200412.1269035-1-arnd@arndb.de
State New
Headers show
Series misc: habanalabs: avoid HWMON dependency | expand

Commit Message

Arnd Bergmann March 4, 2019, 8:04 p.m. UTC
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(-)

-- 
2.20.0

Comments

Oded Gabbay March 4, 2019, 8:21 p.m. UTC | #1
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
Arnd Bergmann March 4, 2019, 9:12 p.m. UTC | #2
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
diff mbox series

Patch

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);