Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp3113006pxa; Tue, 18 Aug 2020 07:01:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxH/ZAnDUNvYrspYbXKxXMVAJe9etLWl9eB4IDql2+kU1I2Uvv6KCUbf36lT77UObeq3rU1 X-Received: by 2002:a17:906:5a93:: with SMTP id l19mr19799695ejq.418.1597759290828; Tue, 18 Aug 2020 07:01:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597759290; cv=none; d=google.com; s=arc-20160816; b=iHzVev9CU+/3lW/NoLx673OGQhUon3ENxpWYzW5r6Htptv+EdctFNHfO/HyONr5QAm 7QJxRO9yffBzNtXlkWUk7sffW0J+ou6cDTGIKJQQhp1VGRmFd8D2vUJbnoxv4GxDN5dx DPxj4Ftt94KFv95xvPyl/R6YG3ua52G89FLYsfhNF9R3tKrdIFs1XPY/JKRsZWawcOV0 7qedWR8sA6gTrjPZyY82kFhFL89khBK2AuzZ+/dolpZAJfmCMRjND5z4UsXzMN1f7lmR mCJRr3e1Kcl5PlSc7RloHwRk3xNKUBP1/vbh9I+5jWUl9mc97VvViKeZImMlxuCuWrKV azXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=/oh+BcdsFeBRm7bcoZIVYJ25TsHY2ROrPUeqhFfeYCY=; b=0kIk+Fn8/tKYxCS8wIs5zezF20kvkAL7Pkvn7bYYsMecm+8FH1NQeylKk7ICY6MaCR XAwxyIWozqePGpEHcrS0eKAlFjB+oDcMd+Fcyz2uAxULSJ9ibYkfjMeo6RLKvxQpJps7 LgrAwEJpJkuHnbNbeTXE3BArNqO1CuR42xRhawas4E01BA30lZcBBJPqLJTfGFUfu2UI lZ9NQ0GiyGrsAlWN1E8L9QQbzkdPN3odz40bNFjPjxh6hSSWPeFr4P01uB1zngLPVikj awdmRsx3dkuGO/utM96CFG1K2CcrY0jNAubtCdbcygFfcA25un1BJZ6GWhsoqSHxSKMk sJWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=rPsGsqpB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t21si13677065edi.213.2020.08.18.07.01.06; Tue, 18 Aug 2020 07:01:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=rPsGsqpB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726783AbgHROAM (ORCPT + 99 others); Tue, 18 Aug 2020 10:00:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726482AbgHROAJ (ORCPT ); Tue, 18 Aug 2020 10:00:09 -0400 Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26825C061389; Tue, 18 Aug 2020 07:00:09 -0700 (PDT) Received: by mail-pj1-x1042.google.com with SMTP id 2so9440566pjx.5; Tue, 18 Aug 2020 07:00:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=/oh+BcdsFeBRm7bcoZIVYJ25TsHY2ROrPUeqhFfeYCY=; b=rPsGsqpBlwfOIi1dDqvsJIViRe2mzwhb1+n7f2Ez6TWD9FWEPhZD1teu6GGT/YEKBk xX4n3EmeK6UC0cHa/PILAC66FWHopAqt2WOCYoOr99kUGIgFgd5KwcpAspg5l9jBkhT6 B6suQg6iPopeT5V5p06r+MH6K6uWfU+HxcWh+CF+qIQcsPoJW3z7/519xtBzwq/KnjgB 1KxnywCbY7qdOpJOrFG/3olaE31TWk/146VsMQCZlHS8BLacEsZkOEQxBSDxDTRlymlX VVboTuvAuIUNTEii9Y85xPOBan44+nD+pwnfRccdua5gFLOs78zSgnmOSsfEL3aNJ9Xm 6JjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=/oh+BcdsFeBRm7bcoZIVYJ25TsHY2ROrPUeqhFfeYCY=; b=EaViUmdHBHTm5PqV0JI1oOVSk0emb6zePqnEBL13cGnIdhy9o/qIUiwlGvpuG+6qVO CfPyd6TbJnYrjRX59c7UmSNGpH4CTo6D1BSBh36SMSLJ9tU9mXnQeZeDwXmir8eMsRvy /DCS9/jZRJmBeHffaYlwudxnWHGW7fGDlkHcl6sTZKfvqe0XZsvHjh26jDlg9KRuPPHj 1zH5AM+DtwS7LeIm1iafNuQwnO59XPaQZczVCkqNHkmWHsY7U6ubyOaLNXrZZ3dotHId W15Pqg0VXgm4r90VTGNfJ+5/iqzDQCfyUNCfW1Wrgqeae5nVUOCkDAryRgdrLxCQmIFU 5+7w== X-Gm-Message-State: AOAM532dm2pM9ZJBmtm85BkP9vhsxhMyMFbw59Lzr42rX5n2YR70BBsk ifcN0SqvgRmpNGgrPSuv3pGt0pMwHsY= X-Received: by 2002:a17:90a:fe91:: with SMTP id co17mr79426pjb.103.1597759208613; Tue, 18 Aug 2020 07:00:08 -0700 (PDT) Received: from sol (106-69-184-100.dyn.iinet.net.au. [106.69.184.100]) by smtp.gmail.com with ESMTPSA id w82sm25275749pff.7.2020.08.18.07.00.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Aug 2020 07:00:07 -0700 (PDT) Date: Tue, 18 Aug 2020 22:00:02 +0800 From: Kent Gibson To: Bartosz Golaszewski Cc: LKML , linux-gpio , Linus Walleij Subject: Re: [PATCH v4 09/20] gpiolib: cdev: support edge detection for uAPI v2 Message-ID: <20200818140002.GA17809@sol> References: <20200814030257.135463-1-warthog618@gmail.com> <20200814030257.135463-10-warthog618@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Aug 16, 2020 at 04:32:34PM +0200, Bartosz Golaszewski wrote: > On Fri, Aug 14, 2020 at 5:04 AM Kent Gibson wrote: > > > > Add support for edge detection to lines requested using > > GPIO_V2_GET_LINE_IOCTL. > > [snip] > > > > + /* event_buffer_size only valid with edge detection */ > > + has_edge_detection = gpio_v2_line_config_has_edge_detection(lc); > > + if (lr.event_buffer_size && !has_edge_detection) > > + return -EINVAL; > > + > > line = kzalloc(struct_size(line, descs, lr.num_lines), > > GFP_KERNEL); > > if (!line) > > @@ -666,6 +944,16 @@ static int line_create(struct gpio_device *gdev, void __user *ip) > > line->gdev = gdev; > > get_device(&gdev->dev); > > > > + line->edets = kcalloc(lr.num_lines, sizeof(*line->edets), > > + GFP_KERNEL); > > You're allocating num_lines of edge detectors even if only certain > lines have edge detection (via attributes). I don't like it but it > made me think about struct line. How about having struct line which > actually only represents a single line (and it contains the relevant > gpio_desc pointer as well as the associated edge detector and any > other data only relevant for this line) and a set of lines would be > aggregated in struct line_request or line_request_data which would > additionally contain common fields? Does that even make sense? > You are right, and it makes total sense. I'm not totally thrilled with the block allocation either, but an earlier draft with edge detectors/debouncers created and destroyed as required resulted in complicated lifecycle management that this approach avoids. I'll have a look at restructuring it as you suggest. The only downside that springs to mind is that the gpiolib API expects a desc array, which we'll no longer have handy, so it would have to be built on the fly as per the sparse gets/sets. Cheers, Kent.