From: Johannes Berg <johannes@sipsolutions.net>
To: Zhang Rui <rui.zhang@intel.com>
Cc: linux-acpi@vger.kernel.org, netdev@vger.kernel.org,
lenb@kernel.org, hadi@cyberus.ca
Subject: Re: [PATCH] ACPI: export acpi events via generic netlink
Date: Tue, 03 Jul 2007 19:18:51 +0200 [thread overview]
Message-ID: <1183483131.4021.8.camel@johannes.berg> (raw)
In-Reply-To: <1182224403.5411.84.camel@localhost.localdomain>
[-- Attachment #1: Type: text/plain, Size: 2143 bytes --]
On Tue, 2007-06-19 at 11:40 +0800, Zhang Rui wrote:
> +/* attributes of acpi_genl_family */
> +enum {
> + ACPI_GENL_ATTR_UNSPEC,
> + ACPI_GENL_ATTR_EVENT, /* ACPI event info needed by user space */
> + __ACPI_GENL_ATTR_MAX,
> +};
> +#define ACPI_GENL_ATTR_MAX (__ACPI_GENL_ATTR_MAX - 1)
> +
> +/* commands supported by the acpi_genl_family */
> +enum {
> + ACPI_GENL_CMD_UNSPEC,
> + ACPI_GENL_CMD_EVENT, /* kernel->user notifications for ACPI events */
> + __ACPI_GENL_CMD_MAX,
> +};
> +#define ACPI_GENL_CMD_MAX (__ACPI_GENL_CMD_MAX - 1)
Shouldn't you put these into some header file instead of copying them
into your userspace tool?
> +#define ACPI_GENL_NAME "acpi_event"
> +#define ACPI_GENL_VERSION 0x01
and maybe those too?
> +/* .doit: standard command callback */
> +static int acpi_genl_cmd_event(struct sk_buff *skb, struct genl_info *info)
> +{
> + struct acpi_genl_event *event = info->userhdr;
> +
> + if (!event)
> + ACPI_DEBUG_PRINT((ACPI_DB_WARN, "ACPI event: NULL\n"));
> +
> + return 0;
> +}
> +
> +static struct genl_ops acpi_event_genl_ops = {
> + .cmd = ACPI_GENL_CMD_EVENT,
> + .doit = acpi_genl_cmd_event,
> +};
This I don't understand, why would userspace ever send events to the
kernel? I think you should just leave this out completely.
> + result =
> + genlmsg_multicast(skb, 0, acpi_event_genl_family.id, GFP_ATOMIC);
If my patches are merged you should now register a multicast group.
Here's how I do it in nl80211 now:
| static struct genl_multicast_group nl80211_config_mcgrp = {
| .name = "config",
| };
during init:
| err = genl_register_mc_group(&nl80211_fam, &nl80211_config_mcgrp);
| if (err)
| goto err_out;
for sending the message:
| genlmsg_multicast(msg, 0, nl80211_config_mcgrp.id, GFP_KERNEL);
(I suppose you want GFP_ATOMIC for a reason)
In userspace you query the new multicast group attribute(s) [but let's
see what Jamal wants me to change there first] and bind to that group
using
| int group = ...;
| setsockopt(s, 270 /*SOL_NETLINK*/, NETLINK_ADD_MEMBERSHIP, &group, sizeof(group));.
johannes
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 190 bytes --]
next prev parent reply other threads:[~2007-07-04 11:37 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-19 3:40 [PATCH] ACPI: export acpi events via generic netlink Zhang Rui
2007-07-03 17:18 ` Johannes Berg [this message]
2007-07-03 19:45 ` Len Brown
2007-07-04 12:01 ` Johannes Berg
2007-07-05 8:24 ` Zhang Rui
2007-07-05 8:35 ` Johannes Berg
2007-07-05 8:54 ` Zhang Rui
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1183483131.4021.8.camel@johannes.berg \
--to=johannes@sipsolutions.net \
--cc=hadi@cyberus.ca \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=rui.zhang@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox