From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756738AbbDWEaK (ORCPT ); Thu, 23 Apr 2015 00:30:10 -0400 Received: from mail-pd0-f180.google.com ([209.85.192.180]:33892 "EHLO mail-pd0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751000AbbDWEaH (ORCPT ); Thu, 23 Apr 2015 00:30:07 -0400 Date: Thu, 23 Apr 2015 13:30:22 +0900 From: Sergey Senozhatsky To: Minchan Kim Cc: Sergey Senozhatsky , Andrew Morton , Nitin Gupta , linux-kernel@vger.kernel.org, Sergey Senozhatsky Subject: Re: [PATCHv2 03/10] zram: use idr instead of `zram_devices' array Message-ID: <20150423043022.GE724@swordfish> References: <1429185356-11096-1-git-send-email-sergey.senozhatsky@gmail.com> <1429185356-11096-4-git-send-email-sergey.senozhatsky@gmail.com> <20150423022358.GB24928@blaptop> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150423022358.GB24928@blaptop> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On (04/23/15 11:23), Minchan Kim wrote: [..] > > +static int zram_exit_cb(int id, void *ptr, void *data) > > trivial: I prefer remove to exit. > ok. > > +{ > > + zram_remove(ptr); > > + return 0; > > +} > > > > - kfree(zram_devices); > > +static void destroy_devices(void) > > +{ > > + idr_for_each(&zram_index_idr, &zram_exit_cb, NULL); > > + idr_destroy(&zram_index_idr); > > unregister_blkdev(zram_major, "zram"); > > - pr_info("Destroyed %u device(s)\n", nr); > > + pr_info("Destroyed device(s)\n"); > > } > > > > static int __init zram_init(void) > > @@ -1283,16 +1302,9 @@ static int __init zram_init(void) > > return -EBUSY; > > } > > > > - /* Allocate the device array and initialize each one */ > > - zram_devices = kzalloc(num_devices * sizeof(struct zram), GFP_KERNEL); > > - if (!zram_devices) { > > - unregister_blkdev(zram_major, "zram"); > > - return -ENOMEM; > > - } > > - > > for (dev_id = 0; dev_id < num_devices; dev_id++) { > > - ret = create_device(&zram_devices[dev_id], dev_id); > > - if (ret) > > + ret = zram_add(dev_id); > > + if (ret != 0) > > It's better to check ret < 0 rather than ret != 0. > yes, it's for (dev_id = 0; dev_id < num_devices; dev_id++) { mutex_lock(&zram_index_mutex); ret = zram_add(dev_id); mutex_unlock(&zram_index_mutex); if (ret < 0) goto out_error; } at the end of the patch set. will clean up everything and resubmit after the merge window, next week. thanks! -ss > Otherwise, > Acked-by: Minchan Kim > > -- > Kind regards, > Minchan Kim >