Message ID | 20250410070623.3676647-1-sakari.ailus@linux.intel.com (mailing list archive) |
---|---|
Headers | show |
Series | Use a local device pointer for hwrng drivers instead of casting constantly | expand |
On Thu, Apr 10, 2025 at 10:06:21AM +0300, Sakari Ailus wrote: > Add a local variable for a struct device pointer instead of obtaining the > hwrng priv field and casting it as a struct device pointer whenever it's > needed. > > Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> > --- > drivers/char/hw_random/atmel-rng.c | 9 +++++---- > 1 file changed, 5 insertions(+), 4 deletions(-) > > diff --git a/drivers/char/hw_random/atmel-rng.c b/drivers/char/hw_random/atmel-rng.c > index 143406bc6939..5192c39ebaeb 100644 > --- a/drivers/char/hw_random/atmel-rng.c > +++ b/drivers/char/hw_random/atmel-rng.c > @@ -56,12 +56,13 @@ static int atmel_trng_read(struct hwrng *rng, void *buf, size_t max, > bool wait) > { > struct atmel_trng *trng = container_of(rng, struct atmel_trng, rng); > + struct device *dev = (struct device *)trng->rng.priv; Please stop using the priv field and instead add a struct device pointer to struct atmel_trng. Thanks,
Hi Herbert, On Thu, Apr 10, 2025 at 03:42:53PM +0800, Herbert Xu wrote: > On Thu, Apr 10, 2025 at 10:06:21AM +0300, Sakari Ailus wrote: > > Add a local variable for a struct device pointer instead of obtaining the > > hwrng priv field and casting it as a struct device pointer whenever it's > > needed. > > > > Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> > > --- > > drivers/char/hw_random/atmel-rng.c | 9 +++++---- > > 1 file changed, 5 insertions(+), 4 deletions(-) > > > > diff --git a/drivers/char/hw_random/atmel-rng.c b/drivers/char/hw_random/atmel-rng.c > > index 143406bc6939..5192c39ebaeb 100644 > > --- a/drivers/char/hw_random/atmel-rng.c > > +++ b/drivers/char/hw_random/atmel-rng.c > > @@ -56,12 +56,13 @@ static int atmel_trng_read(struct hwrng *rng, void *buf, size_t max, > > bool wait) > > { > > struct atmel_trng *trng = container_of(rng, struct atmel_trng, rng); > > + struct device *dev = (struct device *)trng->rng.priv; > > Please stop using the priv field and instead add a struct device > pointer to struct atmel_trng. Thanks for the review. I'll do that in v2.