@@ -190,15 +190,6 @@ static struct attribute *kobj_pkt_attrs_wqueue[] = {
190190 NULL
191191};
192192
193- /* declares a char buffer[64] _dbuf, copies data from
194- * _b with length _l into it and ensures that _dbuf ends
195- * with a \0 character.
196- */
197- #define DECLARE_BUF_AS_STRING (_dbuf , _b , _l ) \
198- char _dbuf[64]; int dlen = (_l) < 0 ? 0 : (_l); \
199- if (dlen >= sizeof(_dbuf)) dlen = sizeof(_dbuf)-1; \
200- memcpy(_dbuf, _b, dlen); _dbuf[dlen] = 0
201-
202193static ssize_t kobj_pkt_show (struct kobject * kobj ,
203194 struct attribute * attr , char * data )
204195{
@@ -264,25 +255,24 @@ static ssize_t kobj_pkt_store(struct kobject *kobj,
264255{
265256 struct pktcdvd_device * pd = to_pktcdvdkobj (kobj )-> pd ;
266257 int val ;
267- DECLARE_BUF_AS_STRING (dbuf , data , len ); /* ensure sscanf scans a string */
268258
269- if (strcmp (attr -> name , "reset" ) == 0 && dlen > 0 ) {
259+ if (strcmp (attr -> name , "reset" ) == 0 && len > 0 ) {
270260 pd -> stats .pkt_started = 0 ;
271261 pd -> stats .pkt_ended = 0 ;
272262 pd -> stats .secs_w = 0 ;
273263 pd -> stats .secs_rg = 0 ;
274264 pd -> stats .secs_r = 0 ;
275265
276266 } else if (strcmp (attr -> name , "congestion_off" ) == 0
277- && sscanf (dbuf , "%d" , & val ) == 1 ) {
267+ && sscanf (data , "%d" , & val ) == 1 ) {
278268 spin_lock (& pd -> lock );
279269 pd -> write_congestion_off = val ;
280270 init_write_congestion_marks (& pd -> write_congestion_off ,
281271 & pd -> write_congestion_on );
282272 spin_unlock (& pd -> lock );
283273
284274 } else if (strcmp (attr -> name , "congestion_on" ) == 0
285- && sscanf (dbuf , "%d" , & val ) == 1 ) {
275+ && sscanf (data , "%d" , & val ) == 1 ) {
286276 spin_lock (& pd -> lock );
287277 pd -> write_congestion_on = val ;
288278 init_write_congestion_marks (& pd -> write_congestion_off ,
@@ -369,8 +359,7 @@ static ssize_t class_pktcdvd_store_add(struct class *c, const char *buf,
369359 size_t count )
370360{
371361 unsigned int major , minor ;
372- DECLARE_BUF_AS_STRING (dbuf , buf , count );
373- if (sscanf (dbuf , "%u:%u" , & major , & minor ) == 2 ) {
362+ if (sscanf (buf , "%u:%u" , & major , & minor ) == 2 ) {
374363 pkt_setup_dev (MKDEV (major , minor ), NULL );
375364 return count ;
376365 }
@@ -381,8 +370,7 @@ static ssize_t class_pktcdvd_store_remove(struct class *c, const char *buf,
381370 size_t count )
382371{
383372 unsigned int major , minor ;
384- DECLARE_BUF_AS_STRING (dbuf , buf , count );
385- if (sscanf (dbuf , "%u:%u" , & major , & minor ) == 2 ) {
373+ if (sscanf (buf , "%u:%u" , & major , & minor ) == 2 ) {
386374 pkt_remove_dev (MKDEV (major , minor ));
387375 return count ;
388376 }
@@ -1377,7 +1365,7 @@ static int pkt_handle_queue(struct pktcdvd_device *pd)
13771365 && pd -> bio_queue_size <= pd -> write_congestion_off );
13781366 spin_unlock (& pd -> lock );
13791367 if (wakeup )
1380- blk_clear_queue_congested ( pd -> disk -> queue , WRITE );
1368+ clear_bdi_congested ( & pd -> disk -> queue -> backing_dev_info , WRITE );
13811369
13821370 pkt -> sleep_time = max (PACKET_WAIT_TIME , 1 );
13831371 pkt_set_state (pkt , PACKET_WAITING_STATE );
@@ -2598,7 +2586,7 @@ static int pkt_make_request(request_queue_t *q, struct bio *bio)
25982586 spin_lock (& pd -> lock );
25992587 if (pd -> write_congestion_on > 0
26002588 && pd -> bio_queue_size >= pd -> write_congestion_on ) {
2601- blk_set_queue_congested ( q , WRITE );
2589+ set_bdi_congested ( & q -> backing_dev_info , WRITE );
26022590 do {
26032591 spin_unlock (& pd -> lock );
26042592 congestion_wait (WRITE , HZ );
0 commit comments