From patchwork Tue Nov 19 04:34:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kurt Borja X-Patchwork-Id: 13879405 Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) (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 C866A14883C; Tue, 19 Nov 2024 04:34:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731990879; cv=none; b=AWp/tEtDU1R58YS/eZlGseN2vsOqBJbkfiTKIMAUT+lGYtvxYXBBjz1IehD47tHbdPb+pOImLhdfGv0DgklhZYUDDag3hyc40LOFDpUYbNk4ReawPO2ia7kk0higwEcYGJdL8fheqz9nWvfelmgejDypGDWtK3zT6eVA3tOL3zA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731990879; c=relaxed/simple; bh=SEQpEaowS0OdYUDTCat7cY8a/l1lk//Ix8hlUOQQ6oA=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=cLcaUg6+n15uy+L7hsPkzLF4fvqneN3Pu+bbNTwYf/8eHVqAV5JnWDhi6X+Ri7IhPJfwvoD+cSDiL+hrPq4z+GHClEEMkY/ghUVpoFCCBQEushYVCTQ3mXv4lRj1xNh0s5PLlyUcZ6xNe/YzMu/z17+pDOiS1n7gUDurMvI0HoU= 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=B61HWkvw; arc=none smtp.client-ip=209.85.214.182 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="B61HWkvw" Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-20cf6eea3c0so4612915ad.0; Mon, 18 Nov 2024 20:34:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731990877; x=1732595677; 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=8MGnvmdEROwEwV4J3OrYTF1e+3PLHvjyYjupX2tzbmI=; b=B61HWkvwIrenN0WxeZhLY/sl7xlSIHBY3iDqm9iTblNH4Q94Ohx037oEZzQaLcxgMk 9ZHKmlrdb59RPRa6+G/TibjQq7pgk3oooOYsPnRKNmohnB1+VRBm0l+a+ANK/V07vS2q kJDXRlb1ClJrGEJJSLWjVj/eUEbPyuHxRirWBYbJ8OMk2m5lB6791gGNR+MlNOLs/i1t 0WsaZ4aGUKKn6R97OV2RKxe+kPdrCc6W0zyGm/e9pmVD2CPSL/ZzqbwnJkgsWaPcigq3 lv6Vt8+KIchwW/c5NgNuUbn1Wm8n+2A0lKsFCjlfpESk7VBVEI7rxtBjVzhjRPt/9JmX hD7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731990877; x=1732595677; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=8MGnvmdEROwEwV4J3OrYTF1e+3PLHvjyYjupX2tzbmI=; b=VfVC5AhVnBzQlrd38G4Vw8b9zvFVeCqkqSerQwri1xCLxHqkKXouD58V6O2yQ21cwD YHiHNkPcwnt/s0Uo7prrr7BpnyGlz7mWmtBaHFwxDGwWoSUwSWkC0p4CEKeYyRYVxI5U YdfK5HEqa9VsAjZGTCcg0X6zLnkD5Sz5l0g/iJo7A8812oDtbdL19vo/Xd0cHCv0kwEe 3Q0n80hH0dcbEeXn5yIF6T4r7mVSEJBIMyg07YtQBgUChvBdvP2aK8bm4S/zz74/7Pyf KObjSbNozN5wnBVNXNvH+JelGehcB9mm1by7p4efMWi7SUCYRUAC5wN9Bqlr8AJc80rp 61iw== X-Forwarded-Encrypted: i=1; AJvYcCUdh/rNGB2F6dPceWnW0ZdNHAyPggWtodITlSL72wxDrQQ6piqN0ZrBq896UwsVoBlpmTwEj0AdM6I7ddDWuVCLuy99ZA==@vger.kernel.org, AJvYcCUvLROAhkK5w5xWaEeFjuQxihdzJDCSYd60qXKrDn419unPBLG+mYgUGytQr+wfplM9C0BP4A3ydOaarTM=@vger.kernel.org X-Gm-Message-State: AOJu0YydNzYDZiLCbtY1P9FCj7s/VYI5a4x1Mker/u5K7mbo5tQOq7Q5 u96YctIwf4eivSBEvlS6XomAYTqXk/QsflsgmCo0VHQBxS1SS9bn X-Google-Smtp-Source: AGHT+IGPIyD3t78gxunz8Gv3ugpZPEDp5GR+HrdJ+kIyD2a3w7XddKzUVvy7vlyibNLSlwzhq9+eAw== X-Received: by 2002:a17:903:2292:b0:20b:8a71:b5c1 with SMTP id d9443c01a7336-211d0d624cbmr238407335ad.1.1731990876965; Mon, 18 Nov 2024 20:34:36 -0800 (PST) Received: from localhost.localdomain (host95.181-12-202.telecom.net.ar. [181.12.202.95]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-211d0ecc6a4sm65560665ad.94.2024.11.18.20.34.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Nov 2024 20:34:36 -0800 (PST) From: Kurt Borja To: kuurtb@gmail.com Cc: Dell.Client.Kernel@dell.com, hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com, linux-kernel@vger.kernel.org, mario.limonciello@amd.com, platform-driver-x86@vger.kernel.org, w_armin@gmx.de Subject: [PATCH 1/5] alienware-wmi: Simplify platform device creation Date: Tue, 19 Nov 2024 01:34:29 -0300 Message-ID: <20241119043429.25538-1-kuurtb@gmail.com> X-Mailer: git-send-email 2.47.0 Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Simplfy platform device creation by using platform_device_register_simple(). Signed-off-by: Kurt Borja Reviewed-by: Mario Limonciello --- drivers/platform/x86/dell/alienware-wmi.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x86/dell/alienware-wmi.c index 77465ed9b449..742fe79f13dc 100644 --- a/drivers/platform/x86/dell/alienware-wmi.c +++ b/drivers/platform/x86/dell/alienware-wmi.c @@ -1196,14 +1196,13 @@ static int __init alienware_wmi_init(void) ret = platform_driver_register(&platform_driver); if (ret) goto fail_platform_driver; - platform_device = platform_device_alloc("alienware-wmi", PLATFORM_DEVID_NONE); - if (!platform_device) { - ret = -ENOMEM; + + platform_device = platform_device_register_simple("alienware-wmi", + PLATFORM_DEVID_NONE, NULL, 0); + if (IS_ERR(platform_device)) { + ret = PTR_ERR(platform_device); goto fail_platform_device1; } - ret = platform_device_add(platform_device); - if (ret) - goto fail_platform_device2; if (quirks->hdmi_mux > 0) { ret = create_hdmi(platform_device); @@ -1242,9 +1241,7 @@ static int __init alienware_wmi_init(void) fail_prep_deepsleep: fail_prep_amplifier: fail_prep_hdmi: - platform_device_del(platform_device); -fail_platform_device2: - platform_device_put(platform_device); + platform_device_unregister(platform_device); fail_platform_device1: platform_driver_unregister(&platform_driver); fail_platform_driver: From patchwork Tue Nov 19 04:34:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kurt Borja X-Patchwork-Id: 13879406 Received: from mail-pg1-f179.google.com (mail-pg1-f179.google.com [209.85.215.179]) (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 AFBFF14884F; Tue, 19 Nov 2024 04:34:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731990897; cv=none; b=lnBbsvK7ERjzGF/VLJKyEKv9hDEs0bHVfdT3FesEjLttWjpOUEqmhAThxGGqmgWbRoeQBT5imUH308+DbcnToLxNFjQ4KvBfDgfT/1IwwT/cq7V7Jas2yU7WVlBKe4jW1SWBlLRDkqWtdrvCJHhRHlpQllKyDFqEzGUfN4lWJD0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731990897; c=relaxed/simple; bh=Ngp1w3QUlS9RiMRnxtGhRctCKsbIXsFJRrpwsCwhnl0=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=TTnLwaZrOtnOdTEUML1IUV33B2BYGFpbhXIJdbX6zFcnKztfu4zawTLvubtS4j2l4MFWA0HMZe0p/BFsy1EO9AGoiLU0bg0clXAjMmZti8w5TWAmB1eSXk2dCJp1pMjLmn+TEowCy6SaOXtsuAMlSiFGCeovleiIk7J+Scr0ryE= 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=geOTHx5V; arc=none smtp.client-ip=209.85.215.179 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="geOTHx5V" Received: by mail-pg1-f179.google.com with SMTP id 41be03b00d2f7-7f8095a200eso3514578a12.1; Mon, 18 Nov 2024 20:34:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731990895; x=1732595695; 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=n4MibD/tDTTi7VO5iTu8AQmQE3saCCZ8yCpb8Ukl5+Y=; b=geOTHx5V4r6LwGSoxs4gl0Xat2+GI/36jY4IBPCt/iXHQWGxwhPizReooCKYYeNorL WLIjp/8kh2BOUeR48RCRrQbcvd38ulcAX3vO+iMMCIjACl3XAYdhnpfuYGwVNfJcSpel TH0HDtaShyb/0V9hqIeHQVgGO8TNiU8IgUs5lumYhP6XDLBaZh1cuhRS4y4nWiTBSp9r PERFJDPY2i1YSXwHmYV+1TPE/xCtXoGEL6exsBjKjz3RnmHHFlmcoWvz1UC00YxmiiEr 0+9ZpzIjpQGGDCbSaJUcalQMspy3fG1FFRdYs/u2OgpCiO2qwG8bFaICnPiCap+35sN2 F2ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731990895; x=1732595695; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=n4MibD/tDTTi7VO5iTu8AQmQE3saCCZ8yCpb8Ukl5+Y=; b=ZZFV5vOz5uxhh1NfqOZSsglPWe3lX0ihZzF/61cL9FM33C0trmegaD/stCw5lMBgaJ isBxh46afcLsob1nGQ+ItNMunLfzSAo4vGR57hwFLQ4peiN+jdKFp+ashmEtqRPpxgt1 2bvWBd/OLdz4GN1M8RhPsHdW1AVDx0acj7ZoDIenUZIR08FZ28cbzhxvTysFp4eOfIfl S17O7CZbUOaT/SnGRKDx6sN0m+nISowwtKPRWmuSKzUFaoyLW5hYxFNGRlqjhR13xoHm RS7hoQxz6Lw7SjiCdT3eLKU1dleWSh3YolZvANOQePcIXPVOOrDSmHXP5UJFbxd3XHEx catg== X-Forwarded-Encrypted: i=1; AJvYcCUwFitOQ9nOK1Dy/mCSLl5C6yOMLQdkMGCFYB/sPCv1+5DArn2lgBpG0YXX/nnGE1U+sM54yu6B5sxtIBxgEYP5/vZydw==@vger.kernel.org, AJvYcCVBdq/t6EIABxO6l/9QFifGW1Z1WdEYHtNGOWDZSwtPOS3pK72t0zYIT/Wp5Vx+/FI53jnwxczDh5IbpNc=@vger.kernel.org X-Gm-Message-State: AOJu0YycVZoLOZAMTse7Z5b7zLxKRjm54AWM36q7nGHeu0QhlnJeRLU0 wpqcXpXEoaNPWIi6H9An99P72evcr4ZHaZMseZktpj3zxj3f7DFr X-Google-Smtp-Source: AGHT+IFNpX3W4HogRyPAEEW6jj1Tptg9P7kFaZa0f4qV+GG4ilWBEW3Bq2kXG+2RNupfB6wT1T0KTg== X-Received: by 2002:a17:90b:4c41:b0:2ea:a9ac:eeec with SMTP id 98e67ed59e1d1-2eaaa7cf78emr2676256a91.18.1731990894933; Mon, 18 Nov 2024 20:34:54 -0800 (PST) Received: from localhost.localdomain (host95.181-12-202.telecom.net.ar. [181.12.202.95]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-211d0f47135sm65128405ad.193.2024.11.18.20.34.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Nov 2024 20:34:54 -0800 (PST) From: Kurt Borja To: kuurtb@gmail.com Cc: Dell.Client.Kernel@dell.com, hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com, linux-kernel@vger.kernel.org, mario.limonciello@amd.com, platform-driver-x86@vger.kernel.org, w_armin@gmx.de Subject: [PATCH 2/5] alienware-wmi: Remove unnecessary check at module exit Date: Tue, 19 Nov 2024 01:34:46 -0300 Message-ID: <20241119043446.25572-1-kuurtb@gmail.com> X-Mailer: git-send-email 2.47.0 Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Module initialization fails if platform device fails to register so it's always not NULL at exit. Signed-off-by: Kurt Borja --- drivers/platform/x86/dell/alienware-wmi.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x86/dell/alienware-wmi.c index 742fe79f13dc..289b842c07aa 100644 --- a/drivers/platform/x86/dell/alienware-wmi.c +++ b/drivers/platform/x86/dell/alienware-wmi.c @@ -1252,13 +1252,11 @@ module_init(alienware_wmi_init); static void __exit alienware_wmi_exit(void) { - if (platform_device) { - alienware_zone_exit(platform_device); - remove_hdmi(platform_device); - remove_thermal_profile(); - platform_device_unregister(platform_device); - platform_driver_unregister(&platform_driver); - } + alienware_zone_exit(platform_device); + remove_hdmi(platform_device); + remove_thermal_profile(); + platform_device_unregister(platform_device); + platform_driver_unregister(&platform_driver); } module_exit(alienware_wmi_exit); From patchwork Tue Nov 19 04:35:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kurt Borja X-Patchwork-Id: 13879407 Received: from mail-oi1-f175.google.com (mail-oi1-f175.google.com [209.85.167.175]) (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 8DC04149C57; Tue, 19 Nov 2024 04:35:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731990914; cv=none; b=hQrfkbMNE2kbNOdCacYas9Mz8lpwz3XffJJ/q7wgGf08WXvFIAm1AuATSnCbTjUh3qAJqQMMVIJrGw/Zq4svqR3lkIjOp9sIqiHZ6DB+tPIqTe/XFshtNqpiHvsJ35bwkMwy6obIVJvupsSu1/Z13usS3tJPd43e1oPqjXrsBdI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731990914; c=relaxed/simple; bh=jjMFNJ7TfVSIiHLU1uUB9MdGrQDFNHvXGBxvrKjkOTc=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=SRTaU3li5dMWg+fwhJWtJ/0Td3ym6fYXTu9aEaPKHTkyHnqrothXZAeoteD4ULOpH8wiWJyJRnqvl4V6GjjBXpt/Y5qtLRmqTm4F1ET3RjZDD+kfE83a5nV+BaGh05usNqgzWjIM82/ovOMNvqUJDEYttRjwmHl/nhwk7atp8mU= 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=Ozp6iN4r; arc=none smtp.client-ip=209.85.167.175 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="Ozp6iN4r" Received: by mail-oi1-f175.google.com with SMTP id 5614622812f47-3e5ffbc6acbso1563938b6e.3; Mon, 18 Nov 2024 20:35:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731990911; x=1732595711; 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=qutRYX47PZq2TLtsUHnQwEmMSJ5C/hYw2sul0EI6m04=; b=Ozp6iN4rfmb1Vc8WbWzs67uZxrlaICw/BcbOuhcVClpujV2DhPo+WHXkAshXUPpYjC nt3jCfDNtdUmVaCC31oxVXVVkfi9tWr+RHUnJmAANf6tz3B861meB+sF2afkU/EMMPIY 75Q0mvcxkOGyi8sjtwM0KMP11jQjj8jem9cw5cB2OOz1WB9Qkn70QW9ccVM1/9F8O1Lb OgkJXYPqkNaxWnpgIQFMZSsp/tQUu6LwhZ9rSzvIdSgpfTHFQmE8Lva/riYnEseUlwyc J5zGuOPuRnj/7Mun20wOTLXnamFb6Pc7CbL0aXjwkMJ6EGSQ+gd1AH5ivjfY/5OPV9sZ x6sA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731990911; x=1732595711; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=qutRYX47PZq2TLtsUHnQwEmMSJ5C/hYw2sul0EI6m04=; b=Dn7Y+DXy/B+zrRirQ7KydvXXG2e0RdSHjSYosMNZGDh8VmtfiPwaY2oM9eVWtUK3bP G51fnaFrNI43dXD0Irw4BUpaVVA+/h99OUBacGvUsSdOwYn11g99qGaRbkyzOCoIbPhr f6Z0lbGk1fmmEBcm0eYAI/zjclOQWMFp3VWyHsWW1qUdJAO8v+whzndlWD/WwC8PcUBH huhNWfIvzKeoGh846ol7UGeALXyRyUUYlTbLIfIhO37hzuwgmNfmU30GdYARnpo8qJWp jgxeZ+xoxmcUQ1nuEzpkw0nJ9IQJK44kEtr2g+IGN97aoar59fNm7R8uC//iK8ZYhHva 6UdQ== X-Forwarded-Encrypted: i=1; AJvYcCVYzbkb2NcAsjA9jtr16ATE3YTIIlGzhnua5WbrOujBJKruGyOxa770LyDO6oAaIJBn4L6zQ7KWCns8njo=@vger.kernel.org, AJvYcCXMV7B+OOE3Bzmpv1Ba7zOfgt6hztw2YpaYX7pI7Xs3xl9xuzfc4DrgIVXX4lfVdX4bPhN/jEL6NH6MxqAjQxwtgckbDw==@vger.kernel.org X-Gm-Message-State: AOJu0Yw4VQ1KRyVmssCUjQip1whjuz0OSA23fkSslE8/smo2k283MmDu jE9CYIr/1h4mGjSC10B7ouZNP+2vK5pFIePOQ+RU3/5v8mWT95UU X-Google-Smtp-Source: AGHT+IH8PX/8w9Hkk5kEwM/fjpVkD0RLQ/t5jnTZsGQtIcgZum72ZmOZWLsoa9E/lEyXMkEPsZFk5w== X-Received: by 2002:a05:6808:4481:b0:3e3:cd42:58b0 with SMTP id 5614622812f47-3e7bc877597mr12378149b6e.43.1731990911595; Mon, 18 Nov 2024 20:35:11 -0800 (PST) Received: from localhost.localdomain (host95.181-12-202.telecom.net.ar. [181.12.202.95]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-724771c0d37sm7306207b3a.104.2024.11.18.20.35.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Nov 2024 20:35:11 -0800 (PST) From: Kurt Borja To: kuurtb@gmail.com Cc: Dell.Client.Kernel@dell.com, hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com, linux-kernel@vger.kernel.org, mario.limonciello@amd.com, platform-driver-x86@vger.kernel.org, w_armin@gmx.de Subject: [PATCH 3/5] alienware-wmi: Migrate to device managed allocations Date: Tue, 19 Nov 2024 01:35:06 -0300 Message-ID: <20241119043506.25611-1-kuurtb@gmail.com> X-Mailer: git-send-email 2.47.0 Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 All allocation's lifetimes are tied to the platform device lifetime thus make them device managed. Signed-off-by: Kurt Borja --- drivers/platform/x86/dell/alienware-wmi.c | 40 ++++++++--------------- 1 file changed, 14 insertions(+), 26 deletions(-) diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x86/dell/alienware-wmi.c index 289b842c07aa..980ffc545093 100644 --- a/drivers/platform/x86/dell/alienware-wmi.c +++ b/drivers/platform/x86/dell/alienware-wmi.c @@ -411,8 +411,6 @@ struct wmax_u32_args { }; static struct platform_device *platform_device; -static struct device_attribute *zone_dev_attrs; -static struct attribute **zone_attrs; static struct platform_zone *zone_data; static struct platform_profile_handler pp_handler; static enum wmax_thermal_mode supported_thermal_profiles[PLATFORM_PROFILE_LAST]; @@ -624,10 +622,12 @@ static ssize_t store_control_state(struct device *dev, static DEVICE_ATTR(lighting_control_state, 0644, show_control_state, store_control_state); -static int alienware_zone_init(struct platform_device *dev) +static int alienware_zone_init(struct platform_device *pdev) { u8 zone; char *name; + struct device_attribute *zone_dev_attrs; + struct attribute **zone_attrs; if (interface == WMAX) { lighting_control_state = WMAX_RUNNING; @@ -644,28 +644,25 @@ static int alienware_zone_init(struct platform_device *dev) * the lighting control + null terminated * - zone_data num_zones is for the distinct zones */ - zone_dev_attrs = - kcalloc(quirks->num_zones + 1, sizeof(struct device_attribute), - GFP_KERNEL); + zone_dev_attrs = devm_kcalloc(&pdev->dev, quirks->num_zones + 1, + sizeof(struct device_attribute), GFP_KERNEL); if (!zone_dev_attrs) return -ENOMEM; - zone_attrs = - kcalloc(quirks->num_zones + 2, sizeof(struct attribute *), - GFP_KERNEL); + zone_attrs = devm_kcalloc(&pdev->dev, quirks->num_zones + 2, + sizeof(struct attribute *), GFP_KERNEL); if (!zone_attrs) return -ENOMEM; - zone_data = - kcalloc(quirks->num_zones, sizeof(struct platform_zone), - GFP_KERNEL); + zone_data = devm_kcalloc(&pdev->dev, quirks->num_zones, + sizeof(struct platform_zone), GFP_KERNEL); if (!zone_data) return -ENOMEM; for (zone = 0; zone < quirks->num_zones; zone++) { - name = kasprintf(GFP_KERNEL, "zone%02hhX", zone); - if (name == NULL) - return 1; + name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "zone%02hhX", zone); + if (!name) + return -ENOMEM; sysfs_attr_init(&zone_dev_attrs[zone].attr); zone_dev_attrs[zone].attr.name = name; zone_dev_attrs[zone].attr.mode = 0644; @@ -678,24 +675,15 @@ static int alienware_zone_init(struct platform_device *dev) zone_attrs[quirks->num_zones] = &dev_attr_lighting_control_state.attr; zone_attribute_group.attrs = zone_attrs; - led_classdev_register(&dev->dev, &global_led); + led_classdev_register(&pdev->dev, &global_led); - return sysfs_create_group(&dev->dev.kobj, &zone_attribute_group); + return sysfs_create_group(&pdev->dev.kobj, &zone_attribute_group); } static void alienware_zone_exit(struct platform_device *dev) { - u8 zone; - sysfs_remove_group(&dev->dev.kobj, &zone_attribute_group); led_classdev_unregister(&global_led); - if (zone_dev_attrs) { - for (zone = 0; zone < quirks->num_zones; zone++) - kfree(zone_dev_attrs[zone].attr.name); - } - kfree(zone_dev_attrs); - kfree(zone_data); - kfree(zone_attrs); } static acpi_status alienware_wmax_command(void *in_args, size_t in_size, From patchwork Tue Nov 19 04:35:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kurt Borja X-Patchwork-Id: 13879408 Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) (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 F1C93149C57; Tue, 19 Nov 2024 04:35:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731990930; cv=none; b=WitiFL3Fn51VrpJ7qtL/acYZwREl0a4ocjZkDXmgc2sMsh0d0/Ef1cqirz/OOjqwX6F4gPQjtd4MpY73unbjJbOcUlXM8Wj2IRwU/hCaE9GA/q14NulpEAYKUNQXGwbJrR3XwjSkTr4bYnSkyEbM0lr8TgUWauHjrwqtaA9KfPQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731990930; c=relaxed/simple; bh=8wuAZsTBhNUwhdQkZXHbwWv41FpbwOHG9TqAiR1vqc4=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=cYmnzP02SKFTPhEGhJR39Y93L13EKXzv9je9TOfeBLnPT30ooYg1NkrVCY8bql6A8XfLiKjeq8NGaVeV5AJm5vsLxEsBNHASzaS7F3IdAleraI29jkhSbprh/n4sbUZJScswgjKg0jGB3o1fKt38jHIrRumt4KKHS8iP8grvzhc= 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=VeFGDfMy; arc=none smtp.client-ip=209.85.214.175 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="VeFGDfMy" Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-20c70abba48so23089195ad.0; Mon, 18 Nov 2024 20:35:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731990928; x=1732595728; 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=7f3VVsKlKn3uK84HbMZ0iSO4Dt/y5UTYoKWdW3JUriM=; b=VeFGDfMy9pNg3llDmup/BgxuFRbASl7ZirUSX7vrhvMVHZAoLu/+xsv1LLMuOD8rGI 58aJnF/K8cMsr/pdC/t1yrpyOKrEUIA1DfejCZr9nT6juUxUYOrlVNT684bmwNpUzazI AocDvd5T5iQIEX5zCugFOfGlAhrcJCQuotMO9HXyDgm9d9jh123ewmpT6SdOeyCWPOv8 CrcYs8AbzL/TZtvKop8zzTYDmVzqrp1uAbhmqsDoSogrw5OmOf1xZDILgnTa8of/tZYx Dh/Ed7YygfvJ7nQfVKTXHkkFk+ek3KSblUs8iQR3IYATA/PRC+hGgqTyFi2fdx6pTh71 P3uQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731990928; x=1732595728; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=7f3VVsKlKn3uK84HbMZ0iSO4Dt/y5UTYoKWdW3JUriM=; b=Ker13BLnGEx12PngLR+B4J/aaPrc/AISgtNNZMm9xVfDB2GlvxkJxb97RTMlfyYHLE p79A7BQGvNFvCCDtQykRwxfXracIkFCAuAONg8dGcHi8Ih7s4gZtF47gpj+Ibr24jEqm punNZZuJzJQAjEHkGQDn+GF0ah8TSNUWuSd1IHPUhK0UnTm/YQu6fG2LLVhw05+9pJRn 3QbKpD4A1oQ6DzLoLbaEP3eKfAVlmyistV/95+h+V9dZv9to8IPjtpux7zRMInXbcuGq GRyb16sbA2sYn/606S1/cjYb0/9QndeKcZIJCIvsYCFhjhtDlofZUj40QGWToBbGHnQV GcyQ== X-Forwarded-Encrypted: i=1; AJvYcCWaZWMzpDk0124uRvsWu2CQQc6yTeJo1u7mxTeGicR9J7+lhLvywM7G4D+f9q3aQi/VpAYyoiERZck6umE=@vger.kernel.org, AJvYcCXTD+i6Owk5RtS/fbZTCjaGLVYMrlZiiFdnxc0PTFIIurtL17deBFBw4hcws3No3JG8qpf0NVIC1QG+wdjYlOedzomg+w==@vger.kernel.org X-Gm-Message-State: AOJu0Yz1ov85l3VBbGO4zfz9ojlU6S+8FyL3fDNz0Gjx1n/eEjfgqHCP Wmz2hs2sZsgfZ5/Vyq2DRgvIoaiKeurcZ5YsrbrEuA/fiobSTf8Z X-Google-Smtp-Source: AGHT+IFLot3x/OiWOd2HLL0ZEAOvNkW+em39WPt3+hKjvb6vOhBcOvY1ficoZJafNEV6gU63PXTj7A== X-Received: by 2002:a17:902:cecf:b0:1fa:1dd8:947a with SMTP id d9443c01a7336-211d0ebf182mr190185955ad.46.1731990928332; Mon, 18 Nov 2024 20:35:28 -0800 (PST) Received: from localhost.localdomain (host95.181-12-202.telecom.net.ar. [181.12.202.95]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-211fb9cb4e7sm44953045ad.217.2024.11.18.20.35.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Nov 2024 20:35:28 -0800 (PST) From: Kurt Borja To: kuurtb@gmail.com Cc: Dell.Client.Kernel@dell.com, hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com, linux-kernel@vger.kernel.org, mario.limonciello@amd.com, platform-driver-x86@vger.kernel.org, w_armin@gmx.de Subject: [PATCH 4/5] alienware-wmi: Fix module init error handling Date: Tue, 19 Nov 2024 01:35:23 -0300 Message-ID: <20241119043523.25650-1-kuurtb@gmail.com> X-Mailer: git-send-email 2.47.0 Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Propagate led_classdev_register return value in case of error. Call led_classdev_unregister in case sysfs_create_group fails. If alienware_zone_init fails, alienware_zone_exit should not be called because the latter unregisters/removes the led class and the sysfs group, which may not be registered/created if the former failed prematurely. Signed-off-by: Kurt Borja --- drivers/platform/x86/dell/alienware-wmi.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x86/dell/alienware-wmi.c index 980ffc545093..44f1f7b57d0a 100644 --- a/drivers/platform/x86/dell/alienware-wmi.c +++ b/drivers/platform/x86/dell/alienware-wmi.c @@ -628,6 +628,7 @@ static int alienware_zone_init(struct platform_device *pdev) char *name; struct device_attribute *zone_dev_attrs; struct attribute **zone_attrs; + int ret; if (interface == WMAX) { lighting_control_state = WMAX_RUNNING; @@ -675,9 +676,19 @@ static int alienware_zone_init(struct platform_device *pdev) zone_attrs[quirks->num_zones] = &dev_attr_lighting_control_state.attr; zone_attribute_group.attrs = zone_attrs; - led_classdev_register(&pdev->dev, &global_led); + ret = led_classdev_register(&pdev->dev, &global_led); + if (ret < 0) + return ret; + + ret = sysfs_create_group(&pdev->dev.kobj, &zone_attribute_group); + if (ret < 0) + goto fail_prep_zone_group; + + return 0; - return sysfs_create_group(&pdev->dev.kobj, &zone_attribute_group); +fail_prep_zone_group: + led_classdev_unregister(&global_led); + return ret; } static void alienware_zone_exit(struct platform_device *dev) @@ -1223,7 +1234,6 @@ static int __init alienware_wmi_init(void) return 0; fail_prep_zones: - alienware_zone_exit(platform_device); remove_thermal_profile(); fail_prep_thermal_profile: fail_prep_deepsleep: From patchwork Tue Nov 19 04:35:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kurt Borja X-Patchwork-Id: 13879409 Received: from mail-pg1-f172.google.com (mail-pg1-f172.google.com [209.85.215.172]) (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 BC60C14883C; Tue, 19 Nov 2024 04:35:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731990942; cv=none; b=ZijbME6+K64pbetHj+efAtszlY/RaviGYpoGn1vN//49CzJMLGeHcasJmGRhKkn0cOzp94fWInYJh4pebh9gjl2hOC5mpoWqTM7BvXdDMUS22csc7Xc3Io7S5ZajeX0cA5TOJT314/M5kUB9tOvUD0BA7CnGmn0FvSysj/Gcc7o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731990942; c=relaxed/simple; bh=JvVjEtUcK8mPj6HAzqx4Td1tV1c6mTucb2cJy/j6Ij0=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=uZoIxa7aHqYEJR7dKwbAXO123PwPF5wB0Dj+I67rm6EjM2H0snLUWZthaEKj2bDbEZSe2YoRosJU57jh6Q87tRzQ93O84aDuoYSvTAex4CrxacTGhGATt6tcUCOKQWRqdavK4YJtGFQR91TaChfQZV0CBmW6AcnKFzXlmlcWE6A= 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=ATxncjnS; arc=none smtp.client-ip=209.85.215.172 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="ATxncjnS" Received: by mail-pg1-f172.google.com with SMTP id 41be03b00d2f7-7ee020ec76dso358321a12.3; Mon, 18 Nov 2024 20:35:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731990940; x=1732595740; 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=6Mt2kk2PoDSy2cjvOCOwysjW9T27/nUvH/Sb5nJrvwg=; b=ATxncjnSly5kX01UrEscrOUjYGqIhaKc17eFheLZsnZqGXZd+VHrCwLfnnL6i9tGy2 y5Zt4xicd8h3qHSz1qbyTda1h2ICT7/T3vk7Vag3qk50v58cv9AToTJyh3JHywfZqH6c B2apl/EPwUdXQtP/HrsW9bJOLTjZlw5m9zFe2l/3Od2CJLjHtEQ8xSaQvR+191Wg39j3 a+WYhZRsLf2ffD5pHv+0lXVyUh7Ye6YwENgEeFDSRTqNDPFQvLicbuxveVto9aPLJLUG SZn1Czmo7iPh0Qj6hywR21bQcsCfu7gL2tBsNAdmRzkU33qG04EUJkHboTSWn8UA5F7x x+rQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731990940; x=1732595740; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=6Mt2kk2PoDSy2cjvOCOwysjW9T27/nUvH/Sb5nJrvwg=; b=CKgmCLrDcyp8nsLOo3JR0uZoi041YjN7z4IK1PDBlF5raVGR3C6oHKC2hWYb3cAGgn 86O1NMyKmD0ZYMCn805jvt4UBmBqScVfyswCvGRg5iBPP0GiuUnEY8bN/xWRFev9HDgG kbEwgt2t6jlINOW+X7WpxK/swZMPBo746yahVNfG4nIS2MFJd79OuZe5eHNSBu8scaRw YiHV+5XKUBbUDCaxISJSa0zsIxzsvw+RTg+bDt4mLMrZHL3WkQcG/oHC9zhB21wrtMye qdGrHiNoqfXaNBZCkqIWyPBctq3EjiVxwJbL0ovhePZ9dkAWHm3l6Gzx8bDa9HQBos4d UZPg== X-Forwarded-Encrypted: i=1; AJvYcCWan7gHd+OdQK4RFEpunlGfdFX2zD4/PhcU8E2ZHF8HTdKxsg9mxMA5PdeEzXxOLUgTI8W5pGoa1y2Gd/JFx0JVQJ+mCw==@vger.kernel.org, AJvYcCXLtQiyFU5fQU0h2oayrHqJUjf2MN9yPKNyBCYOkfH3uugO8pWB8SQXax39WANsrG/BXUdYubXbB5b22nU=@vger.kernel.org X-Gm-Message-State: AOJu0YyAnOgbFZT90dgkrXpiG9tKRGwPZd8cj5C4tRZvj71eZDwgMURJ n1IK6gTkMCK8U2tFHcCtYGA8QfToS1Gy8gFoSPr0D/zBeOfshUVF X-Google-Smtp-Source: AGHT+IFIbC5XYKPiw7Q5hAiWvRuRq5h8g+cAOP1pn9KewVr847vttcmRTfnskisPgoXj6hMDjXkpWA== X-Received: by 2002:a05:6a20:158e:b0:1db:f07e:8ab5 with SMTP id adf61e73a8af0-1dc90bcd528mr22349418637.36.1731990940075; Mon, 18 Nov 2024 20:35:40 -0800 (PST) Received: from localhost.localdomain (host95.181-12-202.telecom.net.ar. [181.12.202.95]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-724771394ffsm7050045b3a.90.2024.11.18.20.35.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Nov 2024 20:35:39 -0800 (PST) From: Kurt Borja To: kuurtb@gmail.com Cc: Dell.Client.Kernel@dell.com, hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com, linux-kernel@vger.kernel.org, mario.limonciello@amd.com, platform-driver-x86@vger.kernel.org, w_armin@gmx.de Subject: [PATCH 5/5] alienware-wmi: Improves sysfs groups creation Date: Tue, 19 Nov 2024 01:35:34 -0300 Message-ID: <20241119043534.25683-1-kuurtb@gmail.com> X-Mailer: git-send-email 2.47.0 Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Devices with hdmi_mux, amplifier or deepslp quirks create a sysfs group for each available feature. To accomplish this, helper create/remove functions were called on module init, but they had the following problems: - Create helpers called remove helpers on failure, which in turn tried to remove the sysfs group that failed to be created - If group creation failed mid way, previous successfully created groups were not cleaned up - Module exit only removed hdmi_mux group To improve this, drop all helpers in favor of two helpers that make use of sysfs_create_groups/sysfs_remove_groups to cleanly create/remove groups at module init/exit. Signed-off-by: Kurt Borja --- I have a question. Do the created sysfs groups get removed when their kobj reference count goes to 0? I ask because I want to know if this is a bug fix. --- drivers/platform/x86/dell/alienware-wmi.c | 105 ++++++++-------------- 1 file changed, 36 insertions(+), 69 deletions(-) diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x86/dell/alienware-wmi.c index 44f1f7b57d0a..e9ed2089cba0 100644 --- a/drivers/platform/x86/dell/alienware-wmi.c +++ b/drivers/platform/x86/dell/alienware-wmi.c @@ -410,8 +410,10 @@ struct wmax_u32_args { u8 arg3; }; + static struct platform_device *platform_device; static struct platform_zone *zone_data; +const struct attribute_group *wmax_groups[4]; static struct platform_profile_handler pp_handler; static enum wmax_thermal_mode supported_thermal_profiles[PLATFORM_PROFILE_LAST]; @@ -810,22 +812,6 @@ static const struct attribute_group hdmi_attribute_group = { .attrs = hdmi_attrs, }; -static void remove_hdmi(struct platform_device *dev) -{ - if (quirks->hdmi_mux > 0) - sysfs_remove_group(&dev->dev.kobj, &hdmi_attribute_group); -} - -static int create_hdmi(struct platform_device *dev) -{ - int ret; - - ret = sysfs_create_group(&dev->dev.kobj, &hdmi_attribute_group); - if (ret) - remove_hdmi(dev); - return ret; -} - /* * Alienware GFX amplifier support * - Currently supports reading cable status @@ -864,22 +850,6 @@ static const struct attribute_group amplifier_attribute_group = { .attrs = amplifier_attrs, }; -static void remove_amplifier(struct platform_device *dev) -{ - if (quirks->amplifier > 0) - sysfs_remove_group(&dev->dev.kobj, &lifier_attribute_group); -} - -static int create_amplifier(struct platform_device *dev) -{ - int ret; - - ret = sysfs_create_group(&dev->dev.kobj, &lifier_attribute_group); - if (ret) - remove_amplifier(dev); - return ret; -} - /* * Deep Sleep Control support * - Modifies BIOS setting for deep sleep control allowing extra wakeup events @@ -942,22 +912,6 @@ static const struct attribute_group deepsleep_attribute_group = { .attrs = deepsleep_attrs, }; -static void remove_deepsleep(struct platform_device *dev) -{ - if (quirks->deepslp > 0) - sysfs_remove_group(&dev->dev.kobj, &deepsleep_attribute_group); -} - -static int create_deepsleep(struct platform_device *dev) -{ - int ret; - - ret = sysfs_create_group(&dev->dev.kobj, &deepsleep_attribute_group); - if (ret) - remove_deepsleep(dev); - return ret; -} - /* * Thermal Profile control * - Provides thermal profile control through the Platform Profile API @@ -1165,6 +1119,34 @@ static void remove_thermal_profile(void) platform_profile_remove(); } +static int __init create_wmax_groups(struct platform_device *pdev) +{ + int no_groups = 0; + + if (quirks->hdmi_mux) { + wmax_groups[no_groups] = &hdmi_attribute_group; + no_groups++; + } + + if (quirks->amplifier) { + wmax_groups[no_groups] = &lifier_attribute_group; + no_groups++; + } + + if (quirks->deepslp) { + wmax_groups[no_groups] = &deepsleep_attribute_group; + no_groups++; + } + + return no_groups > 0 ? device_add_groups(&pdev->dev, wmax_groups) : 0; +} + +static void __exit remove_wmax_groups(struct platform_device *pdev) +{ + if (!wmax_groups[0]) + device_remove_groups(&pdev->dev, wmax_groups); +} + static int __init alienware_wmi_init(void) { int ret; @@ -1203,23 +1185,9 @@ static int __init alienware_wmi_init(void) goto fail_platform_device1; } - if (quirks->hdmi_mux > 0) { - ret = create_hdmi(platform_device); - if (ret) - goto fail_prep_hdmi; - } - - if (quirks->amplifier > 0) { - ret = create_amplifier(platform_device); - if (ret) - goto fail_prep_amplifier; - } - - if (quirks->deepslp > 0) { - ret = create_deepsleep(platform_device); - if (ret) - goto fail_prep_deepsleep; - } + ret = create_wmax_groups(platform_device); + if (ret) + goto fail_prep_groups; if (quirks->thermal) { ret = create_thermal_profile(); @@ -1236,9 +1204,8 @@ static int __init alienware_wmi_init(void) fail_prep_zones: remove_thermal_profile(); fail_prep_thermal_profile: -fail_prep_deepsleep: -fail_prep_amplifier: -fail_prep_hdmi: + remove_wmax_groups(platform_device); +fail_prep_groups: platform_device_unregister(platform_device); fail_platform_device1: platform_driver_unregister(&platform_driver); @@ -1251,7 +1218,7 @@ module_init(alienware_wmi_init); static void __exit alienware_wmi_exit(void) { alienware_zone_exit(platform_device); - remove_hdmi(platform_device); + remove_wmax_groups(platform_device); remove_thermal_profile(); platform_device_unregister(platform_device); platform_driver_unregister(&platform_driver);