[patch] Make APM and PMU poll like acpi does

Sjoerd Simons sjoerd at luon.net
Mon Mar 7 02:28:09 PST 2005


On Sun, Mar 06, 2005 at 08:02:08PM +0000, Richard Hughes wrote:
> Patch attached makes APM and PMU poll like acpi does.
> 
> I used cvs diff -up but I notice lots of "extra" stuff in the patch. Is
> this still okay?
> 
> Richard.

> +static gboolean
> +pmu_poll (gpointer data)
> +{
> +	GSList *i;
> +	GSList *devices;
> +
> +	devices = hal_device_store_match_multiple_key_value_string (hald_get_gdl (),
> +								    "battery.type",
> +								    "primary");
> +	for (i = devices; i != NULL; i = g_slist_next (i)) {
> +		HalDevice *d;
> +		
> +		d = HAL_DEVICE (i->data);
> +		if (hal_device_has_property (d, "linux.pmu_type"))
> +			pmu_rescan_device (d);
> +	}
> +
> +	return TRUE;
> +}
> +
>  static gboolean
>  battery_refresh (HalDevice *d, PMUDevHandler *handler)
>  {
> @@ -208,6 +230,11 @@ pmu_synthesize_hotplug_events (void)
>  	/* close directory */
>  	g_dir_close (dir);
>  
> +	/* setup timer for things that we need to poll */
> +	g_timeout_add (PMU_POLL_INTERVAL,
> +		       pmu_poll,
> +		       NULL);
> +
>  out:
>  	return ret;
>  }

Why are you using one poll function that searches the complete gdl for the
right objects each time ? Just adding a timeout for each object when it's added 
and removing that when the object is removed seems cleaner to me.

  Sjoerd
-- 
An authority is a person who can tell you more about something than you
really care to know.
_______________________________________________
hal mailing list
hal at lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/hal



More information about the Hal mailing list