Commit graph

23 commits

Author SHA1 Message Date
Bastien Nocera
0fd6b11085 all: Remove HAVE_CONFIG_H conditional
We always have a config.h now, and don't rely on autotools setting this
cflags for us to know it.
2021-09-07 17:20:48 +02:00
Bastien Nocera
c6d2618e95 linux: Fix gudev includes for UpInput 2020-11-05 16:40:36 +01:00
Bastien Nocera
d697b39408 linux: Add support for running under umockdev
The sysfs path needs to be adjusted when running under umockdev.
2020-11-05 16:22:28 +01:00
Bastien Nocera
522fb6fff2 linux: Don't throw debug errors unless needed
It's really confusing seeing "not a switch [...]" when we actually
managed to find a switch, so throw 2 errors in the debug when both
checks fail, rather than as things are being tested.
2020-11-05 16:13:43 +01:00
Bastien Nocera
47481f3a57 linux: Fix warning when compiling with meson
src/up-input.c:294:3: warning: implicit declaration of function ‘close’; did you mean ‘pclose’? [-Wimplicit-function-declaration]
  294 |   close (input->eventfp);
      |   ^~~~~
      |   pclose
2020-10-23 14:34:34 +02:00
Bastien Nocera
809d69e66e linux: Remove unused headers in up-input.c 2020-10-22 16:53:45 +02:00
Bastien Nocera
7ddb75166d linux: Remove UpDaemon dependency from UpInput
Emit signals from UpInput for UpBackend to consume, rather than having
UpInput poke the daemon directly.
2020-10-22 16:52:37 +02:00
Bastien Nocera
50c48e0bcb linux: Make watched switch a property of UpInput
And add up_input_new_for_switch() to watch other switches.
2020-10-22 16:51:28 +02:00
Bastien Nocera
e87cc7b47c linux: Remove duplicate header in up-input.c 2020-10-22 16:50:04 +02:00
Bastien Nocera
c987ca4ed2 linux: Simplify UpInput object code
Use G_DECLARE_FINAL_TYPE() to clean up header and remove the use of a
private struct, as the whole object struct is now private.
2020-10-22 16:50:02 +02:00
Christian Kellner
9b7ce3dea3 Replace use of G_TYPE_INSTANCE_GET_PRIVATE
G_TYPE_INSTANCE_GET_PRIVATE has been deprecated since glib version
2.58 and should be replaced with the xxx_get_instance_private (obj)
which is generated by G_ADD_PRIVATE.
2019-02-21 12:09:06 +01:00
Christian Kellner
8da188b303 Replace use of deprecated g_type_class_add_private
Use G_DEFINE_TYPE_WITH_CODE (..., G_PRIVATE_ADD (...)) instead of
the (deprecated since glib 2.58) function g_type_class_add_private
to add a private structure for a type.
Bump the minimal required version of glib to 2.38.0, the version
where G_PRIVATE_ADD was added.
2019-02-21 12:07:59 +01:00
Bastien Nocera
054cb3f4b8 linux: Fix possible double-close on exit
Fix double-close on exit. If we created a GIOChannel from the file
descriptor, then g_io_channel_shutdown() will close that file descriptor
as well. Close the channel first, so that the file descriptor is only
closed manually if we didn't manage to create a GIOChannel from it.

https://gitlab.freedesktop.org/upower/upower/issues/60
2018-06-19 12:48:39 +00:00
Bastien Nocera
b3f39a5ca3 linux: Use g_clear_object() when possible
Rather than using != NULL, followed by unref().

https://bugs.freedesktop.org/show_bug.cgi?id=103380
2017-10-31 17:42:55 +01:00
Bastien Nocera
91df125e39 daemon: Remove unneeded reset of priv struct members
It's already done by GObject.
2013-10-14 10:42:56 +02:00
Richard Hughes
fe643d6fc0 trivial: remove an overzealous warning when starting up 2011-09-28 16:12:40 +01:00
Arnaud Patard
8b9ee53133 up-input.c: fix bitmap check
In up_input_coldplug(), some checks are done on the input device found in order
to detect if it's a lid switch or not.

The following one is problematic :

         /* convert to a bitmask */
         num_bits = up_input_str_to_bitmask (contents, bitmask, sizeof (bitmask));
         if (num_bits != 1) {
                 g_debug ("not one bitmask entry for %s", native_path);
                 ret = FALSE;
                 goto out;
         }

Checking if there's only 1 bit set is wrong. It's nice if you have a x86 with
acpi using 1 input device for the lid switch but it's not always nice.
One can create input devices with gpios-keys like this:

 static struct gpio_keys_button keys[] = {
         {
                 .code = SW_LID,
                 .gpio = ...,
                 .type = EV_SW,
                 .desc = "Lid Switch",
         },
         {
                 .code = SW_RFKILL_ALL,
                 .gpio = ...,
                 .type = EV_SW,
                 .desc = "rfkill",
         },
 };

The resulting SW bitmap will be 9 and thus there are 2 bits sets and due to the
mentionned check, the device is ignored by upower.

As a fix, I'm checking if the number of bits is between 0 and SW_CNT
bits.

Signed-off-by: Arnaud Patard <arnaud.patard@rtp-net.org>
Signed-off-by: Richard Hughes <richard@hughsie.com>
2011-03-04 17:29:44 +00:00
Richard Hughes
59893663fb Port from EggDebug to the GLib built-in logging framework 2010-11-01 11:28:31 +00:00
Richard Hughes
3dee7b22f8 Provide UpDaemon with C setters rather than relying on GObject properties 2010-04-19 17:05:59 +01:00
Michael Biebl
8e3791afe4 devkit-power-gobject/up-enum.h be gone
Port from devkit-power-gobject/up-enum.h to libupower-glib/up-types.h
2010-02-06 13:46:03 +00:00
Richard Hughes
c8cec18f06 trivial: DkpInput -> UpInput (no ABI or API break) 2010-01-18 13:15:47 +00:00
Richard Hughes
d2550b4c78 trivial: DkpDaemon -> UpDaemon (no ABI or API break) 2010-01-18 12:35:47 +00:00
Richard Hughes
15ac5102c8 trivial: Rename a lot of the source files from dkp-foo to up-foo, no API or ABI changes 2010-01-18 12:26:55 +00:00
Renamed from src/linux/dkp-input.c (Browse further)