From nobody Wed Dec 17 04:16:55 2025 Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C742D204098 for ; Tue, 14 Jan 2025 20:05:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736885149; cv=none; b=Vlr+q23yFRW4BqCED3rhggy5sK0ZMvEu0c0n7d9stJnxE7/XKsHsXlwBjkCMqKuXwt7Y15+3iOTFaaLELlEiHFhc4KRknheJmxYk3PhV9bt5MHBRkrJCnJOnOd8BPpbAJcbnQ5hHOuJOvjMi1B5/cenVH3Otgm31jB78Zwqm6r8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736885149; c=relaxed/simple; bh=oBRrldCGEtQDH9TkaLDR4/zC/3PP573MIhVqsz9gJTw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Hri4G6g/y8mV/p4VyTqG2pzGw4/FhSaZbgnaLHViqDIFX5Un0Il3G4swmIFVzsMZi6lZ2AamDKMgwXVKHXF4N+asBqRix0q8k63pv40IKy5Aci3dpPPrwoBYRsQNZBquydtu4cNguL074/YoOKfCH3fE9r+HsKoDUDUZ9kXrwow= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=VnkFXAPi; arc=none smtp.client-ip=209.85.128.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="VnkFXAPi" Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-43616bf3358so7474695e9.3 for ; Tue, 14 Jan 2025 12:05:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1736885146; x=1737489946; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=ix4BWT9qwOiJ6xVGoiI7oaTduq2Ilx63FNUEN2N3zfk=; b=VnkFXAPic+CT8CfPGdclmGVNFdBrftO4RcT3nQHje5UAWlfXOMoQqPq56BW8yZOLa9 Gky2KrBx5bQzuisOV01XNBMVkyqyVQJFkgJj8N4uLf4jIZUm7FNhhLxYl2+1+1dj0X5O U1s/KuKzcSUDDwlF7AyZL3w5+9TIT4vpBCabYEvhzgolnn/WNs5X9dztFYjaaXWrxj7D QRZHyTe51JVuocDPFY46Pv2knF+UGf1AFZM23uE67cfuSkNquPxV2p06DY9f2WWVG9Ry wZwCFDB+b/BMIEC3w1bPhQscVviQM+lJp6MRIHIUuBR1o6hdgPT81RaPCA9EcZBr9xF9 o3GQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736885146; x=1737489946; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ix4BWT9qwOiJ6xVGoiI7oaTduq2Ilx63FNUEN2N3zfk=; b=mJtKfvNXKp5swrIUEF/Iu9+KlGVvhnK8TNMzyUNEzS7rsVWkQKwYDMwvx1s/WTdhDN huQ2wsRKUjtdr6hPji1P/1bLpPj1H4Yk6pAW27RsJKMSeP4nh3E/Q3iv76AzZXAvnNwp L/240iieeHnK8DC6uWlggbJOpRLXV3U+h4jApluLNQQ6IgF7XtE10uSy2YtyBMT/B2xo oQa7UKOr0GQIX1lzUNhytk+BJMgSFGwC/vVobL8gwA5XzKmT116PUvtQyE1oh/28fBcF kTB9g0vVP/9eoYhXqM+fvGI9qDwJTlmIS6oDxXn4jAl9zfl8i+WD84wzvrrcbYDmEG3B 6s4A== X-Forwarded-Encrypted: i=1; AJvYcCXbgctNYyGtnwESRjMugAQvQg8U9CmP4gYm5KpQqZ0kvRmt9NEV5xG8ItqbUOTCdZ/+pfnjBtK8vwtKuV4=@vger.kernel.org X-Gm-Message-State: AOJu0YxzX6kODB8osXdPWzdzF6E7/uxycK0f5W83tH/EN/DlTH1M5YGh PGj/qllsl3TYtdBrzG0Avgm0kL3zjVFYu7rVhLkPZ0avupSPyju8CYCWq0noy14= X-Gm-Gg: ASbGncswI7p5aYqq7IhC/M94tXq1/ahbTwk5/0JBKt16Q9nh4cqloq6eoJolI17fUDb zkuRgC3f8IaMdv4UQVRk1+x5RpAnC8B/bbmInSEBd5OAZF61LS4bTdf5D9M0Uk0uFSgGpZGQnjq I+L4sJxK7FpjMtj7Xebxfr5JGVRKarhJ96PsOaFGyqBS14rXlyDsry5TJN40f09SAFZ+0kYffQt YqGxw0nufOr99Ayd1q9DXCRjzTz5QeIowQi5JKMMcUIjUQpLT5mvAP9/nwI0qttJBWpN73s X-Google-Smtp-Source: AGHT+IFF+NOL6cyiG7mt/hpyvkvyIQ5FH47+mKOsgPqnCVkB6Agi5TbojvwLum3KesDuClRq/0X9YA== X-Received: by 2002:a05:600c:3b11:b0:42c:bb35:b6d0 with SMTP id 5b1f17b1804b1-436e267f21bmr104196145e9.1.1736885146061; Tue, 14 Jan 2025 12:05:46 -0800 (PST) Received: from [127.0.1.1] ([178.197.223.165]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-436e9dc8802sm184622025e9.10.2025.01.14.12.05.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jan 2025 12:05:45 -0800 (PST) From: Krzysztof Kozlowski Date: Tue, 14 Jan 2025 21:05:34 +0100 Subject: [PATCH 1/6] USB: Replace own str_plural with common one Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250114-str-enable-disable-usb-v1-1-c8405df47c19@linaro.org> References: <20250114-str-enable-disable-usb-v1-0-c8405df47c19@linaro.org> In-Reply-To: <20250114-str-enable-disable-usb-v1-0-c8405df47c19@linaro.org> To: Greg Kroah-Hartman , Mathias Nyman , Thierry Reding , Jonathan Hunter , Heikki Krogerus , Andrew Jeffery , Nicolas Ferre , Alexandre Belloni , Claudiu Beznea , Daniel Mack , Haojian Zhuang , Robert Jarzmik , Peter Chen , Linus Walleij , Alan Stern Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, usb-storage@lists.one-eyed-alien.net, Krzysztof Kozlowski X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=4557; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=oBRrldCGEtQDH9TkaLDR4/zC/3PP573MIhVqsz9gJTw=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBnhsORQpZSPRfkKaL3N8KwomBIhzaY4ZZ1/V+EP p3YB7iKfC2JAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZ4bDkQAKCRDBN2bmhouD 1/ihD/4zYcA+M7tRdqi7/4Eu0P6oiHwpIW+zgjjC8mO4dKq/fzdsBl6GN0MPubf3R+62Dn9SnlZ gBkxcpdPfMPzibVeDxdAxqS/QFZCYYfiYHTOUfNvFX4yjYDZ/F+e34/1VyxC/CsP4NiGivuM1qy zhYf6dMBMFG2cvEw2a1kyx/HYLvdjFakU6qqy8zckY9c+NkUVSzs7hcIfn8b8XLf6VJk3CCsbFC eFAvoZoXKQdleAAlT1D0Pj5QXP+piUPJYY1zpD7AatwpaCgQS3tAaO2qTKebXHVAQlcYgrnWjNO U/JAwvdS2ckWppCHDH9hPb0M0WbFxji74szMZm/F6faWFlHxLVs+NDFB+umXtlluIAM4lLH0fxt g7V7Ma5GLHOJjzXMOk0Nx/MKFiDPnDeHOEEdn/zazix7cPwagALIFuZIRHyS+2Hb6E7Jim4VQPy EjG0PB4bNJw7WoOzXhMBUuem1SAaRPOw7M1CPetC6vw1w7l7PoyevPZLHy6Qc5xW1YZOKrGR5kh qI/1IOST1DLVe+KRGyTwfCBs/ZdurCWpWaseYe6pmkR46WH9pJj+50nK91+HRsuj/cAoU/2jFs0 59Ytog3gzGwCenTSUtSlN7SsMs7uDj8jCE/rC4cMXVQj4nqZXGsiWEkXD8mSi/5aADZGy32Pm1i 6OczTp8+0UGp3Jg== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B Use existing str_plural() helper from string_choices.h to reduce amount of duplicated code. Signed-off-by: Krzysztof Kozlowski --- drivers/usb/core/config.c | 19 +++++++------------ drivers/usb/core/generic.c | 12 ++++-------- 2 files changed, 11 insertions(+), 20 deletions(-) diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c index 25a00f974934fb5a562caf3f5f259ba23031e457..f7bf8d1de3adeb16a540ec52367= 26fc7b03517df 100644 --- a/drivers/usb/core/config.c +++ b/drivers/usb/core/config.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include "usb.h" @@ -18,12 +19,6 @@ =20 #define USB_MAXCONFIG 8 /* Arbitrary limit */ =20 - -static inline const char *plural(int n) -{ - return (n =3D=3D 1 ? "" : "s"); -} - static int find_next_descriptor(unsigned char *buffer, int size, int dt1, int dt2, int *num_skipped) { @@ -484,7 +479,7 @@ static int usb_parse_endpoint(struct device *ddev, int = cfgno, retval =3D buffer - buffer0 + i; if (n > 0) dev_dbg(ddev, "skipped %d descriptor%s after %s\n", - n, plural(n), "endpoint"); + n, str_plural(n), "endpoint"); return retval; =20 skip_to_next_endpoint_or_interface_descriptor: @@ -563,7 +558,7 @@ static int usb_parse_interface(struct device *ddev, int= cfgno, alt->extralen =3D i; if (n > 0) dev_dbg(ddev, "skipped %d descriptor%s after %s\n", - n, plural(n), "interface"); + n, str_plural(n), "interface"); buffer +=3D i; size -=3D i; =20 @@ -605,7 +600,7 @@ static int usb_parse_interface(struct device *ddev, int= cfgno, dev_notice(ddev, "config %d interface %d altsetting %d has %d " "endpoint descriptor%s, different from the interface " "descriptor's value: %d\n", - cfgno, inum, asnum, n, plural(n), num_ep_orig); + cfgno, inum, asnum, n, str_plural(n), num_ep_orig); return buffer - buffer0; =20 skip_to_next_interface_descriptor: @@ -664,7 +659,7 @@ static int usb_parse_configuration(struct usb_device *d= ev, int cfgidx, if (size2 < sizeof(struct usb_descriptor_header)) { dev_notice(ddev, "config %d descriptor has %d excess " "byte%s, ignoring\n", - cfgno, size2, plural(size2)); + cfgno, size2, str_plural(size2)); break; } =20 @@ -754,7 +749,7 @@ static int usb_parse_configuration(struct usb_device *d= ev, int cfgidx, if (n !=3D nintf) dev_notice(ddev, "config %d has %d interface%s, different from " "the descriptor's value: %d\n", - cfgno, n, plural(n), nintf_orig); + cfgno, n, str_plural(n), nintf_orig); else if (n =3D=3D 0) dev_notice(ddev, "config %d has no interfaces?\n", cfgno); config->desc.bNumInterfaces =3D nintf =3D n; @@ -798,7 +793,7 @@ static int usb_parse_configuration(struct usb_device *d= ev, int cfgidx, config->extralen =3D i; if (n > 0) dev_dbg(ddev, "skipped %d descriptor%s after %s\n", - n, plural(n), "configuration"); + n, str_plural(n), "configuration"); buffer +=3D i; size -=3D i; =20 diff --git a/drivers/usb/core/generic.c b/drivers/usb/core/generic.c index b134bff5c3fe3e86215bdcd14a2591a521f5ba3c..9c6ae5e1198bb2043d27e2f309a= 46f8ce512225f 100644 --- a/drivers/usb/core/generic.c +++ b/drivers/usb/core/generic.c @@ -21,14 +21,10 @@ =20 #include #include +#include #include #include "usb.h" =20 -static inline const char *plural(int n) -{ - return (n =3D=3D 1 ? "" : "s"); -} - static int is_rndis(struct usb_interface_descriptor *desc) { return desc->bInterfaceClass =3D=3D USB_CLASS_COMM @@ -194,18 +190,18 @@ int usb_choose_configuration(struct usb_device *udev) if (insufficient_power > 0) dev_info(&udev->dev, "rejected %d configuration%s " "due to insufficient available bus power\n", - insufficient_power, plural(insufficient_power)); + insufficient_power, str_plural(insufficient_power)); =20 if (best) { i =3D best->desc.bConfigurationValue; dev_dbg(&udev->dev, "configuration #%d chosen from %d choice%s\n", - i, num_configs, plural(num_configs)); + i, num_configs, str_plural(num_configs)); } else { i =3D -1; dev_warn(&udev->dev, "no configuration chosen from %d choice%s\n", - num_configs, plural(num_configs)); + num_configs, str_plural(num_configs)); } return i; } --=20 2.43.0 From nobody Wed Dec 17 04:16:55 2025 Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A2FA220C47C for ; Tue, 14 Jan 2025 20:05:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736885152; cv=none; b=SpN04L6eJIzeIcxXNTlKldHjgDrvqwqD6dSjmBGi1X13+P/SWgIT/vDFyt2e7RkfJj6D6Vksh9gpuOgY0VqF+uoOd4h1RGBubogwJlPfqJ5nG5Qfk3eTB6Izk6iHcbVAtgL//O1PULViwVcJcLJpbDW8Sf9eB6SLvO1Zsw9hwBw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736885152; c=relaxed/simple; bh=6gsuWbH88x9KgXoI5TgmCdvl5bUYE9XYTxx1EDNabmI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=sGE520tcqm5jSfiIq2Gq9rbSOhchlN3VAOWTBbaLBBpFKV6+dALiPURTBpPkYB+B0Es4SGueU9xPBpALYVWg7G5TBcEVG2xoT6+GrtwmlH3NRXr5bJMGsDJWVSdyp9KJArGwdmgAUwVI6rBxXzm3w9694TbWv7UAZ/PBX2v9jqQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=iGUZ7oNg; arc=none smtp.client-ip=209.85.221.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="iGUZ7oNg" Received: by mail-wr1-f43.google.com with SMTP id ffacd0b85a97d-38625aa01b3so571694f8f.3 for ; Tue, 14 Jan 2025 12:05:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1736885149; x=1737489949; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=3qM/tcI7j/OfvD0CcvoyLKgC3FnLS8o6FdfzDJsqGic=; b=iGUZ7oNgcd8hJ0qCrWeCb9THArdG5Evj4XLXyZ+1ueOKlqpXbBuBC2XCsI5DtRy+Ln iXM3CDL5UuiEnqlmKsfjS1qS0LelsqH+ai5bzHpDI0s6lpTsaYz1KJ53IT8k+q2IpPMn l/pskYTzkk4JXraGE+DEAybm05VlIVe8h/ESGzUxz9zZgFlDkPwK8FcD48heZqGoDXvY cFV1KksDnmz4tqyl0cvUooPwt9oA8J+fGP0HTY0e7ERoQY0PBqdB1ylEhfrYfVn1rVf7 cDFFHm2rqCM0hVkrj/dYSVoAJ58ocLAkJa18a89FS1tWjgKOl+qqT3GpcBNE0B9yzYrP JQ8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736885149; x=1737489949; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3qM/tcI7j/OfvD0CcvoyLKgC3FnLS8o6FdfzDJsqGic=; b=C2nLGwdZ40YCun9kI+buretCPfk2yEsd9Rh1XQDvNewMp49xwRNr/VnHY5PhHusv83 GeVq/ukYI2L7x/LPSKli9+m9RUzne1sCWO47+tDtNXooSyyWbhE3HRsvbJdyRghuK9rI k1okpru3H0aXnIqENBdU9DitvaJUivh3G6Uodyr2LZesk0R2rUnIzNN5lkK57p34DJa+ 24wqhfbQiCCC2eU5HynOqVe0a5A7IxVXZ9qszhqqMjcXBhIZjd1Fs9bZatosayg7ggol 7A3qO+1N+TpAkjp1zQvgt7fummCXDXGHu6yxWtj97Yq+xO+Us7pasO+3XpynYDZhEv9x D/qg== X-Forwarded-Encrypted: i=1; AJvYcCWoTOXbvi+K4coJbnB8ZOB5c9bCW3XCyW+dEsnAlP7B4x0bjzEtB7UsKmahsb+ffr2PUmov4ts9aGUbb7U=@vger.kernel.org X-Gm-Message-State: AOJu0Yyd2qjjIC1K56LV3wVVEMZD+S9n1fd3KrZ0PDQU2cvLDaODI97E ObsLYtXebWCD0eOOS8B8R4TXPY8gtiI6OCIWxxmrEshKY76E2rn15Pt3Hwj0yBY= X-Gm-Gg: ASbGncvaIO8a+wOlcWbtMIZ0Mv4QTcZRRC87aONLiBYhXSCVGdFu1Q76QOSMPU59UvR ob1dnxEa+bmj5Ux7Hv9fm0+5OrywZRau/FZx+YEGTTXIltdXq5wj4qvy/YI1p4ty4PSmUqYcd7u C4dS0nIbB07HVnCvjFaBHW0dqEc8DZylIq7NkY7jEBoom0AMyaP5evXoz2PLYp/amy6zEgF/WeO 3ntwfDRT0GD9/phdyw52NK8gK7NPNk1o5LA4N+9Ow5OyuQK8mjCac7HJAD4PRBs9WLdLnQV X-Google-Smtp-Source: AGHT+IEoOZbZSuWLCARa3ej13fhaIk8K815salz+1rjHY3uOlYhFohf1g25+udMvLC8TNZHWQ3cTPw== X-Received: by 2002:a05:600c:3b08:b0:42c:c0d8:bf49 with SMTP id 5b1f17b1804b1-436e2560720mr96739485e9.0.1736885148916; Tue, 14 Jan 2025 12:05:48 -0800 (PST) Received: from [127.0.1.1] ([178.197.223.165]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-436e9dc8802sm184622025e9.10.2025.01.14.12.05.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jan 2025 12:05:48 -0800 (PST) From: Krzysztof Kozlowski Date: Tue, 14 Jan 2025 21:05:35 +0100 Subject: [PATCH 2/6] USB: host: Use str_enable_disable-like helpers Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250114-str-enable-disable-usb-v1-2-c8405df47c19@linaro.org> References: <20250114-str-enable-disable-usb-v1-0-c8405df47c19@linaro.org> In-Reply-To: <20250114-str-enable-disable-usb-v1-0-c8405df47c19@linaro.org> To: Greg Kroah-Hartman , Mathias Nyman , Thierry Reding , Jonathan Hunter , Heikki Krogerus , Andrew Jeffery , Nicolas Ferre , Alexandre Belloni , Claudiu Beznea , Daniel Mack , Haojian Zhuang , Robert Jarzmik , Peter Chen , Linus Walleij , Alan Stern Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, usb-storage@lists.one-eyed-alien.net, Krzysztof Kozlowski X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=5423; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=6gsuWbH88x9KgXoI5TgmCdvl5bUYE9XYTxx1EDNabmI=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBnhsOStoOcTYIheQheuxTvcNt6qNGqwgv4Mrucb HQfcC8AoGiJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZ4bDkgAKCRDBN2bmhouD 116uD/4pUHkYVwXjtXupkx4piF1QjTdJqIeQMmpgViZX1SSVvola2wMqHd7L0mTS4axfqr/Rwj/ WI+LNzEX+tbz1FbtSpXuk5xAy9hn1u536wKGFprj/qinJIqZ6UykfwOE5xhpFjft8Bv8B116enk KsmoVSqZhtX9JJak44+tbXuPRRJAfBME/2p7hDNhoJ+gxeh8VNHcGo4Mf1cGg+5b17gStjlogF0 yz56HV6XS4C+UIdtu6nlwUyoCJfqJRmJd90J1zCgX8LdigNU9lA4DYnfHg1mVQQBV7mO7TTD5qv RxZN40B7NtpGvXpXZgOOE3dpeupV9KmSPnVaCiErynSUpwojakhIpYJsCs9Wwihu+gmSvPiCT10 p8ycLvxfEtXiGbWF+fM8lQQlELVofXa3wmI37ipCMZTc5t4XXzFYeQJI+glL+S1gOE06OMVpuFC N5WMZjELYyp3W3/O0KLYMqJ0MogG/eF6wa3bY/9l0Z7qh8A+iX90PZJ28INhPhwo1QFW9K3rriR 0RlJBemWOA+xMFxBHOqZKcY9H9Z0M2GrDjqH6nzMnst7hrJFdzwhb2EJWzd+3APBWLENlXhY6ZA z8VxayvKVWQmB+J5Q0BjIEYorPzk1EEMJvgO9X36XpRXQHG7YmpYtluPO6QnQfP6wr8QRgWa5Ol TxWH79PhGdn8YTg== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B Replace ternary (condition ? "enable" : "disable") syntax with helpers from string_choices.h because: 1. Simple function call with one argument is easier to read. Ternary operator has three arguments and with wrapping might lead to quite long code. 2. Is slightly shorter thus also easier to read. 3. It brings uniformity in the text - same string. 4. Allows deduping by the linker, which results in a smaller binary file. Signed-off-by: Krzysztof Kozlowski --- drivers/usb/host/oxu210hp-hcd.c | 3 ++- drivers/usb/host/sl811-hcd.c | 3 ++- drivers/usb/host/xhci-ring.c | 5 +++-- drivers/usb/host/xhci-tegra.c | 5 +++-- drivers/usb/host/xhci.c | 3 ++- 5 files changed, 12 insertions(+), 7 deletions(-) diff --git a/drivers/usb/host/oxu210hp-hcd.c b/drivers/usb/host/oxu210hp-hc= d.c index a6c20facf9450153121001d36547eee68d6c9ca9..fce800ba4c614ca0ccf23b5af0c= 0b13423e2a95d 100644 --- a/drivers/usb/host/oxu210hp-hcd.c +++ b/drivers/usb/host/oxu210hp-hcd.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -2756,7 +2757,7 @@ static void ehci_port_power(struct oxu_hcd *oxu, int = is_on) if (!HCS_PPC(oxu->hcs_params)) return; =20 - oxu_dbg(oxu, "...power%s ports...\n", is_on ? "up" : "down"); + oxu_dbg(oxu, "...power%s ports...\n", str_up_down(is_on)); for (port =3D HCS_N_PORTS(oxu->hcs_params); port > 0; ) { if (is_on) oxu_hub_control(oxu_to_hcd(oxu), SetPortFeature, diff --git a/drivers/usb/host/sl811-hcd.c b/drivers/usb/host/sl811-hcd.c index 036f5fd6d159feee18f3be187c6bc9d5ea59dc4f..fa2e4badd288c0d355b121f27e9= d9b5460fa4e7c 100644 --- a/drivers/usb/host/sl811-hcd.c +++ b/drivers/usb/host/sl811-hcd.c @@ -48,6 +48,7 @@ #include #include #include +#include #include #include =20 @@ -98,7 +99,7 @@ static void port_power(struct sl811 *sl811, int is_on) if (sl811->board && sl811->board->port_power) { /* switch VBUS, at 500mA unless hub power budget gets set */ dev_dbg(hcd->self.controller, "power %s\n", - is_on ? "on" : "off"); + str_on_off(is_on)); sl811->board->port_power(hcd->self.controller, is_on); } =20 diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index 3d66ed240dc375af3d51a7c6bcb1970efc7ecd49..965bffce301e24502310fd4a848= ede01e1348530 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -55,6 +55,7 @@ #include #include #include +#include #include #include "xhci.h" #include "xhci-trace.h" @@ -3441,8 +3442,8 @@ static void check_interval(struct urb *urb, struct xh= ci_ep_ctx *ep_ctx) if (xhci_interval !=3D ep_interval) { dev_dbg_ratelimited(&urb->dev->dev, "Driver uses different interval (%d microframe%s) than xHCI (%d microf= rame%s)\n", - ep_interval, ep_interval =3D=3D 1 ? "" : "s", - xhci_interval, xhci_interval =3D=3D 1 ? "" : "s"); + ep_interval, str_plural(ep_interval), + xhci_interval, str_plural(xhci_interval)); urb->interval =3D xhci_interval; /* Convert back to frames for LS/FS devices */ if (urb->dev->speed =3D=3D USB_SPEED_LOW || diff --git a/drivers/usb/host/xhci-tegra.c b/drivers/usb/host/xhci-tegra.c index 06ae193ec87407f13487556862c9caf03f51b786..a51ce71a6a77eb7ce5308669624= c7b8bb735e382 100644 --- a/drivers/usb/host/xhci-tegra.c +++ b/drivers/usb/host/xhci-tegra.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -724,7 +725,7 @@ static void tegra_xusb_mbox_handle(struct tegra_xusb *t= egra, if (err < 0) { dev_err(dev, "failed to %s LFPS detection on USB3#%u: %d\n", - enable ? "enable" : "disable", port, err); + str_enable_disable(enable), port, err); rsp.cmd =3D MBOX_CMD_NAK; } else { rsp.cmd =3D MBOX_CMD_ACK; @@ -1349,7 +1350,7 @@ static void tegra_xhci_id_work(struct work_struct *wo= rk) u32 status; int ret; =20 - dev_dbg(tegra->dev, "host mode %s\n", tegra->host_mode ? "on" : "off"); + dev_dbg(tegra->dev, "host mode %s\n", str_on_off(tegra->host_mode)); =20 mutex_lock(&tegra->lock); =20 diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 5ebde8cae4fc44cdb997b0f61314e309bda56c0d..45653114ccd7fcc4a1c6872e749= c660d4cab705f 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include =20 @@ -4523,7 +4524,7 @@ static int xhci_set_usb2_hardware_lpm(struct usb_hcd = *hcd, hlpm_addr =3D ports[port_num]->addr + PORTHLPMC; =20 xhci_dbg(xhci, "%s port %d USB2 hardware LPM\n", - enable ? "enable" : "disable", port_num + 1); + str_enable_disable(enable), port_num + 1); =20 if (enable) { /* Host supports BESL timeout instead of HIRD */ --=20 2.43.0 From nobody Wed Dec 17 04:16:55 2025 Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 726CE20CCE9 for ; Tue, 14 Jan 2025 20:05:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736885156; cv=none; b=sPiQDm0Y3XbbZ3D8r6Yo6iqmurbM2mK1a3yQm7EwJXiatCmxWq5x3ZEQaC89YyHFBQ1Myq8vkCtPKwHZ+ycpZBJX1sjvNHZRfiR+mXgA1HmMo+w0yQAFbMsL6COUUa1hk97LNbJgikPFetVdcgVNQ/2IxyxM9p8zKk3lAc8GrOQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736885156; c=relaxed/simple; bh=op/DCt6ROIee0t+eYACLLqRtmspLz0pZPqJlNXnqaN4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=sQR2BRxpMzEkawbE64tPUVsNN2jlZ3xpGI+kN+OZG119z4imye5yi3/yNSEaCVJFDccasDTsQ8m+/fM2uYEDNb8D+ShPzYmVqM5sdL1/q9hMjI7w58MvGSQGVOPUNCFo+wxMdSVSb/x+DBhofEvFnJ3DQNSGbLmMh5cQBx0ufkw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=TziIXzGy; arc=none smtp.client-ip=209.85.128.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="TziIXzGy" Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-43620a5f81bso6426815e9.0 for ; Tue, 14 Jan 2025 12:05:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1736885152; x=1737489952; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=lUd9pE4ibsdIBdg8Wzjk/goShzuEiiFqbneq+H7LmXk=; b=TziIXzGyDyLgfbg4Svhvu3iuh2S6tnplo+/qWmClvhB1x5eKR50HyC3rBr0tdy25m8 3GF5cAuJyoIFL93gyU1+HmyuD9HFUdD68n0b9/gAMnlR5DL2j4Bce0oUXYn8YId33+cU CIf9cp1aHTIedHEq3FGilJPaC8mYjKIXvKQz9rW30h7r+r1a+5z5mF6EN78V2Dto9mgQ HYCtffWtnSMrJlLfXuzCt5FJAI97cVp0l5rN1UxvSJayNRDdbgJoIwToACbYJkm4z4K1 c9UZSA4klp+UqNuHBX/vslSlpjDlj3bKFQsBhfjd7wivDTyTlE90fjUT/fukhuCf/hNG c/6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736885152; x=1737489952; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lUd9pE4ibsdIBdg8Wzjk/goShzuEiiFqbneq+H7LmXk=; b=vWpDNfuvspzHqGSV6pCqpAECLTqlyFRn0geJy5wdwkdSH5qSkJ6AhTtQ+YGmvELovX RtPQdg3nUbt8tXNEseG2Hrh1H1BKIeY19/Av95o/53RgOPHGnWxv5QYWQ5WEo+DekJJJ 3g9usxtrP+Y8QXkLfh2Co/H6QKT7O/jbkYfkh3WiXomgTy+qpyOQEElxGjFSU0MD+1V8 uW32xKG6PnFT8EAMU9Be4Hw+XAYbw3tIwcG1l+SqNg3wiMlgBZfkfGLjJ5kG1OUwttNo 2+7+8yHedQpckQkndk0sUvmnq2CqTcztmpdwB+Mx8e4xGdYEk4ArqtX7Imu6Afl81ZM4 JukA== X-Forwarded-Encrypted: i=1; AJvYcCW0j64laGnRBMfzfK/iq/YJZpZdB5GTh0lBYwpYTLj0q2AKA+9jl6AXwwkbfbJ7fMuIxeceB3NJbsXcYUQ=@vger.kernel.org X-Gm-Message-State: AOJu0YyjWucrMQYm3eTPpDTTfjbk5z5nFyRsD9pNa/Jpum3olnzDCaRz UgphY36+tzmUJwn+2IFA6IiEGPJQezREr1b2u+txk+i9zpSgRvvyx7qKgQUwr5I= X-Gm-Gg: ASbGnctv+O7kiEbr7qSV8khmfIqQF68RLsPjv+03Tae/gCfRY2Qg6Ydh7PVQ3yKyR27 LvuVTM/nwtvk85ZMTX+hms2jXAonD0Sw+SRA2C+eBkyXuLzYkT25/TBIrIXEdkvikrc0N5KDnCI uO0Wdsa1BhQJb52LlNnbW27Z4SOkGWACWKG4+/ll1xIZUZrkm/bqj8NOCNgs/mYyFXons5Gzxod ZUwFZPtrbIHjQJ29XCtWsC3Fsaae0xQzVWYHjObki2Y41yydhowujdBuqyKegZq7h4Mo1bt X-Google-Smtp-Source: AGHT+IFMvUJ1WIMM1UnKEmJAeByugzBupQdHG12m5u1eVkgqRkIU1T58DOpbdwucugHJJCsq7sIZfQ== X-Received: by 2002:a05:600c:4e52:b0:434:a339:ec67 with SMTP id 5b1f17b1804b1-436eba35780mr83014555e9.3.1736885151629; Tue, 14 Jan 2025 12:05:51 -0800 (PST) Received: from [127.0.1.1] ([178.197.223.165]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-436e9dc8802sm184622025e9.10.2025.01.14.12.05.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jan 2025 12:05:50 -0800 (PST) From: Krzysztof Kozlowski Date: Tue, 14 Jan 2025 21:05:36 +0100 Subject: [PATCH 3/6] USB: typec: Use str_enable_disable-like helpers Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250114-str-enable-disable-usb-v1-3-c8405df47c19@linaro.org> References: <20250114-str-enable-disable-usb-v1-0-c8405df47c19@linaro.org> In-Reply-To: <20250114-str-enable-disable-usb-v1-0-c8405df47c19@linaro.org> To: Greg Kroah-Hartman , Mathias Nyman , Thierry Reding , Jonathan Hunter , Heikki Krogerus , Andrew Jeffery , Nicolas Ferre , Alexandre Belloni , Claudiu Beznea , Daniel Mack , Haojian Zhuang , Robert Jarzmik , Peter Chen , Linus Walleij , Alan Stern Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, usb-storage@lists.one-eyed-alien.net, Krzysztof Kozlowski X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=10285; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=op/DCt6ROIee0t+eYACLLqRtmspLz0pZPqJlNXnqaN4=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBnhsOT5omtXZe4pNX5FucIXi5M/SLvLnE6Fx0dg 5RFTZwpizSJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZ4bDkwAKCRDBN2bmhouD 1wniEACTnxh/J9HADUSXH/B4PxpTjFV+HrzcRy0yJFO5nAqDf8CUvzoxy5LiOSJDsxsv27LeepD N5ehvpyz+w2gWupb8eKYhihGTkZ1w0IyNmJj6Ohn4aBEU9WxRZyebFGmFgq+U+5Yq3MgEfoEDl9 KLU9ATXXCmI42YpRmlk8329azwR3r8wRSmREHw9PbPr1Q997cij4f6FSC5kDaf7XqNFkq3Biy7r sEKxzqtAq+1zMUbuRJqVoc5bDq1zmjPaX5XF9BSD1luW+oTxpU5XewskSF2zy4llNlDkvOBhpUf brYhgStgG0YmQovvVmwGF13nw6GRW3xN/8/O7VG1jmMJMg8U3XDEHcRJFG1uyfxZelW5vyKCFr0 yNMHm1IfLNSSd0BhcGE/R4kUyI6N/XkeZJzVba/Kc5KZA7HVTb+CSpIBtIJuKtpm39WM+W60PHx qSoLgrOPGXZ7fArYjAsMCi2yWV/ZbGsWzpCAblo9RjEYJnvrxUhNTJ181Oy/dCLY58C86yX2j5H noV1BpUMujRYSzzVCK93IgHmRlnfKI9vkAa0hJPXjsbXDcJjMtDlNEFGlcCnRGzSSGK2ASCSXY0 nDWJOYR13ka9BCCBi+4IFPoETK1PdZLOY0+MSfRDgq+ikD5D/uZlMz7v8y0W7VtlqdLvOeEVUr+ DK2pcX225G0ItrA== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B Replace ternary (condition ? "enable" : "disable") syntax with helpers from string_choices.h because: 1. Simple function call with one argument is easier to read. Ternary operator has three arguments and with wrapping might lead to quite long code. 2. Is slightly shorter thus also easier to read. 3. It brings uniformity in the text - same string. 4. Allows deduping by the linker, which results in a smaller binary file. Signed-off-by: Krzysztof Kozlowski Reviewed-by: Heikki Krogerus --- drivers/usb/typec/class.c | 7 ++++--- drivers/usb/typec/tcpm/fusb302.c | 24 +++++++++++-------= ---- .../usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c | 3 ++- .../typec/tcpm/qcom/qcom_pmic_typec_pdphy_stub.c | 3 ++- drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.c | 4 +++- drivers/usb/typec/tcpm/tcpm.c | 7 ++++--- 6 files changed, 27 insertions(+), 21 deletions(-) diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c index d9d019cff01908eaa8dcb484a87147f3d9992bf3..9c76c3d0c6cff9c9b94ef35fb0c= b4be0e395aad6 100644 --- a/drivers/usb/typec/class.c +++ b/drivers/usb/typec/class.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -361,7 +362,7 @@ active_show(struct device *dev, struct device_attribute= *attr, char *buf) { struct typec_altmode *alt =3D to_typec_altmode(dev); =20 - return sprintf(buf, "%s\n", alt->active ? "yes" : "no"); + return sprintf(buf, "%s\n", str_yes_no(alt->active)); } =20 static ssize_t active_store(struct device *dev, struct device_attribute *a= ttr, @@ -707,7 +708,7 @@ static ssize_t supports_usb_power_delivery_show(struct = device *dev, { struct typec_partner *p =3D to_typec_partner(dev); =20 - return sprintf(buf, "%s\n", p->usb_pd ? "yes" : "no"); + return sprintf(buf, "%s\n", str_yes_no(p->usb_pd)); } static DEVICE_ATTR_RO(supports_usb_power_delivery); =20 @@ -1855,7 +1856,7 @@ static ssize_t vconn_source_show(struct device *dev, struct typec_port *port =3D to_typec_port(dev); =20 return sprintf(buf, "%s\n", - port->vconn_role =3D=3D TYPEC_SOURCE ? "yes" : "no"); + str_yes_no(port->vconn_role =3D=3D TYPEC_SOURCE)); } static DEVICE_ATTR_RW(vconn_source); =20 diff --git a/drivers/usb/typec/tcpm/fusb302.c b/drivers/usb/typec/tcpm/fusb= 302.c index e2fe479e16ada018930ea0dbbf58ee37ce9a1990..f15c63d3a8f441569ec98302f5b= 241430d8e4547 100644 --- a/drivers/usb/typec/tcpm/fusb302.c +++ b/drivers/usb/typec/tcpm/fusb302.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -733,7 +734,7 @@ static int tcpm_set_vconn(struct tcpc_dev *dev, bool on) =20 mutex_lock(&chip->lock); if (chip->vconn_on =3D=3D on) { - fusb302_log(chip, "vconn is already %s", on ? "On" : "Off"); + fusb302_log(chip, "vconn is already %s", str_on_off(on)); goto done; } if (on) { @@ -746,7 +747,7 @@ static int tcpm_set_vconn(struct tcpc_dev *dev, bool on) if (ret < 0) goto done; chip->vconn_on =3D on; - fusb302_log(chip, "vconn :=3D %s", on ? "On" : "Off"); + fusb302_log(chip, "vconn :=3D %s", str_on_off(on)); done: mutex_unlock(&chip->lock); =20 @@ -761,7 +762,7 @@ static int tcpm_set_vbus(struct tcpc_dev *dev, bool on,= bool charge) =20 mutex_lock(&chip->lock); if (chip->vbus_on =3D=3D on) { - fusb302_log(chip, "vbus is already %s", on ? "On" : "Off"); + fusb302_log(chip, "vbus is already %s", str_on_off(on)); } else { if (on) ret =3D regulator_enable(chip->vbus); @@ -769,15 +770,14 @@ static int tcpm_set_vbus(struct tcpc_dev *dev, bool o= n, bool charge) ret =3D regulator_disable(chip->vbus); if (ret < 0) { fusb302_log(chip, "cannot %s vbus regulator, ret=3D%d", - on ? "enable" : "disable", ret); + str_enable_disable(on), ret); goto done; } chip->vbus_on =3D on; - fusb302_log(chip, "vbus :=3D %s", on ? "On" : "Off"); + fusb302_log(chip, "vbus :=3D %s", str_on_off(on)); } if (chip->charge_on =3D=3D charge) - fusb302_log(chip, "charge is already %s", - charge ? "On" : "Off"); + fusb302_log(chip, "charge is already %s", str_on_off(charge)); else chip->charge_on =3D charge; =20 @@ -854,16 +854,16 @@ static int tcpm_set_pd_rx(struct tcpc_dev *dev, bool = on) ret =3D fusb302_pd_set_auto_goodcrc(chip, on); if (ret < 0) { fusb302_log(chip, "cannot turn %s auto GCRC, ret=3D%d", - on ? "on" : "off", ret); + str_on_off(on), ret); goto done; } ret =3D fusb302_pd_set_interrupts(chip, on); if (ret < 0) { fusb302_log(chip, "cannot turn %s pd interrupts, ret=3D%d", - on ? "on" : "off", ret); + str_on_off(on), ret); goto done; } - fusb302_log(chip, "pd :=3D %s", on ? "on" : "off"); + fusb302_log(chip, "pd :=3D %s", str_on_off(on)); done: mutex_unlock(&chip->lock); =20 @@ -1531,7 +1531,7 @@ static void fusb302_irq_work(struct work_struct *work) if (interrupt & FUSB_REG_INTERRUPT_VBUSOK) { vbus_present =3D !!(status0 & FUSB_REG_STATUS0_VBUSOK); fusb302_log(chip, "IRQ: VBUS_OK, vbus=3D%s", - vbus_present ? "On" : "Off"); + str_on_off(vbus_present)); if (vbus_present !=3D chip->vbus_present) { chip->vbus_present =3D vbus_present; tcpm_vbus_change(chip->tcpm_port); @@ -1562,7 +1562,7 @@ static void fusb302_irq_work(struct work_struct *work) if ((interrupt & FUSB_REG_INTERRUPT_COMP_CHNG) && intr_comp_chng) { comp_result =3D !!(status0 & FUSB_REG_STATUS0_COMP); fusb302_log(chip, "IRQ: COMP_CHNG, comp=3D%s", - comp_result ? "true" : "false"); + str_true_false(comp_result)); if (comp_result) { /* cc level > Rd_threshold, detach */ chip->cc1 =3D TYPEC_CC_OPEN; diff --git a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c b/drivers/= usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c index 726423684bae0a690bd20547313704b7d2f4cfdc..18303b34594bbf6f43d1138177c= 4ab58f0dec395 100644 --- a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c +++ b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include "qcom_pmic_typec.h" @@ -418,7 +419,7 @@ static int qcom_pmic_typec_pdphy_set_pd_rx(struct tcpc_= dev *tcpc, bool on) =20 spin_unlock_irqrestore(&pmic_typec_pdphy->lock, flags); =20 - dev_dbg(pmic_typec_pdphy->dev, "set_pd_rx: %s\n", on ? "on" : "off"); + dev_dbg(pmic_typec_pdphy->dev, "set_pd_rx: %s\n", str_on_off(on)); =20 return ret; } diff --git a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy_stub.c b/dri= vers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy_stub.c index df79059cda6755d4de35b7239fadc2dff2e699b1..8fac171778daf471fe4d03de8cc= 4f9c7ce1f323b 100644 --- a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy_stub.c +++ b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy_stub.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include "qcom_pmic_typec.h" @@ -38,7 +39,7 @@ static int qcom_pmic_typec_pdphy_stub_set_pd_rx(struct tc= pc_dev *tcpc, bool on) struct pmic_typec *tcpm =3D tcpc_to_tcpm(tcpc); struct device *dev =3D tcpm->dev; =20 - dev_dbg(dev, "set_pd_rx: %s\n", on ? "on" : "off"); + dev_dbg(dev, "set_pd_rx: %s\n", str_on_off(on)); =20 return 0; } diff --git a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.c b/drivers/u= sb/typec/tcpm/qcom/qcom_pmic_typec_port.c index c37dede62e12cd8a105da108838b5ca4f5e632d7..4fc83dcfae643e7a8b8e89ac6e6= f5a9aaba3f65b 100644 --- a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.c +++ b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -562,7 +563,8 @@ static int qcom_pmic_typec_port_set_vconn(struct tcpc_d= ev *tcpc, bool on) spin_unlock_irqrestore(&pmic_typec_port->lock, flags); =20 dev_dbg(dev, "set_vconn: orientation %d control 0x%08x state %s cc %s vco= nn %s\n", - orientation, value, on ? "on" : "off", misc_to_vconn(misc), misc_to_cc(m= isc)); + orientation, value, str_on_off(on), misc_to_vconn(misc), + misc_to_cc(misc)); =20 return ret; } diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c index fcf2d7902352c447651f30610d59fef2471f3124..ef2cec386d965512c64e8b7e640= 199e10bb7bc94 100644 --- a/drivers/usb/typec/tcpm/tcpm.c +++ b/drivers/usb/typec/tcpm/tcpm.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -892,8 +893,8 @@ static int tcpm_enable_auto_vbus_discharge(struct tcpm_= port *port, bool enable) =20 if (port->tcpc->enable_auto_vbus_discharge) { ret =3D port->tcpc->enable_auto_vbus_discharge(port->tcpc, enable); - tcpm_log_force(port, "%s vbus discharge ret:%d", enable ? "enable" : "di= sable", - ret); + tcpm_log_force(port, "%s vbus discharge ret:%d", + str_enable_disable(enable), ret); if (!ret) port->auto_vbus_discharge_enabled =3D enable; } @@ -4439,7 +4440,7 @@ static void tcpm_unregister_altmodes(struct tcpm_port= *port) =20 static void tcpm_set_partner_usb_comm_capable(struct tcpm_port *port, bool= capable) { - tcpm_log(port, "Setting usb_comm capable %s", capable ? "true" : "false"); + tcpm_log(port, "Setting usb_comm capable %s", str_true_false(capable)); =20 if (port->tcpc->set_partner_usb_comm_capable) port->tcpc->set_partner_usb_comm_capable(port->tcpc, capable); --=20 2.43.0 From nobody Wed Dec 17 04:16:55 2025 Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E6DEA20DD51 for ; Tue, 14 Jan 2025 20:05:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736885157; cv=none; b=VgV0jvFnbYWB65PQXZUMvqO+726qdr5MbksimHAbbyNMW7fmTEAUPQyr2zu+TzdHOmHi1UIJP9Mo2szCdXE1vSfieCHj1/m4Zpziu2wgtOEFgpN5lXIVzwlp0BgV7tuV17PJENFuqphhPhXiKb7h01Bn57gNvcS4QP3PXMMrgaw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736885157; c=relaxed/simple; bh=U9HpxC9pEH0EWD9Q/rURtR7vQ0PaHWPP6MGt75vQgGI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=DQbIjPaRWYWOh+uOsz9Dx5dii3VOh6ObAMMgSXTriWdmIXjReNqdbPMvBPGz2CBfsym+Ml4apkyNE5Yb2N41FLb9E8LR9++t8PFyBLWDw/fYBLjY57YqBtTvl4gt6UoLPwN3eYeVnX2VGdHecvC09m8AmgoJiftnM1hRAXmgS4A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=nI5KfqqV; arc=none smtp.client-ip=209.85.128.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="nI5KfqqV" Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-4361e82e3c3so7463435e9.0 for ; Tue, 14 Jan 2025 12:05:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1736885154; x=1737489954; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=Nu6/XX3P+UDLqPCZUwHTSPpolsKgeM4I+r25no45AIw=; b=nI5KfqqVyKqxpIFkLPKRy6IQiWtS2WnJd9vp48Hkbihk5dyqoPsf8TXo8xiN13MZtA 82qtxXljqDyfLyODuqW2+vjsOtb3HlJtJHliDRPNigje+XLGIRBdII4Sz/8tMM2uwW8Y o9flK+kFu3XUzFy6fMyCMnmiI+3zZTG4xmo2GfG96Sx3BfgMh7e0xl6vKCPM8e/m1qF3 31f2UTpVnhGExsBhHe9kbfJ0uHWpaz8ODkJPYMuuqS4SpiOQplrxrN/3aMZcoV0L3HRf kj2xK42yfr1te0e3/TUNaGSIXOP4fYQFF3PAKYoTwLhJyvB2KaV6yw+SxoRCxaIFE0+c zDmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736885154; x=1737489954; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Nu6/XX3P+UDLqPCZUwHTSPpolsKgeM4I+r25no45AIw=; b=cEpoRRor222hAo8fd/bmbFcs3mb/jY7YQVC4/+WasBO9aLztRR8I4bxxGr4egrol2d JCxleJBoh9i+cHlXM4sB303zztEoAUmb7WiKzlQu2bCG64eUyon6nozuWp6KtW9wjJUd qapRhy6O0iyiTPI+4FrgD+isiqijFpd47h3tqGGauT/3haSBwTkVnpFDqESsRVrlCxQt BS8KjmGTzlme6bAIg7avNXKl2xa8Nff6UMdZ6igUmG1QXCKlAX3lHg7PXbWVe5EIoaog Gwu5i7IQUgKzcx0wXsPkzzDMOZv3FOQYo+9+N5gCVf+FZLe7W9hbHXf6HSbCpx2e4lAW RJyg== X-Forwarded-Encrypted: i=1; AJvYcCWbVqf2RasbZUqYnZGhETKox9S1+lKeLYu0J1xs0gLRQD3Ogl2SXdoHaUoYOCVMz0IVRC651kGUbdbmAdE=@vger.kernel.org X-Gm-Message-State: AOJu0Yx0zayNYY5KNJH9nwSbRItBOB/eZmcfj+18yh0qHzDkQ62IuySN bZHnNL/6ETmM8aFIBpFW2q+VI3pcPCqh2R0f21qZgl4ZE6WtPc6zm/i8/f7hPdY= X-Gm-Gg: ASbGnctUoTGFP+RcI3UzlBkWCH/NpoQIUXLSB4GimSqn756Ljhwrjf2SoNwkO3Y5Eq7 9CV/wEU1vHGIzqOwnR+80FEzed/4HzcTlR6xXFLddgzTsTwg6Hpki4QwOf18yrfUxUCyI/gA/Z3 SBW9WC8DD/0eltMBgKWhxS/668EmwgpKQRQTOxatZCpUDd/folDISwTJBJtH3FLRo12Vau90V3U CgAsjLyzVqsr+N9UFFIrlAhc8I5PDIM6K7/eW4WnnsKEsEgfquimULKNvt/X+TV+QjKuvxm X-Google-Smtp-Source: AGHT+IGBhkeOheEjYD/B1unZiV+4XE8yV1wVFVbnVs8thkNOHSXe8ezrHomgdhQRKHJpnJtTQ3WDig== X-Received: by 2002:a05:600c:3ca0:b0:436:17f4:9b3b with SMTP id 5b1f17b1804b1-436e270729bmr101202205e9.6.1736885154241; Tue, 14 Jan 2025 12:05:54 -0800 (PST) Received: from [127.0.1.1] ([178.197.223.165]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-436e9dc8802sm184622025e9.10.2025.01.14.12.05.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jan 2025 12:05:52 -0800 (PST) From: Krzysztof Kozlowski Date: Tue, 14 Jan 2025 21:05:37 +0100 Subject: [PATCH 4/6] USB: phy: Use str_enable_disable-like helpers Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250114-str-enable-disable-usb-v1-4-c8405df47c19@linaro.org> References: <20250114-str-enable-disable-usb-v1-0-c8405df47c19@linaro.org> In-Reply-To: <20250114-str-enable-disable-usb-v1-0-c8405df47c19@linaro.org> To: Greg Kroah-Hartman , Mathias Nyman , Thierry Reding , Jonathan Hunter , Heikki Krogerus , Andrew Jeffery , Nicolas Ferre , Alexandre Belloni , Claudiu Beznea , Daniel Mack , Haojian Zhuang , Robert Jarzmik , Peter Chen , Linus Walleij , Alan Stern Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, usb-storage@lists.one-eyed-alien.net, Krzysztof Kozlowski X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=3021; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=U9HpxC9pEH0EWD9Q/rURtR7vQ0PaHWPP6MGt75vQgGI=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBnhsOTPwA/vm8owUe4EJZse5Hr4rjlTRWXCB2aG KDucAG0092JAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZ4bDkwAKCRDBN2bmhouD 11++EACY8+eR+j3tvSf+ncTv3YQsKVEU2LFwS6tJbJCtwQQAxxSlEHMS38SL3z3TjXBKaWCJhHe I7Wvb5qUM66zzBAbOq8HxnfInql3Vuh/7o3+qBSmnjj6JgFZ/1miQRUPjTBxVUniz4H5z5WF2Ur p0mIfk1MqxGLV+dZkzanl6GwmamqQsRP5GR2zluh77lUmb0fJ5/Tw7tZ/8WsY463w19lqZYAsrW tLWR+TfRKuVvJORSgxABSxAxsOyQehKbiTPVW+VpOwBLfiydGkmRbLqNawdvPeW1KM0YM7eeS1o YeW+dujSWP10wXtF7/B4bM8bXByrPxuCgMyRxo3i+3prm7sQ+CBmse57sSPb7pLwwiI8VtSSnzX xyA7aQk6X1trGVNnAvFX7UiiPlWQwU4czybDh27fiLvixBADIsU2xvgIuXDU+fuqXzrs25j0YzY ZpozRJLPjCAAVQ4zmJmNNDgjsRRw5CJgkXFK+/XiAxmaPOMs7bwnj4WqXEkgDkZ9e1LTL9UL8EQ nLugIwjUe9M/Q6inM/mdBXLYQCIqgxBMEyEQiC5DZeC9KvXDrIKDxjq/b9be9+DmL+cj2S2BeG4 GIzWLaWePDlxjuY18oKvhroo/E9Nm09ltQk+dxiRCzEMz+rSSypXWNGBbna5xt3VfZx8P3Nc23P hytQ2OSgUK9arkw== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B Replace ternary (condition ? "enable" : "disable") syntax with helpers from string_choices.h because: 1. Simple function call with one argument is easier to read. Ternary operator has three arguments and with wrapping might lead to quite long code. 2. Is slightly shorter thus also easier to read. 3. It brings uniformity in the text - same string. 4. Allows deduping by the linker, which results in a smaller binary file. Signed-off-by: Krzysztof Kozlowski --- drivers/usb/phy/phy-fsl-usb.c | 3 ++- drivers/usb/phy/phy-mv-usb.c | 3 ++- drivers/usb/phy/phy-tahvo.c | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/usb/phy/phy-fsl-usb.c b/drivers/usb/phy/phy-fsl-usb.c index 42c42e1932326c66c842f03b8060af2909a50aa0..40ac68e52cee73d168960e3588a= 4a0d87a88e1c1 100644 --- a/drivers/usb/phy/phy-fsl-usb.c +++ b/drivers/usb/phy/phy-fsl-usb.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -529,7 +530,7 @@ int fsl_otg_start_gadget(struct otg_fsm *fsm, int on) if (!otg->gadget || !otg->gadget->dev.parent) return -ENODEV; =20 - VDBG("gadget %s\n", on ? "on" : "off"); + VDBG("gadget %s\n", str_on_off(on)); dev =3D otg->gadget->dev.parent; =20 if (on) { diff --git a/drivers/usb/phy/phy-mv-usb.c b/drivers/usb/phy/phy-mv-usb.c index a7a102f2e163facb7797664a8999207419ae33fd..30d6c8840a5e6af8df05acffa93= a806af47047b2 100644 --- a/drivers/usb/phy/phy-mv-usb.c +++ b/drivers/usb/phy/phy-mv-usb.c @@ -15,6 +15,7 @@ #include #include #include +#include =20 #include #include @@ -217,7 +218,7 @@ static void mv_otg_start_periphrals(struct mv_otg *mvot= g, int on) if (!otg->gadget) return; =20 - dev_info(mvotg->phy.dev, "gadget %s\n", on ? "on" : "off"); + dev_info(mvotg->phy.dev, "gadget %s\n", str_on_off(on)); =20 if (on) usb_gadget_vbus_connect(otg->gadget); diff --git a/drivers/usb/phy/phy-tahvo.c b/drivers/usb/phy/phy-tahvo.c index ae7bf3ff89ee176d730d2fb1e7377ce4835b7c6f..88607d0edb01485902f611e4e50= 1dec2946d9939 100644 --- a/drivers/usb/phy/phy-tahvo.c +++ b/drivers/usb/phy/phy-tahvo.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -63,7 +64,7 @@ static ssize_t vbus_show(struct device *device, struct device_attribute *attr, char *buf) { struct tahvo_usb *tu =3D dev_get_drvdata(device); - return sprintf(buf, "%s\n", tu->vbus_state ? "on" : "off"); + return sprintf(buf, "%s\n", str_on_off(tu->vbus_state)); } static DEVICE_ATTR_RO(vbus); =20 --=20 2.43.0 From nobody Wed Dec 17 04:16:55 2025 Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AEFBA20E331 for ; Tue, 14 Jan 2025 20:05:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736885159; cv=none; b=KrCx22MyxiMcy1BHURdPNjcrJmF/73wUofDYGHbxl8sVgGfexR9L0whiCFkmYPV+AEmBBiL37rkUbBDqMrV49j1xVHG0gYVH01rhRQZ25Pn0sbKVyASosJvF/iUpBQVEdDGyXHVMqPvUKWzauTAOQFKI9FK4WlNTWqIpYin0GL4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736885159; c=relaxed/simple; bh=ChnARzU8vkZ4N8/sOQo0Ix2BDfajX6xlMScKMcecQCo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ZRysTT+h+0nwZDslt1vyW2RkrEZSch+QiL1rKctLWdhnsj/MyUlilizbwj6SDp6Oc0DoziCuN3vvVbsQxi+FIH1KJfgHdmrYQhIj+nIdtk7kUilfr29bd7b1m19cx4UEdHIhpfcRAWnf0GlmI0Epgq7yANCRS0FETc0oWiPmNIw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=Rld9k4J1; arc=none smtp.client-ip=209.85.221.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Rld9k4J1" Received: by mail-wr1-f47.google.com with SMTP id ffacd0b85a97d-38625aa01b3so571715f8f.3 for ; Tue, 14 Jan 2025 12:05:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1736885156; x=1737489956; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=TTD6x1Lk041c+VoW0XQVNqPy/PU8FV8OyNgCvVmY2nI=; b=Rld9k4J1NLBnK53Ec3v7xQoASqry9SxVHSCS0xULH0LrLIWvDumxYfzpD+H4KalGQv bL6o+XMEvIG9gSxVk6awNvmnnXfw6zQyzkjxOWPfL/ZhCc30OuS+JC8aRH+uPAJl/9Qq +lBl+A8GLpe9XJbgEpHF9wnAm+JUoSiMWuIJdE1kkYKApIAZ/QbdjqjC5YXDK6JIbrgy zIy70TOaLGj8fCFk6JfDH37cFUm+LiaaluNYYepnWS0L3qmXg71wvijYMuyFGVKb7uSN +kdjGeMjc9Mv+5ax8Gu1YKoy+rl9bVgCKnWGXlIwt180XwVi/nBmuoIjXsc92xxT9bPA SNmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736885156; x=1737489956; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TTD6x1Lk041c+VoW0XQVNqPy/PU8FV8OyNgCvVmY2nI=; b=XIcJju6MJc6M5C8QSTPANeppf5ekX8BgiAPie5aWcKLgGE/FHP9wySxIH4ncSyhhcr K9xcEznKNoVPL8KUjSskCD9qcszqCSD9ne+72IlFm79U7d2qB7z8lUxOyUDqYWsr5Gjj z6MojA/7SbhUlwgDzIDON6OpgNyBOyluXKL3U7joQhTHMugZ/IHo4RO7iNePOXHlZL9l v1Ux83NrqCI9EkDLGG6kOo4FgBBm2QhciId+Ox41wkGKbvCn7a9RzLK53iBtaYiHjJXl CJEf4OyLIQVKeEHYC1p5eouOhEI/v032BxxgE1CXYDPMVRct72trGx4KvJYkujyXPyYT mKmA== X-Forwarded-Encrypted: i=1; AJvYcCVr2yd4+trtJRpMe2xPxPdm23Ck6nL/UtdinmMubcRucJ8L1GIVewd1rz/OFVNkyrtEBqNPNJhz9Zq5TwE=@vger.kernel.org X-Gm-Message-State: AOJu0YzGt7ZjHw/NcTVqiu1OKvxT8F9DhK/hU+AqOU5xrS+yubxAk9MQ 2n0TA0V1fmVcrJJfojQvF5YtTgvovZvn2IzpRa3zAOM/lnoOcZqv8K82LjQkisE= X-Gm-Gg: ASbGnct8gVJ5EcDeSekfQfiKMgoXbS2i8ehUnG6tHKWzpEEmdT8QsB2NuyUki37abox UarHTVcIAd/t3oadO0amiJaRhWqgKJ02jMpPLTD9e4M7qk6Ze9o+8IKBCLCOo+3UNrleB6/8t5I SfaGpoYfiwGwMyBHgLR/D33Z4MKHZMzFIIKMMv5GLQ0rMzQRB0P+NP44ozr4Unc2QDSmhn+z5hk cajGjEl+smCBAR6M6LmDtyMMCyMK1X239VTji3ngTQZTHxXoHQGuoqpLMqOWH9ZOR06CI2c X-Google-Smtp-Source: AGHT+IGxND6xy5nbDMXlLJof5zJ1WURbjIRC0t+BVySYcz+h6/d0aMJOQigcunQUz7PnqwmnaXQnTQ== X-Received: by 2002:adf:9ccd:0:b0:38a:5557:7677 with SMTP id ffacd0b85a97d-38a872e161dmr7612204f8f.5.1736885155913; Tue, 14 Jan 2025 12:05:55 -0800 (PST) Received: from [127.0.1.1] ([178.197.223.165]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-436e9dc8802sm184622025e9.10.2025.01.14.12.05.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jan 2025 12:05:55 -0800 (PST) From: Krzysztof Kozlowski Date: Tue, 14 Jan 2025 21:05:38 +0100 Subject: [PATCH 5/6] USB: gadget: Use str_enable_disable-like helpers Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250114-str-enable-disable-usb-v1-5-c8405df47c19@linaro.org> References: <20250114-str-enable-disable-usb-v1-0-c8405df47c19@linaro.org> In-Reply-To: <20250114-str-enable-disable-usb-v1-0-c8405df47c19@linaro.org> To: Greg Kroah-Hartman , Mathias Nyman , Thierry Reding , Jonathan Hunter , Heikki Krogerus , Andrew Jeffery , Nicolas Ferre , Alexandre Belloni , Claudiu Beznea , Daniel Mack , Haojian Zhuang , Robert Jarzmik , Peter Chen , Linus Walleij , Alan Stern Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, usb-storage@lists.one-eyed-alien.net, Krzysztof Kozlowski X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=10986; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=ChnARzU8vkZ4N8/sOQo0Ix2BDfajX6xlMScKMcecQCo=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBnhsOUr4DH74j1XH0iJ+MUvhAzl6rXxBkoviRuh xhBDndCrD2JAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZ4bDlAAKCRDBN2bmhouD 1xigD/9uO2A+K9X0l9z0fBURd0QHpksk5JEq9mdkT/Eotp4sPG9oTB1mL4QvKsIkKwHjHHZ7PT2 hujen0zuhWUDLbnwOAmDlS9Qlr5j5RdUOTW5ua36V1fFyCs11eeBegKf8jfe8jS1H7BFgMBm7B0 9qmpzfRTnjW6PpuD0gz0WmFKrxGUsDPkJWVOP+96+hdW4rPz5FEnbdXlbKmULDqp03Pq8OSGbOJ eOiVtSmqR1CZthgT47JRgufY5LIG/ZekfqD1eGToTeWX7J3HuNTQdUtATiG8g8v8djikaZxS4nv 02bigHcvqTpRO1HCmY9/rpz9tonb/mryOTFnWuloA/e6LDuBAJ/DR4phr9F+P2170GYxO3aDkPJ 3JUbFlnsfdg4LRXyqteXvGlN/jg1IKR/Dm5vvWRqZ91ke5odvDAGhRrVplUFXfACEXO0WX54eEh lGzup+iWi6CmWs1ZJSE7NCilxzF2Jb0UEpi/b6OeRZwaHoCfTzsmGa3GQEkmmLXbfohrc6TiTqf CJ1lKguZ8PeHU7y2OwlE7IVeVhlhTC5c4AtONfmHnk9Gkv1hoIW0/1TK15Y4skTAE7ZfV7lV1XR E63O5dIXpabPWDRxosZnAwVYEtlHxp4ysuLa1XPj0dFl6lkPP8DHnLsqIPZ53dhseGezkL3rp49 VpAd+QxCNWc+iPA== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B Replace ternary (condition ? "enable" : "disable") syntax with helpers from string_choices.h because: 1. Simple function call with one argument is easier to read. Ternary operator has three arguments and with wrapping might lead to quite long code. 2. Is slightly shorter thus also easier to read. 3. It brings uniformity in the text - same string. 4. Allows deduping by the linker, which results in a smaller binary file. Signed-off-by: Krzysztof Kozlowski Reviewed-by: Andrew Jeffery #aspeed --- drivers/usb/gadget/function/f_ecm.c | 4 ++-- drivers/usb/gadget/function/f_ncm.c | 3 ++- drivers/usb/gadget/function/u_serial.c | 3 ++- drivers/usb/gadget/legacy/inode.c | 3 ++- drivers/usb/gadget/udc/aspeed-vhub/hub.c | 3 ++- drivers/usb/gadget/udc/at91_udc.c | 3 ++- drivers/usb/gadget/udc/cdns2/cdns2-gadget.c | 13 +++++++------ drivers/usb/gadget/udc/dummy_hcd.c | 3 ++- drivers/usb/gadget/udc/fsl_udc_core.c | 3 ++- drivers/usb/gadget/udc/omap_udc.c | 3 ++- drivers/usb/gadget/udc/pxa27x_udc.c | 3 ++- 11 files changed, 27 insertions(+), 17 deletions(-) diff --git a/drivers/usb/gadget/function/f_ecm.c b/drivers/usb/gadget/funct= ion/f_ecm.c index 6cb7771e8a692dbf555d65f4b3699b2a62c85cec..80841de845b09129564cb6d1b77= 10f8b76174292 100644 --- a/drivers/usb/gadget/function/f_ecm.c +++ b/drivers/usb/gadget/function/f_ecm.c @@ -13,6 +13,7 @@ #include #include #include +#include =20 #include "u_ether.h" #include "u_ether_configfs.h" @@ -387,8 +388,7 @@ static void ecm_do_notify(struct f_ecm *ecm) event->wLength =3D 0; req->length =3D sizeof *event; =20 - DBG(cdev, "notify connect %s\n", - ecm->is_open ? "true" : "false"); + DBG(cdev, "notify connect %s\n", str_true_false(ecm->is_open)); ecm->notify_state =3D ECM_NOTIFY_SPEED; break; =20 diff --git a/drivers/usb/gadget/function/f_ncm.c b/drivers/usb/gadget/funct= ion/f_ncm.c index 8e761249d672c7b079f2c9ec13cbe9644251ec94..f60576a65ca67e84d8d4d568171= bea2e6b4fcfe7 100644 --- a/drivers/usb/gadget/function/f_ncm.c +++ b/drivers/usb/gadget/function/f_ncm.c @@ -17,6 +17,7 @@ #include #include #include +#include =20 #include =20 @@ -558,7 +559,7 @@ static void ncm_do_notify(struct f_ncm *ncm) req->length =3D sizeof *event; =20 DBG(cdev, "notify connect %s\n", - ncm->is_open ? "true" : "false"); + str_true_false(ncm->is_open)); ncm->notify_state =3D NCM_NOTIFY_NONE; break; =20 diff --git a/drivers/usb/gadget/function/u_serial.c b/drivers/usb/gadget/fu= nction/u_serial.c index bc143a86c2ddf07cba0d3ab6ada41387bc0d4bec..5413882b149812a141cc641be99= e216d0b11006a 100644 --- a/drivers/usb/gadget/function/u_serial.c +++ b/drivers/usb/gadget/function/u_serial.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -1545,7 +1546,7 @@ static int __init userial_init(void) =20 pr_debug("%s: registered %d ttyGS* device%s\n", __func__, MAX_U_SERIAL_PORTS, - (MAX_U_SERIAL_PORTS =3D=3D 1) ? "" : "s"); + str_plural(MAX_U_SERIAL_PORTS)); =20 return status; fail: diff --git a/drivers/usb/gadget/legacy/inode.c b/drivers/usb/gadget/legacy/= inode.c index 9c7381661016daa3a1a61d0509e57210d5f5e682..b6a30d88a800347de9d8e274923= bd24b58018b53 100644 --- a/drivers/usb/gadget/legacy/inode.c +++ b/drivers/usb/gadget/legacy/inode.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -1182,7 +1183,7 @@ ep0_fasync (int f, struct file *fd, int on) { struct dev_data *dev =3D fd->private_data; // caller must F_SETOWN before signal delivery happens - VDEBUG (dev, "%s %s\n", __func__, on ? "on" : "off"); + VDEBUG(dev, "%s %s\n", __func__, str_on_off(on)); return fasync_helper (f, fd, on, &dev->fasync); } =20 diff --git a/drivers/usb/gadget/udc/aspeed-vhub/hub.c b/drivers/usb/gadget/= udc/aspeed-vhub/hub.c index a63e4af60a56a9a0b00c2828c4de14f31b13e033..02fe1a08d5757e9e3e21e874766= d3cee1305e555 100644 --- a/drivers/usb/gadget/udc/aspeed-vhub/hub.c +++ b/drivers/usb/gadget/udc/aspeed-vhub/hub.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -219,7 +220,7 @@ static int ast_vhub_hub_dev_feature(struct ast_vhub_ep = *ep, if (wValue =3D=3D USB_DEVICE_REMOTE_WAKEUP) { ep->vhub->wakeup_en =3D is_set; EPDBG(ep, "Hub remote wakeup %s\n", - is_set ? "enabled" : "disabled"); + str_enabled_disabled(is_set)); return std_req_complete; } =20 diff --git a/drivers/usb/gadget/udc/at91_udc.c b/drivers/usb/gadget/udc/at9= 1_udc.c index e3af4ec3794e2ef871bc252948b6121921623704..aa4c61094dc6fa379de04f08f3b= 771dcafe942b3 100644 --- a/drivers/usb/gadget/udc/at91_udc.c +++ b/drivers/usb/gadget/udc/at91_udc.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -131,7 +132,7 @@ static void proc_ep_show(struct seq_file *s, struct at9= 1_ep *ep) seq_printf(s, "csr %08x rxbytes=3D%d %s %s %s" EIGHTBITS "\n", csr, (csr & 0x07ff0000) >> 16, - (csr & (1 << 15)) ? "enabled" : "disabled", + str_enabled_disabled(csr & (1 << 15)), (csr & (1 << 11)) ? "DATA1" : "DATA0", types[(csr & 0x700) >> 8], =20 diff --git a/drivers/usb/gadget/udc/cdns2/cdns2-gadget.c b/drivers/usb/gadg= et/udc/cdns2/cdns2-gadget.c index 62fce42ef2dabd18643e3d933426025a17cdb9f1..7e69944ef18a91ab51f4f8abefa= e7149e93eb92c 100644 --- a/drivers/usb/gadget/udc/cdns2/cdns2-gadget.c +++ b/drivers/usb/gadget/udc/cdns2/cdns2-gadget.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include =20 @@ -2233,12 +2234,12 @@ static int cdns2_init_eps(struct cdns2_device *pdev) dev_dbg(pdev->dev, "Init %s, SupType: CTRL: %s, INT: %s, " "BULK: %s, ISOC %s, SupDir IN: %s, OUT: %s\n", pep->name, - (pep->endpoint.caps.type_control) ? "yes" : "no", - (pep->endpoint.caps.type_int) ? "yes" : "no", - (pep->endpoint.caps.type_bulk) ? "yes" : "no", - (pep->endpoint.caps.type_iso) ? "yes" : "no", - (pep->endpoint.caps.dir_in) ? "yes" : "no", - (pep->endpoint.caps.dir_out) ? "yes" : "no"); + str_yes_no(pep->endpoint.caps.type_control), + str_yes_no(pep->endpoint.caps.type_int), + str_yes_no(pep->endpoint.caps.type_bulk), + str_yes_no(pep->endpoint.caps.type_iso), + str_yes_no(pep->endpoint.caps.dir_in), + str_yes_no(pep->endpoint.caps.dir_out)); =20 INIT_LIST_HEAD(&pep->pending_list); INIT_LIST_HEAD(&pep->deferred_list); diff --git a/drivers/usb/gadget/udc/dummy_hcd.c b/drivers/usb/gadget/udc/du= mmy_hcd.c index a7e8fa45776b5c16220bc5181eb6a91c45adf019..bda08c5ba7c01457aee61f86f82= 8c12cc1ce8d01 100644 --- a/drivers/usb/gadget/udc/dummy_hcd.c +++ b/drivers/usb/gadget/udc/dummy_hcd.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -625,7 +626,7 @@ static int dummy_enable(struct usb_ep *_ep, desc->bEndpointAddress & 0x0f, (desc->bEndpointAddress & USB_DIR_IN) ? "in" : "out", usb_ep_type_string(usb_endpoint_type(desc)), - max, ep->stream_en ? "enabled" : "disabled"); + max, str_enabled_disabled(ep->stream_en)); =20 /* at this point real hardware should be NAKing transfers * to that endpoint, until a buffer is queued to it. diff --git a/drivers/usb/gadget/udc/fsl_udc_core.c b/drivers/usb/gadget/udc= /fsl_udc_core.c index 8b7f7f96177459f6d295f5740b5ab23c0eab838f..4dea8bc30cf6d64663889ad0694= bd34513321b54 100644 --- a/drivers/usb/gadget/udc/fsl_udc_core.c +++ b/drivers/usb/gadget/udc/fsl_udc_core.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -1181,7 +1182,7 @@ static int fsl_vbus_session(struct usb_gadget *gadget= , int is_active) =20 udc =3D container_of(gadget, struct fsl_udc, gadget); spin_lock_irqsave(&udc->lock, flags); - dev_vdbg(&gadget->dev, "VBUS %s\n", is_active ? "on" : "off"); + dev_vdbg(&gadget->dev, "VBUS %s\n", str_on_off(is_active)); udc->vbus_active =3D (is_active !=3D 0); if (can_pullup(udc)) fsl_writel((fsl_readl(&dr_regs->usbcmd) | USB_CMD_RUN_STOP), diff --git a/drivers/usb/gadget/udc/omap_udc.c b/drivers/usb/gadget/udc/oma= p_udc.c index 698463bf697b29aaf15f05297b8beac9f2bfdab3..8902abe3ca7659f4248cc857c53= f53920a011d67 100644 --- a/drivers/usb/gadget/udc/omap_udc.c +++ b/drivers/usb/gadget/udc/omap_udc.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -1252,7 +1253,7 @@ static int omap_vbus_session(struct usb_gadget *gadge= t, int is_active) =20 udc =3D container_of(gadget, struct omap_udc, gadget); spin_lock_irqsave(&udc->lock, flags); - VDBG("VBUS %s\n", is_active ? "on" : "off"); + VDBG("VBUS %s\n", str_on_off(is_active)); udc->vbus_active =3D (is_active !=3D 0); if (cpu_is_omap15xx()) { /* "software" detect, ignored if !VBUS_MODE_1510 */ diff --git a/drivers/usb/gadget/udc/pxa27x_udc.c b/drivers/usb/gadget/udc/p= xa27x_udc.c index f9a55d4f189f4396230afcef85241c858fe40c41..897f53601b5b208955a29bca2b0= 743cce4155843 100644 --- a/drivers/usb/gadget/udc/pxa27x_udc.c +++ b/drivers/usb/gadget/udc/pxa27x_udc.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -1083,7 +1084,7 @@ static int pxa_ep_queue(struct usb_ep *_ep, struct us= b_request *_req, =20 is_first_req =3D list_empty(&ep->queue); ep_dbg(ep, "queue req %p(first=3D%s), len %d buf %p\n", - _req, is_first_req ? "yes" : "no", + _req, str_yes_no(is_first_req), _req->length, _req->buf); =20 if (!ep->enabled) { --=20 2.43.0 From nobody Wed Dec 17 04:16:55 2025 Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8954C20F09D for ; Tue, 14 Jan 2025 20:05:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736885162; cv=none; b=dc6ID+hoc9cHoXLtP6G4R7PWVt5sYQe+Z72pLN8yTmaVaKysP7qfht+7ZjJoToAI3wJYvFpsu6beUw5jHYbKE+dmr48hSzz6awe/23TPLJrCilxnCKDHD1LGZIXTXOaqbEnedGNjs3v19baUjl8lb+BvLqVYK5Gzca6KtuMrJ9Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736885162; c=relaxed/simple; bh=Dn7AExi9kOpb4kbvZsYQzaTe1/K3uWL4UVL+vFuGLtQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=M/OP9RlnSDl2ZCgRj898pjMkNyp+skJkmOn3GP8DK7OgtseaA/2Izs4FZNTeaVaEHUooRIUIO2U9sqgZTMj4ZphooXEH4k3wDJUsioV2LbhZwxKocRZvIKChxDD+VLRizOSu/2NfoJ8sALUq0wEJobo1p8tX+hgwqoLtjBz3fCA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=FcODDjea; arc=none smtp.client-ip=209.85.128.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="FcODDjea" Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-4361f09be37so7484575e9.1 for ; Tue, 14 Jan 2025 12:05:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1736885158; x=1737489958; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=jCj4MiQdDJTjdmm2UQHbDgKs2hpOoyxOgKsd7sNfwWo=; b=FcODDjea37GF0Dj89KllsmcuTr4u1QuQ/KIO+gSQpNFB7I7U7e4vML2SVoUSVQ2z9w X6zX+OwhhG/BVEW404cIw572r+MNRUPbSOPHTFGCByc5rB+7zzzu17ahoijHx+KxPJpF 7tW3hEY4vqR2G8VA9TWuSVw7/hhLAKfw2U4f/U8QHmiB+/lMTI39aGhZB6xKbvkj78nG 4iTuCsSXT8x8UIJ7MGd87o0TQodp8aqlKaaWdZEdMLAnNB8bL7HutVYbJk99APQ/yadV UkMxV+iSl0uIJDB3Vx7j7UvAIZbqGE3pfzNpHgyrhf1L4nYz9BJmK74aCJpPs+++14MV SKmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736885158; x=1737489958; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jCj4MiQdDJTjdmm2UQHbDgKs2hpOoyxOgKsd7sNfwWo=; b=Bn1DgnnELNfa4MyZUHTJb/+dd78rXSNJsAPi9r84fIE175ap44CCwc5O2wZO9MeXNf BUIaZBEyM90gIrzrRg96bXRxi4DWZgI8/X+8f72ufqT4Ue9KEWROtJ5aTm3KAOMOutvq 9t3a/txPIE1btQu7UFf7gGk6NPd6DW2fQUsj7UReUL9tC69b3GRsMLIqTt55DntqiFi+ D6Rez1jpBeF66I4+HpB0ez4bloLJsRC8NzbMdbfA+BZWMynh4iNTSxQbfRnA8Hi9b43Z qebBBK8I+RUFvIa4vMJb/7Ypwyc13IH0mL8fPTbjr5n/id6vPQPg/QW0CC0aW4KUhz3m AH+A== X-Forwarded-Encrypted: i=1; AJvYcCW8IxlwzKUKIdenBtDGyAoPp3AdAeadeLDBo1Kb8dzu75Z5ajBdRWwLzHU8vXrh3gpQF5w26kx2H0EkRTo=@vger.kernel.org X-Gm-Message-State: AOJu0YypWXZxkAVR6ybz4lWNn2sAYyrbUgvAbII0nNnItEd89pdbzzIN UuPQSspIf+/zTpUyNaf+qL/Z38rjnY5GzzGkkxlE9xQV7KAW0WLVz2i5eq0xyz4= X-Gm-Gg: ASbGncsLHsMw8GxLpbYhXmHq+P4gsTUeqzCW+m1o/0qCgH9Cz+EC4LsHzlEPH/CMB3N D0ADGIzI4hYtcd9qJkmiSMkZVSfnLahNQECgaVn0f8UUSJTPkXHjhZQ7wH/87eHoc8K31aoHiqE 6ILw/MqL+TgMCLVuv7V1mhfY2aNE86EjMhp0W8sx/vVopc0KzsjUT0+nBb0vQbKLE8nzkPTSki3 aKe5PyrPxp0FURbG+IMBBdtQ/VSAMstrmngArcE3wXgMFZf+Au0964bwFzx6+H/4Gh7n5s7 X-Google-Smtp-Source: AGHT+IGpUnCjOtwWTc+k/P2Jh9s7TGe5bsB4tkwgm9Xo/d2v0LUwlV1a7JVjXOXZxW9kJFIEf9IFpg== X-Received: by 2002:a05:600c:a09:b0:434:f1d5:144a with SMTP id 5b1f17b1804b1-436e2557087mr97123485e9.0.1736885157846; Tue, 14 Jan 2025 12:05:57 -0800 (PST) Received: from [127.0.1.1] ([178.197.223.165]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-436e9dc8802sm184622025e9.10.2025.01.14.12.05.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jan 2025 12:05:57 -0800 (PST) From: Krzysztof Kozlowski Date: Tue, 14 Jan 2025 21:05:39 +0100 Subject: [PATCH 6/6] USB: Use str_enable_disable-like helpers Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250114-str-enable-disable-usb-v1-6-c8405df47c19@linaro.org> References: <20250114-str-enable-disable-usb-v1-0-c8405df47c19@linaro.org> In-Reply-To: <20250114-str-enable-disable-usb-v1-0-c8405df47c19@linaro.org> To: Greg Kroah-Hartman , Mathias Nyman , Thierry Reding , Jonathan Hunter , Heikki Krogerus , Andrew Jeffery , Nicolas Ferre , Alexandre Belloni , Claudiu Beznea , Daniel Mack , Haojian Zhuang , Robert Jarzmik , Peter Chen , Linus Walleij , Alan Stern Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, usb-storage@lists.one-eyed-alien.net, Krzysztof Kozlowski X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=15462; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=Dn7AExi9kOpb4kbvZsYQzaTe1/K3uWL4UVL+vFuGLtQ=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBnhsOVm6R2JV4lMLh0HO2WSwbkBxxWF0im5GEM3 s2zrHwToKqJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZ4bDlQAKCRDBN2bmhouD 18u4D/99tu1qrTUAznVyLt0LA2L7BicoL8heL+g2pjM0KHhMN+Ir9q7job/YtO0c7Rc9fwccR77 Q4uUn7KPSNP1lypzr9mc9VVgmRgy8eruB4qZBKXMcfoyll1z1YYvkxIwefjMBq7frPDSIyNSgcM +rPcFKvKdP7muu1rW6cGm2pETvb1mVRSCBkngzSmhwlc/HCTw92U3Ri3afb8hKi7wn3RVDfcy4p ZaYec757+oN5flqHgM7nLzlEmOFaEhkUgOqKwGnV9baasNHZPYSJxBeN9KhC1YlgjYvFaLQ79jx o1y2agQ+Iok322rs3RBvs1VOFgzC2FP4LIc+Rqfq0E31c6vQy2J6VtNW6LWGV4iOm09WjFDi0Me Zq3W6a8eQLr+b1AHW36uuMbsjYdxSAZsgXv7LeV80BLU+I8hgy2mrJaPrW/0EhZoZrkZ1ztzvsy ub6+Mxos9aD/KXpZzcu4HvebKTOD3Ika+JOsvuTpgStn2abxypEw0o/KZZifEx50veT5fcO6GMt CqhEQXT2u8EBapZkrXBx8TClLPOCmyK3BHLU+4kG5oWbMsa8H4xsFmdtnr/TrJ9r//qA/eGHHa4 J9Asc9fRTHGfjz7LchxYl60yCKY9bc0MOiQOFVRrbuxbzKjA6TBpHJ+pvXBdwZoRrdTwcUmkX5a AUfyqFvJHCcjRvA== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B Replace ternary (condition ? "enable" : "disable") syntax with helpers from string_choices.h because: 1. Simple function call with one argument is easier to read. Ternary operator has three arguments and with wrapping might lead to quite long code. 2. Is slightly shorter thus also easier to read. 3. It brings uniformity in the text - same string. 4. Allows deduping by the linker, which results in a smaller binary file. Signed-off-by: Krzysztof Kozlowski --- drivers/usb/cdns3/cdnsp-gadget.c | 13 +++++++------ drivers/usb/chipidea/host.c | 3 ++- drivers/usb/common/usb-conn-gpio.c | 3 ++- drivers/usb/core/hub.c | 10 +++++----- drivers/usb/core/port.c | 3 ++- drivers/usb/fotg210/fotg210-core.c | 5 +++-- drivers/usb/mtu3/mtu3_debugfs.c | 3 ++- drivers/usb/mtu3/mtu3_dr.c | 3 ++- drivers/usb/mtu3/mtu3_gadget.c | 3 ++- drivers/usb/musb/da8xx.c | 3 ++- drivers/usb/musb/musb_core.c | 3 ++- drivers/usb/musb/musb_dsps.c | 3 ++- drivers/usb/musb/musb_gadget.c | 3 ++- drivers/usb/musb/musb_host.c | 3 ++- drivers/usb/storage/shuttle_usbat.c | 4 ++-- drivers/usb/usbip/vhci_hcd.c | 3 ++- 16 files changed, 41 insertions(+), 27 deletions(-) diff --git a/drivers/usb/cdns3/cdnsp-gadget.c b/drivers/usb/cdns3/cdnsp-gad= get.c index 4a3f0f95825698f0524cace5c06bfcf27f763149..97edf767ecee9067e3db66c2373= d4b1a7a2e29de 100644 --- a/drivers/usb/cdns3/cdnsp-gadget.c +++ b/drivers/usb/cdns3/cdnsp-gadget.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -1671,12 +1672,12 @@ static int cdnsp_gadget_init_endpoints(struct cdnsp= _device *pdev) "CTRL: %s, INT: %s, BULK: %s, ISOC %s, " "SupDir IN: %s, OUT: %s\n", pep->name, 1024, - (pep->endpoint.caps.type_control) ? "yes" : "no", - (pep->endpoint.caps.type_int) ? "yes" : "no", - (pep->endpoint.caps.type_bulk) ? "yes" : "no", - (pep->endpoint.caps.type_iso) ? "yes" : "no", - (pep->endpoint.caps.dir_in) ? "yes" : "no", - (pep->endpoint.caps.dir_out) ? "yes" : "no"); + str_yes_no(pep->endpoint.caps.type_control), + str_yes_no(pep->endpoint.caps.type_int), + str_yes_no(pep->endpoint.caps.type_bulk), + str_yes_no(pep->endpoint.caps.type_iso), + str_yes_no(pep->endpoint.caps.dir_in), + str_yes_no(pep->endpoint.caps.dir_out)); =20 INIT_LIST_HEAD(&pep->pending_list); } diff --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c index 442d79e32a65b59d551e274dc3464febead3820b..ced6076a8248427e2aaafd28fd7= a6f5aaa1cbc05 100644 --- a/drivers/usb/chipidea/host.c +++ b/drivers/usb/chipidea/host.c @@ -13,6 +13,7 @@ #include #include #include +#include #include =20 #include "../host/ehci.h" @@ -56,7 +57,7 @@ static int ehci_ci_portpower(struct usb_hcd *hcd, int por= tnum, bool enable) if (ret) { dev_err(dev, "Failed to %s vbus regulator, ret=3D%d\n", - enable ? "enable" : "disable", ret); + str_enable_disable(enable), ret); return ret; } priv->enabled =3D enable; diff --git a/drivers/usb/common/usb-conn-gpio.c b/drivers/usb/common/usb-co= nn-gpio.c index c84b4a70008460f4607050b517a22fba4dc0ffec..aa710b50791b0282be0a6a26cff= dd981b794acaa 100644 --- a/drivers/usb/common/usb-conn-gpio.c +++ b/drivers/usb/common/usb-conn-gpio.c @@ -19,6 +19,7 @@ #include #include #include +#include #include =20 #define USB_GPIO_DEB_MS 20 /* ms */ @@ -111,7 +112,7 @@ static void usb_conn_detect_cable(struct work_struct *w= ork) =20 if (info->vbus) dev_dbg(info->dev, "vbus regulator is %s\n", - regulator_is_enabled(info->vbus) ? "enabled" : "disabled"); + str_enabled_disabled(regulator_is_enabled(info->vbus))); =20 power_supply_changed(info->charger); } diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 21ac9b464696f561c87b56eab4b4dce7c5e64533..c3f839637cb5a6222754ae7cd2e= a137e8086768e 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -1496,7 +1497,7 @@ static int hub_configure(struct usb_hub *hub, =20 maxchild =3D hub->descriptor->bNbrPorts; dev_info(hub_dev, "%d port%s detected\n", maxchild, - (maxchild =3D=3D 1) ? "" : "s"); + str_plural(maxchild)); =20 hub->ports =3D kcalloc(maxchild, sizeof(struct usb_port *), GFP_KERNEL); if (!hub->ports) { @@ -4139,14 +4140,14 @@ static int usb_set_device_initiated_lpm(struct usb_= device *udev, break; default: dev_warn(&udev->dev, "%s: Can't %s non-U1 or U2 state.\n", - __func__, enable ? "enable" : "disable"); + __func__, str_enable_disable(enable)); return -EINVAL; } =20 if (udev->state !=3D USB_STATE_CONFIGURED) { dev_dbg(&udev->dev, "%s: Can't %s %s state " "for unconfigured device.\n", - __func__, enable ? "enable" : "disable", + __func__, str_enable_disable(enable), usb3_lpm_names[state]); return 0; } @@ -4172,8 +4173,7 @@ static int usb_set_device_initiated_lpm(struct usb_de= vice *udev, } if (ret < 0) { dev_warn(&udev->dev, "%s of device-initiated %s failed.\n", - enable ? "Enable" : "Disable", - usb3_lpm_names[state]); + str_enable_disable(enable), usb3_lpm_names[state]); return -EBUSY; } return 0; diff --git a/drivers/usb/core/port.c b/drivers/usb/core/port.c index e857e532b35a4687bb8113610cb76d0386fa26b5..f54198171b6a3fb49c5f74f4a8a= 303b422d099eb 100644 --- a/drivers/usb/core/port.c +++ b/drivers/usb/core/port.c @@ -9,6 +9,7 @@ =20 #include #include +#include #include #include #include @@ -25,7 +26,7 @@ static ssize_t early_stop_show(struct device *dev, { struct usb_port *port_dev =3D to_usb_port(dev); =20 - return sysfs_emit(buf, "%s\n", port_dev->early_stop ? "yes" : "no"); + return sysfs_emit(buf, "%s\n", str_yes_no(port_dev->early_stop)); } =20 static ssize_t early_stop_store(struct device *dev, struct device_attribut= e *attr, diff --git a/drivers/usb/fotg210/fotg210-core.c b/drivers/usb/fotg210/fotg2= 10-core.c index 49f25a70b32ebdd8bdad672d31342d5f89c4a502..7fb4d4715e9f7f5ca64bc4b40e0= 260e304791bc9 100644 --- a/drivers/usb/fotg210/fotg210-core.c +++ b/drivers/usb/fotg210/fotg210-core.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include =20 @@ -119,8 +120,8 @@ void fotg210_vbus(struct fotg210 *fotg, bool enable) ret =3D regmap_update_bits(fotg->map, GEMINI_GLOBAL_MISC_CTRL, mask, val); if (ret) dev_err(fotg->dev, "failed to %s VBUS\n", - enable ? "enable" : "disable"); - dev_info(fotg->dev, "%s: %s VBUS\n", __func__, enable ? "enable" : "disab= le"); + str_enable_disable(enable)); + dev_info(fotg->dev, "%s: %s VBUS\n", __func__, str_enable_disable(enable)= ); } =20 static int fotg210_probe(struct platform_device *pdev) diff --git a/drivers/usb/mtu3/mtu3_debugfs.c b/drivers/usb/mtu3/mtu3_debugf= s.c index f0de9985835313500ebcce6435dbdd5d0357f914..9bd74c505872dd05bf1237f96d1= dde878f76b59b 100644 --- a/drivers/usb/mtu3/mtu3_debugfs.c +++ b/drivers/usb/mtu3/mtu3_debugfs.c @@ -7,6 +7,7 @@ * Author: Chunfeng Yun */ =20 +#include #include =20 #include "mtu3.h" @@ -479,7 +480,7 @@ static int ssusb_vbus_show(struct seq_file *sf, void *u= nused) struct otg_switch_mtk *otg_sx =3D &ssusb->otg_switch; =20 seq_printf(sf, "vbus state: %s\n(echo on/off)\n", - regulator_is_enabled(otg_sx->vbus) ? "on" : "off"); + str_on_off(regulator_is_enabled(otg_sx->vbus))); =20 return 0; } diff --git a/drivers/usb/mtu3/mtu3_dr.c b/drivers/usb/mtu3/mtu3_dr.c index 8191b7ed3852107a4ddd55b39fc53987eb56fef6..ffa5b9401dad0a79fa8ded2c32d= 3bb4e49069951 100644 --- a/drivers/usb/mtu3/mtu3_dr.c +++ b/drivers/usb/mtu3/mtu3_dr.c @@ -7,6 +7,7 @@ * Author: Chunfeng Yun */ =20 +#include #include "mtu3.h" #include "mtu3_dr.h" #include "mtu3_debug.h" @@ -109,7 +110,7 @@ int ssusb_set_vbus(struct otg_switch_mtk *otg_sx, int i= s_on) if (!vbus) return 0; =20 - dev_dbg(ssusb->dev, "%s: turn %s\n", __func__, is_on ? "on" : "off"); + dev_dbg(ssusb->dev, "%s: turn %s\n", __func__, str_on_off(is_on)); =20 if (is_on) { ret =3D regulator_enable(vbus); diff --git a/drivers/usb/mtu3/mtu3_gadget.c b/drivers/usb/mtu3/mtu3_gadget.c index ad0eeac4332d9f69d5237180a8a16cbc0eee35c2..bf73fbc29976ff8d99a3591b33f= 4f6b90ed9b4c3 100644 --- a/drivers/usb/mtu3/mtu3_gadget.c +++ b/drivers/usb/mtu3/mtu3_gadget.c @@ -7,6 +7,7 @@ * Author: Chunfeng Yun */ =20 +#include #include "mtu3.h" #include "mtu3_trace.h" =20 @@ -490,7 +491,7 @@ static int mtu3_gadget_pullup(struct usb_gadget *gadget= , int is_on) unsigned long flags; =20 dev_dbg(mtu->dev, "%s (%s) for %sactive device\n", __func__, - is_on ? "on" : "off", mtu->is_active ? "" : "in"); + str_on_off(is_on), mtu->is_active ? "" : "in"); =20 pm_runtime_get_sync(mtu->dev); =20 diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c index f772aa272bea65eb403655b81a7bec26a1d355e4..26fd71a5f9b2aeef43eea19fc58= 302e79b4abc4a 100644 --- a/drivers/usb/musb/da8xx.c +++ b/drivers/usb/musb/da8xx.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include =20 @@ -306,7 +307,7 @@ static irqreturn_t da8xx_musb_interrupt(int irq, void *= hci) } =20 dev_dbg(musb->controller, "VBUS %s (%s)%s, devctl %02x\n", - drvvbus ? "on" : "off", + str_on_off(drvvbus), usb_otg_state_string(musb->xceiv->otg->state), err ? " ERROR" : "", devctl); diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c index 03b1154a6014ab27b8cca916af3a724b58046c53..7f349f5e781df481c44e84a02e8= c93cf3279132d 100644 --- a/drivers/usb/musb/musb_core.c +++ b/drivers/usb/musb/musb_core.c @@ -72,6 +72,7 @@ #include #include #include +#include #include #include #include @@ -1937,7 +1938,7 @@ vbus_show(struct device *dev, struct device_attribute= *attr, char *buf) pm_runtime_put_sync(dev); =20 return sprintf(buf, "Vbus %s, timeout %lu msec\n", - vbus ? "on" : "off", val); + str_on_off(vbus), val); } static DEVICE_ATTR_RW(vbus); =20 diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c index 2542239ec64eafa2de5bd34f19cb0bb7d68b88ea..f877faf5a930cabad4e2a62289c= 4d8224b2befa6 100644 --- a/drivers/usb/musb/musb_dsps.c +++ b/drivers/usb/musb/musb_dsps.c @@ -24,6 +24,7 @@ #include #include #include +#include =20 #include #include @@ -378,7 +379,7 @@ static irqreturn_t dsps_interrupt(int irq, void *hci) =20 /* NOTE: this must complete power-on within 100 ms. */ dev_dbg(musb->controller, "VBUS %s (%s)%s, devctl %02x\n", - drvvbus ? "on" : "off", + str_on_off(drvvbus), usb_otg_state_string(musb->xceiv->otg->state), err ? " ERROR" : "", devctl); diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c index c6076df0d50cc7aa9b733c2685394cd810c39f4a..6869c58367f2d05b464a0f9a630= 08425730b94da 100644 --- a/drivers/usb/musb/musb_gadget.c +++ b/drivers/usb/musb/musb_gadget.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -1606,7 +1607,7 @@ static void musb_pullup(struct musb *musb, int is_on) /* FIXME if on, HdrcStart; if off, HdrcStop */ =20 musb_dbg(musb, "gadget D+ pullup %s", - is_on ? "on" : "off"); + str_on_off(is_on)); musb_writeb(musb->mregs, MUSB_POWER, power); } =20 diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c index 732ba981e607e750995db0b7cca2bb270e9793e6..6b4481a867c5e8189ce164b3f98= cc3576b0b1a81 100644 --- a/drivers/usb/musb/musb_host.c +++ b/drivers/usb/musb/musb_host.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -1028,7 +1029,7 @@ static bool musb_h_ep0_continue(struct musb *musb, u1= 6 len, struct urb *urb) + urb->actual_length); musb_dbg(musb, "Sending %d byte%s to ep0 fifo %p", fifo_count, - (fifo_count =3D=3D 1) ? "" : "s", + str_plural(fifo_count), fifo_dest); musb_write_fifo(hw_ep, fifo_count, fifo_dest); =20 diff --git a/drivers/usb/storage/shuttle_usbat.c b/drivers/usb/storage/shut= tle_usbat.c index 087c706bb315f9d4b921b9d9eb85df752c90337b..c33cbf177e6fcaa80e0d2639594= d1314c59f4950 100644 --- a/drivers/usb/storage/shuttle_usbat.c +++ b/drivers/usb/storage/shuttle_usbat.c @@ -32,6 +32,7 @@ #include #include #include +#include #include =20 #include @@ -651,8 +652,7 @@ static int usbat_hp8200e_rw_block_test(struct us_data *= us, return USB_STOR_TRANSPORT_FAILED; =20 usb_stor_dbg(us, "Redoing %s\n", - direction =3D=3D DMA_TO_DEVICE - ? "write" : "read"); + str_write_read(direction =3D=3D DMA_TO_DEVICE)); =20 } else if (result !=3D USB_STOR_XFER_GOOD) return USB_STOR_TRANSPORT_ERROR; diff --git a/drivers/usb/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c index 2f722849dfc9ff64b8801c56beca3cde49184f31..f4843ea5080c03cade2a7765770= 1731af7dbf8b0 100644 --- a/drivers/usb/usbip/vhci_hcd.c +++ b/drivers/usb/usbip/vhci_hcd.c @@ -11,6 +11,7 @@ #include #include #include +#include =20 #include "usbip_common.h" #include "vhci.h" @@ -1449,7 +1450,7 @@ static int vhci_hcd_suspend(struct platform_device *p= dev, pm_message_t state) if (connected > 0) { dev_info(&pdev->dev, "We have %d active connection%s. Do not suspend.\n", - connected, (connected =3D=3D 1 ? "" : "s")); + connected, str_plural(connected)); ret =3D -EBUSY; } else { dev_info(&pdev->dev, "suspend vhci_hcd"); --=20 2.43.0