Received: by 2002:a05:7412:8598:b0:f9:33c2:5753 with SMTP id n24csp441089rdh; Tue, 19 Dec 2023 03:52:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IHs+VfHhGmKObxyBS9tREhPB1YOZIeOUXj7rBqpM4KbxTGXuui9djfEiXxXoj94IfvzLCiz X-Received: by 2002:a92:cdac:0:b0:35f:b61f:a8ac with SMTP id g12-20020a92cdac000000b0035fb61fa8acmr2871565ild.46.1702986722933; Tue, 19 Dec 2023 03:52:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702986722; cv=none; d=google.com; s=arc-20160816; b=Rgb7PdcxpHbbBprTV1DeF1Ovh4y5Fxs0aQWRa4M5Dk2rfTS69iiVTeheUhYuUzw4Gu IAznWcT//77xesNxSY1l2QU7sKKyB9l/A+UYn5x0SDnHMoBWqsInN6GwFHGSWczSek2C +On5KGz0V5bDX8vAy0Pd4JKxBs1hYzgWMAiAjLkDVs6Honsq1OBK+JW389L5WIJkRAU0 MICSfUWyAy2Kip6Q3dhyvl3JUfBKojdBUU5kmVjljsriEPVtGF+cNhplSZpvmRtVHEAg 7zsH9F7UvAqIFKxK3xiin/0TP7Rp3Ety15OZw34AcachZNhbFWTr9hG6luhm0RB6UWR2 WN7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=XkkcHE+zAhJX4QAmxCl5JxzKcstw+Seg1o6TF5s7ihk=; fh=W2pHPIJPqCP8HsXFXoA7ZzEbMb5czJzPDgB2sMvpzSo=; b=P7KKU+olyMNz0FLLCkzVehFL28o0asllGp3geslVd1mb9LvtIZ2X0yhUH/UFC6Vivs 27aNpWHGt0mlscEARkX13QSciw7/6Wfcoze9MOs4AyBZFaCy96gWf0AuXdnuXsiM8Loe RWrSvd4wSBk0i+VYZEOTHkmJNYhGsUpnlVIxLGcHG7WhOZQxpEk6ag7Afc3TF0rfmGIg dLeK0dKOZGYFYNIWv8FRvx+7mcQHG1S7RMSOv279ZyZZ9yMBOFR85JBKGnrSrD5mNN92 bxOg7EDyDNVMfktkAVK1flf9DRyrjdDcR1fTRskCIRoI3LfGCQtsMMQkWOsvraBr2rOB pdRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=SYrGD+0x; spf=pass (google.com: domain of linux-kernel+bounces-5111-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5111-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id 138-20020a630190000000b005cd84872621si5402213pgb.700.2023.12.19.03.52.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 03:52:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-5111-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=SYrGD+0x; spf=pass (google.com: domain of linux-kernel+bounces-5111-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5111-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id EDCC2B2472A for ; Tue, 19 Dec 2023 11:51:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 148801642D; Tue, 19 Dec 2023 11:51:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="SYrGD+0x" X-Original-To: linux-kernel@vger.kernel.org Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2DE8718E2F; Tue, 19 Dec 2023 11:51:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1702986662; x=1734522662; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=fnK/Y9O3xSfWK7qWy8ICoXoJrkOhv0lVOPade4CcLM0=; b=SYrGD+0xVyypsVgyB2oYVGeDUs0eUVB9sxrgWMiNGUTKH0W3tFjH7X7B cE2jsSeHFAQS0BuSi69g1LBDe54T0W4k6eD9WvCV1eHTZbvN1DiXqODVX 7O40pngjA5LNowz33+45dYeWldxAlyXcS6ig4mxhILek7V3QWpLCpV1GJ 2iXny+5bF8/4e+wg3cLT6EGJTE9T4mD7elh4BAW11yPmoeseE2RnKPgUy 8qXQHl8PWQuoqpM1bT8CEs6r9qt3HrEDJr/2IAfG0YHi9ABr7L3QcWe+K Xdm8poUpsS0RDdQPyyVu7YwzRl71WD+6yXFWJcnWBDluGrIOV6oHUFArM A==; X-IronPort-AV: E=McAfee;i="6600,9927,10928"; a="394524569" X-IronPort-AV: E=Sophos;i="6.04,288,1695711600"; d="scan'208";a="394524569" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Dec 2023 03:51:01 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10928"; a="779458621" X-IronPort-AV: E=Sophos;i="6.04,288,1695711600"; d="scan'208";a="779458621" Received: from kuha.fi.intel.com ([10.237.72.185]) by fmsmga007.fm.intel.com with SMTP; 19 Dec 2023 03:50:59 -0800 Received: by kuha.fi.intel.com (sSMTP sendmail emulation); Tue, 19 Dec 2023 13:50:58 +0200 Date: Tue, 19 Dec 2023 13:50:58 +0200 From: Heikki Krogerus To: Javier Carrasco Cc: Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 2/4] usb: typec: tipd: add function to request firmware Message-ID: References: <20231207-tps6598x_update-v2-0-f3cfcde6d890@wolfvision.net> <20231207-tps6598x_update-v2-2-f3cfcde6d890@wolfvision.net> 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=us-ascii Content-Disposition: inline In-Reply-To: <20231207-tps6598x_update-v2-2-f3cfcde6d890@wolfvision.net> On Thu, Dec 14, 2023 at 05:29:10PM +0100, Javier Carrasco wrote: > The firmware request process is device agnostic and can be used for > other parts. > > Signed-off-by: Javier Carrasco Reviewed-by: Heikki Krogerus > --- > drivers/usb/typec/tipd/core.c | 35 ++++++++++++++++++++++++++--------- > 1 file changed, 26 insertions(+), 9 deletions(-) > > diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c > index f0c4cd571a37..83e5eeecdf5c 100644 > --- a/drivers/usb/typec/tipd/core.c > +++ b/drivers/usb/typec/tipd/core.c > @@ -873,6 +873,30 @@ tps6598x_register_port(struct tps6598x *tps, struct fwnode_handle *fwnode) > return 0; > } > > +static int tps_request_firmware(struct tps6598x *tps, const struct firmware **fw) > +{ > + const char *firmware_name; > + int ret; > + > + ret = device_property_read_string(tps->dev, "firmware-name", > + &firmware_name); > + if (ret) > + return ret; > + > + ret = request_firmware(fw, firmware_name, tps->dev); > + if (ret) { > + dev_err(tps->dev, "failed to retrieve \"%s\"\n", firmware_name); > + return ret; > + } > + > + if ((*fw)->size == 0) { > + release_firmware(*fw); > + ret = -EINVAL; > + } > + > + return ret; > +} > + > static int > tps25750_write_firmware(struct tps6598x *tps, > u8 bpms_addr, const u8 *data, size_t len) > @@ -961,16 +985,9 @@ static int tps25750_start_patch_burst_mode(struct tps6598x *tps) > if (ret) > return ret; > > - ret = request_firmware(&fw, firmware_name, tps->dev); > - if (ret) { > - dev_err(tps->dev, "failed to retrieve \"%s\"\n", firmware_name); > + ret = tps_request_firmware(tps, &fw); > + if (ret) > return ret; > - } > - > - if (fw->size == 0) { > - ret = -EINVAL; > - goto release_fw; > - } > > ret = of_property_match_string(np, "reg-names", "patch-address"); > if (ret < 0) { > > -- > 2.39.2 -- heikki