Received: by 10.223.164.221 with SMTP id h29csp2490914wrb; Mon, 23 Oct 2017 08:20:05 -0700 (PDT) X-Received: by 10.98.17.7 with SMTP id z7mr13463947pfi.206.1508772005802; Mon, 23 Oct 2017 08:20:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508772005; cv=none; d=google.com; s=arc-20160816; b=TfUkHlpleverFEJJrWjknaPTxmPGrrloIo5gue1Jvn9B1B+1zZan2led0tVXeLrcxj 63VBCb0bRz4ZTDIaLXTnqnnKf8SCGDEROJgzdAq1EBOQXlPfNXt18OBwWNc0fob1FQWg Pph/IbjY4CaClnjMZXqM31f9ByHxmpMNJOFUoLIpUSfvDMdUnmcNshwiSdeCdfOmpfGg xoEeFwGREup49uHLWUifP7/fq2LF9bll4I0h+xkT3LePExf7DhqZTD4ofsOSKqd3C3TD U+urqIXFea/85s5yRnzaCpg1tymhFXNni1Obm2wuwV66qZncsw74v0Agtz1IR26S/T2p U2yg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=Itwa+GFrVJY0FrNw51Iapb6RdNb9u/M4ABVoOmFMSeg=; b=uCi6huaiAiF4copFzNoBtfutkl/wWEC2FB/udITDkcofMVJPGujd80kcgYQ/7PceDz 8vMr5K2TwPW/es+2eN+naCtUxottLUba0he4PriivMH7h584d83o80ees6A8tKW75RxH vUeVaEdAFqzlhsCLy19+UcU1DFTtlKyp0XRtZ1bMxdI5d5eVKs3XCboBJxojyKtPwWqR WDtv7qbhN2YSAQLJ0bpzFtYBQJ68hwLA1DFb1YKImK5MeND925JnEG7MvzAJFUeib9ai dNHUb7rPgGJT3wCYlmUJtwS9YTQoakihpZX9ODB/oJhbGis2y86WGDxjxExjxitD7ULW IcNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GwqaLNAn; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z7si5467082pfk.378.2017.10.23.08.19.50; Mon, 23 Oct 2017 08:20:05 -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; dkim=pass header.i=@linaro.org header.s=google header.b=GwqaLNAn; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932166AbdJWPT2 (ORCPT + 99 others); Mon, 23 Oct 2017 11:19:28 -0400 Received: from mail-qk0-f195.google.com ([209.85.220.195]:47943 "EHLO mail-qk0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751280AbdJWPT0 (ORCPT ); Mon, 23 Oct 2017 11:19:26 -0400 Received: by mail-qk0-f195.google.com with SMTP id m189so22362635qke.4 for ; Mon, 23 Oct 2017 08:19:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=Itwa+GFrVJY0FrNw51Iapb6RdNb9u/M4ABVoOmFMSeg=; b=GwqaLNAn0DMfHdKpiZZ4MA8eZZuO4hxnBQQGlHUiqGrT9+39aKAKx4c0xnOfehQNed xzfkJh7IdEbLTc8LzVjurCbvjqOYbmUgzv1EhS7fQ/uEIdvz1HJDOJV2BTGeci5nt1rB wNVjyJGxa0THBurGBdJjr2vYE98wdm6mbxsP4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=Itwa+GFrVJY0FrNw51Iapb6RdNb9u/M4ABVoOmFMSeg=; b=ZjwQj4HLzCweZs9s5LXlr94fmF7w+ipNgiQLNurDpco8tANaRUiyuDrkfaLheF1tR7 MaWN3Uxu1moVG2UYuYZ54wUNokFI4NdpVJJnAp6QfRwFieAFRqJpiLaGPq8E13bHp2ln JXLhW9v+TLURWosIi0nBAir4E4LUU0fUDsQDtHoHDCOwNEfohDIDFcrPEU3j8hMEJW55 NCYCClvd4uJvrFxwF/47Sq3hUA7rpL5fhIifKw4AWiKo6ezANrNttafhOuDjtyr/zXGD 2KKB65V//o4jB4Ba0U51bCaFWmSs3z+Un67ZNSUyPT4nyAApI9m1nmOq8VKzKqczx7Gi cabg== X-Gm-Message-State: AMCzsaWprfS8keiqMftpEZkDj9gtBuPNOr6bz8tbEQgtcUjzVTXf8+zC TmjQeSVrcT3ofkIKxeRsezYY2rghbREd8rU96oQ/Jg== X-Google-Smtp-Source: ABhQp+SJhtc1RPqYMMtChZVZvEI7h90ijF2LHp1511BlZqMsGo8m+Y52TgTxToeiQuShk3kIS0AZhwl+rHH1JK36YHw= X-Received: by 10.55.137.198 with SMTP id l189mr20304310qkd.169.1508771965571; Mon, 23 Oct 2017 08:19:25 -0700 (PDT) MIME-Version: 1.0 Received: by 10.140.88.101 with HTTP; Mon, 23 Oct 2017 08:19:24 -0700 (PDT) In-Reply-To: References: <1506518409-16887-1-git-send-email-benjamin.gaignard@linaro.org> <1506518409-16887-3-git-send-email-benjamin.gaignard@linaro.org> From: Benjamin Gaignard Date: Mon, 23 Oct 2017 17:19:24 +0200 Message-ID: Subject: Re: [PATCH v5 2/2] staging: ion: create one device entry per heap To: Laura Abbott Cc: Sumit Semwal , Greg Kroah-Hartman , =?UTF-8?B?QXJ2ZSBIasO4bm5ldsOlZw==?= , Riley Andrews , Mark Brown , Dan Carpenter , driverdevel , Linux Kernel Mailing List , "dri-devel@lists.freedesktop.org" , linux-api@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 2017-10-18 22:07 GMT+02:00 Laura Abbott : > 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. > You are right it is because ion devices are parentless so they directly put under /sys/devices directory. I will give them platform_bus as parent to solve that problem. Benjamin > Thanks, > Laura > > From 1581627258926043765@xxx Wed Oct 18 20:08:14 +0000 2017 X-GM-THRID: 1579699119100728687 X-Gmail-Labels: Inbox,Category Forums