public inbox for linux-rtc@vger.kernel.org
 help / color / mirror / Atom feed
From: "Danilo Krummrich" <dakr@kernel.org>
To: "Alexandre Belloni" <alexandre.belloni@bootlin.com>
Cc: "Ke Sun" <sunke@kylinos.cn>, "Miguel Ojeda" <ojeda@kernel.org>,
	"Boqun Feng" <boqun.feng@gmail.com>,
	"Gary Guo" <gary@garyguo.net>,
	"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
	"Benno Lossin" <lossin@kernel.org>,
	"Andreas Hindborg" <a.hindborg@kernel.org>,
	"Alice Ryhl" <aliceryhl@google.com>,
	"Trevor Gross" <tmgross@umich.edu>,
	linux-rtc@vger.kernel.org, rust-for-linux@vger.kernel.org,
	"Alvin Sun" <sk.alvin.x@gmail.com>
Subject: Re: [RFC PATCH v2 1/5] rtc: migrate driver data to RTC device
Date: Thu, 08 Jan 2026 15:06:46 +0100	[thread overview]
Message-ID: <DFJ9L2GPU6WT.1RYEWZJ1V75DE@kernel.org> (raw)
In-Reply-To: <202601081401239bbfff9d@mail.local>

On Thu Jan 8, 2026 at 3:01 PM CET, Alexandre Belloni wrote:
> On 08/01/2026 14:52:08+0100, Danilo Krummrich wrote:
>> On Thu Jan 8, 2026 at 2:45 PM CET, Ke Sun wrote:
>> >
>> > On 1/8/26 19:12, Danilo Krummrich wrote:
>> >> On Wed Jan 7, 2026 at 3:37 PM CET, Ke Sun wrote:
>> >>> diff --git a/drivers/rtc/dev.c b/drivers/rtc/dev.c
>> >>> index baf1a8ca8b2b1..0f62ba9342e3e 100644
>> >>> --- a/drivers/rtc/dev.c
>> >>> +++ b/drivers/rtc/dev.c
>> >>> @@ -410,7 +410,7 @@ static long rtc_dev_ioctl(struct file *file,
>> >>>   		}
>> >>>   		default:
>> >>>   			if (rtc->ops->param_get)
>> >>> -				err = rtc->ops->param_get(rtc->dev.parent, &param);
>> >>> +				err = rtc->ops->param_get(&rtc->dev, &param);
>> >> It would make more sense to just pass a struct rtc_device than the embedded
>> >> struct device in the RTC callbacks.
>> > I considered passing struct rtc_device directly, but chose &rtc->dev
>> > to minimize changes to existing drivers, since most callbacks use
>> > dev_get_drvdata() on the device parameter.
>> 
>> No, you should not expose the embedded base device. For accessing the private
>> data you should add helpers like rtc_get_drvdata(). This is what other
>> subsystems do as well, e.g. [1].
>> 
>> [1] https://elixir.bootlin.com/linux/v6.18.3/source/include/linux/i2c.h#L371
>
> This is not a correct example as i2c is a bus, just like amba is...

Yes, struct i2c_client is indeed a bus device. However, the core struct device
is what holds the device private data commonly in the same way, regardless of
whether it is embedded in a bus or class device.

If you look for a class device example, here's PWM [2] and input [3].

[2] https://elixir.bootlin.com/linux/v6.18.3/source/include/linux/pwm.h#L382
[3] https://elixir.bootlin.com/linux/v6.18.3/source/include/linux/input.h#L388

> Actually, I don't think the rework is necessary at all or this would
> mean we need to rewor most of our existing subsystems.

That's not true, subsystems do not pass the parent device (i.e. the bus device)
through their class device callbacks exclusively.

- Danilo

  reply	other threads:[~2026-01-08 14:06 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-07 14:37 [RFC PATCH v2 0/5] rust: Add RTC driver support Ke Sun
2026-01-07 14:37 ` [RFC PATCH v2 1/5] rtc: migrate driver data to RTC device Ke Sun
2026-01-07 14:41   ` Ke Sun
2026-01-07 16:12   ` Greg KH
2026-01-07 23:18     ` Ke Sun
2026-01-08  0:24       ` Ke Sun
2026-01-08 11:06         ` Danilo Krummrich
2026-01-08  5:46       ` Greg KH
2026-01-08  9:02         ` Ke Sun
2026-01-08  9:10           ` Greg KH
2026-01-08 11:12   ` Danilo Krummrich
2026-01-08 13:45     ` Ke Sun
2026-01-08 13:52       ` Danilo Krummrich
2026-01-08 14:01         ` Ke Sun
2026-01-08 14:01         ` Alexandre Belloni
2026-01-08 14:06           ` Danilo Krummrich [this message]
2026-02-20 23:19             ` Alexandre Belloni
2026-01-14 23:23           ` Ke Sun
2026-01-14 23:48             ` Danilo Krummrich
2026-01-07 14:37 ` [RFC PATCH v2 2/5] rust: add AMBA bus driver support Ke Sun
2026-01-08 11:29   ` Danilo Krummrich
2026-01-07 14:37 ` [RFC PATCH v2 3/5] rust: add device wakeup capability support Ke Sun
2026-01-07 14:57   ` Greg KH
2026-01-07 23:35     ` Ke Sun
2026-01-07 14:37 ` [RFC PATCH v2 4/5] rust: add RTC core abstractions and data structures Ke Sun
2026-01-08 11:50   ` Danilo Krummrich
2026-01-08 13:17     ` Ke Sun
2026-01-08 13:49       ` Miguel Ojeda
2026-01-08 13:56         ` Ke Sun
2026-01-08 23:31   ` Kari Argillander
2026-01-07 14:37 ` [RFC PATCH v2 5/5] rust: add PL031 RTC driver Ke Sun
2026-01-08 11:57   ` Danilo Krummrich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DFJ9L2GPU6WT.1RYEWZJ1V75DE@kernel.org \
    --to=dakr@kernel.org \
    --cc=a.hindborg@kernel.org \
    --cc=alexandre.belloni@bootlin.com \
    --cc=aliceryhl@google.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=gary@garyguo.net \
    --cc=linux-rtc@vger.kernel.org \
    --cc=lossin@kernel.org \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=sk.alvin.x@gmail.com \
    --cc=sunke@kylinos.cn \
    --cc=tmgross@umich.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox