backlight.c revision c33b329709ebe2755181980a050d02ec7c81ed87
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering This file is part of systemd.
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering Copyright 2013 Lennart Poettering
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering systemd is free software; you can redistribute it and/or modify it
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering under the terms of the GNU Lesser General Public License as published by
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering the Free Software Foundation; either version 2.1 of the License, or
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering (at your option) any later version.
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering systemd is distributed in the hope that it will be useful, but
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering WITHOUT ANY WARRANTY; without even the implied warranty of
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering Lesser General Public License for more details.
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering You should have received a copy of the GNU Lesser General Public License
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering along with systemd; If not, see <http://www.gnu.org/licenses/>.
875c2e220e2611165e09051c4747971811f1de58Lennart Poetteringstatic struct udev_device *find_pci_or_platform_parent(struct udev_device *device) {
if (!parent)
return NULL;
if (!subsystem)
return NULL;
if (!sysname)
return NULL;
return NULL;
return NULL;
const char *value;
if (value) {
unsigned long class = 0;
return NULL;
return parent;
return parent;
assert(a);
assert(b);
const char *v, *subsystem;
if (!parent)
if (!subsystem)
if (!enumerate)
const char *other_subsystem;
if (!other)
if (!other_parent)
log_debug("Skipping backlight device %s, since device %s is on same PCI device and takes precedence.",
log_debug("Skipping backlight device %s, since device %s is a platform device and takes precedence.",
const char *max_brightness_str;
unsigned max_brightness;
if (!max_brightness_str) {
if (max_brightness <= 0) {
return max_brightness;
const char *subsystem;
min_brightness = 0;
log_oom();
*value);
_cleanup_free_ char *saved = NULL, *ss = NULL, *escaped_ss = NULL, *escaped_sysname = NULL, *escaped_path_id = NULL;
unsigned max_brightness;
return EXIT_FAILURE;
log_open();
return EXIT_FAILURE;
if (!udev) {
log_oom();
return EXIT_FAILURE;
if (!sysname) {
return EXIT_FAILURE;
if (!ss) {
log_oom();
return EXIT_FAILURE;
sysname++;
return EXIT_FAILURE;
errno = 0;
if (!device) {
if (errno != 0)
log_oom();
return EXIT_FAILURE;
if (max_brightness == 0)
return EXIT_SUCCESS;
if (!escaped_ss) {
log_oom();
return EXIT_FAILURE;
if (!escaped_sysname) {
log_oom();
return EXIT_FAILURE;
if (path_id) {
if (!escaped_path_id) {
log_oom();
return EXIT_FAILURE;
saved = strjoin("/var/lib/systemd/backlight/", escaped_path_id, ":", escaped_ss, ":", escaped_sysname, NULL);
if (!saved) {
log_oom();
return EXIT_FAILURE;
if (!shall_restore_state())
return EXIT_SUCCESS;
return EXIT_SUCCESS;
if (r == -ENOENT)
return EXIT_SUCCESS;
return EXIT_FAILURE;
return EXIT_FAILURE;
const char *value;
return EXIT_SUCCESS;
if (!value) {
return EXIT_FAILURE;
return EXIT_FAILURE;
return EXIT_FAILURE;
return EXIT_SUCCESS;