From patchwork Wed Aug 2 10:29:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhumika Goyal X-Patchwork-Id: 9876593 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7F9D760360 for ; Wed, 2 Aug 2017 10:30:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 728592871C for ; Wed, 2 Aug 2017 10:30:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 65DBE287A3; Wed, 2 Aug 2017 10:30:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0642B2871C for ; Wed, 2 Aug 2017 10:30:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752100AbdHBKaR (ORCPT ); Wed, 2 Aug 2017 06:30:17 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:37377 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751997AbdHBKaQ (ORCPT ); Wed, 2 Aug 2017 06:30:16 -0400 Received: by mail-pf0-f195.google.com with SMTP id p13so2117299pfd.4; Wed, 02 Aug 2017 03:30:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=K3twZOXQBBgBDpgVOwP6WlEY3/1v9m99JuUzY3J+4No=; b=uyvyoANjeRcP5ntil7hxtTTQqbpIFX9TC5VMh2/vE9X6mz7KwM+p00q6pCC7vdQ5Iu Vm9k2oUERDD+0o9Q+ruoZwcWoW6Uz+c7Ft8B11OQ4I/26mcWpUxRN6V4SWcQBQzhObqh Je+5ZPta0diCipAalj76/NwJCBP0SThFrVw76UW89V1mDzvc3xj0ragzlZcbGYXPMFwN +AV5ENFLFhTS8V3g2DevqHA9fhT71nGr3P+NXUvg0jHg1WiP6c197xCTjb+Su7/aghTe p+LlzA2DarZrwjKqD3PJOCaWKL7to1M37MrL9kBfjQBwtrE9twxkQ5N98Wwy8509Yyca SkdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=K3twZOXQBBgBDpgVOwP6WlEY3/1v9m99JuUzY3J+4No=; b=EjKtmddPnTssvP9EPzwEf0SntE8JatQZvSf7J0iAKVX7gXK2seKR07mmlKdubPQ519 tpO72jX28vYqkArT9+HRbvyLZhXJTpF4IomGuElK/9ciq1UKHvodvEd9Qso1qSUmcWdv BK3VCR/k2iS4OEG/Xqa8fOZcUFVk9aSqcIMrQ1bLPPoPcEaE//Ixf/KnDguhuVfa1exy tvQJ9ZCWHrc3kikT6xwt9PSZWgbBlfTW5nZf40Eyxk/KSMYJo6cd3LeoiQ0TeibR94Hs tfxiMkTxJS1/tLHdT8rOD1GYMXABZYQ/Y2hky8w1x++chs+eOiBxyASvYuPDCOD/JgjA GAzQ== X-Gm-Message-State: AIVw112p/IeX6InGhEa+otP23133qf9KnNl9fGI/CVEq2ibCiLZPeTlQ iBWG6V31GkTDDA== X-Received: by 10.99.126.86 with SMTP id o22mr21730855pgn.382.1501669816189; Wed, 02 Aug 2017 03:30:16 -0700 (PDT) Received: from gmail.com ([117.196.126.40]) by smtp.gmail.com with ESMTPSA id s14sm63993486pgo.14.2017.08.02.03.30.05 (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 02 Aug 2017 03:30:15 -0700 (PDT) Received: by gmail.com (sSMTP sendmail emulation); Wed, 02 Aug 2017 15:59:56 +0530 From: Bhumika Goyal To: julia.lawall@lip6.fr, sre@kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Bhumika Goyal Subject: [PATCH] power: add const to bin_attribute structures Date: Wed, 2 Aug 2017 15:59:38 +0530 Message-Id: <1501669778-25033-1-git-send-email-bhumirks@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add const to bin_attribute structures as they are only passed to the functions sysfs_{remove/create}_bin_file or device_{remove/create}_bin_file. The corresponding parameters 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={...}; Same script was modified for device_{create/remove}_bin_file functions. Signed-off-by: Bhumika Goyal --- Could not find an architecture to cross compile olpc_battery.o file. drivers/power/supply/ds2780_battery.c | 4 ++-- drivers/power/supply/ds2781_battery.c | 4 ++-- drivers/power/supply/olpc_battery.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/power/supply/ds2780_battery.c b/drivers/power/supply/ds2780_battery.c index 8edd4aa..e5d81b4 100644 --- a/drivers/power/supply/ds2780_battery.c +++ b/drivers/power/supply/ds2780_battery.c @@ -663,7 +663,7 @@ static ssize_t ds2780_write_param_eeprom_bin(struct file *filp, return count; } -static struct bin_attribute ds2780_param_eeprom_bin_attr = { +static const struct bin_attribute ds2780_param_eeprom_bin_attr = { .attr = { .name = "param_eeprom", .mode = S_IRUGO | S_IWUSR, @@ -708,7 +708,7 @@ static ssize_t ds2780_write_user_eeprom_bin(struct file *filp, return count; } -static struct bin_attribute ds2780_user_eeprom_bin_attr = { +static const struct bin_attribute ds2780_user_eeprom_bin_attr = { .attr = { .name = "user_eeprom", .mode = S_IRUGO | S_IWUSR, diff --git a/drivers/power/supply/ds2781_battery.c b/drivers/power/supply/ds2781_battery.c index 4400402..efe83ef 100644 --- a/drivers/power/supply/ds2781_battery.c +++ b/drivers/power/supply/ds2781_battery.c @@ -665,7 +665,7 @@ static ssize_t ds2781_write_param_eeprom_bin(struct file *filp, return count; } -static struct bin_attribute ds2781_param_eeprom_bin_attr = { +static const struct bin_attribute ds2781_param_eeprom_bin_attr = { .attr = { .name = "param_eeprom", .mode = S_IRUGO | S_IWUSR, @@ -711,7 +711,7 @@ static ssize_t ds2781_write_user_eeprom_bin(struct file *filp, return count; } -static struct bin_attribute ds2781_user_eeprom_bin_attr = { +static const struct bin_attribute ds2781_user_eeprom_bin_attr = { .attr = { .name = "user_eeprom", .mode = S_IRUGO | S_IWUSR, diff --git a/drivers/power/supply/olpc_battery.c b/drivers/power/supply/olpc_battery.c index 9e29b13..fc20ca3 100644 --- a/drivers/power/supply/olpc_battery.c +++ b/drivers/power/supply/olpc_battery.c @@ -535,7 +535,7 @@ static ssize_t olpc_bat_eeprom_read(struct file *filp, struct kobject *kobj, return count; } -static struct bin_attribute olpc_bat_eeprom = { +static const struct bin_attribute olpc_bat_eeprom = { .attr = { .name = "eeprom", .mode = S_IRUGO,