lkml.org 
[lkml]   [2021]   [Sep]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2] drivers/cdrom: improved ioctl for media change detection
> +static int cdrom_ioctl_timed_media_change(struct cdrom_device_info *cdi,
> + unsigned long arg)
> +{
> + int ret;
> + struct cdrom_timed_media_change_info __user *info;
> + struct cdrom_timed_media_change_info tmp_info;
> +
> + if (!CDROM_CAN(CDC_MEDIA_CHANGED))
> + return -ENOSYS;
> +
> + info = (struct cdrom_timed_media_change_info __user *)arg;
> + cd_dbg(CD_DO_IOCTL, "entering CDROM_TIMED_MEDIA_CHANGE\n");
> +
> + ret = cdrom_ioctl_media_changed(cdi, CDSL_CURRENT);
> + if (ret < 0)
> + return ret;
> +
> + if (copy_from_user(&tmp_info, info, sizeof(tmp_info)) != 0)
> + return -EFAULT;
> +
> + tmp_info.has_changed = ((tmp_info.last_media_change - cdi->last_media_change_ms) < 0);

Overly long line here, but more importantly this is much cleaner with
a good old if:


if (tmp_info.last_media_change - cdi->last_media_change_ms) < 0)
tmp_info.has_changed = 1;

> +{
> + __s64 last_media_change; /* Timestamp of the last detected media
> + * change in ms. May be set by caller, updated
> + * upon successful return of ioctl.
> + */
> + __u64 has_changed; /* Set to 1 by ioctl if last detected media

More overly long lines. Also why is has_changed a u64 if it is used as
a boolean flag?

\
 
 \ /
  Last update: 2021-09-07 08:37    [W:0.135 / U:0.048 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site