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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 53B87C48BEB for ; Wed, 21 Feb 2024 20:25:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=fW76nAhf6H+iLpuLvROMluY39tN/d1ziTjYjiprvNgU=; b=t35SzN+60RahBJ YYl3dL8jVQY7laolgx2vn16O8QgXW86hnwgWTiJDDGjTQQjDZR7ST6apIpx0dxvBypM9fVdhP3Olt 0tWKpRBu1pKc4oYBS98MW/RphGzozS+lRtHY8OJEY3AG+UbF7WP+Zy+d2fpeup1fqDesLr+vWXEFJ HaCT2MyQBtMi1z6vzDUxfjNRC8EwF6ebO/HygmARoUgiBECXOw+QIHGLIjR8c9S76jo5wFAspFcc2 bURfg+QDKDcBUJPqBrq9A1mbPddIsgu4PMDBLQRffcYCGLntGQGQPmXJlCybE34P0UVwlzuSfniJt etq19wA+GE9u8/yukX5g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rct9c-00000002TSv-0oRk; Wed, 21 Feb 2024 20:25:20 +0000 Received: from mail-io1-xd31.google.com ([2607:f8b0:4864:20::d31]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rct9a-00000002TSa-12yU for linux-arm-kernel@lists.infradead.org; Wed, 21 Feb 2024 20:25:19 +0000 Received: by mail-io1-xd31.google.com with SMTP id ca18e2360f4ac-7c72290deb6so261021339f.3 for ; Wed, 21 Feb 2024 12:25:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1708547117; x=1709151917; darn=lists.infradead.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=2wkgeRh9IF6PLJzH5c/hW4z1k21RwGIOmpMXRCu5Jsc=; b=g0q6tcnsrIhxwMbY2fOBFspfIJ+JLsy0FxaSVqtwQKwPKLIj72tPSKoWwlGSqPwBMQ HjygWlQl7weZ2HMrA46ta/VSwPEGWh9v8M8PVWb8XB7fHOCJvLMo6T0glAurLtafd+rp 3VhPXlaItOEXvCNsmfKgS8oT81NbiOdwBZiUY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708547117; x=1709151917; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=2wkgeRh9IF6PLJzH5c/hW4z1k21RwGIOmpMXRCu5Jsc=; b=giocCvPjRQHDYHjQXRbffGKlgodeJc7hmctlGCeBWxSQGuHvI+N1DIGFo++VFj9hX3 RiOwPXmKz+yhro/j94f4A1D9Iq/Q373YioAVfKMGxi7VFdo4VenY+wJqJLno382pUM3I BK4iYRWootND8aEHw+GnIAqCHlX1omQhNzhcYLZyGkwjRskP/oSz7vjG5vkQ8/jeOw8p YHUh+yHkcO8hoWtvoDECZI4sY1jcbLwSU+k9gnz5VsymJopqkXIuJ595NmJHIe/SPTZT dEUkYn2Veiyzysz5aktqbt4fvJT7CJz7T2XXWxgEhNhEoAiWhrAK9BfS9ZS4rT8zcHza 0kAw== X-Forwarded-Encrypted: i=1; AJvYcCXVhv6NoYPwawi8OoBW/E6i68PCfXZgPhX/zHzQoQ1doVgXobkw8U6Gkj+w5S+TP4MNSaHF1G3fWtoULtMvLipElB3/LUd+22ZkJmKm6IEK3ucfmz4= X-Gm-Message-State: AOJu0YwQbPQurA+o+LxNa8V9udlTAPp904cXJtA4nNOL+yj+ttaqzYJV 8QA2xmhQHZQm6KwsvP6uL6XHK7LBE8QVvOi6NDr4yEgpkFCPcuvDiQBBLArczg== X-Google-Smtp-Source: AGHT+IHHf/4LjAJjVkP9U0N3B1K1orn7osgB11jKx5iI8zxropaoPlYRW14hh4HVSps9PWMjT6jAMg== X-Received: by 2002:a05:6602:3408:b0:7c4:8a72:d17b with SMTP id n8-20020a056602340800b007c48a72d17bmr24641170ioz.13.1708547117013; Wed, 21 Feb 2024 12:25:17 -0800 (PST) Received: from localhost (147.220.222.35.bc.googleusercontent.com. [35.222.220.147]) by smtp.gmail.com with UTF8SMTPSA id b99-20020a0295ec000000b004742c0fafb5sm1724032jai.15.2024.02.21.12.25.16 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 21 Feb 2024 12:25:16 -0800 (PST) Date: Wed, 21 Feb 2024 20:25:16 +0000 From: Matthias Kaehlcke To: Javier Carrasco Cc: Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Greg Kroah-Hartman , Helen Koike , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Catalin Marinas , Will Deacon , Russell King , linux-sound@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v4 6/8] usb: misc: onboard_dev: use device supply names Message-ID: References: <20240220-onboard_xvf3500-v4-0-dc1617cc5dd4@wolfvision.net> <20240220-onboard_xvf3500-v4-6-dc1617cc5dd4@wolfvision.net> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20240220-onboard_xvf3500-v4-6-dc1617cc5dd4@wolfvision.net> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240221_122518_348123_E1B6D42D X-CRM114-Status: GOOD ( 30.66 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, Feb 20, 2024 at 03:05:50PM +0100, Javier Carrasco wrote: > The current mechanism uses generic names for the power supplies, which > conflicts with proper name definitions in the device bindings. > > Add a per-device property to include real supply names and keep generic > names as a fallback mechanism for backward compatibility. > > Signed-off-by: Javier Carrasco > --- > drivers/usb/misc/onboard_usb_dev.c | 54 ++++++++++++++++++++------------------ > drivers/usb/misc/onboard_usb_dev.h | 23 ++++++++++++++++ > 2 files changed, 52 insertions(+), 25 deletions(-) > > diff --git a/drivers/usb/misc/onboard_usb_dev.c b/drivers/usb/misc/onboard_usb_dev.c > index f43130a6786f..e66fcac93006 100644 > --- a/drivers/usb/misc/onboard_usb_dev.c > +++ b/drivers/usb/misc/onboard_usb_dev.c > @@ -29,18 +29,6 @@ > > #include "onboard_usb_dev.h" > > -/* > - * Use generic names, as the actual names might differ between devices. If a new > - * device requires more than the currently supported supplies, add a new one > - * here. > - */ > -static const char * const supply_names[] = { > - "vdd", > - "vdd2", > -}; > - > -#define MAX_SUPPLIES ARRAY_SIZE(supply_names) > - > static void onboard_dev_attach_usb_driver(struct work_struct *work); > > static struct usb_device_driver onboard_dev_usbdev_driver; > @@ -66,6 +54,33 @@ struct onboard_dev { > struct clk *clk; > }; > > +static int onboard_dev_get_regulator_bulk(struct device *dev, > + struct onboard_dev *onboard_dev) > +{ > + unsigned int i; > + int err; > + > + const char * const *supply_names = onboard_dev->pdata->supply_names; > + > + if (onboard_dev->pdata->num_supplies > MAX_SUPPLIES) > + return dev_err_probe(dev, -EINVAL, "max %zu supplies supported!\n", > + MAX_SUPPLIES); > + > + if (!supply_names[0]) > + supply_names = generic_supply_names; Please change to 'if (!supply_names)' and omit the initialization of .supply_names for devices that use the generic supply names. > diff --git a/drivers/usb/misc/onboard_usb_dev.h b/drivers/usb/misc/onboard_usb_dev.h > index ebe83e19d818..59dced6bd339 100644 > --- a/drivers/usb/misc/onboard_usb_dev.h > +++ b/drivers/usb/misc/onboard_usb_dev.h > @@ -6,63 +6,86 @@ > #ifndef _USB_MISC_ONBOARD_USB_DEV_H > #define _USB_MISC_ONBOARD_USB_DEV_H > > +/* > + * Fallback supply names for backwards compatibility. If the device requires > + * more than the currently supported supplies, add a new one here, and if > + * possible, the real name supplies to the device-specific data. > + */ > +static const char * const generic_supply_names[] = { > + "vdd", > + "vdd2", > +}; > + > +#define MAX_SUPPLIES ARRAY_SIZE(generic_supply_names) This will have to change when support for a device with more than 2 non-generic supply names gets added. Please use a literal value for MAX_SUPPLIES instead of ARRAY_SIZE. If the literal is 2 it would still need to change for future devices with more supplies, but that change would be more straighforward. > + > struct onboard_dev_pdata { > unsigned long reset_us; /* reset pulse width in us */ > unsigned int num_supplies; /* number of supplies */ > bool is_hub; > + const char * const supply_names[MAX_SUPPLIES]; > + > }; > > static const struct onboard_dev_pdata microchip_usb424_data = { > .reset_us = 1, > .num_supplies = 1, > + .supply_names = { NULL }, > .is_hub = true, > }; > > ... _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel