diff mbox series

s390/dasd: avoid calling do_gettimeofday()

Message ID 20171106140328.1498644-1-arnd@arndb.de
State Accepted
Commit 399c5acd5837f6c93d784d8dd25ebae5a50362e1
Headers show
Series s390/dasd: avoid calling do_gettimeofday() | expand

Commit Message

Arnd Bergmann Nov. 6, 2017, 2:02 p.m. UTC
do_gettimeofday() is deprecated because it's not y2038-safe on
32-bit architectures. Since it is basically a wrapper around
ktime_get_real_ts64(), we can just call that function directly
instead.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>

---
 drivers/s390/block/dasd_eer.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

-- 
2.9.0

Comments

Stefan Haberland Nov. 8, 2017, 1:27 p.m. UTC | #1
On 06.11.2017 15:02, Arnd Bergmann wrote:
> do_gettimeofday() is deprecated because it's not y2038-safe on

> 32-bit architectures. Since it is basically a wrapper around

> ktime_get_real_ts64(), we can just call that function directly

> instead.

>

> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

> ---

>   drivers/s390/block/dasd_eer.c | 16 ++++++++--------

>   1 file changed, 8 insertions(+), 8 deletions(-)

>

> diff --git a/drivers/s390/block/dasd_eer.c b/drivers/s390/block/dasd_eer.c

> index 4630782b5456..5169c717c9d6 100644

> --- a/drivers/s390/block/dasd_eer.c

> +++ b/drivers/s390/block/dasd_eer.c

> @@ -296,7 +296,7 @@ static void dasd_eer_write_standard_trigger(struct dasd_device *device,

>   {

>   	struct dasd_ccw_req *temp_cqr;

>   	int data_size;

> -	struct timeval tv;

> +	struct timespec64 ts64;

...
> +	ktime_get_real_ts64(&ts);

> +	header.tv_sec = ts.tv_sec;

> +	header.tv_usec = ts.tv_nsec / NSEC_PER_USEC;

>


I renamed ts64 to ts to match the usage below and fix the compile error.

Beside of this, applied. Thanks for the patch.
Arnd Bergmann Nov. 8, 2017, 1:56 p.m. UTC | #2
On Wed, Nov 8, 2017 at 2:27 PM, Stefan Haberland <sth@linux.vnet.ibm.com> wrote:
> On 06.11.2017 15:02, Arnd Bergmann wrote:

>> diff --git a/drivers/s390/block/dasd_eer.c b/drivers/s390/block/dasd_eer.c

>> index 4630782b5456..5169c717c9d6 100644

>> --- a/drivers/s390/block/dasd_eer.c

>> +++ b/drivers/s390/block/dasd_eer.c

>> @@ -296,7 +296,7 @@ static void dasd_eer_write_standard_trigger(struct

>> dasd_device *device,

>>   {

>>         struct dasd_ccw_req *temp_cqr;

>>         int data_size;

>> -       struct timeval tv;

>> +       struct timespec64 ts64;

>

> ...

>>

>> +       ktime_get_real_ts64(&ts);

>> +       header.tv_sec = ts.tv_sec;

>> +       header.tv_usec = ts.tv_nsec / NSEC_PER_USEC;

>>

>

> I renamed ts64 to ts to match the usage below and fix the compile error.

>

> Beside of this, applied. Thanks for the patch.

>


Thanks and sorry for not build-testing it properly, I thought I had at
least compiled
this one separately with my cross-toolchain, but maybe I renamed the variable
after testing it, or I misremember testing it.

        Arnd
kernel test robot Nov. 8, 2017, 3:47 p.m. UTC | #3
Hi Arnd,

I love your patch! Yet something to improve:

[auto build test ERROR on s390/features]
[also build test ERROR on v4.14-rc8 next-20171108]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Arnd-Bergmann/s390-dasd-avoid-calling-do_gettimeofday/20171108-213507
base:   https://git.kernel.org/pub/scm/linux/kernel/git/s390/linux.git features
config: s390-default_defconfig (attached as .config)
compiler: s390x-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=s390 

All errors (new ones prefixed by >>):

   In file included from include/linux/ktime.h:272:0,
                    from include/linux/timer.h:5,
                    from include/linux/workqueue.h:8,
                    from include/linux/srcu.h:34,
                    from include/linux/notifier.h:15,
                    from arch/s390/include/asm/uprobes.h:11,
                    from include/linux/uprobes.h:62,
                    from include/linux/mm_types.h:13,
                    from include/linux/fs.h:21,
                    from drivers/s390/block/dasd_eer.c:12:
   drivers/s390/block/dasd_eer.c: In function 'dasd_eer_write_standard_trigger':
>> drivers/s390/block/dasd_eer.c:312:23: error: 'ts' undeclared (first use in this function)

     ktime_get_real_ts64(&ts);
                          ^
   include/linux/timekeeping.h:160:50: note: in definition of macro 'ktime_get_real_ts64'
    #define ktime_get_real_ts64(ts) getnstimeofday64(ts)
                                                     ^~
   drivers/s390/block/dasd_eer.c:312:23: note: each undeclared identifier is reported only once for each function it appears in
     ktime_get_real_ts64(&ts);
                          ^
   include/linux/timekeeping.h:160:50: note: in definition of macro 'ktime_get_real_ts64'
    #define ktime_get_real_ts64(ts) getnstimeofday64(ts)
                                                     ^~
   drivers/s390/block/dasd_eer.c:298:20: warning: unused variable 'ts64' [-Wunused-variable]
     struct timespec64 ts64;
                       ^~~~

vim +/ts +312 drivers/s390/block/dasd_eer.c

   284	
   285	/*
   286	 * The following function can be used for those triggers that have
   287	 * all necessary data available when the function is called.
   288	 * If the parameter cqr is not NULL, the chain of requests will be searched
   289	 * for valid sense data, and all valid sense data sets will be added to
   290	 * the triggers data.
   291	 */
   292	static void dasd_eer_write_standard_trigger(struct dasd_device *device,
   293						    struct dasd_ccw_req *cqr,
   294						    int trigger)
   295	{
   296		struct dasd_ccw_req *temp_cqr;
   297		int data_size;
   298		struct timespec64 ts64;
   299		struct dasd_eer_header header;
   300		unsigned long flags;
   301		struct eerbuffer *eerb;
   302		char *sense;
   303	
   304		/* go through cqr chain and count the valid sense data sets */
   305		data_size = 0;
   306		for (temp_cqr = cqr; temp_cqr; temp_cqr = temp_cqr->refers)
   307			if (dasd_get_sense(&temp_cqr->irb))
   308				data_size += 32;
   309	
   310		header.total_size = sizeof(header) + data_size + 4; /* "EOR" */
   311		header.trigger = trigger;
 > 312		ktime_get_real_ts64(&ts);

   313		header.tv_sec = ts.tv_sec;
   314		header.tv_usec = ts.tv_nsec / NSEC_PER_USEC;
   315		strncpy(header.busid, dev_name(&device->cdev->dev),
   316			DASD_EER_BUSID_SIZE);
   317	
   318		spin_lock_irqsave(&bufferlock, flags);
   319		list_for_each_entry(eerb, &bufferlist, list) {
   320			dasd_eer_start_record(eerb, header.total_size);
   321			dasd_eer_write_buffer(eerb, (char *) &header, sizeof(header));
   322			for (temp_cqr = cqr; temp_cqr; temp_cqr = temp_cqr->refers) {
   323				sense = dasd_get_sense(&temp_cqr->irb);
   324				if (sense)
   325					dasd_eer_write_buffer(eerb, sense, 32);
   326			}
   327			dasd_eer_write_buffer(eerb, "EOR", 4);
   328		}
   329		spin_unlock_irqrestore(&bufferlock, flags);
   330		wake_up_interruptible(&dasd_eer_read_wait_queue);
   331	}
   332	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
diff mbox series

Patch

diff --git a/drivers/s390/block/dasd_eer.c b/drivers/s390/block/dasd_eer.c
index 4630782b5456..5169c717c9d6 100644
--- a/drivers/s390/block/dasd_eer.c
+++ b/drivers/s390/block/dasd_eer.c
@@ -296,7 +296,7 @@  static void dasd_eer_write_standard_trigger(struct dasd_device *device,
 {
 	struct dasd_ccw_req *temp_cqr;
 	int data_size;
-	struct timeval tv;
+	struct timespec64 ts64;
 	struct dasd_eer_header header;
 	unsigned long flags;
 	struct eerbuffer *eerb;
@@ -310,9 +310,9 @@  static void dasd_eer_write_standard_trigger(struct dasd_device *device,
 
 	header.total_size = sizeof(header) + data_size + 4; /* "EOR" */
 	header.trigger = trigger;
-	do_gettimeofday(&tv);
-	header.tv_sec = tv.tv_sec;
-	header.tv_usec = tv.tv_usec;
+	ktime_get_real_ts64(&ts);
+	header.tv_sec = ts.tv_sec;
+	header.tv_usec = ts.tv_nsec / NSEC_PER_USEC;
 	strncpy(header.busid, dev_name(&device->cdev->dev),
 		DASD_EER_BUSID_SIZE);
 
@@ -340,7 +340,7 @@  static void dasd_eer_write_snss_trigger(struct dasd_device *device,
 {
 	int data_size;
 	int snss_rc;
-	struct timeval tv;
+	struct timespec64 ts;
 	struct dasd_eer_header header;
 	unsigned long flags;
 	struct eerbuffer *eerb;
@@ -353,9 +353,9 @@  static void dasd_eer_write_snss_trigger(struct dasd_device *device,
 
 	header.total_size = sizeof(header) + data_size + 4; /* "EOR" */
 	header.trigger = DASD_EER_STATECHANGE;
-	do_gettimeofday(&tv);
-	header.tv_sec = tv.tv_sec;
-	header.tv_usec = tv.tv_usec;
+	ktime_get_real_ts64(&ts);
+	header.tv_sec = ts.tv_sec;
+	header.tv_usec = ts.tv_nsec / NSEC_PER_USEC;
 	strncpy(header.busid, dev_name(&device->cdev->dev),
 		DASD_EER_BUSID_SIZE);