Return-path: Received: from fg-out-1718.google.com ([72.14.220.152]:46453 "EHLO fg-out-1718.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934119Ab0CLSWU (ORCPT ); Fri, 12 Mar 2010 13:22:20 -0500 Date: Fri, 12 Mar 2010 10:22:09 -0800 From: Dmitry Torokhov To: florian@mickler.org Cc: "John W. Linville" , Marcel Holtmann , Henrique de Moraes Holschuh , Johannes Berg , linux-wireless@vger.kernel.org, Randy Dunlap , Alan Jenkins , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org Subject: Re: [PATCH 2/2] enhance sysfs rfkill interface Message-ID: <20100312182209.GB8736@core.coreip.homeip.net> References: <1268416988-24862-1-git-send-email-florian@mickler.org> <1268416988-24862-2-git-send-email-florian@mickler.org> <1268416988-24862-3-git-send-email-florian@mickler.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii In-Reply-To: <1268416988-24862-3-git-send-email-florian@mickler.org> Sender: linux-wireless-owner@vger.kernel.org List-ID: On Fri, Mar 12, 2010 at 07:03:08PM +0100, florian@mickler.org wrote: > > +static ssize_t rfkill_hard_show(struct device *dev, > + struct device_attribute *attr, > + char *buf) > +{ > + struct rfkill *rfkill = to_rfkill(dev); > + unsigned long flags; > + u32 state; > + > + spin_lock_irqsave(&rfkill->lock, flags); > + state = rfkill->state; > + spin_unlock_irqrestore(&rfkill->lock, flags); Why exactly is this lock needed? > + > + return sprintf(buf, "%d\n", (state & RFKILL_BLOCK_HW) ? 1 : 0 ); > +} > + > +static ssize_t rfkill_soft_show(struct device *dev, > + struct device_attribute *attr, > + char *buf) > +{ > + struct rfkill *rfkill = to_rfkill(dev); > + unsigned long flags; > + u32 state; > + > + spin_lock_irqsave(&rfkill->lock, flags); > + state = rfkill->state; > + spin_unlock_irqrestore(&rfkill->lock, flags); And here as well... -- Dmitry