From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3F4AAC4332F for ; Thu, 14 Dec 2023 14:05:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1573387AbjLNOEw (ORCPT ); Thu, 14 Dec 2023 09:04:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230048AbjLNOEu (ORCPT ); Thu, 14 Dec 2023 09:04:50 -0500 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.8]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 57DAD9C; Thu, 14 Dec 2023 06:04:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1702562698; x=1734098698; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=PONu75sM+YBENqHudHU14x0Wg1ISHEzLVA/83cLs8ww=; b=cCzXC+pHTg3pyabPIHoBhQBV4SUunYy2Ue6tg041ZktEbeMgq9NtJ2uH tdTldQr1FE7llXfnAHRtxBvb2UiEKqmy0sicoNEtOeSOiBCr78+mWoMG/ g05Rg8GG71D2RqCY7ncEBmAiFsXDeMeLigqJXdxJ103puAje0BL9oAtvm 5FIig/D0b9217UF8mz8pz1YqZFqCtFo/IazpTCjK8oVfx0dzSxp2P7aXf /bzxlDveEtayjXFGZlvjENS5SFzxr7sXFlksVWgRcWw77nCfy3mgk+LSE JobYGdtajf2fJf0aYirqAkYcs1yo7yhQ2/bDihkDH7OwPW+pvk5r8i6+n w==; X-IronPort-AV: E=McAfee;i="6600,9927,10924"; a="8518706" X-IronPort-AV: E=Sophos;i="6.04,275,1695711600"; d="scan'208";a="8518706" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Dec 2023 06:04:57 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10924"; a="892479943" X-IronPort-AV: E=Sophos;i="6.04,275,1695711600"; d="scan'208";a="892479943" Received: from smile.fi.intel.com ([10.237.72.54]) by fmsmga002.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Dec 2023 06:04:55 -0800 Received: from andy by smile.fi.intel.com with local (Exim 4.97) (envelope-from ) id 1rDmKa-00000005rN7-2Y4X; Thu, 14 Dec 2023 16:04:52 +0200 Date: Thu, 14 Dec 2023 16:04:52 +0200 From: Andy Shevchenko To: Bartosz Golaszewski Cc: Linus Walleij , Kent Gibson , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: Re: [PATCH v2 2/2] gpiolib: use a mutex to protect the list of GPIO devices Message-ID: References: <20231208102020.36390-1-brgl@bgdev.pl> <20231208102020.36390-3-brgl@bgdev.pl> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Dec 14, 2023 at 02:59:28PM +0100, Bartosz Golaszewski wrote: > On Thu, Dec 14, 2023 at 2:53 PM Andy Shevchenko > wrote: > > > > On Fri, Dec 08, 2023 at 11:20:20AM +0100, Bartosz Golaszewski wrote: > > > From: Bartosz Golaszewski > > > > > > The global list of GPIO devices is never modified or accessed from > > > atomic context so it's fine to protect it using a mutex. Add a new > > > global lock dedicated to the gpio_devices list and use it whenever > > > accessing or modifying it. ... > > > While at it: fold the sysfs registering of existing devices into > > > gpiolib.c and make gpio_devices static within its compilation unit. > > > > TBH I do not like injecting sysfs (legacy!) code into gpiolib. > > It makes things at very least confusing. > > > > That _ugly_ ifdeffery and sysfs in the function name are not okay. > > > > If you want do that, please create a separate change and explain the rationale > > behind with answering to the Q "Why do we need all that and why is it better > > than any alternatives?". > > I can move it back to gpiolib-sysfs.c but this way we'll have to keep > the GPIO device mutex public in gpiolib.h. And I'm fine with that. Again, we can discuss this in a separate change that will do that (make that mutex local with the explanation why). -- With Best Regards, Andy Shevchenko