Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965102AbbD0SZP (ORCPT ); Mon, 27 Apr 2015 14:25:15 -0400 Received: from mail-wi0-f172.google.com ([209.85.212.172]:37807 "EHLO mail-wi0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964867AbbD0SZJ convert rfc822-to-8bit (ORCPT ); Mon, 27 Apr 2015 14:25:09 -0400 Subject: Re: [PATCH v3 2/4] of: overlay: global sysfs enable attribute Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2098\)) Content-Type: text/plain; charset=utf-8 From: Pantelis Antoniou In-Reply-To: <20150424203619.GC14970@kroah.com> Date: Mon, 27 Apr 2015 21:25:03 +0300 Cc: Rob Herring , Grant Likely , Andrew Morton , Matt Porter , Koen Kooi , Guenter Roeck , devicetree@vger.kernel.org, Linux Kernel Mailing List , linux-api@vger.kernel.org Content-Transfer-Encoding: 8BIT Message-Id: <9F31828D-016A-4C01-A75D-DF9891DE417A@konsulko.com> References: <1429868744-19863-1-git-send-email-pantelis.antoniou@konsulko.com> <1429868744-19863-3-git-send-email-pantelis.antoniou@konsulko.com> <20150424203619.GC14970@kroah.com> To: Greg KH X-Mailer: Apple Mail (2.2098) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2093 Lines: 69 Hi Greg, > On Apr 24, 2015, at 23:36 , Greg KH wrote: > > On Fri, Apr 24, 2015 at 12:45:42PM +0300, Pantelis Antoniou wrote: >> A throw once master enable switch to protect against any >> further overlay applications if the administrator desires so. >> >> Signed-off-by: Pantelis Antoniou >> --- >> drivers/of/overlay.c | 45 ++++++++++++++++++++++++++++++++++++++++++++- >> 1 file changed, 44 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/of/overlay.c b/drivers/of/overlay.c >> index f17f5ef..c335809 100644 >> --- a/drivers/of/overlay.c >> +++ b/drivers/of/overlay.c >> @@ -21,6 +21,7 @@ >> #include >> #include >> #include >> +#include >> >> #include "of_private.h" >> >> @@ -55,8 +56,12 @@ struct of_overlay { >> struct kobject kobj; >> }; >> >> +/* master enable switch; once set to 0 can't be re-enabled */ >> +static atomic_t ov_enable = ATOMIC_INIT(1); >> + >> static int of_overlay_apply_one(struct of_overlay *ov, >> struct device_node *target, const struct device_node *overlay); >> +static int overlay_removal_is_ok(struct of_overlay *ov); >> >> static int of_overlay_apply_single_property(struct of_overlay *ov, >> struct device_node *target, struct property *prop) >> @@ -339,6 +344,37 @@ void of_overlay_release(struct kobject *kobj) >> kfree(ov); >> } >> >> +static ssize_t enable_show(struct kobject *kobj, >> + struct kobj_attribute *attr, char *buf) >> +{ >> + return snprintf(buf, PAGE_SIZE, "%d\n", atomic_read(&ov_enable)); >> +} >> + >> +static ssize_t enable_store(struct kobject *kobj, >> + struct kobj_attribute *attr, const char *buf, size_t count) >> +{ >> + int ret; >> + long new_enable; >> + >> + ret = kstrtol(buf, 10, &new_enable); > > strtobool()? OK Regards — Pantelis -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/