Patch Detail
Show a patch.
GET /api/patches/9208/?format=api
{ "id": 9208, "url": "https://patchwork.libcamera.org/api/patches/9208/?format=api", "web_url": "https://patchwork.libcamera.org/patch/9208/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20200805104900.2172763-2-niklas.soderlund@ragnatech.se>", "date": "2020-08-05T10:48:52", "name": "[libcamera-devel,v8,1/9] libcamera: sysfs: Add helper to lookup sysfs path of a character device", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "5f47ba1f9e12348853c15f28629e50871cdd4e3c", "submitter": { "id": 5, "url": "https://patchwork.libcamera.org/api/people/5/?format=api", "name": "Niklas Söderlund", "email": "niklas.soderlund@ragnatech.se" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/9208/mbox/", "series": [ { "id": 1192, "url": "https://patchwork.libcamera.org/api/series/1192/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1192", "date": "2020-08-05T10:48:51", "name": "libcamera: Generate unique and stable camera IDs", "version": 8, "mbox": "https://patchwork.libcamera.org/series/1192/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/9208/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/9208/checks/", "tags": {}, "headers": { "Return-Path": "<libcamera-devel-bounces@lists.libcamera.org>", "X-Original-To": "parsemail@patchwork.libcamera.org", "Delivered-To": "parsemail@patchwork.libcamera.org", "Received": [ "from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id BDBC2BD86F\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 5 Aug 2020 10:49:13 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 809F460595;\n\tWed, 5 Aug 2020 12:49:13 +0200 (CEST)", "from bin-mail-out-05.binero.net (bin-mail-out-05.binero.net\n\t[195.74.38.228])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D4BF660492\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 5 Aug 2020 12:49:11 +0200 (CEST)", "from bismarck.berto.se (p54ac52a8.dip0.t-ipconnect.de\n\t[84.172.82.168]) by bin-vsp-out-02.atm.binero.net (Halon) with ESMTPA\n\tid 4b0c393e-d709-11ea-a39b-005056917f90;\n\tWed, 05 Aug 2020 12:49:10 +0200 (CEST)" ], "X-Halon-ID": "4b0c393e-d709-11ea-a39b-005056917f90", "Authorized-sender": "niklas@soderlund.pp.se", "From": "=?utf-8?q?Niklas_S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Wed, 5 Aug 2020 12:48:52 +0200", "Message-Id": "<20200805104900.2172763-2-niklas.soderlund@ragnatech.se>", "X-Mailer": "git-send-email 2.28.0", "In-Reply-To": "<20200805104900.2172763-1-niklas.soderlund@ragnatech.se>", "References": "<20200805104900.2172763-1-niklas.soderlund@ragnatech.se>", "MIME-Version": "1.0", "Subject": "[libcamera-devel] [PATCH v8 1/9] libcamera: sysfs: Add helper to\n\tlookup sysfs path of a character device", "X-BeenThere": "libcamera-devel@lists.libcamera.org", "X-Mailman-Version": "2.1.29", "Precedence": "list", "List-Id": "<libcamera-devel.lists.libcamera.org>", "List-Unsubscribe": "<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>", "List-Archive": "<https://lists.libcamera.org/pipermail/libcamera-devel/>", "List-Post": "<mailto:libcamera-devel@lists.libcamera.org>", "List-Help": "<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>", "List-Subscribe": "<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>", "Content-Type": "text/plain; charset=\"utf-8\"", "Content-Transfer-Encoding": "base64", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "Add a helper function to lookup the sysfs path of a character device.\nStore the function in a new libcamera::sysfs namespace as there is not\nclass to host it.\n\nSuggested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nSigned-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n* Changes since v7\n- Rename parameter to deviceNode\n- Include sstream\n- Rename LOG category to SysFs\n- Update documentation\n- Print errno on failure\n`\n---\n include/libcamera/internal/meson.build | 1 +\n include/libcamera/internal/sysfs.h | 22 +++++++++++\n src/libcamera/meson.build | 1 +\n src/libcamera/sysfs.cpp | 52 ++++++++++++++++++++++++++\n 4 files changed, 76 insertions(+)\n create mode 100644 include/libcamera/internal/sysfs.h\n create mode 100644 src/libcamera/sysfs.cpp", "diff": "diff --git a/include/libcamera/internal/meson.build b/include/libcamera/internal/meson.build\nindex d868eff47f920da0..150103388fdb219d 100644\n--- a/include/libcamera/internal/meson.build\n+++ b/include/libcamera/internal/meson.build\n@@ -25,6 +25,7 @@ libcamera_internal_headers = files([\n 'process.h',\n 'pub_key.h',\n 'semaphore.h',\n+ 'sysfs.h',\n 'thread.h',\n 'utils.h',\n 'v4l2_controls.h',\ndiff --git a/include/libcamera/internal/sysfs.h b/include/libcamera/internal/sysfs.h\nnew file mode 100644\nindex 0000000000000000..247a376ab7e0e8ee\n--- /dev/null\n+++ b/include/libcamera/internal/sysfs.h\n@@ -0,0 +1,22 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2020, Google Inc.\n+ *\n+ * sysfs.h - Miscellaneous utility functions to access sysfs\n+ */\n+#ifndef __LIBCAMERA_INTERNAL_SYSFS_H__\n+#define __LIBCAMERA_INTERNAL_SYSFS_H__\n+\n+#include <string>\n+\n+namespace libcamera {\n+\n+namespace sysfs {\n+\n+std::string charDevPath(const std::string &deviceNode);\n+\n+} /* namespace sysfs */\n+\n+} /* namespace libcamera */\n+\n+#endif /* __LIBCAMERA_INTERNAL_SYSFS_H__ */\ndiff --git a/src/libcamera/meson.build b/src/libcamera/meson.build\nindex 3aad4386ffc296db..bada45bcb11e9e88 100644\n--- a/src/libcamera/meson.build\n+++ b/src/libcamera/meson.build\n@@ -41,6 +41,7 @@ libcamera_sources = files([\n 'semaphore.cpp',\n 'signal.cpp',\n 'stream.cpp',\n+ 'sysfs.cpp',\n 'thread.cpp',\n 'timer.cpp',\n 'utils.cpp',\ndiff --git a/src/libcamera/sysfs.cpp b/src/libcamera/sysfs.cpp\nnew file mode 100644\nindex 0000000000000000..398df2c2be114908\n--- /dev/null\n+++ b/src/libcamera/sysfs.cpp\n@@ -0,0 +1,52 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2020, Google Inc.\n+ *\n+ * sysfs.cpp - Miscellaneous utility functions to access sysfs\n+ */\n+\n+#include \"libcamera/internal/sysfs.h\"\n+\n+#include <sstream>\n+#include <sys/stat.h>\n+#include <sys/sysmacros.h>\n+\n+#include \"libcamera/internal/log.h\"\n+\n+/**\n+ * \\file sysfs.h\n+ * \\brief Miscellaneous utility functions to access sysfs\n+ */\n+\n+namespace libcamera {\n+\n+LOG_DEFINE_CATEGORY(SysFs);\n+\n+namespace sysfs {\n+\n+/**\n+ * \\brief Retrieve the sysfs path for a character device\n+ * \\param[in] deviceNode Path to character device node\n+ * \\return The sysfs path on success or an empty string on failure\n+ */\n+std::string charDevPath(const std::string &deviceNode)\n+{\n+\tstruct stat st;\n+\tint ret = stat(deviceNode.c_str(), &st);\n+\tif (ret < 0) {\n+\t\tret = -errno;\n+\t\tLOG(SysFs, Error)\n+\t\t\t<< \"Unable to stat '\" << deviceNode << \"': \"\n+\t\t\t<< strerror(-ret);\n+\t\treturn {};\n+\t}\n+\n+\tstd::ostringstream dev(\"/sys/dev/char/\", std::ios_base::ate);\n+\tdev << major(st.st_rdev) << \":\" << minor(st.st_rdev);\n+\n+\treturn dev.str();\n+}\n+\n+} /* namespace sysfs */\n+\n+} /* namespace libcamera */\n", "prefixes": [ "libcamera-devel", "v8", "1/9" ] }