Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1629644pxb; Thu, 4 Mar 2021 16:56:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJzrduaUbeb7kkqCKG7DFomJD6Ij3DpvZiIUbGHUNph11iVL5s1yxhfAAYjtuY8IzIfGyHmF X-Received: by 2002:a02:3ec7:: with SMTP id s190mr7007389jas.11.1614905805846; Thu, 04 Mar 2021 16:56:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614905805; cv=none; d=google.com; s=arc-20160816; b=e89ZJbBUDKsKClyjlecvNZoe/Aoph/RuW03i34GSQQgKnQckreSa7rjFgKJwLKtjz5 hTQCQwJgkGhKjkavc5fk8OBMHgA9kWQzWSjCZ724d9vDTAoblfGKrY3ns/yesCtOYk6O 8X3vpHPVizMwFdo8RpSMJszgQNkCHr1eyi1fC+/jLyZK4Ecbv71uYqEth6lZSZ+ZAUe/ MW2K6gRMTT4fbxJC0vEmh9oeXrzLL6QbhF6+rfhhs6E7nuhC47+E0/ptvJ34A2s3SOzT S5uJga0D0Bu/wnAUENLygPcOZNiGALfP+reU+yv6j1YSq8tlEoucRRovhzVWwHmv6UIv kPQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=w5jLuTPwmQtRh5LkNxQ0rgOEhjoPWcJ+o8G/ZVzu4EU=; b=wWsvO341oiwUWtosfpWid/R218J/K2dUolTshfRNjX1ZlrTBGbepyFGqIbpB4D4KNK Bq423s6ZsEjwUCHwjXoW0wGh+Ow+XZM/jVysnXrYcCtsMchAfneTMmtYo/lHDZBy60Pq q5joIeG3mu3YzxuFA7BiXkb0X0CMl+k810GJBOqpvy2VUc5i67ywfHSSHor82aZe6l7F fUqQMSfX+p3wpbfVssIV8l6lV7OAy+/attoNWlxKnZ8C+4VitOfWfx1T3DJXGrdPM4h0 l7nDWYrWgDrnJu0qSCxhTqDrldawhqU1VnxCcPrgO6ioMAU7B/JDBK9MvimIrQXg9oVh /jyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=RY7ZjM39; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z9si848536ior.7.2021.03.04.16.56.32; Thu, 04 Mar 2021 16:56:45 -0800 (PST) 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=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=RY7ZjM39; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237483AbhCDUQx (ORCPT + 99 others); Thu, 4 Mar 2021 15:16:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238428AbhCDUQW (ORCPT ); Thu, 4 Mar 2021 15:16:22 -0500 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6E39C06175F for ; Thu, 4 Mar 2021 12:15:41 -0800 (PST) Received: by mail-ed1-x52a.google.com with SMTP id p1so32168378edy.2 for ; Thu, 04 Mar 2021 12:15:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=w5jLuTPwmQtRh5LkNxQ0rgOEhjoPWcJ+o8G/ZVzu4EU=; b=RY7ZjM39neNt3ha6ii8uWFcQxr80X5YMwMUA0Ejq7ZGnIXSjRA/JXlAOahRjyCQBIH 8XD714pj5JMyrz/3SxcmOxxe6Uy6Q+a0m0782DT4l2BUxpWGRaglT2myg3EU/TnsVVES 3MejCu+RDHyUXgOCFczHYp3vNzDaLnEakeyOlGHx17JsOjPkBY1hcwD4acqJVhIapfpJ r2XEV0fGZu284sk++Ba93oXDdnWTXKlvEcInRkMoIKA13kE1jvsewnVdsA+MOQzE6LQM 3/lMiG4vUpZ88UWLKA5VQyF4pBMzeR9SgJeMxZPDtdEA9gcSVY3NFf5tHUqORB2IlJR3 axBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=w5jLuTPwmQtRh5LkNxQ0rgOEhjoPWcJ+o8G/ZVzu4EU=; b=MG2bNA++Ti/4/8uGwPbYBBBnANqhI54Wk2nfg4Odlh8xJ/4zRHv4iGuZvLR0f80Tcv DgFDoV4YDz3bp5vZIIGjsZCWTJG8u3TalQv3tpfdncaHrM5PnVvYaZztRwQye4eUuJaj K+UhmoM+gNFQXHqdwuIRFahsPBEIhY5CbgsL73VKSGZ4Ax973wHm6SV3tubCj40V2WJ7 2QLGCkN6Ohj0S+/oRYC2VJH8tdSjIUO62DPYoPBuwQuwoTx9d7e3+SapHDQaRaYv4qaK HNe5f25R+KmodqSGWIjcVxLMGNLsvsO6uOZtynR1atZqdpSQGYv4NUaMc+I8djZI/euU cYXQ== X-Gm-Message-State: AOAM53126wTtInCTQNloaqhfuWV3j7oB2Ze42Xag6hC2rdeY9jw5sc/V 4DDtmQFJPeduc1TIq5AYQWsjUC4POkjcCS85f3xCDA== X-Received: by 2002:a50:ee05:: with SMTP id g5mr6420181eds.164.1614888940442; Thu, 04 Mar 2021 12:15:40 -0800 (PST) MIME-Version: 1.0 References: <20210304102452.21726-1-brgl@bgdev.pl> <20210304102452.21726-10-brgl@bgdev.pl> In-Reply-To: From: Bartosz Golaszewski Date: Thu, 4 Mar 2021 21:15:29 +0100 Message-ID: Subject: Re: [PATCH v2 09/12] gpio: sim: new testing module To: Andy Shevchenko Cc: Joel Becker , Christoph Hellwig , Shuah Khan , Linus Walleij , =?UTF-8?Q?Uwe_Kleine=2DK=C3=B6nig?= , Geert Uytterhoeven , Kent Gibson , Jonathan Corbet , "open list:GPIO SUBSYSTEM" , Linux Kernel Mailing List , linux-doc , Bartosz Golaszewski Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 4, 2021 at 2:15 PM Andy Shevchenko wrote: > > On Thu, Mar 04, 2021 at 11:24:49AM +0100, Bartosz Golaszewski wrote: > > From: Bartosz Golaszewski > > > > Implement a new, modern GPIO testing module controlled by configfs > > attributes instead of module parameters. The goal of this driver is > > to provide a replacement for gpio-mockup that will be easily extensible > > with new features and doesn't require reloading the module to change > > the setup. > > Shall we put a reference to this in the gpio-mockup documentation and mark the > latter deprecated? > I don't think it's necessary right away. Let's phase out gpio-mockup once this one gets some attention (for example: after libgpiod switches to using it). [snip] > > > + dev_attr->attr.name = devm_kasprintf(dev, GFP_KERNEL, > > + "gpio%u", i); > > Reads better as one line. > Yeah, so the removal of the 80 characters limit should not be abused when there's no need for it - this doesn't look that bad really with a broken line. Same elsewhere where the limit is exceeded. [snip] > > > + ret = sprintf(page + written, > > + i < config->num_line_names - 1 ? > > + "\"%s\", " : "\"%s\"\n", > > + config->line_names[i] ?: ""); > > Indentation here looks not the best... > So this is the place where it may make sense to go over 80 chars. [snip] > > + > > + /* > > + * FIXME If anyone knows a better way to parse that - please let me > > + * know. > > + */ > > If comma can be replaced with ' ' (space) then why not to use next_arg() from > cmdline.c? I.o.w. do you have strong opinion why should we use comma here? > My opinion is not very strong but I wanted to make the list of names resemble what we pass to the gpio-line-names property in device tree. Doesn't next_arg() react differently to string of the form: "foo=bar"? [snip] > > + > > +static int gpio_sim_config_uncommit_item(struct config_item *item) > > +{ > > + struct gpio_sim_chip_config *config = to_gpio_sim_chip_config(item); > > + int id; > > + > > + mutex_lock(&config->lock); > > + id = config->pdev->id; > > + platform_device_unregister(config->pdev); > > + config->pdev = NULL; > > > + ida_free(&gpio_sim_ida, id); > > Isn't it atomic per se? I mean that IDA won't give the same ID until you free > it. I.o.w. why is it under the mutex? > You're right but if we rapidly create and destroy chips we'll be left with holes in the numbering (because new devices would be created before the IDA numbers are freed, so the driver would take a larger number that's currently free). It doesn't hurt but it would look worse IMO. Do you have a strong opinion on this? [snip] I'll address issues I didn't comment on. Thanks for the review! Bart