Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751921AbdDIFVM (ORCPT ); Sun, 9 Apr 2017 01:21:12 -0400 Received: from mail-it0-f68.google.com ([209.85.214.68]:34582 "EHLO mail-it0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751211AbdDIFVH (ORCPT ); Sun, 9 Apr 2017 01:21:07 -0400 MIME-Version: 1.0 In-Reply-To: References: <58e77955.09c3620a.bb125.3e20@mx.google.com> <20170407154520.GA11575@kroah.com> From: Varsha Rao Date: Sun, 9 Apr 2017 10:50:25 +0530 Message-ID: Subject: Re: [PATCH 5/5] drivers: char: Replace bit operation functions with IDA allocator. To: Matthew Wilcox , Greg Kroah-Hartman , Arnd Bergmann Cc: linux-kernel@vger.kernel.org Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2423 Lines: 70 >> Replace bit operation functions with IDA allocator functions. As IDA >> allocation is simpler. > > But why does this matter? Few of the files in this driver is already using ida allocation. For maintaining the uniformity I have used ida allocation. Files using idr-ida interface hw_random/virtio-rng.c tpm/tpm-chip.c ppdev.c tpm/tpm-interface.c tpm/tpm.h >> if (is_dynamic) { >> - int i = find_first_zero_bit(misc_minors, DYNAMIC_MINORS); >> + int i = ida_simple_get(&misc_minors_ida, 0, >> + DYNAMIC_MINORS, GFP_KERNEL); >> >> if (i >= DYNAMIC_MINORS) { >> err = -EBUSY; >> goto out; >> - } >> + } else if (i < 0) { >> + err = i; >> + goto out; >> + } else { >> misc->minor = DYNAMIC_MINORS - i - 1; >> - set_bit(i, misc_minors); >> + } > > Your indentation is now incorrect :( I don't know but in the patch it has correct indentation as below. - set_bit(i, misc_minors); + } } else { struct miscdevice *c; >> } else { >> struct miscdevice *c; >> >> @@ -222,7 +226,7 @@ int misc_register(struct miscdevice *misc) >> int i = DYNAMIC_MINORS - misc->minor - 1; >> >> if (i < DYNAMIC_MINORS && i >= 0) >> - clear_bit(i, misc_minors); >> + ida_simple_remove(&misc_minors_ida, i); >> misc->minor = MISC_DYNAMIC_MINOR; >> } >> err = PTR_ERR(misc->this_device); >> @@ -258,7 +262,7 @@ void misc_deregister(struct miscdevice *misc) >> list_del(&misc->list); >> device_destroy(misc_class, MKDEV(MISC_MAJOR, misc->minor)); >> if (i < DYNAMIC_MINORS && i >= 0) >> - clear_bit(i, misc_minors); >> + ida_simple_remove(&misc_minors_ida, i); > > As much as I like the ida interface, I don't see why it is required to > use it here, you have not provided any justification for this patch at > all :( Here by the usage of ida interface, allocation will be simpler, faster and more space efficient. Also conversion to it is simple. As I mentioned earlier in this mail also to maintain uniformity of the driver. Thanks, Varsha Rao