{"action":"created","comment":{"url":"https://api.github.com/repos/hughsie/fwupd/pulls/comments/138328849","pull_request_review_id":62108175,"id":138328849,"diff_hunk":"@@ -146,6 +147,89 @@ fu_plugin_thunderbolt_is_host (GUdevDevice *device)\n \treturn g_str_has_prefix (name, \"domain\");\n }\n \n+static gchar *\n+fu_plugin_thunderbolt_get_force_power_path (FuPlugin *plugin)\n+{\n+\tFuPluginData *data = fu_plugin_get_data (plugin);\n+\n+\tGList *devices;\n+\tconst gchar *basepath;\n+\tg_autofree gchar *built_path = NULL;\n+\n+\tdevices = g_udev_client_query_by_subsystem (data->udev, \"wmi\");\n+\tfor (GList *l = devices; l != NULL; l = l->next) {\n+\t\tGUdevDevice *device = l->data;\n+\t\tbasepath = g_udev_device_get_sysfs_path (device);\n+\t\tbuilt_path = g_build_path (\"/\", basepath,\n+\t\t\t\t\t   \"force_power\", NULL);\n+\t\tif (g_file_test (built_path, G_FILE_TEST_IS_REGULAR))\n+\t\t\tbreak;\n+\t\tbuilt_path = NULL;\n+\t}\n+\tg_list_foreach (devices, (GFunc) g_object_unref, NULL);\n+\tg_list_free (devices);\n+\n+\tif (built_path)\n+\t\treturn g_strdup (built_path);\n+\treturn NULL;\n+}\n+\n+static gboolean\n+fu_plugin_thunderbolt_set_force_power (FuPlugin *plugin, gboolean enable,\n+\t\t\t\t       GError **error)\n+{\n+\tg_autofree gchar *path = NULL;\n+\tgint fd;\n+\tgint ret;\n+\n+\tpath = fu_plugin_thunderbolt_get_force_power_path (plugin);\n+\tif (path == NULL) {\n+\t\treturn FALSE;\n+\t}\n+\tg_debug (\"Setting force power to %d\", enable);\n+\tfd = g_open (path, O_WRONLY);\n+\tif (fd == -1) {\n+\t\tg_set_error (error,\n+\t\t\t     FWUPD_ERROR,\n+\t\t\t     FWUPD_ERROR_INTERNAL,\n+\t\t\t     \"failed to open %s\", path);\n+\t\treturn FALSE;\n+\t}\n+\tif (enable)\n+\t\tret = write (fd, \"1\", 1);\n+\telse\n+\t\tret = write (fd, \"0\", 1);","path":"plugins/thunderbolt/fu-plugin-thunderbolt.c","position":71,"original_position":63,"commit_id":"c6c4effd5bda835f22972551e518a5e45e2fc07d","original_commit_id":"71db9e96f2b8787a739001b66fb4318080a2ad2a","user":{"login":"superm1","id":494526,"avatar_url":"https://avatars0.githubusercontent.com/u/494526?v=4","gravatar_id":"","url":"https://api.github.com/users/superm1","html_url":"https://github.com/superm1","followers_url":"https://api.github.com/users/superm1/followers","following_url":"https://api.github.com/users/superm1/following{/other_user}","gists_url":"https://api.github.com/users/superm1/gists{/gist_id}","starred_url":"https://api.github.com/users/superm1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/superm1/subscriptions","organizations_url":"https://api.github.com/users/superm1/orgs","repos_url":"https://api.github.com/users/superm1/repos","events_url":"https://api.github.com/users/superm1/events{/privacy}","received_events_url":"https://api.github.com/users/superm1/received_events","type":"User","site_admin":false},"body":"Adjusted","created_at":"2017-09-12T12:13:37Z","updated_at":"2017-09-12T12:13:38Z","html_url":"https://github.com/hughsie/fwupd/pull/245#discussion_r138328849","pull_request_url":"https://api.github.com/repos/hughsie/fwupd/pulls/245","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/hughsie/fwupd/pulls/comments/138328849"},"html":{"href":"https://github.com/hughsie/fwupd/pull/245#discussion_r138328849"},"pull_request":{"href":"https://api.github.com/repos/hughsie/fwupd/pulls/245"}},"in_reply_to_id":138269355},"pull_request":{"url":"https://api.github.com/repos/hughsie/fwupd/pulls/245","id":140485330,"html_url":"https://github.com/hughsie/fwupd/pull/245","diff_url":"https://github.com/hughsie/fwupd/pull/245.diff","patch_url":"https://github.com/hughsie/fwupd/pull/245.patch","issue_url":"https://api.github.com/repos/hughsie/fwupd/issues/245","number":245,"state":"open","locked":false,"title":"Add support for the new kernel API for force power","user":{"login":"superm1","id":494526,"avatar_url":"https://avatars0.githubusercontent.com/u/494526?v=4","gravatar_id":"","url":"https://api.github.com/users/superm1","html_url":"https://github.com/superm1","followers_url":"https://api.github.com/users/superm1/followers","following_url":"https://api.github.com/users/superm1/following{/other_user}","gists_url":"https://api.github.com/users/superm1/gists{/gist_id}","starred_url":"https://api.github.com/users/superm1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/superm1/subscriptions","organizations_url":"https://api.github.com/users/superm1/orgs","repos_url":"https://api.github.com/users/superm1/repos","events_url":"https://api.github.com/users/superm1/events{/privacy}","received_events_url":"https://api.github.com/users/superm1/received_events","type":"User","site_admin":false},"body":"This is a WIP with more testing still needed.  Early feedback welcome however.\r\n\r\nIt wraps around this API being introduced in kernel 4.14:\r\nhttp://git.infradead.org/linux-platform-drivers-x86.git/commit/d08e3b522bdaccde031a394039b299bfd8c18492","created_at":"2017-09-12T04:21:07Z","updated_at":"2017-09-12T12:13:38Z","closed_at":null,"merged_at":null,"merge_commit_sha":"232b32818876e13bed3ae7ceca0780b44535b519","assignee":null,"assignees":[],"requested_reviewers":[{"login":"gicmo","id":2040,"avatar_url":"https://avatars2.githubusercontent.com/u/2040?v=4","gravatar_id":"","url":"https://api.github.com/users/gicmo","html_url":"https://github.com/gicmo","followers_url":"https://api.github.com/users/gicmo/followers","following_url":"https://api.github.com/users/gicmo/following{/other_user}","gists_url":"https://api.github.com/users/gicmo/gists{/gist_id}","starred_url":"https://api.github.com/users/gicmo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gicmo/subscriptions","organizations_url":"https://api.github.com/users/gicmo/orgs","repos_url":"https://api.github.com/users/gicmo/repos","events_url":"https://api.github.com/users/gicmo/events{/privacy}","received_events_url":"https://api.github.com/users/gicmo/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/hughsie/fwupd/pulls/245/commits","review_comments_url":"https://api.github.com/repos/hughsie/fwupd/pulls/245/comments","review_comment_url":"https://api.github.com/repos/hughsie/fwupd/pulls/comments{/number}","comments_url":"https://api.github.com/repos/hughsie/fwupd/issues/245/comments","statuses_url":"https://api.github.com/repos/hughsie/fwupd/statuses/c6c4effd5bda835f22972551e518a5e45e2fc07d","head":{"label":"hughsie:wip/superm1/wmi-thunderbolt-forcepower","ref":"wip/superm1/wmi-thunderbolt-forcepower","sha":"c6c4effd5bda835f22972551e518a5e45e2fc07d","user":{"login":"hughsie","id":151380,"avatar_url":"https://avatars0.githubusercontent.com/u/151380?v=4","gravatar_id":"","url":"https://api.github.com/users/hughsie","html_url":"https://github.com/hughsie","followers_url":"https://api.github.com/users/hughsie/followers","following_url":"https://api.github.com/users/hughsie/following{/other_user}","gists_url":"https://api.github.com/users/hughsie/gists{/gist_id}","starred_url":"https://api.github.com/users/hughsie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hughsie/subscriptions","organizations_url":"https://api.github.com/users/hughsie/orgs","repos_url":"https://api.github.com/users/hughsie/repos","events_url":"https://api.github.com/users/hughsie/events{/privacy}","received_events_url":"https://api.github.com/users/hughsie/received_events","type":"User","site_admin":false},"repo":{"id":31374735,"name":"fwupd","full_name":"hughsie/fwupd","owner":{"login":"hughsie","id":151380,"avatar_url":"https://avatars0.githubusercontent.com/u/151380?v=4","gravatar_id":"","url":"https://api.github.com/users/hughsie","html_url":"https://github.com/hughsie","followers_url":"https://api.github.com/users/hughsie/followers","following_url":"https://api.github.com/users/hughsie/following{/other_user}","gists_url":"https://api.github.com/users/hughsie/gists{/gist_id}","starred_url":"https://api.github.com/users/hughsie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hughsie/subscriptions","organizations_url":"https://api.github.com/users/hughsie/orgs","repos_url":"https://api.github.com/users/hughsie/repos","events_url":"https://api.github.com/users/hughsie/events{/privacy}","received_events_url":"https://api.github.com/users/hughsie/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/hughsie/fwupd","description":"A simple daemon to allow session software to update firmware","fork":false,"url":"https://api.github.com/repos/hughsie/fwupd","forks_url":"https://api.github.com/repos/hughsie/fwupd/forks","keys_url":"https://api.github.com/repos/hughsie/fwupd/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hughsie/fwupd/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hughsie/fwupd/teams","hooks_url":"https://api.github.com/repos/hughsie/fwupd/hooks","issue_events_url":"https://api.github.com/repos/hughsie/fwupd/issues/events{/number}","events_url":"https://api.github.com/repos/hughsie/fwupd/events","assignees_url":"https://api.github.com/repos/hughsie/fwupd/assignees{/user}","branches_url":"https://api.github.com/repos/hughsie/fwupd/branches{/branch}","tags_url":"https://api.github.com/repos/hughsie/fwupd/tags","blobs_url":"https://api.github.com/repos/hughsie/fwupd/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hughsie/fwupd/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hughsie/fwupd/git/refs{/sha}","trees_url":"https://api.github.com/repos/hughsie/fwupd/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hughsie/fwupd/statuses/{sha}","languages_url":"https://api.github.com/repos/hughsie/fwupd/languages","stargazers_url":"https://api.github.com/repos/hughsie/fwupd/stargazers","contributors_url":"https://api.github.com/repos/hughsie/fwupd/contributors","subscribers_url":"https://api.github.com/repos/hughsie/fwupd/subscribers","subscription_url":"https://api.github.com/repos/hughsie/fwupd/subscription","commits_url":"https://api.github.com/repos/hughsie/fwupd/commits{/sha}","git_commits_url":"https://api.github.com/repos/hughsie/fwupd/git/commits{/sha}","comments_url":"https://api.github.com/repos/hughsie/fwupd/comments{/number}","issue_comment_url":"https://api.github.com/repos/hughsie/fwupd/issues/comments{/number}","contents_url":"https://api.github.com/repos/hughsie/fwupd/contents/{+path}","compare_url":"https://api.github.com/repos/hughsie/fwupd/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hughsie/fwupd/merges","archive_url":"https://api.github.com/repos/hughsie/fwupd/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hughsie/fwupd/downloads","issues_url":"https://api.github.com/repos/hughsie/fwupd/issues{/number}","pulls_url":"https://api.github.com/repos/hughsie/fwupd/pulls{/number}","milestones_url":"https://api.github.com/repos/hughsie/fwupd/milestones{/number}","notifications_url":"https://api.github.com/repos/hughsie/fwupd/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hughsie/fwupd/labels{/name}","releases_url":"https://api.github.com/repos/hughsie/fwupd/releases{/id}","deployments_url":"https://api.github.com/repos/hughsie/fwupd/deployments","created_at":"2015-02-26T15:52:25Z","updated_at":"2017-09-09T21:19:55Z","pushed_at":"2017-09-12T12:00:23Z","git_url":"git://github.com/hughsie/fwupd.git","ssh_url":"git@github.com:hughsie/fwupd.git","clone_url":"https://github.com/hughsie/fwupd.git","svn_url":"https://github.com/hughsie/fwupd","homepage":"","size":5221,"stargazers_count":206,"watchers_count":206,"language":"C","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":45,"mirror_url":null,"open_issues_count":14,"forks":45,"open_issues":14,"watchers":206,"default_branch":"master"}},"base":{"label":"hughsie:master","ref":"master","sha":"4d3025a1089271a4b7a4e160e52f75eca167ce1a","user":{"login":"hughsie","id":151380,"avatar_url":"https://avatars0.githubusercontent.com/u/151380?v=4","gravatar_id":"","url":"https://api.github.com/users/hughsie","html_url":"https://github.com/hughsie","followers_url":"https://api.github.com/users/hughsie/followers","following_url":"https://api.github.com/users/hughsie/following{/other_user}","gists_url":"https://api.github.com/users/hughsie/gists{/gist_id}","starred_url":"https://api.github.com/users/hughsie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hughsie/subscriptions","organizations_url":"https://api.github.com/users/hughsie/orgs","repos_url":"https://api.github.com/users/hughsie/repos","events_url":"https://api.github.com/users/hughsie/events{/privacy}","received_events_url":"https://api.github.com/users/hughsie/received_events","type":"User","site_admin":false},"repo":{"id":31374735,"name":"fwupd","full_name":"hughsie/fwupd","owner":{"login":"hughsie","id":151380,"avatar_url":"https://avatars0.githubusercontent.com/u/151380?v=4","gravatar_id":"","url":"https://api.github.com/users/hughsie","html_url":"https://github.com/hughsie","followers_url":"https://api.github.com/users/hughsie/followers","following_url":"https://api.github.com/users/hughsie/following{/other_user}","gists_url":"https://api.github.com/users/hughsie/gists{/gist_id}","starred_url":"https://api.github.com/users/hughsie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hughsie/subscriptions","organizations_url":"https://api.github.com/users/hughsie/orgs","repos_url":"https://api.github.com/users/hughsie/repos","events_url":"https://api.github.com/users/hughsie/events{/privacy}","received_events_url":"https://api.github.com/users/hughsie/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/hughsie/fwupd","description":"A simple daemon to allow session software to update firmware","fork":false,"url":"https://api.github.com/repos/hughsie/fwupd","forks_url":"https://api.github.com/repos/hughsie/fwupd/forks","keys_url":"https://api.github.com/repos/hughsie/fwupd/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hughsie/fwupd/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hughsie/fwupd/teams","hooks_url":"https://api.github.com/repos/hughsie/fwupd/hooks","issue_events_url":"https://api.github.com/repos/hughsie/fwupd/issues/events{/number}","events_url":"https://api.github.com/repos/hughsie/fwupd/events","assignees_url":"https://api.github.com/repos/hughsie/fwupd/assignees{/user}","branches_url":"https://api.github.com/repos/hughsie/fwupd/branches{/branch}","tags_url":"https://api.github.com/repos/hughsie/fwupd/tags","blobs_url":"https://api.github.com/repos/hughsie/fwupd/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hughsie/fwupd/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hughsie/fwupd/git/refs{/sha}","trees_url":"https://api.github.com/repos/hughsie/fwupd/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hughsie/fwupd/statuses/{sha}","languages_url":"https://api.github.com/repos/hughsie/fwupd/languages","stargazers_url":"https://api.github.com/repos/hughsie/fwupd/stargazers","contributors_url":"https://api.github.com/repos/hughsie/fwupd/contributors","subscribers_url":"https://api.github.com/repos/hughsie/fwupd/subscribers","subscription_url":"https://api.github.com/repos/hughsie/fwupd/subscription","commits_url":"https://api.github.com/repos/hughsie/fwupd/commits{/sha}","git_commits_url":"https://api.github.com/repos/hughsie/fwupd/git/commits{/sha}","comments_url":"https://api.github.com/repos/hughsie/fwupd/comments{/number}","issue_comment_url":"https://api.github.com/repos/hughsie/fwupd/issues/comments{/number}","contents_url":"https://api.github.com/repos/hughsie/fwupd/contents/{+path}","compare_url":"https://api.github.com/repos/hughsie/fwupd/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hughsie/fwupd/merges","archive_url":"https://api.github.com/repos/hughsie/fwupd/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hughsie/fwupd/downloads","issues_url":"https://api.github.com/repos/hughsie/fwupd/issues{/number}","pulls_url":"https://api.github.com/repos/hughsie/fwupd/pulls{/number}","milestones_url":"https://api.github.com/repos/hughsie/fwupd/milestones{/number}","notifications_url":"https://api.github.com/repos/hughsie/fwupd/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hughsie/fwupd/labels{/name}","releases_url":"https://api.github.com/repos/hughsie/fwupd/releases{/id}","deployments_url":"https://api.github.com/repos/hughsie/fwupd/deployments","created_at":"2015-02-26T15:52:25Z","updated_at":"2017-09-09T21:19:55Z","pushed_at":"2017-09-12T12:00:23Z","git_url":"git://github.com/hughsie/fwupd.git","ssh_url":"git@github.com:hughsie/fwupd.git","clone_url":"https://github.com/hughsie/fwupd.git","svn_url":"https://github.com/hughsie/fwupd","homepage":"","size":5221,"stargazers_count":206,"watchers_count":206,"language":"C","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":45,"mirror_url":null,"open_issues_count":14,"forks":45,"open_issues":14,"watchers":206,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/hughsie/fwupd/pulls/245"},"html":{"href":"https://github.com/hughsie/fwupd/pull/245"},"issue":{"href":"https://api.github.com/repos/hughsie/fwupd/issues/245"},"comments":{"href":"https://api.github.com/repos/hughsie/fwupd/issues/245/comments"},"review_comments":{"href":"https://api.github.com/repos/hughsie/fwupd/pulls/245/comments"},"review_comment":{"href":"https://api.github.com/repos/hughsie/fwupd/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/hughsie/fwupd/pulls/245/commits"},"statuses":{"href":"https://api.github.com/repos/hughsie/fwupd/statuses/c6c4effd5bda835f22972551e518a5e45e2fc07d"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"superm1"}}