From nobody Tue Apr 7 14:36:49 2026 Received: from mail-yx1-f45.google.com (mail-yx1-f45.google.com [74.125.224.45]) (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 01A9F156CA for ; Fri, 13 Mar 2026 00:12:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.224.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773360750; cv=none; b=Pa5/gxG6IqCQn2gbcUxeIIn8zQdRTGGon2B+ju9IJZnr93fYS16y1Qn2t0678NTkP7EhLRm9Cg2p0LaqkqUdbxAQ+TwJDIevbuYifjZ2RS4SoK/YxFQf4B8iqxrEt/z7yInEon5wNSLmiKd/f5dKia5TyDW8S7TbKEdTdGDoePU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773360750; c=relaxed/simple; bh=T4r2vx6dhxOLnZH/JlyaRVdHbC7RPrKhEoaEGGAroBI=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=PFNO0Ai5MCRfEcTOW+NzMlPlZ50twDI5CBUYW4TB1ES2oZOtaNKMz6qQ/aXo/qAYIU9o4pXUj1GNo9imUCxT6jmgtUMc5Fhv/OABbDhTNnzD4fcMQoSVEdbzBt6kYcRDQMX4b/sAHL1Jv4VSDhXL3xTOwkj4vZhdYp4er7oEdsY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Lim6HX+x; arc=none smtp.client-ip=74.125.224.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Lim6HX+x" Received: by mail-yx1-f45.google.com with SMTP id 956f58d0204a3-64d5a7926cfso1763314d50.2 for ; Thu, 12 Mar 2026 17:12:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1773360748; x=1773965548; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=riNuyQ7mIoctt4Nrm79i2EVlOIkF+ZTDYIpMnh/XtIM=; b=Lim6HX+xMzOPVP/Pp0w1ILKLhdAUQDcOXkWJAK0WEmjLa0fXXdWPV7MPlK6YcVRJNr ie8KDiYHdeoO97maDvBpVDu+609642Wh1gKr1r7r6uBZELON8yjPN6I9qdaYVyN9bujl RJjZKjZQe2uJ6juToj8jyNYPH1QwVcRjrcYrI31zzFycrKmClkVkzbMYddGtFEf+9Vae pCE7bE+s0nC9exiDdmesglQtpI/p4OEpUfi26s0HqC7eaKb5oHjizuSJTbChWAgkj+AI mbvupb9YnKwK2Ez37WjmENyAptqdsC9VN66QXXUp1lb1fwG0Oj//ycPAjGVFvc/yXjzy 3mdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773360748; x=1773965548; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=riNuyQ7mIoctt4Nrm79i2EVlOIkF+ZTDYIpMnh/XtIM=; b=M0QahNO2iZalnnnFMgxDxn3mGv2n3PsFyWJ8MRGXZlXbEQjUF8/askdsaha6TwiCVU zMJ0sD5ZOpi9NVv0LWLD9xvGGLb3RYsG4T3X8j0RjdF786mn0kqH5BhwM6PApUjRKtZh r6xgO65DSt41v8wQy3IkJ3WA0ecMyesboCwn/2Tf/u0gzp6A8LcHgrMYGZWi4GlaOFw4 8ckkj7uUbYWLfBJ2r/DuDoqXlpmAiCoekbiBRLqZ5kUdWvbCghXWN1nDRR7w2YDwgb1X x9T8DOc6zkNkMRK2vCyVt4sG1ZnVqqAyoEoqkI07V1JTn2T9N5VrKGHLX8rmXP4cczh4 KT8w== X-Forwarded-Encrypted: i=1; AJvYcCWbHWqnQa4HrnHPGWtDQXw/l1fZCIs9WhZ9w8lUCdAfwPSLP/JdktQeO9oBW5HtLnbjIfxn/av4GPTsiLU=@vger.kernel.org X-Gm-Message-State: AOJu0YwYJXEg3a3jHEyKc48RVDppqAZRLa0W5NUujFLHFq2DKBPyOhhJ sa6ihtSVRYsZ9opUu9TreRC0MHpobRI8bVFYlqGMharpyoD35mcbjGKb X-Gm-Gg: ATEYQzxMZvIAhh8xioUgjDSToXUnokds59IwK6jLbhVgKwr74+1U+ayMF80w8WdUQx+ o/1eqSJssUeHjRPgtjCinAhc5g/C1Vd+rcS3EjLn71Z0XiwvNI2WpfItQnDxG8/6rMRyK2WphmK OAIb+o4KlhffZpBGRKbEWv5tqgiT/22hG0Tnu12vRTs3Fz0aMM0bpC8gnPrMWsntDTWSDcxONQN wgwul+fc193bxot0Of6JzOFSoU1PWKrhWuuWeZ555yllAcIRYAe5TTFazSLlpH+SflM35JpoR0+ u2glNjrjzAWUBCro1XREBA3XdmFymwob474pSBtrowKCMe6zcHzkhC6lxJYLd2aXA2Yuhopr9Q5 PojGWzKBorx0P5T621iwvhgF7PGepIbi2kXyprHnQjkyDgj6vyGiqS6Qx+qwPWdV0L0gucKLAx5 /U39aeMDeKR1hplPMtLnGqj2Zd7NxrxoUBbMMStzAloVbchR3vKuxCvg== X-Received: by 2002:a05:690e:44a3:b0:649:38be:34bd with SMTP id 956f58d0204a3-64e63050c8cmr1360709d50.45.1773360747727; Thu, 12 Mar 2026 17:12:27 -0700 (PDT) Received: from ryzen ([2601:644:8000:56f5::8bd]) by smtp.gmail.com with ESMTPSA id 956f58d0204a3-64e65b39dd2sm144411d50.14.2026.03.12.17.12.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Mar 2026 17:12:27 -0700 (PDT) From: Rosen Penev To: linux-gpio@vger.kernel.org Cc: Linus Walleij , Bartosz Golaszewski , linux-kernel@vger.kernel.org (open list) Subject: [PATCH] gpio: cs5535: use dynamically allocated priv struct Date: Thu, 12 Mar 2026 17:12:09 -0700 Message-ID: <20260313001209.117823-1-rosenp@gmail.com> X-Mailer: git-send-email 2.53.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Static allocation is deprecated. Remove the FIXME as gpiochip_add_data allows using gpiod_get_data. No need for container_of. Signed-off-by: Rosen Penev --- drivers/gpio/gpio-cs5535.c | 48 +++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 27 deletions(-) diff --git a/drivers/gpio/gpio-cs5535.c b/drivers/gpio/gpio-cs5535.c index 8affe4e9f90e..5f5373d86397 100644 --- a/drivers/gpio/gpio-cs5535.c +++ b/drivers/gpio/gpio-cs5535.c @@ -39,10 +39,6 @@ static ulong mask =3D GPIO_DEFAULT_MASK; module_param_named(mask, mask, ulong, 0444); MODULE_PARM_DESC(mask, "GPIO channel mask."); =20 -/* - * FIXME: convert this singleton driver to use the state container - * design pattern, see Documentation/driver-api/driver-model/design-patter= ns.rst - */ static struct cs5535_gpio_chip { struct gpio_chip chip; resource_size_t base; @@ -285,30 +281,29 @@ static const char * const cs5535_gpio_names[] =3D { "GPIO28", NULL, NULL, NULL, }; =20 -static struct cs5535_gpio_chip cs5535_gpio_chip =3D { - .chip =3D { - .owner =3D THIS_MODULE, - .label =3D DRV_NAME, - - .base =3D 0, - .ngpio =3D 32, - .names =3D cs5535_gpio_names, - .request =3D chip_gpio_request, - - .get =3D chip_gpio_get, - .set =3D chip_gpio_set, - - .direction_input =3D chip_direction_input, - .direction_output =3D chip_direction_output, - }, -}; - static int cs5535_gpio_probe(struct platform_device *pdev) { + struct cs5535_gpio_chip *priv; + struct gpio_chip *gc; struct resource *res; int err =3D -EIO; ulong mask_orig =3D mask; =20 + priv =3D devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); + if (!priv) + return -ENOMEM; + + gc =3D &priv->chip; + gc->owner =3D THIS_MODULE; + gc->label =3D DRV_NAME; + gc->ngpio =3D 32; + gc->names =3D cs5535_gpio_names; + gc->request =3D chip_gpio_request; + gc->get =3D chip_gpio_get; + gc->set =3D chip_gpio_set; + gc->direction_input =3D chip_direction_input; + gc->direction_output =3D chip_direction_output; + /* There are two ways to get the GPIO base address; one is by * fetching it from MSR_LBAR_GPIO, the other is by reading the * PCI BAR info. The latter method is easier (especially across @@ -329,9 +324,9 @@ static int cs5535_gpio_probe(struct platform_device *pd= ev) } =20 /* set up the driver-specific struct */ - cs5535_gpio_chip.base =3D res->start; - cs5535_gpio_chip.pdev =3D pdev; - spin_lock_init(&cs5535_gpio_chip.lock); + priv->base =3D res->start; + priv->pdev =3D pdev; + spin_lock_init(&priv->lock); =20 dev_info(&pdev->dev, "reserved resource region %pR\n", res); =20 @@ -347,8 +342,7 @@ static int cs5535_gpio_probe(struct platform_device *pd= ev) mask_orig, mask); =20 /* finally, register with the generic GPIO API */ - return devm_gpiochip_add_data(&pdev->dev, &cs5535_gpio_chip.chip, - &cs5535_gpio_chip); + return devm_gpiochip_add_data(&pdev->dev, gc, priv); } =20 static struct platform_driver cs5535_gpio_driver =3D { --=20 2.53.0