qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Bhumika Goyal <bhumirks@gmail.com>
Cc: julia.lawall@lip6.fr, somlo@cmu.edu,
	linux-kernel@vger.kernel.org, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] firmware: add const to bin_attribute structures
Date: Thu, 3 Aug 2017 00:28:10 +0300	[thread overview]
Message-ID: <20170803002709-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <1501663295-18774-1-git-send-email-bhumirks@gmail.com>

On Wed, Aug 02, 2017 at 02:11:35PM +0530, Bhumika Goyal wrote:
> Add const to bin_attribute structures as they are only passed to the
> functions sysfs_{remove/create}_bin_file. The arguments passed are of
> type const, so declare the structures to be const.
> 
> Done using Coccinelle.
> 
> @m disable optional_qualifier@
> identifier s;
> position p;
> @@
> static struct bin_attribute s@p={...};
> 
> @okay1@
> position p;
> identifier m.s;
> @@
> (
> sysfs_create_bin_file(...,&s@p,...)
> |
> sysfs_remove_bin_file(...,&s@p,...)
> )
> 
> @bad@
> position p!={m.p,okay1.p};
> identifier m.s;
> @@
> s@p
> 
> @change depends on !bad disable optional_qualifier@
> identifier m.s;
> @@
> static
> +const
> struct bin_attribute s={...};
> 
> Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>

For qemu bits:

Acked-by: Michael S. Tsirkin <mst@redhat.com>

Feel free to merge.,

> ---
>  drivers/firmware/dell_rbu.c          | 6 +++---
>  drivers/firmware/dmi-sysfs.c         | 2 +-
>  drivers/firmware/google/gsmi.c       | 2 +-
>  drivers/firmware/google/memconsole.c | 2 +-
>  drivers/firmware/qemu_fw_cfg.c       | 2 +-
>  5 files changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/firmware/dell_rbu.c b/drivers/firmware/dell_rbu.c
> index 2f452f1..a771360 100644
> --- a/drivers/firmware/dell_rbu.c
> +++ b/drivers/firmware/dell_rbu.c
> @@ -675,18 +675,18 @@ static ssize_t write_rbu_packet_size(struct file *filp, struct kobject *kobj,
>  	return count;
>  }
>  
> -static struct bin_attribute rbu_data_attr = {
> +static const struct bin_attribute rbu_data_attr = {
>  	.attr = {.name = "data", .mode = 0444},
>  	.read = read_rbu_data,
>  };
>  
> -static struct bin_attribute rbu_image_type_attr = {
> +static const struct bin_attribute rbu_image_type_attr = {
>  	.attr = {.name = "image_type", .mode = 0644},
>  	.read = read_rbu_image_type,
>  	.write = write_rbu_image_type,
>  };
>  
> -static struct bin_attribute rbu_packet_size_attr = {
> +static const struct bin_attribute rbu_packet_size_attr = {
>  	.attr = {.name = "packet_size", .mode = 0644},
>  	.read = read_rbu_packet_size,
>  	.write = write_rbu_packet_size,
> diff --git a/drivers/firmware/dmi-sysfs.c b/drivers/firmware/dmi-sysfs.c
> index d5de6ee..936e656 100644
> --- a/drivers/firmware/dmi-sysfs.c
> +++ b/drivers/firmware/dmi-sysfs.c
> @@ -440,7 +440,7 @@ static ssize_t dmi_sel_raw_read(struct file *filp, struct kobject *kobj,
>  	return find_dmi_entry(entry, dmi_sel_raw_read_helper, &state);
>  }
>  
> -static struct bin_attribute dmi_sel_raw_attr = {
> +static const struct bin_attribute dmi_sel_raw_attr = {
>  	.attr = {.name = "raw_event_log", .mode = 0400},
>  	.read = dmi_sel_raw_read,
>  };
> diff --git a/drivers/firmware/google/gsmi.c b/drivers/firmware/google/gsmi.c
> index c8f169b..1ad29f7 100644
> --- a/drivers/firmware/google/gsmi.c
> +++ b/drivers/firmware/google/gsmi.c
> @@ -508,7 +508,7 @@ static ssize_t eventlog_write(struct file *filp, struct kobject *kobj,
>  
>  }
>  
> -static struct bin_attribute eventlog_bin_attr = {
> +static const struct bin_attribute eventlog_bin_attr = {
>  	.attr = {.name = "append_to_eventlog", .mode = 0200},
>  	.write = eventlog_write,
>  };
> diff --git a/drivers/firmware/google/memconsole.c b/drivers/firmware/google/memconsole.c
> index 166f07c..b11a02c 100644
> --- a/drivers/firmware/google/memconsole.c
> +++ b/drivers/firmware/google/memconsole.c
> @@ -33,7 +33,7 @@ static ssize_t memconsole_read(struct file *filp, struct kobject *kobp,
>  	return memconsole_read_func(buf, pos, count);
>  }
>  
> -static struct bin_attribute memconsole_bin_attr = {
> +static const struct bin_attribute memconsole_bin_attr = {
>  	.attr = {.name = "log", .mode = 0444},
>  	.read = memconsole_read,
>  };
> diff --git a/drivers/firmware/qemu_fw_cfg.c b/drivers/firmware/qemu_fw_cfg.c
> index 0e20116..f254977 100644
> --- a/drivers/firmware/qemu_fw_cfg.c
> +++ b/drivers/firmware/qemu_fw_cfg.c
> @@ -343,7 +343,7 @@ static ssize_t fw_cfg_sysfs_read_raw(struct file *filp, struct kobject *kobj,
>  	return count;
>  }
>  
> -static struct bin_attribute fw_cfg_sysfs_attr_raw = {
> +static const struct bin_attribute fw_cfg_sysfs_attr_raw = {
>  	.attr = { .name = "raw", .mode = S_IRUSR },
>  	.read = fw_cfg_sysfs_read_raw,
>  };
> -- 
> 1.9.1

      reply	other threads:[~2017-08-02 21:28 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-02  8:41 [Qemu-devel] [PATCH] firmware: add const to bin_attribute structures Bhumika Goyal
2017-08-02 21:28 ` Michael S. Tsirkin [this message]

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=20170803002709-mutt-send-email-mst@kernel.org \
    --to=mst@redhat.com \
    --cc=bhumirks@gmail.com \
    --cc=julia.lawall@lip6.fr \
    --cc=linux-kernel@vger.kernel.org \
    --cc=qemu-devel@nongnu.org \
    --cc=somlo@cmu.edu \
    /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;
as well as URLs for NNTP newsgroup(s).