Received: by 10.223.164.221 with SMTP id h29csp3150746wrb; Wed, 18 Oct 2017 13:08:15 -0700 (PDT) X-Received: by 10.159.233.195 with SMTP id b3mr6241182plr.11.1508357294970; Wed, 18 Oct 2017 13:08:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508357294; cv=none; d=google.com; s=arc-20160816; b=kq20n1xFwqEWLLmjsEf2IwfyHaLbie6wj7BZE+Ip29w2f+gCFnxdk7sQs6vSQQw+8B EQ1i2u+sAFdZsY9BTEhcJuMeJt2yXSrgrXkuLMgDMnW0b35h8vizg1X7cZyaIQYunW6M NdW/BZ6L0Rc+Uc4vZ+HdjOi4HKnsFkDiq1zrQ78EljbrvH2VjMxgL+nrwP1Vvl8unYG9 6zZyFrevgBuiSZXoryYXXa7f3L97t+7H5f84Z273356etvHQZz/77K6RGvq0G3c3giOr LZ7w+0EeCExb7Cj3AjGGohi2XYCusUF/8QmBEAH16FnkgLa24tCIfWzLYRuc2gFbGTLg 1fxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=rsZfM9QPiODjm2UacxDWfyOagoxU5fFyGa1ruy+SYYM=; b=sdv2eWXwx+1Y8sK02fwRwR9ct3AHyAL/gRzkqq04R9HYUgbdLr2XwufcBTfZeMsy2B 9TZVl9nNfFRTFTy0mRZSN31crvMVySHh3Jlg6nvyf+LgZDczzrevZxIxAiLJxxkzA1FR 4yy/Oe+F5ybwWmlyryeIJ2AxP2Z/NJ2qbtRSqQEp3ult/M6PYtDryfr0HS5ZMC2kCFs2 /zLlWjdMN0GPn832S7AQvjch7OHNhqeY37PCcLbZKvCSHL+jeJSRpfBYFOtbAAlfAI1z z0dqGtqr6mKglDVGehLGBVZk11GpiYRPXzwmDbc8XPwhnppBhNnwnDWHXB3EvroqNlSz fAbw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h7si7371102pgq.26.2017.10.18.13.08.00; Wed, 18 Oct 2017 13:08:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751110AbdJRUHj (ORCPT + 99 others); Wed, 18 Oct 2017 16:07:39 -0400 Received: from mail-qt0-f193.google.com ([209.85.216.193]:49017 "EHLO mail-qt0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750877AbdJRUHh (ORCPT ); Wed, 18 Oct 2017 16:07:37 -0400 Received: by mail-qt0-f193.google.com with SMTP id f8so11834519qta.5 for ; Wed, 18 Oct 2017 13:07:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=rsZfM9QPiODjm2UacxDWfyOagoxU5fFyGa1ruy+SYYM=; b=HGEeHZvm2B6ePXu5OXc5copCdEITgMHClHTl27ofXG1OIgHezl/h4zqYnqhx+WLCcG w9FsWyMMym/ZaiSt+cvbCfJGlLnw2RG91mmKQ0wA1Enu3E5W11Z8zFFuGgn2TFJMmDyw sKEIPulkclF9doLJDJcXUuuY8hna35KaT+GIpmDsW4DROX+5E5zDTOKbp+/3ogIBy5Xr cSHKAcTaBUWGH0sll4ZInAnHkLDDX1sIZAz532y3vxHaq3apl1zV9xr5yradYDWuM6+H QPmXBr7jif0Aj72XzoC7TcFJhLy4sMqBk92ca6tVUKJv8PTIBvLwEjC6BSaiUWXY2pT6 Y5cg== X-Gm-Message-State: AMCzsaX3jfDr0AywgP/9l8e652Xi4XEDYJCgIkcP5V5FWWR/0eV0YhNr J5L4BqMI2MVrtiYyk4EeALNdxQ== X-Google-Smtp-Source: ABhQp+SYChP4UvnXzjavB1VZwq/c6f6dSbLtHrkvuNAQiGS5nY38m+hTqeIBmGd2sUHKdTaIOXY6Ig== X-Received: by 10.200.33.199 with SMTP id 7mr4877610qtz.35.1508357257161; Wed, 18 Oct 2017 13:07:37 -0700 (PDT) Received: from ?IPv6:2601:602:9802:a8dc::e174? ([2601:602:9802:a8dc::e174]) by smtp.gmail.com with ESMTPSA id 42sm8257768qkx.27.2017.10.18.13.07.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Oct 2017 13:07:36 -0700 (PDT) Subject: Re: [PATCH v5 2/2] staging: ion: create one device entry per heap To: Benjamin Gaignard , sumit.semwal@linaro.org, gregkh@linuxfoundation.org, arve@android.com, riandrews@android.com, broonie@kernel.org, dan.carpenter@oracle.com Cc: devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-api@vger.kernel.org References: <1506518409-16887-1-git-send-email-benjamin.gaignard@linaro.org> <1506518409-16887-3-git-send-email-benjamin.gaignard@linaro.org> From: Laura Abbott Message-ID: Date: Wed, 18 Oct 2017 13:07:33 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <1506518409-16887-3-git-send-email-benjamin.gaignard@linaro.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09/27/2017 06:20 AM, Benjamin Gaignard wrote: > diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c > index 93e2c90..092b24c 100644 > --- a/drivers/staging/android/ion/ion.c > +++ b/drivers/staging/android/ion/ion.c > @@ -40,6 +40,8 @@ > > #include "ion.h" > > +#define ION_DEV_MAX 32 > + > static struct ion_device *internal_dev; > static int heap_id; > > @@ -537,15 +539,28 @@ static int debug_shrink_get(void *data, u64 *val) > DEFINE_SIMPLE_ATTRIBUTE(debug_shrink_fops, debug_shrink_get, > debug_shrink_set, "%llu\n"); > > -void ion_device_add_heap(struct ion_heap *heap) > +int ion_device_add_heap(struct ion_heap *heap) > { > struct dentry *debug_file; > struct ion_device *dev = internal_dev; > + int ret = 0; > > if (!heap->ops->allocate || !heap->ops->free) > pr_err("%s: can not add heap with invalid ops struct.\n", > __func__); > > + if (heap_id >= ION_DEV_MAX) > + return -EBUSY; > + > + heap->ddev.devt = MKDEV(MAJOR(dev->devt), heap_id); > + dev_set_name(&heap->ddev, "ion%d", heap_id); > + device_initialize(&heap->ddev); > + cdev_init(&heap->chrdev, &ion_fops); > + heap->chrdev.owner = THIS_MODULE; > + ret = cdev_device_add(&heap->chrdev, &heap->ddev); > + if (ret < 0) > + return ret; > + > spin_lock_init(&heap->free_lock); > heap->free_list_size = 0; > > @@ -583,6 +598,8 @@ void ion_device_add_heap(struct ion_heap *heap) > > dev->heap_cnt++; > up_write(&dev->lock); > + > + return ret; > } > EXPORT_SYMBOL(ion_device_add_heap); > > @@ -595,6 +612,7 @@ static int ion_device_create(void) > if (!idev) > return -ENOMEM; > > +#ifdef CONFIG_ION_LEGACY_DEVICE_API > idev->dev.minor = MISC_DYNAMIC_MINOR; > idev->dev.name = "ion"; > idev->dev.fops = &ion_fops; > @@ -605,6 +623,17 @@ static int ion_device_create(void) > kfree(idev); > return ret; > } > +#endif > + > + ret = alloc_chrdev_region(&idev->devt, 0, ION_DEV_MAX, "ion"); > + if (ret) { > + pr_err("ion: unable to allocate device\n"); > +#ifdef CONFIG_ION_LEGACY_DEVICE_API > + misc_deregister(&idev->dev); > +#endif > + kfree(idev); > + return ret; > + } > > idev->debug_root = debugfs_create_dir("ion", NULL); > if (!idev->debug_root) { I'm not 100% sure about the device hierarchy here. We're ending up with devices at the root of /sys/devices /sys/devices # ls breakpoint ion0 ion1 ion2 platform software system virtual and the Android init system doesn't pick this up. I'll admit to being out of my area here but I don't think this looks quite right. Thanks, Laura From 1581550082335049712@xxx Tue Oct 17 23:41:33 +0000 2017 X-GM-THRID: 1579699119100728687 X-Gmail-Labels: Inbox,Category Forums