title: Basic Kernel HWMon Driver Module for LPC Chip?
body: <p>I'm working on writing a kernel hwmon driver module for a chip that communicates over LPC (ISA style bus).  I have the following code so far</p>
  <pre><code>umode_t qnap_ec_is_visible(const void* data, enum hwmon_sensor_types type, u32 attr, int channel)
  {
  }
  
  int qnap_ec_read(struct device* dev, enum hwmon_sensor_types type, u32 attr, int channel, long* val)
  {
  }
  
  int qnap_ec_write(struct device* dev, enum hwmon_sensor_types type, u32 attr, int channel, long val)
  {
  }
  
  static const struct hwmon_ops qnap_ec_ops = {
    .is_visible = qnap_ec_is_visible,
    .read = qnap_ec_read,
    .write = qnap_ec_write
  };
  
  static const struct hwmon_channel_info *qnap_ec_channel_info[] = {
    HWMON_CHANNEL_INFO(pwm, HWMON_PWM_INPUT),
    HWMON_CHANNEL_INFO(fan, HWMON_F_INPUT),
    HWMON_CHANNEL_INFO(temp, HWMON_T_INPUT),
    NULL
  };
  
  static const struct hwmon_chip_info qnap_ec_chip_info = {
    .ops = &amp;qnap_ec_ops,
    .info = qnap_ec_channel_info
  };
  
  static int qnap_ec_probe(struct platform_device* platform_dev)
  {
    struct device* dev;
    dev = devm_hwmon_device_register_with_info(&amp;platform_dev-&gt;dev, &quot;qnap_ec_hwmon&quot;, NULL,
      &amp;qnap_ec_chip_info, NULL);
    return PTR_ERR_OR_ZERO(dev);
  }
  
  static const struct of_device_id qnap_ec_of_match[] = {
    { .compatible = &quot;???&quot; },
    {}
  };
  
  MODULE_DEVICE_TABLE(of, qnap_ec_of_match);
  
  static struct platform_driver qnap_ec_driver = {
    .driver = {
      .name = &quot;qnap_ec_hwmon&quot;,
      .of_match_table = qnap_ec_of_match
    },
    .probe = qnap_ec_probe
  };
  
  module_platform_driver(qnap_ec_driver);
  </code></pre>
  <p>however I'm pretty sure this approach (using a device ID and having the kernel call the probe function when it finds that device ID on the system) won't work for something on the LPC bus.  The IT87 driver which also communicates over the LPC bus uses __init/__exit functions to enter the driver, however, that driver is very large and probably not an ideal example of a simple driver module.  Are there any examples available of how to write a basic (ie: no real functionality just the skeleton) kernel hwmon driver for a LPC device?  Some of the things I can't find answers for, for example, is if I use the __init/__exit functions, can I still register the driver using the devm_hwmon_device_register_with_info function or do I need to use another approach (the it87 driver for example uses the platform_driver_register function, but I'm not sure why since there doesn't seem to be any documentation on the correct approach for LPC devices).</p>