lkml.org 
[lkml]   [2019]   [Mar]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v4] Drivers: hv: vmbus: Expose monitor data only when monitor pages are used
On Fri, Mar 01, 2019 at 02:18:24PM -0500, Kimberly Brown wrote:
> +/*
> + * Channel-level attribute_group callback function. Returns the permission for
> + * each attribute, and returns 0 if an attribute is not visible.
> + */
> +static umode_t vmbus_chan_attr_is_visible(struct kobject *kobj,
> + struct attribute *attr, int idx)
> +{
> + const struct vmbus_channel *channel =
> + container_of(kobj, struct vmbus_channel, kobj);
> +
> + /* Hide the monitor attributes if the monitor mechanism is not used. */
> + if (!channel->offermsg.monitor_allocated &&
> + (attr == &chan_attr_pending.attr ||
> + attr == &chan_attr_latency.attr ||
> + attr == &chan_attr_monitor_id.attr))
> + return 0;
> +
> + return attr->mode;
> +}
> +
> +static struct attribute_group vmbus_chan_group = {
> + .attrs = vmbus_chan_attrs,
> + .is_visible = vmbus_chan_attr_is_visible
> +};
> +
> static struct kobj_type vmbus_chan_ktype = {
> .sysfs_ops = &vmbus_chan_sysfs_ops,
> .release = vmbus_chan_release,
> - .default_attrs = vmbus_chan_attrs,

Why did you remove this line?

> };
>
> /*
> @@ -1571,6 +1624,12 @@ int vmbus_add_channel_kobj(struct hv_device *dev, struct vmbus_channel *channel)
> if (ret)
> return ret;
>
> + ret = sysfs_create_group(kobj, &vmbus_chan_group);

Why are you adding these "by hand"? What was wrong with using the
default attribute group pointer? You also are not removing the
attributes :(

greg k-h

\
 
 \ /
  Last update: 2019-03-03 09:06    [W:0.169 / U:14.368 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site