Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754706AbbKYO1m (ORCPT ); Wed, 25 Nov 2015 09:27:42 -0500 Received: from mail-wm0-f42.google.com ([74.125.82.42]:35314 "EHLO mail-wm0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753032AbbKYO1k (ORCPT ); Wed, 25 Nov 2015 09:27:40 -0500 Message-ID: <5655C55A.8040001@lightnvm.io> Date: Wed, 25 Nov 2015 15:27:38 +0100 From: =?UTF-8?B?TWF0aWFzIEJqw7hybGluZw==?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Wenwei Tao CC: linux-kernel@vger.kernel.org, linux-block@vger.kernel.org Subject: Re: [PATCH] lightnvm: missing nvm_lock acquire References: <1448378697-2532-1-git-send-email-ww.tao0320@gmail.com> <5654AE2D.2080802@lightnvm.io> <56559D5C.6090004@lightnvm.io> In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1006 Lines: 29 On 11/25/2015 03:18 PM, Wenwei Tao wrote: > Or we can add a new function > > static struct nvm_dev *nvm_find_nvm_dev_locked(const char *name) > { > struct nvm_dev *dev; > > + down_write(&nvm_lock); > list_for_each_entry(dev, &nvm_devices, devices) > if (!strcmp(name, dev->name)) > return dev; > + up_write(&nvm_lock); > > return NULL; > } > > use nvm_find_nvm_dev_locked() and nvm_find_nvm_dev() properly. > That could also work. Let's go with your original solution. I don't like it completely, but on the other hand. The other iterators build up to the locks in that way. So making a special case for the nvm_find_nvm_dev properly makes the code harder to understand. -- 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/