From patchwork Wed Oct 4 16:23:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 729849 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7F8E0E7C4E4 for ; Wed, 4 Oct 2023 16:25:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243325AbjJDQZI (ORCPT ); Wed, 4 Oct 2023 12:25:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243287AbjJDQZH (ORCPT ); Wed, 4 Oct 2023 12:25:07 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11F24E8 for ; Wed, 4 Oct 2023 09:23:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1696436627; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fCKgDeYs5G2UxuYhogLBnsUuAjSI/jIJLn3GDbWKl68=; b=Qr/VCdCn5XulbjOdSDmzXt76TYa80bNJcb4oEg+CpuBFXKmf0F0L+vD9oHuaXsyDBTYJzp z9UZ+FbgSU8tFp9AD8g84KHtwcMUqc23d+LUQBhdhGR3gVhlC1Y37A6suRLXRdxbKKp4w7 4mNAeA1Iat+SJn6K56tqqmYz5bHVp6I= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-333-utG86j4yNrClnCeAeKUEZg-1; Wed, 04 Oct 2023 12:23:31 -0400 X-MC-Unique: utG86j4yNrClnCeAeKUEZg-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5074C98B723; Wed, 4 Oct 2023 16:23:31 +0000 (UTC) Received: from localhost.localdomain (unknown [10.39.192.89]) by smtp.corp.redhat.com (Postfix) with ESMTP id D949540C2015; Wed, 4 Oct 2023 16:23:29 +0000 (UTC) From: Hans de Goede To: =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Mika Westerberg , Andy Shevchenko , Bartosz Golaszewski , Bartosz Golaszewski , Linus Walleij Cc: Hans de Goede , platform-driver-x86@vger.kernel.org, Daniel Scally , linux-gpio@vger.kernel.org, linux-acpi@vger.kernel.org Subject: [PATCH v3 2/5] platform/x86: int3472: Add new skl_int3472_gpiod_get_from_temp_lookup() helper Date: Wed, 4 Oct 2023 18:23:14 +0200 Message-ID: <20231004162317.163488-3-hdegoede@redhat.com> In-Reply-To: <20231004162317.163488-1-hdegoede@redhat.com> References: <20231004162317.163488-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org From: Bartosz Golaszewski Add a new skl_int3472_gpiod_get_from_temp_lookup() helper. This is a preparation patch for removing usage of the deprecated gpiod_toggle_active_low() and acpi_get_and_request_gpiod() functions. Signed-off-by: Bartosz Golaszewski [hdegoede@redhat.com] use the new skl_int3472_fill_gpiod_lookup() helper Reviewed-by: Andy Shevchenko Co-developed-by: Hans de Goede Signed-off-by: Hans de Goede --- Changes in v3: - Fix wrong size of gpio lookup table allocation. There must also be an empty terminating lookup, so 2 entries must be allocated. Changes in v2: - Use the new skl_int3472_fill_gpiod_lookup() helper. --- drivers/platform/x86/intel/int3472/discrete.c | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/drivers/platform/x86/intel/int3472/discrete.c b/drivers/platform/x86/intel/int3472/discrete.c index 351ecf047944..b69ef63f75ab 100644 --- a/drivers/platform/x86/intel/int3472/discrete.c +++ b/drivers/platform/x86/intel/int3472/discrete.c @@ -99,6 +99,32 @@ static int skl_int3472_map_gpio_to_sensor(struct int3472_discrete_device *int347 return 0; } +/* This should *really* only be used when there's no other way... */ +static struct gpio_desc * +skl_int3472_gpiod_get_from_temp_lookup(struct int3472_discrete_device *int3472, + struct acpi_resource_gpio *agpio, + const char *func, u32 polarity) +{ + struct gpio_desc *desc; + int ret; + + struct gpiod_lookup_table *lookup __free(kfree) = + kzalloc(struct_size(lookup, table, 2), GFP_KERNEL); + if (!lookup) + return ERR_PTR(-ENOMEM); + + lookup->dev_id = dev_name(int3472->dev); + ret = skl_int3472_fill_gpiod_lookup(&lookup->table[0], agpio, func, polarity); + if (ret) + return ERR_PTR(ret); + + gpiod_add_lookup_table(lookup); + desc = gpiod_get(int3472->dev, func, GPIOD_OUT_LOW); + gpiod_remove_lookup_table(lookup); + + return desc; +} + static void int3472_get_func_and_polarity(u8 type, const char **func, u32 *polarity) { switch (type) {