From patchwork Mon Jan 20 02:25:35 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Peng Fan (OSS)" X-Patchwork-Id: 13944690 Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on2055.outbound.protection.outlook.com [40.107.241.55]) (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 3D99535968 for ; Mon, 20 Jan 2025 02:26:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.241.55 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737340003; cv=fail; b=mZX63feCEjh6NrlyPxF/zt6Y6wBPSE4JjCUEMykPvMuye6a+N6qbt+fQJGarzrHLCUzVyW0Bg+bS/XTLYL7D7Hf7ocgtm8W/ahxvX9cVagyqT/msgbl7//5ekbIonf72yD3oBBuWVv/gPh4vIr3MQ+5aZ123p4uS6SeFcAe9VuM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737340003; c=relaxed/simple; bh=S3TiT74+c6cbS/0OYDBl578TfCGtZLQhnlEXJ5xPqKU=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=b/JF/5hPXXQJQ/+2W0tg168b4N6aIlxuFNSUtZp+Ex6JhyldWsWJH/722g08kmo1k8qoNp4dTHgEGus7P6Zt8rzV5GFqRzthaU6nkKJplLgikJ/PxhD2kQYUQUlz/A6vW9sQQFz1iodaWjFBmn4U6rglk5TqcMc3Gs7Em64JPUQ= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.nxp.com; spf=pass smtp.mailfrom=oss.nxp.com; dkim=pass (2048-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b=A5SbAMLh; arc=fail smtp.client-ip=40.107.241.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="A5SbAMLh" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=tJPwDu1WKYEL5NxvtLoCNez8r4qILx5JGhcTwe39u0WDTa9KWMIVPbxtqvBoHkIC53sxrlaTOq5BYm1DU1OlFylQzaEiIw48ramjeiW/LT3By0J29/Xou2MJeDUF7kyllV5wGvIyovNn8nrI3B2muDwS0JOjrVl2zpGAFzvlMjcr6u8VwZjzD1bWY8yoxmgRLmXOdXZl/GQxzksmr6AU8xy4PzRJaeJ3pn64jydmktoY4TNTgFQP9wa+XdL15EvtAAuICx3twZA8tnxqVxlXVtQ5WOWy7Us1FOhsp1J4r267WFDVGS6F+bSPywKVvowh6JNOTyzq3LIYp0bNef6SJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=uS0I3mCc295EBaZyA+OocoFOODJEqDmZ8GPyzx+KJVo=; b=PVyMWji1zXxPBP0SYL98vZkKtDrhYmyRGaP44C4NTquGebs/M7ki/7Hk/nGnmDvodCV1vKl3m4IIGYZPeLcziwdmaBpzEoCZdIfFJ+g+fZ3k6r+KeDYkwlEUeshhPE3djoONL2TiuvPTb4aJcTh0fRW+RFfkf+/xTY2omcSCa1bI1EMR6cJF5RjwoEkq8njBwSSc7lRwo0vMBSbVfT/AXN0s2w3KrvOTYow7jte5O+xmYp++wvG98M3+OEGnZVQgn6jsZaTdROKSoRe3G58uRxZnRpHJenNXoXPll3x4bexkI3JaS++SEuwMpvKU4gDZEcI9WN0zEfe6aLIeI755hw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector1-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=uS0I3mCc295EBaZyA+OocoFOODJEqDmZ8GPyzx+KJVo=; b=A5SbAMLh0A4B/Ia2/KBp/pHoS1ehNKINTceOmQdSoiy798Mz/2Dp8JuYPwebe7P2LCXlQLPy3N+pcjTfgP+dotGciUySEXPV6TAlacF3lg+M7dwTJaciqgzw4+72RVNxrxJSkV2FX+LfIKPbTy2QcX/nu83fS0CV9Pg9hSOA59KwPq6kXgYyvJ1aO8dL1ZCP9oj1/MICIP0aiZXBEc0qsM4aOkbLmy6gVuFwswg1m8B6xX89d5cT0+vmC6Fb6gXqIp+3dvSO3w5D4V1XWqOBSysi34W20Fw0iH9DdleBjFDJaj1O1WI1aESUtTwjgjGJ+xJpraBfXC4AXKN0af8Zvg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from PAXPR04MB8459.eurprd04.prod.outlook.com (2603:10a6:102:1da::15) by AS8PR04MB8690.eurprd04.prod.outlook.com (2603:10a6:20b:429::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8356.17; Mon, 20 Jan 2025 02:26:37 +0000 Received: from PAXPR04MB8459.eurprd04.prod.outlook.com ([fe80::165a:30a2:5835:9630]) by PAXPR04MB8459.eurprd04.prod.outlook.com ([fe80::165a:30a2:5835:9630%5]) with mapi id 15.20.8356.020; Mon, 20 Jan 2025 02:26:37 +0000 From: "Peng Fan (OSS)" Date: Mon, 20 Jan 2025 10:25:35 +0800 Subject: [PATCH 3/4] rtc: Introduce devm_rtc_allocate_device_priv Message-Id: <20250120-rtc-v1-3-08c50830bac9@nxp.com> References: <20250120-rtc-v1-0-08c50830bac9@nxp.com> In-Reply-To: <20250120-rtc-v1-0-08c50830bac9@nxp.com> To: Sudeep Holla , Cristian Marussi , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Alexandre Belloni Cc: arm-scmi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, imx@lists.linux.dev, linux-kernel@vger.kernel.org, linux-rtc@vger.kernel.org, Peng Fan X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1737339953; l=7539; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=bmjnxEYUzAa6HVdDVruMYsPIBr6KAocDxz9TUR0lnWI=; b=YcnuPCTqDzMStsGS4pHEqTuj1IjTom/OT/HPgxVwZkJWxo4DM3jgTfZWjdfblgP9K1VIVBN1t /NrUI4e3joICLuXCNWslFEc3vER8ti2ysxPbTUjrUj5/ysQ7YrZ+bfh X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SG2P153CA0038.APCP153.PROD.OUTLOOK.COM (2603:1096:4:c6::7) To PAXPR04MB8459.eurprd04.prod.outlook.com (2603:10a6:102:1da::15) Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8459:EE_|AS8PR04MB8690:EE_ X-MS-Office365-Filtering-Correlation-Id: 9d2223e8-6a5b-4404-cc02-08dd38f9dda5 X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|52116014|366016|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?btWofoHkfosDIcgeuOQD6RPITXZxYxD?= =?utf-8?q?CZNZgYLYe4WBEdaOri0gAU6SX9N3XKC4QPEKxhLBqm4bYn88SC7y8Q1UnApHMgyMb?= =?utf-8?q?r07sV/NwV404yorWASzMO8nuogADgtV8OuK9CAENkMsiy0e/WA0pGS6PenbI803Aj?= =?utf-8?q?YHzuNt5Ux46ffoiR0LxnENOdx5pJEVP31at+MZfniIDQBGG9fU14rW+xIajg+6459?= =?utf-8?q?q7HZqF/oeYGGmuMxzm4XW0p1wN791JrcKyBUTPZ2G7pvsWfZTFKlqMklMA0mEuIp5?= =?utf-8?q?AxCQOBr/6pnAnim+C9+WiBnkVKNxV60LEih6otyr4tHRWIcRTA+X5mD1y4iAANqn1?= =?utf-8?q?Mn52H7vUuGTMWtnTpTVgx8ksEYljdY9R6Nw6zPiEnq7CkkginzjduAl5r2HJu2bIS?= =?utf-8?q?TwJ0nOrmJ9oi+q0fHjK07YLxPod69Z5g1MrJnJgh7jaQvyFpUdT5Hnw/POknhO9PI?= =?utf-8?q?x8q9xjEuMj6ub55r0IvGkXu2pZAInoS7a7sgkCr5Pe17DOUgbhO1M2dqqjrAYfKT7?= =?utf-8?q?2Cn6vsutzU39KxXD5Ue1LKZuJObrWdP2vwfnQbgJtaVnbxaYf13tMWGTyuurbGz9Q?= =?utf-8?q?k89Z8xdA1VmZaat4dZw1tAkQNYgdM4avwa8cKamJx8E1dgLn1BuxuZk45NrY9bcEa?= =?utf-8?q?uEH5cvBQxrGosjZpnhNSYOmfamD1RIXf+1tP1AQdF1Mnw1cRXHCelMcH3Ltk1HgF7?= =?utf-8?q?7IKtDXiqWhaMkWSfApArk54HZdRz9EPYzSSdPd0zod4Hp1fjzwFKGeWW95+A3wBNC?= =?utf-8?q?cmHABFbPzGfmDXeiXZQCY9b1NaeFCc43xodExvTuGCq0Z1w1ZKrREjlZ9OhtI/+jc?= =?utf-8?q?NWKPNuuW4L2GEshzy1EYY3Y+3MXXPu6NSowyaCz2xrs44mVeTrmUs8BkY2x7Eio8n?= =?utf-8?q?07TBDKMttSjgghW7aXP4Sz9shJUNa7TXfA9689xkM3tLZ7V4BiU1BbDCmor1TfkRl?= =?utf-8?q?Xf0V3WqA5XvoCOICA87p27bCemRbi0ac9drS8/C4S/nxEgE0dp1ITRK3jy3K+KMpM?= =?utf-8?q?DiD2PiwZPTSSXTEeOH95AouBIC/8S+P6FNQeXniOZRH35wuzl+GNDyPvtsbbSfI4T?= =?utf-8?q?DtwstwAUN6s5IYqKK0rB+rKWZI6J07RL15X86lN0A0LRBe10a3Pj+R37W8CEmWy5u?= =?utf-8?q?Ei0+qb7vxa8UiS4iGcUV2wzIUczGwUb2E062H9l0XwPM4vjeAVGueJHffTlKB5v6y?= =?utf-8?q?jMXXRJ6kIP5wKfFrRWrvuXrn3rRI2rRkUWBLG21Kk4KZkdHAh311sW/atWvY1qCG2?= =?utf-8?q?WJ9pRrJTdMGmfLACNCihKCDQYOcY7x5IejA/codbO4OzD5BaFAXPE+ljkYkk6o/Ou?= =?utf-8?q?TvpElAnUg4QU7dinKNN/0M20rWAUu0KdgTrGF/5GzupUjmdu9pcTAZ5WWg9mrfEPu?= =?utf-8?q?KV5/oQpBHEm?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB8459.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(7416014)(52116014)(366016)(1800799024)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?CEMsgqCA+6sEQUuh2MXjvKy7QIuf?= =?utf-8?q?lWysLpGI+S9BGN27WUCpqhO7URXdN7DjGe1Etj3GMjMbqNOXRQNOrYq5oQ6Og7VdI?= =?utf-8?q?vZf4eKg3v3DCkpDqvCtmka+1QfZvp63FStU8P3LeBx1RHGrA7ZmUBo6TYEh7EDm+/?= =?utf-8?q?gbFP8s9sEqWbHlN+QN4JkzA+M7jce1zyY3Zw6frEU3SGqdelNVlMnMKhR0asIJrAH?= =?utf-8?q?wX/pOaOZ5geJsuOV9NE+7JyyU8g6A7pwTuxeqXkbYLUkWjtFF+PQW5B1RwYmmrgPD?= =?utf-8?q?XfBPd/953RUKzCFNWdvI1qUFeU43Z3eNioMAGfcC1ZmwGI3f8cmCqwUcPwv4VVkSf?= =?utf-8?q?x9aJtat2JJ2jVTz5iEv/AMAd6RXP+UPubbmD2Ys4Pc+kmKMBOoDMAlnu/eqyDsPYA?= =?utf-8?q?dlIrvdePXtMIPx9WGmEFLCfQekUX3VxiMXamH12cc2X3UcYXiPfyx46WcizvhFnxB?= =?utf-8?q?m21ucR5RuInosnMx9P1m/1XDjTLKUIQsN/xi0ZkQxG+c+OR2k+UMDp/EYwI3Dn6k2?= =?utf-8?q?tZLCqD0rytUIppxh/gL2tcwRcDo37h5rDE1hhrEipZSlvgRWa7SfWJ7gXGW15iX48?= =?utf-8?q?PMiIKEvVoUvHm7RDjYNu4CO+bxSfA4Kmd0Jc4LmE7fYR7G8Dxv5TiWytURbW28L3U?= =?utf-8?q?T7kt2+fZZRhNplYlVDkP8BA2HBSz1vTnqaV/mfcky3hFmMrMH0CyECl94YIQff7t6?= =?utf-8?q?PUXH1CN2JGDA2KHzVxJUxby9RL8WIiVEHc80eqTV65HIbXwHi+pSpTVyYDTf78f3P?= =?utf-8?q?7wdXcLR25SePyFkoICGC4PgULx2sXGePVGUrKY7CoNUKaNi+rDQHjKPdv+EifCkd0?= =?utf-8?q?k3mG2cJHGeSErxDEK8ecg4hLsV0w6gYqg+RBwYdY1CipxIdfBSZnXBExd+W1TnHj7?= =?utf-8?q?3dyKMiD6Y5U8ptHcNLMOQwARTbuPUSkqPxXbJkMId4U1DWP6yJxEDd8H7yzLrY2Dh?= =?utf-8?q?li5AKmTPuLe2LK62basZIte0SB1si3JGCA/vgbSvp7iJok2gZR+lqJ53qzc0EJ5ds?= =?utf-8?q?vn7gcCoFrDSMqqCqZnJiu8XnipNZOaskVpjII9IdzP3fAOG13pjqZPy5Z8UOE1Vxy?= =?utf-8?q?kj6CG/0JXQ6DGxELPRauWP0R6XSXs3aWEvXD7ei2qz+ACyhwpy/+EV06MB4cdLxo4?= =?utf-8?q?e6MMJpb5LUrenGJKXWOkgecqCArRN5VI8cOXW1EzwGvF8SpZCfPhlMi/19m4fjeee?= =?utf-8?q?+nhUImvVen0tobQtHmJB3a4AS8X90C9U+vMUZDMtN/z8vAPlZBHAvItSjfP8WMCss?= =?utf-8?q?m+0cnX+MyerBQi3FGqRz8J+r19grtao+bo34OdE6pioak9sabmovSIPpIjm70ogVk?= =?utf-8?q?rB69XoWb1V348YmTQ/JtY2SmqHEol9NRke190SUchucPyVLwCsCyqskYwLXfi2C0x?= =?utf-8?q?8IJuV8ifHpIUBUcmmindp+QMTTzki5wHbneKfvmt+Qk8AWKo7czo8cUD08YwXuyNL?= =?utf-8?q?w00GTJk2ukYn0uR2jqgSn4zKp2S+EheHmNXnQpWd+EFmfJhKS77lrHMbH0BMo1ai/?= =?utf-8?q?lvfI+iCt1ZoS?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9d2223e8-6a5b-4404-cc02-08dd38f9dda5 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8459.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jan 2025 02:26:37.3957 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: uFMXonDB1l9nD7gh19/vWLKx6Ltm+p3o0RpThXckuXkZz9W5RU+GK3E/pdl5jJ5lW5RAd1iRGuBLXO/aTFxbmg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8690 From: Peng Fan Current users of rtc_class_ops->x are using 'rtc->dev.parent', so there is no way for rtc drivers get rtc private information. Take i.MX95 for example, i.MX95 SCMI BBM Protocol supports two RTCs for i.MX95 EVK board. Using 'rtc->dev.parent' causing driver not not able to know the exact RTC device. So introduce 'priv' and devm_rtc_allocate_device_priv for driver to set rtc device private information. Signed-off-by: Peng Fan --- drivers/rtc/class.c | 9 ++++++++- drivers/rtc/dev.c | 8 +++++--- drivers/rtc/interface.c | 16 ++++++++-------- drivers/rtc/proc.c | 2 +- include/linux/rtc.h | 2 ++ 5 files changed, 24 insertions(+), 13 deletions(-) diff --git a/drivers/rtc/class.c b/drivers/rtc/class.c index e31fa0ad127e9545afac745a621d4ccbcd5fca28..67413600785d806fe4da441483ce1280357d8791 100644 --- a/drivers/rtc/class.c +++ b/drivers/rtc/class.c @@ -361,7 +361,7 @@ static void devm_rtc_release_device(void *res) put_device(&rtc->dev); } -struct rtc_device *devm_rtc_allocate_device(struct device *dev) +struct rtc_device *devm_rtc_allocate_device_priv(struct device *dev, void *priv) { struct rtc_device *rtc; int id, err; @@ -378,6 +378,7 @@ struct rtc_device *devm_rtc_allocate_device(struct device *dev) rtc->id = id; rtc->dev.parent = dev; + rtc->priv = priv; err = devm_add_action_or_reset(dev, devm_rtc_release_device, rtc); if (err) return ERR_PTR(err); @@ -388,6 +389,12 @@ struct rtc_device *devm_rtc_allocate_device(struct device *dev) return rtc; } +EXPORT_SYMBOL_GPL(devm_rtc_allocate_device_priv); + +struct rtc_device *devm_rtc_allocate_device(struct device *dev) +{ + return devm_rtc_allocate_device_priv(dev, NULL); +} EXPORT_SYMBOL_GPL(devm_rtc_allocate_device); int __devm_rtc_register_device(struct module *owner, struct rtc_device *rtc) diff --git a/drivers/rtc/dev.c b/drivers/rtc/dev.c index c4a3ab53dcd4b7280a3a2981fe842729603a1feb..e0e1a488b795645d7c9453490d6cdba510cc5db5 100644 --- a/drivers/rtc/dev.c +++ b/drivers/rtc/dev.c @@ -410,7 +410,8 @@ static long rtc_dev_ioctl(struct file *file, } default: if (rtc->ops->param_get) - err = rtc->ops->param_get(rtc->dev.parent, ¶m); + err = rtc->ops->param_get(rtc->priv ? + &rtc->dev : rtc->dev.parent, ¶m); else err = -EINVAL; } @@ -440,7 +441,8 @@ static long rtc_dev_ioctl(struct file *file, default: if (rtc->ops->param_set) - err = rtc->ops->param_set(rtc->dev.parent, ¶m); + err = rtc->ops->param_set(rtc->priv ? + &rtc->dev : rtc->dev.parent, ¶m); else err = -EINVAL; } @@ -450,7 +452,7 @@ static long rtc_dev_ioctl(struct file *file, default: /* Finally try the driver's ioctl interface */ if (ops->ioctl) { - err = ops->ioctl(rtc->dev.parent, cmd, arg); + err = ops->ioctl(rtc->priv ? &rtc->dev : rtc->dev.parent, cmd, arg); if (err == -ENOIOCTLCMD) err = -ENOTTY; } else { diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c index aaf76406cd7d7d2cfd5479fc1fc892fcb5efbb6b..06d51761900ee5d6cc3916d31d907505c193c6ad 100644 --- a/drivers/rtc/interface.c +++ b/drivers/rtc/interface.c @@ -91,7 +91,7 @@ static int __rtc_read_time(struct rtc_device *rtc, struct rtc_time *tm) err = -EINVAL; } else { memset(tm, 0, sizeof(struct rtc_time)); - err = rtc->ops->read_time(rtc->dev.parent, tm); + err = rtc->ops->read_time(rtc->priv ? &rtc->dev : rtc->dev.parent, tm); if (err < 0) { dev_dbg(&rtc->dev, "read_time: fail to read: %d\n", err); @@ -155,7 +155,7 @@ int rtc_set_time(struct rtc_device *rtc, struct rtc_time *tm) if (!rtc->ops) err = -ENODEV; else if (rtc->ops->set_time) - err = rtc->ops->set_time(rtc->dev.parent, tm); + err = rtc->ops->set_time(rtc->priv ? &rtc->dev : rtc->dev.parent, tm); else err = -EINVAL; @@ -200,7 +200,7 @@ static int rtc_read_alarm_internal(struct rtc_device *rtc, alarm->time.tm_wday = -1; alarm->time.tm_yday = -1; alarm->time.tm_isdst = -1; - err = rtc->ops->read_alarm(rtc->dev.parent, alarm); + err = rtc->ops->read_alarm(rtc->priv ? &rtc->dev : rtc->dev.parent, alarm); } mutex_unlock(&rtc->ops_lock); @@ -441,7 +441,7 @@ static int __rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) else if (!test_bit(RTC_FEATURE_ALARM, rtc->features)) err = -EINVAL; else - err = rtc->ops->set_alarm(rtc->dev.parent, alarm); + err = rtc->ops->set_alarm(rtc->priv ? &rtc->dev : rtc->dev.parent, alarm); trace_rtc_set_alarm(rtc_tm_to_time64(&alarm->time), err); return err; @@ -545,7 +545,7 @@ int rtc_alarm_irq_enable(struct rtc_device *rtc, unsigned int enabled) else if (!test_bit(RTC_FEATURE_ALARM, rtc->features) || !rtc->ops->alarm_irq_enable) err = -EINVAL; else - err = rtc->ops->alarm_irq_enable(rtc->dev.parent, enabled); + err = rtc->ops->alarm_irq_enable(rtc->priv ? &rtc->dev : rtc->dev.parent, enabled); mutex_unlock(&rtc->ops_lock); @@ -847,7 +847,7 @@ static void rtc_alarm_disable(struct rtc_device *rtc) if (!rtc->ops || !test_bit(RTC_FEATURE_ALARM, rtc->features) || !rtc->ops->alarm_irq_enable) return; - rtc->ops->alarm_irq_enable(rtc->dev.parent, false); + rtc->ops->alarm_irq_enable(rtc->priv ? &rtc->dev : rtc->dev.parent, false); trace_rtc_alarm_irq_enable(0, 0); } @@ -1049,7 +1049,7 @@ int rtc_read_offset(struct rtc_device *rtc, long *offset) return -EINVAL; mutex_lock(&rtc->ops_lock); - ret = rtc->ops->read_offset(rtc->dev.parent, offset); + ret = rtc->ops->read_offset(rtc->priv ? &rtc->dev : rtc->dev.parent, offset); mutex_unlock(&rtc->ops_lock); trace_rtc_read_offset(*offset, ret); @@ -1084,7 +1084,7 @@ int rtc_set_offset(struct rtc_device *rtc, long offset) return -EINVAL; mutex_lock(&rtc->ops_lock); - ret = rtc->ops->set_offset(rtc->dev.parent, offset); + ret = rtc->ops->set_offset(rtc->priv ? &rtc->dev : rtc->dev.parent, offset); mutex_unlock(&rtc->ops_lock); trace_rtc_set_offset(offset, ret); diff --git a/drivers/rtc/proc.c b/drivers/rtc/proc.c index cbcdbb19d848e78e6674bd626833151a99773ef0..94cc4f9d62b7867018d876f7933468fbd1552ffc 100644 --- a/drivers/rtc/proc.c +++ b/drivers/rtc/proc.c @@ -73,7 +73,7 @@ static int rtc_proc_show(struct seq_file *seq, void *offset) seq_printf(seq, "24hr\t\t: yes\n"); if (ops->proc) - ops->proc(rtc->dev.parent, seq); + ops->proc(rtc->priv ? &rtc->dev : rtc->dev.parent, seq); return 0; } diff --git a/include/linux/rtc.h b/include/linux/rtc.h index 3f4d315aaec9e641e35c1c86a522f2879bec19ba..a6f3c86a08e1e214062b2a68d9a6a437afb186b3 100644 --- a/include/linux/rtc.h +++ b/include/linux/rtc.h @@ -110,6 +110,7 @@ struct rtc_device { struct hrtimer pie_timer; /* sub second exp, so needs hrtimer */ int pie_enabled; struct work_struct irqwork; + void *priv; /* * This offset specifies the update timing of the RTC. @@ -182,6 +183,7 @@ extern struct rtc_device *devm_rtc_device_register(struct device *dev, const struct rtc_class_ops *ops, struct module *owner); struct rtc_device *devm_rtc_allocate_device(struct device *dev); +struct rtc_device *devm_rtc_allocate_device_priv(struct device *dev, void *priv); int __devm_rtc_register_device(struct module *owner, struct rtc_device *rtc); extern int rtc_read_time(struct rtc_device *rtc, struct rtc_time *tm);